Class FileSmoosher
java.lang.Object
org.apache.druid.java.util.common.io.smoosh.FileSmoosher
- All Implemented Interfaces:
Closeable,AutoCloseable,SegmentFileBuilder
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 -
Constructor Summary
ConstructorsConstructorDescriptionFileSmoosher(File baseDir) FileSmoosher(File baseDir, int maxChunkSize) FileSmoosher(File baseDir, int maxChunkSize, String outputFileName) -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()cleanup any open resources in the event of an exception while building the segment filesvoidAdd aFileto the segment file as the specified namevoidadd(String name, ByteBuffer bufferToAdd) Add aByteBufferto a segment file as the specified namevoidaddColumn(String name, ColumnDescriptor columnDescriptor) Add a column to the metadata of this segment fileaddWithChannel(String name, long size) Creates aSegmentFileChannelto write data to the segment file as the specified name.addWithSmooshedWriter(String name, long size) voidclose()Close the segment file builder, writing the file(s) to the destinationMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.druid.segment.file.SegmentFileBuilder
getExternalBuilder
-
Constructor Details
-
FileSmoosher
-
FileSmoosher
-
FileSmoosher
-
-
Method Details
-
getOutFiles
-
getContainers
-
getInternalFiles
-
addColumn
Description copied from interface:SegmentFileBuilderAdd a column to the metadata of this segment file- Specified by:
addColumnin interfaceSegmentFileBuilder
-
add
Description copied from interface:SegmentFileBuilderAdd aFileto the segment file as the specified name- Specified by:
addin interfaceSegmentFileBuilder- Throws:
IOException
-
add
Description copied from interface:SegmentFileBuilderAdd aByteBufferto a segment file as the specified name- Specified by:
addin interfaceSegmentFileBuilder- Throws:
IOException
-
addWithChannel
Description copied from interface:SegmentFileBuilderCreates aSegmentFileChannelto write data to the segment file as the specified name. Callers must be sure to write the amount of data specified by the size parameter.- Specified by:
addWithChannelin interfaceSegmentFileBuilder- Throws:
IOException
-
abort
public void abort()Description copied from interface:SegmentFileBuildercleanup any open resources in the event of an exception while building the segment files- Specified by:
abortin interfaceSegmentFileBuilder
-
addWithSmooshedWriter
- Throws:
IOException
-
close
Description copied from interface:SegmentFileBuilderClose the segment file builder, writing the file(s) to the destination- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceSegmentFileBuilder- Throws:
IOException
-