public class FlightStream extends Object implements AutoCloseable
Modifier and Type | Class and Description |
---|---|
static interface |
FlightStream.Cancellable
Provides a callback to cancel a process that is in progress.
|
static interface |
FlightStream.Requestor
Provides a interface to request more items from a stream producer.
|
Constructor and Description |
---|
FlightStream(BufferAllocator allocator,
int pendingTarget,
FlightStream.Cancellable cancellable,
FlightStream.Requestor requestor)
Constructs a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel(String message,
Throwable exception)
Cancels sending the stream to a client.
|
void |
close()
Closes the stream (freeing any existing resources).
|
FlightDescriptor |
getDescriptor()
Get the descriptor for this stream.
|
DictionaryProvider |
getDictionaryProvider()
Get the provider for dictionaries in this stream.
|
ArrowBuf |
getLatestMetadata()
Get the most recent metadata sent from the server.
|
VectorSchemaRoot |
getRoot()
Get the current vector data from the stream.
|
Schema |
getSchema()
Get the schema for this stream.
|
boolean |
hasRoot()
Check if there is a root (i.e.
|
boolean |
next()
Blocking request to load next item into list.
|
DictionaryProvider |
takeDictionaryOwnership()
Get an owned reference to the dictionaries in this stream.
|
public FlightStream(BufferAllocator allocator, int pendingTarget, FlightStream.Cancellable cancellable, FlightStream.Requestor requestor)
allocator
- The allocator to use for creating/reallocating buffers for Vectors.pendingTarget
- Target number of messages to receive.cancellable
- Used to cancel mid-stream requests.requestor
- A callback to determine how many pending items there are.public Schema getSchema()
public DictionaryProvider getDictionaryProvider()
Does NOT retain a reference to the underlying dictionaries. Dictionaries may be updated as the stream is read. This method is intended for stream processing, where the application code will not retain references to values after the stream is closed.
IllegalStateException
- if takeDictionaryOwnership()
was calledtakeDictionaryOwnership()
public DictionaryProvider takeDictionaryOwnership()
If called, the client is responsible for closing the dictionaries in this provider. Can only be called once.
IllegalStateException
- if called more than once.public FlightDescriptor getDescriptor()
public void close() throws Exception
If the stream isn't complete and is cancellable, this method will cancel and drain the stream first.
close
in interface AutoCloseable
Exception
public boolean next()
public VectorSchemaRoot getRoot()
The data in the root may change at any time. Clients should NOT modify the root, but instead unload the data into their own root.
FlightRuntimeException
- if there was an error reading the schema from the stream.public boolean hasRoot()
next()
.public ArrowBuf getLatestMetadata()
next()
if the server
sends a message without metadata. This does NOT take ownership of the buffer - call retain() to create a reference
if you need the buffer after a call to next()
.Copyright © 2023 The Apache Software Foundation. All rights reserved.