Merge branch 'master' into DATACASS-34
This commit is contained in:
@@ -66,6 +66,31 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> T query(final String cql, ResultSetExtractor<T> rse) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Executes the provided CQL Query, and extracts the results with the ResultSetExtractor.
|
||||
*
|
||||
* @param cql The Query
|
||||
* @param rse The implementation for extracting the ResultSet
|
||||
* @param optionsByName Query Options Map
|
||||
*
|
||||
* @return
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> T query(final String cql, ResultSetExtractor<T> rse, final Map<String, Object> optionsByName)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Executes the provided CQL Query, and extracts the results with the ResultSetExtractor.
|
||||
*
|
||||
* @param cql The Query
|
||||
* @param rse The implementation for extracting the ResultSet
|
||||
* @param options Query Options Object
|
||||
*
|
||||
* @return
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> T query(final String cql, ResultSetExtractor<T> rse, final QueryOptions options) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Executes the provided CQL Query asynchronously, and extracts the results with the ResultSetFutureExtractor
|
||||
*
|
||||
@@ -76,6 +101,30 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> T queryAsynchronously(final String cql, ResultSetFutureExtractor<T> rse) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Executes the provided CQL Query asynchronously, and extracts the results with the ResultSetFutureExtractor
|
||||
*
|
||||
* @param cql The Query
|
||||
* @param rse The implementation for extracting the future results
|
||||
* @param optionsByName Query Options Map
|
||||
* @return
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> T queryAsynchronously(final String cql, ResultSetFutureExtractor<T> rse, final Map<String, Object> optionsByName)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Executes the provided CQL Query asynchronously, and extracts the results with the ResultSetFutureExtractor
|
||||
*
|
||||
* @param cql The Query
|
||||
* @param rse The implementation for extracting the future results
|
||||
* @param options Query Options Object
|
||||
* @return
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> T queryAsynchronously(final String cql, ResultSetFutureExtractor<T> rse, final QueryOptions options)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Executes the provided CQL Query, and then processes the results with the <code>RowCallbackHandler</code>.
|
||||
*
|
||||
@@ -85,6 +134,27 @@ public interface CassandraOperations {
|
||||
*/
|
||||
void query(final String cql, RowCallbackHandler rch) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Executes the provided CQL Query, and then processes the results with the <code>RowCallbackHandler</code>.
|
||||
*
|
||||
* @param cql The Query
|
||||
* @param rch The implementation for processing the rows returned.
|
||||
* @param options Query Options Map
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
void query(final String cql, RowCallbackHandler rch, final Map<String, Object> optionsByName)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Executes the provided CQL Query, and then processes the results with the <code>RowCallbackHandler</code>.
|
||||
*
|
||||
* @param cql The Query
|
||||
* @param rch The implementation for processing the rows returned.
|
||||
* @param options Query Options Object
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
void query(final String cql, RowCallbackHandler rch, final QueryOptions options) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Processes the ResultSet through the RowCallbackHandler and return nothing. This is used internal to the Template
|
||||
* for core operations, but is made available through Operations in the event you have a ResultSet to process. The
|
||||
@@ -106,6 +176,29 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> List<T> query(final String cql, RowMapper<T> rowMapper) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Executes the provided CQL Query, and maps all Rows returned with the supplied RowMapper.
|
||||
*
|
||||
* @param cql The Query
|
||||
* @param rowMapper The implementation for mapping all rows
|
||||
* @param optionsByName Query Options Map
|
||||
* @return List of <T> processed by the RowMapper
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> List<T> query(final String cql, RowMapper<T> rowMapper, final Map<String, Object> optionsByName)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Executes the provided CQL Query, and maps all Rows returned with the supplied RowMapper.
|
||||
*
|
||||
* @param cql The Query
|
||||
* @param rowMapper The implementation for mapping all rows
|
||||
* @param options Query Options Object
|
||||
* @return List of <T> processed by the RowMapper
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> List<T> query(final String cql, RowMapper<T> rowMapper, final QueryOptions options) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Processes the ResultSet through the RowMapper and returns the List of mapped Rows. This is used internal to the
|
||||
* Template for core operations, but is made available through Operations in the event you have a ResultSet to
|
||||
@@ -270,6 +363,12 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> T query(final String cql, PreparedStatementBinder psb, ResultSetExtractor<T> rse) throws DataAccessException;
|
||||
|
||||
<T> T query(final String cql, PreparedStatementBinder psb, ResultSetExtractor<T> rse,
|
||||
final Map<String, Object> optionsByName) throws DataAccessException;
|
||||
|
||||
<T> T query(final String cql, PreparedStatementBinder psb, ResultSetExtractor<T> rse, final QueryOptions options)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Converts the CQL provided into a {@link SimplePreparedStatementCreator}. Then, the PreparedStatementBinder will
|
||||
* bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
|
||||
@@ -282,6 +381,34 @@ public interface CassandraOperations {
|
||||
*/
|
||||
void query(final String cql, PreparedStatementBinder psb, RowCallbackHandler rch) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Converts the CQL provided into a {@link SimplePreparedStatementCreator}. Then, the PreparedStatementBinder will
|
||||
* bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
|
||||
* processed with the RowCallbackHandler implementation provided and nothing is returned.
|
||||
*
|
||||
* @param cql The Query to Prepare
|
||||
* @param psb The Binding implementation
|
||||
* @param rch The RowCallbackHandler for processing the ResultSet
|
||||
* @param optionsByName The Query Options Map
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
void query(final String cql, PreparedStatementBinder psb, RowCallbackHandler rch,
|
||||
final Map<String, Object> optionsByName) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Converts the CQL provided into a {@link SimplePreparedStatementCreator}. Then, the PreparedStatementBinder will
|
||||
* bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
|
||||
* processed with the RowCallbackHandler implementation provided and nothing is returned.
|
||||
*
|
||||
* @param cql The Query to Prepare
|
||||
* @param psb The Binding implementation
|
||||
* @param rch The RowCallbackHandler for processing the ResultSet
|
||||
* @param options The Query Options Object
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
void query(final String cql, PreparedStatementBinder psb, RowCallbackHandler rch, final QueryOptions options)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Converts the CQL provided into a {@link SimplePreparedStatementCreator}. Then, the PreparedStatementBinder will
|
||||
* bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
|
||||
@@ -296,6 +423,38 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> List<T> query(final String cql, PreparedStatementBinder psb, RowMapper<T> rowMapper) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Converts the CQL provided into a {@link SimplePreparedStatementCreator}. Then, the PreparedStatementBinder will
|
||||
* bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
|
||||
* processed with the RowMapper implementation provided and a List is returned with elements of Type <T> for each Row
|
||||
* returned.
|
||||
*
|
||||
* @param cql The Query to Prepare
|
||||
* @param psb The Binding implementation
|
||||
* @param rowMapper The implementation for Mapping a Row to Type <T>
|
||||
* @param optionsByName The Query Options Map
|
||||
* @return List of <T> for each Row returned from the Query.
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> List<T> query(final String cql, PreparedStatementBinder psb, RowMapper<T> rowMapper,
|
||||
final Map<String, Object> optionsByName) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Converts the CQL provided into a {@link SimplePreparedStatementCreator}. Then, the PreparedStatementBinder will
|
||||
* bind its values to the bind variables in the provided CQL String. The results of the PreparedStatement are
|
||||
* processed with the RowMapper implementation provided and a List is returned with elements of Type <T> for each Row
|
||||
* returned.
|
||||
*
|
||||
* @param cql The Query to Prepare
|
||||
* @param psb The Binding implementation
|
||||
* @param rowMapper The implementation for Mapping a Row to Type <T>
|
||||
* @param options The Query Options Object
|
||||
* @return List of <T> for each Row returned from the Query.
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> List<T> query(final String cql, PreparedStatementBinder psb, RowMapper<T> rowMapper, final QueryOptions options)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. <b>This can only be used for CQL
|
||||
* Statements that do not have data binding.</b> The results of the PreparedStatement are processed with
|
||||
@@ -308,6 +467,34 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> T query(PreparedStatementCreator psc, ResultSetExtractor<T> rse) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. <b>This can only be used for CQL
|
||||
* Statements that do not have data binding.</b> The results of the PreparedStatement are processed with
|
||||
* ResultSetExtractor implementation provided by the Application Code.
|
||||
*
|
||||
* @param psc The implementation to create the PreparedStatement
|
||||
* @param rse Implementation for extracting from the ResultSet
|
||||
* @param optionsByName The Query Options Map
|
||||
* @return Type <T> which is the output of the ResultSetExtractor
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> T query(PreparedStatementCreator psc, ResultSetExtractor<T> rse, final Map<String, Object> optionsByName)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. <b>This can only be used for CQL
|
||||
* Statements that do not have data binding.</b> The results of the PreparedStatement are processed with
|
||||
* ResultSetExtractor implementation provided by the Application Code.
|
||||
*
|
||||
* @param psc The implementation to create the PreparedStatement
|
||||
* @param rse Implementation for extracting from the ResultSet
|
||||
* @param options The Query Options Object
|
||||
* @return Type <T> which is the output of the ResultSetExtractor
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> T query(PreparedStatementCreator psc, ResultSetExtractor<T> rse, final QueryOptions options)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. <b>This can only be used for CQL
|
||||
* Statements that do not have data binding.</b> The results of the PreparedStatement are processed with
|
||||
@@ -319,6 +506,32 @@ public interface CassandraOperations {
|
||||
*/
|
||||
void query(PreparedStatementCreator psc, RowCallbackHandler rch) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. <b>This can only be used for CQL
|
||||
* Statements that do not have data binding.</b> The results of the PreparedStatement are processed with
|
||||
* RowCallbackHandler and nothing is returned.
|
||||
*
|
||||
* @param psc The implementation to create the PreparedStatement
|
||||
* @param rch The implementation to process Results
|
||||
* @param optionsByName The Query Options Map
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
void query(PreparedStatementCreator psc, RowCallbackHandler rch, final Map<String, Object> optionsByName)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. <b>This can only be used for CQL
|
||||
* Statements that do not have data binding.</b> The results of the PreparedStatement are processed with
|
||||
* RowCallbackHandler and nothing is returned.
|
||||
*
|
||||
* @param psc The implementation to create the PreparedStatement
|
||||
* @param rch The implementation to process Results
|
||||
* @param options The Query Options Object
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
void query(PreparedStatementCreator psc, RowCallbackHandler rch, final QueryOptions options)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. <b>This can only be used for CQL
|
||||
* Statements that do not have data binding.</b> The results of the PreparedStatement are processed with RowMapper
|
||||
@@ -331,6 +544,64 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> List<T> query(PreparedStatementCreator psc, RowMapper<T> rowMapper) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. <b>This can only be used for CQL
|
||||
* Statements that do not have data binding.</b> The results of the PreparedStatement are processed with RowMapper
|
||||
* implementation provided and a List is returned with elements of Type <T> for each Row returned.
|
||||
*
|
||||
* @param psc The implementation to create the PreparedStatement
|
||||
* @param rowMapper The implementation for mapping each Row returned.
|
||||
* @param optionsByName The Query Options Map
|
||||
* @return List of Type <T> mapped from each Row in the Results
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> List<T> query(PreparedStatementCreator psc, RowMapper<T> rowMapper, final Map<String, Object> optionsByName)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. <b>This can only be used for CQL
|
||||
* Statements that do not have data binding.</b> The results of the PreparedStatement are processed with RowMapper
|
||||
* implementation provided and a List is returned with elements of Type <T> for each Row returned.
|
||||
*
|
||||
* @param psc The implementation to create the PreparedStatement
|
||||
* @param rowMapper The implementation for mapping each Row returned.
|
||||
* @param options The Query Options Object
|
||||
* @return List of Type <T> mapped from each Row in the Results
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> List<T> query(PreparedStatementCreator psc, RowMapper<T> rowMapper, final QueryOptions options)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
|
||||
* PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
|
||||
* ResultSetExtractor implementation provided by the Application Code.
|
||||
*
|
||||
* @param psc The implementation to create the PreparedStatement
|
||||
* @param psb The implementation to bind variables to values
|
||||
* @param rse Implementation for extracting from the ResultSet
|
||||
* @param optionsByName The Query Options Map
|
||||
* @return Type <T> which is the output of the ResultSetExtractor
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> T query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final ResultSetExtractor<T> rse,
|
||||
final Map<String, Object> optionsByName) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
|
||||
* PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
|
||||
* ResultSetExtractor implementation provided by the Application Code.
|
||||
*
|
||||
* @param psc The implementation to create the PreparedStatement
|
||||
* @param psb The implementation to bind variables to values
|
||||
* @param rse Implementation for extracting from the ResultSet
|
||||
* @param options The Query Options Object
|
||||
* @return Type <T> which is the output of the ResultSetExtractor
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> T query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final ResultSetExtractor<T> rse,
|
||||
final QueryOptions options) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
|
||||
* PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
|
||||
@@ -345,6 +616,36 @@ public interface CassandraOperations {
|
||||
<T> T query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final ResultSetExtractor<T> rse)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
|
||||
* PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
|
||||
* RowCallbackHandler and nothing is returned.
|
||||
*
|
||||
* @param psc The implementation to create the PreparedStatement
|
||||
* @param psb The implementation to bind variables to values
|
||||
* @param rch The implementation to process Results
|
||||
* @param optionsByName The Query Options Map
|
||||
* @return Type <T> which is the output of the ResultSetExtractor
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
void query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final RowCallbackHandler rch,
|
||||
final Map<String, Object> optionsByName) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
|
||||
* PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
|
||||
* RowCallbackHandler and nothing is returned.
|
||||
*
|
||||
* @param psc The implementation to create the PreparedStatement
|
||||
* @param psb The implementation to bind variables to values
|
||||
* @param rch The implementation to process Results
|
||||
* @param options The Query Options Object
|
||||
* @return Type <T> which is the output of the ResultSetExtractor
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
void query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final RowCallbackHandler rch,
|
||||
final QueryOptions options) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
|
||||
* PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
|
||||
@@ -359,6 +660,36 @@ public interface CassandraOperations {
|
||||
void query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final RowCallbackHandler rch)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
|
||||
* PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
|
||||
* RowMapper implementation provided and a List is returned with elements of Type <T> for each Row returned.
|
||||
*
|
||||
* @param psc The implementation to create the PreparedStatement
|
||||
* @param psb The implementation to bind variables to values
|
||||
* @param rowMapper The implementation for mapping each Row returned.
|
||||
* @param optionsByName The Query Options Map
|
||||
* @return Type <T> which is the output of the ResultSetExtractor
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> List<T> query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final RowMapper<T> rowMapper,
|
||||
final Map<String, Object> optionsByName) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
|
||||
* PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
|
||||
* RowMapper implementation provided and a List is returned with elements of Type <T> for each Row returned.
|
||||
*
|
||||
* @param psc The implementation to create the PreparedStatement
|
||||
* @param psb The implementation to bind variables to values
|
||||
* @param rowMapper The implementation for mapping each Row returned.
|
||||
* @param options The Query Options Object
|
||||
* @return Type <T> which is the output of the ResultSetExtractor
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
<T> List<T> query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final RowMapper<T> rowMapper,
|
||||
final QueryOptions options) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Uses the provided PreparedStatementCreator to prepare a new Session call. Binds the values from the
|
||||
* PreparedStatementBinder to the available bind variables. The results of the PreparedStatement are processed with
|
||||
@@ -398,6 +729,36 @@ public interface CassandraOperations {
|
||||
*/
|
||||
Session getSession();
|
||||
|
||||
/**
|
||||
* This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
|
||||
* all row values are bound to the single PreparedStatement and executed against the Session.
|
||||
*
|
||||
* <p>
|
||||
* This is used internally by the other ingest() methods, but can be used if you want to write your own RowIterator.
|
||||
* The Object[] length returned by the next() implementation must match the number of bind variables in the CQL.
|
||||
* </p>
|
||||
*
|
||||
* @param cql The CQL
|
||||
* @param rowIterator Implementation to provide the Object[] to be bound to the CQL.
|
||||
* @param optionsByName The Query Options Map
|
||||
*/
|
||||
void ingest(String cql, RowIterator rowIterator, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
|
||||
* all row values are bound to the single PreparedStatement and executed against the Session.
|
||||
*
|
||||
* <p>
|
||||
* This is used internally by the other ingest() methods, but can be used if you want to write your own RowIterator.
|
||||
* The Object[] length returned by the next() implementation must match the number of bind variables in the CQL.
|
||||
* </p>
|
||||
*
|
||||
* @param cql The CQL
|
||||
* @param rowIterator Implementation to provide the Object[] to be bound to the CQL.
|
||||
* @param options The Query Options Object
|
||||
*/
|
||||
void ingest(String cql, RowIterator rowIterator, QueryOptions options);
|
||||
|
||||
/**
|
||||
* This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
|
||||
* all row values are bound to the single PreparedStatement and executed against the Session.
|
||||
@@ -412,6 +773,34 @@ public interface CassandraOperations {
|
||||
*/
|
||||
void ingest(String cql, RowIterator rowIterator);
|
||||
|
||||
/**
|
||||
* This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
|
||||
* all row values are bound to the single PreparedStatement and executed against the Session.
|
||||
*
|
||||
* <p>
|
||||
* The List<?> length must match the number of bind variables in the CQL.
|
||||
* </p>
|
||||
*
|
||||
* @param cql The CQL
|
||||
* @param rows List of List<?> with data to bind to the CQL.
|
||||
* @param optionsByName The Query Options Map
|
||||
*/
|
||||
void ingest(String cql, List<List<?>> rows, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
|
||||
* all row values are bound to the single PreparedStatement and executed against the Session.
|
||||
*
|
||||
* <p>
|
||||
* The List<?> length must match the number of bind variables in the CQL.
|
||||
* </p>
|
||||
*
|
||||
* @param cql The CQL
|
||||
* @param rows List of List<?> with data to bind to the CQL.
|
||||
* @param options The Query Options Object
|
||||
*/
|
||||
void ingest(String cql, List<List<?>> rows, QueryOptions options);
|
||||
|
||||
/**
|
||||
* This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
|
||||
* all row values are bound to the single PreparedStatement and executed against the Session.
|
||||
@@ -425,6 +814,34 @@ public interface CassandraOperations {
|
||||
*/
|
||||
void ingest(String cql, List<List<?>> rows);
|
||||
|
||||
/**
|
||||
* This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
|
||||
* all row values are bound to the single PreparedStatement and executed against the Session.
|
||||
*
|
||||
* <p>
|
||||
* The Object[] length of the nested array must match the number of bind variables in the CQL.
|
||||
* </p>
|
||||
*
|
||||
* @param cql The CQL
|
||||
* @param rows Object array of Object array of values to bind to the CQL.
|
||||
* @param optionsByName The Query Options Map
|
||||
*/
|
||||
void ingest(String cql, Object[][] rows, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
|
||||
* all row values are bound to the single PreparedStatement and executed against the Session.
|
||||
*
|
||||
* <p>
|
||||
* The Object[] length of the nested array must match the number of bind variables in the CQL.
|
||||
* </p>
|
||||
*
|
||||
* @param cql The CQL
|
||||
* @param rows Object array of Object array of values to bind to the CQL.
|
||||
* @param options The Query Options Object
|
||||
*/
|
||||
void ingest(String cql, Object[][] rows, QueryOptions options);
|
||||
|
||||
/**
|
||||
* This is an operation designed for high performance writes. The cql is used to create a PreparedStatement once, then
|
||||
* all row values are bound to the single PreparedStatement and executed against the Session.
|
||||
|
||||
@@ -33,10 +33,13 @@ import com.datastax.driver.core.DataType;
|
||||
import com.datastax.driver.core.Host;
|
||||
import com.datastax.driver.core.Metadata;
|
||||
import com.datastax.driver.core.PreparedStatement;
|
||||
import com.datastax.driver.core.Query;
|
||||
import com.datastax.driver.core.ResultSet;
|
||||
import com.datastax.driver.core.ResultSetFuture;
|
||||
import com.datastax.driver.core.Row;
|
||||
import com.datastax.driver.core.Session;
|
||||
import com.datastax.driver.core.SimpleStatement;
|
||||
import com.datastax.driver.core.Statement;
|
||||
import com.datastax.driver.core.exceptions.DriverException;
|
||||
import com.datastax.driver.core.querybuilder.QueryBuilder;
|
||||
import com.datastax.driver.core.querybuilder.Truncate;
|
||||
@@ -87,7 +90,33 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
*/
|
||||
@Override
|
||||
public void execute(final String cql) throws DataAccessException {
|
||||
doExecute(cql);
|
||||
doExecute(cql, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#queryAsynchronously(java.lang.String, org.springframework.cassandra.core.ResultSetFutureExtractor, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> T queryAsynchronously(final String cql, ResultSetFutureExtractor<T> rse,
|
||||
final Map<String, Object> optionsByName) throws DataAccessException {
|
||||
return rse.extractData(execute(new SessionCallback<ResultSetFuture>() {
|
||||
@Override
|
||||
public ResultSetFuture doInSession(Session s) throws DataAccessException {
|
||||
Statement statement = new SimpleStatement(cql);
|
||||
addQueryOptions(statement, optionsByName);
|
||||
return s.executeAsync(statement);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#queryAsynchronously(java.lang.String, org.springframework.cassandra.core.ResultSetFutureExtractor, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> T queryAsynchronously(String cql, ResultSetFutureExtractor<T> rse, QueryOptions options)
|
||||
throws DataAccessException {
|
||||
Assert.notNull(options);
|
||||
return queryAsynchronously(cql, rse, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -95,69 +124,120 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
*/
|
||||
@Override
|
||||
public <T> T queryAsynchronously(final String cql, ResultSetFutureExtractor<T> rse) throws DataAccessException {
|
||||
return rse.extractData(execute(new SessionCallback<ResultSetFuture>() {
|
||||
@Override
|
||||
public ResultSetFuture doInSession(Session s) throws DataAccessException {
|
||||
return s.executeAsync(cql);
|
||||
}
|
||||
}));
|
||||
return queryAsynchronously(cql, rse, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.ResultSetExtractor)
|
||||
*/
|
||||
public <T> T query(String cql, ResultSetExtractor<T> rse) throws DataAccessException {
|
||||
ResultSet rs = doExecute(cql);
|
||||
public <T> T query(String cql, ResultSetExtractor<T> rse, Map<String, Object> optionsByName)
|
||||
throws DataAccessException {
|
||||
Assert.notNull(cql);
|
||||
Assert.notNull(optionsByName);
|
||||
ResultSet rs = doExecute(cql, optionsByName);
|
||||
return rse.extractData(rs);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.ResultSetExtractor, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> T query(String cql, ResultSetExtractor<T> rse) throws DataAccessException {
|
||||
return query(cql, rse, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.ResultSetExtractor, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> T query(String cql, ResultSetExtractor<T> rse, QueryOptions options) throws DataAccessException {
|
||||
Assert.notNull(options);
|
||||
return query(cql, rse, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.RowCallbackHandler, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void query(String cql, RowCallbackHandler rch, Map<String, Object> optionsByName) throws DataAccessException {
|
||||
process(doExecute(cql, optionsByName), rch);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.RowCallbackHandler, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public void query(String cql, RowCallbackHandler rch, QueryOptions options) throws DataAccessException {
|
||||
Assert.notNull(options);
|
||||
query(cql, rch, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.RowCallbackHandler)
|
||||
*/
|
||||
public void query(String cql, RowCallbackHandler rch) throws DataAccessException {
|
||||
process(doExecute(cql), rch);
|
||||
query(cql, rch, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.RowMapper, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> query(String cql, RowMapper<T> rowMapper, Map<String, Object> optionsByName)
|
||||
throws DataAccessException {
|
||||
Assert.notNull(optionsByName);
|
||||
return process(doExecute(cql, optionsByName), rowMapper);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.RowMapper, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> query(String cql, RowMapper<T> rowMapper, QueryOptions options) throws DataAccessException {
|
||||
Assert.notNull(options);
|
||||
return query(cql, rowMapper, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.RowMapper)
|
||||
*/
|
||||
public <T> List<T> query(String cql, RowMapper<T> rowMapper) throws DataAccessException {
|
||||
return process(doExecute(cql), rowMapper);
|
||||
return query(cql, rowMapper, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#queryForList(java.lang.String)
|
||||
*/
|
||||
public List<Map<String, Object>> queryForListOfMap(String cql) throws DataAccessException {
|
||||
return processListOfMap(doExecute(cql));
|
||||
return processListOfMap(doExecute(cql, new HashMap<String, Object>()));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#queryForList(java.lang.String, java.lang.Class)
|
||||
*/
|
||||
public <T> List<T> queryForList(String cql, Class<T> elementType) throws DataAccessException {
|
||||
return processList(doExecute(cql), elementType);
|
||||
return processList(doExecute(cql, new HashMap<String, Object>()), elementType);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#queryForMap(java.lang.String)
|
||||
*/
|
||||
public Map<String, Object> queryForMap(String cql) throws DataAccessException {
|
||||
return processMap(doExecute(cql));
|
||||
return processMap(doExecute(cql, new HashMap<String, Object>()));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#queryForObject(java.lang.String, java.lang.Class)
|
||||
*/
|
||||
public <T> T queryForObject(String cql, Class<T> requiredType) throws DataAccessException {
|
||||
return processOne(doExecute(cql), requiredType);
|
||||
return processOne(doExecute(cql, new HashMap<String, Object>()), requiredType);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#queryForObject(java.lang.String, org.springframework.cassandra.core.RowMapper)
|
||||
*/
|
||||
public <T> T queryForObject(String cql, RowMapper<T> rowMapper) throws DataAccessException {
|
||||
return processOne(doExecute(cql), rowMapper);
|
||||
return processOne(doExecute(cql, new HashMap<String, Object>()), rowMapper);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,7 +265,7 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
* @param callback
|
||||
* @return
|
||||
*/
|
||||
protected ResultSet doExecute(final String cql) {
|
||||
protected ResultSet doExecute(final String cql, final Map<String, Object> optionsByName) {
|
||||
|
||||
logger.info(cql);
|
||||
|
||||
@@ -193,7 +273,9 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
|
||||
@Override
|
||||
public ResultSet doInSession(Session s) throws DataAccessException {
|
||||
return s.execute(cql);
|
||||
SimpleStatement statement = new SimpleStatement(cql);
|
||||
addQueryOptions(statement, optionsByName);
|
||||
return s.execute(statement);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -204,12 +286,13 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
* @param callback
|
||||
* @return
|
||||
*/
|
||||
protected ResultSet doExecute(final BoundStatement bs) {
|
||||
protected ResultSet doExecute(final BoundStatement bs, final Map<String, Object> optionsByName) {
|
||||
|
||||
return doExecute(new SessionCallback<ResultSet>() {
|
||||
|
||||
@Override
|
||||
public ResultSet doInSession(Session s) throws DataAccessException {
|
||||
addQueryOptions(bs, optionsByName);
|
||||
return s.execute(bs);
|
||||
}
|
||||
});
|
||||
@@ -443,12 +526,52 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
return execute(new SimplePreparedStatementCreator(cql), action);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.ResultSetExtractor, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> T query(PreparedStatementCreator psc, ResultSetExtractor<T> rse, Map<String, Object> optionsByName)
|
||||
throws DataAccessException {
|
||||
Assert.notNull(optionsByName);
|
||||
return query(psc, null, rse, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.ResultSetExtractor, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> T query(PreparedStatementCreator psc, ResultSetExtractor<T> rse, QueryOptions options)
|
||||
throws DataAccessException {
|
||||
Assert.notNull(options);
|
||||
return query(psc, rse, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.ResultSetExtractor)
|
||||
*/
|
||||
@Override
|
||||
public <T> T query(PreparedStatementCreator psc, ResultSetExtractor<T> rse) throws DataAccessException {
|
||||
return query(psc, null, rse);
|
||||
return query(psc, rse, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.RowCallbackHandler, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void query(PreparedStatementCreator psc, RowCallbackHandler rch, Map<String, Object> optionsByName)
|
||||
throws DataAccessException {
|
||||
Assert.notNull(optionsByName);
|
||||
query(psc, null, rch, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.RowCallbackHandler, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public void query(PreparedStatementCreator psc, RowCallbackHandler rch, QueryOptions options)
|
||||
throws DataAccessException {
|
||||
Assert.notNull(options);
|
||||
query(psc, rch, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -456,7 +579,27 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
*/
|
||||
@Override
|
||||
public void query(PreparedStatementCreator psc, RowCallbackHandler rch) throws DataAccessException {
|
||||
query(psc, null, rch);
|
||||
query(psc, rch, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.RowMapper, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> query(PreparedStatementCreator psc, RowMapper<T> rowMapper, Map<String, Object> optionsByName)
|
||||
throws DataAccessException {
|
||||
Assert.notNull(optionsByName);
|
||||
return query(psc, null, rowMapper, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.RowMapper, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> query(PreparedStatementCreator psc, RowMapper<T> rowMapper, QueryOptions options)
|
||||
throws DataAccessException {
|
||||
Assert.notNull(options);
|
||||
return query(psc, rowMapper, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -464,14 +607,14 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> query(PreparedStatementCreator psc, RowMapper<T> rowMapper) throws DataAccessException {
|
||||
return query(psc, null, rowMapper);
|
||||
return query(psc, rowMapper, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.PreparedStatementSetter, org.springframework.cassandra.core.ResultSetExtractor)
|
||||
*/
|
||||
public <T> T query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final ResultSetExtractor<T> rse)
|
||||
throws DataAccessException {
|
||||
public <T> T query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final ResultSetExtractor<T> rse,
|
||||
final Map<String, Object> optionsByName) throws DataAccessException {
|
||||
|
||||
Assert.notNull(rse, "ResultSetExtractor must not be null");
|
||||
logger.debug("Executing prepared CQL query");
|
||||
@@ -485,18 +628,58 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
} else {
|
||||
bs = ps.bind();
|
||||
}
|
||||
rs = doExecute(bs);
|
||||
rs = doExecute(bs, optionsByName);
|
||||
return rse.extractData(rs);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.ResultSetExtractor, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> T query(String cql, PreparedStatementBinder psb, ResultSetExtractor<T> rse,
|
||||
Map<String, Object> optionsByName) throws DataAccessException {
|
||||
Assert.notNull(optionsByName);
|
||||
return query(new SimplePreparedStatementCreator(cql), psb, rse, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.ResultSetExtractor, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> T query(String cql, PreparedStatementBinder psb, ResultSetExtractor<T> rse, QueryOptions options)
|
||||
throws DataAccessException {
|
||||
Assert.notNull(options);
|
||||
return query(cql, psb, rse, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.PreparedStatementSetter, org.springframework.cassandra.core.ResultSetExtractor)
|
||||
*/
|
||||
@Override
|
||||
public <T> T query(String cql, PreparedStatementBinder psb, ResultSetExtractor<T> rse) throws DataAccessException {
|
||||
return query(new SimplePreparedStatementCreator(cql), psb, rse);
|
||||
return query(cql, psb, rse, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.RowCallbackHandler, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void query(String cql, PreparedStatementBinder psb, RowCallbackHandler rch, Map<String, Object> optionsByName)
|
||||
throws DataAccessException {
|
||||
Assert.notNull(optionsByName);
|
||||
query(new SimplePreparedStatementCreator(cql), psb, rch, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.RowCallbackHandler, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public void query(String cql, PreparedStatementBinder psb, RowCallbackHandler rch, QueryOptions options)
|
||||
throws DataAccessException {
|
||||
Assert.notNull(options);
|
||||
query(cql, psb, rch, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -504,7 +687,27 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
*/
|
||||
@Override
|
||||
public void query(String cql, PreparedStatementBinder psb, RowCallbackHandler rch) throws DataAccessException {
|
||||
query(new SimplePreparedStatementCreator(cql), psb, rch);
|
||||
query(cql, psb, rch, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.RowMapper, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> query(String cql, PreparedStatementBinder psb, RowMapper<T> rowMapper,
|
||||
Map<String, Object> optionsByName) throws DataAccessException {
|
||||
Assert.notNull(optionsByName);
|
||||
return query(new SimplePreparedStatementCreator(cql), psb, rowMapper, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(java.lang.String, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.RowMapper, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> query(String cql, PreparedStatementBinder psb, RowMapper<T> rowMapper, QueryOptions options)
|
||||
throws DataAccessException {
|
||||
Assert.notNull(options);
|
||||
return query(cql, psb, rowMapper, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -512,15 +715,15 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> query(String cql, PreparedStatementBinder psb, RowMapper<T> rowMapper) throws DataAccessException {
|
||||
return query(new SimplePreparedStatementCreator(cql), psb, rowMapper);
|
||||
return query(cql, psb, rowMapper, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.RowCallbackHandler)
|
||||
*/
|
||||
@Override
|
||||
public void query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final RowCallbackHandler rch)
|
||||
throws DataAccessException {
|
||||
public void query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final RowCallbackHandler rch,
|
||||
final Map<String, Object> optionsByName) throws DataAccessException {
|
||||
Assert.notNull(rch, "RowCallbackHandler must not be null");
|
||||
logger.debug("Executing prepared CQL query");
|
||||
|
||||
@@ -533,7 +736,7 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
} else {
|
||||
bs = ps.bind();
|
||||
}
|
||||
rs = doExecute(bs);
|
||||
rs = doExecute(bs, optionsByName);
|
||||
process(rs, rch);
|
||||
return null;
|
||||
}
|
||||
@@ -544,8 +747,8 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.RowMapper)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> query(PreparedStatementCreator psc, final PreparedStatementBinder psb, final RowMapper<T> rowMapper)
|
||||
throws DataAccessException {
|
||||
public <T> List<T> query(PreparedStatementCreator psc, final PreparedStatementBinder psb,
|
||||
final RowMapper<T> rowMapper, final Map<String, Object> optionsByName) throws DataAccessException {
|
||||
Assert.notNull(rowMapper, "RowMapper must not be null");
|
||||
logger.debug("Executing prepared CQL query");
|
||||
|
||||
@@ -558,7 +761,7 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
} else {
|
||||
bs = ps.bind();
|
||||
}
|
||||
rs = doExecute(bs);
|
||||
rs = doExecute(bs, optionsByName);
|
||||
|
||||
return process(rs, rowMapper);
|
||||
}
|
||||
@@ -569,9 +772,10 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#execute(java.lang.String, org.springframework.cassandra.core.RowProvider, int)
|
||||
*/
|
||||
@Override
|
||||
public void ingest(String cql, RowIterator rowIterator) {
|
||||
public void ingest(String cql, RowIterator rowIterator, Map<String, Object> optionsByName) {
|
||||
|
||||
PreparedStatement preparedStatement = getSession().prepare(cql);
|
||||
addPreparedStatementOptions(preparedStatement, optionsByName);
|
||||
|
||||
while (rowIterator.hasNext()) {
|
||||
getSession().execute(preparedStatement.bind(rowIterator.next()));
|
||||
@@ -579,12 +783,30 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#ingest(java.lang.String, org.springframework.cassandra.core.RowIterator, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public void ingest(String cql, RowIterator rowIterator, QueryOptions options) {
|
||||
Assert.notNull(options);
|
||||
ingest(cql, rowIterator, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#ingest(java.lang.String, org.springframework.cassandra.core.RowIterator)
|
||||
*/
|
||||
@Override
|
||||
public void ingest(String cql, RowIterator rowIterator) {
|
||||
ingest(cql, rowIterator, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#execute(java.lang.String, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public void ingest(String cql, List<List<?>> rows) {
|
||||
public void ingest(String cql, List<List<?>> rows, Map<String, Object> optionsByName) {
|
||||
|
||||
Assert.notNull(optionsByName);
|
||||
Assert.notNull(rows);
|
||||
Assert.notEmpty(rows);
|
||||
|
||||
@@ -594,15 +816,34 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
values[i++] = row.toArray();
|
||||
}
|
||||
|
||||
ingest(cql, values);
|
||||
ingest(cql, values, optionsByName);
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#ingest(java.lang.String, java.util.List, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public void ingest(String cql, List<List<?>> rows, QueryOptions options) {
|
||||
Assert.notNull(options);
|
||||
ingest(cql, rows, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#ingest(java.lang.String, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public void ingest(String cql, List<List<?>> rows) {
|
||||
ingest(cql, rows, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#execute(java.lang.String, java.lang.Object[][])
|
||||
*/
|
||||
@Override
|
||||
public void ingest(String cql, final Object[][] rows) {
|
||||
public void ingest(String cql, final Object[][] rows, final Map<String, Object> optionsByName) {
|
||||
|
||||
Assert.notNull(optionsByName);
|
||||
|
||||
ingest(cql, new RowIterator() {
|
||||
|
||||
@@ -618,7 +859,24 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
return index < rows.length;
|
||||
}
|
||||
|
||||
});
|
||||
}, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#ingest(java.lang.String, java.lang.Object[][], org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public void ingest(String cql, final Object[][] rows, QueryOptions options) {
|
||||
Assert.notNull(options);
|
||||
ingest(cql, rows, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#ingest(java.lang.String, java.lang.Object[][])
|
||||
*/
|
||||
@Override
|
||||
public void ingest(String cql, final Object[][] rows) {
|
||||
ingest(cql, rows, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -627,6 +885,116 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
||||
@Override
|
||||
public void truncate(String tableName) throws DataAccessException {
|
||||
Truncate truncate = QueryBuilder.truncate(tableName);
|
||||
doExecute(truncate.getQueryString());
|
||||
doExecute(truncate.getQueryString(), new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add common Query options for all types of queries.
|
||||
*
|
||||
* @param q
|
||||
* @param optionsByName
|
||||
*/
|
||||
public static void addQueryOptions(Query q, Map<String, Object> optionsByName) {
|
||||
|
||||
if (optionsByName == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add Query Options
|
||||
*/
|
||||
if (optionsByName.get(QueryOptions.QueryOptionMapKeys.CONSISTENCY_LEVEL) != null) {
|
||||
q.setConsistencyLevel(ConsistencyLevelResolver.resolve((ConsistencyLevel) optionsByName
|
||||
.get(QueryOptions.QueryOptionMapKeys.CONSISTENCY_LEVEL)));
|
||||
}
|
||||
if (optionsByName.get(QueryOptions.QueryOptionMapKeys.RETRY_POLICY) != null) {
|
||||
q.setRetryPolicy(RetryPolicyResolver.resolve((RetryPolicy) optionsByName
|
||||
.get(QueryOptions.QueryOptionMapKeys.RETRY_POLICY)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add common Query options for all types of queries.
|
||||
*
|
||||
* @param q
|
||||
* @param optionsByName
|
||||
*/
|
||||
public static void addPreparedStatementOptions(PreparedStatement s, Map<String, Object> optionsByName) {
|
||||
|
||||
if (optionsByName == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add Query Options
|
||||
*/
|
||||
if (optionsByName.get(QueryOptions.QueryOptionMapKeys.CONSISTENCY_LEVEL) != null) {
|
||||
s.setConsistencyLevel(ConsistencyLevelResolver.resolve((ConsistencyLevel) optionsByName
|
||||
.get(QueryOptions.QueryOptionMapKeys.CONSISTENCY_LEVEL)));
|
||||
}
|
||||
if (optionsByName.get(QueryOptions.QueryOptionMapKeys.RETRY_POLICY) != null) {
|
||||
s.setRetryPolicy(RetryPolicyResolver.resolve((RetryPolicy) optionsByName
|
||||
.get(QueryOptions.QueryOptionMapKeys.RETRY_POLICY)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.ResultSetExtractor, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> T query(PreparedStatementCreator psc, PreparedStatementBinder psb, ResultSetExtractor<T> rse,
|
||||
QueryOptions options) throws DataAccessException {
|
||||
Assert.notNull(options);
|
||||
return query(psc, psb, rse, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.ResultSetExtractor)
|
||||
*/
|
||||
@Override
|
||||
public <T> T query(PreparedStatementCreator psc, PreparedStatementBinder psb, ResultSetExtractor<T> rse)
|
||||
throws DataAccessException {
|
||||
return query(psc, psb, rse, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.RowCallbackHandler, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public void query(PreparedStatementCreator psc, PreparedStatementBinder psb, RowCallbackHandler rch,
|
||||
QueryOptions options) throws DataAccessException {
|
||||
Assert.notNull(options);
|
||||
query(psc, psb, rch, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.RowCallbackHandler)
|
||||
*/
|
||||
@Override
|
||||
public void query(PreparedStatementCreator psc, PreparedStatementBinder psb, RowCallbackHandler rch)
|
||||
throws DataAccessException {
|
||||
query(psc, psb, rch, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.RowMapper, org.springframework.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> query(PreparedStatementCreator psc, PreparedStatementBinder psb, RowMapper<T> rowMapper,
|
||||
QueryOptions options) throws DataAccessException {
|
||||
Assert.notNull(options);
|
||||
return query(psc, psb, rowMapper, options.toMap());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.CassandraOperations#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.RowMapper)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> query(PreparedStatementCreator psc, PreparedStatementBinder psb, RowMapper<T> rowMapper)
|
||||
throws DataAccessException {
|
||||
return query(psc, psb, rowMapper, new HashMap<String, Object>());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
package org.springframework.cassandra.core;
|
||||
|
||||
/**
|
||||
* Generic Consistency Levels associated with Cassandra.
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
package org.springframework.cassandra.core;
|
||||
|
||||
/**
|
||||
* Determine driver consistency level based on ConsistencyLevel
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
package org.springframework.cassandra.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
package org.springframework.cassandra.core;
|
||||
|
||||
/**
|
||||
* Retry Policies associated with Cassandra.
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
package org.springframework.cassandra.core;
|
||||
|
||||
import com.datastax.driver.core.policies.DefaultRetryPolicy;
|
||||
import com.datastax.driver.core.policies.DowngradingConsistencyRetryPolicy;
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.cassandra.core;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.cassandra.core.QueryOptions;
|
||||
import org.springframework.data.cassandra.convert.CassandraConverter;
|
||||
|
||||
import com.datastax.driver.core.querybuilder.Select;
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.cassandra.core.CassandraTemplate;
|
||||
import org.springframework.cassandra.core.QueryOptions;
|
||||
import org.springframework.cassandra.core.SessionCallback;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
|
||||
@@ -6,12 +6,12 @@ import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cassandra.core.ConsistencyLevel;
|
||||
import org.springframework.cassandra.core.ConsistencyLevelResolver;
|
||||
import org.springframework.cassandra.core.QueryOptions;
|
||||
import org.springframework.cassandra.core.RetryPolicy;
|
||||
import org.springframework.cassandra.core.RetryPolicyResolver;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.cassandra.core.ConsistencyLevel;
|
||||
import org.springframework.data.cassandra.core.ConsistencyLevelResolver;
|
||||
import org.springframework.data.cassandra.core.QueryOptions;
|
||||
import org.springframework.data.cassandra.core.RetryPolicy;
|
||||
import org.springframework.data.cassandra.core.RetryPolicyResolver;
|
||||
import org.springframework.data.cassandra.exception.EntityWriterException;
|
||||
import org.springframework.data.cassandra.mapping.CassandraPersistentEntity;
|
||||
import org.springframework.data.cassandra.mapping.CassandraPersistentProperty;
|
||||
|
||||
@@ -40,10 +40,10 @@ import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cassandra.core.ConsistencyLevel;
|
||||
import org.springframework.cassandra.core.QueryOptions;
|
||||
import org.springframework.cassandra.core.RetryPolicy;
|
||||
import org.springframework.data.cassandra.core.CassandraDataOperations;
|
||||
import org.springframework.data.cassandra.core.ConsistencyLevel;
|
||||
import org.springframework.data.cassandra.core.QueryOptions;
|
||||
import org.springframework.data.cassandra.core.RetryPolicy;
|
||||
import org.springframework.data.cassandra.test.integration.config.TestConfig;
|
||||
import org.springframework.data.cassandra.test.integration.table.Book;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
Reference in New Issue
Block a user