简体   繁体   中英

Multiple Column Family with PutRequest

I'm in process of writing a custom HbaseSink for use with Flume-NG 1.3.0, and need to perform a org.hbase.async.PutRequest with multiple column families in the same row. I do not see a constructor or anything similar to Put.add(columnFamily, columnName, value) .

Can someone shine some light on how I should go about doing this?

I also tried to find the solution for this problem but could not find any reference. So here is what I did in my application

`

public void addRecord(String tableName, String rowKey, String family, HashMap<String, String> hash) {
        try {
            HTable table = new HTable(conf, tableName);
            Put put = new Put(Bytes.toBytes(rowKey));

            Iterator<String> it = hash.keySet().iterator();
            while (it.hasNext()) {
                String key = it.next();
                String val = hash.get(key);
                put.add(Bytes.toBytes(family), Bytes.toBytes(key), Bytes.toBytes(val));
            }
            table.put(put);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

`

Here, the HashMap hash contains the column name and its value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM