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 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-thrift-hbase

v0.12.1

Published

Easy to CRUD for hbase by node-thrift-hbase

Readme

#Use thrift2 to CRUD for hbase#

##Get ready for start hadoop hbase thrift2

  • start-dfs.sh

  • start-hbase.sh

  • hbase-daemon.sh start thrift2

####if you run command example display by : jps####

2423 DataNode

2746 ThriftServer

4854 Jps

2349 NameNode

2668 HMaster

2513 SecondaryNameNode

##1 . create Hbase instance client##

var HBase = require('node-thrift-hbase');

var config = {

    host: 'master',

    port: 9090

};

var hbaseClient = HBase.client(config);

#2 . Use get or getRow function to query data

##get(table,get,callback)

var get = hbaseClient.Get('row1');    //row1 is rowKey

//get.addFamily('cf');  //add not found column is error

//get.addFamily('info');

//get.addColumn('info','name');   //this replace addFamily

//get.addTimestamp('info','name',1414385447707);

//get.addColumn('ecf','name');

//get.setMaxVersions(3);  //default 1

//or Recommend this function add

get.add('info');    //get all family info

get.add('info','name');   //get family and qualifier info:name

get.add('info','name',1414385447707); //get info:name and timestamp

get.add('ecf'); //get other family ecf

get.add('ecf','name');  //get family and qualifier ecf:name

get.add('ecf','name',1414385555890); //get info:name and timestamp


hbaseClient.get('users',get,function(err,data){ 
    //get users table

    if(err){
        console.log('error:',err);
        return;
    }
    
    console.log(err,data);

});

##getRow(table,rowKey,columns,versions,callback)##

###introduce getRow function###

  • hbaseClient.getRow = function (table,rowKey,columns,versions,callback) {

    • //table is must
    • //rowKey is must
    • //columns is not must,the default is get all row value
    • //versions is not must, the default is 1 ,if have this params,string is auto cost number
  • }


###getRow( table, rowKey, callback)###

hbaseClient.getRow('users','row1',function(err,data){ 
    //get users table

    if(err){
        console.log('error:',err);
        return;
    }

    console.log(err,data);

});

###getRow( table, rowKey, columns, callback)###


hbaseClient.getRow('users','row1',['info:name','ecf'],function(err,data){ 
    //get users table

    if(err){
        console.log('error:',err);
        return;
    }

    console.log(err,data);

});

###getRow( table, rowKey, columns, versions, callback)###


hbaseClient.getRow('users','row1',['info:name','ecf'], 2 ,function(err,data){ 
    //get users table

    if(err){
        console.log('error:',err);
        return;
    }

    console.log(err,data);

});
  • //'users' is table name

  • //row1 is rowKey

  • //[] is family or family qualifier

  • //['info:name','info:tel'] is right. info is family, name and tel is qualifier

  • //['info:name','ecf'] is rigth too, info is family , ecf is family

  • //function is callback function

  • //2 is Maxversion ,default is 1

##put( table, put, callback)##

var put = hbaseClient.Put('row1');    //row1 is rowKey

put.add('info','click','100'); // 100 must be string

put.add('info','name','beijing',new Date().getTime());

put.add('ecf','name','zhudaxian');

hbaseClient.put('users',put,function(err){ //put users table

    if(err){

        console.log('error:',err);

        return;

    }

    console.log(err,'put is successfully');

});
  • //info and ecf are family

  • //click and name is qualifier

  • //beijing is value

  • timestamp is now Date() and this value also by coustom

##putRow(table,row,columns,value,callback)##


hbaseClient.putRow('users','row1','info:name','phoneqq.com',function(err){ 
    //put users table
    
    if(err){
        console.log('error:',err);
        return;
    }
    
    console.log(err,'put is successfully');
});

##putRow(table,row,columns,value,timestamp,callback)##


hbaseClient.putRow('users','row1','info:name','phoneqq.com',1414140874929,function(err){ 
    //put users table
    
    if(err){
        console.log('error:',err);
        return;
    }
    
    console.log(err,'put is successfully');
});
  • //'users' is table name

  • //row1 is rowKey

  • //'info:name' is right. info is family, name is qualifier

  • //function is callback function

  • //phoneqq.com is value

  • //1414140874929 is timestamp ,not must,if not so auto generate new Date()

##inc( table, inc, callback)##


var inc = hbaseClient.Inc('row1');    //row1 is rowKey

inc.add('info','counter');

inc.add('info','counter2');

hbaseClient.inc('users',inc,function(err,data){ 
    //inc users table

    if(err){
        console.log('error:',err);
        return;
    }

    console.log(err,data);

});

##incRow( table, rowKey, family:qualifier, callback)##


hbaseClient.incRow('users','row1','info:counter',function(err,data){ //inc users table

    if(err){
        console.log('error:',err);
        return;
    }

    console.log(err,data);
    //data is return new counter object
});

##del( table, del, callback)##


var del = hbaseClient.Del('row1');    //row1 is rowKey

//del.addFamily('ips');   //delete family ips
//del.addColumn('info','click2'); //delete family and qualifier info:click2
//del.addTimestamp('info','click3',1414136046864); //delete info:click3 and timestamp

//or Recommend this function add

del.add('info');    //delete all family info
del.add('info','name');   //delete family and qualifier info:name
del.add('info','tel',1414136046864); //delete info:tel and timestamp

del.add('ecf'); //delete other family ecf
del.add('ecf','name');  //delete family and qualifier ecf:name
del.add('ecf','tel',1414136119207); //delete info:tel and timestamp

//del.add('ips'); //is error ,because this family ips is not exist

hbaseClient.del('users',del,function(err){ //put users table
    if(err){
        console.log('error:',err);
        return;
    }
    console.log(err,'del is successfully');
});

##delRow( table, rowKey, family:qualifier, callback)##


hbaseClient.delRow('users','row1','info:name',function(err){ 
    //put users table
    
    if(err){
        console.log('error:',err);
        return;
    }
    
    console.log(err,'del is successfully');
});

##delRow( table, rowKey, family:qualifier, timestamp, callback)##


hbaseClient.delRow('users','row1','info:name',1414137991649,function(err){ 
    //put users table
    
    if(err){
        console.log('error:',err);
        return;
    }
    
    console.log(err,'del is successfully');
});

var scan = hbaseClient.Scan();

//get.addFamily('cf');  //add not found column is error

//scan.addFamily('info');  //add all family

//scan.addStartRow('row1');   //start rowKey

//scan.addStopRow('row1p');   //stop rowKey

//scan.addColumn('info','name');  //add family and qualifier

//scan.addColumn('ecf','name');   //add other family

//scan.setMaxVersions(1); //set maxversions

//scan.addNumRows(10); //search how much number rows

//or Recommend this function add

scan.addStartRow('row1');   //start rowKey

scan.addStopRow('row1p');   //stop rowKey

scan.add('info');    //scan all family info

scan.add('info','name');   //scan family and qualifier info:name

scan.add('ecf'); //scan other family ecf

scan.add('ecf','name');  //scan family and qualifier ecf:name

scan.setMaxVersions(1); //set maxversions

scan.addNumRows(10); //search how much number rows

hbaseClient.scan('users',scan,function(err,data){ //get users table
    if(err){
        console.log('error:',err);
        return;
    }
    console.log(err,data);

//    console.log(err,data[0].columnValues);
});

##scanRow(table,startRow,stopRow,columns,numRows,callback)##

  • //table is search tableName,must

  • //startRow is first rowKey,must

  • //stopRow is end rowKey,must

  • //columns is family or family and qualifier,is not must //example : ['info:name','ecf']

  • //numRows is count rows, is not must,if none the default is 10.

  • //callback is function

##scanRow(table,startRow,stopRow,callback)##


hbaseClient.scanRow('users','row1','row1b',function(err,data){ 
    //get users table
    
    if(err){
        console.log('error:',err);
        return;
    }
    
    console.log(err,data);
});

##scanRow(table,startRow,stopRow,colmuns,callback)##


hbaseClient.scanRow('users','row1','row1b',['info:name','ecf'],function(err,data){ 
    //get users table
    
    if(err){
        console.log('error:',err);
        return;
    }
    
    console.log(err,data);
});

##scanRow(table,startRow,stopRow,columns,numRows,callback)##


hbaseClient.scanRow('users','row1','row1b',['info:name','ecf'],10,function(err,data){ 
    //get users table
    
    if(err){
        console.log('error:',err);
        return;
    }
    
    console.log(err,data);
});