ConfigHelper.setThriftContact()在cassandra v1.2中未定义
我正在尝试《卡桑德拉权威指南》第12章中给出的例子。此语句出现错误,我无法找出替换它的方法:ConfigHelper.setThriftContact()在cassandra v1.2中未定义,cassandra,Cassandra,我正在尝试《卡桑德拉权威指南》第12章中给出的例子。此语句出现错误,我无法找出替换它的方法: ConfigHelper.setThriftContact(job.getConfiguration(), "localhost", 9160); 而且 column.value()给出编译错误。 有什么解决办法吗?卡桑德拉权威指南在这一点上是一个贫乏的资源,因为它已经过时了。卡桑德拉和Hadoop从那时起发生了很大的变化,因此卡桑德拉Hadoop集成章节尤其不可靠 下面是一个完整的Cassandr
ConfigHelper.setThriftContact(job.getConfiguration(), "localhost", 9160);
而且
column.value()给出编译错误。
有什么解决办法吗?卡桑德拉权威指南在这一点上是一个贫乏的资源,因为它已经过时了。卡桑德拉和Hadoop从那时起发生了很大的变化,因此卡桑德拉Hadoop集成章节尤其不可靠 下面是一个完整的Cassandra配置:
ConfigHelper.setRangeBatchSize(getConf(), 99);
final Job job = new Job(getConf(), "average");
final Configuration conf = job.getConfiguration();
ConfigHelper.setInputRpcPort(conf, "9160");
ConfigHelper.setInputInitialAddress(conf, cassHost);
ConfigHelper.setInputPartitioner(conf, "org.apache.cassandra.dht.Murmur3Partitioner");
ConfigHelper.setInputColumnFamily(conf, conf.get(keyspace), conf.get(inputCF));
//get all records
SlicePredicate predicate = new SlicePredicate().setSlice_range(new SliceRange(ByteBufferUtil.bytes(""), ByteBufferUtil.bytes(""), false, Integer.MAX_VALUE));
ConfigHelper.setInputSlicePredicate(conf, predicate);
ConfigHelper.setOutputInitialAddress(conf, cassHost);
ConfigHelper.setOutputRpcPort(conf, "9160");
ConfigHelper.setOutputPartitioner(conf, "org.apache.cassandra.dht.Murmur3Partitioner");
ConfigHelper.setOutputColumnFamily(conf, conf.get(keyspace), conf.get(outputCF));
您的产品线的问题:
String value = new String(column.value());
正在尝试将其传递到字符串构造函数中。在旧版本的Cassandracolumn.value()
中返回了byte[]
,但现在它返回了一个ByteBuffer
。如果底层数据实际上是一个字符串,则可以使用Cassandra的ByteBufferUtil.string()
对其进行解码。因此,您的新产品线如下所示:
String value = ByteBufferUtil.string(column.value());
DataStax文档很好,对于Hadoop我可以推荐。
String value = ByteBufferUtil.string(column.value());