UNPKG

node-thrift2-hbase

Version:
58 lines (47 loc) 1.76 kB
'use strict'; var config = { hosts: ["master"], port: "9090", }; var HBase = require('../src/service')(config); var get = HBase.Get('row1'); //row1 is rowKey get.addFamily('cf'); // get.add('cf'); identical to addFamily get.addColumn('info', 'name'); // get.add('info', 'name'); identical to addColumn get.addTimestamp('info', 'name', 1414385447707); // get.add('info', 'name', 1414385447707); identical to addTimestamp get.setMaxVersions(3); //last ten days as timerange get.setTimeRange({ minStamp: Date.now() - 10 * 24 * 60 * 60 * 1000, maxStamp: Date.now() }); HBase.getAsync('users', get) .then(function (data) { console.log("Data for user with key 'row1':"); console.log('=============================='); _.each(data[0].columnValues, function (colVal, index) { console.log('Column value #', index); console.log('family:', colVal.family.toString()); console.log('qualifier:', colVal.qualifier.toString()); console.log('value:', colVal.value.readInt32BE(0, 4)); }); }) .catch(function (err) { console.log('error:', err); }); HBase.get('users', get, function (err, data) { //get users table if (err) { console.log('error:', err); return; } console.log("Data for user with key 'row1':"); console.log('=============================='); _.each(data[0].columnValues, function (colVal, index) { console.log('Column value #', index); console.log('family:', colVal.family.toString()); console.log('qualifier:', colVal.qualifier.toString()); console.log('value:', colVal.value.readInt32BE(0, 4)); }); });