Skip to content

kuiwang/node-hbase-client

 
 

Repository files navigation

hbase-client

Build Status Coverage Status

NPM

logo

Asynchronous HBase client for Node.js, pure JavaScript implementation.

Support HBase Server Versions

  • [√] 0.94.x
    • [√] 0.94.0
    • [√] 0.94.16
  • 0.95.x
  • 0.96.x

Install

$ npm install hbase-client

Usage

get(table, get, callback): Get a row from a table

var HBase = require('hbase-client');

var client = HBase.create({
  zookeeperHosts: [
    '127.0.0.1:2181', '127.0.0.1:2182',
  ],
  zookeeperRoot: '/hbase-0.94',
});

// Get `f1:name, f2:age` from `user` table.
var param = new HBase.Get('foo');
param.addColumn('f1', 'name');
param.addColumn('f1', 'age');

client.get('user', param, function (err, result) {
  console.log(err);
  var kvs = result.raw();
  for (var i = 0; i < kvs.length; i++) {
    var kv = kvs[i];
    console.log('key: `%s`, value: `%s`', kv.toString(), kv.getValue().toString());
  }
});

getRow(table, rowkey, columns, callback)

client.getRow(table, row, ['f:name', 'f:age'], function (err, row) {
  row.should.have.keys('f:name', 'f:age');
});

// return all columns, like `select *`
client.getRow(table, row, function (err, row) {
  row.should.have.keys('f:name', 'f:age', 'f:gender');
});

client.getRow(table, row, '*', function (err, row) {
  row.should.have.keys('f:name', 'f:age', 'f:gender');
});

put(table, put, callback): Put a row to table

var put = new HBase.Put('foo');
put.add('f1', 'name', 'foo');
put.add('f1', 'age', '18');
client.put('user', put, function (err) {
  console.log(err);
});

putRow(table, row, data, callback)

client.putRow(table, row, {'f1:name': 'foo name', 'f1:age': '18'}, function (err) {
  should.not.exists(err);
});

delete(tableName, del, callback)

var del = new Delete(rowkey);
del.deleteColumns('f', 'name-t');
client.delete(table, del, function (err, result) {
  //TODO:...
});
var del = new Delete(rowkey);
del.deleteFamily('f');
client.delete(table, del, function (err, result) {
  //TODO:...
});

deleteRow(tableName, rowkey, callback)

var tableName = 'user_search';
var rowkey = 'rowkeyyyyyy';
client.deleteRow(tableName, rowkey, function (err) {
  //TODO:...
});

mget(tableName, rows, columns, callback)

var rows = ['row1', 'row2'];
var columns = ['f:col1', 'f:col2'];
client.mget(tableName, rows, columns, function (err, results){
  //TODO:...
});

mput(tableName, rows, callback)

var rows = [{row: 'rowkey1', 'f:col1': 'col_value'}, {row: 'rowkey2', 'f:col1': 'col_value'}];
client.mput(tableName, rows, function (err, results) {
  //TODO:...
});

mdelete(tableName, rowkeys, callback)

var rowKeys = ['rowkey1', 'rowkey2'];
client.mdelete(tableName, rowKeys, function (err, results) {
  //TODO:...
});

TODO

  • [√] support put
  • [√] benchmark
  • [√] more stable
  • [√] support delete
  • [√] multi actions
    • [√] multi get
    • [√] multi put
    • [√] multi delete
  • [√] fail retry

Benchmarks

@see docs/benchmark.md

Authors

Thanks for @haosdent support the test hbase clusters environment and debug helps.

$ git summary

 project  : node-hbase-client
 repo age : 11 months
 active   : 48 days
 commits  : 129
 files    : 277
 authors  :
   108  fengmk2                 83.7%
    19  tangyao                 14.7%
     1  Alsotang                0.8%
     1  不四                  0.8%

License

(The MIT License)

Copyright (c) 2013 - 2014 Alibaba Group Holding Limited

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Asynchronous HBase client for Node.js, pure JavaScript implementation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published