Class DelayableWriteable<T extends Writeable>
java.lang.Object
org.elasticsearch.common.io.stream.DelayableWriteable<T>
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Writeable
,org.elasticsearch.core.Releasable
- Direct Known Subclasses:
DelayableWriteable.Serialized
public abstract class DelayableWriteable<T extends Writeable>
extends Object
implements Writeable, org.elasticsearch.core.Releasable
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
Modifier and TypeClassDescriptionstatic class
DelayableWriteable.Serialized<T extends Writeable>
AWriteable
stored in serialized form backed by aReleasableBytesReference
.Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Method Summary
Modifier and TypeMethodDescriptionabstract 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
Returns the serialized size of the innerWriteable
.static long
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
Methods inherited from interface org.elasticsearch.core.Releasable
close
-
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 IOExceptionBuild a DelayableWriteable that copies a buffer from the provided StreamInput and deserializes the buffer whenexpand()
is called.- Throws:
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
.
-