Package org.apache.druid.segment
Class SegmentReference
java.lang.Object
org.apache.druid.segment.SegmentReference
- All Implemented Interfaces:
Closeable,AutoCloseable
Wrapper for a
SegmentDescriptor and Optional<Segment>. For regular segments, the latter is typically
created by a ReferenceCountedSegmentProvider that may have a SegmentMapFunction applied to it.
If the SegmentMapFunction you want to apply is not available at the time the SegmentReference
is created, use map(SegmentMapFunction) to apply it.
Closing this object closes both the getSegmentReference() and any closeables attached from the process of
creating this object, such as from AcquireSegmentAction. The object from getSegmentReference()
should not be closed directly by callers.-
Constructor Summary
ConstructorsConstructorDescriptionSegmentReference(SegmentDescriptor segmentDescriptor, Optional<Segment> segmentReference, Closeable cleanupHold) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Returns the actual segment.map(SegmentMapFunction segmentMapFn) Maps the wrapped segment and returns a reference to it.static SegmentReferencemissing(SegmentDescriptor segmentDescriptor)
-
Constructor Details
-
SegmentReference
public SegmentReference(SegmentDescriptor segmentDescriptor, Optional<Segment> segmentReference, @Nullable Closeable cleanupHold)
-
-
Method Details
-
missing
-
getSegmentDescriptor
-
getSegmentReference
Returns the actual segment. Do not close the Segment when you are done with it, only close the SegmentReference. -
map
Maps the wrapped segment and returns a reference to it. Closes the reference if theSegmentMapFunctionthrows an exception. Regardless of success or failure of this method, the old reference should be discarded. Do not callclose()on the old reference, only call it on the new one. -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-