{"_id":"thrift-hive","_rev":"13-9d90299dc88acaf7da0a44cb422bdb26","name":"thrift-hive","description":"Hive client using the Apache Thrift RPC system","dist-tags":{"latest":"0.0.7"},"versions":{"0.0.3":{"name":"thrift-hive","description":"Hive client using the Apache Thrift RPC system","version":"0.0.3","author":{"name":"David Worms"},"contributors":[{"name":"David Worms","email":"david@adaltas.com"}],"dependencies":{"coffee-script":"latest","thrift":"latest"},"devDependencies":{},"keywords":[],"main":"index","engines":{"node":">= 0.4.7"},"_npmUser":{"name":"david","email":"david@adaltas.com"},"_id":"thrift-hive@0.0.3","_engineSupported":true,"_npmVersion":"1.0.105","_nodeVersion":"v0.6.1","_defaultsLoaded":true,"dist":{"shasum":"9ff517b6deca1b6d0e64787773227232c8c0312d","tarball":"https://registry.npmjs.org/thrift-hive/-/thrift-hive-0.0.3.tgz","integrity":"sha512-gunE4n3h+7zA3D1mhqsBmGGSvO0Bf+mhdGxBVJYqtYk8BNwuYq/Ze675L/2ojVS07l1BenDgGBoFzw4BTjwpjg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD0yo7mpAAf7wAGWNbi2mwIyeyHCXcsn0bTAivN+25vVAIgfRXQ6Vlk57o/10LTHsqTS/DKU4KYwt6OnS3MYKmHSAI="}]},"maintainers":[{"name":"david","email":"david@adaltas.com"}]},"0.0.4":{"name":"thrift-hive","description":"Hive client using the Apache Thrift RPC system","version":"0.0.4","author":{"name":"David Worms"},"contributors":[{"name":"David Worms","email":"david@adaltas.com"}],"dependencies":{"coffee-script":"latest","thrift":"latest","each":"latest"},"devDependencies":{},"keywords":[],"main":"index","engines":{"node":">= 0.4.7"},"_npmUser":{"name":"david","email":"david@adaltas.com"},"_id":"thrift-hive@0.0.4","_engineSupported":true,"_npmVersion":"1.0.105","_nodeVersion":"v0.6.1","_defaultsLoaded":true,"dist":{"shasum":"cb1f9c7311ae9698f5f0fc734e49dd0eca88cb9f","tarball":"https://registry.npmjs.org/thrift-hive/-/thrift-hive-0.0.4.tgz","integrity":"sha512-Mw3eq3ydQFL39tPeI+dDcYZ+w6xatyDZyYN2zOslX8RyVgVzZ01U8LAxFcqpshCd3XcdnbX8Huwyt2l9g3uD9g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEQx6zK9Fptf+4W8LUdF5J/YZNOBJlX3AYexWP2ibkE6AiBYETBO9gXvK0+9zmPi7YeCCmQ56VMasIR4Rz0Riaeg0A=="}]},"maintainers":[{"name":"david","email":"david@adaltas.com"}]},"0.0.5":{"name":"thrift-hive","description":"Hive client using the Apache Thrift RPC system","version":"0.0.5","author":{"name":"David Worms"},"contributors":[{"name":"David Worms","email":"david@adaltas.com"}],"dependencies":{"coffee-script":"latest","thrift":"latest","each":"latest"},"devDependencies":{},"keywords":[],"main":"index","engines":{"node":">= 0.4.7"},"_npmUser":{"name":"david","email":"david@adaltas.com"},"_id":"thrift-hive@0.0.5","_engineSupported":true,"_npmVersion":"1.0.105","_nodeVersion":"v0.6.1","_defaultsLoaded":true,"dist":{"shasum":"29db10d90c0856554f34616b4f89e73186eac930","tarball":"https://registry.npmjs.org/thrift-hive/-/thrift-hive-0.0.5.tgz","integrity":"sha512-LLXHbFCuvEmSIklnJdCI0LUVdDNLwwWAopzsHerVqqhCREBDQyIDLK3by5LANWb5wrwSVGrJS1JaDW4MzSeopQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEDtMuwlq4BdJiRGThColDcqAULvCC/fKqZ9x6VG+0BoAiAmFjJkoSBP3sGBe+3SmIytdmksrZpVU3LlUPtBgN5KJg=="}]},"maintainers":[{"name":"david","email":"david@adaltas.com"}]},"0.0.6":{"name":"thrift-hive","description":"Hive client using the Apache Thrift RPC system","version":"0.0.6","author":{"name":"David Worms"},"contributors":[{"name":"David Worms","email":"david@adaltas.com"}],"dependencies":{"coffee-script":"latest","thrift":"latest","each":"latest"},"devDependencies":{},"keywords":["hive","nosql","hadoop"],"main":"index","engines":{"node":">= 0.4.7"},"_npmUser":{"name":"david","email":"david@adaltas.com"},"_id":"thrift-hive@0.0.6","_engineSupported":true,"_npmVersion":"1.1.0-beta-10","_nodeVersion":"v0.6.7","_defaultsLoaded":true,"dist":{"shasum":"4ca147a63007d212ea971c22f0b13b10f3f6796a","tarball":"https://registry.npmjs.org/thrift-hive/-/thrift-hive-0.0.6.tgz","integrity":"sha512-soqAa6f2HTvb/TUVB5F0l2XXbwNpcPxaC5KtTVbA28Ro5elILObzzvsnfx3a4bzYI7M6TpXq5MYVtX1ovwFJHQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC4s8Jj3/ei/by20JwlQrYXYLJnuyb4TRzPqKO4Nqx1CwIgc1Td7WuXCCmLvFkwFx/B/Nol5pvF97mMQKR8RlzjPKY="}]},"maintainers":[{"name":"david","email":"david@adaltas.com"}]},"0.0.7":{"name":"thrift-hive","description":"Hive client using the Apache Thrift RPC system","version":"0.0.7","author":{"name":"David Worms"},"contributors":[{"name":"David Worms","email":"david@adaltas.com"}],"dependencies":{"thrift":"latest","each":"latest"},"devDependencies":{"coffee-script":"latest","mocha":"latest","should":"latest"},"keywords":["hive","nosql","hadoop"],"main":"index","engines":{"node":">= 0.4.7"},"readme":"# Thrift Hive - Hive client using the Apache Thrift RPC system\n\nHive client with the following main features:\n- fetch rows with optional batch size\n- implement Node Readable Stream API (including `pipe`)\n- hive multiple version support\n- multiple query support through the `multi_execute` and `multi_query` functions\n- advanced comments parsing\n\nThe project export the [Hive API][1] using [Apache Thrift RPC system][2]. It \nsupport multiple versions and a readable stream API.\n\n## Installation\n\n```\nnpm install thrift-hive\n```\n\n## Quick example\n\n```javascript\nvar hive = require('thrift-hive');\n// Client connection\nvar client = hive.createClient({\n  version: '0.7.1-cdh3u2',\n  server: '127.0.0.1',\n  port: 10000,\n  timeout: 1000\n});\n// Execute call\nclient.execute('use default', function(err){\n  // Query call\n  client.query('show tables')\n  .on('row', function(database){\n    console.log(database);\n  })\n  .on('error', function(err){\n    console.log(err.message);\n    client.end();\n  });\n  .on('end', function(){\n    client.end();\n  });\n});\n```\n\n## Hive Client\n\nWe've added a function `hive.createClient` to simplify coding. However, you \nare free to use the raw Thrift API. The client take an `options` object as its \nargument andexpose an `execute` and a `query` methods.\n\nAvailable options\n\n-   `version`   \n    default to '0.7.1-cdh3u2'\n-   `server`   \n    default to '127.0.0.1'\n-   `port`   \n    default to 10000\n-   `timeout`   \n    default to 1000 milliseconds\n\nAvailable API\n\n-   `client`   \n    A reference to the thrift client returned by `thrift.createClient`\n-   `connection`   \n    A reference to the thrift connection returned by `thrift.createConnection`\n-   `end([callback])`   \n    Close the Thrift connection\n-   `execute(query, [callback])`   \n    Execute a query and, when done, call the provided callback with an optional \n    error.\n-   `query(query, [size])`   \n    Execute a query and return its results as an array of arrays (rows and \n    columns). The size argument is optional and indicate the number of row to \n    return on each fetch.\n\n```coffeescript\nhive = require 'thrift-hive'\n# Client connection\nclient = hive.createClient\n  version: '0.7.1-cdh3u2'\n  server: '127.0.0.1'\n  port: 10000\n  timeout: 1000\n# Execute\nclient.execute 'USE default', (err) ->\n  console.log err.message if err\n  client.end()\n```\n\n## Hive Query\n\nThe `client.query` function implement the [EventEmitter API][3].\n\nThe following events are emitted:\n\n-   `row`\n    Emitted for each row returned by Hive. Contains a two arguments, the row\n    as an array and the row index.\n-   `row-first`\n    Emitted after the first row returned by Hive. Contains a two arguments, \n    the row as an array and the row index (always 0).\n-   `row-last`\n    Emitted after the last row returned by Hive. Contains a two arguments, \n    the row as an array and the row index.\n-   `error`\n    Emitted when the connection failed or when Hive return an error.\n-   `end`\n    Emitted when there are no more rows to retrieve, not called if there was\n    an error before.\n-   `both`\n    Convenient event combining the `error` and `end` events. Emitted when an\n    error occured or when there are no more rows to retrieve. Return the same \n    arguments than the `error` or `end` event depending on the operation \n    outturn.\n\nThe `client.query` function return a Node [readable stream][4]. It is possible to \npipe the data into a [writable stream][5] but it is your responsibility to emit\nthe `data` event, usually inside the `row` event.\n\nThe following code written in CoffeeScript is an example of piping data returned by the query into a [writable stream][5].\n\n```coffeescript\nfs = require 'fs'\nhive = require 'thrift-hive'\n# Client connection\nclient = hive.createClient\n  version: '0.7.1-cdh3u2'\n  server: '127.0.0.1'\n  port: 10000\n  timeout: 1000\n# Execute query\nclient.query('show tables')\n.on 'row', (database) ->\n  this.emit 'data', 'Found ' + database + '\\n'\n.on 'error', (err) ->\n  client.end()\n.on 'end', () ->\n  client.end()\n.pipe( fs.createWriteStream \"#{__dirname}/pipe.out\" )\n```\n\n## Navite Thrift API\n\nHere's the same example as the one in the \"Quick example\" section but using the \nnative thrift API.\n\n```javascript\nvar assert     = require('assert');\nvar thrift     = require('thrift');\nvar transport  = require('thrift/lib/thrift/transport');\nvar ThriftHive = require('../lib/0.7.1-cdh3u2/ThriftHive');\n// Client connection\nvar options = {transport: transport.TBufferedTransport, timeout: 1000};\nvar connection = thrift.createConnection('127.0.0.1', 10000, options);\nvar client = thrift.createClient(ThriftHive, connection);\n// Execute query\nclient.execute('use default', function(err){\n  client.execute('show tables', function(err){\n    assert.ifError(err);\n    client.fetchAll(function(err, databases){\n      if(err){\n        console.log(err.message);\n      }else{\n        console.log(databases);\n      }\n      connection.end();\n    });\n  });\n});\n```\n\n## Multi queries\n\nFor conveniency, we've added two functions, `multi_execute` and `multi_query` which\nmay run multiple requests in sequential mode inside a same client connection. They \nare both the same except how the last query is handled:\n\n-   `multi_execute` will end with an `execute` call, thus it's API is the same \n    as the `execute` function.\n-   `multi_query` will end with a `query` call, thus it's API is the same \n    as the `query` function.\n\nThey accept the same arguments as their counterpart but the query may be an \narray or a string of queries. If it is a string, it will be split into multiple \nqueries. Note, the parser is pretty light, removing ';' and comments but it \nseems to do the job.\n\n## Testing\n\nRun the samples:\n\n```bash\nnode samples/execute.js\nnode samples/query.js\nnode samples/style_native.js\nnode samples/style_sugar.js\n```\n\nRun the tests with `expresso`:\n\nHive must be started with Thrift support. By default, the tests will connect to\nHive Thrift server on the host `localhost` and the port `10000`. Edit the file\n\"./test/config.json\" if you wish to change the connection settings used accross\nthe tests. A database `test_database` will be created if it does not yet exist\nand all the tests will run on it.\n\n```bash\nnpm install -g expresso\nexpresso -s\n```\n\n[1]: http://hive.apache.org  \"Apache Hive\"\n[2]: http://thrift.apache.org  \"Apache Thrift\"\n[3]: http://nodejs.org/docs/v0.6.2/api/events.html#events.EventEmitter  \"EventEmitter API\"\n[4]: http://nodejs.org/docs/v0.6.2/api/streams.html#readable_Stream  \"Readable Stream API\"\n[5]: http://nodejs.org/docs/v0.6.2/api/streams.html#writable_Stream  \"Writable Stream API\"\n","_id":"thrift-hive@0.0.7","dist":{"shasum":"238da541d85472e371198f412300aea5edb62f3b","tarball":"https://registry.npmjs.org/thrift-hive/-/thrift-hive-0.0.7.tgz","integrity":"sha512-2Rh5+omp0pEQF8KmQSeFTiuHjUR70bJF2T6CwztgtYHo6fGs9bRhRVT9HjjFnalQ2Eb+JfkheoJx905ZbfyHQA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDfwfwCZXjzduiBJlfAsZvFujYeqMb2Kca+Q7xQ1pCIigIgBm1StGMpVgoHZE9fZXSEPJYG0eHJ5nYozDkAb/0HW3U="}]},"maintainers":[{"name":"david","email":"david@adaltas.com"}]}},"readme":"# Thrift Hive - Hive client with multi versions support and a Readable Stream API.\n\nThe project export the [Hive API][1] using [Apache Thrift RPC system][2]. It \nsupport multiple versions and a readable stream API.\n\n## Installation\n\n```\n    npm install thrift-hive\n```\n\n## Hive Client\n\nWe've added a function `hive.createClient` to simplify coding. However, you \nare free to use the raw Thrift API. The client take an `options` object as its \nargument andexpose an `execute` and a `query` methods.\n\nAvailable options\n-   `version`   \n    default to '0.7.1-cdh3u2'\n-   `server`   \n    default to '127.0.0.1'\n-   `port`   \n    default to 10000\n-   `timeout`   \n    default to 1000 milliseconds\n\nAvailable API\n\n-   `client`   \n    A reference to the thrift client returned by `thrift.createClient`\n-   `connection`   \n    A reference to the thrift connection returned by `thrift.createConnection`\n-   `end([callback])`   \n    Close the Thrift connection\n-   `execute(query, [callback])`   \n    Execute a query\n-   `query(query, [size])`   \n    Execute a query and return its results as an array of arrays (rows and \n    columns). The size argument is optional and indicate the number of row to \n    return on each fetch.\n\n```coffeescript\n    hive = require 'thrift-hive'\n    # Client connection\n    client = hive.createClient\n        version: '0.7.1-cdh3u2'\n        server: '127.0.0.1'\n        port: 10000\n        timeout: 1000\n    # Execute\n    client.execute 'USE default', (err) ->\n        console.log err.message if err\n        client.end()\n```\n\n## Hive Query\n\nThe `client.query` function implement the [EventEmitter API][3].\n\nThe following events are emitted:\n\n-   `row`\n-   `row-first`\n-   `row-last`\n-   `error`\n-   `end`\n\nThe `client.query` functionreturn a Node [Readable Stream][4]. It is possible to \npipe the data into a [Writable Stream][5] but it is your responsibility to emit\nthe `data` event, usually inside the `row` event.\n\n## Raw versus sugar API\n\nHere's an exemple using the raw API\n\n```javascript\n    var assert     = require('assert');\n    var thrift     = require('thrift');\n    var transport  = require('thrift/lib/thrift/transport');\n\tvar ThriftHive = require('../lib/0.7.1-cdh3u2/ThriftHive');\n\t// Client connection\n\tvar options = {transport: transport.TBufferedTransport, timeout: 1000};\n\tvar connection = thrift.createConnection('127.0.0.1', 10000, options);\n\tvar client = thrift.createClient(ThriftHive, connection);\n    // Execute query\n    client.execute('show databases', function(err){\n        assert.ifError(err);\n        client.fetchAll(function(err, databases){\n            assert.ifError(err);\n            console.log(databases);\n            connection.end();\n        });\n    });\n```\n\nHere's an exemple using our sugar API\n\n```javascript\n    var assert = require('assert');\n    var hive = require('thrift-hive');\n    // Client connection\n    var client = hive.createClient({\n        version: '0.7.1-cdh3u2',\n        server: '127.0.0.1',\n        port: 10000,\n        timeout: 1000\n    });\n    // Execute query\n    client.query('show databases')\n    .on('row', function(database){\n        console.log(database);\n    })\n    .on('end', function(err){\n        assert.ifError(err);\n        client.end();\n    });\n```\n\n\n[1]: http://hive.apache.org  \"Apache Hive\"\n[2]: http://thrift.apache.org  \"Apache Thrift\"\n[3]: http://nodejs.org/docs/v0.6.2/api/events.html#events.EventEmitter  \"EventEmitter API\"\n[4]: http://nodejs.org/docs/v0.6.2/api/streams.html#readable_Stream  \"Readable Stream API\"\n[5]: http://nodejs.org/docs/v0.6.2/api/streams.html#writable_Stream  \"Writable Stream API\"\n","maintainers":[{"name":"david","email":"david@adaltas.com"}],"time":{"modified":"2022-06-27T06:22:50.750Z","created":"2011-11-22T23:13:44.656Z","0.0.3":"2011-11-22T23:13:46.214Z","0.0.4":"2011-12-05T17:01:41.545Z","0.0.5":"2011-12-07T23:04:32.353Z","0.0.6":"2012-02-09T23:47:43.618Z","0.0.7":"2012-11-13T15:17:41.179Z"},"author":{"name":"David Worms"}}