给一张表单独加上coprocessor后,put数据抛IOException。 |
楼主 为什么我在hbase里面,运行完 alter 'ceshi',METHOD=>'table_att','coprocessor'=>'hdfs:///demo/wyn.jar|hbase.SenondIndexCoprocessor|1001' 这段代码后 子节点上的 regionserver 就都宕机了 |
非常感谢 |
学习了,多谢多谢! |
我按照这个做法,为啥put数据后,索引表没有自动插入数据呢?hbase日志里也提示协议处理器加载成功了,“Loaded coprocessor test.HbaseCoprocessor from HTD of test successfully.” 以下是代码,其中testi是索引表,test是数据表 create 'testi', {NAME=>'keys'} create 'test', {NAME=>'info'} alter 'test',METHOD=>'table_att','coprocessor'=>'hdfs:///user/dw/myhbase-0.0.1-SNAPSHOT.jar|test.HbaseCoprocessor|1001' put 'test','row1','info:1','hello0' 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 = "1"; HTable table = new HTable(conf, "testi"); List<Cell> kv = put.get("info".getBytes(), "1".getBytes()); Iterator<Cell> kvItor = kv.iterator(); while (kvItor.hasNext()) { Cell tmp = kvItor.next(); Put indexPut = new Put(tmp.getValue()); // Put indexPut = new Put("hello"); indexPut.add("keys".getBytes(), "1".getBytes(), tmp.getRow()); table.put(indexPut); } table.close(); } } |
楼主,我用这个办法做了,当我向主表写入key=rk0003,value=b33时,索引表想要的结果是这样: key=b33,value=rk0003 实际是这样: key=\x00\x00\x00\x1A\x00\x00\x00\x03\x00\x06rk0003\x04infoname\x7F\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x04b33,value=\x00\x00\x00\x1A\x00\x00\x00\x03\x00\x06rk0003\x04infoname\x7F\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x04b33 在想要的值旁还多出了很多奇怪的字符,这是什么原因? |
学习了 谢谢分享 |
hhhhh ..不错不错。。。。。 |
华为的二级索引 |