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
RandomAccessReader
for 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.Factory
suitable for serialization.void
close()
RandomOffset
fetchOffset(RandomAccessReader.Listing type, java.lang.String key)
ConstructOffset
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).EntityDescriptor
getEntityDescriptor()
Retrieve entity associated with this reader.java.net.URI
getUri()
void
listEntities(RandomOffset offset, int limit, Consumer<Pair<RandomOffset,java.lang.String>> consumer)
List all entity keys with offset and limit.<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.-
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:RandomAccessReader
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.- Specified by:
fetchOffset
in 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:RandomAccessReader
Retrieve data stored under given (key, attribute) pair (if any).- Specified by:
get
in 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
KeyValue
if 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:RandomAccessReader
List data stored for a particular wildcard attribute.- Specified by:
scanWildcard
in 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:RandomAccessReader
List all entity keys with offset and limit.- Specified by:
listEntities
in interfaceRandomAccessReader
- Parameters:
offset
- offset of the entitieslimit
- limit for number of resultsconsumer
- consumer of results
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
getEntityDescriptor
public EntityDescriptor getEntityDescriptor()
Description copied from interface:RandomAccessReader
Retrieve entity associated with this reader.- Specified by:
getEntityDescriptor
in interfaceRandomAccessReader
- Returns:
- entity associated with this reader
-
asFactory
public RandomAccessReader.Factory<?> asFactory()
Description copied from interface:RandomAccessReader
Convert instance of this reader toRandomAccessReader.Factory
suitable for serialization.- Specified by:
asFactory
in interfaceRandomAccessReader
- Returns:
- the
RandomAccessReader.Factory
representing this reader
-
scanWildcardAll
public void scanWildcardAll(java.lang.String key, RandomOffset offset, long stamp, int limit, Consumer<KeyValue<?>> consumer)
Description copied from interface:RandomAccessReader
Scan all data stored per given key.- Specified by:
scanWildcardAll
in interfaceRandomAccessReader
- 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
-
getUri
public java.net.URI getUri()
-
-