Interface WireTransferable
- All Known Implementing Classes:
FrameWireTransferable
RowsAndColumns over the wire.
Serialization and Deserialization are a weird beast. It is very easy to follow an Object-Oriented mechanism for serializing out an object, but when you want to deserialize, it is unclear exactly which class should be deserialized. This requires extra metadata that helps point the deserializing code to how to interpret the bytes.
The WireTransferable works by serializing the object as a singular byte array, the first byte of the byte array
is interpretted as an unsigned integer (N) and represents the length of the "extra metadata" to identify the correct
deserializer. Those N bytes are read as a utf8 String and used to look up the deserialization logic. This
identifier must be registered with DruidSecondaryModule.getWireTransferableDeserializerBinder(com.google.inject.Binder), which will
use the identifier to look up the logic and deserialize the RowsAndColumns object.
There is, intentionally, no default implementation of WireTransferable that just wraps a RowsAndColumns,
this is because the point at which data is transfered over the wire tends to be a very sensitive point in terms of
what the best format for transmission is and what optimizations are available. As such, we don't want a concrete
class that makes its way to the wire to accidentally get a least-common-denominator serialization and instead want
it to be explicitly chosen.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classA holder class for a byte array, offset and length, this exists to minimize copies.static classstatic interface -
Method Summary
Modifier and TypeMethodDescriptionserializedBytes(com.fasterxml.jackson.databind.ObjectMapper mapper) Serializes the object into bytes.
-
Method Details
-
serializedBytes
WireTransferable.ByteArrayOffsetAndLen serializedBytes(com.fasterxml.jackson.databind.ObjectMapper mapper) throws IOException Serializes the object into bytes. This method is passed a jackson ObjectMapper that can be used to serialize objects if needed. In general, it's better to generate binary serializations and not rely on the mapper but it's there as an expediency layer to support some compatibility stuff. Hopefully it goes away at some point.- Parameters:
mapper- ObjectMapper- Returns:
- bytes that represent the wire-format of this object
- Throws:
IOException- a problem with IO
-