Class TmpFileSegmentWriteOutMedium
- java.lang.Object
-
- org.apache.druid.segment.writeout.TmpFileSegmentWriteOutMedium
-
- All Implemented Interfaces:
Closeable,AutoCloseable,SegmentWriteOutMedium
public final class TmpFileSegmentWriteOutMedium extends Object implements SegmentWriteOutMedium
Builds segment write out medium objects that are based on temporary files. Some analysis of usage of these objects shows that they periodically get used for very small things, where the overhead of creating a tmp file is actually very large. It would be best to go back and look at usages and try to make them lazy such that they only actually use a medium when they need it. But, in an attempt to get some benefits, we "shim" in the laziness by returning a heap-based WriteOutBytes that only falls back to making a tmp file when it actually fills up.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()ClosergetCloser()Returns a closer of this SegmentWriteOutMedium, which is closed in this SegmentWriteOutMedium's close() method.SegmentWriteOutMediummakeChildWriteOutMedium()Creates a 'child' version of theSegmentWriteOutMedium, which can be optionally closed, independent of thisSegmentWriteOutMediumbut otherwise shares the same configuration.WriteOutBytesmakeWriteOutBytes()Creates a new emptyWriteOutBytes, attached to this SegmentWriteOutMedium.
-
-
-
Method Detail
-
makeWriteOutBytes
public WriteOutBytes makeWriteOutBytes()
Description copied from interface:SegmentWriteOutMediumCreates a new emptyWriteOutBytes, attached to this SegmentWriteOutMedium. When this SegmentWriteOutMedium is closed, the returned WriteOutBytes couldn't be used anymore.- Specified by:
makeWriteOutBytesin interfaceSegmentWriteOutMedium
-
makeChildWriteOutMedium
public SegmentWriteOutMedium makeChildWriteOutMedium() throws IOException
Description copied from interface:SegmentWriteOutMediumCreates a 'child' version of theSegmentWriteOutMedium, which can be optionally closed, independent of thisSegmentWriteOutMediumbut otherwise shares the same configuration. This allows callers using a sharedSegmentWriteOutMediumbut which control the complete lifecycle of theWriteOutByteswhich they require to free the backing resources when they are finished, rather than waiting untilCloseable.close()is called for this medium.The 'child' medium will be closed when
Closeable.close()is called, if not called explicitly prior to closing this medium.- Specified by:
makeChildWriteOutMediumin interfaceSegmentWriteOutMedium- Throws:
IOException
-
getCloser
public Closer getCloser()
Description copied from interface:SegmentWriteOutMediumReturns a closer of this SegmentWriteOutMedium, which is closed in this SegmentWriteOutMedium's close() method. Could be used to "attach" some random resources to this SegmentWriteOutMedium, to be closed at the same time.- Specified by:
getCloserin interfaceSegmentWriteOutMedium
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-