写入Cassandra Column系列时Hadoop MR作业失败“InavlidRequestException(列名不能为空)”

时间:2012-10-09 09:24:46

标签: hadoop cassandra

我有一个MR作业,它写入多行,每行一列。虽然我为列名传递了一个非null值,但我得到以下异常

java.io.IOException:InvalidRequestException(why:column name不能为空)     在org.apache.cassandra.hadoop.ColumnFamilyRecordWriter $ RangeClient.run(ColumnFamilyRecordWriter.java:307) 引起:InvalidRequestException(原因:列名不能为空)     在org.apache.cassandra.thrift.Cassandra $ batch_mutate_result.read(Cassandra.java:19477)     在org.apache.cassandra.thrift.Cassandra $ Client.recv_batch_mutate(Cassandra.java:1035)     在org.apache.cassandra.thrift.Cassandra $ Client.batch_mutate(Cassandra.java:1009)     在org.apache.cassandra.hadoop.ColumnFamilyRecordWriter $ RangeClient.run(ColumnFamilyRecordWriter.java:299)

我在这里有什么东西吗?

这是我写过的减速机 -

公共静态类SampleReducer扩展了Reducer> {                 static Logger logger = LoggerFactory.getLogger(AndroidEthnicityMap.class);

            @Override
            protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException ,InterruptedException {
                    String tStr[] = key.toString().split("__");
                    logger.info("The string to be reduced is " + key.toString());
                    String appid = tStr[0];
                    String columnName = tStr[1];
                    String columnValue = "{}";
                    if(values.iterator().hasNext())
                            columnValue = values.iterator().next().toString();



                    ByteBuffer bbcn = ByteBufferUtil.bytes(columnName);
                    ByteBuffer bbcv = ByteBufferUtil.bytes(columnValue);
                    ByteBuffer bbkey = ByteBufferUtil.bytes(appid);

                    Mutation m = new Mutation();
                    m.setColumn_or_supercolumn(new ColumnOrSuperColumn());
                    Column c = new Column();
                    c.setName(ByteBufferUtil.bytes(columnName));
                    c.setValue(ByteBufferUtil.bytes(columnValue));
                    c.setTimestamp(System.currentTimeMillis());
                    m.column_or_supercolumn.setColumn(c);

                    Mutation[] marray = new Mutation[]{m};
                    context.write(ByteBufferUtil.bytes(appid), Arrays.asList(marray));

            }
    }

2 个答案:

答案 0 :(得分:1)

“空”表示“非空,零长度”。这不是有效的列名。

答案 1 :(得分:0)

将日志添加到reducer以查看它转移到上下文的所有列名称。看来你的列族是一个空字符串。记录所有数据不仅是colName