Package org.pipecraft.pipes.sync.source
Class BinInputReaderPipe<T>
- java.lang.Object
-
- org.pipecraft.pipes.sync.source.InputStreamPipe<T>
-
- org.pipecraft.pipes.sync.source.BinInputReaderPipe<T>
-
- All Implemented Interfaces:
Closeable,AutoCloseable,BasePipe,Pipe<T>
public class BinInputReaderPipe<T> extends InputStreamPipe<T>
A source pipe reading items from a given binary input (file or input stream).- Author:
- Eyal Schneider
-
-
Constructor Summary
Constructors Constructor Description BinInputReaderPipe(File inputFile, FileReadOptions options, DecoderFactory<T> decoderFactory)ConstructorBinInputReaderPipe(File inputFile, DecoderFactory<T> decoderFactory)ConstructorBinInputReaderPipe(InputStream is, DecoderFactory<T> decoderFactory, int bufferSize, long sizeBytes, Compression compression)ConstructorBinInputReaderPipe(FailableInterruptibleSupplier<SizedInputStream,IOException> isCreator, DecoderFactory<T> decoderFactory, int bufferSize, Compression compression)ConstructorBinInputReaderPipe(SizedInputStream is, DecoderFactory<T> decoderFactory, FileReadOptions readOptions)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SizedInputStreamcreateInputStream()Tnext()Tpeek()voidstart()Performs pre-processing prior to item flow throw the pipe.-
Methods inherited from class org.pipecraft.pipes.sync.source.InputStreamPipe
close, getInputStream, getInputStreamSize, getProgress
-
-
-
-
Constructor Detail
-
BinInputReaderPipe
public BinInputReaderPipe(FailableInterruptibleSupplier<SizedInputStream,IOException> isCreator, DecoderFactory<T> decoderFactory, int bufferSize, Compression compression)
Constructor- Parameters:
isCreator- The creator of the input stream. Expected to be the raw input stream (without decompression or buffering layers), but should be initialized with expected size (seeSizedInputStream). The size should be either null if unknown, or it should be the exact number of stream bytes.decoderFactory- The decoder of binary values to pipe items.bufferSize- Buffer size to use on the input streamcompression- Input stream compression
-
BinInputReaderPipe
public BinInputReaderPipe(InputStream is, DecoderFactory<T> decoderFactory, int bufferSize, long sizeBytes, Compression compression)
Constructor- Parameters:
is- Input stream to read items from. Expected to be the raw input stream (without decompression or buffering layers).decoderFactory- The decoder of binary values to pipe items.bufferSize- Buffer size to use on the input streamcompression- Input stream compression
-
BinInputReaderPipe
public BinInputReaderPipe(SizedInputStream is, DecoderFactory<T> decoderFactory, FileReadOptions readOptions)
Constructor- Parameters:
is- TheSizedInputStreamto read items from. Expected to be the raw input stream (without decompression or buffering layers).decoderFactory- The decoder of binary values to pipe items.readOptions- The reading options
-
BinInputReaderPipe
public BinInputReaderPipe(File inputFile, FileReadOptions options, DecoderFactory<T> decoderFactory)
Constructor- Parameters:
inputFile- Input file to read items fromoptions- The file read optionsdecoderFactory- The decoder of binary values to pipe items
-
BinInputReaderPipe
public BinInputReaderPipe(File inputFile, DecoderFactory<T> decoderFactory)
Constructor- Parameters:
inputFile- The file to read items fromdecoderFactory- The decoder of binary values to pipe items
-
-
Method Detail
-
next
public T next() throws PipeException, InterruptedException
- Returns:
- The next item in this pipe output, or null if the output end has been reached. May be a blocking operation.
- Throws:
PipeException- In case of pipe errors in this pipe or somewhere up-stream while trying to prepare next item to return.InterruptedException- In case that the operation has been interrupted by another thread.
-
peek
public T peek()
- Returns:
- The next item in the pipe's output. Does not remove it, so next call to next() will return it.
-
createInputStream
protected SizedInputStream createInputStream() throws IOException, InterruptedException
- Specified by:
createInputStreamin classInputStreamPipe<T>- Returns:
- A new input stream based on ctor arguments. Called once in the start() method.
Expected to be the raw input stream (without decompression or buffering layers),
but should be initialized with expected size (see
SizedInputStream). The size should be null if unknown. - Throws:
IOException- (Will be wrapped by IOPipeException)InterruptedException- In case that the operation is interrupted
-
start
public void start() throws PipeException, InterruptedExceptionDescription copied from interface:BasePipePerforms pre-processing prior to item flow throw the pipe. Implementations must call the same method for all their input pipes before accessing their items. This is typically done here.- Specified by:
startin interfaceBasePipe- Overrides:
startin classInputStreamPipe<T>- Throws:
PipeException- In case of pipe errors in this pipe or somewhere up-stream.InterruptedException- In case that the operation has been interrupted by another thread.
-
-