我是 Cassandra 的新手,一直在玩 Hector API。正如您在下面的屏幕截图中看到的那样,我定义了一个列族,当我使用 CQL 返回行时,它将键和值作为十六进制值返回,如果可能,我想将其作为 UTF8 值返回。另外,我的列名似乎没有使用,而是使用“Column1”。我将在下面发布我的 col 家庭声明。
//Define ColumnFamily Def in Hector
ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(keyspaceName,"DP_ColumnFamily1",ComparatorType.UTF8TYPE);
//Add the column family to actual Cassandra Instance
cluster.addColumnFamily(cfDef,false);
stringSerializer = StringSerializer.get();
//The following example inserts a Column with the column name "Datapower_Device_Name" and the column value of "DPIPE0101" under the key "key1".
Mutator mutator = HFactory.createMutator(ksp, stringSerializer);
mutator.insert("key1", "DP_ColumnFamily1", HFactory.createStringColumn("Datapower_Device_Name", "DPIPE0101"));
cqlsh:test3> select * from "DP_ColumnFamily1";
key | column1 | value
------------+-----------------------+----------------------
0x6b657931 | Datapower_Device_Name | 0x445049504530313031
(1 rows)