gpt4 book ai didi

cassandra - InvalidRequestException(为什么 :Too many bytes for comparator) on execute query to composite columns using Asytanax

转载 作者:行者123 更新时间:2023-12-02 03:56:31 25 4
gpt4 key购买 nike

我正在尝试使用 Astyanax 1.0.9 提取复合列并得到“InvalidRequestException(为什么:比较器字节太多)”

这是我的CF:

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 中设置的,适用于非复合列)

@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());
}
}

编译正常,但在 execute() 期间失败:

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

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

有什么建议我做错了吗?

谢谢查克

最佳答案

Astyanax 是一个基于 Thrift 的客户端,所以这是行不通的:(服务器端)Thrift 验证路径不是 CQL 感知的。

我们是addressing this在 1.2.0 中提供更顺畅的升级路径;否则,您要么需要使用 CQL 客户端访问您的 CQL 表,要么使用 CLI 为基于 Thrift 的客户端定义您的架构。

关于cassandra - InvalidRequestException(为什么 :Too many bytes for comparator) on execute query to composite columns using Asytanax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12360067/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com