Package cz.o2.proxima.direct.core.view
Class LocalCachedPartitionedView
- java.lang.Object
- 
- cz.o2.proxima.direct.core.view.LocalCachedPartitionedView
 
- 
- All Implemented Interfaces:
- AttributeWriterBase,- OnlineAttributeWriter,- RandomAccessReader,- CachedView,- java.io.Closeable,- java.lang.AutoCloseable
 
 public class LocalCachedPartitionedView extends java.lang.Object implements CachedView A transformation view fromCommitLogReadertoCachedView.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface cz.o2.proxima.direct.core.AttributeWriterBaseAttributeWriterBase.Type
 - 
Nested classes/interfaces inherited from interface cz.o2.proxima.direct.core.view.CachedViewCachedView.Factory
 - 
Nested classes/interfaces inherited from interface cz.o2.proxima.direct.core.randomaccess.RandomAccessReaderRandomAccessReader.GetRequest<T>, RandomAccessReader.Listing, RandomAccessReader.MultiFetch
 
- 
 - 
Constructor SummaryConstructors Constructor Description LocalCachedPartitionedView(EntityDescriptor entity, CommitLogReader reader, OnlineAttributeWriter writer)LocalCachedPartitionedView(EntityDescriptor entity, CommitLogReader reader, OnlineAttributeWriter writer, long keepCachedDuration)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description CachedView.FactoryasFactory()Convert instance of this view toCachedView.Factorysuitable for serialization.voidassign(java.util.Collection<Partition> partitions, BiConsumer<StreamElement,Pair<java.lang.Long,java.lang.Object>> updateCallback, java.time.Duration ttl)Assign and make given partitions accessible by random reads.voidcache(StreamElement element)Cache givenStreamElementinto local cache without writing it to the underlying writer.voidclose()Close allocated resources of this writer.RandomOffsetfetchOffset(RandomAccessReader.Listing type, java.lang.String key)ConstructOffsetfrom 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.EntityDescriptorgetEntityDescriptor()Retrieve entity associated with this reader.java.util.Optional<ObserveHandle>getRunningHandle()Retrieve a running handle (if present).CommitLogReadergetUnderlyingReader()Retrieve underlyingCommitLogReader.OnlineAttributeWritergetUnderlyingWriter()Retrieve underlyingOnlineAttributeWriter.java.net.URIgetUri()Retrieve URI of this writer.voidlistEntities(RandomOffset offset, int limit, Consumer<Pair<RandomOffset,java.lang.String>> consumer)List all entity keys with offset and limit.protected voidonCache(StreamElement element, boolean overwrite)<T> voidscanWildcard(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.voidscanWildcardAll(java.lang.String key, RandomOffset offset, long stamp, int limit, Consumer<KeyValue<?>> consumer)Scan all data stored per given key.voidwrite(StreamElement data, CommitCallback statusCallback)Write given serialized attribute value to given entity.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface cz.o2.proxima.direct.core.AttributeWriterBasebulk, online
 - 
Methods inherited from interface cz.o2.proxima.direct.core.view.CachedViewassign, assign, assign, getPartitions
 - 
Methods inherited from interface cz.o2.proxima.direct.core.OnlineAttributeWritergetType, isTransactional, rollback, transactional
 - 
Methods inherited from interface cz.o2.proxima.direct.core.randomaccess.RandomAccessReaderget, get, get, get, listEntities, multiFetch, scanWildcard, scanWildcard, scanWildcard, scanWildcardAll, scanWildcardAll, scanWildcardAll
 
- 
 
- 
- 
- 
Constructor Detail- 
LocalCachedPartitionedViewpublic LocalCachedPartitionedView(EntityDescriptor entity, CommitLogReader reader, OnlineAttributeWriter writer) 
 - 
LocalCachedPartitionedViewpublic LocalCachedPartitionedView(EntityDescriptor entity, CommitLogReader reader, OnlineAttributeWriter writer, long keepCachedDuration) 
 
- 
 - 
Method Detail- 
onCacheprotected void onCache(StreamElement element, boolean overwrite) 
 - 
assignpublic void assign(java.util.Collection<Partition> partitions, BiConsumer<StreamElement,Pair<java.lang.Long,java.lang.Object>> updateCallback, @Nullable java.time.Duration ttl) Description copied from interface:CachedViewAssign and make given partitions accessible by random reads. If the view contains any partitions not listed in the collection, these partitions are dropped.- Specified by:
- assignin interface- CachedView
- Parameters:
- partitions- the partitions to cache locally
- updateCallback- 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 stamp
- ttl- maximaul Duration that an update should be kept in the cache NOTE: this is not a hard limit, it is only a signal, that after this time the element can be removed to free up memory
 
 - 
getAssignedpublic java.util.Collection<Partition> getAssigned() Description copied from interface:CachedViewRetrieve currently assigned partitions.- Specified by:
- getAssignedin interface- CachedView
- Returns:
- currently assigned partitions
 
 - 
fetchOffsetpublic RandomOffset fetchOffset(RandomAccessReader.Listing type, java.lang.String key) Description copied from interface:RandomAccessReaderConstructOffsetfrom string (representing either key of the entity or attribute). The returned offset represents the first element that is following the givenkey, in case of equality.- Specified by:
- fetchOffsetin interface- RandomAccessReader
- Parameters:
- type- the type of the key
- key- the key of entity or attribute
- Returns:
- offset representation of the key
 
 - 
getpublic <T> java.util.Optional<KeyValue<T>> get(java.lang.String key, java.lang.String attribute, AttributeDescriptor<T> desc, long stamp) Description copied from interface:RandomAccessReaderRetrieve data stored under given (key, attribute) pair (if any).- Specified by:
- getin interface- RandomAccessReader
- Type Parameters:
- T- value type
- Parameters:
- key- key of the entity
- attribute- name of the attribute
- desc- the attribute to search for
- stamp- timestamp to relatively to which retrieve the data
- Returns:
- optional KeyValueif present
 
 - 
scanWildcardAllpublic void scanWildcardAll(java.lang.String key, RandomOffset offset, long stamp, int limit, Consumer<KeyValue<?>> consumer)Description copied from interface:RandomAccessReaderScan all data stored per given key.- Specified by:
- scanWildcardAllin interface- RandomAccessReader
- Parameters:
- key- the key whose- KeyValues to scan
- offset- offset to start from (next key value will be returned)
- stamp- timestamp to relatively to which retrieve the data
- limit- how many elements to process at most
- consumer- consumer to use for scanning
 
 - 
scanWildcardpublic <T> void scanWildcard(java.lang.String key, AttributeDescriptor<T> wildcard, RandomOffset offset, long stamp, int limit, Consumer<KeyValue<T>> consumer)Description copied from interface:RandomAccessReaderList data stored for a particular wildcard attribute.- Specified by:
- scanWildcardin interface- RandomAccessReader
- Type Parameters:
- T- value type
- Parameters:
- key- key of the entity
- wildcard- wildcard attribute to scan
- offset- name of attribute (including the prefix) to start from
- stamp- timestamp to relatively to which retrieve the data
- limit- maximal number of items to consume *
- consumer- the consumer to stream data to
 
 - 
listEntitiespublic void listEntities(RandomOffset offset, int limit, Consumer<Pair<RandomOffset,java.lang.String>> consumer) Description copied from interface:RandomAccessReaderList all entity keys with offset and limit.- Specified by:
- listEntitiesin interface- RandomAccessReader
- Parameters:
- offset- offset of the entities
- limit- limit for number of results
- consumer- consumer of results
 
 - 
closepublic void close() Description copied from interface:AttributeWriterBaseClose allocated resources of this writer. This is supposed to be idempotent.- Specified by:
- closein interface- AttributeWriterBase
- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- CachedView
- Specified by:
- closein interface- java.io.Closeable
 
 - 
getEntityDescriptorpublic EntityDescriptor getEntityDescriptor() Description copied from interface:RandomAccessReaderRetrieve entity associated with this reader.- Specified by:
- getEntityDescriptorin interface- RandomAccessReader
- Returns:
- entity associated with this reader
 
 - 
writepublic void write(StreamElement data, CommitCallback statusCallback) Description copied from interface:OnlineAttributeWriterWrite given serialized attribute value to given entity.- Specified by:
- writein interface- OnlineAttributeWriter
- Parameters:
- data- the data to write
- statusCallback- callback used to commit data processing
 
 - 
getUripublic java.net.URI getUri() Description copied from interface:AttributeWriterBaseRetrieve URI of this writer.- Specified by:
- getUriin interface- AttributeWriterBase
- Returns:
- URI of this writer
 
 - 
cachepublic void cache(StreamElement element) Description copied from interface:CachedViewCache givenStreamElementinto local cache without writing it to the underlying writer. This is used in conjunction with attribute family proxy.- Specified by:
- cachein interface- CachedView
- Parameters:
- element- the data to cache
 
 - 
getUnderlyingReaderpublic CommitLogReader getUnderlyingReader() Description copied from interface:CachedViewRetrieve underlyingCommitLogReader.- Specified by:
- getUnderlyingReaderin interface- CachedView
 
 - 
getUnderlyingWriterpublic OnlineAttributeWriter getUnderlyingWriter() Description copied from interface:CachedViewRetrieve underlyingOnlineAttributeWriter. Note that using this write might not update the cache. In most cases, useOnlineAttributeWriter.write(StreamElement, CommitCallback)directly.- Specified by:
- getUnderlyingWriterin interface- CachedView
 
 - 
getRunningHandlepublic java.util.Optional<ObserveHandle> getRunningHandle() Description copied from interface:CachedViewRetrieve a running handle (if present).- Specified by:
- getRunningHandlein interface- CachedView
 
 - 
asFactorypublic CachedView.Factory asFactory() Description copied from interface:CachedViewConvert instance of this view toCachedView.Factorysuitable for serialization.- Specified by:
- asFactoryin interface- AttributeWriterBase
- Specified by:
- asFactoryin interface- CachedView
- Specified by:
- asFactoryin interface- OnlineAttributeWriter
- Specified by:
- asFactoryin interface- RandomAccessReader
- Returns:
- the CachedView.Factoryrepresenting this view
 
 
- 
 
-