@Override
    public ByteBuffer getFullByteBuffer() {
        if (fullBuffer == null) {
            checkTypeIdSet();
            fullBuffer = pooledByteBufferOutputStream.getByteBuffer();
            // Hash just the value part of the buffer
            final int valueLength = fullBuffer.remaining() - META_LENGTH;
            try {
                valueBuffer = fullBuffer.slice(
                        VALUE_OFFSET,
                        fullBuffer.remaining() - META_LENGTH);
            } catch (Exception e) {
                throw new RuntimeException(LogUtil.message("""
                                Error slicing valueBuffer (offset: {}, length: {}) from fullBuffer: {}
                                byteBuffer: {}""",
                        VALUE_OFFSET,
                        valueLength,
                        e.getMessage(),
                        ByteBufferUtils.byteBufferInfo(fullBuffer)), e);
            }

            LOGGER.trace(() -> LogUtil.message("\nbyteBuffer: {}\nvalueBuffer: {}",
                    ByteBufferUtils.byteBufferInfo(fullBuffer),
                    ByteBufferUtils.byteBufferInfo(valueBuffer)));

            final long valueHash = valueStoreHashAlgorithm.hash(valueBuffer);

            // Now add the type and hash into the buffer without changing its position/limit
            fullBuffer.put(TYPE_ID_OFFSET, typeId);
            fullBuffer.putLong(VALUE_HASH_OFFSET, valueHash);
        }
        return fullBuffer;
    }
Only call this after you have finished writing to the output stream.
stroom-pipeline/src/main/java/stroom/pipeline/refdata/store/StagingValueOutputStream.java