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 bothAbstractAttributeWriter
andRandomAccessReader
can 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 interface
RandomAccessReader.Factory<T extends RandomAccessReader>
Serializable
factory forRandomAccessReader
.static class
RandomAccessReader.GetRequest<T>
A wraper for a get request.static class
RandomAccessReader.Listing
Type of listing (either listing entities of entity attributes).static interface
RandomAccessReader.MultiFetch
A facade for fetching multipleKeyValues
in 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.Factory
suitable for serialization.RandomOffset
fetchOffset(RandomAccessReader.Listing type, java.lang.String key)
ConstructOffset
from string (representing either key of the entity or attribute).default <T> java.util.Optional<KeyValue<T>>
get(RandomAccessReader.GetRequest<T> request)
Get singleKeyValue
usingRandomAccessReader.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).EntityDescriptor
getEntityDescriptor()
Retrieve entity associated with this reader.default void
listEntities(Consumer<Pair<RandomOffset,java.lang.String>> consumer)
List all entity keys.void
listEntities(RandomOffset offset, int limit, Consumer<Pair<RandomOffset,java.lang.String>> consumer)
List all entity keys with offset and limit.default RandomAccessReader.MultiFetch
multiFetch()
Return a facadeRandomAccessReader.MultiFetch
object that can be used to queue multiple requests to the storage and fetch them at once usingRandomAccessReader.MultiFetch.fetch(Consumer)
.static MultiAccessBuilder
newBuilder(Repository repo, ContextProvider context)
Create a new builder that is able to constructRandomAccessReader
from multiple readers responsible for reading from various attribute families.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.default <T> void
scanWildcard(java.lang.String key, AttributeDescriptor<T> wildcard, Consumer<KeyValue<T>> consumer)
List data stored for a particular wildcard attribute.default <T> void
scanWildcard(java.lang.String key, AttributeDescriptor<T> wildcard, RandomOffset offset, int limit, Consumer<KeyValue<T>> consumer)
List data stored for a particular wildcard attribute.<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.default void
scanWildcardAll(java.lang.String key, long stamp, Consumer<KeyValue<?>> consumer)
Scan all data stored per given key.default void
scanWildcardAll(java.lang.String key, Consumer<KeyValue<?>> consumer)
Scan all data stored per given key.default void
scanWildcardAll(java.lang.String key, RandomOffset offset, int limit, Consumer<KeyValue<?>> consumer)
Scan all data stored per given key.void
scanWildcardAll(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 constructRandomAccessReader
from multiple readers responsible for reading from various attribute families.- Parameters:
repo
- theRepository
context
- 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)
ConstructOffset
from 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
KeyValue
if 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
KeyValue
if 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
KeyValue
if present
-
get
default <T> java.util.Optional<KeyValue<T>> get(RandomAccessReader.GetRequest<T> request)
Get singleKeyValue
usingRandomAccessReader.GetRequest
.- Type Parameters:
T
- value type- Parameters:
request
- the request- Returns:
- optional
KeyValue
if 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
KeyValue
if present
-
multiFetch
default RandomAccessReader.MultiFetch multiFetch()
Return a facadeRandomAccessReader.MultiFetch
object 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 whoseKeyValue
s 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 whoseKeyValue
s 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 whoseKeyValue
s 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 whoseKeyValue
s 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.Factory
suitable for serialization.- Returns:
- the
RandomAccessReader.Factory
representing this reader
-
-