/** * Advance the iterator. Should only be called if {@link #isValid()} returned true. Valid can * only chance after calls to {@link #next()}. */ public void next() { newKeyGroup = false; newKVState = false; final RocksIterator rocksIterator = currentSubIterator.getIterator(); rocksIterator.next(); byte[] oldKey = currentSubIterator.getCurrentKey(); if (rocksIterator.isValid()) { currentSubIterator.currentKey = rocksIterator.key(); if (isDifferentKeyGroup(oldKey, currentSubIterator.getCurrentKey())) { heap.offer(currentSubIterator); currentSubIterator = heap.poll(); newKVState = currentSubIterator.getIterator() != rocksIterator; detectNewKeyGroup(oldKey); } } else { rocksIterator.close(); if (heap.isEmpty()) { currentSubIterator = null; valid = false; } else { currentSubIterator = heap.poll(); newKVState = true; detectNewKeyGroup(oldKey); } } }
public byte[] key() { return currentSubIterator.getCurrentKey(); }