Package org.pipecraft.pipes.sync.source
Class StorageTxtFileFetcherReaderPipe
- java.lang.Object
-
- org.pipecraft.pipes.sync.inter.CompoundPipe<String>
-
- org.pipecraft.pipes.sync.source.StorageTxtFileFetcherReaderPipe
-
- All Implemented Interfaces:
Closeable,AutoCloseable,BasePipe,Pipe<String>
public class StorageTxtFileFetcherReaderPipe extends CompoundPipe<String>
A source pipe providing the lines of a text file from cloud storage. Supports decompression. In contrast to the streaming nature ofStorageTxtFileReaderPipe, this implementation downloads the file completely first. This approach may be much faster for large files, since the download is optimized (sliced) and reading from local disk is usually faster than network read.- Author:
- Eyal Schneider
-
-
Constructor Summary
Constructors Constructor Description StorageTxtFileFetcherReaderPipe(Storage<?,?> storage, String bucket, String path, File tempFolder)Constructor Uses the default read chunk size and default read options, and assumes UTF8StorageTxtFileFetcherReaderPipe(Storage<?,?> storage, String bucket, String path, Charset charset, int chunkSize, FileReadOptions options, File tempFolder)ConstructorStorageTxtFileFetcherReaderPipe(Storage<?,?> storage, String bucket, String path, Charset charset, File tempFolder)Constructor Uses the default read chunk size and default read optionsStorageTxtFileFetcherReaderPipe(Storage<?,?> storage, String bucket, String path, FileReadOptions options, File tempFolder)Constructor Uses the default read chunk size and assumes UTF8
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()protected Pipe<String>createPipeline()-
Methods inherited from class org.pipecraft.pipes.sync.inter.CompoundPipe
getProgress, next, peek, start
-
-
-
-
Constructor Detail
-
StorageTxtFileFetcherReaderPipe
public StorageTxtFileFetcherReaderPipe(Storage<?,?> storage, String bucket, String path, Charset charset, int chunkSize, FileReadOptions options, File tempFolder)
Constructor- Parameters:
storage- The cloud storage connectorbucket- The bucket to read the file frompath- The full path of the text file inside the bucketcharset- The charset usedchunkSize- The size (in bytes) of each chunk read from storage at once, or 0 for using the default one.options- The file read optionstempFolder- A folder where to place the temporary file for the download. The file is deleted by the pipe at the end of work.
-
StorageTxtFileFetcherReaderPipe
public StorageTxtFileFetcherReaderPipe(Storage<?,?> storage, String bucket, String path, Charset charset, File tempFolder)
Constructor Uses the default read chunk size and default read options- Parameters:
storage- The cloud storage connectorbucket- The bucket to read the file frompath- The full path of the text file inside the bucketcharset- The charset usedtempFolder- A folder where to place the temporary file for the download. The file is deleted by the pipe at the end of work.
-
StorageTxtFileFetcherReaderPipe
public StorageTxtFileFetcherReaderPipe(Storage<?,?> storage, String bucket, String path, File tempFolder)
Constructor Uses the default read chunk size and default read options, and assumes UTF8- Parameters:
storage- The cloud storage connectorbucket- The bucket to read the file frompath- The full path of the text file inside the bucket. The file is assumed to be UTF8.tempFolder- A folder where to place the temporary file for the download. The file is deleted by the pipe at the end of work.
-
StorageTxtFileFetcherReaderPipe
public StorageTxtFileFetcherReaderPipe(Storage<?,?> storage, String bucket, String path, FileReadOptions options, File tempFolder)
Constructor Uses the default read chunk size and assumes UTF8- Parameters:
storage- The cloud torage connectorbucket- The bucket to read the file frompath- The full path of the text file inside the bucket. The file is assumed to be UTF8.options- The file read optionstempFolder- A folder where to place the temporary file for the download. The file is deleted by the pipe at the end of work.
-
-
Method Detail
-
createPipeline
protected Pipe<String> createPipeline() throws PipeException, InterruptedException
- Specified by:
createPipelinein classCompoundPipe<String>- Returns:
- A new pipeline to represent the logic of this pipe
- Throws:
PipeException- In case of a pipeline creation errorInterruptedException- In case that the thread is interrupted
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classCompoundPipe<String>- Throws:
IOException
-
-