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

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

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

QueryBuilder.add介绍

[英]Adds a value to a set column.

This will generate: name = name + {value}}.
[中]将值添加到集合列。
这将生成:name=name+{value}。

代码示例

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

@Test(groups = "unit", expectedExceptions = InvalidQueryException.class)
public void should_not_allow_bind_marker_for_add() {
 // This generates the query "UPDATE foo SET s = s + {?} WHERE k = 1", which is invalid in
 // Cassandra
 update("foo").with(add("s", bindMarker())).where(eq("k", 1));
}

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

update("foo")
  .with(discardAll("b", Arrays.asList(1, 2, 3)))
  .and(add("c", 1))
  .and(
    addAll(

代码示例来源:origin: valchkou/cassandra-driver-mapping

public static BoundStatement prepareAppendItemToCollection(Object id, Class<?> clazz, String propertyName, Object item, WriteOptions options, String keyspace, Session session) {
  EntityTypeMetadata emeta = EntityTypeParser.getEntityMetadata(clazz);
  EntityFieldMetaData fmeta = emeta.getFieldMetadata(propertyName);
  Update update = QueryBuilder.update(keyspace, emeta.getTableName());
  if (item instanceof Set<?> && fmeta.getType() == Set.class) {
    Set<?> set = (Set<?>) item;
    if (set.size() == 0)
      return null;
    update.with(QueryBuilder.addAll(fmeta.getColumnName(), set));
  } else if (item instanceof List<?> && fmeta.getType() == List.class) {
    List<?> list = (List<?>) item;
    if (list.size() == 0)
      return null;
    update.with(QueryBuilder.appendAll(fmeta.getColumnName(), list));
  } else if (item instanceof Map<?, ?>) {
    Map<?, ?> map = (Map<?, ?>) item;
    if (map.size() == 0)
      return null;
    update.with(QueryBuilder.putAll(fmeta.getColumnName(), map));
  } else if (fmeta.getType() == Set.class) {
    update.with(QueryBuilder.add(fmeta.getColumnName(), item));
  } else if (fmeta.getType() == List.class) {
    update.with(QueryBuilder.append(fmeta.getColumnName(), item));
  }
  applyOptions(options, update, null);
  return prepareUpdate(id, emeta, update, session);
}

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

public void insert(CassandraSessionPool.Session session,
          CassandraBackendEntry.Row entry) {
  Update update = QueryBuilder.update(this.table);
  update.with(QueryBuilder.add(ELEMENT_IDS, entry.id().asLong()));
  update.where(CassandraTable.formatEQ(HugeKeys.NAME,
                     entry.column(HugeKeys.NAME)));
  session.add(update);
}

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

update("foo")
  .with(discardAll("b", Arrays.asList(1, 2, 3)))
  .and(add("c", 1))
  .and(
    addAll(

代码示例来源:origin: org.apache.james/apache-james-mailbox-cassandra

private Assignments addUserFlagsToQuery(Set<String> userFlags, Assignments updateQuery) {
  userFlags.forEach(userFlag -> updateQuery.and(add(USER_FLAGS, userFlag)));
  return updateQuery;
}

代码示例来源:origin: otaviojava/Easy-Cassandra

@Override
public UpdateBuilder<T> addSet(String name, Object value) {
  update.with(QueryBuilder.add(classBean.toColumn(name), value));
  return this;
}
@Override

代码示例来源:origin: tech.aroma/aroma-data-operations

private Statement createStatementToAddDevice(String userId, MobileDevice mobileDevice)
{
  UUID userUuid = UUID.fromString(userId);
  String serializedDevice = serializeMobileDevice(mobileDevice);
  return QueryBuilder
    .update(UserPreferences.TABLE_NAME)
    .with(add(UserPreferences.SERIALIZED_DEVICES, serializedDevice))
    .where(eq(UserPreferences.USER_ID, userUuid));
}

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

private ImmutableList<BuiltStatement> idempotentBuiltStatements() {
 return ImmutableList.<BuiltStatement>of(
   update("foo").with(set("v", 1)).where(eq("k", 1)), // set simple value
   update("foo").with(add("s", 1)).where(eq("k", 1)), // add to set
   update("foo").with(put("m", "a", 1)).where(eq("k", 1)), // put in map
   // select statements should be idempotent even with function calls
   select().countAll().from("foo").where(eq("k", 1)),
   select().ttl("v").from("foo").where(eq("k", 1)),
   select().writeTime("v").from("foo").where(eq("k", 1)),
   select().fcall("token", "k").from("foo").where(eq("k", 1)));
}

代码示例来源:origin: dmart28/gcplot

private List<RegularStatement> addJvm(Identifier accId, String analyseId, UUID jvmUUID,
            String jvmName, VMVersion version, GarbageCollectorType type,
            String headers, MemoryDetails memoryDetails) {
  UUID uuid = UUID.fromString(analyseId);
  String jvmId = jvmUUID.toString();
  List<RegularStatement> batch = new ArrayList<>();
  batch.add(updateTable(accId, uuid).with(add("jvm_ids", jvmId)));
  batch.add(updateTable(accId, uuid).with(put("jvm_names", jvmId, jvmName)));
  batch.add(updateTable(accId, uuid).with(put("jvm_headers", jvmId, headers)));
  batch.add(updateTable(accId, uuid).with(put("jvm_versions", jvmId, version.type())));
  batch.add(updateTable(accId, uuid).with(put("jvm_gc_types", jvmId, type.type())));
  if (memoryDetails != null) {
    insertMemoryDetails(accId, jvmId, memoryDetails, uuid, batch);
  }
  return batch;
}

代码示例来源:origin: com.baidu.hugegraph/hugegraph-scylladb

public void insert(CassandraSessionPool.Session session,
          CassandraBackendEntry.Row entry) {
  Update update = QueryBuilder.update(this.table);
  update.with(QueryBuilder.add(ELEMENT_IDS, entry.id().asLong()));
  update.where(CassandraTable.formatEQ(HugeKeys.NAME,
                     entry.column(HugeKeys.NAME)));
  session.add(update);
}

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

@Test(groups = "unit", expectedExceptions = InvalidQueryException.class)
public void should_not_allow_bind_marker_for_add() {
 // This generates the query "UPDATE foo SET s = s + {?} WHERE k = 1", which is invalid in
 // Cassandra
 update("foo").with(add("s", bindMarker())).where(eq("k", 1));
}

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

private ImmutableList<BuiltStatement> idempotentBuiltStatements() {
 return ImmutableList.<BuiltStatement>of(
   update("foo").with(set("v", 1)).where(eq("k", 1)), // set simple value
   update("foo").with(add("s", 1)).where(eq("k", 1)), // add to set
   update("foo").with(put("m", "a", 1)).where(eq("k", 1)), // put in map
   // select statements should be idempotent even with function calls
   select().countAll().from("foo").where(eq("k", 1)),
   select().ttl("v").from("foo").where(eq("k", 1)),
   select().writeTime("v").from("foo").where(eq("k", 1)),
   select().fcall("token", "k").from("foo").where(eq("k", 1)));
}

相关文章

微信公众号

最新文章

更多