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 class
TypeInformationSerializer.SimpleTypeSerializer
Serialization class for pure simple types.(package private) static class
TypeInformationSerializer.VectorFieldTypeSerializer
Serialization class for field vector types.(package private) static class
TypeInformationSerializer.VectorTypeSerializer
Serialization class for non-field vector types.
-
Field Summary
Fields Modifier and Type Field Description (package private) static ByteBufferSerializer<SimpleTypeInformation<?>>
SIMPLE_TYPE_SERIALIZER
Serializer for simple types only.static TypeInformationSerializer
STATIC
Static instance.private static byte
TAG_SIMPLE
Tag for simple type.private static byte
TAG_VECTOR
Tag for non-field vector type.private static byte
TAG_VECTOR_FIELD
Tag for vector field type.(package private) static ByteBufferSerializer<VectorFieldTypeInformation<?>>
VECTOR_FIELD_TYPE_SERIALIZER
Serializer for vector fields.(package private) static ByteBufferSerializer<VectorTypeInformation<?>>
VECTOR_TYPE_SERIALIZER
Serializer for non-field vectors.
-
Constructor Summary
Constructors Constructor Description TypeInformationSerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TypeInformation
fromByteBuffer(java.nio.ByteBuffer buffer)
Deserialize an object from a byte buffer (e.g., disk)int
getByteSize(TypeInformation object)
Get the size of the object in bytes.void
toByteBuffer(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:ByteBufferSerializer
Deserialize an object from a byte buffer (e.g., disk)- Specified by:
fromByteBuffer
in 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.IOException
Description copied from interface:ByteBufferSerializer
Serialize the object to a byte array (e.g., disk)- Specified by:
toByteBuffer
in 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:ByteBufferSerializer
Get the size of the object in bytes.- Specified by:
getByteSize
in interfaceByteBufferSerializer<TypeInformation>
- Parameters:
object
- Object to serialize- Returns:
- maximum size in serialized form
- Throws:
java.io.IOException
- on IO errors
-
-