@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); }
public static Selection select(List<CassandraColumnHandle> columns) { Selection selection = QueryBuilder.select(); for (CassandraColumnHandle column : columns) { selection.column(validColumnName(column.getName())); } return selection; }
@SuppressWarnings("rawtypes") public JSONArray select(String keyspace, String table, JSONArray columns, JSONObject where, ConsistencyLevel consistencyLevel) throws MemnonException, CharacterCodingException { Selection selection = QueryBuilder.select(); if (columns == null) { selection.all(); } else { Iterator columnIterator = columns.iterator(); while (columnIterator.hasNext()) { selection.column((String) columnIterator.next()); } } Select 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); } ResultSet results = executeStatement(keyspace, statement); return JsonMarshaller.marshallResultSet(results); }
public static Select from(Selection selection, CassandraTableHandle tableHandle) { String schema = validSchemaName(tableHandle.getSchemaName()); String table = validTableName(tableHandle.getTableName()); return selection.from(schema, table); }