Class BinaryDtoValueCodec<T extends BinaryDto<T>>
java.lang.Object
io.datarouter.bytes.binarydto.codec.BinaryDtoValueCodec<T>
public class BinaryDtoValueCodec<T extends BinaryDto<T>> extends Object
For encoding non-key fields.
The output is not comparable, but it allows adding and removing fields while staying backwards compatible with data
serialized by previous dto versions.
Note that index re-use is dangerous unless you are certain that persisted data is free of the previous index. There
is not much benefit to reusing an index, only a tiny bit if you are exceeding index 127, which is where the varint
encoding starts taking a second byte.
Fields are made of 3 pieces:
- index, as specified in the field's annotation or inferred by alphabetical field order
- length, the number of bytes in the value section.
- We need this to know how many bytes to skip in case the field is removed from the dto.
- value, the actual value bytes for the field
-
Field Summary
Fields Modifier and Type Field Description Class<T>dtoClassList<Field>fieldsList<? extends BinaryDtoFieldSchema<?>>fieldSchemas -
Method Summary
Modifier and Type Method Description byte[]encode(T dto)List<Field>getFieldsOrdered()static <T extends BinaryDto<T>>
BinaryDtoValueCodec<T>of(Class<? extends T> dtoClass)
-
Field Details
-
dtoClass
-
fields
-
fieldSchemas
-
-
Method Details
-
of
-
getFieldsOrdered
-
encode
-