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

@tg1518/hbase

v0.6.21

Published

HBase client using the REST connector

Downloads

4

Readme

Build Status

Node.js HBase is a Node.JS client for the Apache HBase database. It use the Rest API (Stargate) to communicate with HBase. Currently, all the API is implemented and the data exchange format is JSON (but protocol buffer could follow).

Apache HBase is part of the Hadoop ecosystem. It describes itself as the Hadoop database optimized for random, realtime read/write access to big data. It is an open-source, distributed, versioned, column-oriented store modeled after Google Bigtable.

Client features include:

  • Intuitive API following Apache HBase naming conventions
  • Documentation and tests
  • Full Implementation of the REST API
  • Transparent encoding/decoding of values
  • Scanner and filter support implementing the stream.Readable API
  • Kerberos Support
  • 新增命名空间支持

About HBase

Apache HBase is part of the Hadoop ecosystem from the Apache Software Foundation. It is a column oriented database (think NoSql) that really scale and is modelled after Google papers and its BigTable database.

Installing

From your project directoy, via npm:

npm install @tg1518/hbase
# Or without the krb5 optional dependency
npm install @tg1518/hbase --no-optional

Documentation

Quick example

The following code initialise a new HBase instance, create a table and a column family, insert a record and read it.

const hbase = require('hbase')
// Instantiate a new client
client = hbase({ host: '127.0.0.1', port: 8080 })
// Create a table
client
.table('my_table' )
.create('my_column_family', function(err, success){
  // Insert a record
  client
  .table('my_table' )
  .row('my_row')
  .put('my_column_family:my_column', 'my value', function(err, success){
    // Read a record
    client
    .table('my_table' )
    .row('my_row')
    .get('my_column_family', function(err, [cell]){
      // Validate the result
      assert(cell.key, 'my_row')
      assert(cell.column, 'my_column_family:my_column')
      assert(cell.$, 'my value')
    })
  })
})

Or shortly as:

// Instantiate a new client
require('hbase')({ host: '127.0.0.1', port: 8080 })
// Create a table
.table('my_table' )
.create('my_column_family', function(err, success){
  // Insert a record
  this.put('my_column_family:my_column', 'my value', function(err, success){
    // Read a record
    this.get('my_column_family', function(err, [[cell]]){
      // Validate the result
      // ...
    })
  })
})

Using Kerberos/SPNEGO

Options accepts a krb5 object. Password and keytab authentication are supported. Refer to the krb5 package for additionnal information on how to configure the krb5 option.

Using a keytab:

const hbase = require('hbase');
hbase({
  host: '127.0.0.1',
  port: 8080,
  "krb5": {
    "principal": "{username}@{REALM}",
    "keytab": "{path/to/keytab}",
    "service_principal": "HTTP@{fqdn}"
  }
})
.version();

Using a password:

const hbase = require('hbase');
hbase({
  host: '127.0.0.1',
  port: 8080,
  "krb5": {
    "principal": "{username}@{REALM}",
    "password": "{password}",
    "service_principal": "HTTP@{fqdn}"
  }
})
.version();

命名空间


//获取所有命名空间列表
client.spaces((error, version) => {
    console.info(version)
})

//移除指定命名空间 [注意:该命名空间下不能存在表,需要先删除表]
client.removeSpace("test",(error, version) => {
    console.info(error,version)
})

//创建命名空间
client.createSpace("test",(error, version) => {
    console.info(error,version)
})
//获取命令空间信息
client.spaceInfo("test",(error, version) => {
    console.info(error,version)
})

//获取指定命令空间下的表列表
client.spaceTable("test",(error, version) => {
    console.info(error,version)
})

//添加指定命令空间下的表
client.table("test:testT1").update({
    ColumnSchema: [
        {
            name: 'age'
        },
        {
            name: 'name'
        },
        {
            name: 'id'
        }
    ]
},(error, success) => {
    console.info('Table created: ' + (success ? 'yes' : 'no'))
    // console.error(error)
})

Scanner and Filters

The scanner implement the stream.Readable API. For ease of usage, an optional callback argument may be provided. For example:

client
.table('node_table')
.scan({
  startRow: 'my_row',
  maxVersions: 1
}, function(err, rows){
  console.log(err, rows);
});

is equivalent to:

const rows = [];
scanner = client
.table('node_table')
.scan({
  startRow: 'my_row',
  maxVersions: 1
});
scanner.on('readable', function(){
  while(chunk = scanner.read()){
    rows.push(chunk);
  }
});
scanner.on('error', function(err){
  console.log(err);
});
scanner.on('end', function(){
  console.log(rows);
});

It can be quite a pain to figure out what options can be sent with a scanner request. You will find a lot of examples inside the Scanner test and also look at the examples published by Marc Trudel.

More documentation

Related projects

Contributors

This package is developed by Adaltas. 原作者git地址 git.