Package cz.o2.proxima.direct.io.hbase
Class RandomHBaseReader
- java.lang.Object
-
- cz.o2.proxima.direct.io.hbase.RandomHBaseReader
-
- All Implemented Interfaces:
RandomAccessReader,java.io.Closeable,java.lang.AutoCloseable
public class RandomHBaseReader extends java.lang.Object implements RandomAccessReader
RandomAccessReaderfor HBase.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface cz.o2.proxima.direct.core.randomaccess.RandomAccessReader
RandomAccessReader.Factory<T extends RandomAccessReader>, RandomAccessReader.GetRequest<T>, RandomAccessReader.Listing, RandomAccessReader.MultiFetch
-
-
Constructor Summary
Constructors Constructor Description RandomHBaseReader(java.net.URI uri, org.apache.hadoop.conf.Configuration conf, java.util.Map<java.lang.String,java.lang.Object> cfg, EntityDescriptor entity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RandomAccessReader.Factory<?>asFactory()Convert instance of this reader toRandomAccessReader.Factorysuitable for serialization.voidclose()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).EntityDescriptorgetEntityDescriptor()Retrieve entity associated with this reader.java.net.URIgetUri()voidlistEntities(RandomOffset offset, int limit, Consumer<Pair<RandomOffset,java.lang.String>> consumer)List all entity keys with offset and limit.<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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cz.o2.proxima.direct.core.randomaccess.RandomAccessReader
get, get, get, get, listEntities, multiFetch, scanWildcard, scanWildcard, scanWildcard, scanWildcardAll, scanWildcardAll, scanWildcardAll
-
-
-
-
Constructor Detail
-
RandomHBaseReader
public RandomHBaseReader(java.net.URI uri, org.apache.hadoop.conf.Configuration conf, java.util.Map<java.lang.String,java.lang.Object> cfg, EntityDescriptor entity)
-
-
Method Detail
-
fetchOffset
public 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 interfaceRandomAccessReader- Parameters:
type- the type of the keykey- the key of entity or attribute- Returns:
- offset representation of the key
-
get
public <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 interfaceRandomAccessReader- 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
-
scanWildcard
public <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 interfaceRandomAccessReader- 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
public 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 interfaceRandomAccessReader- Parameters:
offset- offset of the entitieslimit- limit for number of resultsconsumer- consumer of results
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
getEntityDescriptor
public EntityDescriptor getEntityDescriptor()
Description copied from interface:RandomAccessReaderRetrieve entity associated with this reader.- Specified by:
getEntityDescriptorin interfaceRandomAccessReader- Returns:
- entity associated with this reader
-
asFactory
public RandomAccessReader.Factory<?> asFactory()
Description copied from interface:RandomAccessReaderConvert instance of this reader toRandomAccessReader.Factorysuitable for serialization.- Specified by:
asFactoryin interfaceRandomAccessReader- Returns:
- the
RandomAccessReader.Factoryrepresenting this reader
-
scanWildcardAll
public 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 interfaceRandomAccessReader- 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
-
getUri
public java.net.URI getUri()
-
-