Cassandra 使用Asytanax对复合列执行查询时出现InvalidRequestException(原因:比较器的字节太多)

Cassandra 使用Asytanax对复合列执行查询时出现InvalidRequestException(原因:比较器的字节太多),cassandra,astyanax,Cassandra,Astyanax,我试图使用Astyanax 1.0.9从复合列中提取数据,结果得到“InvalidRequestException(原因:比较器的字节太多)” 这是我的简历: CREATE TABLE user_attributes ( user_id bigint, attr_name ascii, attr_value text, last_sync_timestamp bigint, last_sync_digest text, PRIMARY KEY (user_id, attr_name) ); 我

我试图使用Astyanax 1.0.9从复合列中提取数据,结果得到“InvalidRequestException(原因:比较器的字节太多)”

这是我的简历:

CREATE TABLE user_attributes (
user_id bigint,
attr_name ascii,
attr_value text,
last_sync_timestamp bigint,
last_sync_digest text,
PRIMARY KEY (user_id, attr_name)
);
我可以用CQL读取数据:

select * from user_attributes where user_id = 1 and attr_name = 'mock';
以下是我对复合栏的POJO:

public static class UserAttributeCassandraTuple implements Comparable {
    public @Component(ordinal = 0) String attrName;
    public @Component(ordinal = 1) String attrValue;
    public @Component(ordinal = 2) long lastSyncTimeStamp;
    public @Component(ordinal = 3) String lastSyncDigest;

    public int compareTo(Object o) { /* impl omitted here */ }
    public int hashCode() { /* impl omitted here */ }
    public boolean equals(Object o) { /* impl omitted here */ }
}
这是我的测试驱动程序:(keyspace是在junit@before中设置的,可以很好地用于非复合列)

我尝试用Long替换BigInteger,但得到了相同的错误

有什么建议我做错了什么吗

谢谢
Chuck

Astyanax是一个基于节俭的客户端,因此这不起作用:服务器端的节俭验证路径不支持CQL


我们在1.2.0中寻求更平滑的升级路径;否则,您需要使用CQL客户端访问CQL表,或者使用CLI为基于Thrift的客户端定义模式。

thx。我正在使用maven来构建我的spring项目,我是cassandra的新手。你能告诉我哪个java CQL客户端最好吗?我在谷歌上搜索了一下,看到了卡桑德拉·jdbc:和赫克托的CQL:。但不确定它们是否可以通过maven存储库使用。只是尝试了cassandra jdbc,它似乎不喜欢复合键,只返回行键列。此代码出错:`。。。字符串attrName=rs.getString(2);…`java.sql.SQLSyntaxErrorException:索引必须是一个正数,小于或等于返回列的计数:org.apache.cassandra.cql.jdbc.CassandraResultSet.checkIndex(CassandraResultSet.java:182)org.apache.cassandra.cql.jdbc.CassandraResultSet.getString(CassandraResultSet.java:762)以下是我在调试输出中看到的内容:rs CassandraResultSet(id=8426)。。。indexMap HashMap(id=1277)的值为:{user\u id=1}。。。类似的代码确实可以从一个不包含复合项的2列表中获得结果。有什么解决办法吗?@jbellis:这个错误似乎在1.2.0中得到了修复。我仍然可以在1.2.5中复制它
@Test
public void test_user_attributes() throws Exception {

    ColumnFamily<BigInteger, UserAttributeCassandraTuple> CF_USER_ATTR = new ColumnFamily<BigInteger, UserAttributeCassandraTuple>(
        "user_attributes", // Column Family Name
        BigIntegerSerializer.get(), // Key Serializer
        userAttributeSerializer); // Column Serializer

    // proto column for "mock"
    UserAttributeCassandraTuple mockColumn = new UserAttributeCassandraTuple();
    mockColumn.attrName = "mock";

    OperationResult<ColumnList<UserAttributeCassandraTuple>> result = keyspace.prepareQuery(CF_USER_ATTR)
    .getKey(BigInteger.valueOf(1))
    .withColumnSlice(mockColumn, mockColumn)
    .execute();
    ColumnList<UserAttributeCassandraTuple> columns = result.getResult();

    for (Column<UserAttributeCassandraTuple> c : columns) {
        System.out.println(c.getName() + "=" + c.getStringValue());
    }
}
com.netflix.astyanax.connectionpool.exceptions.BadRequestException: BadRequestException: [host=127.0.0.1(127.0.0.1):9160, latency=22(44), attempts=1] InvalidRequestException(why:Too many bytes for comparator)
at com.netflix.astyanax.thrift.ThriftConverter.ToConnectionPoolException(ThriftConverter.java:159)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:60)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$1$2.execute(ThriftColumnFamilyQueryImpl.java:196)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$1$2.execute(ThriftColumnFamilyQueryImpl.java:188)
at com.netflix.astyanax.thrift.ThriftSyncConnectionFactoryImpl$1.execute(ThriftSyncConnectionFactoryImpl.java:132)
at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:52)
at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:229)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$1.execute(ThriftColumnFamilyQueryImpl.java:186)
at com.ebay.raptor.search.test.srp.domain.cassandra.CassandraTest.test_user_attributes(CassandraTest.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: InvalidRequestException(why:Too many bytes for comparator)
at org.apache.cassandra.thrift.Cassandra$get_slice_result.read(Cassandra.java:7196)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
at org.apache.cassandra.thrift.Cassandra$Client.recv_get_slice(Cassandra.java:543)
at org.apache.cassandra.thrift.Cassandra$Client.get_slice(Cassandra.java:527)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$1$2.internalExecute(ThriftColumnFamilyQueryImpl.java:201)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$1$2.internalExecute(ThriftColumnFamilyQueryImpl.java:188)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:55)
... 30 more