/**
     * @param keyBytes
     * @param value
     * @param hash2
     * @return
     */
    V acquireEntry(DirectBytes keyBytes, V value, int hash2) {
      value = createValueIfNull(value);

      final int pos = nextFree();
      final long offset = entriesOffset + pos * entrySize;
      tmpBytes.storePositionAndSize(bytes, offset, entrySize);
      final long keyLength = keyBytes.remaining();
      tmpBytes.writeStopBit(keyLength);
      tmpBytes.write(keyBytes);
      if (value instanceof Byteable) {
        Byteable byteable = (Byteable) value;
        int length = byteable.maxSize();
        tmpBytes.writeStopBit(length);
        tmpBytes.position(align(tmpBytes.position()));
        if (length > tmpBytes.remaining())
          throw new IllegalStateException(
              "Not enough space left in entry for value, needs "
                  + length
                  + " but only "
                  + tmpBytes.remaining()
                  + " left");
        tmpBytes.zeroOut(tmpBytes.position(), tmpBytes.position() + length);
        byteable.bytes(bytes, offset + tmpBytes.position());
      } else {
        appendInstance(keyBytes, value);
      }
      // add to index if successful.
      hashLookup.put(hash2, pos);
      incrementSize();
      return value;
    }