com.datastax.driver.core.querybuilder.QueryBuilder.update()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(191)

本文整理了Java中com.datastax.driver.core.querybuilder.QueryBuilder.update方法的一些代码示例,展示了QueryBuilder.update的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryBuilder.update方法的具体详情如下:
包路径:com.datastax.driver.core.querybuilder.QueryBuilder
类名称:QueryBuilder
方法名:update

QueryBuilder.update介绍

[英]Start building a new UPDATE query.
[中]开始构建新的更新查询。

代码示例

代码示例来源:origin: kaaproject/kaa

@Override
public String generateAccessToken(String externalId, String tenantId) {
 LOG.debug("Generating access token for endpoint user with external id {} and tenant id {}",
   externalId, tenantId);
 String accessToken = UUID.randomUUID().toString();
 Update.Where query = update(getColumnFamilyName())
   .with(set(CassandraModelConstants.EP_USER_ACCESS_TOKEN_PROPERTY, accessToken))
   .where(eq(EP_USER_EXTERNAL_ID_PROPERTY, externalId))
   .and(eq(EP_USER_TENANT_ID_PROPERTY, tenantId));
 execute(query);
 LOG.trace("Generated access token {} for endpoint user by query {}", accessToken, query);
 return accessToken;
}

代码示例来源:origin: brianfrankcooper/YCSB

Update updateStmt = QueryBuilder.update(table);

代码示例来源:origin: kaaproject/kaa

@Override
public CassandraEndpointProfile updateServerProfile(byte[] keyHash,
                          int version,
                          String serverProfile) {
 LOG.debug("Updating server profile for endpoint profile with key hash [{}] "
     + "with schema version [{}]",
   Utils.encodeHexString(keyHash), version);
 ByteBuffer key = ByteBuffer.wrap(keyHash);
 Statement update = QueryBuilder.update(EP_COLUMN_FAMILY_NAME)
   .with(set(EP_SERVER_PROFILE_PROPERTY, serverProfile))
   .and(set(EP_SERVER_PROFILE_VERSION_PROPERTY, version))
   .where(eq(EP_EP_KEY_HASH_PROPERTY, key));
 execute(update, ConsistencyLevel.ALL);
 return findById(key);
}

代码示例来源:origin: apache/usergrid

private void decrementCounterInStorage( String queueName, DatabaseQueueMessage.Type type, long decrement ) {
  Statement update = QueryBuilder.update( TABLE_MESSAGE_COUNTERS )
    .where( QueryBuilder.eq(   COLUMN_QUEUE_NAME, queueName ) )
    .and(   QueryBuilder.eq(   COLUMN_MESSAGE_TYPE, type.toString() ) )
    .with(  QueryBuilder.decr( COLUMN_COUNTER_VALUE, decrement ) );
  cassandraClient.getQueueMessageSession().execute( update );
}

代码示例来源:origin: apache/usergrid

private void incrementCounterInStorage( String queueName, DatabaseQueueMessage.Type type, long increment ) {
  Statement update = QueryBuilder.update( TABLE_MESSAGE_COUNTERS )
      .where( QueryBuilder.eq(   COLUMN_QUEUE_NAME, queueName ) )
      .and(   QueryBuilder.eq(   COLUMN_MESSAGE_TYPE, type.toString() ) )
      .with(  QueryBuilder.incr( COLUMN_COUNTER_VALUE, increment ) );
  cassandraClient.getQueueMessageSession().execute( update );
}

代码示例来源:origin: Netflix/conductor

/**
 * @return cql query statement to add a new task_id to workflow_id mapping to the "task_lookup" table
 */
public String getUpdateTaskLookupStatement() {
  return QueryBuilder.update(keyspace, TABLE_TASK_LOOKUP)
      .with(set(WORKFLOW_ID_KEY, bindMarker()))
      .where(eq(TASK_ID_KEY, bindMarker()))
      .getQueryString();
}

代码示例来源:origin: apache/usergrid

void incrementCounterInStorage( String queueName, Shard.Type type, long shardId, long increment ) {
  Statement update = QueryBuilder.update( TABLE_COUNTERS )
      .where( QueryBuilder.eq(   COLUMN_QUEUE_NAME, queueName ) )
      .and(   QueryBuilder.eq(   COLUMN_SHARD_TYPE, type.toString() ) )
      .and(   QueryBuilder.eq(   COLUMN_SHARD_ID, shardId ) )
      .with(  QueryBuilder.incr( COLUMN_COUNTER_VALUE, increment ) );
  cassandraClient.getQueueMessageSession().execute( update );
}

代码示例来源:origin: kaaproject/kaa

@Override
public Optional<CassandraCredentials> updateStatus(String applicationId,
                          String credentialsId,
                          CredentialsStatus status) {
 LOG.debug("Updating credentials status with applicationID[{}] "
     + "and credentialsID[{}] to STATUS[{}]",
   applicationId, credentialsId, status.toString());
 Update.Assignments query = update(getColumnFamilyName())
   .where(eq(CREDENTIALS_ID_PROPERTY, credentialsId))
   .and(eq(CREDENTIALS_APPLICATION_ID_PROPERTY, applicationId))
   .with(set(CREDENTIALS_STATUS_PROPERTY, status.toString()));
 execute(query);
 return find(applicationId, credentialsId);
}

代码示例来源:origin: apache/usergrid

@Override
public void resetCounter(String queueName, DatabaseQueueMessage.Type type) {
  // this sucks: "You cannot index, delete, or re-add a counter column"
  // https://docs.datastax.com/en/cql/3.1/cql/cql_using/use_counter_t.html
  // so instead we decrement or increment the counter to zero
  // get value first, before resetting in memory counter
  long value = getCounterValue( queueName, type );
  String key = buildKey( queueName, type );
  InMemoryCount inMemoryCount = inMemoryCounters.get( key );
  if ( inMemoryCount != null ) {
    inMemoryCount.reset();
  }
  if ( value < 0 ) {
    Statement update = QueryBuilder.update( TABLE_MESSAGE_COUNTERS )
      .where( QueryBuilder.eq(   COLUMN_QUEUE_NAME, queueName ) )
      .and(   QueryBuilder.eq(   COLUMN_MESSAGE_TYPE, type.toString() ) )
      .with(  QueryBuilder.incr( COLUMN_COUNTER_VALUE, -1 * value ) ); // incr must be positive
    cassandraClient.getQueueMessageSession().execute( update );
  } else {
    Statement update = QueryBuilder.update( TABLE_MESSAGE_COUNTERS )
      .where( QueryBuilder.eq(   COLUMN_QUEUE_NAME, queueName ) )
      .and(   QueryBuilder.eq(   COLUMN_MESSAGE_TYPE, type.toString() ) )
      .with(  QueryBuilder.decr( COLUMN_COUNTER_VALUE, value ) );
    cassandraClient.getQueueMessageSession().execute( update );
  }
}

代码示例来源:origin: apache/usergrid

batchStatement.add(
  QueryBuilder
    .update(TOKENS_TABLE)
    .with(setInactiveTime)
    .where(inKey).and(whereTokenInactive)
.update(TOKENS_TABLE)
.with(setAccessedTime)
.where(inKey).and(whereTokenAccessed)

代码示例来源:origin: Netflix/conductor

/**
 * @return cql query statement to update the total_tasks in a shard for a workflow in the "workflows" table
 */
public String getUpdateTotalTasksStatement() {
  return QueryBuilder.update(keyspace, TABLE_WORKFLOWS)
      .with(set(TOTAL_TASKS_KEY, bindMarker()))
      .where(eq(WORKFLOW_ID_KEY, bindMarker()))
      .and(eq(SHARD_ID_KEY, bindMarker()))
      .getQueryString();
}

代码示例来源:origin: kaaproject/kaa

update("notification")
  .with(set("schema_id", String.valueOf(schemaId + idShift)))
  .where(eq("topic_id", ids[0]))
update("ep_nfs")
  .with(set("schema_id", String.valueOf(schemaId + idShift)))
  .where(eq("ep_key_hash", epKeyHash))

代码示例来源:origin: Netflix/conductor

/**
 * @return cql query statement to update the total_partitions for a workflow in the "workflows" table
 */
public String getUpdateTotalPartitionsStatement() {
  return QueryBuilder.update(keyspace, TABLE_WORKFLOWS)
      .with(set(TOTAL_PARTITIONS_KEY, bindMarker()))
      .and(set(TOTAL_TASKS_KEY, bindMarker()))
      .where(eq(WORKFLOW_ID_KEY, bindMarker()))
      .and(eq(SHARD_ID_KEY, 1))
      .getQueryString();
}

代码示例来源:origin: apache/usergrid

public void updateShardPointer(final Shard shard){
  Assignment assignment = QueryBuilder.set(COLUMN_POINTER, shard.getPointer());
  Clause queueNameClause = QueryBuilder.eq(COLUMN_QUEUE_NAME, shard.getQueueName());
  Clause regionClause = QueryBuilder.eq(COLUMN_REGION, shard.getRegion());
  Clause activeClause = QueryBuilder.eq(COLUMN_ACTIVE, 1);
  Clause shardIdClause = QueryBuilder.eq(COLUMN_SHARD_ID, shard.getShardId());
  Statement update = QueryBuilder.update(getTableName(shard.getType()))
      .with(assignment)
      .where(queueNameClause)
      .and(regionClause)
      .and(activeClause)
      .and(shardIdClause);
  cassandraClient.getQueueMessageSession().execute(update);
}

代码示例来源:origin: Netflix/conductor

/**
 * @return cql query statement to update a workflow in the "workflows" table
 */
public String getUpdateWorkflowStatement() {
  return QueryBuilder.update(keyspace, TABLE_WORKFLOWS)
      .with(set(PAYLOAD_KEY, bindMarker()))
      .where(eq(WORKFLOW_ID_KEY, bindMarker()))
      .and(eq(SHARD_ID_KEY, 1))
      .and(eq(ENTITY_KEY, ENTITY_TYPE_WORKFLOW))
      .and(eq(TASK_ID_KEY, ""))
      .getQueryString();
}

代码示例来源:origin: apache/usergrid

Statement update = QueryBuilder.update( TABLE_COUNTERS )
  .where( QueryBuilder.eq(   COLUMN_QUEUE_NAME, queueName ) )
  .and(   QueryBuilder.eq(   COLUMN_SHARD_TYPE, type.toString() ) )
Statement update = QueryBuilder.update( TABLE_COUNTERS )
  .where( QueryBuilder.eq(   COLUMN_QUEUE_NAME, queueName ) )
  .and(   QueryBuilder.eq(   COLUMN_SHARD_TYPE, type.toString() ) )

代码示例来源:origin: kaaproject/kaa

update(tableName)
  .with(set("body", bodyEncoded))
  .where(eq("user_id", userId))

代码示例来源:origin: kaaproject/kaa

private T updateLocked(T entity) {
 long version = (entity.getVersion() == null) ? 0L : entity.getVersion();
 Assignments assigns = update(getColumnFamilyName())
   .onlyIf(eq(OPT_LOCK, version))
   .with(set(OPT_LOCK, version + 1));

代码示例来源:origin: hugegraph/hugegraph

public void increaseCounter(CassandraSessionPool.Session session,
                HugeType type, long increment) {
    Update update = QueryBuilder.update(TABLE);
    update.with(QueryBuilder.incr(formatKey(HugeKeys.ID), increment));
    update.where(formatEQ(HugeKeys.SCHEMA_TYPE, type.name()));
    session.execute(update);
  }
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

@SuppressWarnings("deprecation")
 @Test(groups = "short")
 public void should_handle_collections_of_tuples() {
  String query;
  BuiltStatement statement;
  query = "UPDATE foo SET l=[(1,2)] WHERE k=1;";
  TupleType tupleType = cluster().getMetadata().newTupleType(cint(), cint());
  List<TupleValue> list = ImmutableList.of(tupleType.newValue(1, 2));
  statement = update("foo").with(set("l", list)).where(eq("k", 1));
  assertThat(statement.toString()).isEqualTo(query);
 }
}

相关文章

微信公众号

最新文章

更多