Serialization

User API for Serialization.

class ObjectDataOutput[source]

Bases: object

ObjectDataOutput provides an interface to convert any of primitive types or arrays of them to series of bytes and write them on a stream.

write_from(buff: bytearray, offset: Optional[int] = None, length: Optional[int] = None) None[source]

Writes the content of the buffer to this output stream.

Parameters
  • buff – Input buffer.

  • offset – Offset of the buffer where copy begin.

  • length – Length of data to be copied from the offset into stream.

write_boolean(val: bool) None[source]

Writes a bool value to this output stream.

Single byte value 1 represent True, 0 represent False

Parameters

val – The bool to be written.

write_byte(val: int) None[source]

Writes a byte value to this output stream.

Parameters

val – The byte value to be written.

write_short(val: int) None[source]

Writes a short value to this output stream.

Parameters

val – The short value to be written.

write_char(val: str) None[source]

Writes a char value to this output stream.

Parameters

val – The char value to be written.

write_int(val: int) None[source]

Writes an int value to this output stream.

Parameters

val – The int value to be written.

write_long(val: int) None[source]

Writes a long value to this output stream.

Parameters

val – The long value to be written.

write_float(val: float) None[source]

Writes a float value to this output stream.

Parameters

val – The float value to be written.

write_double(val: float) None[source]

Writes a double value to this output stream.

Parameters

val – The double value to be written.

write_bytes(val: str) None[source]

Writes a string to this output stream.

Parameters

val – The string to be written.

write_chars(val: str) None[source]

Writes every character of string to this output stream.

Parameters

val – The string to be written.

write_string(val: str) None[source]

Writes UTF-8 string to this output stream.

Parameters

val – The UTF-8 string to be written.

write_utf(val: str) None[source]

Writes UTF-8 string to this output stream.

Deprecated since version 4.1: This method is deprecated and will be removed in the next major version. Use write_string() instead.

Parameters

val – The UTF-8 string to be written.

write_byte_array(val: bytearray) None[source]

Writes a byte array to this output stream.

Parameters

val – The byte array to be written.

write_boolean_array(val: Sequence[bool]) None[source]

Writes a bool array to this output stream.

Parameters

val – The bool array to be written.

write_char_array(val: Sequence[str]) None[source]

Writes a char array to this output stream.

Parameters

val – The char array to be written.

write_int_array(val: Sequence[int]) None[source]

Writes a int array to this output stream.

Parameters

val – The int array to be written.

write_long_array(val: Sequence[int]) None[source]

Writes a long array to this output stream.

Parameters

val – The long array to be written.

write_double_array(val: Sequence[float]) None[source]

Writes a double array to this output stream.

Parameters

val – The double array to be written.

write_float_array(val: Sequence[float]) None[source]

Writes a float array to this output stream.

Parameters

val – The float array to be written.

write_short_array(val: Sequence[int]) None[source]

Writes a short array to this output stream.

Parameters

val – The short array to be written.

write_string_array(val: Sequence[str]) None[source]

Writes a UTF-8 String array to this output stream.

Parameters

val – The UTF-8 String array to be written.

write_utf_array(val: Sequence[str]) None[source]

Writes a UTF-8 String array to this output stream.

Deprecated since version 4.1: This method is deprecated and will be removed in the next major version. Use write_string_array() instead.

Parameters

val – The UTF-8 String array to be written.

write_object(val: Any) None[source]

Writes an object to this output stream.

Parameters

val – The object to be written.

to_byte_array() bytearray[source]

Returns a copy of internal byte array.

Returns

The copy of internal byte array

get_byte_order() str[source]

Returns the order of bytes, as BIG_ENDIAN or LITTLE_ENDIAN.

class ObjectDataInput[source]

Bases: object

ObjectDataInput provides an interface to read bytes from a stream and reconstruct it to any of primitive types or arrays of them.

read_into(buff: bytearray, offset: Optional[int] = None, length: Optional[int] = None) bytearray[source]

Reads the content of the buffer into an array of bytes.

Parameters
  • buff – Input buffer.

  • offset – Offset of the buffer where the read begin.

  • length – Length of data to be read.

Returns

The read data.

skip_bytes(count: int) int[source]

Skips over given number of bytes from input stream.

Parameters

count – Number of bytes to be skipped.

Returns

The actual number of bytes skipped.

read_boolean() bool[source]

Reads 1 byte from input stream and convert it to a bool value.

Returns

The bool value read.

read_byte() int[source]

Reads 1 byte from input stream and returns it.

Returns

The byte value read.

read_unsigned_byte() int[source]

Reads 1 byte from input stream, zero-extends it and returns.

Returns

The unsigned byte value read.

read_short() int[source]

Reads 2 bytes from input stream and returns a short value.

Returns

The short value read.

read_unsigned_short() int[source]

Reads 2 bytes from input stream and returns an int value.

Returns

The unsigned short value read.

read_char() str[source]

Reads 2 bytes from the input stream and returns a str value.

Returns

The char value read.

read_int() int[source]

Reads 4 bytes from input stream and returns an int value.

Returns

The int value read.

read_long() int[source]

Reads 8 bytes from input stream and returns a long value.

Returns

The int value read.

read_float() float[source]

Reads 4 bytes from input stream and returns a float value.

Returns

The float value read.

read_double() float[source]

Reads 8 bytes from input stream and returns a double value.

Returns

The double value read.

read_string() str[source]

Reads a UTF-8 string from input stream and returns it.

Returns

The UTF-8 string read.

read_utf() str[source]

Reads a UTF-8 string from input stream and returns it.

Deprecated since version 4.1: This method is deprecated and will be removed in the next major version. Use read_string() instead.

Returns

The UTF-8 string read.

read_byte_array() bytearray[source]

Reads a byte array from input stream and returns it.

Returns

The byte array read.

read_boolean_array() List[bool][source]

Reads a bool array from input stream and returns it.

Returns

The bool array read.

read_char_array() List[str][source]

Reads a char array from input stream and returns it.

Returns

The char array read.

read_int_array() List[int][source]

Reads a int array from input stream and returns it.

Returns

The int array read.

read_long_array() List[int][source]

Reads a long array from input stream and returns it.

Returns

The long array read.

read_double_array() List[float][source]

Reads a double array from input stream and returns it.

Returns

The double array read.

read_float_array() List[float][source]

Reads a float array from input stream and returns it.

Returns

The float array read.

read_short_array() List[int][source]

Reads a short array from input stream and returns it.

Returns

The short array read.

read_string_array() List[str][source]

Reads a UTF-8 string array from input stream and returns it.

Returns

The UTF-8 string array read.

read_utf_array() List[str][source]

Reads a UTF-8 string array from input stream and returns it.

Deprecated since version 4.1: This method is deprecated and will be removed in the next major version. Use read_string_array() instead.

Returns

The UTF-8 string array read.

read_object() Any[source]

Reads an object from input stream and returns it.

Returns

The object read.

get_byte_order() str[source]

Returns the order of bytes, as BIG_ENDIAN or LITTLE_ENDIAN.

position() int[source]

Returns current position in buffer.

Returns

Current position in buffer.

size() int[source]

Returns size of buffer.

Returns

Size of buffer.

class IdentifiedDataSerializable[source]

Bases: object

IdentifiedDataSerializable is an alternative serialization method to Python pickle, which also avoids reflection during de-serialization.

Each IdentifiedDataSerializable is created by a registered DataSerializableFactory.

write_data(object_data_output: ObjectDataOutput) None[source]

Writes object fields to output stream.

Parameters

object_data_output – The output.

read_data(object_data_input: ObjectDataInput) None[source]

Reads fields from the input stream.

Parameters

object_data_input – The input.

get_factory_id() int[source]

Returns DataSerializableFactory factory id for this class.

Returns

The factory id.

get_class_id() int[source]

Returns type identifier for this class. Id should be unique per DataSerializableFactory.

Returns

The type id.

class Portable[source]

Bases: object

Portable provides an alternative serialization method.

Instead of relying on reflection, each Portable is created by a registered PortableFactory. Portable serialization has the following advantages:

  • Support multiversion of the same object type.

  • Fetching individual fields without having to rely on reflection.

  • Querying and indexing support without de-serialization and/or reflection.

write_portable(writer: PortableWriter) None[source]

Serialize this portable object using given PortableWriter.

Parameters

writer – The PortableWriter.

read_portable(reader: PortableReader) None[source]

Read portable fields using PortableReader.

Parameters

reader – The PortableReader.

get_factory_id() int[source]

Returns PortableFactory id for this portable class

Returns

The factory id.

get_class_id() int[source]

Returns class identifier for this portable class. Class id should be unique per PortableFactory.

Returns

The class id.

class StreamSerializer[source]

Bases: object

A base class for custom serialization.

write(out: ObjectDataOutput, obj: Any) None[source]

Writes object to ObjectDataOutput

Parameters
  • out – Stream that object will be written to.

  • obj – The object to be written.

read(inp: ObjectDataInput) Any[source]

Reads object from objectDataInputStream

Parameters

inp – Stream that object will read from.

Returns

The read object.

get_type_id() int[source]

Returns typeId of serializer.

Returns

The type id of the serializer.

destroy() None[source]

Called when instance is shutting down.

It can be used to clear used resources.

class PortableReader[source]

Bases: object

Provides a mean of reading portable fields from binary in form of Python primitives and arrays of these primitives, nested portable fields and array of portable fields.

get_version() int[source]

Returns the global version of portable classes.

Returns

Global version of portable classes.

has_field(field_name: str) bool[source]

Determine whether the field name exists in this portable class or not.

Parameters

field_name – name of the field (does not support nested paths).

Returns

True if the field name exists in class, False otherwise.

get_field_names() Set[str][source]

Returns the set of field names on this portable class.

Returns

Set of field names on this portable class.

get_field_type(field_name: str) FieldType[source]

Returns the field type of given field name.

Parameters

field_name – Name of the field.

Returns

The field type.

get_field_class_id(field_name: str) int[source]

Returns the class id of given field.

Parameters

field_name – Name of the field.

Returns

Class id of given field.

read_int(field_name: str) int[source]

Reads a primitive int.

Parameters

field_name – Name of the field.

Returns

The int value read.

read_long(field_name: str) int[source]

Reads a primitive long.

Parameters

field_name – Name of the field.

Returns

The long value read.

read_string(field_name: str) str[source]

Reads a UTF-8 String.

Parameters

field_name – Name of the field.

Returns

The UTF-8 String read.

read_utf(field_name: str) str[source]

Reads a UTF-8 String.

Deprecated since version 4.1: This method is deprecated and will be removed in the next major version. Use read_string() instead.

Parameters

field_name – Name of the field.

Returns

The UTF-8 String read.

read_boolean(field_name: str) bool[source]

Reads a primitive bool.

Parameters

field_name – Name of the field.

Returns

The bool value read.

read_byte(field_name: str) int[source]

Reads a primitive byte.

Parameters

field_name – Name of the field.

Returns

The byte value read.

read_char(field_name: str) str[source]

Reads a primitive char.

Parameters

field_name – Name of the field.

Returns

The char value read.

read_double(field_name: str) float[source]

Reads a primitive double.

Parameters

field_name – Name of the field.

Returns

The double value read.

read_float(field_name: str) float[source]

Reads a primitive float.

Parameters

field_name – Name of the field.

Returns

The float value read.

read_short(field_name: str) int[source]

Reads a primitive short.

Parameters

field_name – Name of the field.

Returns

The short value read.

read_portable(field_name: str) Portable[source]

Reads a portable.

Parameters

field_name – Name of the field.

Returns

The portable read.

read_byte_array(field_name: str) bytearray[source]

Reads a primitive byte array.

Parameters

field_name – Name of the field.

Returns

The byte array read.

read_boolean_array(field_name: str) List[bool][source]

Reads a primitive bool array.

Parameters

field_name – Name of the field.

Returns

The bool array read.

read_char_array(field_name: str) List[str][source]

Reads a primitive char array.

Parameters

field_name – Name of the field.

Returns

The char array read.

read_int_array(field_name: str) List[int][source]

Reads a primitive int array.

Parameters

field_name – Name of the field.

Returns

The int array read.

read_long_array(field_name: str) List[int][source]

Reads a primitive long array.

Parameters

field_name – Name of the field.

Returns

The long array read.

read_double_array(field_name: str) List[float][source]

Reads a primitive double array.

Parameters

field_name – Name of the field.

Returns

The double array read.

read_float_array(field_name: str) List[float][source]

Reads a primitive float array.

Parameters

field_name – Name of the field.

Returns

The float array read.

read_short_array(field_name: str) List[int][source]

Reads a primitive short array.

Parameters

field_name – Name of the field.

Returns

The short array read.

read_string_array(field_name: str) List[str][source]

Reads a UTF-8 String array.

Parameters

field_name – Name of the field.

Returns

The UTF-8 String array read.

read_utf_array(field_name: str) List[str][source]

Reads a UTF-8 String array.

Deprecated since version 4.1: This method is deprecated and will be removed in the next major version. Use read_string_array() instead.

Parameters

field_name – Name of the field.

Returns

The UTF-8 String array read.

read_portable_array(field_name: str) List[Portable][source]

Reads a portable array.

Parameters

field_name – Name of the field.

Returns

The portable array read.

get_raw_data_input() ObjectDataInput[source]

After reading portable fields, one can read remaining fields in old fashioned way consecutively from the end of stream. After get_raw_data_input() called, no data can be read.

Returns

The input.

class PortableWriter[source]

Bases: object

Provides a mean of writing portable fields to a binary in form of Python primitives and arrays of these primitives, nested portable fields and array of portable fields.

write_int(field_name: str, value: int) None[source]

Writes a primitive int.

Parameters
  • field_name – Name of the field.

  • value – Int value to be written.

write_long(field_name: str, value: int) None[source]

Writes a primitive long.

Parameters
  • field_name – Name of the field.

  • value – Long value to be written.

write_string(field_name: str, value: str) None[source]

Writes an UTF string.

Parameters
  • field_name – Name of the field.

  • value – UTF string value to be written.

write_utf(field_name: str, value: str) None[source]

Writes an UTF string.

Deprecated since version 4.1: This method is deprecated and will be removed in the next major version. Use write_string() instead.

Parameters
  • field_name – Name of the field.

  • value – UTF string value to be written.

write_boolean(field_name: str, value: bool) None[source]

Writes a primitive bool.

Parameters
  • field_name – Name of the field.

  • value – Bool value to be written.

write_byte(field_name: str, value: int) None[source]

Writes a primitive byte.

Parameters
  • field_name – Name of the field.

  • value – Byte value to be written.

write_char(field_name: str, value: str) None[source]

Writes a primitive char.

Parameters
  • field_name – Name of the field.

  • value – Char value to be written.

write_double(field_name: str, value: float) None[source]

Writes a primitive double.

Parameters
  • field_name – Name of the field.

  • value – Double value to be written.

write_float(field_name: str, value: float) None[source]

Writes a primitive float.

Parameters
  • field_name – Name of the field.

  • value – Float value to be written.

write_short(field_name: str, value: int) None[source]

Writes a primitive short.

Parameters
  • field_name – Name of the field.

  • value – Short value to be written.

write_portable(field_name: str, portable: Portable) None[source]

Writes a Portable.

Parameters
  • field_name – Name of the field.

  • portable – Portable to be written.

write_null_portable(field_name: str, factory_id: int, class_id: int) None[source]

To write a null portable value, user needs to provide class and factory ids of related class.

Parameters
  • field_name – Name of the field.

  • factory_id – Factory id of related portable class.

  • class_id – Class id of related portable class.

write_byte_array(field_name: str, values: bytearray) None[source]

Writes a primitive byte array.

Parameters
  • field_name – Name of the field.

  • values – Bytearray to be written.

write_boolean_array(field_name: str, values: Sequence[bool]) None[source]

Writes a primitive bool array.

Parameters
  • field_name – Name of the field.

  • values – Bool array to be written.

write_char_array(field_name: str, values: Sequence[str]) None[source]

Writes a primitive char array.

Parameters
  • field_name – Name of the field.

  • values – Char array to be written.

write_int_array(field_name: str, values: Sequence[int]) None[source]

Writes a primitive int array.

Parameters
  • field_name – Name of the field.

  • values – Int array to be written.

write_long_array(field_name: str, values: Sequence[int]) None[source]

Writes a primitive long array.

Parameters
  • field_name – Name of the field.

  • values – Long array to be written.

write_double_array(field_name: str, values: Sequence[float]) None[source]

Writes a primitive double array.

Parameters
  • field_name – Name of the field.

  • values – Double array to be written.

write_float_array(field_name: str, values: Sequence[float]) None[source]

Writes a primitive float array.

Parameters
  • field_name – Name of the field.

  • values – Float array to be written.

write_short_array(field_name: str, values: Sequence[int]) None[source]

Writes a primitive short array.

Parameters
  • field_name – Name of the field.

  • values – Short array to be written.

write_string_array(field_name: str, values: Sequence[str]) None[source]

Writes a UTF-8 String array.

Parameters
  • field_name – Name of the field.

  • values – UTF-8 String array to be written.

write_utf_array(field_name: str, values: Sequence[str]) None[source]

Writes a UTF-8 String array.

Deprecated since version 4.1: This method is deprecated and will be removed in the next major version. Use write_string_array() instead.

Parameters
  • field_name – Name of the field.

  • values – UTF-8 String array to be written.

write_portable_array(field_name: str, values: Sequence[Portable]) None[source]

Writes a portable array.

Parameters
  • field_name – Name of the field.

  • values – Portable array to be written.

get_raw_data_output() ObjectDataOutput[source]

After writing portable fields, one can write remaining fields in old fashioned way consecutively at the end of stream. After get_raw_data_output() called, no data can be written.

Returns

The output.

class CompactReader[source]

Bases: ABC

Provides means of reading compact serialized fields from the binary data.

Read operations might throw HazelcastSerializationError when a field with the given name is not found or there is a type mismatch. On such occasions, one might provide default values to the read methods to return it in case of the failure scenarios described above. Providing default values might be especially useful, if the class might evolve in future, either by adding or removing fields.

Warning

This API is in the BETA status and any part of it might be changed without a prior notice, until it is promoted to the stable status.

abstract get_field_kind(field_name)[source]

Returns the FieldKind for the given field.

Parameters

field_name – Name of the field.

Returns

Field kind for the given field. or FieldKind.NOT_AVAILABLE if the field does not exist.

abstract read_boolean(field_name: str) bool[source]

Reads a boolean.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_nullable_boolean(field_name: str) Optional[bool][source]

Reads a nullable boolean.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_int8(field_name: str) int[source]

Reads an 8-bit two’s complement signed integer.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_nullable_int8(field_name: str) Optional[int][source]

Reads a nullable 8-bit two’s complement signed integer.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_int16(field_name: str) int[source]

Reads a 16-bit two’s complement signed integer.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_nullable_int16(field_name: str) Optional[int][source]

Reads a nullable 16-bit two’s complement signed integer.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_int32(field_name: str) int[source]

Reads a 32-bit two’s complement signed integer.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_nullable_int32(field_name: str) Optional[int][source]

Reads a nullable 32-bit two’s complement signed integer.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_int64(field_name: str) int[source]

Reads a 64-bit two’s complement signed integer.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_nullable_int64(field_name: str) Optional[int][source]

Reads a nullable 64-bit two’s complement signed integer.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_float32(field_name: str) float[source]

Reads a 32-bit IEEE 754 floating point number.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_nullable_float32(field_name: str) Optional[float][source]

Reads a nullable 32-bit IEEE 754 floating point number.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_float64(field_name: str) float[source]

Reads a 64-bit IEEE 754 floating point number.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_nullable_float64(field_name: str) Optional[float][source]

Reads a nullable 64-bit IEEE 754 floating point number.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_string(field_name: str) Optional[str][source]

Reads an UTF-8 encoded string.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_decimal(field_name: str) Optional[Decimal][source]

Reads an arbitrary precision and scale floating point number.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_time(field_name: str) Optional[time][source]

Reads a time consisting of hour, minute, second, and nanoseconds.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_date(field_name: str) Optional[date][source]

Reads a date consisting of year, month, and day.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_timestamp(field_name: str) Optional[datetime][source]

Reads a timestamp consisting of date and time.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_timestamp_with_timezone(field_name: str) Optional[datetime][source]

Reads a timestamp with timezone consisting of date, time and timezone offset.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_compact(field_name: str) Optional[Any][source]

Reads a compact object.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_boolean(field_name: str) Optional[List[bool]][source]

Reads an array of booleans.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_nullable_boolean(field_name: str) Optional[List[Optional[bool]]][source]

Reads an array of nullable booleans.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_int8(field_name: str) Optional[List[int]][source]

Reads an array of 8-bit two’s complement signed integers.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_nullable_int8(field_name: str) Optional[List[Optional[int]]][source]

Reads an array of nullable 8-bit two’s complement signed integers.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_int16(field_name: str) Optional[List[int]][source]

Reads an array of 16-bit two’s complement signed integers.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_nullable_int16(field_name: str) Optional[List[Optional[int]]][source]

Reads an array of nullable 16-bit two’s complement signed integers.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_int32(field_name: str) Optional[List[int]][source]

Reads an array of 32-bit two’s complement signed integers.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_nullable_int32(field_name: str) Optional[List[Optional[int]]][source]

Reads an array of nullable 32-bit two’s complement signed integers.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_int64(field_name: str) Optional[List[int]][source]

Reads an array of 64-bit two’s complement signed integers.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_nullable_int64(field_name: str) Optional[List[Optional[int]]][source]

Reads an array of nullable 64-bit two’s complement signed integers.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_float32(field_name: str) Optional[List[float]][source]

Reads an array of 32-bit IEEE 754 floating point numbers.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_nullable_float32(field_name: str) Optional[List[Optional[float]]][source]

Reads an array of nullable 32-bit IEEE 754 floating point numbers.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_float64(field_name: str) Optional[List[float]][source]

Reads an array of 64-bit IEEE 754 floating point numbers.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_nullable_float64(field_name: str) Optional[List[Optional[float]]][source]

Reads an array of nullable 64-bit IEEE 754 floating point numbers.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_string(field_name: str) Optional[List[Optional[str]]][source]

Reads an array of UTF-8 encoded strings.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_decimal(field_name: str) Optional[List[Optional[Decimal]]][source]

Reads an array of arbitrary precision and scale floating point numbers.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_time(field_name: str) Optional[List[Optional[time]]][source]

Reads an array of times consisting of hour, minute, second, and nanoseconds.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_date(field_name: str) Optional[List[Optional[date]]][source]

Reads an array of dates consisting of year, month, and day.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_timestamp(field_name: str) Optional[List[Optional[datetime]]][source]

Reads an array of timestamps consisting of date and time.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_timestamp_with_timezone(field_name: str) Optional[List[Optional[datetime]]][source]

Reads an array of timestamp with timezones consisting of date, time and timezone offset.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

abstract read_array_of_compact(field_name: str) Optional[List[Optional[Any]]][source]

Reads an array of compact objects.

Parameters

field_name – Name of the field.

Returns

The value of the field.

Raises

HazelcastSerializationError – If the field does not exist in the schema or the type of the field does not match with the one defined in the schema.

class CompactWriter[source]

Bases: ABC

Provides means of writing compact serialized fields to the binary data.

Warning

This API is in the BETA status and any part of it might be changed without a prior notice, until it is promoted to the stable status.

abstract write_boolean(field_name: str, value: bool) None[source]

Writes a boolean.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_nullable_boolean(field_name: str, value: Optional[bool]) None[source]

Writes a nullable boolean.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_int8(field_name: str, value: int) None[source]

Writes an 8-bit two’s complement signed integer.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_nullable_int8(field_name: str, value: Optional[int]) None[source]

Writes a nullable 8-bit two’s complement signed integer.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_int16(field_name: str, value: int) None[source]

Writes a 16-bit two’s complement signed integer.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_nullable_int16(field_name: str, value: Optional[int]) None[source]

Writes a nullable 16-bit two’s complement signed integer.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_int32(field_name: str, value: int) None[source]

Writes a 32-bit two’s complement signed integer.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_nullable_int32(field_name: str, value: Optional[int]) None[source]

Writes a nullable 32-bit two’s complement signed integer.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_int64(field_name: str, value: int) None[source]

Writes a 64-bit two’s complement signed integer.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_nullable_int64(field_name: str, value: Optional[int]) None[source]

Writes a nullable 64-bit two’s complement signed integer.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_float32(field_name: str, value: float) None[source]

Writes a 32-bit IEEE 754 floating point number.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_nullable_float32(field_name: str, value: Optional[float]) None[source]

Writes a nullable 32-bit IEEE 754 floating point number.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_float64(field_name: str, value: float) None[source]

Writes a 64-bit IEEE 754 floating point number.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_nullable_float64(field_name: str, value: Optional[float]) None[source]

Writes a nullable 64-bit IEEE 754 floating point number.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_string(field_name: str, value: Optional[str]) None[source]

Writes an UTF-8 encoded string.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_decimal(field_name: str, value: Optional[Decimal]) None[source]

Writes an arbitrary precision and scale floating point number.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_time(field_name: str, value: Optional[time]) None[source]

Writes a time consisting of hour, minute, second, and nanoseconds.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_date(field_name: str, value: Optional[date]) None[source]

Writes a date consisting of year, month, and day.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_timestamp(field_name: str, value: Optional[datetime]) None[source]

Writes a timestamp consisting of date and time.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_timestamp_with_timezone(field_name: str, value: Optional[datetime]) None[source]

Writes a timestamp with timezone consisting of date, time, and timezone offset.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_compact(field_name: str, value: Optional[Any]) None[source]

Writes a nested compact object.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_boolean(field_name: str, value: Optional[List[bool]]) None[source]

Writes an array of booleans.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_nullable_boolean(field_name: str, value: Optional[List[Optional[bool]]]) None[source]

Writes an array of nullable booleans.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_int8(field_name: str, value: Optional[List[int]]) None[source]

Writes an array of 8-bit two’s complement signed integers.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_nullable_int8(field_name: str, value: Optional[List[Optional[int]]]) None[source]

Writes an array of nullable 8-bit two’s complement signed integers.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_int16(field_name: str, value: Optional[List[int]]) None[source]

Writes an array of 16-bit two’s complement signed integers.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_nullable_int16(field_name: str, value: Optional[List[Optional[int]]]) None[source]

Writes an array of nullable 16-bit two’s complement signed integers.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_int32(field_name: str, value: Optional[List[int]]) None[source]

Writes an array of 32-bit two’s complement signed integers.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_nullable_int32(field_name: str, value: Optional[List[Optional[int]]]) None[source]

Writes an array of nullable 32-bit two’s complement signed integers.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_int64(field_name: str, value: Optional[List[int]]) None[source]

Writes an array of 64-bit two’s complement signed integers.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_nullable_int64(field_name: str, value: Optional[List[Optional[int]]]) None[source]

Writes an array of nullable 64-bit two’s complement signed integers.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_float32(field_name: str, value: Optional[List[float]]) None[source]

Writes an array of 32-bit IEEE 754 floating point numbers.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_nullable_float32(field_name: str, value: Optional[List[Optional[float]]]) None[source]

Writes an array of nullable 32-bit IEEE 754 floating point numbers.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_float64(field_name: str, value: Optional[List[float]]) None[source]

Writes an array of 64-bit IEEE 754 floating point numbers.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_nullable_float64(field_name: str, value: Optional[List[Optional[float]]]) None[source]

Writes an array of nullable 64-bit IEEE 754 floating point numbers.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_string(field_name: str, value: Optional[List[Optional[str]]]) None[source]

Writes an array of UTF-8 encoded strings.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_decimal(field_name: str, value: Optional[List[Optional[Decimal]]]) None[source]

Writes an array of arbitrary precision and scale floating point numbers.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_time(field_name: str, value: Optional[List[Optional[time]]]) None[source]

Writes an array of times consisting of hour, minute, second, and nanoseconds.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_date(field_name: str, value: Optional[List[Optional[date]]]) None[source]

Writes an array of dates consisting of year, month, and day.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_timestamp(field_name: str, value: Optional[List[Optional[datetime]]]) None[source]

Writes an array of timestamps consisting of date and time.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_timestamp_with_timezone(field_name: str, value: Optional[List[Optional[datetime]]]) None[source]

Writes an array of timestamps with timezone consisting of date, time, and timezone offset.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

abstract write_array_of_compact(field_name: str, value: Optional[List[Optional[Any]]]) None[source]

Writes an array of nested compact objects.

Parameters
  • field_name – Name of the field.

  • value – Value to be written.

class CompactSerializer(*args, **kwds)[source]

Bases: Generic[CompactSerializableClass], ABC

Defines the contract of the serializers used for Compact serialization.

write() and read() methods must be consistent with each other.

Warning

This API is in the BETA status and any part of it might be changed without a prior notice, until it is promoted to the stable status.

abstract read(reader: CompactReader) CompactSerializableClass[source]

Deserializes the object from the reader.

Parameters

reader – Reader to read fields of an object.

Returns

The object read.

Raises

hazelcast.errors.HazelcastSerializationError – In case of failure to read.

abstract write(writer: CompactWriter, obj: CompactSerializableClass) None[source]

Serializes the object to writer.

Parameters
  • writer – Writer to serialize the fields.

  • obj – Object to be serialized.

Raises

hazelcast.errors.HazelcastSerializationError – In case of failure to write.

abstract get_class() Type[CompactSerializableClass][source]

Returns the class that this serializer reads or writes.

Returns

The class that this serializer reads or writes.

abstract get_type_name() str[source]

Returns the unique type name associated with :const`CompactSerializableClass`.

Returns

The type name.