1

I am using HBase MapReduce (docs) to read strings from HBase table. Here is part of the code:

public void map(ImmutableBytesWritable row, Result values, Context context) throws IOException {

    String testing = values.getValue(Bytes.toBytes("data"),Bytes.toBytes("lastLine")).toString();

        try {
            context.write(new ImmutableBytesWritable(Bytes.toBytes(testing)), new IntWritable(1));
        } catch (InterruptedException e) {
            throw new IOException(e);
        }

    }
}

There is a reducer to output the string to another HBase table, which works fine when I try testing it with some hard code strings from mapper. I have checked from HBase shell that the string to be read is set correctly.

However, when I try to input that into another table in HBase as row id, it becomes unknown string like the following:

[B@fe2851
column=result:count, timestamp=1415868730030, value=\x00\x00\x00\x01
[B@fe331c
column=result:count, timestamp=1415868730030, value=\x00\x00\x00\x01
[B@fe6526
column=result:count, timestamp=1415868730030, value=\x00\x00\x00\x01
[B@fe7a98
column=result:count, timestamp=1415868730030, value=\x00\x00\x00\x01

The following is the expected result:

apple
column=result:count, timestamp=1415868730030, value=\x00\x00\x00\x01
orange
column=result:count, timestamp=1415868730030, value=\x00\x00\x00\x01
banana
column=result:count, timestamp=1415868730030, value=\x00\x00\x00\x01
pineapple
column=result:count, timestamp=1415868730030, value=\x00\x00\x00\x01

Any clue on what is the possible reason?

1 Answer 1

2

You are writing the string name of the array which is [B@fe6526 or similar.

I think you wanted this one:

byte[] testing = values.getValue(Bytes.toBytes("data"), Bytes.toBytes("lastLine"));
context.write(new ImmutableBytesWritable(testing), new IntWritable(1));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.