CoffeeScript HBase Implementation with protobuf support based on https://github.com/alibaba/node-hbase-client/
npm install -S hbase-rpc-client
- 0.98.x
- 1.0.x
- 1.2.x
- get
- put
- delete
- mget
- mput
- mdelete
- checkAndPut
- checkAndDelete
- scan:
- [√] filter
- [√] filterList
- [√] reverse scan
- increment
- incrementColumnValue
- getRowOrBefore
- mutateRow
- append
hbase = require "hbase-rpc-client"
client = hbase
zookeeperHosts: ["localhost"] # required
zookeeperRoot: "/hbase"
zookeeperReconnectTimeout: 20000
rootRegionZKPath: "/meta-region-server"
rpcTimeout: 30000
callTimeout: 5000
tcpNoDelay: no
tcpKeepAlive: yes
realUser: "someRealUser"
effectiveUser: "someEffectiveUser"
client.on "error", (err) ->
console.log "hbase client error:", err
In case you experience slow communication with hbase, please see issue #24 and try to set tcpNoDelay: true
Timeouts explained:
- zookeeperReconnectTimeout - Time after zookeeper watcher creates new zk client upon receiving following events: closing, session_expired or authentication_failed (other events are handled by node-zookeeper-client). Default: 20000ms (set by zookeeper-watcher)
- rpcTimeout - Time after hbase-rpc-client emits an error if it doesn't manage to ensure zookeeper connection or doesn't manage to get region server connection. Default: 30000ms
- callTimeout - Time after each operation call on hbase timeouts. Default: 5000ms
Values can be only strings or buffers.
put = new hbase.Put rowKey
put.add cf, qualifier, value
client.put table, put, (err, res) ->
console.log arguments
get = new hbase.Get rowKey
client.get table, get, (err, res) ->
console.log arguments
del = new hbase.Delete rowKey
client.delete table, del, (err, res) ->
console.log arguments
Values can be only strings or buffers.
put1 = new hbase.Put rowKey1
put1.add cf1, qualifier1, value1
put2 = new hbase.Put rowKey2
put2.add cf2, qualifier2, value2
client.mput table, [put1, put2], (err, res) ->
console.log arguments
put1 =
row: rowKey1
put1["#{cf1}:#{qualifier1}"] = value1
put2 =
row: rowKey2
put2["#{cf2}:#{qualifier2}"] = value2
client.mput table, [put1, put2], (err, res) ->
console.log arguments
get1 = new hbase.Get rowKey1
get2 = new hbase.Get rowKey2
client.mget table, [get1, get2], (err, res) ->
console.log arguments
client.mget table, [rowKey1, rowKey2], (err, res) ->
console.log arguments
delete1 = new hbase.Delete rowKey1
delete2 = new hbase.Delete rowKey2
client.mdelete table, [delete1, delete2], (err, res) ->
console.log arguments
client.mdelete table, [rowKey1, rowKey2], (err, res) ->
console.log arguments
scan = client.getScanner table
scan.next (err, row) ->
console.log arguments
scan = client.getScanner table, startRow, stopRow
scan.next (err, row) ->
console.log arguments
scan = client.getScanner table
scan.setFilter columnPrefixFilter: prefix: columnPrefix
scan.next (err, row) ->
console.log arguments
scan = client.getScanner table
filter1 =
singleColumnValueFilter:
columnFamily: cf1
columnQualifier: qualifier1
compareOp: "EQUAL"
comparator:
substringComparator:
substr: value1
filterIfMissing: yes
latestVersionOnly: yes
filter2 =
singleColumnValueFilter:
columnFamily: cf2
columnQualifier: qualifier2
compareOp: "EQUAL"
comparator:
substringComparator:
substr: value2
filterIfMissing: yes
latestVersionOnly: yes
filterList1 = new hbase.FilterList
filterList2 = new hbase.FilterList
filterList3 = new hbase.FilterList "MUST_PASS_ONE"
filterList1.addFilter f1
filterList2.addFilter f2
filterList3.addFilter filterList1
filterList3.addFilter filterList2
scan.setFilter filterList3
scan.toArray (err, res) ->
console.log arguments
scan = client.getScanner table
scan.toArray (err, res) ->
console.log arguments
scan = client.getScanner table
scan.each (err, row) ->
return unless row # no more rows
# do something with row synchronously
scan = client.getScanner table
scan.each (err, row, done) ->
return unless row # no more rows
# do something with row asynchronously
done()
scan = client.getScanner table
scan.each (err, row, done) ->
# do something with row asynchronously
done()
, (err) ->
# error or no more rows
console.log err if err
Values can be only strings or buffers.
put = new hbase.Put rowKey1
put.add cf1, qualifier1, value1
client.checkAndPut table, rowKey2, cf2, qualifier2, value2, put, (err, res) ->
console.log arguments
del = new hbase.Put rowKey1
client.checkAndDelete table, rowKey2, cf2, qualifier2, value2, del, (err, res) ->
console.log arguments
increment = new hbase.Increment rowKey
increment.add cf1, qualifier1, incrementValue1
increment.add cf2, qualifier2, incrementValue2
client.increment table, increment, (err, res) ->
console.log arguments
client.incrementColumnValue table, rowKey, cf, qualifier, incrementValue, (err, res) ->
console.log arguments
hbase-rpc-client is made available under the Apache License, version 2.0