我为HBase thrift生成了node.js代码,编写了代码,使用mutateRow()
方法将单行放入HBase。我想知道如何在mutateRow()
方法的单个API调用中放置多行以提高性能?我目前的代码如下:
connection.on('connect', function(){
console.log('connected to hbase.');
var dummyCol1 = {'family' : 'CF', 'qualifier':'CF:dummy_col_1', 'value':'dummy_val'};
var colVal = new TColumnValue(dummyCol1);
var putJs = {'row' : 'dummy_rk_for_testing_thrift_mutateRow_method','columnValues' : [colVal]};
var put = new TPut(putJs);
var mute = new TMutation({'put' : put});
var m1 = new TRowMutations({'row' : 'dummy_rk_for_testing_thrift_mutateRow_method', 'mutations' : [mute]});
client.mutateRow('COMPANY_TABLE', m1, function(err){
if(err) {
console.log('some error occurred in put operation.');
console.dir(err);
} else {
console.log('success !!!');
}
});
connection.end();
});
上面的代码可以在HBase中运行并创建一个新行,但是当我执行以下代码时:
connection.on('connect', function(){
console.log('connected to hbase.');
var dummyCol1 = {'family' : 'CF', 'qualifier':'CF:dummy_col_1', 'value':'dummy_val'};
var colVal = new TColumnValue(dummyCol1);
var putJs = {'row' : 'dummy_rk_for_testing_thrift_mutateRow_method','columnValues' : [colVal]};
var put = new TPut(putJs);
var putJs2 = {'row' : 'dummy_rk_2_for_testing_thrift_mutateRow_method','columnValues' : [colVal]};
var put2 = new TPut(putJs2);
var mute = new TMutation({'put' : put});
var mute2 = new TMutation({'put' : put2});
var m1 = new TRowMutations({'row' : 'dummy_rk_for_testing_thrift_mutateRow_method', 'mutations' : [mute]});
var m2 = new TRowMutations({'row' : 'dummy_rk_2_for_testing_thrift_mutateRow_method', 'mutations' : [mute2]});
client.mutateRow('COMPANY_TABLE', [m1, m2], function(err){
if(err) {
console.log('some error occurred in put operation.');
console.dir(err);
} else {
console.log('success !!!');
console.dir(err);
}
});
connection.end();
});
我收到以下错误:
/home/ubuntu/shekhar/thrift/client/gen-nodejs/THBaseService.js:2321
this.rowMutations.write(output);
^
TypeError: undefined is not a function
at Object.THBaseService_mutateRow_args.write (/home/ubuntu/shekhar/thrift/client/gen-nodejs/THBaseService.js:2321:23)
at Object.THBaseServiceClient.send_mutateRow (/home/ubuntu/shekhar/thrift/client/gen-nodejs/THBaseService.js:3317:8)
at Object.THBaseServiceClient.mutateRow (/home/ubuntu/shekhar/thrift/client/gen-nodejs/THBaseService.js:3307:10)
at null.<anonymous> (/home/ubuntu/shekhar/thrift/client/multi-put.js:39:10)
at emit (events.js:104:17)
at Socket.<anonymous> (/home/ubuntu/shekhar/thrift/client/node_modules/thrift/lib/thrift/connection.js:73:10)
at Socket.emit (events.js:129:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1001:10)
有人可以帮忙吗?