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

thrift-hive

v0.0.7

Published

Hive client using the Apache Thrift RPC system

Downloads

73

Readme

Thrift Hive - Hive client with multi versions support and a Readable Stream API.

The project export the Hive API using Apache Thrift RPC system. It support multiple versions and a readable stream API.

Installation

    npm install thrift-hive

Hive Client

We've added a function hive.createClient to simplify coding. However, you are free to use the raw Thrift API. The client take an options object as its argument andexpose an execute and a query methods.

Available options

  • version
    default to '0.7.1-cdh3u2'
  • server
    default to '127.0.0.1'
  • port
    default to 10000
  • timeout
    default to 1000 milliseconds

Available API

  • client
    A reference to the thrift client returned by thrift.createClient
  • connection
    A reference to the thrift connection returned by thrift.createConnection
  • end([callback])
    Close the Thrift connection
  • execute(query, [callback])
    Execute a query
  • query(query, [size])
    Execute a query and return its results as an array of arrays (rows and columns). The size argument is optional and indicate the number of row to return on each fetch.
    hive = require 'thrift-hive'
    # Client connection
    client = hive.createClient
        version: '0.7.1-cdh3u2'
        server: '127.0.0.1'
        port: 10000
        timeout: 1000
    # Execute
    client.execute 'USE default', (err) ->
        console.log err.message if err
        client.end()

Hive Query

The client.query function implement the EventEmitter API.

The following events are emitted:

  • row
  • row-first
  • row-last
  • error
  • end

The client.query functionreturn a Node Readable Stream. It is possible to pipe the data into a Writable Stream but it is your responsibility to emit the data event, usually inside the row event.

Raw versus sugar API

Here's an exemple using the raw API

    var assert     = require('assert');
    var thrift     = require('thrift');
    var transport  = require('thrift/lib/thrift/transport');
	var ThriftHive = require('../lib/0.7.1-cdh3u2/ThriftHive');
	// Client connection
	var options = {transport: transport.TBufferedTransport, timeout: 1000};
	var connection = thrift.createConnection('127.0.0.1', 10000, options);
	var client = thrift.createClient(ThriftHive, connection);
    // Execute query
    client.execute('show databases', function(err){
        assert.ifError(err);
        client.fetchAll(function(err, databases){
            assert.ifError(err);
            console.log(databases);
            connection.end();
        });
    });

Here's an exemple using our sugar API

    var assert = require('assert');
    var hive = require('thrift-hive');
    // Client connection
    var client = hive.createClient({
        version: '0.7.1-cdh3u2',
        server: '127.0.0.1',
        port: 10000,
        timeout: 1000
    });
    // Execute query
    client.query('show databases')
    .on('row', function(database){
        console.log(database);
    })
    .on('end', function(err){
        assert.ifError(err);
        client.end();
    });