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
Modifier and TypeFieldDescription(package private) int
(package private) byte[]
(package private) int
(package private) static final int
private final int
private final InputStream
(package private) int
private final int
(package private) long
-
Constructor Summary
ConstructorDescriptionAbstractDemarcator
(InputStream is, int maxDataSize) Constructs an instance of demarcator with providedInputStream
and max buffer size.AbstractDemarcator
(InputStream is, int maxDataSize, int initialBufferSize) Constructs an instance of demarcator with providedInputStream
and max buffer size and initial buffer size. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
(package private) byte[]
extractDataToken
(int length) Will extract data token of the provided length from the current buffer starting at the 'mark'.(package private) void
fill()
Will fill the current buffer from current 'index' position, expanding it and or shuffling it if necessary.private void
validate
(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 providedInputStream
and 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 providedInputStream
and 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:
close
in interfaceAutoCloseable
- Specified by:
close
in 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 aTokenTooLargeException
will 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
-