hadoop - CqlInputFormat中的Hadoop Cassandra宽行

标签 hadoop cassandra cassandra-2.0

我正在写一个使用Cassandra(v2.0.11)作为输入和输出的hadoop作业。

在我的hadoop工作中,我定义了输入列族:

ConfigHelper.setInputColumnFamily(job.getConfiguration(), KEYSPACE, INPUT_COLUMN_FAMILY, WIDE_ROWS);

其中WIDE_ROWS=true。我还将CqlInputFormat设置为阅读类:
job.setInputFormatClass(CqlInputFormat.class);
CqlInputFormat在其写入位置(link)使用CqlRecordReader:
// Because the old Hadoop API wants us to write to the key and value
// and the new asks for them, we need to copy the output of the new API
// to the old. Thus, expect a small performance hit.
// And obviously this wouldn't work for wide rows. But since ColumnFamilyInputFormat
// and ColumnFamilyRecordReader don't support them, it should be fine for now.
public boolean next(Long key, Row value) throws IOException
{
    if (nextKeyValue())
    {
        ((WrappedRow)value).setRow(getCurrentValue());
        return true;
    }
    return false;
}

我不太明白...当我检查ColumnFamilyRecordReader代码(link)时,似乎使用的是宽行...CqlInputFormat是否真的支持宽行?你能解释一下吗?

最佳答案

我对其进行了调查,并意识到CQL“转置”宽行,以便将每一列分别馈给map函数(CqlInputFormat运行CQL查询以从cassandra节点获取数据)。

当处理非常宽的行时,此方法不会导致OOM异常,因为CqlInputFormat使用CQL中可用的分页机制。每页只需要CqlConfigHelper.getInputCQLPageRowSize列。

不幸的是,在我的情况下效率不高,因为我想对每个行键执行“分组依据”操作以对列进行计数。而且,在成千上万个列的循环中增加计数器比仅使用columns.size()(如果有这种可能)要慢。

了解更多信息:
http://www.datastax.com/dev/blog/cql3-for-cassandra-experts
https://issues.apache.org/jira/browse/CASSANDRA-3264

关于hadoop - CqlInputFormat中的Hadoop Cassandra宽行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28933048/

相关文章:

java - 由于 ClassNotFound,CDH Hadoop 无法执行 hadoop 作业

索引上的 Cassandra IN 子句

java - Cassandra:使用 DataStax Java 驱动程序选择一系列 TimeUUID

cassandra - 使用nodetool和cqlsh copy命令备份数据有什么区别?

hadoop - Cassandra 是用于 OLAP 还是 OLTP 或两者?

java - Cassandra java 查询性能 count(*) 或 all().size()

hadoop - 在Hive中分解结构的多个数组

hadoop - 从Spark将JavaRDD保存到HDFS

multithreading - hadoop -0.20.0无法处理bin/hadoop namenode-format

cassandra的连接问题