public static void calcDatasetItem(final byte[] buffer, final int[] cache, final int index) {
    final int rows = cache.length / HASH_WORDS;
    final int[] mixInts = new int[HASH_BYTES / 4];
    final int offset = index % rows * HASH_WORDS;
    mixInts[0] = cache[offset] ^ index;
    System.arraycopy(cache, offset + 1, mixInts, 1, HASH_WORDS - 1);
    intToByte(buffer, mixInts);
    final MessageDigest keccak512 = KECCAK_512.get();
    keccak512.update(buffer);
    try {
      keccak512.digest(buffer, 0, HASH_BYTES);
      ByteBuffer.wrap(buffer).order(ByteOrder.LITTLE_ENDIAN).asIntBuffer().get(mixInts);
      for (int i = 0; i < DATASET_PARENTS; ++i) {
        fnvHash(
            mixInts,
            cache,
            Integer.remainderUnsigned(fnv(index ^ i, mixInts[i % 16]), rows) * HASH_WORDS);
      }
      intToByte(buffer, mixInts);
      keccak512.update(buffer);
      keccak512.digest(buffer, 0, HASH_BYTES);
    } catch (final DigestException ex) {
      throw new IllegalStateException(ex);
    }
  }
Calculates a dataset item and writes it to a given buffer.

@param buffer Buffer to store dataset item in
@param cache EthHash Cache
@param index Index of the dataset item to calculate
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/EthHash.java