当前位置: 首页>>代码示例>>Java>>正文


Java Update.with方法代码示例

本文整理汇总了Java中com.datastax.driver.core.querybuilder.Update.with方法的典型用法代码示例。如果您正苦于以下问题:Java Update.with方法的具体用法?Java Update.with怎么用?Java Update.with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.datastax.driver.core.querybuilder.Update的用法示例。


在下文中一共展示了Update.with方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUpdateByQueryForAvro

import com.datastax.driver.core.querybuilder.Update; //导入方法依赖的package包/类
/**
 * This method returns the CQL Query for UpdateByQuery method
 * refer : http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlUpdate.html
 *
 * @param mapping        Cassandra mapping {@link CassandraMapping}
 * @param cassandraQuery Cassandra Query {@link CassandraQuery}
 * @param objects        field Objects list
 * @return CQL Query
 */
static String getUpdateByQueryForAvro(CassandraMapping mapping, Query cassandraQuery, List<Object> objects, Schema schema) {
  Update update = QueryBuilder.update(mapping.getKeySpace().getName(), mapping.getCoreName());
  Update.Assignments updateAssignments = null;
  if (cassandraQuery instanceof CassandraQuery) {
    String[] columnNames = getColumnNames(mapping, Arrays.asList(cassandraQuery.getFields()));
      for (String column : columnNames) {
        updateAssignments = update.with(QueryBuilder.set(column, "?"));
        Field field = mapping.getFieldFromColumnName(column);
        Object value = ((CassandraQuery) cassandraQuery).getUpdateFieldValue(field.getFieldName());
        try {
          Schema schemaField = schema.getField(field.getFieldName()).schema();
          objects.add(AvroCassandraUtils.getFieldValueFromAvroBean(schemaField, schemaField.getType(), value, field));
        } catch (NullPointerException e) {
          throw new RuntimeException(field + " field couldn't find in the class " + mapping.getPersistentClass() + ".");
        }
      }
  } else {
    throw new RuntimeException("Please use Cassandra Query object to invoke, UpdateByQuery method.");
  }
  return processQuery(cassandraQuery, updateAssignments, mapping, objects);
}
 
开发者ID:apache,项目名称:gora,代码行数:31,代码来源:CassandraQueryFactory.java

示例2: incrementEvent

import com.datastax.driver.core.querybuilder.Update; //导入方法依赖的package包/类
@Override
public void incrementEvent(long playerId, String event, long count) {
    Update updateStatement = QueryBuilder.update("player_event_counts");
    updateStatement.where(QueryBuilder.eq("player_id", playerId)).and(QueryBuilder.eq("event", event));
    updateStatement.with(QueryBuilder.incr("counter_value", count));
    session.execute(updateStatement);
}
 
开发者ID:rridgley1,项目名称:agon,代码行数:8,代码来源:CassandraPlayerRepository.java

示例3: getUpdateByQueryForNative

import com.datastax.driver.core.querybuilder.Update; //导入方法依赖的package包/类
/**
 * This method returns the CQL Query for UpdateByQuery method
 * refer : http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlUpdate.html
 *
 * @param mapping        Cassandra mapping {@link CassandraMapping}
 * @param cassandraQuery Cassandra Query {@link CassandraQuery}
 * @param objects        field Objects list
 * @return CQL Query
 */
static String getUpdateByQueryForNative(CassandraMapping mapping, Query cassandraQuery, List<Object> objects) {
  Update update = QueryBuilder.update(mapping.getKeySpace().getName(), mapping.getCoreName());
  Update.Assignments updateAssignments = null;
  if (cassandraQuery instanceof CassandraQuery) {
    String[] columnNames = getColumnNames(mapping, Arrays.asList(cassandraQuery.getFields()));
      for (String column : columnNames) {
        updateAssignments = update.with(QueryBuilder.set(column, "?"));
        objects.add(((CassandraQuery) cassandraQuery).getUpdateFieldValue(mapping.getFieldFromColumnName(column).getFieldName()));
      }
  } else {
    throw new RuntimeException("Please use Cassandra Query object to invoke, UpdateByQuery method.");
  }
  return processQuery(cassandraQuery, updateAssignments, mapping, objects);
}
 
开发者ID:apache,项目名称:gora,代码行数:24,代码来源:CassandraQueryFactory.java

示例4: diffMap

import com.datastax.driver.core.querybuilder.Update; //导入方法依赖的package包/类
private Collection<RegularStatement> diffMap(String table, String column, Clause whereClause, Map<?, ?> past,
        Map<?, ?> present) {

    List<RegularStatement> queries = Lists.newArrayList();

    Set<?> removed = Sets.newHashSet(past.keySet());
    removed.removeAll(present.keySet());

    if (!removed.isEmpty()) {
        Delete.Selection delete = QueryBuilder.delete();

        for (Object o : removed) {
            delete.mapElt(column, o);
        }

        queries.add(delete.from(table).where(whereClause));
    }

    Set<Entry<?, ?>> changed = Sets.<Entry<?, ?>> newHashSet(present.entrySet());
    changed.removeAll(past.entrySet());

    if (!changed.isEmpty()) {
        Update update = QueryBuilder.update(table);

        for (Entry<?, ?> entry : changed) {
            update.with(QueryBuilder.put(column, entry.getKey(), entry.getValue()));
        }

        queries.add(update.where(whereClause));
    }

    return queries;
}
 
开发者ID:eevans,项目名称:lucidity,代码行数:34,代码来源:CassandraEntityStore.java


注:本文中的com.datastax.driver.core.querybuilder.Update.with方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。