Read query generator for queries on flat tables i.e tables with no clustering keys.
The class lives along other implementations like
CFRowQueryGen,
CFRowRangeQueryGen and
CFRowKeysQueryGen
The structure of queries for flat tables was different enough that they warranted their own class. If your schema contains clustering keys
then see
CFRowQueryGen,
CFRowRangeQueryGen and
CFRowKeysQueryGen for implementation details.
Note that the class manages several individual query generators for different use cases like
1. Selecting the entire row
2. Performing a column slice operation i.e column collection
Each of these query generators uses the
QueryGenCache to maintain a cached reference to the
PreparedStatement
that it creates, which can then be leveraged by subsequent flat table queries that have the same signature.
Note the one must use caching for flat table queries with EXTREME CAUTION. The cacheability of a query depends on the actual
signature of a query. If you use different queries with different signatures for the same column slice operations, then caching will
not work. Here is an example where caching will break queries.
Consider a query where you want to perform a column slice operation i.e cherry pick some column for a given row.
The Astyanax query for that will look somewhat like this
ks.prepareQuery( myCF )
.getRow( 1 )
.getColumn( first_name )
.execute();
Now if the table is a flat table, then the query for this will look something like
SELECT first_name FROM ks.myCF WHERE key = ? ;
Note the bind marker for the row key. That is the only parameter here which is dynamic and the column name here i.e "first_name" is not
and hence is part of the signature of this query.
Now if we were to attempt to re-use the same prepared statement for a query like this
ks.prepareQuery( myCF )
.getRow( 1 )
.getColumn( last_name ) <------ NOTE THAT WE ARE CHANGING OUR COLUMN SLICE AND HENCE VIOLATING THE QUERY SIGNATURE
.execute();
Then this will break since the CQL query required for this is
SELECT first_name FROM ks.myCF WHERE key = ? ;
In cases like this, DO NOT use statement caching.