Package ai.djl.inference.streaming
Class PublisherBytesSupplier
- java.lang.Object
-
- ai.djl.inference.streaming.PublisherBytesSupplier
-
- All Implemented Interfaces:
BytesSupplier
public class PublisherBytesSupplier extends java.lang.Object implements BytesSupplier
AnPublisherBytesSupplieris a streamingBytesSuppliersuitable for reactive asynchronous usage.
-
-
Constructor Summary
Constructors Constructor Description PublisherBytesSupplier()Constructs aPublisherBytesSupplier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendContent(byte[] data, boolean lastChunk)Appends content to theBytesSupplier.java.util.concurrent.CompletableFuture<java.lang.Void>subscribe(java.util.function.Consumer<byte[]> subscriber)Adds the subscriber to theBytesSupplierto get notified about additional data.java.nio.ByteBuffertoByteBuffer()Returns theByteBufferpresentation of the object.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ai.djl.ndarray.BytesSupplier
getAsBytes, getAsObject, getAsString
-
-
-
-
Constructor Detail
-
PublisherBytesSupplier
public PublisherBytesSupplier()
Constructs aPublisherBytesSupplier.
-
-
Method Detail
-
appendContent
public void appendContent(byte[] data, boolean lastChunk)Appends content to theBytesSupplier.- Parameters:
data- bytes to appendlastChunk- true if this is the last chunk
-
subscribe
public java.util.concurrent.CompletableFuture<java.lang.Void> subscribe(java.util.function.Consumer<byte[]> subscriber)
Adds the subscriber to theBytesSupplierto get notified about additional data.- Parameters:
subscriber- a consumer function that will receive bytes when new daata is added and null when completed- Returns:
- a
CompletableFutureobject
-
toByteBuffer
public java.nio.ByteBuffer toByteBuffer()
Returns theByteBufferpresentation of the object.- Specified by:
toByteBufferin interfaceBytesSupplier- Returns:
- the
ByteBufferpresentation of the object
-
-