没有足够的字节来读取组件0的值 - Hector Composite列读取

时间:2013-06-18 10:16:45

标签: cassandra runtime-error composite hector

使用hector api从复合列读取时遇到问题。

我的专栏系列:

create column family step_wise_stats_cc with key_validation_class = 'CompositeType(UTF8Type, UTF8Type)' and comparator = UTF8Type and default_validation_class = UTF8Type;

数据: 行键:{TYPE-1,SUB-TYPE-1}
列:名1:VALUE1

我这样查询:

Cluster cluster = HFactory.getOrCreateCluster("cls1", "localhost:9160");;
Keyspace keyspace = HFactory.createKeyspace("ks1",cluster);;
Serializer se = StringSerializer.get();

Composite start = new Composite();
start.addComponent(0, "TYPE-1", ComponentEquality.EQUAL);
start.addComponent(1, "SUB-TYPE-1", ComponentEquality.EQUAL);
Composite end = new Composite();
end.addComponent(0, "TYPE-1", ComponentEquality.GREATER_THAN_EQUAL);
start.addComponent(1, "SUB-TYPE-1", ComponentEquality.GREATER_THAN_EQUAL);

SliceQuery<String, Composite, String> sliceQuery = HFactory.createSliceQuery(keyspace, se, CompositeSerializer.get(), se);;
sliceQuery.setColumnFamily("cf1");
sliceQuery.setKey("TYPE-1");
sliceQuery.setRange(start, start, false, 999);

QueryResult<ColumnSlice<Composite, String>> qr = sliceQuery.execute();

但要低于例外: me.prettyprint.hector.api.exceptions.HInvalidRequestException:InvalidRequestExc eption(原因:没有足够的字节来读取组件0的值)

任何帮助?

1 个答案:

答案 0 :(得分:0)

您的行键是CompositeType,但您将行键设置为“TYPE-1”。这就是Cassandra给你一个错误的原因。

切片查询返回给定行的列范围。您需要为行键指定复合,或者通过将子类型移动到列并使列成为复合来更改数据模型。