Interface RandomAccessReader
-
- All Superinterfaces:
java.lang.AutoCloseable,java.io.Closeable
- All Known Subinterfaces:
CachedView
- All Known Implementing Classes:
JdbcOnlineAttributeReader,LocalCachedPartitionedView,RandomHBaseReader,TransactionalCachedView
@Stable public interface RandomAccessReader extends java.io.Closeable
Reader of data stored in random access storage. Every class that implements bothAbstractAttributeWriterandRandomAccessReadercan be used to access data stored at that attribute family by random access. The data can be either get by pair (key, attribute) or scanned through by a mask (key, attributePrefix) for attributes that are wildcard attributes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceRandomAccessReader.Factory<T extends RandomAccessReader>Serializablefactory forRandomAccessReader.static classRandomAccessReader.GetRequest<T>A wraper for a get request.static classRandomAccessReader.ListingType of listing (either listing entities of entity attributes).static interfaceRandomAccessReader.MultiFetchA facade for fetching multipleKeyValuesin single request.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description RandomAccessReader.Factory<?>asFactory()Convert instance of this reader toRandomAccessReader.Factorysuitable for serialization.RandomOffsetfetchOffset(RandomAccessReader.Listing type, java.lang.String key)ConstructOffsetfrom string (representing either key of the entity or attribute).default <T> java.util.Optional<KeyValue<T>>get(RandomAccessReader.GetRequest<T> request)Get singleKeyValueusingRandomAccessReader.GetRequest.default <T> java.util.Optional<KeyValue<T>>get(java.lang.String key, AttributeDescriptor<T> desc)Retrieve data stored under given (key, attribute) pair (if any).default <T> java.util.Optional<KeyValue<T>>get(java.lang.String key, AttributeDescriptor<T> desc, long stamp)Retrieve data stored under given (key, attribute) pair (if any).default <T> java.util.Optional<KeyValue<T>>get(java.lang.String key, java.lang.String attribute, AttributeDescriptor<T> desc)Retrieve data stored under given (key, attribute) pair (if any).<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).EntityDescriptorgetEntityDescriptor()Retrieve entity associated with this reader.default voidlistEntities(Consumer<Pair<RandomOffset,java.lang.String>> consumer)List all entity keys.voidlistEntities(RandomOffset offset, int limit, Consumer<Pair<RandomOffset,java.lang.String>> consumer)List all entity keys with offset and limit.default RandomAccessReader.MultiFetchmultiFetch()Return a facadeRandomAccessReader.MultiFetchobject that can be used to queue multiple requests to the storage and fetch them at once usingRandomAccessReader.MultiFetch.fetch(Consumer).static MultiAccessBuildernewBuilder(Repository repo, ContextProvider context)Create a new builder that is able to constructRandomAccessReaderfrom multiple readers responsible for reading from various attribute families.default <T> voidscanWildcard(java.lang.String key, AttributeDescriptor<T> wildcard, long stamp, Consumer<KeyValue<T>> consumer)List data stored for a particular wildcard attribute.default <T> voidscanWildcard(java.lang.String key, AttributeDescriptor<T> wildcard, Consumer<KeyValue<T>> consumer)List data stored for a particular wildcard attribute.default <T> voidscanWildcard(java.lang.String key, AttributeDescriptor<T> wildcard, RandomOffset offset, int limit, Consumer<KeyValue<T>> consumer)List data stored for a particular wildcard attribute.<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.default voidscanWildcardAll(java.lang.String key, long stamp, Consumer<KeyValue<?>> consumer)Scan all data stored per given key.default voidscanWildcardAll(java.lang.String key, Consumer<KeyValue<?>> consumer)Scan all data stored per given key.default voidscanWildcardAll(java.lang.String key, RandomOffset offset, int limit, Consumer<KeyValue<?>> consumer)Scan all data stored per given key.voidscanWildcardAll(java.lang.String key, RandomOffset offset, long stamp, int limit, Consumer<KeyValue<?>> consumer)Scan all data stored per given key.
-
-
-
Method Detail
-
newBuilder
static MultiAccessBuilder newBuilder(Repository repo, ContextProvider context)
Create a new builder that is able to constructRandomAccessReaderfrom multiple readers responsible for reading from various attribute families.- Parameters:
repo- theRepositorycontext- direct translation context provider (e.g.DirectDataOperator)- Returns:
- new builder for multi random access reader
-
fetchOffset
RandomOffset fetchOffset(RandomAccessReader.Listing type, java.lang.String key)
ConstructOffsetfrom 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.- Parameters:
type- the type of the keykey- the key of entity or attribute- Returns:
- offset representation of the key
-
get
default <T> java.util.Optional<KeyValue<T>> get(java.lang.String key, AttributeDescriptor<T> desc)
Retrieve data stored under given (key, attribute) pair (if any).- Type Parameters:
T- value type- Parameters:
key- key of the entitydesc- the attribute to search for (not wildcard)- Returns:
- optional
KeyValueif present
-
get
default <T> java.util.Optional<KeyValue<T>> get(java.lang.String key, AttributeDescriptor<T> desc, long stamp)
Retrieve data stored under given (key, attribute) pair (if any).- Type Parameters:
T- value type- Parameters:
key- key of the entitydesc- the attribute to search for (not wildcard)stamp- timestamp to relatively to which retrieve the data- Returns:
- optional
KeyValueif present
-
get
default <T> java.util.Optional<KeyValue<T>> get(java.lang.String key, java.lang.String attribute, AttributeDescriptor<T> desc)
Retrieve data stored under given (key, attribute) pair (if any).- Type Parameters:
T- value type- Parameters:
key- key of the entityattribute- name of the attributedesc- the attribute to search for- Returns:
- optional
KeyValueif present
-
get
default <T> java.util.Optional<KeyValue<T>> get(RandomAccessReader.GetRequest<T> request)
Get singleKeyValueusingRandomAccessReader.GetRequest.- Type Parameters:
T- value type- Parameters:
request- the request- Returns:
- optional
KeyValueif present
-
get
<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).- Type Parameters:
T- value type- Parameters:
key- key of the entityattribute- name of the attributedesc- the attribute to search forstamp- timestamp to relatively to which retrieve the data- Returns:
- optional
KeyValueif present
-
multiFetch
default RandomAccessReader.MultiFetch multiFetch()
Return a facadeRandomAccessReader.MultiFetchobject that can be used to queue multiple requests to the storage and fetch them at once usingRandomAccessReader.MultiFetch.fetch(Consumer).- Returns:
- the
RandomAccessReader.MultiFetch
-
scanWildcardAll
default void scanWildcardAll(java.lang.String key, Consumer<KeyValue<?>> consumer)Scan all data stored per given key.- Parameters:
key- the key whoseKeyValues to scanconsumer- consumer to use for scanning
-
scanWildcardAll
default void scanWildcardAll(java.lang.String key, long stamp, Consumer<KeyValue<?>> consumer)Scan all data stored per given key.- Parameters:
key- the key whoseKeyValues to scanstamp- timestamp to relatively to which retrieve the dataconsumer- consumer to use for scanning
-
scanWildcardAll
default void scanWildcardAll(java.lang.String key, @Nullable RandomOffset offset, int limit, Consumer<KeyValue<?>> consumer)Scan all data stored per given key.- Parameters:
key- the key whoseKeyValues to scanoffset- offset to start from (next key value will be returned)limit- how many elements to process at mostconsumer- consumer to use for scanning
-
scanWildcardAll
void scanWildcardAll(java.lang.String key, @Nullable RandomOffset offset, long stamp, int limit, Consumer<KeyValue<?>> consumer)Scan all data stored per given key.- Parameters:
key- the key whoseKeyValues 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 scanning
-
scanWildcard
default <T> void scanWildcard(java.lang.String key, AttributeDescriptor<T> wildcard, Consumer<KeyValue<T>> consumer)List data stored for a particular wildcard attribute.- Type Parameters:
T- value type- Parameters:
key- key of the entitywildcard- wildcard attribute to scanconsumer- the consumer to stream data to
-
scanWildcard
default <T> void scanWildcard(java.lang.String key, AttributeDescriptor<T> wildcard, long stamp, Consumer<KeyValue<T>> consumer)List data stored for a particular wildcard attribute.- Type Parameters:
T- value type- Parameters:
key- key of the entitywildcard- wildcard attribute to scanstamp- timestamp to relatively to which retrieve the dataconsumer- the consumer to stream data to
-
scanWildcard
default <T> void scanWildcard(java.lang.String key, AttributeDescriptor<T> wildcard, @Nullable RandomOffset offset, int limit, Consumer<KeyValue<T>> consumer)List data stored for a particular wildcard attribute.- Type Parameters:
T- value type- Parameters:
key- key of the entitywildcard- wildcard attribute to scanoffset- name of attribute (including the prefix) to start fromlimit- maximal number of items to consumeconsumer- the consumer to stream data to
-
scanWildcard
<T> void scanWildcard(java.lang.String key, AttributeDescriptor<T> wildcard, @Nullable RandomOffset offset, long stamp, int limit, Consumer<KeyValue<T>> consumer)List data stored for a particular wildcard attribute.- Type Parameters:
T- value type- Parameters:
key- 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 to
-
listEntities
default void listEntities(Consumer<Pair<RandomOffset,java.lang.String>> consumer)
List all entity keys.- Parameters:
consumer- consumer that will receive keys of entities in the random access storage
-
listEntities
void listEntities(@Nullable RandomOffset offset, int limit, Consumer<Pair<RandomOffset,java.lang.String>> consumer)List all entity keys with offset and limit.- Parameters:
offset- offset of the entitieslimit- limit for number of resultsconsumer- consumer of results
-
getEntityDescriptor
EntityDescriptor getEntityDescriptor()
Retrieve entity associated with this reader.- Returns:
- entity associated with this reader
-
asFactory
RandomAccessReader.Factory<?> asFactory()
Convert instance of this reader toRandomAccessReader.Factorysuitable for serialization.- Returns:
- the
RandomAccessReader.Factoryrepresenting this reader
-
-