public class ReferenceCountingSegment extends AbstractSegment
close()
before some other "users", which called increment()
, has not called decrement()
yet, and the wrapped Segment
won't be actually closed
until that. So ReferenceCountingSegment implements something like automatic reference count-based resource
management.Constructor and Description |
---|
ReferenceCountingSegment(Segment baseSegment) |
Modifier and Type | Method and Description |
---|---|
<T> T |
as(Class<T> clazz)
Request an implementation of a particular interface.
|
QueryableIndex |
asQueryableIndex() |
StorageAdapter |
asStorageAdapter() |
void |
close() |
void |
decrement() |
Closeable |
decrementOnceCloseable()
Returns a
Closeable which action is to call decrement() only once. |
Segment |
getBaseSegment() |
org.joda.time.Interval |
getDataInterval() |
String |
getIdentifier() |
int |
getNumReferences() |
boolean |
increment() |
boolean |
isClosed() |
public ReferenceCountingSegment(Segment baseSegment)
public Segment getBaseSegment()
public int getNumReferences()
public boolean isClosed()
public String getIdentifier()
public org.joda.time.Interval getDataInterval()
public QueryableIndex asQueryableIndex()
public StorageAdapter asStorageAdapter()
public void close()
public boolean increment()
public Closeable decrementOnceCloseable()
Closeable
which action is to call decrement()
only once. If close() is called on the
returned Closeable object for the second time, it won't call decrement()
again.public void decrement()
public <T> T as(Class<T> clazz)
Segment
QueryableIndex
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.as
in interface Segment
as
in class AbstractSegment
T
- desired interfaceclazz
- desired interfaceCopyright © 2011–2018. All rights reserved.