本文整理了Java中com.datastax.driver.core.querybuilder.QueryBuilder.eq
方法的一些代码示例,展示了QueryBuilder.eq
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryBuilder.eq
方法的具体详情如下:
包路径:com.datastax.driver.core.querybuilder.QueryBuilder
类名称:QueryBuilder
方法名:eq
[英]Creates an "equal" WHERE clause for a group of clustering columns.
For instance, eq(Arrays.asList("a", "b"), Arrays.asList(2, "test")) will generate the CQL WHERE clause (a, b) = (2, 'test') .
Please note that this variant is only supported starting with Cassandra 2.0.6.
[中]为一组集群列创建一个“equal”WHERE子句。
例如,eq(Arrays.asList(“a”、“b”)、数组。asList(2,“测试”)将生成CQL WHERE子句(a,b)=(2,“测试”)。
请注意,仅从Cassandra 2.0.6开始支持此变体。
代码示例来源:origin: Netflix/conductor
/**
* @return cql query statement to retrieve a workflow (without its tasks) from the "workflows" table
*/
public String getSelectWorkflowStatement() {
return QueryBuilder.select(PAYLOAD_KEY)
.from(keyspace, TABLE_WORKFLOWS)
.where(eq(WORKFLOW_ID_KEY, bindMarker()))
.and(eq(SHARD_ID_KEY, 1))
.and(eq(ENTITY_KEY, ENTITY_TYPE_WORKFLOW))
.getQueryString();
}
代码示例来源: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");
update("ep_nfs")
.with(set("schema_id", String.valueOf(schemaId + idShift)))
.where(eq("ep_key_hash", epKeyHash))
.and(eq("last_mod_time", lastModTime))
);
代码示例来源: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: 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: Netflix/conductor
/**
* @return cql query statement to retrieve the total_tasks and total_partitions for a workflow from the "workflows" table
*/
public String getSelectTotalStatement() {
return QueryBuilder.select(TOTAL_TASKS_KEY, TOTAL_PARTITIONS_KEY)
.from(keyspace, TABLE_WORKFLOWS)
.where(eq(WORKFLOW_ID_KEY, bindMarker()))
.and(eq(SHARD_ID_KEY, 1))
.getQueryString();
}
代码示例来源: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: kaaproject/kaa
@Override
public CassandraEndpointSpecificConfiguration findByEndpointKeyHashAndConfigurationVersion(byte[] endpointKeyHash, int configurationVersion) {
LOG.debug("Try to find endpoint specific configuration by endpointKeyHash {} and configurationVersion {}", endpointKeyHash, configurationVersion);
Select.Where where = select().from(getColumnFamilyName())
.where(eq(EPS_CONFIGURATION_KEY_HASH_PROPERTY, getByteBuffer(endpointKeyHash)))
.and(eq(EP_CONFIGURATION_VERSION_PROPERTY, configurationVersion));
LOG.trace("Try to find endpoint specific configuration by cql select {}", where);
CassandraEndpointSpecificConfiguration configuration = findOneByStatement(where);
LOG.trace("Found {} endpoint specific configuration", configuration);
return configuration;
}
代码示例来源:origin: Netflix/conductor
/**
* @return cql query statement to retrieve a task from the "workflows" table
*/
public String getSelectTaskStatement() {
return QueryBuilder.select(PAYLOAD_KEY)
.from(keyspace, TABLE_WORKFLOWS)
.where(eq(WORKFLOW_ID_KEY, bindMarker()))
.and(eq(SHARD_ID_KEY, bindMarker()))
.and(eq(ENTITY_KEY, ENTITY_TYPE_TASK))
.and(eq(TASK_ID_KEY, bindMarker()))
.getQueryString();
}
代码示例来源: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 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: 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 List<UUID> getTokensForPrincipal(ByteBuffer principalKeyBuffer){
Preconditions.checkNotNull(principalKeyBuffer, "principal key bytebuffer cannot be null");
Clause inPrincipal = QueryBuilder.eq("key", principalKeyBuffer);
Statement statement = QueryBuilder
.select()
.column("column1")
.from(PRINCIPAL_TOKENS_TABLE)
.where(inPrincipal);
final List<Row> rows = session.execute(statement).all();
final List<UUID> tokenUUIDs = new ArrayList<>(rows.size());
rows.forEach(row -> tokenUUIDs.add(row.getUUID("column1")));
logger.trace("getTokensForPrincipal, token UUIDs: {}", tokenUUIDs);
return tokenUUIDs;
}
代码示例来源: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: kaaproject/kaa
@Override
public CassandraEndpointUserConfiguration findByUserIdAndAppTokenAndSchemaVersion(
String userId,
String appToken,
Integer schemaVersion
) {
LOG.debug("Searching for user specific configuration by user id {}, "
+ "application token {} and schema version {}",
userId, appToken, schemaVersion);
Select.Where select = select().from(getColumnFamilyName())
.where(eq(EP_USER_CONF_USER_ID_PROPERTY, userId))
.and(eq(EP_USER_CONF_APP_TOKEN_PROPERTY, appToken))
.and(eq(EP_USER_CONF_VERSION_PROPERTY, schemaVersion));
CassandraEndpointUserConfiguration userConfiguration = findOneByStatement(select);
if (LOG.isTraceEnabled()) {
LOG.debug("[{},{},{}] Search result: {}.",
userId, appToken, schemaVersion, userConfiguration);
} else {
LOG.debug("[{},{},{}] Search result: {}.",
userId, appToken, schemaVersion, userConfiguration != null);
}
return userConfiguration;
}
代码示例来源:origin: kaaproject/kaa
@Override
public Optional<CassandraEndpointRegistration> findByEndpointId(String endpointId) {
LOG.debug("Searching for endpoint registration by endpoint ID [{}]", endpointId);
Optional<String> credentialsId = this.byEndpointId.getCredentialsIdByEndpointId(
endpointId);
if (credentialsId.isPresent()) {
LOG.debug("[{}] Endpoint credentials ID by endpoint ID: {}",
endpointId, credentialsId.get());
Clause clause = QueryBuilder.eq(
CassandraModelConstants.EP_REGISTRATION_CREDENTIALS_ID_PROPERTY,
credentialsId.get());
Statement statement = QueryBuilder.select().from(this.getColumnFamilyName())
.where(clause);
return Optional.ofNullable(this.findOneByStatement(statement));
} else {
LOG.debug("[{}] No credentials ID found by endpoint ID: {}", endpointId);
return Optional.empty();
}
}
代码示例来源:origin: kaaproject/kaa
@Override
public CassandraEndpointNotification findById(String id) {
LOG.debug("Try to find endpoint notifications by id {}", id);
CassandraEndpointNotification key = new CassandraEndpointNotification(id);
Select.Where where = select().from(getColumnFamilyName())
.where(eq(ET_NF_ENDPOINT_KEY_HASH_PROPERTY, key.getEndpointKeyHash()))
.and(eq(ET_NF_LAST_MOD_TIME_PROPERTY, key.getLastModifyTime()));
LOG.debug("[{}] Execute query {}:", id, where);
CassandraEndpointNotification endpointNotification = findOneByStatement(where);
LOG.trace("Found endpoint notification {} by id {}:", endpointNotification, id);
return endpointNotification;
}
代码示例来源:origin: prestodb/presto
@Override
public List<SizeEstimate> getSizeEstimates(String keyspaceName, String tableName)
{
checkSizeEstimatesTableExist();
Statement statement = select("range_start", "range_end", "mean_partition_size", "partitions_count")
.from(SYSTEM, SIZE_ESTIMATES)
.where(eq("keyspace_name", keyspaceName))
.and(eq("table_name", tableName));
ResultSet result = executeWithSession(session -> session.execute(statement));
ImmutableList.Builder<SizeEstimate> estimates = ImmutableList.builder();
for (Row row : result.all()) {
SizeEstimate estimate = new SizeEstimate(
row.getString("range_start"),
row.getString("range_end"),
row.getLong("mean_partition_size"),
row.getLong("partitions_count"));
estimates.add(estimate);
}
return estimates.build();
}
代码示例来源:origin: kaaproject/kaa
@Override
public List<CassandraEndpointNotification> findNotificationsByKeyHash(byte[] keyHash) {
LOG.debug("Try to find endpoint notifications by endpoint key hash {}", Utils.encodeHexString(keyHash));
List<CassandraEndpointNotification> cassandraEndpointNotifications =
Collections.emptyList();
if (keyHash != null) {
Select.Where where = select().from(getColumnFamilyName())
.where(eq(ET_NF_ENDPOINT_KEY_HASH_PROPERTY, getByteBuffer(keyHash)));
LOG.debug("Execute query {}:", where);
cassandraEndpointNotifications = findListByStatement(where);
}
return cassandraEndpointNotifications;
}
代码示例来源:origin: Netflix/conductor
/**
* @return cql query statement to retrieve a workflow with its tasks from the "workflows" table
*/
public String getSelectWorkflowWithTasksStatement() {
return QueryBuilder.select()
.all()
.from(keyspace, TABLE_WORKFLOWS)
.where(eq(WORKFLOW_ID_KEY, bindMarker()))
.and(eq(SHARD_ID_KEY, bindMarker()))
.getQueryString();
}
代码示例来源:origin: jooby-project/jooby
private static String selectSQL(final String table) {
return select().from(table).where(eq(ID, raw("?"))).getQueryString();
}
内容来源于网络,如有侵权,请联系作者删除!