本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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;
}
示例5: CassandraUtilsUpdate
import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
public CassandraUtilsUpdate(CassandraUtils parent) {
this.parent = parent;
update = QueryBuilder.update(parent.getKeyspace(), parent.getTable());
}