public Entry readNext()

in src/main/java/com/spotify/sparkey/SortHelper.java [153:171]


    public Entry readNext() {
      if (!iterator.hasNext()) {
        return null;
      }
      // Safe cast, since the iterator is known to be a SparkeyLogIterator
      SparkeyLogIterator.Entry entry = (SparkeyLogIterator.Entry) iterator.next();

      int typeBit = entry.getType() == SparkeyReader.Type.DELETE ? 0 : 1;

      long hash = hashData.hash(entry.getKeyLength(), entry.getKey(), hashSeed);
      long position = entry.getPosition();
      long entryIndex = entry.getEntryIndex();
      long address = position << (entryBlockBits + 1) | (entryIndex << 1) | typeBit;

      if (position < 0) {
        throw new RuntimeException("Data size overflow");
      }
      return Entry.fromHash(hash, address, hashCapacity);
    }