@NotThreadSafe public class SelectObjectContentEventStream extends Object implements Closeable
SelectObjectContentEvent
s, generated as the result of a call
to AmazonS3.selectObjectContent(SelectObjectContentRequest)
.
This stream is usually read by one of getEventsIterator()
, visitAllEvents(SelectObjectContentEventVisitor)
,
getRecordsInputStream()
or (for smaller results) getAllEvents()
.SelectObjectContentResult.getPayload()
Constructor and Description |
---|
SelectObjectContentEventStream(SdkFilterInputStream inputStream) |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Abort this stream, potentially before all events have been read.
|
void |
close()
Close this stream, after all events have been read.
|
List<SelectObjectContentEvent> |
getAllEvents()
Read all of the
SelectObjectContentEvent s from this stream into memory. |
Iterator<SelectObjectContentEvent> |
getEventsIterator()
Retrieve an iterator over the
SelectObjectContentEvent s in this stream, in the order they are returned by S3. |
SelectRecordsInputStream |
getRecordsInputStream()
Retrieve an input stream to the subset of the S3 object that matched the query.
|
SelectRecordsInputStream |
getRecordsInputStream(SelectObjectContentEventVisitor listener)
Retrieve an input stream to the subset of the S3 object that matched the query.
|
void |
visitAllEvents(SelectObjectContentEventVisitor visitor)
Apply the provided
SelectObjectContentEventVisitor to each SelectObjectContentEvent in this stream
in the order they are returned by S3. |
public SelectObjectContentEventStream(SdkFilterInputStream inputStream)
public List<SelectObjectContentEvent> getAllEvents() throws SelectObjectContentEventException
SelectObjectContentEvent
s from this stream into memory. For large objects, lazy-loading using
getEventsIterator()
, getRecordsInputStream()
or visitAllEvents(SelectObjectContentEventVisitor)
should be used instead.
This will raise a runtime exception if visitAllEvents(SelectObjectContentEventVisitor)
,
getRecordsInputStream()
or getEventsIterator()
have already been used.
After using this method, you still must close()
this object to release the connection to S3.public void visitAllEvents(SelectObjectContentEventVisitor visitor) throws SelectObjectContentEventException
SelectObjectContentEventVisitor
to each SelectObjectContentEvent
in this stream
in the order they are returned by S3. This will lazily-load the events from S3, minimizing the amount of memory used.
This will raise a runtime exception if getAllEvents()
, getRecordsInputStream()
or getEventsIterator()
have already been used.
After using this method, you still must close()
this object to release the connection to S3.visitor
- The visitor that should be applied to each event in this stream.SelectObjectContentEventException
public Iterator<SelectObjectContentEvent> getEventsIterator() throws SelectObjectContentEventException
SelectObjectContentEvent
s in this stream, in the order they are returned by S3. This
will lazily-load the events from S3, minimizing the amount of memory used.
This will raise a runtime exception if getAllEvents()
, visitAllEvents(SelectObjectContentEventVisitor)
or getRecordsInputStream()
have already been used.
After using this method, you still must close()
this object to release the connection to S3.public SelectRecordsInputStream getRecordsInputStream() throws SelectObjectContentEventException
SelectObjectContentEvent.RecordsEvent
s into an InputStream
. This will lazily-load the content from
S3, minimizing the amount of memory used.
This will raise a runtime exception if getAllEvents()
, visitAllEvents(SelectObjectContentEventVisitor)
or getEventsIterator()
have already been used.
Like all streams, you should SelectRecordsInputStream.close()
it after the content has been read. This
is equivalent to calling close()
on this SelectObjectContentEventStream
.public SelectRecordsInputStream getRecordsInputStream(SelectObjectContentEventVisitor listener) throws SelectObjectContentEventException
SelectObjectContentEvent.RecordsEvent
s into an InputStream
. This will lazily-load the content from
S3, minimizing the amount of memory used.
Unlike getRecordsInputStream()
, this allows you to provide a "listener" SelectObjectContentEventVisitor
that intercepts the events returned by S3 while the thread that called SdkFilterInputStream.read()
blocks
waiting for S3 to return a response.
This will raise a runtime exception if getAllEvents()
, visitAllEvents(SelectObjectContentEventVisitor)
or getEventsIterator()
have already been used.
Like all streams, you should SelectRecordsInputStream.close()
it after the content has been read. This
is equivalent to calling close()
on this SelectObjectContentEventStream
.listener
- A visitor for monitoring the progress of the query between SelectObjectContentEvent.RecordsEvent
s.SelectObjectContentEventException
getRecordsInputStream()
public void abort()
close()
if there are
still events pending on the stream. Using this method has a performance impact, because it will forcibly close the active
connection to S3, whereas reading to end of the stream before calling close()
will still allow the connection to
be reused.public void close() throws IOException
abort()
to signal an intent to only partially read events in the
stream.close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2018. All rights reserved.