use of com.datastax.driver.core.querybuilder.Select in project camel by apache.
the class CassandraAggregationRepository method initSelectKeyIdStatement.
// -------------------------------------------------------------------------
private void initSelectKeyIdStatement() {
Select select = generateSelect(table, // Key + Exchange Id columns
new String[] { getKeyColumn(), exchangeIdColumn }, pkColumns, // Where fixed PK columns
pkColumns.length - 1);
select = applyConsistencyLevel(select, readConsistencyLevel);
LOGGER.debug("Generated Select keys {}", select);
selectKeyIdStatement = getSession().prepare(select);
}
use of com.datastax.driver.core.querybuilder.Select in project camel by apache.
the class CassandraAggregationRepository method initSelectStatement.
// -------------------------------------------------------------------------
// Get exchange from repository
protected void initSelectStatement() {
Select select = generateSelect(table, getAllColumns(), pkColumns);
select = applyConsistencyLevel(select, readConsistencyLevel);
LOGGER.debug("Generated Select {}", select);
selectStatement = getSession().prepare(select);
}
use of com.datastax.driver.core.querybuilder.Select in project presto by prestodb.
the class NativeCassandraSession method queryPartitionKeys.
protected Iterable<Row> queryPartitionKeys(CassandraTable table, List<Object> filterPrefix) {
CassandraTableHandle tableHandle = table.getTableHandle();
List<CassandraColumnHandle> partitionKeyColumns = table.getPartitionKeyColumns();
if (filterPrefix.size() != partitionKeyColumns.size()) {
return null;
}
Select partitionKeys = CassandraCqlUtils.selectDistinctFrom(tableHandle, partitionKeyColumns);
addWhereClause(partitionKeys.where(), partitionKeyColumns, filterPrefix);
return executeWithSession(session -> session.execute(partitionKeys)).all();
}
use of com.datastax.driver.core.querybuilder.Select in project spring-boot by spring-projects.
the class CassandraHealthIndicator method doHealthCheck.
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
try {
Select select = QueryBuilder.select("release_version").from("system", "local");
ResultSet results = this.cassandraOperations.getCqlOperations().queryForResultSet(select);
if (results.isExhausted()) {
builder.up();
return;
}
String version = results.one().getString(0);
builder.up().withDetail("version", version);
} catch (Exception ex) {
builder.down(ex);
}
}
use of com.datastax.driver.core.querybuilder.Select in project YCSB by brianfrankcooper.
the class CassandraCQLClientTest method testUpdate.
@Test
public void testUpdate() throws Exception {
final String key = "key";
final HashMap<String, String> input = new HashMap<String, String>();
input.put("field0", "value1");
input.put("field1", "value2");
final Status status = client.insert(TABLE, key, StringByteIterator.getByteIteratorMap(input));
assertThat(status, is(Status.OK));
// Verify result
final Select selectStmt = QueryBuilder.select("field0", "field1").from(TABLE).where(QueryBuilder.eq(CassandraCQLClient.YCSB_KEY, key)).limit(1);
final ResultSet rs = session.execute(selectStmt);
final Row row = rs.one();
assertThat(row, notNullValue());
assertThat(rs.isExhausted(), is(true));
assertThat(row.getString("field0"), is("value1"));
assertThat(row.getString("field1"), is("value2"));
}
Aggregations