@Test public void testSelectionOnly() { List<SegmentDataManager> segmentDataManagers = Arrays .asList(getSegmentDataManager(null, null, 10), getSegmentDataManager(0L, 10L, 10), getSegmentDataManager(-5L, 5L, 15)); ServerQueryRequest queryRequest = getQueryRequest("SELECT * FROM testTable LIMIT 5"); List<SegmentDataManager> result = _segmentPruner.prune(_tableDataManager, segmentDataManagers, queryRequest); assertEquals(result.size(), 1); assertSame(result.get(0), segmentDataManagers.get(0)); queryRequest = getQueryRequest("SELECT * FROM testTable LIMIT 10"); result = _segmentPruner.prune(_tableDataManager, segmentDataManagers, queryRequest); assertEquals(result.size(), 1); assertSame(result.get(0), segmentDataManagers.get(0)); queryRequest = getQueryRequest("SELECT * FROM testTable LIMIT 15"); result = _segmentPruner.prune(_tableDataManager, segmentDataManagers, queryRequest); assertEquals(result.size(), 2); assertSame(result.get(0), segmentDataManagers.get(0)); assertSame(result.get(1), segmentDataManagers.get(1)); queryRequest = getQueryRequest("SELECT * FROM testTable LIMIT 25"); result = _segmentPruner.prune(_tableDataManager, segmentDataManagers, queryRequest); assertEquals(result.size(), 3); assertSame(result.get(0), segmentDataManagers.get(0)); assertSame(result.get(1), segmentDataManagers.get(1)); assertSame(result.get(2), segmentDataManagers.get(2)); queryRequest = getQueryRequest("SELECT * FROM testTable LIMIT 100"); result = _segmentPruner.prune(_tableDataManager, segmentDataManagers, queryRequest); assertEquals(result.size(), 3); assertSame(result.get(0), segmentDataManagers.get(0)); assertSame(result.get(1), segmentDataManagers.get(1)); assertSame(result.get(2), segmentDataManagers.get(2)); }
@Override public List<SegmentDataManager> prune(TableDataManager tableDataManager, List<SegmentDataManager> segmentDataManagers, ServerQueryRequest queryRequest) { int numSegments = segmentDataManagers.size(); if (numSegments == 0) { return Collections.emptyList(); } QueryContext queryContext = queryRequest.getQueryContext(); if (QueryContextUtils.isAggregationQuery(queryContext)) { return segmentDataManagers; } int limit = queryContext.getLimit(); if (limit == 0) { for (int i = 1; i < numSegments; i++) { tableDataManager.releaseSegment(segmentDataManagers.get(i)); } return Collections.singletonList(segmentDataManagers.get(0)); } FilterContext filter = queryContext.getFilter(); if (filter != null) { return segmentDataManagers; } if (queryContext.getOrderByExpressions() == null) { return pruneSelectionOnly(tableDataManager, segmentDataManagers, queryContext); } else { return pruneSelectionOrderBy(tableDataManager, segmentDataManagers, queryContext); } }
SelectionQuerySegmentPruner implements SegmentPruner { @Override public List<SegmentDataManager> prune(TableDataManager tableDataManager, List<SegmentDataManager> segmentDataManagers, ServerQueryRequest queryRequest) { int numSegments = segmentDataManagers.size(); if (numSegments == 0) { return Collections.emptyList(); } QueryContext queryContext = queryRequest.getQueryContext(); if (QueryContextUtils.isAggregationQuery(queryContext)) { return segmentDataManagers; } int limit = queryContext.getLimit(); if (limit == 0) { for (int i = 1; i < numSegments; i++) { tableDataManager.releaseSegment(segmentDataManagers.get(i)); } return Collections.singletonList(segmentDataManagers.get(0)); } FilterContext filter = queryContext.getFilter(); if (filter != null) { return segmentDataManagers; } if (queryContext.getOrderByExpressions() == null) { return pruneSelectionOnly(tableDataManager, segmentDataManagers, queryContext); } else { return pruneSelectionOrderBy(tableDataManager, segmentDataManagers, queryContext); } } }
SelectionQuerySegmentPruner implements SegmentPruner { @Override public List<SegmentDataManager> prune(TableDataManager tableDataManager, List<SegmentDataManager> segmentDataManagers, ServerQueryRequest queryRequest) { int numSegments = segmentDataManagers.size(); if (numSegments == 0) { return Collections.emptyList(); } QueryContext queryContext = queryRequest.getQueryContext(); if (QueryContextUtils.isAggregationQuery(queryContext)) { return segmentDataManagers; } int limit = queryContext.getLimit(); if (limit == 0) { for (int i = 1; i < numSegments; i++) { tableDataManager.releaseSegment(segmentDataManagers.get(i)); } return Collections.singletonList(segmentDataManagers.get(0)); } FilterContext filter = queryContext.getFilter(); if (filter != null) { return segmentDataManagers; } if (queryContext.getOrderByExpressions() == null) { return pruneSelectionOnly(tableDataManager, segmentDataManagers, queryContext); } else { return pruneSelectionOrderBy(tableDataManager, segmentDataManagers, queryContext); } }  }
SelectionQuerySegmentPruner implements SegmentPruner { @Override public List<SegmentDataManager> prune(TableDataManager tableDataManager, List<SegmentDataManager> segmentDataManagers, ServerQueryRequest queryRequest) { int numSegments = segmentDataManagers.size(); if (numSegments == 0) { return Collections.emptyList(); } QueryContext queryContext = queryRequest.getQueryContext(); if (QueryContextUtils.isAggregationQuery(queryContext)) { return segmentDataManagers; } int limit = queryContext.getLimit(); if (limit == 0) { for (int i = 1; i < numSegments; i++) { tableDataManager.releaseSegment(segmentDataManagers.get(i)); } return Collections.singletonList(segmentDataManagers.get(0)); } FilterContext filter = queryContext.getFilter(); if (filter != null) { return segmentDataManagers; } if (queryContext.getOrderByExpressions() == null) { return pruneSelectionOnly(tableDataManager, segmentDataManagers, queryContext); } else { return pruneSelectionOrderBy(tableDataManager, segmentDataManagers, queryContext); } }  @Override void init(PinotConfiguration config); @Override List<SegmentDataManager> prune(TableDataManager tableDataManager, List<SegmentDataManager> segmentDataManagers,
      ServerQueryRequest queryRequest); }
SelectionQuerySegmentPruner implements SegmentPruner { @Override public List<SegmentDataManager> prune(TableDataManager tableDataManager, List<SegmentDataManager> segmentDataManagers, ServerQueryRequest queryRequest) { int numSegments = segmentDataManagers.size(); if (numSegments == 0) { return Collections.emptyList(); } QueryContext queryContext = queryRequest.getQueryContext(); if (QueryContextUtils.isAggregationQuery(queryContext)) { return segmentDataManagers; } int limit = queryContext.getLimit(); if (limit == 0) { for (int i = 1; i < numSegments; i++) { tableDataManager.releaseSegment(segmentDataManagers.get(i)); } return Collections.singletonList(segmentDataManagers.get(0)); } FilterContext filter = queryContext.getFilter(); if (filter != null) { return segmentDataManagers; } if (queryContext.getOrderByExpressions() == null) { return pruneSelectionOnly(tableDataManager, segmentDataManagers, queryContext); } else { return pruneSelectionOrderBy(tableDataManager, segmentDataManagers, queryContext); } }  @Override void init(PinotConfiguration config); @Override List<SegmentDataManager> prune(TableDataManager tableDataManager, List<SegmentDataManager> segmentDataManagers,
      ServerQueryRequest queryRequest);  }