Class DelayableWriteable<T extends Writeable>
java.lang.Object
org.elasticsearch.common.io.stream.DelayableWriteable<T>
- All Implemented Interfaces:
Writeable
- Direct Known Subclasses:
DelayableWriteable.Serialized
public abstract class DelayableWriteable<T extends Writeable> extends java.lang.Object implements Writeable
A holder for
Writeable
s that delays reading the underlying object
on the receiving end. To be used for objects whose deserialized
representation is inefficient to keep in memory compared to their
corresponding serialized representation.
The node that produces the Writeable
calls referencing(Writeable)
to create a DelayableWriteable
that serializes the inner object
first to a buffer and writes the content of the buffer to the StreamOutput
.
The receiver node calls delayed(Reader, StreamInput)
to create a
DelayableWriteable
that reads the buffer from the @link StreamInput
but delays creating the actual object by calling expand()
when needed.
Multiple DelayableWriteable
s coming from different nodes may be buffered
on the receiver end, which may hold a mix of DelayableWriteable
s that were
produced locally (hence expanded) as well as received form another node (hence subject
to delayed expansion). When such objects are buffered for some time it may be desirable
to force their buffering in serialized format by calling
asSerialized(Reader, NamedWriteableRegistry)
.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DelayableWriteable.Serialized<T extends Writeable>
AWriteable
stored in serialized form.Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Method Summary
Modifier and Type Method Description abstract DelayableWriteable.Serialized<T>
asSerialized(Writeable.Reader<T> reader, NamedWriteableRegistry registry)
Returns a DelayableWriteable that stores its contents in serialized form.static <T extends Writeable>
DelayableWriteable<T>delayed(Writeable.Reader<T> reader, StreamInput in)
Build a DelayableWriteable that copies a buffer from the provided StreamInput and deserializes the buffer whenexpand()
is called.abstract T
expand()
Expands the innerWriteable
to its original representation and returns itabstract long
getSerializedSize()
Returns the serialized size of the innerWriteable
.static long
getSerializedSize(Writeable ref)
Returns the serialized size in bytes of the providedWriteable
.static <T extends Writeable>
DelayableWriteable<T>referencing(T reference)
Build a DelayableWriteable that wraps an existing object but is serialized so that deserializing it can be delayed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
referencing
Build a DelayableWriteable that wraps an existing object but is serialized so that deserializing it can be delayed. -
delayed
public static <T extends Writeable> DelayableWriteable<T> delayed(Writeable.Reader<T> reader, StreamInput in) throws java.io.IOExceptionBuild a DelayableWriteable that copies a buffer from the provided StreamInput and deserializes the buffer whenexpand()
is called.- Throws:
java.io.IOException
-
asSerialized
public abstract DelayableWriteable.Serialized<T> asSerialized(Writeable.Reader<T> reader, NamedWriteableRegistry registry)Returns a DelayableWriteable that stores its contents in serialized form. -
expand
Expands the innerWriteable
to its original representation and returns it -
getSerializedSize
public abstract long getSerializedSize()Returns the serialized size of the innerWriteable
. -
getSerializedSize
Returns the serialized size in bytes of the providedWriteable
.
-