當前位置: 首頁>>代碼示例>>Java>>正文


Java QueryBuilder.update方法代碼示例

本文整理匯總了Java中com.datastax.driver.core.querybuilder.QueryBuilder.update方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryBuilder.update方法的具體用法?Java QueryBuilder.update怎麽用?Java QueryBuilder.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.datastax.driver.core.querybuilder.QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder.update方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getUpdateByQueryForAvro

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的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.QueryBuilder; //導入方法依賴的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.QueryBuilder; //導入方法依賴的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.QueryBuilder; //導入方法依賴的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

示例5: CassandraUtilsUpdate

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
public CassandraUtilsUpdate(CassandraUtils parent) {
    this.parent = parent;
    update = QueryBuilder.update(parent.getKeyspace(), parent.getTable());
}
 
開發者ID:Stratio,項目名稱:stratio-cassandra-test,代碼行數:5,代碼來源:CassandraUtilsUpdate.java


注:本文中的com.datastax.driver.core.querybuilder.QueryBuilder.update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。