Top Description Inners Fields Constructors Methods
com.amazon.ion.impl

pack-priv final Class IonReaderContinuableTopLevelBinary

extends IonReaderContinuableApplicationBinary
implements IonReader, _Private_ReaderWriter
Class Inheritance
All Implemented Interfaces
com.amazon.ion.impl._Private_ReaderWriter, com.amazon.ion.IonReader, com.amazon.ion.facet.Faceted, java.io.Closeable, java.lang.AutoCloseable
Imports
com.amazon.ion.IonBufferConfiguration, .IonException, .IonReader, .IonCursor, .IonType, .OffsetSpan, .OversizedValueException, .RawValueSpanProvider, .SeekableReader, .Span, .SpanProvider, .SymbolTable, com.amazon.ion.system.IonReaderBuilder, java.io.InputStream

An optionally continuable (i.e., incremental) binary IonReader implementation. Continuability is enabled using IonReaderBuilder.withIncrementalReadingEnabled(true).

When continuable reading is enabled, if IonReader#next() returns null at the top-level, it indicates that there is not (yet) enough data in the stream to complete a top-level value. The user may wait for more data to become available in the stream and call IonReader#next() again to continue reading. Unlike the non-incremental reader, the continuable reader will never throw an exception due to unexpected EOF during next(). If, however, IonReader#close() is called when an incomplete value is buffered, the reader will raise an IonException.

There is one caveat with the continuable reader implementation: it must be able to buffer an entire top-level value and any preceding system values (Ion version marker(s) and symbol table(s)) in memory. This means that each value and preceding system values must be no larger than any of the following:

This will not be a problem for the vast majority of Ion streams, as it is rare for a single top-level value or symbol table to exceed a few megabytes in size. However, if the size of the stream's values risk exceeding the available memory, then continuable reading must not be used.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class
IonReaderContinuableTopLevelBinary.RawValueSpanProviderFacet

References Deprecated RawValueSpanProvider is deprecated or references (maybe indirectly) at least one deprecated element.
private class
private class

Field Summary

Modifier and TypeField and Description
private boolean
private final boolean
private final boolean
private SymbolTable
private IonType

Constructor Summary

AccessConstructor and Description
pack-priv
IonReaderContinuableTopLevelBinary(IonReaderBuilder
the builder containing the configuration for the new reader.
builder
,
InputStream inputStream, byte[]
the byte array containing the bytes already read (often the IVM).
alreadyRead
,
int
the offset into 'alreadyRead` at which the first byte that was already read exists.
alreadyReadOff
,
int
the number of bytes already read from `alreadyRead`.
alreadyReadLen
)

Constructs a new reader from the given input stream.

pack-priv
IonReaderContinuableTopLevelBinary(IonReaderBuilder
the builder containing the configuration for the new reader.
builder
,
byte[]
the byte array containing the bytes to read.
data
,
int
the offset into the byte array at which the first byte of Ion data begins.
offset
,
int
the number of bytes to be read from the byte array.
length
)

Constructs a new reader from the given byte array.

Method Summary

Modifier and TypeMethod and Description
public <T> T
asFacet(Class<T>
The type token of the requested facet type.
facetType
)

Implements com.amazon.ion.facet.Faceted.asFacet.

Returns a facet of this subject if supported.

public void
close()

Overrides com.amazon.ion.impl.IonReaderContinuableCoreBinary.close.

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

public IonType
getType()

Overrides com.amazon.ion.impl.IonReaderContinuableCoreBinary.getType.

Implements com.amazon.ion.IonReader.getType, com.amazon.ion.impl.IonReaderContinuableCore.getType.

Returns the type of the current value, or null if there is no current value.

private void
handleIncompleteValue()

Handles the case where the current value extends beyond the end of the reader's internal buffer.

public boolean
hasNext()

Implements com.amazon.ion.IonReader.hasNext.

Determines whether there is another value at the current depth; in other words whether there is a sibling value that may be reached using next().

public IonType
next()

Implements com.amazon.ion.IonReader.next.

Positions this reader on the next sibling after the current value, returning the type of that value.

private void
nextAndFill()

Advances to the next value and attempts to fill it.

public SymbolTable
pack-priv void
prepareScalar()

Overrides com.amazon.ion.impl.IonReaderContinuableCoreBinary.prepareScalar.

Prepares a scalar value to be parsed by ensuring it is present in the buffer.

public void
stepIn()

Implements com.amazon.ion.IonReader.stepIn.

Positions the reader just before the contents of the current value, which must be a container (list, sexp, or struct).

public void
stepOut()

Implements com.amazon.ion.IonReader.stepOut.

Positions the iterator after the current parent's value, moving up one level in the data hierarchy.

Inherited from com.amazon.ion.impl.IonReaderContinuableApplicationBinary:
getFieldNamegetFieldNameSymbolgetSymbolgetSymbolTablegetTypeAnnotationsgetTypeAnnotationSymbolsiterateTypeAnnotationsnextValuerestoreSymbolTablestartsWithIonSymbolTablestringValuesymbolValue

Field Detail

isFillingValueback to summary
private boolean isFillingValue
isFillRequiredback to summary
private final boolean isFillRequired
isNonContinuableback to summary
private final boolean isNonContinuable
symbolTableLastTransferredback to summary
private SymbolTable symbolTableLastTransferred
typeback to summary
private IonType type

Constructor Detail

IonReaderContinuableTopLevelBinaryback to summary
pack-priv IonReaderContinuableTopLevelBinary(IonReaderBuilder builder, InputStream inputStream, byte[] alreadyRead, int alreadyReadOff, int alreadyReadLen)

Constructs a new reader from the given input stream.

Parameters
builder:IonReaderBuilder

the builder containing the configuration for the new reader.

alreadyRead:byte[]

the byte array containing the bytes already read (often the IVM).

alreadyReadOff:int

the offset into 'alreadyRead` at which the first byte that was already read exists.

alreadyReadLen:int

the number of bytes already read from `alreadyRead`.

IonReaderContinuableTopLevelBinaryback to summary
pack-priv IonReaderContinuableTopLevelBinary(IonReaderBuilder builder, byte[] data, int offset, int length)

Constructs a new reader from the given byte array.

Parameters
builder:IonReaderBuilder

the builder containing the configuration for the new reader.

data:byte[]

the byte array containing the bytes to read.

offset:int

the offset into the byte array at which the first byte of Ion data begins.

length:int

the number of bytes to be read from the byte array.

Method Detail

asFacetback to summary
public <T> T asFacet(Class<T> facetType)

Implements com.amazon.ion.facet.Faceted.asFacet.

Doc from com.amazon.ion.facet.Faceted.asFacet.

Returns a facet of this subject if supported.

Parameters
<T>
The requested facet type.
facetType:Class<T>

The type token of the requested facet type.

Returns:T

An instance of T representing the facet of the subject, or null if the facet is not supported by the subject.

Annotations
@Override
closeback to summary
public void close()

Overrides com.amazon.ion.impl.IonReaderContinuableCoreBinary.close.

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
getTypeback to summary
public IonType getType()

Overrides com.amazon.ion.impl.IonReaderContinuableCoreBinary.getType.

Implements com.amazon.ion.IonReader.getType, com.amazon.ion.impl.IonReaderContinuableCore.getType.

Doc from com.amazon.ion.IonReader.getType.

Returns the type of the current value, or null if there is no current value.

Annotations
@Override
handleIncompleteValueback to summary
private void handleIncompleteValue()

Handles the case where the current value extends beyond the end of the reader's internal buffer.

hasNextback to summary
public boolean hasNext()

Implements com.amazon.ion.IonReader.hasNext.

Doc from com.amazon.ion.IonReader.hasNext.

Determines whether there is another value at the current depth; in other words whether there is a sibling value that may be reached using next(). This method may be called multiple times, which does not move the current position.

Warning

this method alters the internal state of the reader such that you cannot reliably get values from the "current" element. The only thing you should call after hasNext() is next()!

Annotations
@Override
nextback to summary
public IonType next()

Implements com.amazon.ion.IonReader.next.

Doc from com.amazon.ion.IonReader.next.

Positions this reader on the next sibling after the current value, returning the type of that value. Once so positioned the contents of this value can be accessed with the *Value() methods.

A sequence of next() calls traverses the data at a constant depth, within the same container. Use stepIn() to traverse down into any containers, and stepOut() to traverse up to the parent container.

Returns:IonType

the type of the next Ion value (never IonType#DATAGRAM), or null when there are no more elements at the current depth in the same container.

Annotations
@Override
nextAndFillback to summary
private void nextAndFill()

Advances to the next value and attempts to fill it.

pop_passed_symbol_tableback to summary
public SymbolTable pop_passed_symbol_table()

Implements com.amazon.ion.impl._Private_ReaderWriter.pop_passed_symbol_table.

Annotations
@Override
prepareScalarback to summary
pack-priv void prepareScalar()

Overrides com.amazon.ion.impl.IonReaderContinuableCoreBinary.prepareScalar.

Prepares a scalar value to be parsed by ensuring it is present in the buffer.

Annotations
@Override
stepInback to summary
public void stepIn()

Implements com.amazon.ion.IonReader.stepIn.

Doc from com.amazon.ion.IonReader.stepIn.

Positions the reader just before the contents of the current value, which must be a container (list, sexp, or struct). There's no current value immediately after stepping in, so the next thing you'll want to do is call next() to move onto the first child value (or learn that there's not one).

Stepping into a null container (null.list, null.sexp, or null.struct) behaves as if the container were empty ([], (), or {}).

At any time stepOut() may be called to move the cursor back to (just after) the parent value, even if there's more children remaining.

Annotations
@Override
stepOutback to summary
public void stepOut()

Implements com.amazon.ion.IonReader.stepOut.

Doc from com.amazon.ion.IonReader.stepOut.

Positions the iterator after the current parent's value, moving up one level in the data hierarchy. There's no current value immediately after stepping out, so the next thing you'll want to do is call next() to move onto the following value.

Annotations
@Override
com.amazon.ion.impl back to summary

private Class IonReaderContinuableTopLevelBinary.IonReaderBinarySpan

extends DowncastingFaceted
implements Span, OffsetSpan
Class Inheritance
All Implemented Interfaces
com.amazon.ion.OffsetSpan, com.amazon.ion.Span, com.amazon.ion.facet.Faceted

Field Summary

Modifier and TypeField and Description
pack-priv final long
pack-priv final long
pack-priv final SymbolTable
pack-priv final long

Constructor Summary

AccessConstructor and Description
pack-priv
IonReaderBinarySpan(long
the offset of the span's first byte in the cursor's internal buffer.
bufferOffset
,
long
the offset after the span's last byte in the cursor's internal buffer.
bufferLimit
,
long
the total stream offset of the span's first byte. This can differ from 'bufferOffset' if the cursor's internal buffer is refillable, such as when it consumes data from an input stream.
totalOffset
,
SymbolTable
the symbol table active where the span occurs.
symbolTable
)

Method Summary

Modifier and TypeMethod and Description
public long
getFinishOffset()

Implements com.amazon.ion.OffsetSpan.getFinishOffset.

Returns this span's finish position as a zero-based offset within the source.

public long
getStartOffset()

Implements com.amazon.ion.OffsetSpan.getStartOffset.

Returns this span's start position as a zero-based offset within the source.

Inherited from com.amazon.ion.impl.DowncastingFaceted:
asFacet

Field Detail

bufferLimitback to summary
pack-priv final long bufferLimit
bufferOffsetback to summary
pack-priv final long bufferOffset
symbolTableback to summary
pack-priv final SymbolTable symbolTable
totalOffsetback to summary
pack-priv final long totalOffset

Constructor Detail

IonReaderBinarySpanback to summary
pack-priv IonReaderBinarySpan(long bufferOffset, long bufferLimit, long totalOffset, SymbolTable symbolTable)
Parameters
bufferOffset:long

the offset of the span's first byte in the cursor's internal buffer.

bufferLimit:long

the offset after the span's last byte in the cursor's internal buffer.

totalOffset:long

the total stream offset of the span's first byte. This can differ from 'bufferOffset' if the cursor's internal buffer is refillable, such as when it consumes data from an input stream.

symbolTable:SymbolTable

the symbol table active where the span occurs.

Method Detail

getFinishOffsetback to summary
public long getFinishOffset()

Implements com.amazon.ion.OffsetSpan.getFinishOffset.

Doc from com.amazon.ion.OffsetSpan.getFinishOffset.

Returns this span's finish position as a zero-based offset within the source. In some cases, the finish position is implicit and this method returns -1. This includes most text sources, since in general (notably for containers) the finish offset can't be determined without significant effort to parse to the end of the value.

Annotations
@Override
getStartOffsetback to summary
public long getStartOffset()

Implements com.amazon.ion.OffsetSpan.getStartOffset.

Doc from com.amazon.ion.OffsetSpan.getStartOffset.

Returns this span's start position as a zero-based offset within the source.

Annotations
@Override
com.amazon.ion.impl back to summary

private Class IonReaderContinuableTopLevelBinary.RawValueSpanProviderFacet

extends Object
implements RawValueSpanProvider
Class Inheritance
  • java.lang.Object
  • com.amazon.ion.impl.IonReaderContinuableTopLevelBinary.RawValueSpanProviderFacet
All Implemented Interfaces
com.amazon.ion.RawValueSpanProvider

References Deprecated

RawValueSpanProvider is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public byte[]
public Span
valueSpan()

Implements com.amazon.ion.RawValueSpanProvider.valueSpan.

Constructs a Span, which may be faceted as an OffsetSpan, that provides the start and end byte positions of the current value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

RawValueSpanProviderFacetback to summary
private RawValueSpanProviderFacet()

Method Detail

bufferback to summary
public byte[] buffer()

Implements com.amazon.ion.RawValueSpanProvider.buffer.

Returns:byte[]

Doc from com.amazon.ion.RawValueSpanProvider.buffer.

the byte[] that backs this span. This span's start and end positions may be used as indices into the returned buffer.

Note

does NOT perform a copy of the buffer; care must be taken not to mutate and corrupt the data.

Annotations
@Override
valueSpanback to summary
public Span valueSpan()

Implements com.amazon.ion.RawValueSpanProvider.valueSpan.

Doc from com.amazon.ion.RawValueSpanProvider.valueSpan.

Constructs a Span, which may be faceted as an OffsetSpan, that provides the start and end byte positions of the current value.

Note

for Ion int values, users should not use these byte positions to determine which primitive (if any) the value can fit into, because the sign of Ion int values is encoded into the type ID byte, which is not included in this span.

Warning

Spans provided by this method are not compatible with the SeekableReader facet, because they lack the type ID and length bytes that are important when reconstructing the context on seek. For SpanProvider#currentSpan() should be used to retrieve seekable Spans.

Returns:Span

the constructed Span

Annotations
@Override
com.amazon.ion.impl back to summary

private Class IonReaderContinuableTopLevelBinary.SeekableReaderFacet

extends SpanProviderFacet
implements SeekableReader
Class Inheritance
All Implemented Interfaces
com.amazon.ion.SeekableReader, com.amazon.ion.SpanProvider

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
hoist(Span span)

Implements com.amazon.ion.SeekableReader.hoist.

Seeks this reader to produce the given span as if its values were at top-level.

Inherited from com.amazon.ion.impl.IonReaderContinuableTopLevelBinary.SpanProviderFacet:
currentSpan

Constructor Detail

SeekableReaderFacetback to summary
private SeekableReaderFacet()

Method Detail

hoistback to summary
public void hoist(Span span)

Implements com.amazon.ion.SeekableReader.hoist.

Doc from com.amazon.ion.SeekableReader.hoist.

Seeks this reader to produce the given span as if its values were at top-level. The caller cannot stepOut from the span nor continue reading beyond it.

After calling this method, this reader's current span will be empty and positioned just before the first value of the given span; the caller must call next() to begin reading values. At the end of the span, the reader will behave as if it's at EOF regardless whether the source has more data beyond the span.

Hoisting makes the span's values appear to be at top-level even if they have containers in the source. The depth will be zero, and calls to getFieldName() will return null even if the span's original parent was a struct.

Annotations
@Override
com.amazon.ion.impl back to summary

private Class IonReaderContinuableTopLevelBinary.SpanProviderFacet

extends Object
implements SpanProvider
Class Inheritance
  • java.lang.Object
  • com.amazon.ion.impl.IonReaderContinuableTopLevelBinary.SpanProviderFacet
All Implemented Interfaces
com.amazon.ion.SpanProvider
Known Direct Subclasses
com.amazon.ion.impl.IonReaderContinuableTopLevelBinary.SeekableReaderFacet

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Span
currentSpan()

Implements com.amazon.ion.SpanProvider.currentSpan.

Gets the current span of this object, generally covering a single value on the source.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

SpanProviderFacetback to summary
private SpanProviderFacet()

Method Detail

currentSpanback to summary
public Span currentSpan()

Implements com.amazon.ion.SpanProvider.currentSpan.

Doc from com.amazon.ion.SpanProvider.currentSpan.

Gets the current span of this object, generally covering a single value on the source.

Annotations
@Override