mirror of https://github.com/apache/druid.git
Improve filtering of segments for dataSourceMetadataQuery
dataSourceMetadataQuery only needs to be executed on latest segments at present, modify filterSegments and add test.
This commit is contained in:
parent
f73f14ab91
commit
bb8c0cb50b
|
@ -58,7 +58,6 @@ public class DataSourceQueryQueryToolChest
|
||||||
return segments;
|
return segments;
|
||||||
}
|
}
|
||||||
|
|
||||||
final T min = segments.get(0);
|
|
||||||
final T max = segments.get(segments.size() - 1);
|
final T max = segments.get(segments.size() - 1);
|
||||||
|
|
||||||
return Lists.newArrayList(
|
return Lists.newArrayList(
|
||||||
|
@ -69,8 +68,7 @@ public class DataSourceQueryQueryToolChest
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(T input)
|
public boolean apply(T input)
|
||||||
{
|
{
|
||||||
return (min != null && input.getInterval().overlaps(min.getInterval())) ||
|
return max != null && input.getInterval().overlaps(max.getInterval());
|
||||||
(max != null && input.getInterval().overlaps(max.getInterval()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -35,7 +35,6 @@ import io.druid.query.QueryRunnerTestHelper;
|
||||||
import io.druid.query.Result;
|
import io.druid.query.Result;
|
||||||
import io.druid.query.aggregation.AggregatorFactory;
|
import io.druid.query.aggregation.AggregatorFactory;
|
||||||
import io.druid.query.aggregation.CountAggregatorFactory;
|
import io.druid.query.aggregation.CountAggregatorFactory;
|
||||||
import io.druid.query.timeboundary.TimeBoundaryQueryQueryToolChest;
|
|
||||||
import io.druid.segment.IncrementalIndexSegment;
|
import io.druid.segment.IncrementalIndexSegment;
|
||||||
import io.druid.segment.incremental.IncrementalIndex;
|
import io.druid.segment.incremental.IncrementalIndex;
|
||||||
import io.druid.segment.incremental.OnheapIncrementalIndex;
|
import io.druid.segment.incremental.OnheapIncrementalIndex;
|
||||||
|
@ -142,9 +141,25 @@ public class DataSourceMetadataQueryTest
|
||||||
@Test
|
@Test
|
||||||
public void testFilterSegments()
|
public void testFilterSegments()
|
||||||
{
|
{
|
||||||
List<LogicalSegment> segments = new TimeBoundaryQueryQueryToolChest().filterSegments(
|
List<LogicalSegment> segments = new DataSourceQueryQueryToolChest().filterSegments(
|
||||||
null,
|
null,
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
|
new LogicalSegment()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Interval getInterval()
|
||||||
|
{
|
||||||
|
return new Interval("2012-01-01/P1D");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new LogicalSegment()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Interval getInterval()
|
||||||
|
{
|
||||||
|
return new Interval("2012-01-01T01/PT1H");
|
||||||
|
}
|
||||||
|
},
|
||||||
new LogicalSegment()
|
new LogicalSegment()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -172,8 +187,8 @@ public class DataSourceMetadataQueryTest
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(segments.size(), 3);
|
Assert.assertEquals(segments.size(), 2);
|
||||||
|
// should only have the latest segments.
|
||||||
List<LogicalSegment> expected = Arrays.asList(
|
List<LogicalSegment> expected = Arrays.asList(
|
||||||
new LogicalSegment()
|
new LogicalSegment()
|
||||||
{
|
{
|
||||||
|
@ -184,14 +199,6 @@ public class DataSourceMetadataQueryTest
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new LogicalSegment()
|
new LogicalSegment()
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Interval getInterval()
|
|
||||||
{
|
|
||||||
return new Interval("2013-01-01T01/PT1H");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new LogicalSegment()
|
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public Interval getInterval()
|
public Interval getInterval()
|
||||||
|
@ -202,7 +209,7 @@ public class DataSourceMetadataQueryTest
|
||||||
);
|
);
|
||||||
|
|
||||||
for (int i = 0; i < segments.size(); i++) {
|
for (int i = 0; i < segments.size(); i++) {
|
||||||
Assert.assertEquals(segments.get(i).getInterval(), expected.get(i).getInterval());
|
Assert.assertEquals(expected.get(i).getInterval(),segments.get(i).getInterval());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue