class KeyValueWriter implements Closeable {

    public void writeData( BigEndianByteArrayBuffer key, BigEndianByteArrayBuffer value ) throws IOException
    {
        state.data( this );
        assert key.size() == keySize;
        assert value.size() == valueSize;
        if ( key.allZeroes() )
        {
            state = State.in_error;
            throw new IllegalArgumentException( "All-zero keys are not allowed." );
        }
        if ( !write( key, value ) )
        {
            state = State.in_error;
            throw new IllegalStateException( "MetadataCollector stopped on data field." );
        }
    }

      KeyValueWriter( MetadataCollector metadata, Writer writer );

}