public class LocalCachedPartitionedView extends java.lang.Object implements CachedView
CommitLogReader to CachedView.| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
LocalCachedPartitionedView.IntOffset |
CachedView.FactoryRandomAccessReader.ListingAttributeWriterBase.Type| Modifier and Type | Field and Description |
|---|---|
private TimeBoundedVersionedCache |
cache
Cache for data in memory.
|
private EntityDescriptor |
entity |
private java.util.concurrent.atomic.AtomicReference<ObserveHandle> |
handle
Handle of the observation thread (if any running).
|
private CommitLogReader |
reader |
private BiConsumer<StreamElement,Pair<java.lang.Long,java.lang.Object>> |
updateCallback |
private OnlineAttributeWriter |
writer
Writer to persist data to.
|
| Constructor and Description |
|---|
LocalCachedPartitionedView(EntityDescriptor entity,
CommitLogReader reader,
OnlineAttributeWriter writer) |
LocalCachedPartitionedView(EntityDescriptor entity,
CommitLogReader reader,
OnlineAttributeWriter writer,
long keepCachedDuration) |
| Modifier and Type | Method and Description |
|---|---|
CachedView.Factory |
asFactory()
Convert instance of this view to
CachedView.Factory suitable for serialization. |
void |
assign(java.util.Collection<Partition> partitions,
BiConsumer<StreamElement,Pair<java.lang.Long,java.lang.Object>> updateCallback)
Assign and make given partitions accessible by random reads.
|
void |
cache(StreamElement element)
Cache given
StreamElement into local cache without writing it to the underlaying
writer. |
void |
close()
Close allocated resources of this writer.
|
RandomOffset |
fetchOffset(RandomAccessReader.Listing type,
java.lang.String key)
Construct
Offset from string (representing either key of the entity or attribute). |
<T> java.util.Optional<KeyValue<T>> |
get(java.lang.String key,
java.lang.String attribute,
AttributeDescriptor<T> desc,
long stamp)
Retrieve data stored under given (key, attribute) pair (if any).
|
java.util.Collection<Partition> |
getAssigned()
Retrieve currently assigned partitions.
|
EntityDescriptor |
getEntityDescriptor()
Retrieve entity associated with this reader.
|
java.util.Collection<Partition> |
getPartitions()
Retrieve all partitions of the underlying commit log.
|
java.net.URI |
getUri()
Retrieve URI of this writer.
|
void |
listEntities(RandomOffset offset,
int limit,
Consumer<Pair<RandomOffset,java.lang.String>> consumer)
List all entity keys with offset and limit.
|
protected void |
onCache(StreamElement ingest,
boolean overwrite) |
<T> void |
scanWildcard(java.lang.String key,
AttributeDescriptor<T> wildcard,
RandomOffset offset,
long stamp,
int limit,
Consumer<KeyValue<T>> consumer)
List data stored for a particular wildcard attribute.
|
void |
scanWildcardAll(java.lang.String key,
RandomOffset offset,
long stamp,
int limit,
Consumer<KeyValue<?>> consumer)
Scan all data stored per given key.
|
private void |
scanWildcardPrefix(java.lang.String key,
java.lang.String prefix,
java.lang.String offset,
long stamp,
int limit,
Consumer<KeyValue<?>> consumer) |
private <T> KeyValue<T> |
toKv(java.lang.String key,
java.lang.String attribute,
AttributeDescriptor<?> attr,
Pair<java.lang.Long,java.lang.Object> p) |
private <T> KeyValue<T> |
toKv(java.lang.String key,
java.lang.String attribute,
Pair<java.lang.Long,java.lang.Object> p) |
void |
write(StreamElement data,
CommitCallback statusCallback)
Write given serialized attribute value to given entity.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitassignget, get, get, listEntities, newBuilder, scanWildcard, scanWildcard, scanWildcard, scanWildcardAll, scanWildcardAll, scanWildcardAllgetType, rollbackbulk, onlineprivate final CommitLogReader reader
private final EntityDescriptor entity
private final OnlineAttributeWriter writer
private final TimeBoundedVersionedCache cache
private final java.util.concurrent.atomic.AtomicReference<ObserveHandle> handle
private BiConsumer<StreamElement,Pair<java.lang.Long,java.lang.Object>> updateCallback
public LocalCachedPartitionedView(EntityDescriptor entity, CommitLogReader reader, OnlineAttributeWriter writer)
public LocalCachedPartitionedView(EntityDescriptor entity, CommitLogReader reader, OnlineAttributeWriter writer, long keepCachedDuration)
protected void onCache(StreamElement ingest, boolean overwrite)
public void assign(java.util.Collection<Partition> partitions, BiConsumer<StreamElement,Pair<java.lang.Long,java.lang.Object>> updateCallback)
CachedViewassign in interface CachedViewpartitions - the partitions to cache locallyupdateCallback - function that is called when cache gets updated the function takes the
new ingest element and pair of the most recent object that was associated with the key and
it's currently associated stamppublic java.util.Collection<Partition> getAssigned()
CachedViewgetAssigned in interface CachedViewpublic RandomOffset fetchOffset(RandomAccessReader.Listing type, java.lang.String key)
RandomAccessReaderOffset from string (representing either key of the entity or attribute).fetchOffset in interface RandomAccessReadertype - the type of the keykey - the key of entity or attributepublic <T> java.util.Optional<KeyValue<T>> get(java.lang.String key, java.lang.String attribute, AttributeDescriptor<T> desc, long stamp)
RandomAccessReaderget in interface RandomAccessReaderT - value typekey - key of the entityattribute - name of the attributedesc - the attribute to search forstamp - timestamp to relatively to which retrieve the dataKeyValue if presentpublic void scanWildcardAll(java.lang.String key,
RandomOffset offset,
long stamp,
int limit,
Consumer<KeyValue<?>> consumer)
RandomAccessReaderscanWildcardAll in interface RandomAccessReaderkey - the key whose KeyValues to scanoffset - offset to start from (next key value will be returned)stamp - timestamp to relatively to which retrieve the datalimit - how many elements to process at mostconsumer - consumer to use for scanningpublic <T> void scanWildcard(java.lang.String key,
AttributeDescriptor<T> wildcard,
RandomOffset offset,
long stamp,
int limit,
Consumer<KeyValue<T>> consumer)
RandomAccessReaderscanWildcard in interface RandomAccessReaderT - value typekey - key of the entitywildcard - wildcard attribute to scanoffset - name of attribute (including the prefix) to start fromstamp - timestamp to relatively to which retrieve the datalimit - maximal number of items to consume *consumer - the consumer to stream data toprivate void scanWildcardPrefix(java.lang.String key,
java.lang.String prefix,
java.lang.String offset,
long stamp,
int limit,
Consumer<KeyValue<?>> consumer)
public void listEntities(RandomOffset offset, int limit, Consumer<Pair<RandomOffset,java.lang.String>> consumer)
RandomAccessReaderlistEntities in interface RandomAccessReaderoffset - offset of the entitieslimit - limit for number of resultsconsumer - consumer of resultspublic void close()
AttributeWriterBaseclose in interface AttributeWriterBaseclose in interface java.io.Closeableclose in interface java.lang.AutoCloseable@Nullable private <T> KeyValue<T> toKv(java.lang.String key, java.lang.String attribute, @Nullable Pair<java.lang.Long,java.lang.Object> p)
@Nullable private <T> KeyValue<T> toKv(java.lang.String key, java.lang.String attribute, AttributeDescriptor<?> attr, @Nullable Pair<java.lang.Long,java.lang.Object> p)
public EntityDescriptor getEntityDescriptor()
RandomAccessReadergetEntityDescriptor in interface RandomAccessReaderpublic void write(StreamElement data, CommitCallback statusCallback)
OnlineAttributeWriterwrite in interface OnlineAttributeWriterdata - the data to writestatusCallback - callback used to commit data processingpublic java.net.URI getUri()
AttributeWriterBasegetUri in interface AttributeWriterBasepublic void cache(StreamElement element)
CachedViewStreamElement into local cache without writing it to the underlaying
writer. This is used in conjunction with attribute family proxy.cache in interface CachedViewelement - the data to cachepublic java.util.Collection<Partition> getPartitions()
CachedViewgetPartitions in interface CachedViewpublic CachedView.Factory asFactory()
CachedViewCachedView.Factory suitable for serialization.asFactory in interface AttributeWriterBaseasFactory in interface OnlineAttributeWriterasFactory in interface RandomAccessReaderasFactory in interface CachedViewCachedView.Factory representing this viewCopyright © 2017–2021. All rights reserved.