任何人都可以使用cassandra的hector api来帮助知道如何使用特定列值更新行。
,相当于
UPDATE table_name SET value =“”其中column_name = column_value;
答案 0 :(得分:1)
Cassandra中的更新可能只能通过主键完成。
(更一般地说,我建议在https://github.com/datastax/java-driver使用本地CQL驱动程序而不是半过时的Hector。)
答案 1 :(得分:0)
StringSerializer ss = StringSerializer.get();
String keyspaceName = "Test_Keyspace";
Cluster cluster = HFactory.getOrCreateCluster("TestCluster", new CassandraHostConfigurator("localhost:9160"));
Keyspace ksp = HFactory.createKeyspace(keyspaceName, cluster);
// UPDATE =============================
ColumnFamilyTemplate<String, String> template = new ThriftColumnFamilyTemplate<String, String>(ksp,"Standard1",ss,ss);
ColumnFamilyUpdater<String, String> updater = template.createUpdater("jsmith");
updater.setString("first", "Devid");
ColumnFamilyUpdater<String, String> updater2 = template.createUpdater("ksmith");
updater2.setString("first", "Kohli");
updater2.setString("middle", "Virat");
try {
template.update(updater);
template.update(updater2);
RangeSlicesQuery<String, String, String> rangeSlicesQuery3 = HFactory.createRangeSlicesQuery(ksp,ss,ss,ss);
rangeSlicesQuery3.setColumnFamily("Standard1");
rangeSlicesQuery3.setKeys("jsmith", "ksmith");
rangeSlicesQuery3.setRange("jsmith", null, false, 4);
QueryResult<OrderedRows<String, String, String>> result6 = rangeSlicesQuery3.execute();
// System.out.println(result6.get());
} catch (HectorException e) {
// do something ...
e.printStackTrace();
}