SnapshotIterator implements SortedKeyValueIterator<Key, Value> { @Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { Range newRange = range; Collection<ByteSequence> cols; boolean inc; clearReadLock(); hasTop = true; if (range.getStartKey() != null && range.getStartKey().getTimestamp() != Long.MAX_VALUE && !range.isStartKeyInclusive()) { if (ColumnType.from(range.getStartKey()) == ColumnType.RLOCK) { Key currCol = new Key(range.getStartKey()); currCol.setTimestamp(Long.MAX_VALUE); newRange = new Range(currCol, true, range.getEndKey(), range.isEndKeyInclusive()); ignoreReadLock(currCol); } else { Key nextCol = range.getStartKey().followingKey(PartialKey.ROW_COLFAM_COLQUAL_COLVIS); if (range.afterEndKey(nextCol)) { hasTop = false; return; } else { newRange = new Range(nextCol, true, range.getEndKey(), range.isEndKeyInclusive()); } } } else { newRange = range; } if (columnFamilies.isEmpty() && inclusive == false) { cols = NOTIFY_CF_SET; inc = false; } else { cols = columnFamilies; inc = inclusive; } source.seek(newRange, cols, inc); findTop(); }  @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); static void setSnaptime(IteratorSetting cfg, long time); static void setReturnReadLockPresent(IteratorSetting cfg, boolean rrlp);  }
@Test public void testSeek() { TestData input = new TestData(); input.add("0 f q1 WRITE 16", "11"); input.add("0 f q1 LOCK 21", "1 f q"); input.add("0 f q1 LOCK 11", "1 f q"); input.add("0 f q1 DATA 21", "j"); input.add("0 f q1 DATA 11", "i"); input.add("0 f q2 WRITE 26", "20"); input.add("0 f q2 WRITE 18", "9"); input.add("0 f q2 LOCK 20", "1 f q"); input.add("0 f q2 LOCK 9", "1 f q"); input.add("0 f q2 DATA 20", "b"); input.add("0 f q2 DATA 9", "a"); input.add("1 f q1 DEL_LOCK 21", "0 ROLLBACK"); input.add("1 f q1 WRITE 18", "9"); input.add("1 f q1 LOCK 21", "1 f q"); input.add("1 f q1 LOCK 9", "1 f q"); input.add("1 f q1 DATA 21", "y"); input.add("1 f q1 DATA 9", "x"); for (Range range : new Range[] {Range.exact("0"), Range.exact("1"), Range.exact("0", "f"), Range.exact("0", "f", "q1"), Range.exact("0", "f", "q2"), Range.exact("1", "f", "q1")}) { TestData output = new TestData(newSI(input, 6), range); Assert.assertEquals(0, output.data.size()); output = new TestData(newSI(input, 17), range); TestData expected = new TestData(); expected.addIfInRange("0 f q1 DATA 11", "i", range); Assert.assertEquals(expected, output); output = new TestData(newSI(input, 19), range); expected = new TestData(); expected.addIfInRange("0 f q1 DATA 11", "i", range); expected.addIfInRange("0 f q2 DATA 9", "a", range); expected.addIfInRange("1 f q1 DATA 9", "x", range); Assert.assertEquals(expected, output); output = new TestData(newSI(input, 22), range); expected = new TestData(); expected.addIfInRange("0 f q1 LOCK 21", "1 f q", range); expected.addIfInRange("0 f q2 DATA 9", "a", range); expected.addIfInRange("1 f q1 DATA 9", "x", range); Assert.assertEquals(expected, output); output = new TestData(newSI(input, 27), range); expected = new TestData(); expected.addIfInRange("0 f q1 LOCK 21", "1 f q", range); expected.addIfInRange("0 f q2 DATA 20", "b", range); expected.addIfInRange("1 f q1 DATA 9", "x", range); Assert.assertEquals(expected, output); } }