|
98 | 98 | import java.util.Map; |
99 | 99 | import java.util.Map.Entry; |
100 | 100 | import java.util.Objects; |
101 | | -import java.util.Optional; |
102 | 101 | import java.util.Set; |
103 | 102 | import java.util.concurrent.TimeUnit; |
104 | 103 | import java.util.concurrent.TimeoutException; |
@@ -825,33 +824,21 @@ private RowRanges getRowRanges(int blockIndex) { |
825 | 824 | } |
826 | 825 |
|
827 | 826 | private RowRanges calculateRowRanges(int blockIndex, RoaringBitmap32 selection) { |
828 | | - List<OffsetIndex> offsets; |
829 | 827 | BlockMetaData block = blocks.get(blockIndex); |
830 | | - if (paths.isEmpty()) { |
831 | | - Optional<ColumnChunkMetaData> first = block.getColumns().stream().findFirst(); |
832 | | - if (first.isPresent()) { |
833 | | - ColumnPath path = first.get().getPath(); |
834 | | - OffsetIndex index = |
835 | | - ColumnIndexStoreImpl.create(this, block, Collections.singleton(path)) |
836 | | - .getOffsetIndex(path); |
837 | | - offsets = Collections.singletonList(index); |
838 | | - } else { |
839 | | - offsets = Collections.emptyList(); |
840 | | - } |
841 | | - } else { |
842 | | - ColumnIndexStore store = getColumnIndexStore(blockIndex); |
843 | | - offsets = |
844 | | - paths.keySet().stream().map(store::getOffsetIndex).collect(Collectors.toList()); |
845 | | - } |
| 828 | + ColumnIndexStore store = getColumnIndexStore(blockIndex); |
| 829 | + List<OffsetIndex> offsets = |
| 830 | + paths.keySet().stream() |
| 831 | + .map(store::getOffsetIndex) |
| 832 | + .filter(Objects::nonNull) |
| 833 | + .collect(Collectors.toList()); |
846 | 834 |
|
847 | 835 | long rowCount = block.getRowCount(); |
848 | 836 | long rowIndexOffset = block.getRowIndexOffset(); |
849 | 837 | RowRanges rowRanges = RowRanges.createSingle(rowCount); |
850 | 838 | for (OffsetIndex offset : offsets) { |
851 | | - if (offset != null) { |
852 | | - RowRanges result = RowRanges.create(rowCount, rowIndexOffset, offset, selection); |
853 | | - rowRanges = RowRanges.intersection(result, rowRanges); |
854 | | - } |
| 839 | + // avoiding creating too many ranges, just filter columns pages |
| 840 | + RowRanges result = RowRanges.create(rowCount, rowIndexOffset, offset, selection); |
| 841 | + rowRanges = RowRanges.intersection(result, rowRanges); |
855 | 842 | } |
856 | 843 |
|
857 | 844 | return rowRanges; |
|
0 commit comments