Class AcquireSegmentAction

java.lang.Object
org.apache.druid.segment.loading.AcquireSegmentAction
All Implemented Interfaces:
Closeable, AutoCloseable

public class AcquireSegmentAction extends Object implements Closeable
This class represents an intent to acquire a reference to a Segment and then use it to do stuff, and finally closing when done.

When an AcquireSegmentAction is created, segment cache implementations will create a 'hold' to ensure it cannot be removed from the cache until this action has been closed.

Calling getSegmentFuture() is what actually initiates the 'action', and will return a segment reference provider if already cached, or attempt to download from deep storage to load into the cache if not. The Segment returned by acquiring a reference from the ReferenceCountedObjectProvider returned by the future places a separate hold on the cache until the segment itself is closed, and MUST be closed when the caller is finished doing segment things with it.

The caller must also call close() on this object to clean up the hold that exists while possibly loading the segment, and may do so as soon as the Segment is acquired (or can do so earlier to abort the load and release the hold).