com.bigdata.rdf.model
Class BigdataValueSerializer<V extends Value>

java.lang.Object
  extended by com.bigdata.rdf.model.BigdataValueSerializer<V>

public class BigdataValueSerializer<V extends Value>
extends Object

Helper class provides efficient stand-off serialization of RDF Value objects.

Version:
$Id: BigdataValueSerializer.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
protected static String ERR_CODE
          Error message indicates that the term code in the serialized record did not correspond to a known term code for an RDF value of the appropriate type (e.g., a URI code where an Literal code was expected).
protected static String ERR_VERSION
          Error message indicates that the version code in the serialized record did not correspond to a known serialization version for an RDF value.
protected static short VERSION0
          Version zero(0) of the serialization format.
 
Constructor Summary
BigdataValueSerializer(ValueFactory valueFactory)
          Create an instance that will materialize objects using the caller's factory.
 
Method Summary
 V deserialize(byte[] b)
          Routine for efficient de-serialization of an RDF Value.
 V deserialize(DataInputBuffer in)
          Routine for efficient de-serialization of a BigdataValue.
protected  V deserialize(short version, byte termCode, DataInput in)
          Implements the de-serialization of a Literal, URI, or BNode.
protected  byte getTermCode(Value val)
          Return the term code as defined by ITermIndexCodes for this type of term.
 byte[] serialize(V val)
          Routine for efficient serialization of an RDF Value.
 byte[] serialize(V val, DataOutputBuffer out)
          Variant which permits reuse of the same buffer.
protected  void serialize(V val, short version, byte termCode, DataOutput out)
          Implements the serialization of a Literal, URI, or BNode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION0

protected static final short VERSION0
Version zero(0) of the serialization format.

See Also:
Constant Field Values

ERR_VERSION

protected static final String ERR_VERSION
Error message indicates that the version code in the serialized record did not correspond to a known serialization version for an RDF value.

See Also:
Constant Field Values

ERR_CODE

protected static final String ERR_CODE
Error message indicates that the term code in the serialized record did not correspond to a known term code for an RDF value of the appropriate type (e.g., a URI code where an Literal code was expected). The codes are defined by ITermIndexCodes.

See Also:
Constant Field Values
Constructor Detail

BigdataValueSerializer

public BigdataValueSerializer(ValueFactory valueFactory)
Create an instance that will materialize objects using the caller's factory.

Parameters:
valueFactory - The value factory.
Method Detail

serialize

public byte[] serialize(V val)
Routine for efficient serialization of an RDF Value.

Returns:
The byte[] containing the serialized data record.
Throws:
RuntimeException - if there is a IO problem
See Also:
#deserialize(byte[])}

serialize

public byte[] serialize(V val,
                        DataOutputBuffer out)
Variant which permits reuse of the same buffer. This has the advantage that the buffer is reused on each invocation and swiftly grows to its maximum extent.

Parameters:
out - The buffer - the caller is responsible for resetting the buffer before each invocation.
Returns:
The byte[] containing the serialized data record. This array is newly allocated so that a series of invocations of this method return distinct byte[]s.

deserialize

public V deserialize(byte[] b)
Routine for efficient de-serialization of an RDF Value.

Note: This automatically uses the BigdataValueFactoryImpl to create the BigdataValues from the de-serialized state so the factory reference is always set on the returned BigdataValueImpl.

Parameters:
b - The byte[] containing the serialized data record.
Returns:
The BigdataValue.
Throws:
RuntimeException - if there is an IO problem.
See Also:
#serialize()}

deserialize

public V deserialize(DataInputBuffer in)
Routine for efficient de-serialization of a BigdataValue.

Note: This automatically uses the BigdataValueFactoryImpl to create the BigdataValues from the de-serialized state so the factory reference is always set on the returned BigdataValueImpl.

Parameters:
b - An input stream from which the serialized data may be read.
Returns:
The BigdataValue.
Throws:
RuntimeException - if there is an IO problem.
See Also:
#serialize()}

serialize

protected void serialize(V val,
                         short version,
                         byte termCode,
                         DataOutput out)
                  throws IOException
Implements the serialization of a Literal, URI, or BNode.

Parameters:
version - The serialization version number (which has already been written on out by the caller).
termCode - The byte encoding the type of term as defined by ITermIndexCodes (this has already been written on out by the caller).
out - The data are written here.
Throws:
IOException

deserialize

protected V deserialize(short version,
                        byte termCode,
                        DataInput in)
                               throws IOException
Implements the de-serialization of a Literal, URI, or BNode.

Note: This automatically uses the BigdataValueFactoryImpl to create the BigdataValues from the de-serialized state so the factory reference is always set on the returned BigdataValueImpl.

Parameters:
version - The serialization version number (which has already been read by the caller).
termCode - The byte encoding the type of term as defined by ITermIndexCodes (this has already been read by the caller).
in - The data are read from here.
Throws:
IOException

getTermCode

protected byte getTermCode(Value val)
Return the term code as defined by ITermIndexCodes for this type of term. This is used to places URIs, different types of literals, and bnodes into disjoint parts of the key space for sort orders.

See Also:
ITermIndexCodes


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.