Class CacheableCqlFactory

    • Field Detail

      • ttl

        protected long ttl
        A TTL value in seconds associated with each update or insert.
    • Constructor Detail

      • CacheableCqlFactory

        protected CacheableCqlFactory()
    • Method Detail

      • setup

        public final void setup​(EntityDescriptor entity,
                                java.net.URI uri,
                                StringConverter<?> converter)
        Description copied from interface: CqlFactory
        Setup the factory from URI and given string converter.
        Specified by:
        setup in interface CqlFactory
        Parameters:
        entity - descriptor of entity
        uri - URI of the source
        converter - payload to string converter
      • setup

        protected void setup​(java.util.Map<java.lang.String,​java.lang.String> query,
                             StringConverter<?> converter)
        Setup the factory from URI parameters passed in.
        Parameters:
        query - the parsed URI query parameters
        converter - converter of payload to string
      • getPreparedStatement

        protected com.datastax.driver.core.PreparedStatement getPreparedStatement​(com.datastax.driver.core.Session session,
                                                                                  StreamElement what)
        Retrieve cached prepared statement for writing given data.
        Parameters:
        session - the connection session
        what - data to ingest
        Returns:
        the statement to use in order to store the data
      • getPreparedGetStatement

        protected com.datastax.driver.core.PreparedStatement getPreparedGetStatement​(com.datastax.driver.core.Session session,
                                                                                     java.lang.String attribute,
                                                                                     AttributeDescriptor<?> desc)
        Retrieve cached prepared statement for getting data from cassandra for given attribute.
        Parameters:
        session - the connection session
        attribute - the attribute to fetch
        desc - descriptor of the attribute
        Returns:
        the statement to use in order to read the data
      • getPreparedListStatement

        protected com.datastax.driver.core.PreparedStatement getPreparedListStatement​(com.datastax.driver.core.Session session,
                                                                                      AttributeDescriptor<?> wildcardAttribute)
        Retrieve cached prepared statement for listing data by attribute prefix (for wildcard attributes).
        Parameters:
        session - the connection session
        wildcardAttribute - the wildcard attribute to list
        Returns:
        the statement to use in order to read the data
      • getPreparedListAllStatement

        protected com.datastax.driver.core.PreparedStatement getPreparedListAllStatement​(com.datastax.driver.core.Session session)
      • createInsertStatement

        protected abstract java.lang.String createInsertStatement​(StreamElement element)
        Create statement to be prepared for given ingest. This will be then stored in cache after call to prepare.
        Parameters:
        element - the input element to create statement for
        Returns:
        string representation of the CQL
      • createDeleteStatement

        protected abstract java.lang.String createDeleteStatement​(StreamElement element)
        Create statement to be prepared for given ingest when deleting attribute.
        Parameters:
        element - the input element to create statement for
        Returns:
        string representation of the CQL
      • createDeleteWildcardStatement

        protected abstract java.lang.String createDeleteWildcardStatement​(StreamElement element)
        Create statement to delete wildcard attribute.
        Parameters:
        element - the input element to create statement for
        Returns:
        string representation of the CQL
      • createGetStatement

        protected abstract java.lang.String createGetStatement​(java.lang.String attribute,
                                                               AttributeDescriptor<?> desc)
        Create get statement for key-attribute pair. The statement must return only single field with value.
        Parameters:
        attribute - the input attribute to create get for
        desc - the descriptor of the attribute
        Returns:
        string representation of the CQL
      • createListStatement

        protected abstract java.lang.String createListStatement​(AttributeDescriptor<?> desc)
        Create list statement for key-wildcardAttribute pair. The statement must return two fields - attribute, value.
        Parameters:
        desc - the descriptor of the attribute
        Returns:
        string representation of the CQL
      • createListEntitiesStatement

        protected abstract java.lang.String createListEntitiesStatement()
        Create list statement for entity keys. The statement must return single field - the entity key.
        Returns:
        string representation of the CQL
      • createFetchTokenStatement

        protected abstract java.lang.String createFetchTokenStatement()
        Create statement to fetch token for primary key. The statement must return only the token as single field in single row.
        Returns:
        string representation of the CQL
      • createListAllStatement

        protected abstract java.lang.String createListAllStatement​(com.datastax.driver.core.Session session)
        Create statement to list all attributes of this entity.
        Parameters:
        session - the connection session
        Returns:
        string representation of the CQL
      • clearCache

        protected void clearCache()
        Clear the cache (e.g. on reconnects).
      • getListEntitiesStatement

        public com.datastax.driver.core.BoundStatement getListEntitiesStatement​(Offsets.Token offset,
                                                                                int limit,
                                                                                com.datastax.driver.core.Session session)
        Description copied from interface: CqlFactory
        Get statement for listing entities.
        Specified by:
        getListEntitiesStatement in interface CqlFactory
        Parameters:
        offset - offset of the query
        limit - maximal number of elements to list (-1 for all)
        session - connection session
        Returns:
        the statement to execute
      • getFetchTokenStatement

        public com.datastax.driver.core.BoundStatement getFetchTokenStatement​(java.lang.String key,
                                                                              com.datastax.driver.core.Session session)
        Description copied from interface: CqlFactory
        Retrieve a bound statement to fetch a token for given entity.
        Specified by:
        getFetchTokenStatement in interface CqlFactory
        Parameters:
        key - key to fetch token for
        session - connection session
        Returns:
        the statement to execute