Package elki.data.type
Class TypeInformationSerializer
- java.lang.Object
-
- elki.data.type.TypeInformationSerializer
-
- All Implemented Interfaces:
ByteBufferSerializer<TypeInformation>
public class TypeInformationSerializer extends java.lang.Object implements ByteBufferSerializer<TypeInformation>
Class to handle the serialization and deserialization of type information.The serialization format is custom, and not very extensible. However, the standard Java "serializable" API did not seem well suited for this task, and assumes an object stream context, while we intend to focus on Java NIO.
TODO: on the long run, this code needs to be refactored, and a more extensible format needs to be created. Maybe, a protobuf based API would be possible.
- Since:
- 0.5.5
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classTypeInformationSerializer.SimpleTypeSerializerSerialization class for pure simple types.(package private) static classTypeInformationSerializer.VectorFieldTypeSerializerSerialization class for field vector types.(package private) static classTypeInformationSerializer.VectorTypeSerializerSerialization class for non-field vector types.
-
Field Summary
Fields Modifier and Type Field Description (package private) static ByteBufferSerializer<SimpleTypeInformation<?>>SIMPLE_TYPE_SERIALIZERSerializer for simple types only.static TypeInformationSerializerSTATICStatic instance.private static byteTAG_SIMPLETag for simple type.private static byteTAG_VECTORTag for non-field vector type.private static byteTAG_VECTOR_FIELDTag for vector field type.(package private) static ByteBufferSerializer<VectorFieldTypeInformation<?>>VECTOR_FIELD_TYPE_SERIALIZERSerializer for vector fields.(package private) static ByteBufferSerializer<VectorTypeInformation<?>>VECTOR_TYPE_SERIALIZERSerializer for non-field vectors.
-
Constructor Summary
Constructors Constructor Description TypeInformationSerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TypeInformationfromByteBuffer(java.nio.ByteBuffer buffer)Deserialize an object from a byte buffer (e.g., disk)intgetByteSize(TypeInformation object)Get the size of the object in bytes.voidtoByteBuffer(java.nio.ByteBuffer buffer, TypeInformation object)Serialize the object to a byte array (e.g., disk)
-
-
-
Field Detail
-
STATIC
public static final TypeInformationSerializer STATIC
Static instance.
-
TAG_SIMPLE
private static final byte TAG_SIMPLE
Tag for simple type.- See Also:
- Constant Field Values
-
TAG_VECTOR
private static final byte TAG_VECTOR
Tag for non-field vector type.- See Also:
- Constant Field Values
-
TAG_VECTOR_FIELD
private static final byte TAG_VECTOR_FIELD
Tag for vector field type.- See Also:
- Constant Field Values
-
SIMPLE_TYPE_SERIALIZER
static final ByteBufferSerializer<SimpleTypeInformation<?>> SIMPLE_TYPE_SERIALIZER
Serializer for simple types only.
-
VECTOR_TYPE_SERIALIZER
static final ByteBufferSerializer<VectorTypeInformation<?>> VECTOR_TYPE_SERIALIZER
Serializer for non-field vectors.
-
VECTOR_FIELD_TYPE_SERIALIZER
static final ByteBufferSerializer<VectorFieldTypeInformation<?>> VECTOR_FIELD_TYPE_SERIALIZER
Serializer for vector fields.
-
-
Method Detail
-
fromByteBuffer
public TypeInformation fromByteBuffer(java.nio.ByteBuffer buffer) throws java.io.IOException
Description copied from interface:ByteBufferSerializerDeserialize an object from a byte buffer (e.g., disk)- Specified by:
fromByteBufferin interfaceByteBufferSerializer<TypeInformation>- Parameters:
buffer- Data array to process- Returns:
- Deserialized object
- Throws:
java.io.IOException- on IO errors
-
toByteBuffer
public void toByteBuffer(java.nio.ByteBuffer buffer, TypeInformation object) throws java.io.IOExceptionDescription copied from interface:ByteBufferSerializerSerialize the object to a byte array (e.g., disk)- Specified by:
toByteBufferin interfaceByteBufferSerializer<TypeInformation>- Parameters:
buffer- Buffer to serialize toobject- Object to serialize- Throws:
java.io.IOException- on IO errors
-
getByteSize
public int getByteSize(TypeInformation object) throws java.io.IOException
Description copied from interface:ByteBufferSerializerGet the size of the object in bytes.- Specified by:
getByteSizein interfaceByteBufferSerializer<TypeInformation>- Parameters:
object- Object to serialize- Returns:
- maximum size in serialized form
- Throws:
java.io.IOException- on IO errors
-
-