Package org.apache.druid.segment
Class WrappedSegmentReference
- java.lang.Object
-
- org.apache.druid.segment.WrappedSegmentReference
-
- All Implemented Interfaces:
Closeable,AutoCloseable,ReferenceCountedObject,Segment,SegmentReference
- Direct Known Subclasses:
FilteredSegment,UnnestSegment
public abstract class WrappedSegmentReference extends Object implements SegmentReference
SimpleSegmentReferenceimplementation for a segment that wraps a base segment such asUnnestSegmentorFilteredSegment
-
-
Field Summary
Fields Modifier and Type Field Description protected SegmentReferencedelegate
-
Constructor Summary
Constructors Constructor Description WrappedSegmentReference(SegmentReference delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<Closeable>acquireReferences()This method is expected to increment a reference count and provide aCloseablethat decrements the reference count when closed.<T> Tas(Class<T> clazz)Request an implementation of a particular interface.QueryableIndexasQueryableIndex()StringasString()voidclose()org.joda.time.IntervalgetDataInterval()SegmentIdgetId()booleanisTombstone()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.segment.Segment
asCursorFactory, asStorageAdapter
-
-
-
-
Field Detail
-
delegate
protected final SegmentReference delegate
-
-
Constructor Detail
-
WrappedSegmentReference
public WrappedSegmentReference(SegmentReference delegate)
-
-
Method Detail
-
acquireReferences
public Optional<Closeable> acquireReferences()
Description copied from interface:ReferenceCountedObjectThis method is expected to increment a reference count and provide aCloseablethat decrements the reference count when closed. This is likely just a wrapper aroundReferenceCountingCloseableObject.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 theCloseableit creates to throw exceptions. For callers: if this method returns non-empty, IT MUST BE CLOSED, else reference counts can potentially leak.- Specified by:
acquireReferencesin interfaceReferenceCountedObject
-
getDataInterval
public org.joda.time.Interval getDataInterval()
- Specified by:
getDataIntervalin interfaceSegment
-
asQueryableIndex
@Nullable public QueryableIndex asQueryableIndex()
- Specified by:
asQueryableIndexin interfaceSegment
-
as
@Nullable public <T> T as(@Nonnull Class<T> clazz)
Description copied from interface:SegmentRequest an implementation of a particular interface.If the passed-in interface is
QueryableIndexorCursorFactory, then this method behaves identically toSegment.asQueryableIndex()orSegment.asCursorFactory(). 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
QueryableIndexorCursorFactoryare limited to using those classes within the extension. This means that one extension cannot rely on the `Segment.as` behavior of another extension.- Specified by:
asin interfaceSegment- Type Parameters:
T- desired interface- Parameters:
clazz- desired interface- Returns:
- instance of clazz, or null if the interface is not supported by this segment, one of the following:
-
CursorFactory, to make cursors to run queries. Never null. -
QueryableIndex, index object, if this is a memory-mapped regular segment. -
IndexedTable, table object, if this is a joinable indexed table. -
TimeBoundaryInspector, inspector for min/max timestamps, if supported by this segment. -
PhysicalSegmentInspector, inspector for physical segment details, if supported by this segment. -
MaxIngestedEventTimeInspector, inspector forDataSourceMetadataResultValue.getMaxIngestedEventTime() -
TopNOptimizationInspector, inspector containing information for topN specific optimizations -
CloseableShapeshifter, stepping stone toRowsAndColumns. -
BypassRestrictedSegment, a policy-aware segment, converted from a policy-enforced segment.
-
-
isTombstone
public boolean isTombstone()
- Specified by:
isTombstonein interfaceSegment
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-