本文整理了Java中com.datastax.driver.core.querybuilder.QueryBuilder.select
方法的一些代码示例,展示了QueryBuilder.select
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryBuilder.select
方法的具体详情如下:
包路径:com.datastax.driver.core.querybuilder.QueryBuilder
类名称:QueryBuilder
方法名:select
[英]Start building a new SELECT query.
[中]开始构建一个新的SELECT查询。
代码示例来源:origin: kaaproject/kaa
@Override
public Optional<CassandraEndpointRegistration> findByCredentialsId(String credentialsId) {
LOG.debug("Searching for endpoint registration by credentials ID [{}]", credentialsId);
Clause clause = QueryBuilder.eq(
CassandraModelConstants.EP_REGISTRATION_CREDENTIALS_ID_PROPERTY, credentialsId);
Statement statement = QueryBuilder.select().from(this.getColumnFamilyName())
.where(clause);
return Optional.ofNullable(this.findOneByStatement(statement));
}
代码示例来源:origin: apache/usergrid
private <T> T getValuesCQL(
final MapScope scope, final Collection<String> keys, final ResultsBuilderCQL<T> builder ) {
final List<ByteBuffer> serializedKeys = new ArrayList<>();
keys.forEach(key -> serializedKeys.add(getMapEntryPartitionKey(scope,key)));
Clause in = QueryBuilder.in("key", serializedKeys );
Statement statement = QueryBuilder.select().all().from(MAP_ENTRIES_TABLE)
.where(in);
ResultSet resultSet = session.execute(statement);
return builder.buildResultsCQL( resultSet );
}
代码示例来源:origin: apache/usergrid
@Override
public List<String> getListOfQueues() {
logger.trace( "getListOfQueues " );
Statement select = QueryBuilder.select().all().from( TABLE_QUEUES );
ResultSet rs = cassandraClient.getApplicationSession().execute( select );
return rs.all().stream()
.map( row -> row.getString( COLUMN_QUEUE_NAME ))
.collect( Collectors.toList() );
}
代码示例来源:origin: kaaproject/kaa
ResultSet results = session.execute(select().from("notification"));
for (Row row : results) {
String id = row.getString("nf_id");
update("notification")
.with(set("schema_id", String.valueOf(schemaId + idShift)))
.where(eq("topic_id", ids[0]))
.and(eq("nf_type", ids[1]))
.and(eq("nf_version", Integer.valueOf(ids[2])))
.and(eq("seq_num", Integer.valueOf(ids[3])))
);
results = session.execute(select().from("ep_nfs"));
for (Row row : results) {
String id = row.getString("nf_id");
代码示例来源:origin: kaaproject/kaa
@Override
public List<CassandraEndpointUserConfiguration> findByUserId(String userId) {
LOG.debug("Searching for user specific configurations by user id {}", userId);
Select.Where select = select().from(getColumnFamilyName())
.where(eq(EP_USER_CONF_USER_ID_PROPERTY, userId));
List<CassandraEndpointUserConfiguration> configurationList = findListByStatement(select);
if (LOG.isTraceEnabled()) {
LOG.trace("[{}] Search result: {}.",
userId, Arrays.toString(configurationList.toArray()));
} else {
LOG.debug("[{}] Search result: {}.",
userId, configurationList.size());
}
return configurationList;
}
代码示例来源:origin: kaaproject/kaa
@Override
public List<CassandraEndpointProfile> findByEndpointUserId(String endpointUserId) {
LOG.debug("Try to find endpoint profiles by endpoint user id [{}]", endpointUserId);
List<CassandraEndpointProfile> profileList = Collections.emptyList();
CassandraEndpointUser endpointUser = endpointUserDao.findById(endpointUserId);
if (endpointUser != null) {
List<String> ids = endpointUser.getEndpointIds();
if (ids != null && !ids.isEmpty()) {
Statement select = select().from(getColumnFamilyName())
.where(in(EP_EP_KEY_HASH_PROPERTY, convertStringIds(ids)));
LOG.trace("Execute statements {}", select);
profileList = findListByStatement(select);
}
}
if (LOG.isTraceEnabled()) {
LOG.trace("Found endpoint profiles {}", Arrays.toString(profileList.toArray()));
}
return profileList;
}
代码示例来源:origin: prestodb/presto
public static Select selectCountAllFrom(CassandraTableHandle tableHandle)
{
String schema = validSchemaName(tableHandle.getSchemaName());
String table = validTableName(tableHandle.getTableName());
return QueryBuilder.select().countAll().from(schema, table);
}
代码示例来源:origin: kaaproject/kaa
ResultSet results = session.execute(select().from(tableName));
for (Row row : results) {
String userId = row.getString("user_id");
update(tableName)
.with(set("body", bodyEncoded))
.where(eq("user_id", userId))
.and(eq("app_token", appToken))
.and(eq("schema_version", schemaVersion))
);
代码示例来源:origin: kaaproject/kaa
@Override
public CassandraEndpointUser findByExternalIdAndTenantId(String externalId, String tenantId) {
LOG.debug("Try to find endpoint user by external id {} and tenant id {}",
externalId, tenantId);
Where where = select().from(getColumnFamilyName())
.where(eq(EP_USER_EXTERNAL_ID_PROPERTY, externalId))
.and(eq(EP_USER_TENANT_ID_PROPERTY, tenantId));
LOG.trace("Try to find endpoint user by cql select {}", where);
CassandraEndpointUser endpointUser = findOneByStatement(where);
LOG.trace("Found {} endpoint user", endpointUser);
return endpointUser;
}
代码示例来源:origin: apache/usergrid
@Override
public Iterator<UniqueValue> getAllUniqueFields( final ApplicationScope collectionScope, final Id entityId ) {
Preconditions.checkNotNull( collectionScope, "collectionScope is required" );
Preconditions.checkNotNull( entityId, "entity id is required" );
Clause inKey = QueryBuilder.in("key", getLogPartitionKey(collectionScope.getApplication(), entityId));
Statement statement = QueryBuilder.select().all().from(TABLE_UNIQUE_VALUES_LOG)
.where(inKey);
return new AllUniqueFieldsIterator(session, statement, entityId);
}
代码示例来源:origin: brianfrankcooper/YCSB
selectBuilder = QueryBuilder.select().all();
} else {
selectBuilder = QueryBuilder.select();
for (String col : fields) {
((Select.Selection) selectBuilder).column(col);
Select selectStmt = selectBuilder.from(table);
代码示例来源:origin: Netflix/conductor
/**
* @return cql query statement to retrieve the workflow_id for a particular task_id from the "task_lookup" table
*/
public String getSelectTaskFromLookupTableStatement() {
return QueryBuilder.select(WORKFLOW_ID_KEY)
.from(keyspace, TABLE_TASK_LOOKUP)
.where(eq(TASK_ID_KEY, bindMarker()))
.getQueryString();
}
代码示例来源:origin: apache/usergrid
private ByteBuffer getValueCQL( MapScope scope, String key, final ConsistencyLevel consistencyLevel ) {
Clause in = QueryBuilder.in("key", getMapEntryPartitionKey(scope, key) );
Statement statement = QueryBuilder.select().all().from(MAP_ENTRIES_TABLE)
.where(in)
.setConsistencyLevel(consistencyLevel);
ResultSet resultSet = session.execute(statement);
com.datastax.driver.core.Row row = resultSet.one();
return row != null ? row.getBytes("value") : null;
}
代码示例来源:origin: kaaproject/kaa
/**
* Get all entities from cassandra database.
* @return <code>List</code> of entities
*/
public List<T> find() {
LOG.debug("Get all entities from column family {}", getColumnFamilyName());
return findListByStatement(
QueryBuilder.select()
.all().from(getColumnFamilyName())
.setConsistencyLevel(getReadConsistencyLevel()));
}
代码示例来源:origin: kaaproject/kaa
@Override
public boolean checkSdkToken(String sdkToken) {
LOG.debug("Checking for endpoint profiles with SDK token {}", sdkToken);
Statement query = select().from(EP_BY_SDK_TOKEN_COLUMN_FAMILY_NAME)
.where(eq(EP_BY_SDK_TOKEN_SDK_TOKEN_PROPERTY, sdkToken));
return execute(query).one() != null;
}
代码示例来源:origin: apache/usergrid
@Override
public MapKeyResults getAllKeys(final MapScope scope, final String cursor, final int limit ){
final int[] buckets = BUCKET_LOCATOR.getAllBuckets( scope.getName() );
final List<ByteBuffer> partitionKeys = new ArrayList<>(NUM_BUCKETS.length);
for (int bucket : buckets) {
partitionKeys.add(getMapKeyPartitionKey(scope, bucket));
}
Clause in = QueryBuilder.in("key", partitionKeys);
Statement statement;
if( isBlank(cursor) ){
statement = QueryBuilder.select().all().from(MAP_KEYS_TABLE)
.where(in)
.setFetchSize(limit);
}else{
statement = QueryBuilder.select().all().from(MAP_KEYS_TABLE)
.where(in)
.setFetchSize(limit)
.setPagingState(PagingState.fromString(cursor));
}
ResultSet resultSet = session.execute(statement);
PagingState pagingState = resultSet.getExecutionInfo().getPagingState();
final List<String> keys = new ArrayList<>();
Iterator<Row> resultIterator = resultSet.iterator();
int size = 0;
while( resultIterator.hasNext() && size < limit){
size++;
keys.add((String)DataType.text().deserialize(resultIterator.next().getBytes("column1"), ProtocolVersion.NEWEST_SUPPORTED));
}
return new MapKeyResults(pagingState != null ? pagingState.toString() : null, keys);
}
代码示例来源:origin: apache/usergrid
@Override
public Result<TransferLog> getAllTransferLogs(PagingState pagingState, int fetchSize ) {
Statement query = QueryBuilder.select().all().from(TABLE_TRANSFER_LOG);
代码示例来源:origin: kaaproject/kaa
@Override
public Optional<CassandraCredentials> find(String applicationId, String credentialsId) {
LOG.debug("Searching credential by applicationID[{}] and credentialsID[{}]",
applicationId, credentialsId);
Select.Where query = select().from(getColumnFamilyName())
.where(eq(CREDENTIALS_APPLICATION_ID_PROPERTY, applicationId))
.and(eq(CREDENTIALS_ID_PROPERTY, credentialsId));
return Optional.ofNullable(this.findOneByStatement(query));
}
代码示例来源:origin: apache/usergrid
field.getTypeName().toString(), field.getName(), field.getValue()) );
final Statement statement = QueryBuilder.select().all().from(TABLE_UNIQUE_VALUES)
.where(inKey)
.setConsistencyLevel(consistencyLevel);
代码示例来源:origin: hugegraph/hugegraph
protected static Select cloneSelect(Select select, String table) {
// NOTE: there is no Select.clone(), just use copy instead
return CopyUtil.copy(select, QueryBuilder.select().from(table));
}
内容来源于网络,如有侵权,请联系作者删除!