Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import io.druid.collections.OrderedMergeSequence;
import io.druid.common.guava.CombiningSequence;
import io.druid.common.utils.JodaUtils;
import io.druid.data.input.Row;
import io.druid.query.CacheStrategy;
import io.druid.query.DruidMetrics;
import io.druid.query.Query;
Expand All @@ -53,6 +52,7 @@

import javax.annotation.Nullable;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -149,7 +149,7 @@ public SegmentAnalysis apply(SegmentAnalysis arg1, SegmentAnalysis arg2)

List<Interval> newIntervals = null;
if (query.hasInterval()) {
newIntervals = arg1.getIntervals();
newIntervals = new ArrayList<>(arg1.getIntervals());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is just that the List returned by arg1.getIntervals() is immutable , so it was failing with UnsupportedOperationException. I was probably biased and "thought" that the explanation was trivial so dint add the comment... will add it to make it clear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newIntervals.addAll(arg2.getIntervals());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,53 @@ public void testSegmentMetadataQuery()
Assert.assertEquals(Arrays.asList(expectedSegmentAnalysis), results);
}

@Test
public void testSegmentMetadataQueryWithDefaultAnalysisMerge()
{
SegmentAnalysis mergedSegmentAnalysis = new SegmentAnalysis(
"merged",
ImmutableList.of(
expectedSegmentAnalysis.getIntervals().get(0),
expectedSegmentAnalysis.getIntervals().get(0)
),
ImmutableMap.of(
"placement",
new ColumnAnalysis(
ValueType.STRING.toString(),
21762,
1,
null
)
),
expectedSegmentAnalysis.getSize()*2,
expectedSegmentAnalysis.getNumRows()*2
);

QueryToolChest toolChest = factory.getToolchest();

QueryRunner singleSegmentQueryRunner = toolChest.preMergeQueryDecoration(runner);
ExecutorService exec = Executors.newCachedThreadPool();
QueryRunner myRunner = new FinalizeResultsQueryRunner<>(
toolChest.mergeResults(
factory.mergeRunners(
Executors.newCachedThreadPool(),
Lists.<QueryRunner<SegmentAnalysis>>newArrayList(singleSegmentQueryRunner, singleSegmentQueryRunner)
)
),
toolChest
);

TestHelper.assertExpectedObjects(
ImmutableList.of(mergedSegmentAnalysis),
myRunner.run(
testQuery,
Maps.newHashMap()
),
"failed SegmentMetadata bySegment query"
);
exec.shutdownNow();
}

@Test
public void testBySegmentResults()
{
Expand Down