@Test public void testSeek() throws Exception { TreeMap<Key,Value> testData = new TreeMap<>(); genTestData(testData, 20); for (int i = 1; i <= 20; i++) { TreeMap<Key,Value> expectedData = new TreeMap<>(); genTestData(expectedData, i); LargeRowFilter lrfi = setupIterator(testData, i, IteratorScope.scan); TreeMap<Key,Value> filteredData = new TreeMap<>(); for (int j = 1; j <= i; j++) { lrfi.seek(new Range(genRow(j), genRow(j)), LocalityGroupUtil.EMPTY_CF_SET, false); while (lrfi.hasTop()) { assertEquals(genRow(j), lrfi.getTopKey().getRow().toString()); filteredData.put(lrfi.getTopKey(), lrfi.getTopValue()); lrfi.next(); } } assertEquals(expectedData, filteredData); } }
@Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { if (inclusive && !columnFamilies.contains(EMPTY)) { columnFamilies = new HashSet<>(columnFamilies); columnFamilies.add(EMPTY); dropEmptyColFams = true; } else if (!inclusive && columnFamilies.contains(EMPTY)) { columnFamilies = new HashSet<>(columnFamilies); columnFamilies.remove(EMPTY); dropEmptyColFams = true; } else { dropEmptyColFams = false; } this.range = range; this.columnFamilies = columnFamilies; this.inclusive = inclusive; if (range.getStartKey() != null) { Range newRange = new Range(new Key(range.getStartKey().getRow()), true, range.getEndKey(), range.isEndKeyInclusive()); source.seek(newRange, columnFamilies, inclusive); readNextRow(); while (currentPosition < keys.size() && range.beforeStartKey(keys.get(currentPosition))) currentPosition++; if (currentPosition == keys.size()) readNextRow(); } else { source.seek(range, columnFamilies, inclusive); readNextRow(); } }
LargeRowFilter implements SortedKeyValueIterator<Key,Value>, OptionDescriber { @Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { if (inclusive && !columnFamilies.contains(EMPTY)) { columnFamilies = new HashSet<>(columnFamilies); columnFamilies.add(EMPTY); dropEmptyColFams = true; } else if (!inclusive && columnFamilies.contains(EMPTY)) { columnFamilies = new HashSet<>(columnFamilies); columnFamilies.remove(EMPTY); dropEmptyColFams = true; } else { dropEmptyColFams = false; } this.range = range; this.columnFamilies = columnFamilies; this.inclusive = inclusive; if (range.getStartKey() != null) { Range newRange = new Range(new Key(range.getStartKey().getRow()), true, range.getEndKey(), range.isEndKeyInclusive()); source.seek(newRange, columnFamilies, inclusive); readNextRow(); while (currentPosition < keys.size() && range.beforeStartKey(keys.get(currentPosition))) currentPosition++; if (currentPosition == keys.size()) readNextRow(); } else { source.seek(range, columnFamilies, inclusive); readNextRow(); } } }
LargeRowFilter implements SortedKeyValueIterator<Key,Value>, OptionDescriber { @Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { if (inclusive && !columnFamilies.contains(EMPTY)) { columnFamilies = new HashSet<>(columnFamilies); columnFamilies.add(EMPTY); dropEmptyColFams = true; } else if (!inclusive && columnFamilies.contains(EMPTY)) { columnFamilies = new HashSet<>(columnFamilies); columnFamilies.remove(EMPTY); dropEmptyColFams = true; } else { dropEmptyColFams = false; } this.range = range; this.columnFamilies = columnFamilies; this.inclusive = inclusive; if (range.getStartKey() != null) { Range newRange = new Range(new Key(range.getStartKey().getRow()), true, range.getEndKey(), range.isEndKeyInclusive()); source.seek(newRange, columnFamilies, inclusive); readNextRow(); while (currentPosition < keys.size() && range.beforeStartKey(keys.get(currentPosition))) currentPosition++; if (currentPosition == keys.size()) readNextRow(); } else { source.seek(range, columnFamilies, inclusive); readNextRow(); } } private  LargeRowFilter(SortedKeyValueIterator<Key,Value> source, boolean propogateSuppression,
      int maxColumns);  LargeRowFilter(); }
LargeRowFilter implements SortedKeyValueIterator<Key,Value>, OptionDescriber { @Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { if (inclusive && !columnFamilies.contains(EMPTY)) { columnFamilies = new HashSet<>(columnFamilies); columnFamilies.add(EMPTY); dropEmptyColFams = true; } else if (!inclusive && columnFamilies.contains(EMPTY)) { columnFamilies = new HashSet<>(columnFamilies); columnFamilies.remove(EMPTY); dropEmptyColFams = true; } else { dropEmptyColFams = false; } this.range = range; this.columnFamilies = columnFamilies; this.inclusive = inclusive; if (range.getStartKey() != null) { Range newRange = new Range(new Key(range.getStartKey().getRow()), true, range.getEndKey(), range.isEndKeyInclusive()); source.seek(newRange, columnFamilies, inclusive); readNextRow(); while (currentPosition < keys.size() && range.beforeStartKey(keys.get(currentPosition))) currentPosition++; if (currentPosition == keys.size()) readNextRow(); } else { source.seek(range, columnFamilies, inclusive); readNextRow(); } } private  LargeRowFilter(SortedKeyValueIterator<Key,Value> source, boolean propogateSuppression,
      int maxColumns);  LargeRowFilter(); @Override void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options,
      IteratorEnvironment env); @Override boolean hasTop(); @Override void next(); @Override void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive); @Override Key getTopKey(); @Override Value getTopValue(); @Override SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env); @Override IteratorOptions describeOptions(); @Override boolean validateOptions(Map<String,String> options); static void setMaxColumns(IteratorSetting is, int maxColumns); }
LargeRowFilter implements SortedKeyValueIterator<Key,Value>, OptionDescriber { @Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { if (inclusive && !columnFamilies.contains(EMPTY)) { columnFamilies = new HashSet<>(columnFamilies); columnFamilies.add(EMPTY); dropEmptyColFams = true; } else if (!inclusive && columnFamilies.contains(EMPTY)) { columnFamilies = new HashSet<>(columnFamilies); columnFamilies.remove(EMPTY); dropEmptyColFams = true; } else { dropEmptyColFams = false; } this.range = range; this.columnFamilies = columnFamilies; this.inclusive = inclusive; if (range.getStartKey() != null) { Range newRange = new Range(new Key(range.getStartKey().getRow()), true, range.getEndKey(), range.isEndKeyInclusive()); source.seek(newRange, columnFamilies, inclusive); readNextRow(); while (currentPosition < keys.size() && range.beforeStartKey(keys.get(currentPosition))) currentPosition++; if (currentPosition == keys.size()) readNextRow(); } else { source.seek(range, columnFamilies, inclusive); readNextRow(); } } private  LargeRowFilter(SortedKeyValueIterator<Key,Value> source, boolean propogateSuppression,
      int maxColumns);  LargeRowFilter(); @Override void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options,
      IteratorEnvironment env); @Override boolean hasTop(); @Override void next(); @Override void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive); @Override Key getTopKey(); @Override Value getTopValue(); @Override SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env); @Override IteratorOptions describeOptions(); @Override boolean validateOptions(Map<String,String> options); static void setMaxColumns(IteratorSetting is, int maxColumns); static final Value SUPPRESS_ROW_VALUE; }