Package cz.o2.proxima.direct.jdbc
Class JdbcOnlineAttributeReader
- java.lang.Object
-
- cz.o2.proxima.core.storage.AbstractStorage
-
- cz.o2.proxima.direct.jdbc.JdbcOnlineAttributeReader
-
- All Implemented Interfaces:
RandomAccessReader
,java.io.Closeable
,java.lang.AutoCloseable
public class JdbcOnlineAttributeReader extends AbstractStorage implements RandomAccessReader
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class cz.o2.proxima.core.storage.AbstractStorage
AbstractStorage.SerializableAbstractStorage
-
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 JdbcOnlineAttributeReader(JdbcDataAccessor accessor, SqlStatementFactory sqlStatementFactory, EntityDescriptor entityDesc, java.net.URI uri)
-
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).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 cz.o2.proxima.core.storage.AbstractStorage
equals, hashCode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cz.o2.proxima.direct.core.randomaccess.RandomAccessReader
get, get, get, get, getEntityDescriptor, listEntities, multiFetch, scanWildcard, scanWildcard, scanWildcard, scanWildcardAll, scanWildcardAll, scanWildcardAll
-
-
-
-
Constructor Detail
-
JdbcOnlineAttributeReader
public JdbcOnlineAttributeReader(JdbcDataAccessor accessor, SqlStatementFactory sqlStatementFactory, EntityDescriptor entityDesc, java.net.URI uri)
-
-
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
-
scanWildcardAll
public void scanWildcardAll(java.lang.String key, @Nullable 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
-
scanWildcard
public <T> void scanWildcard(java.lang.String key, AttributeDescriptor<T> wildcard, @Nullable 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(@Nullable 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
-
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
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
-