public class ReferenceCountingSegment extends ReferenceCountingCloseableObject<Segment> implements SegmentReference, Overshadowable<ReferenceCountingSegment>
Segment that is also a ReferenceCountingSegment, allowing query engines that operate directly on
segments to track references so that dropping a Segment can be done safely to ensure there are no in-flight
queries.
Extensions can extend this class for populating VersionedIntervalTimeline with
a custom implementation through SegmentLoader.baseObject, referents| Modifier | Constructor and Description |
|---|---|
protected |
ReferenceCountingSegment(Segment baseSegment,
int startRootPartitionId,
int endRootPartitionId,
short minorVersion,
short atomicUpdateGroupSize) |
| Modifier and Type | Method and Description |
|---|---|
Optional<Closeable> |
acquireReferences()
This method is expected to increment a reference count and provide a
Closeable that decrements the
reference count when closed. |
<T> T |
as(Class<T> clazz)
Request an implementation of a particular interface.
|
QueryableIndex |
asQueryableIndex() |
StorageAdapter |
asStorageAdapter() |
short |
getAtomicUpdateGroupSize()
Return the size of atomicUpdateGroup.
|
Segment |
getBaseSegment() |
org.joda.time.Interval |
getDataInterval() |
int |
getEndRootPartitionId()
See doc of
Overshadowable.getStartRootPartitionId(). |
SegmentId |
getId() |
short |
getMinorVersion() |
int |
getStartRootPartitionId()
All overshadowables have root partition range.
|
String |
getVersion() |
boolean |
overshadows(ReferenceCountingSegment other)
Returns true if this overshadowable overshadows the other.
|
static ReferenceCountingSegment |
wrapRootGenerationSegment(Segment baseSegment) |
static ReferenceCountingSegment |
wrapSegment(Segment baseSegment,
ShardSpec shardSpec) |
close, decrement, decrementOnceCloseable, getNumReferences, increment, incrementReferenceAndDecrementOnceCloseable, isClosedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcontainsRootPartition, hasDataprotected ReferenceCountingSegment(Segment baseSegment, int startRootPartitionId, int endRootPartitionId, short minorVersion, short atomicUpdateGroupSize)
public static ReferenceCountingSegment wrapRootGenerationSegment(Segment baseSegment)
public static ReferenceCountingSegment wrapSegment(Segment baseSegment, ShardSpec shardSpec)
@Nullable public org.joda.time.Interval getDataInterval()
getDataInterval in interface Segment@Nullable public QueryableIndex asQueryableIndex()
asQueryableIndex in interface Segment@Nullable public StorageAdapter asStorageAdapter()
asStorageAdapter in interface Segmentpublic boolean overshadows(ReferenceCountingSegment other)
Overshadowableovershadows in interface Overshadowable<ReferenceCountingSegment>public int getStartRootPartitionId()
OvershadowablegetStartRootPartitionId in interface Overshadowable<ReferenceCountingSegment>public int getEndRootPartitionId()
OvershadowableOvershadowable.getStartRootPartitionId().getEndRootPartitionId in interface Overshadowable<ReferenceCountingSegment>public String getVersion()
getVersion in interface Overshadowable<ReferenceCountingSegment>public short getMinorVersion()
getMinorVersion in interface Overshadowable<ReferenceCountingSegment>public short getAtomicUpdateGroupSize()
OvershadowableVersionedIntervalTimeline.getAtomicUpdateGroupSize in interface Overshadowable<ReferenceCountingSegment>public Optional<Closeable> acquireReferences()
ReferenceCountedObjectCloseable that decrements the
reference count when closed. This is likely just a wrapper around
ReferenceCountingCloseableObject.incrementReferenceAndDecrementOnceCloseable(), but may also include any
other associated references which should be incremented when this method is called, and decremented/released by the
closeable.
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 avoid allowing this method or the
Closeable it creates to throw exceptions.
For callers: if this method returns non-empty, IT MUST BE CLOSED, else reference counts can potentially leak.acquireReferences in interface ReferenceCountedObjectpublic <T> T as(Class<T> clazz)
SegmentQueryableIndex or StorageAdapter, then this method behaves
identically to Segment.asQueryableIndex() or Segment.asStorageAdapter(). Other interfaces are only
expected to be requested by callers that have specific knowledge of extra features provided by specific
segment types. For example, an extension might provide a custom Segment type that can offer both
StorageAdapter and some new interface. That extension can also offer a Query that uses that new interface.
Implementations which accept classes other than QueryableIndex or StorageAdapter are limited
to using those classes within the extension. This means that one extension cannot rely on the `Segment.as`
behavior of another extension.Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.