This is two questions for one solution. I want to put a blog post together on this if it's right.

I am playing with htable.batch for multi get to see if I can remove my external hbase indexes. This is what I am trying to do.

#1 What is the best model for a column family that is just used as an index?

Currently I am using a columns family _idx_ with:
column:<row>
value:<timstamp>

This allows me to have a new column for each index with a value of when it was added. That allows me to purge the column family by the value greater than some time in Map reduce.

#2 What is the most performant way to get this back into a get object? This is what I am doing so far but want to validate my thoughts.

        Configuration config = HBaseConfiguration.create();
        HTableDescriptor transactionsbycompany_descriptor = new 
HTableDescriptor(table);
        HTable transactionsbycompany_table = new HTable(config, 
transactionsbycompany_descriptor.getName());
        HTable transactions_table = new HTable(config, 
transactions_descriptor.getName());
List<Row> gets = new ArrayList<Row>(); Get g = new Get(Bytes.toBytes(key));
        Result result = transactionsbycompany_table.get(g);
NavigableMap<byte[], byte[]> nmap = result.getFamilyMap(Bytes.toBytes(colfam_index));

        Set<byte[]>  keySet = nmap.keySet();
        Iterator<byte[]>  iter = keySet.iterator();
        HTableDescriptor transactions_descriptor = new 
HTableDescriptor("transactions");

        while (iter.hasNext()) {
            byte[] idx_key = iter.next();
            Get get = new Get(idx_key);
            get.addColumn(Bytes.toBytes("details"), Bytes.toBytes("amount"));
            gets.add(get);

        }
        Result[] multiRes = new Result[gets.size()];
        try {
            transactions_table.batch(gets, multiRes);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block

            e.printStackTrace();
        }



With appreciation;
Wade Arnold

Reply via email to