Changes between Version 1 and Version 2 of waue/2010/0204-03


Ignore:
Timestamp:
Feb 3, 2010, 9:51:32 PM (14 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/2010/0204-03

    v1 v2  
    44{{{
    55#!java
     6package tsmc;
     7
     8import java.io.IOException;
     9
     10import org.apache.hadoop.hbase.HBaseConfiguration;
     11import org.apache.hadoop.hbase.client.Get;
     12import org.apache.hadoop.hbase.client.HTable;
     13import org.apache.hadoop.hbase.client.Result;
     14import org.apache.hadoop.hbase.util.Bytes;
     15
     16public class GetColumn {
     17
     18        static String getColumn(String tablename, String row, String family,
     19                        String column) {
     20                HBaseConfiguration conf = new HBaseConfiguration();
     21                String ret = "";
     22
     23                HTable table;
     24                try {
     25                        table = new HTable(conf, Bytes.toBytes(tablename));
     26                        Get g = new Get(Bytes.toBytes(row));
     27                        Result rowResult = table.get(g);
     28                        ret = Bytes.toString(rowResult.getValue(Bytes.toBytes(family + ":"
     29                                        + column)));
     30
     31                        table.close();
     32                } catch (IOException e) {
     33
     34                        e.printStackTrace();
     35                }
     36
     37                return ret;
     38        }
     39
     40        public static void main(String[] argv) {
     41                System.out.println(getColumn("tsmc", "T01", "Detail", "Locate"));
     42        }
     43}
    644
    745}}}