Class FileSmoosher
- java.lang.Object
-
- org.apache.druid.java.util.common.io.smoosh.FileSmoosher
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class FileSmoosher extends Object implements Closeable
A class that concatenates files together into configurable sized chunks, works in conjunction with the SmooshedFileMapper to provide access to the individual files. It does not split input files among separate output files, instead the various "chunk" files will be varying sizes and it is not possible to add a file of size greater than Integer.MAX_VALUE. This class is not thread safe. This class allows writing multiple files even if main smoosh file writer is open. If main smoosh file writer is already open, it delegates the write into temporary file on the file system which is later copied on to the main smoosh file and underlying temporary file will be cleaned up.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FileSmoosher.Outer
-
Constructor Summary
Constructors Constructor Description FileSmoosher(File baseDir)
FileSmoosher(File baseDir, int maxChunkSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(File fileToAdd)
void
add(String name, File fileToAdd)
void
add(String name, ByteBuffer bufferToAdd)
void
add(String name, List<ByteBuffer> bufferToAdd)
SmooshedWriter
addWithSmooshedWriter(String name, long size)
void
close()
-
-
-
Method Detail
-
add
public void add(File fileToAdd) throws IOException
- Throws:
IOException
-
add
public void add(String name, File fileToAdd) throws IOException
- Throws:
IOException
-
add
public void add(String name, ByteBuffer bufferToAdd) throws IOException
- Throws:
IOException
-
add
public void add(String name, List<ByteBuffer> bufferToAdd) throws IOException
- Throws:
IOException
-
addWithSmooshedWriter
public SmooshedWriter addWithSmooshedWriter(String name, long size) throws IOException
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-