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


Java QueryBuilder.delete方法代碼示例

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


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

示例1: delete

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public void delete(String keyspace, String table, JSONArray columns,
		JSONObject where, ConsistencyLevel consistency_level)
		throws MemnonException, IOException {

	Delete.Selection selection = QueryBuilder.delete();
	if (columns == null) {
		selection.all();
	} else {
		Iterator columnIterator = columns.iterator();
		while (columnIterator.hasNext()) {
			selection.column((String) columnIterator.next());
		}
	}

	Delete statement = selection.from(table);
	Iterator whereIterator = where.entrySet().iterator();
	while (whereIterator.hasNext()) {
		Map.Entry pair = (Map.Entry) whereIterator.next();
		Clause clause = QueryBuilder.eq((String) pair.getKey(),
				pair.getValue());
		statement.where(clause);
	}

	executeStatement(keyspace, statement);
}
 
開發者ID:boneill42,項目名稱:memnon,代碼行數:27,代碼來源:CassandraStorage.java

示例2: 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


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