问题描述
我是不熟悉astyanax并尝试一些示例程序并遇到此错误的方法.这是一个简单的编写,看起来像是在做一些基本错误的事情.不使用组合键.
I am new to astyanax and trying some sample programs and getting this error. This is a simple write and looks like am doing some thing basic wrong. Not using composite keys.
Caused by: InvalidRequestException(why:Not enough bytes to read value of component 0)
at org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read(Cassandra.java:20833)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
at org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate(Cassandra.java:964)
at org.apache.cassandra.thrift.Cassandra$Client.batch_mutate(Cassandra.java:950)
at com.netflix.astyanax.thrift.ThriftKeyspaceImpl$1$1.internalExecute(ThriftKeyspaceImpl.java:120)
at com.netflix.astyanax.thrift.ThriftKeyspaceImpl$1$1.internalExecute(ThriftKeyspaceImpl.java:117)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:56)
代码如下:
AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
.forCluster(CLUSTER_NAME)
.forKeyspace(keySpaceName)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
.setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
.setCqlVersion("3.0.0")
.setTargetCassandraVersion("1.2")
)
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
.setPort(50825)
.setMaxConnsPerHost(10)
.setSeeds("nodename:50825")
.setConnectTimeout(20000)
)
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
System.out.println("getting context.. done ");
Keyspace keyspace = context.getEntity();
MutationBatch m = keyspace.prepareMutationBatch();
ColumnFamily<String, String> colFam = new ColumnFamily<String, String>("test",
StringSerializer.get(), StringSerializer.get());
m.withRow(colFam, "abc")
.putColumn("col2", "test1", null);
m.execute();
以下是表格说明:
CREATE TABLE test (
col1 text PRIMARY KEY,
col2 text,
col3 text
) WITH
bloom_filter_fp_chance=0.010000 AND
caching='KEYS_ONLY' AND
comment='' AND
dclocal_read_repair_chance=0.000000 AND
gc_grace_seconds=864000 AND
read_repair_chance=0.100000 AND
replicate_on_write='true' AND
populate_io_cache_on_flush='false' AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'SnappyCompressor'};
推荐答案
我也是Astyanax的新手,遇到了相同的异常.例外是由于基于Astyanax Thrift的对象认为列定义应与使用CQL 3将其存储在1.2+中之间不匹配.我学会了指定COMPACT STORAGE,以便以1.2之前的格式创建表让我可以通过基于Thrift的对象与之交互. FWIW:我正在从源代码构建Astyanax,但是我确实在Maven Central看到了1.56.34.我也会对此进行更新.
I'm also new to Astyanax and encountering the the same exceptions. The exception is due to a mismatch between what Astyanax Thrift-based objects think the column definition should look like and how it is store in 1.2+ using CQL 3. I learned specifying COMPACT STORAGE so that the table is created in the pre 1.2 format will allow me interact with it via the Thrift-based objects. FWIW: I'm building Astyanax from source, but I did see a 1.56.34 in maven central; I would update to that also.
CREATE TABLE test (
col1 text PRIMARY KEY,
col2 text,
col3 text
) WITH COMPACT STORAGE AND
...
这篇关于Astyanax:简单写入引发此异常:没有足够的字节来读取组件的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!