mirror of https://github.com/apache/druid.git
Merge pull request #2409 from gianm/smq-merged-thing
SegmentMetadataQuery: Retain segment id when merging, if possible.
This commit is contained in:
commit
b1673ee90e
|
@ -329,8 +329,16 @@ public class SegmentMetadataQueryQueryToolChest extends QueryToolChest<SegmentAn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String mergedId;
|
||||||
|
|
||||||
|
if (arg1.getId() != null && arg2.getId() != null && arg1.getId().equals(arg2.getId())) {
|
||||||
|
mergedId = arg1.getId();
|
||||||
|
} else {
|
||||||
|
mergedId = "merged";
|
||||||
|
}
|
||||||
|
|
||||||
return new SegmentAnalysis(
|
return new SegmentAnalysis(
|
||||||
"merged",
|
mergedId,
|
||||||
newIntervals,
|
newIntervals,
|
||||||
columns,
|
columns,
|
||||||
arg1.getSize() + arg2.getSize(),
|
arg1.getSize() + arg2.getSize(),
|
||||||
|
|
|
@ -75,23 +75,27 @@ public class SegmentMetadataQueryTest
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static QueryRunner makeMMappedQueryRunner(
|
public static QueryRunner makeMMappedQueryRunner(
|
||||||
|
String segmentId,
|
||||||
QueryRunnerFactory factory
|
QueryRunnerFactory factory
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return QueryRunnerTestHelper.makeQueryRunner(
|
return QueryRunnerTestHelper.makeQueryRunner(
|
||||||
factory,
|
factory,
|
||||||
new QueryableIndexSegment(QueryRunnerTestHelper.segmentId, TestIndex.getMMappedTestIndex())
|
segmentId,
|
||||||
|
new QueryableIndexSegment(segmentId, TestIndex.getMMappedTestIndex())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static QueryRunner makeIncrementalIndexQueryRunner(
|
public static QueryRunner makeIncrementalIndexQueryRunner(
|
||||||
|
String segmentId,
|
||||||
QueryRunnerFactory factory
|
QueryRunnerFactory factory
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return QueryRunnerTestHelper.makeQueryRunner(
|
return QueryRunnerTestHelper.makeQueryRunner(
|
||||||
factory,
|
factory,
|
||||||
new IncrementalIndexSegment(TestIndex.getIncrementalTestIndex(), QueryRunnerTestHelper.segmentId)
|
segmentId,
|
||||||
|
new IncrementalIndexSegment(TestIndex.getIncrementalTestIndex(), segmentId)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,30 +103,36 @@ public class SegmentMetadataQueryTest
|
||||||
private final QueryRunner runner2;
|
private final QueryRunner runner2;
|
||||||
private final boolean mmap1;
|
private final boolean mmap1;
|
||||||
private final boolean mmap2;
|
private final boolean mmap2;
|
||||||
|
private final boolean differentIds;
|
||||||
private final SegmentMetadataQuery testQuery;
|
private final SegmentMetadataQuery testQuery;
|
||||||
private final SegmentAnalysis expectedSegmentAnalysis1;
|
private final SegmentAnalysis expectedSegmentAnalysis1;
|
||||||
private final SegmentAnalysis expectedSegmentAnalysis2;
|
private final SegmentAnalysis expectedSegmentAnalysis2;
|
||||||
|
|
||||||
@Parameterized.Parameters(name = "mmap1 = {0}, mmap2 = {1}")
|
@Parameterized.Parameters(name = "mmap1 = {0}, mmap2 = {1}, differentIds = {2}")
|
||||||
public static Collection<Object[]> constructorFeeder()
|
public static Collection<Object[]> constructorFeeder()
|
||||||
{
|
{
|
||||||
return ImmutableList.of(
|
return ImmutableList.of(
|
||||||
new Object[]{true, true},
|
new Object[]{true, true, false},
|
||||||
new Object[]{true, false},
|
new Object[]{true, false, false},
|
||||||
new Object[]{false, true},
|
new Object[]{false, true, false},
|
||||||
new Object[]{false, false}
|
new Object[]{false, false, false},
|
||||||
|
new Object[]{false, false, true}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SegmentMetadataQueryTest(
|
public SegmentMetadataQueryTest(
|
||||||
boolean mmap1,
|
boolean mmap1,
|
||||||
boolean mmap2
|
boolean mmap2,
|
||||||
|
boolean differentIds
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.runner1 = mmap1 ? makeMMappedQueryRunner(FACTORY) : makeIncrementalIndexQueryRunner(FACTORY);
|
final String id1 = differentIds ? "testSegment1" : "testSegment";
|
||||||
this.runner2 = mmap2 ? makeMMappedQueryRunner(FACTORY) : makeIncrementalIndexQueryRunner(FACTORY);
|
final String id2 = differentIds ? "testSegment2" : "testSegment";
|
||||||
|
this.runner1 = mmap1 ? makeMMappedQueryRunner(id1, FACTORY) : makeIncrementalIndexQueryRunner(id1, FACTORY);
|
||||||
|
this.runner2 = mmap2 ? makeMMappedQueryRunner(id2, FACTORY) : makeIncrementalIndexQueryRunner(id2, FACTORY);
|
||||||
this.mmap1 = mmap1;
|
this.mmap1 = mmap1;
|
||||||
this.mmap2 = mmap2;
|
this.mmap2 = mmap2;
|
||||||
|
this.differentIds = differentIds;
|
||||||
testQuery = Druids.newSegmentMetadataQueryBuilder()
|
testQuery = Druids.newSegmentMetadataQueryBuilder()
|
||||||
.dataSource("testing")
|
.dataSource("testing")
|
||||||
.intervals("2013/2014")
|
.intervals("2013/2014")
|
||||||
|
@ -132,7 +142,7 @@ public class SegmentMetadataQueryTest
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
expectedSegmentAnalysis1 = new SegmentAnalysis(
|
expectedSegmentAnalysis1 = new SegmentAnalysis(
|
||||||
"testSegment",
|
id1,
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
new Interval("2011-01-12T00:00:00.000Z/2011-04-15T00:00:00.001Z")
|
new Interval("2011-01-12T00:00:00.000Z/2011-04-15T00:00:00.001Z")
|
||||||
),
|
),
|
||||||
|
@ -166,7 +176,7 @@ public class SegmentMetadataQueryTest
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
expectedSegmentAnalysis2 = new SegmentAnalysis(
|
expectedSegmentAnalysis2 = new SegmentAnalysis(
|
||||||
"testSegment",
|
id2,
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
new Interval("2011-01-12T00:00:00.000Z/2011-04-15T00:00:00.001Z")
|
new Interval("2011-01-12T00:00:00.000Z/2011-04-15T00:00:00.001Z")
|
||||||
),
|
),
|
||||||
|
@ -217,7 +227,7 @@ public class SegmentMetadataQueryTest
|
||||||
public void testSegmentMetadataQueryWithHasMultipleValuesMerge()
|
public void testSegmentMetadataQueryWithHasMultipleValuesMerge()
|
||||||
{
|
{
|
||||||
SegmentAnalysis mergedSegmentAnalysis = new SegmentAnalysis(
|
SegmentAnalysis mergedSegmentAnalysis = new SegmentAnalysis(
|
||||||
"merged",
|
differentIds ? "merged" : "testSegment",
|
||||||
null,
|
null,
|
||||||
ImmutableMap.of(
|
ImmutableMap.of(
|
||||||
"placement",
|
"placement",
|
||||||
|
@ -279,7 +289,7 @@ public class SegmentMetadataQueryTest
|
||||||
public void testSegmentMetadataQueryWithComplexColumnMerge()
|
public void testSegmentMetadataQueryWithComplexColumnMerge()
|
||||||
{
|
{
|
||||||
SegmentAnalysis mergedSegmentAnalysis = new SegmentAnalysis(
|
SegmentAnalysis mergedSegmentAnalysis = new SegmentAnalysis(
|
||||||
"merged",
|
differentIds ? "merged" : "testSegment",
|
||||||
null,
|
null,
|
||||||
ImmutableMap.of(
|
ImmutableMap.of(
|
||||||
"placement",
|
"placement",
|
||||||
|
@ -341,7 +351,7 @@ public class SegmentMetadataQueryTest
|
||||||
public void testSegmentMetadataQueryWithDefaultAnalysisMerge()
|
public void testSegmentMetadataQueryWithDefaultAnalysisMerge()
|
||||||
{
|
{
|
||||||
SegmentAnalysis mergedSegmentAnalysis = new SegmentAnalysis(
|
SegmentAnalysis mergedSegmentAnalysis = new SegmentAnalysis(
|
||||||
"merged",
|
differentIds ? "merged" : "testSegment",
|
||||||
ImmutableList.of(expectedSegmentAnalysis1.getIntervals().get(0)),
|
ImmutableList.of(expectedSegmentAnalysis1.getIntervals().get(0)),
|
||||||
ImmutableMap.of(
|
ImmutableMap.of(
|
||||||
"__time",
|
"__time",
|
||||||
|
@ -405,7 +415,7 @@ public class SegmentMetadataQueryTest
|
||||||
public void testSegmentMetadataQueryWithNoAnalysisTypesMerge()
|
public void testSegmentMetadataQueryWithNoAnalysisTypesMerge()
|
||||||
{
|
{
|
||||||
SegmentAnalysis mergedSegmentAnalysis = new SegmentAnalysis(
|
SegmentAnalysis mergedSegmentAnalysis = new SegmentAnalysis(
|
||||||
"merged",
|
differentIds ? "merged" : "testSegment",
|
||||||
null,
|
null,
|
||||||
ImmutableMap.of(
|
ImmutableMap.of(
|
||||||
"placement",
|
"placement",
|
||||||
|
@ -463,7 +473,7 @@ public class SegmentMetadataQueryTest
|
||||||
expectedAggregators.put(agg.getName(), agg.getCombiningFactory());
|
expectedAggregators.put(agg.getName(), agg.getCombiningFactory());
|
||||||
}
|
}
|
||||||
SegmentAnalysis mergedSegmentAnalysis = new SegmentAnalysis(
|
SegmentAnalysis mergedSegmentAnalysis = new SegmentAnalysis(
|
||||||
"merged",
|
differentIds ? "merged" : "testSegment",
|
||||||
null,
|
null,
|
||||||
ImmutableMap.of(
|
ImmutableMap.of(
|
||||||
"placement",
|
"placement",
|
||||||
|
|
Loading…
Reference in New Issue