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

hypertable-driver

v1.98.4

Published

hypertable-driver

Downloads

9

Readme

hypertable-driver

hypertable-driver

attention

node -v >=6.9.1 Use for hytable 0.9.8

use

npm install hypertable-driver

#website www.hypertable.com

#api http://www.hypertable.com/documentation/reference_manual/thrift_api

instructions & example

##hyperTableClient

var HyperTableDriver = require('hypertable-driver');
var htConfig = {
	host:'121.43.190.15',
	port:15867,
	timeout:3000 //option
};
var hyperTableClient = new HyperTableDriver.HyperTableClient(htConfig);
var client = hyperTableClient.getClient();

##HyperTableNameSpace

var hyperTableNameSpace = new HyperTableDriver.HyperTableNameSpace(client);

hyperTableNameSpace.namespace_exists('test').then((result) => {
 console.log(result);
});

hyperTableNameSpace.namespace_create('test').then((result) => {
	//this is async,attention!
	console.log(result);
});

var namespace = null;
hyperTableNameSpace.namespace_open('/')
.then((result) => {
	namespace = result;
	return hyperTableNameSpace.namespace_get_listing(namespace);
})
.then((list)=>{
	console.log(list);
	return hyperTableNameSpace.namespace_close(namespace);
})
.then((result)=>{
	console.log(result);
});

##HyperTableTable

var namespace = null;
var hyperTableTable = null;
var hyperTableNameSpace = new HyperTableDriver.HyperTableNameSpace(client);

hyperTableNameSpace.namespace_open('test')
.then((result)=>{
	namespace = result;
	var accessGroupOptions = new HyperTableDriver.pojso.AccessGroupOptions();
	var columnFamilyOptions = new HyperTableDriver.pojso.ColumnFamilyOptions();
	var accessGroupSpec = new HyperTableDriver.pojso.AccessGroupSpec();
	var columnFamilySpec = new HyperTableDriver.pojso.ColumnFamilySpec();

	var defaultAccessGroupOptions = accessGroupOptions.setBlocksize(65536)
	.getAccessGroupOptions();
	var defaultColumnFamilyOptions = columnFamilyOptions.setMaxVersions(3)
	.getColumnFamilyOptions();
	var accessGroups ={};
	var columnFamilies ={};

	var ag_normal = accessGroupSpec.setName('ag_normal')
	.setDefaults(defaultColumnFamilyOptions)
	.getAccessGroupSpec();
	accessGroups.ag_normal = ag_normal;


	var fastAccessGroupOptions = accessGroupOptions
	.setInMemory(true)
	.getAccessGroupOptions();

	var ag_fast = accessGroupSpec.setName('ag_fast')
	.setOptions(fastAccessGroupOptions)
	.getAccessGroupSpec();
	accessGroups.ag_fast = ag_fast;

	var secureAccessGroupOptions = accessGroupOptions
	.deleteByName('in_memory')
	.setReplication(5)
	.getAccessGroupOptions();

	var ag_secure = accessGroupSpec.setName('ag_secure')
	.setOptions(secureAccessGroupOptions)
	.getAccessGroupSpec();
	accessGroups.ag_secure = ag_secure;

	var name = columnFamilySpec.setName('name')
	.setAccessGroup('ag_normal')
	.setOptions(defaultColumnFamilyOptions)
	.getColumnFamilySpec();
	var age = columnFamilySpec.setName('age')
	.setAccessGroup('ag_fast')
	.getColumnFamilySpec();
	var sex = columnFamilySpec.setName('sex')
	.setAccessGroup('ag_secure')
	.getColumnFamilySpec();
	columnFamilies.name = name;
	columnFamilies.age = age;
	columnFamilies.sex = sex;

	var schema = new HyperTableDriver.pojso.Schema();
	var schemaObj = schema
	.setAccessGroups(accessGroups)
	.setColumnFamilies(columnFamilies)
	.setAccessGroupDefaults(defaultAccessGroupOptions)
	.setColumnFamilyDefaults(defaultColumnFamilyOptions)
	.getSchema();
	// console.log(schema);return;
	hyperTableTable = new HyperTableDriver.HyperTableTable(client,namespace);
	return hyperTableTable.table_create('testTable2',schemaObj);
})
.then((result)=>{
	console.log(result);
});

hyperTableNameSpace.namespace_open('test')
.then((result)=>{
	namespace = result;
	hyperTableTable = new HyperTableDriver.HyperTableTable(client,namespace);
	return hyperTableTable.get_schema('testTable2');
})
.then((schemaObj)=>{
	//modify 'age' to 'birthday'
	var cfSpec = schemaObj.column_families['age'];
    delete schemaObj.column_families['age'];
    cfSpec.name = 'birthday';
    schemaObj.column_families['birthday'] = cfSpec;

    //add 'city'
    var columnFamilySpec = new HyperTableDriver.pojso.ColumnFamilySpec();
    cfSpec = columnFamilySpec.setName('city')
    .setAccessGroup('ag_normal')
    .getColumnFamilySpec();
    schemaObj.column_families['city'] = cfSpec;

	return hyperTableTable.table_alter('testTable2',schemaObj);
})
.then((result)=>{
	console.log(result);
})
.catch((err) => {
  console.log(err);
});


hyperTableNameSpace.namespace_open('test')
.then((result)=>{
	namespace = result;
	hyperTableTable = new HyperTableDriver.HyperTableTable(client,namespace);
	//or hyperTableTable.table_drop('testTable2',ifExists=true);
	return hyperTableTable.table_drop('testTable2');
})
.then((result)=>{
	console.log(result);
})

##HyperTableCell

var namespace = null;
var hyperTableCell = null;
var hyperTableNameSpace = new HyperTableDriver.HyperTableNameSpace(client);

hyperTableNameSpace.namespace_open('test')
.then((result)=>{
	namespace = result;
	hyperTableCell = new HyperTableDriver.HyperTableCell(client,namespace);
	var key = new HyperTableDriver.pojso.Key();
	var cell = new HyperTableDriver.pojso.Cell();
	var keyObj1 = key.setRow('user3').setColumnFamily('name').setColumnQualifier('column_qualifier1').getKey();
	var keyObj2 = key.setRow('user2').setColumnFamily('name').setColumnQualifier('column_qualifier2').getKey();
	var cells = [];
	var cellObj1 = cell.setKey(keyObj1).setValue('test1').getCell();
	var cellObj2 = cell.setKey(keyObj2).setValue('test2').getCell();
	cells.push(cellObj1);
	cells.push(cellObj2);
	return hyperTableCell.set_cells('user',cells);
})
.then((result)=>{
	console.log(result);
});

hyperTableNameSpace.namespace_open('test')
.then((result)=>{
	namespace = result;
	hyperTableCell = new HyperTableDriver.HyperTableCell(client,namespace);
	var scanSpec = new HyperTableDriver.pojso.ScanSpec();
	var scanSpecObj = scanSpec.setColumns(['name','age']).getScanSpec();
	return hyperTableCell.get_cells('user',scanSpecObj);
})
.then((result)=>{
	console.log(result);
});


hyperTableNameSpace.namespace_open('test')
.then((result)=>{
	namespace = result;
	hyperTableCell = new HyperTableDriver.HyperTableCell(client,namespace);
	var scanSpec = new HyperTableDriver.pojso.ScanSpec();
	var scanSpecObj = scanSpec.setColumns(['name','age']).getScanSpec();
	return hyperTableCell.get_cells('user',scanSpecObj);
})
.then((result)=>{
	console.log(result);
});


hyperTableNameSpace.namespace_open('test')
.then((result)=>{
	namespace = result;
	hyperTableCell = new HyperTableDriver.HyperTableCell(client,namespace);
	cells_as_arrays = [];
	cell_as_array = ['user4', 'name', 'column_qualifier3', 'zl'];
	cells_as_arrays.push(cell_as_array);
	cell_as_array = ['user4', 'age', '', '16'];
	cells_as_arrays.push(cell_as_array);
	return hyperTableCell.set_cells_as_arrays('user',cells_as_arrays);
})
.then((result)=>{
	console.log(result);
});

hyperTableNameSpace.namespace_open('test')
.then((result)=>{
	namespace = result;
	hyperTableCell = new HyperTableDriver.HyperTableCell(client,namespace);
	var scanSpec = new HyperTableDriver.pojso.ScanSpec();
	var scanSpecObj = scanSpec.setColumns(['name','age']).getScanSpec();
	return hyperTableCell.get_cells_as_arrays('user',scanSpecObj);
})
.then((result)=>{
	console.log(result);
});

hyperTableNameSpace.namespace_open('test')
.then((result)=>{
	namespace = result;
	hyperTableCell = new HyperTableDriver.HyperTableCell(client,namespace);
	var writer = new HyperTableDriver.pojso.Writer(1024);
	var timestamp = new HyperTableDriver.pojso.Timestamp();
	writer.add('user0', 'name', 'column_qualifier4',timestamp.setTime(1483758549000).getTimestamp(), 'zl');
	writer.add('user5', 'age', 'column_qualifier5', null, '24');

	var buffer = writer.getBuffer();
	return hyperTableCell.set_cells_serialized('user',buffer);
})
.then((result)=>{
	console.log(result);
})
.catch((err) => {
  console.log(err);
});

hyperTableNameSpace.namespace_open('test')
.then((result)=>{
	namespace = result;
	hyperTableCell = new HyperTableDriver.HyperTableCell(client,namespace);
	var scanSpec = new HyperTableDriver.pojso.ScanSpec();
	var scanSpecObj = scanSpec.setColumns(['name','age']).getScanSpec();
	return hyperTableCell.get_cells_serialized('user',scanSpecObj);
})
.then((result)=>{
	var reader = new HyperTableDriver.pojso.Reader(result);
	reader.next()
    while (reader.next())
        console.log(reader.getCell().toString());
});

##hyperTableMutator

var namespace = null;
var hyperTableMutator = null;
var mutator = null;
var hyperTableNameSpace = new HyperTableDriver.HyperTableNameSpace(client);
hyperTableNameSpace.namespace_open('test')
.then((result)=>{
	namespace = result;
	hyperTableMutator = new HyperTableDriver.HyperTableMutator(client,namespace);
	var flags =0;
	var flush_interval = 0;
	return hyperTableMutator.mutator_open('user',flags,flush_interval);
})
.then((result)=>{
	mutator = result;
	var key = new HyperTableDriver.pojso.Key();
	var cell = new HyperTableDriver.pojso.Cell();
	var keyObj1 = key.setRow('user2').setColumnFamily('name')
	.setColumnQualifier('column_qualifier4')
	.getKey();
	var keyObj2 = key.setRow('user3').setColumnFamily('name')
	.deleteByName('timestamp')
	.setColumnQualifier('column_qualifier5')
	.getKey();
	var cells = [];
	var cellObj1 = cell.setKey(keyObj1).setValue('test1').getCell();
	var cellObj2 = cell.setKey(keyObj2).setValue('test2').getCell();
	cells.push(cellObj1);
	cells.push(cellObj2);
	return hyperTableMutator.mutator_set_cells(mutator,cells);
})
.then((result)=>{
	var key = new HyperTableDriver.pojso.Key();
	var cell = new HyperTableDriver.pojso.Cell();
	var keyObj1 = key.setRow('user2')
	.setFlag(HyperTableDriver.pojso.KeyFlag.DELETE_ROW)
	.getKey();
	var keyObj2 = key.setRow('user3').getKey();
	var cells = [];
	var cellObj1 = cell.setKey(keyObj1).getCell();
	var cellObj2 = cell.setKey(keyObj2).getCell();
	cells.push(cellObj1);
	cells.push(cellObj2);
	return hyperTableMutator.mutator_set_cells(mutator,cells);
})
.then((result)=>{
	console.log(result);
	return hyperTableMutator.mutator_flush(mutator);
})
.then((result)=>{
	console.log(result);
	return hyperTableMutator.mutator_close(mutator);
})
.then((result)=>{
	console.log(result);
})
.catch((err) => {
  console.log(err);
});

##HyperTableScanner

var namespace = null;
var hyperTableScanner = null;
var scanner = null;
var hyperTableNameSpace = new HyperTableDriver.HyperTableNameSpace(client);
hyperTableNameSpace.namespace_open('zytest')
.then((result)=>{
	namespace = result;
	hyperTableScanner = new HyperTableDriver.HyperTableScanner(client,namespace);
	var scanSpec = new HyperTableDriver.pojso.ScanSpec();
	var scanSpecObj = scanSpec.setColumns(['name','age']).getScanSpec();
	return hyperTableScanner.scanner_open('user',scanSpecObj);
})
.then((result)=>{
	scanner = result;
	return hyperTableScanner.scanner_get_cells(scanner);
})
.then((result)=>{
	console.log(result);
	return hyperTableScanner.scanner_close(scanner);
})
.then((result)=>{
	console.log(result);
});

##HyperTableHql

var namespace = null;
var hyperTableHql = null;
var hyperTableMutator = null;
var mutator = null;
var hyperTableScanner = null;
var scanner = null;
var hyperTableNameSpace = new HyperTableDriver.HyperTableNameSpace(client);
hyperTableNameSpace.namespace_open('zytest')
.then((result)=>{
	namespace = result;
	hyperTableHql = new HyperTableDriver.HyperTableHql(client,namespace);
	var hql = "GET LISTING";
	return hyperTableHql.hql_query(hql);
})
.then((result)=>{
	console.log(result);
	var hql = "SELECT * from user WHERE ROW = 'user1'";
	return hyperTableHql.hql_query(hql);
})
.then((result)=>{
	console.log(result);
	var hql = "INSERT INTO user VALUES('user1','age','21'),('user2','age','22')";
	return hyperTableHql.hql_exec(hql);
})
// hql_exec(mutator)
.then((result)=>{
	console.log(result);
	var hql = "INSERT INTO user VALUES('user3','age','21'),('user4','age','22')";
	return hyperTableHql.hql_exec(hql,true);
})
.then((result)=>{
	console.log(result);
	mutator = result.mutator;
	hyperTableMutator = new HyperTableDriver.HyperTableMutator(client,namespace);
	var key = new HyperTableDriver.pojso.Key();
	var cell = new HyperTableDriver.pojso.Cell();
	var keyObj1 = key.setRow('user2').setColumnFamily('name')
	.setColumnQualifier('column_qualifier4')
	.getKey();
	var keyObj2 = key.setRow('user3').setColumnFamily('name')
	.deleteByName('timestamp')
	.setColumnQualifier('column_qualifier5')
	.getKey();
	var cells = [];
	var cellObj1 = cell.setKey(keyObj1).setValue('test1').getCell();
	var cellObj2 = cell.setKey(keyObj2).setValue('test2').getCell();
	cells.push(cellObj1);
	cells.push(cellObj2);
	return hyperTableMutator.mutator_set_cells(mutator,cells);
})
.then((result)=>{
	console.log(result);	
	return hyperTableMutator.mutator_flush(mutator);
})
.then((result)=>{
	console.log(result);	
	return hyperTableMutator.mutator_close(mutator);
})
// hql_exec(scanner)
.then((result)=>{
	console.log(result);	
	var hql = "SELECT * from user WHERE ROW = 'user3'";
	return hyperTableHql.hql_exec(hql,false,true);
})
.then((result)=>{
	console.log(result);
	scanner = result.scanner;
	hyperTableScanner = new HyperTableDriver.HyperTableScanner(client,namespace);
	return hyperTableScanner.scanner_get_cells(scanner);
})
.then((result)=>{
	console.log(result);
	return hyperTableScanner.scanner_close(scanner);
})
.then((result)=>{
	console.log(result);
	return hyperTableScanner.scanner_close(scanner);
})