Exemplo n.º 1
0
    /**
     * 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);
        }
      }
    }
Exemplo n.º 2
0
    @Override
    public void close() {

      if (null != currentSubIterator) {
        currentSubIterator.close();
        currentSubIterator = null;
      }

      for (MergeIterator iterator : heap) {
        iterator.close();
      }

      heap.clear();
    }
Exemplo n.º 3
0
 public byte[] value() {
   return currentSubIterator.getIterator().value();
 }
Exemplo n.º 4
0
 /**
  * Returns the Id of the k/v state to which the current key belongs.
  *
  * @return Id of K/V state to which the current key belongs.
  */
 public int kvStateId() {
   return currentSubIterator.getKvStateId();
 }
Exemplo n.º 5
0
 public byte[] key() {
   return currentSubIterator.getCurrentKey();
 }