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
Writeables 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 DelayableWriteables coming from different nodes may be buffered
on the receiver end, which may hold a mix of DelayableWriteables 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 ClassesModifier and TypeClassDescriptionstatic classDelayableWriteable.Serialized<T extends Writeable>AWriteablestored 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 Texpand()Expands the innerWriteableto its original representation and returns itabstract longReturns the serialized size of the innerWriteable.static longReturns 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, waitMethods 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 innerWriteableto 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.
-