Interface CqlFactory
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
CacheableCqlFactory,DefaultCqlFactory,TransformingCqlFactory
public interface CqlFactory extends java.io.SerializableA factory CQL queries for data access.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceCqlFactory.KvIterable<T>Interface for iteration over returned results returningKeyValues.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description com.datastax.oss.driver.api.core.cql.BoundStatementgetFetchTokenStatement(java.lang.String key, com.datastax.oss.driver.api.core.CqlSession 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.oss.driver.api.core.CqlSession session)Retrieve wrapped statement to execute to list all attributes of given key.com.datastax.oss.driver.api.core.cql.BoundStatementgetListEntitiesStatement(Offsets.TokenOffset offset, int limit, com.datastax.oss.driver.api.core.CqlSession session)Get statement for listing entities.com.datastax.oss.driver.api.core.cql.BoundStatementgetListStatement(java.lang.String key, AttributeDescriptor<?> wildcard, Offsets.Raw offset, int limit, com.datastax.oss.driver.api.core.CqlSession session)Retrieve a CQL query to execute in order to list wildcard attributes.com.datastax.oss.driver.api.core.cql.BoundStatementgetReadStatement(java.lang.String key, java.lang.String attribute, AttributeDescriptor<?> desc, com.datastax.oss.driver.api.core.CqlSession session)Retrieve a CQL query to execute in order to read data.java.util.Optional<com.datastax.oss.driver.api.core.cql.BoundStatement>getWriteStatement(StreamElement element, com.datastax.oss.driver.api.core.CqlSession session)Retrieve a CQL query to execute in order to ingest the request.com.datastax.oss.driver.api.core.cql.StatementscanPartition(java.util.List<AttributeDescriptor<?>> attributes, CassandraPartition partition, com.datastax.oss.driver.api.core.CqlSession session)Retrieve a bound statement to scan data for given attribute and partition.voidsetup(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.oss.driver.api.core.cql.BoundStatement> getWriteStatement(StreamElement element, com.datastax.oss.driver.api.core.CqlSession 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.oss.driver.api.core.cql.BoundStatement getReadStatement(java.lang.String key, java.lang.String attribute, AttributeDescriptor<?> desc, com.datastax.oss.driver.api.core.CqlSession 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.oss.driver.api.core.CqlSession 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.oss.driver.api.core.cql.BoundStatement getListStatement(java.lang.String key, AttributeDescriptor<?> wildcard, @Nullable Offsets.Raw offset, int limit, com.datastax.oss.driver.api.core.CqlSession 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.oss.driver.api.core.cql.BoundStatement getListEntitiesStatement(@Nullable Offsets.TokenOffset offset, int limit, com.datastax.oss.driver.api.core.CqlSession 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.oss.driver.api.core.cql.BoundStatement getFetchTokenStatement(java.lang.String key, com.datastax.oss.driver.api.core.CqlSession 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.oss.driver.api.core.cql.Statement scanPartition(java.util.List<AttributeDescriptor<?>> attributes, CassandraPartition partition, com.datastax.oss.driver.api.core.CqlSession 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.
-
-