I have an MR job that writes multiple rows with one column each. Though I pass a non-null value for the column name, I get the following Exception
java.io.IOException: InvalidRequestException(why:column name must not be empty)
at org.apache.cassandra.hadoop.ColumnFamilyRecordWriter$RangeClient.run(ColumnFamilyRecordWriter.java:307)
Caused by: InvalidRequestException(why:column name must not be empty)
at org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read(Cassandra.java:19477)
at org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate(Cassandra.java:1035)
at org.apache.cassandra.thrift.Cassandra$Client.batch_mutate(Cassandra.java:1009)
at org.apache.cassandra.hadoop.ColumnFamilyRecordWriter$RangeClient.run(ColumnFamilyRecordWriter.java:299)
Is there something I am mising here?
Here is the reducer that I’ve written –
public static class SampleReducer extends 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));
}
}
“Empty” means “non-null, zero length.” That is not a valid column name.