private void writeValue(final RefDataValue refDataValue) {
        stagingValueOutputStream.clear();
        try {
            if (refDataValue instanceof StringValue) {
                final StringValue stringValue = (StringValue) refDataValue;
                stagingValueOutputStream.write(stringValue.getValue());
                stagingValueOutputStream.setTypeId(StringValue.TYPE_ID);
            } else if (refDataValue instanceof FastInfosetValue) {
                stagingValueOutputStream.write(((FastInfosetValue) refDataValue).getByteBuffer());
                stagingValueOutputStream.setTypeId(FastInfosetValue.TYPE_ID);
            } else if (refDataValue instanceof NullValue) {
                stagingValueOutputStream.setTypeId(NullValue.TYPE_ID);
            } else {
                throw new RuntimeException("Unexpected type " + refDataValue.getClass().getSimpleName());
            }
        } catch (IOException e) {
            throw new RuntimeException(LogUtil.message("Error writing value: {}", e.getMessage()), e);
        }
    }
@param refStreamDefinitionCount  Number of {@link RefStreamDefinition}s to create.
@param keyValueMapCount          Number of KeyValue type maps to create per {@link RefStreamDefinition}
@param rangeValueMapCount        Number of RangeValue type maps to create per {@link RefStreamDefinition}
@param entryCount                Number of map entries to create per map
@param refStreamDefinitionOffset The offset from zero for the refStreamDefinition partIndex
@return The created {@link RefStreamDefinition} objects
stroom-pipeline/src/test/java/stroom/pipeline/refdata/store/onheapstore/TestRefDataOnHeapStore.java