Interface CqlFactory
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
CacheableCqlFactory
,DefaultCqlFactory
,TransformingCqlFactory
public interface CqlFactory extends java.io.Serializable
A factory CQL queries for data access.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
CqlFactory.KvIterable<T>
Interface for iteration over returned results returningKeyValue
s.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description com.datastax.driver.core.BoundStatement
getFetchTokenStatement(java.lang.String key, com.datastax.driver.core.Session session)
Retrieve a bound statement to fetch a token for given entity.<T> CqlFactory.KvIterable<T>
getListAllStatement(java.lang.String key, Offsets.Raw offset, int limit, com.datastax.driver.core.Session session)
Retrieve wrapped statement to execute to list all attributes of given key.com.datastax.driver.core.BoundStatement
getListEntitiesStatement(Offsets.Token offset, int limit, com.datastax.driver.core.Session session)
Get statement for listing entities.com.datastax.driver.core.BoundStatement
getListStatement(java.lang.String key, AttributeDescriptor<?> wildcard, Offsets.Raw offset, int limit, com.datastax.driver.core.Session session)
Retrieve a CQL query to execute in order to list wildcard attributes.com.datastax.driver.core.BoundStatement
getReadStatement(java.lang.String key, java.lang.String attribute, AttributeDescriptor<?> desc, com.datastax.driver.core.Session session)
Retrieve a CQL query to execute in order to read data.java.util.Optional<com.datastax.driver.core.BoundStatement>
getWriteStatement(StreamElement element, com.datastax.driver.core.Session session)
Retrieve a CQL query to execute in order to ingest the request.com.datastax.driver.core.Statement
scanPartition(java.util.List<AttributeDescriptor<?>> attributes, CassandraPartition partition, com.datastax.driver.core.Session session)
Retrieve a bound statement to scan data for given attribute and partition.void
setup(EntityDescriptor entity, java.net.URI uri, StringConverter<?> converter)
Setup the factory from URI and given string converter.<T> KeyValue<T>
toKeyValue(EntityDescriptor entityDescriptor, AttributeDescriptor<T> attributeDescriptor, java.lang.String key, java.lang.String attribute, long stamp, RandomOffset offset, byte[] serializedValue)
Convert the byte[] stored in the database intoKeyValue
.
-
-
-
Method Detail
-
setup
void setup(EntityDescriptor entity, java.net.URI uri, StringConverter<?> converter)
Setup the factory from URI and given string converter.- Parameters:
entity
- descriptor of entityuri
- URI of the sourceconverter
- payload to string converter
-
getWriteStatement
java.util.Optional<com.datastax.driver.core.BoundStatement> getWriteStatement(StreamElement element, com.datastax.driver.core.Session session)
Retrieve a CQL query to execute in order to ingest the request.- Parameters:
element
- input datasession
- current session- Returns:
- the statement to execute. When empty, the ingest is silently discarded.
-
getReadStatement
com.datastax.driver.core.BoundStatement getReadStatement(java.lang.String key, java.lang.String attribute, AttributeDescriptor<?> desc, com.datastax.driver.core.Session session)
Retrieve a CQL query to execute in order to read data.- Parameters:
key
- the primary key whose attribute to returnattribute
- the attribute to fetchdesc
- descriptor of the attributesession
- the connection session- Returns:
- the statement to execute
-
getListAllStatement
<T> CqlFactory.KvIterable<T> getListAllStatement(java.lang.String key, @Nullable Offsets.Raw offset, int limit, com.datastax.driver.core.Session session)
Retrieve wrapped statement to execute to list all attributes of given key.- Type Parameters:
T
- type ofCqlFactory.KvIterable
- Parameters:
key
- key to list attributes ofoffset
- offset to start from (return next attribute)limit
- maximum number of items to returnsession
- the connection session- Returns:
- iterable over keyvalues
-
getListStatement
com.datastax.driver.core.BoundStatement getListStatement(java.lang.String key, AttributeDescriptor<?> wildcard, @Nullable Offsets.Raw offset, int limit, com.datastax.driver.core.Session session)
Retrieve a CQL query to execute in order to list wildcard attributes. The prefix is name of wildcard attribute shortened by two last characters (.*).- Parameters:
key
- the primary key value (first part of the composite key)wildcard
- the wildcard attribute to listoffset
- the offset to start from this might be null (start from beginning)limit
- maximal number of elements to list (-1 for all)session
- the connection session- Returns:
- the statement to execute
-
getListEntitiesStatement
com.datastax.driver.core.BoundStatement getListEntitiesStatement(@Nullable Offsets.Token offset, int limit, com.datastax.driver.core.Session session)
Get statement for listing entities.- Parameters:
offset
- offset of the querylimit
- maximal number of elements to list (-1 for all)session
- connection session- Returns:
- the statement to execute
-
getFetchTokenStatement
com.datastax.driver.core.BoundStatement getFetchTokenStatement(java.lang.String key, com.datastax.driver.core.Session session)
Retrieve a bound statement to fetch a token for given entity.- Parameters:
key
- key to fetch token forsession
- connection session- Returns:
- the statement to execute
-
scanPartition
com.datastax.driver.core.Statement scanPartition(java.util.List<AttributeDescriptor<?>> attributes, CassandraPartition partition, com.datastax.driver.core.Session session)
Retrieve a bound statement to scan data for given attribute and partition.- Parameters:
attributes
- list of attributes to scanpartition
- the partition to scansession
- connection session- Returns:
- the statement to execute
-
toKeyValue
@Nullable <T> KeyValue<T> toKeyValue(EntityDescriptor entityDescriptor, AttributeDescriptor<T> attributeDescriptor, java.lang.String key, java.lang.String attribute, long stamp, RandomOffset offset, byte[] serializedValue)
Convert the byte[] stored in the database intoKeyValue
.
-
-