- public class HbaseCoprocessor extends BaseRegionObserver {
- public void prePut(final ObserverContext<RegionCoprocessorEnvironment> e,
- final Put put, final WALEdit edit, final boolean writeToWAL)
- throws IOException {
- // set configuration
- Configuration conf = new Configuration();
- // need conf.set...
- String colName = "columnName";
- HTable table = new HTable(conf, "indexTableName");
- List<Cell> kv = put.get("familyName".getBytes(), colName.getBytes());
- Iterator<Cell> kvItor = kv.iterator();
- while (kvItor.hasNext()) {
- Cell tmp = kvItor.next();
- Put indexPut = new Put(tmp.getValue());
- indexPut.add("familyName".getBytes(), "columnName".getBytes(),
- tmp.getRow());
- table.put(indexPut);
- }
- table.close();
- }
- 对于这种情况,我怎么判断这个put是在hbase中是要更新的还是要直接添加的??
- }
|
|