npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hbase-rpc-client

v0.1.15

Published

CoffeeScript HBase client implementation with protobuf support

Downloads

187

Readme

hbase-rpc-client

Build Status Dependency Status License

CoffeeScript HBase Implementation with protobuf support based on https://github.com/alibaba/node-hbase-client/

Installation

npm install -S hbase-rpc-client

Supported HBase versions

  • [x] 0.98.x
  • [x] 1.0.x
  • [x] 1.2.x

Features

  • [x] get
  • [x] put
  • [x] delete
  • [x] mget
  • [x] mput
  • [x] mdelete
  • [x] checkAndPut
  • [x] checkAndDelete
  • [x] scan:
    • [√] filter
    • [√] filterList
    • [√] reverse scan
  • [x] increment
  • [x] incrementColumnValue
  • [ ] getRowOrBefore
  • [ ] mutateRow
  • [ ] append

Create a hbase client through zookeeper

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

put

Values can be only strings or buffers.

put table, put, callback
put = new hbase.Put rowKey
put.add cf, qualifier, value

client.put table, put, (err, res) ->
	console.log arguments

get

get table, get, callback
get = new hbase.Get rowKey

client.get table, get, (err, res) ->
	console.log arguments

delete

delete table, delete, callback
del = new hbase.Delete rowKey

client.delete table, del, (err, res) ->
	console.log arguments

mput

Values can be only strings or buffers.

mput table, arrayOfPutObjects, callback
mput table, arrayOfObjects, callback
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

mget

mget table, arrayOfGetObjects, callback
mget table, arrayOfObjects, callback
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

mdelete

mdelete table, arrayOfDeleteObjects, callback
mdelete table, arrayOfObjects, callback
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

scanner = getScanner table, startRow, stopRow
scanner.setFilter filter
scanner.setReversed()
scanner.next callback
scanner.each function, callback
scanner.toArray callback
scanner.close()
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

checkAndPut

Values can be only strings or buffers.

checkAndPut table, rowKey, cf, qualifier, value, putObject, callback
put = new hbase.Put rowKey1
put.add cf1, qualifier1, value1

client.checkAndPut table, rowKey2, cf2, qualifier2, value2, put, (err, res) ->
	console.log arguments

checkAndDelete

checkAndDelete table, rowKey, cf, qualifier, value, deleteObject, callback
del = new hbase.Put rowKey1

client.checkAndDelete table, rowKey2, cf2, qualifier2, value2, del, (err, res) ->
	console.log arguments

increment

increment table, incrementObject, callback
increment = new hbase.Increment rowKey
increment.add cf1, qualifier1, incrementValue1
increment.add cf2, qualifier2, incrementValue2

client.increment table, increment, (err, res) ->
	console.log arguments

incrementColumnValue

incrementColumnValue table, rowKey, cf, qualifier, value, callback
client.incrementColumnValue table, rowKey, cf, qualifier, incrementValue, (err, res) ->
	console.log arguments

License

hbase-rpc-client is made available under the Apache License, version 2.0