Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

callback function to notify that fetchInBatch is finished

  • Loading branch information...
commit ca3e4a9a0513c33f9d642baa91df73e5aa158e9e 1 parent a890e5d
@Jae Jae authored
Showing with 7 additions and 4 deletions.
  1. +2 −0  examples/test.js
  2. +4 −3 node-hive.js
  3. +1 −1  package.json
View
2  examples/test.js
@@ -11,6 +11,8 @@ var i = 1;
hive.fetchInBatch(5, "SELECT * FROM weather_data where dated = '2011-07-02' limit 12", function(err, data) {
console.log("SELECT * FROM weather_data where dated = '2011-07-02' limit 12");
console.log(i++ + "th data:", data.toTSV());
+}, function() {
+ console.log("fetchInBatch completed")
});
hive.execute("DESCRIBE weather_data", function(err, data) {
View
7 node-hive.js
@@ -70,17 +70,18 @@ var hiveClient = function(config) {
});
},
- fetchInBatch: function(batchSize, query, onCompletion) {
- connect(onCompletion, function(client) {
+ fetchInBatch: function(batchSize, query, onBatchCompletion, onCompletion) {
+ connect(onBatchCompletion, function(client) {
client.execute(query, function() {
client.getSchema(function(schema) {
var fetchBatch = function() {
client.fetchN(batchSize, function(data) {
if(data.length > 0) {
- onCompletion(null, ResultSet.create(data, schema));
+ onBatchCompletion(null, ResultSet.create(data, schema));
process.nextTick(fetchBatch);
} else {
client.closeConnection();
+ if (onCompletion) onCompletion(null, null);
}
});
};
View
2  package.json
@@ -3,7 +3,7 @@
"contributors":["Jae Lee <jlee@yetitrails.com>", "Antonio Terreno <antonio.terreno@gmail.com>", "Andy Kent"],
"name": "node-hive",
"description": "Node Hive Client Library",
- "version": "0.0.4",
+ "version": "0.0.5",
"homepage": "https://github.com/forward/node-hive",
"repository": {
"type": "git",
Please sign in to comment.
Something went wrong with that request. Please try again.