Package org.apache.druid.segment
Class ReferenceCountedSegmentProvider
java.lang.Object
org.apache.druid.segment.ReferenceCountingCloseableObject<Segment>
org.apache.druid.segment.ReferenceCountedSegmentProvider
- All Implemented Interfaces:
Closeable,AutoCloseable,ReferenceCountedObjectProvider<Segment>
public class ReferenceCountedSegmentProvider
extends ReferenceCountingCloseableObject<Segment>
implements ReferenceCountedObjectProvider<Segment>
Helper object to assist in managing
Segment storage lifecycle. Provides access to the Segment tracked
with reference counting, releasing the reference on close. Closing this provider closes the underlying
Segment once all references are returned, ensuring that a segment cannot be dropped while it is actively
being used.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic classBase type to markSegmentreturned byReferenceCountedObjectProvider<Segment>as 'leaf' segments, to distinguish from other transformations which can be done on top of this segment, such as bySegmentMapFunctionfinal classWraps aSegmentand decrements reference to this segment ofReferenceCountedSegmentProvideron close (instead of closing the segment itself which is managed through the provider)static final class -
Field Summary
Fields inherited from class org.apache.druid.segment.ReferenceCountingCloseableObject
baseObject, referents -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThis method increments a reference count and provides aCloseablethat decrements the reference count when closed.Make a wrapper for aSegmentthat does not close the underlying segment on closewrapCloseable(ReferenceCountedSegmentProvider.LeafReference segment, Closeable closeable) Methods inherited from class org.apache.druid.segment.ReferenceCountingCloseableObject
close, decrement, decrementOnceCloseable, getNumReferences, increment, incrementReferenceAndDecrementOnceCloseable, isClosed
-
Constructor Details
-
ReferenceCountedSegmentProvider
-
-
Method Details
-
of
-
unmanaged
Make a wrapper for aSegmentthat does not close the underlying segment on close -
wrapCloseable
public static Optional<Segment> wrapCloseable(ReferenceCountedSegmentProvider.LeafReference segment, Closeable closeable) -
getBaseSegment
-
acquireReference
Description copied from interface:ReferenceCountedObjectProviderThis method increments a reference count and provides aCloseablethat decrements the reference count when closed. The object returned by this method may or may not be thread-safe, it is best to check with the implementation.IMPORTANT NOTE: to fulfill the contract of this method, implementors must return a closeable to indicate that the reference can be acquired, even if there is nothing to close. Implementors should ideally avoid allowing this method to throw exceptions, but callers are responsible for closing the returned object should any operations on it throw exceptions.
For callers: if this method returns non-empty, IT MUST BE CLOSED, else reference counts can potentially leak.
- Specified by:
acquireReferencein interfaceReferenceCountedObjectProvider<Segment>
-