Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase, mail # user - How to retrieve all columns of a CF and adding it in a put call

Copy link to this message
How to retrieve all columns of a CF and adding it in a put call
Shrijeet Paliwal 2011-09-29, 18:58

I am trying to create a new table with data exactly same as BUT make
the row key in new table set as a column_value in the old table.

Following is my map method ( using a map only MR job)

public void map(ImmutableBytesWritable key, Result value, Context context) {
                throws IOException, InterruptedException {
            byte[] mod_key = value.getValue(INPUT_FAMILY, INPUT_COLUMN);
            if (mod_key != null) {
            Map<byte[], NavigableMap<byte[], byte[]>> cf value.getNoVersionMap();
            Put put = new Put(mod_key);
            for (byte[] c : cf.keySet()) {
                for (byte[] q : cf.get(c).keySet()) {
                    put.add(c, q, cf.get(c).get(q));
            context.write(key, put);}

I am inclined to think there has to be a more efficient way to do
this. By that I mean, not have to iterate through all the columns.

Browsing code I found some usages like this :

outval.add(INPUT_FAMILY, null, value.getValue(INPUT_FAMILY, null);

What does above mean? Does it mean get bytes representing all columns
for INPUT_FAMILY and add it in put object?