-
-
Save simonmorley/01a1146519c5ca6aac74c11120dcfc29 to your computer and use it in GitHub Desktop.
Revisions
-
blmarket revised this gist
Nov 6, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,7 @@ move to the directory and execute thrift --gen js:node Hbase.thrift that's it! gen-nodejs will be generated. copy these files into your working directory(where test.coffee is in) ### use with node. -
blmarket revised this gist
Nov 6, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,7 @@ move to the directory and execute thrift --gen js:node Hbase.thrift that's it! gen-nodejs will be generated. copy these files into your working directory(where test.coffee in) ### use with node. -
blmarket created this gist
Nov 6, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ HBase with thrift using node.js ------------------------------- ## Install (on Mac OS X) ### homebrew Trivial ### hbase used https://github.com/seomoz/homebrew-cloudera ### thrift due to build failure in default formula(my OS X clang doesn't have TR1), used https://gist.github.com/duedal/6934417 brew install https://gist.github.com/duedal/6934417/raw/d802f592d66c5bb9908db8a7c75ae57262dafa06/thrift.rb (you may need github api key because it accesses github several times) ### generate HBase.js(and more) For me, thrift file is on /usr/local/Cellar/hbase/0.94.6-cdh4.3.0/libexec/src/main/resources/org/apache/hadoop/hbase/thrift move to the directory and execute thrift --gen js:node Hbase.thrift that's it! gen-nodejs will be generated. ### use with node. npm install thrift coffee test.coffee This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,53 @@ util = require 'util' thrift = require 'thrift' hbase = require './Hbase' {Mutation} = require './Hbase_types' HOST = 'ec2-54-249-207-247.ap-northeast-1.compute.amazonaws.com' PORT = 9090 inspect = (obj) -> util.inspect obj, { colors: true, depth: null } debug = (err, res) -> console.log err? && err || inspect(res) conn = thrift.createConnection HOST, PORT, { transport: thrift.TBufferedTransport protocol: thrift.TBinaryProtocol } conn.on 'connect', -> console.log 'connected' client = thrift.createClient(hbase, conn) # client.getTableNames (err, data) -> # console.log err # console.log data # client.getColumnDescriptors 'item_id_test', (err, data) -> # console.log err # console.log data client.mutateRow 'item_id_test', 'asdf', [ new Mutation({ column: 'f1:test1', value: 'value1' }) new Mutation({ column: 'f1:test2', value: 'value2' }) ], {}, -> console.log arguments return client.getRow 'item_id_test', 'asdf', {}, debug # client.getTableRegions 'user_action_log', (err, list) -> # for region in list # toBuffer = (value) -> # ret = new Buffer(8) # ret.fill(0) # ret.write value, null, null, 'binary' # return ret # console.log JSON.stringify(region.startKey), toBuffer(region.startKey) # console.log JSON.stringify(region.endKey), toBuffer(region.endKey) # # console.log toBuffer(region.startKey) # # console.log toBuffer(region.endKey) conn.on 'error', (err) -> console.log 'error', err console.log hbase