Package org.apache.nifi.stream.io.util
Class AbstractDemarcator
java.lang.Object
org.apache.nifi.stream.io.util.AbstractDemarcator
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
StreamDemarcator,TextLineDemarcator
Base class for implementing streaming demarcators.
NOTE: Not intended for multi-thread usage hence not Thread-safe.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int(package private) byte[](package private) int(package private) static final intprivate final intprivate final InputStream(package private) intprivate final int(package private) long -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDemarcator(InputStream is, int maxDataSize) Constructs an instance of demarcator with providedInputStreamand max buffer size.AbstractDemarcator(InputStream is, int maxDataSize, int initialBufferSize) Constructs an instance of demarcator with providedInputStreamand max buffer size and initial buffer size. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()(package private) byte[]extractDataToken(int length) Will extract data token of the provided length from the current buffer starting at the 'mark'.(package private) voidfill()Will fill the current buffer from current 'index' position, expanding it and or shuffling it if necessary.private voidvalidate(InputStream is, int maxDataSize, int initialBufferSize) Validates prerequisites for constructor arguments
-
Field Details
-
INIT_BUFFER_SIZE
static final int INIT_BUFFER_SIZE- See Also:
-
is
-
initialBufferSize
private final int initialBufferSize -
maxDataSize
private final int maxDataSize -
buffer
byte[] buffer -
index
int index -
mark
int mark -
offset
long offset -
availableBytesLength
int availableBytesLength
-
-
Constructor Details
-
AbstractDemarcator
AbstractDemarcator(InputStream is, int maxDataSize) Constructs an instance of demarcator with providedInputStreamand max buffer size. Each demarcated token must fit within max buffer size, otherwise the exception will be raised. -
AbstractDemarcator
AbstractDemarcator(InputStream is, int maxDataSize, int initialBufferSize) Constructs an instance of demarcator with providedInputStreamand max buffer size and initial buffer size. Each demarcated token must fit within max buffer size, otherwise the exception will be raised.
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
fill
Will fill the current buffer from current 'index' position, expanding it and or shuffling it if necessary. If buffer exceeds max buffer size aTokenTooLargeExceptionwill be thrown.- Throws:
IOException- if unable to read from the stream
-
extractDataToken
Will extract data token of the provided length from the current buffer starting at the 'mark'.- Throws:
IOException
-
validate
Validates prerequisites for constructor arguments
-