├── .npmignore ├── README.md ├── examples └── test.js ├── generate.sh ├── node-hive.js ├── node_modules ├── gen-nodejs │ ├── FacebookService.js │ ├── ThriftHive.js │ ├── ThriftHiveMetastore.js │ ├── fb303_types.js │ ├── hive_metastore_types.js │ ├── hive_service_types.js │ ├── queryplan_types.js │ └── serde_types.js └── thrift │ ├── binary_parser.js │ ├── connection.js │ ├── index.js │ ├── protocol.js │ ├── server.js │ ├── thrift.js │ └── transport.js ├── package.json ├── result_set.js └── src └── hive-thrift ├── fb303.thrift ├── hive_metastore.thrift ├── hive_service.thrift ├── queryplan.thrift └── serde.thrift /.npmignore: -------------------------------------------------------------------------------- 1 | generate.sh 2 | src 3 | Cakefile 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Node Bindings for Hadoop Hive 2 | ============================= 3 | 4 | Installation 5 | ------------ 6 | 7 | npm install node-hive 8 | 9 | Usage 10 | ----- 11 | 12 | hive = require('node-hive').for({ server:"hive.myserver" }); 13 | 14 | hive.fetch("SELECT * FROM my_table", function(err, data) { 15 | data.each(function(record) { 16 | console.log(record); 17 | }); 18 | }); 19 | 20 | Hive instances currently support the following functions 21 | 22 | hive.fetch(query, callback); 23 | hive.fetchInBatch(batchSize, query, callback); 24 | hive.execute(query, [callback]); 25 | 26 | Query callbacks receive two arguments... 27 | 28 | * `error` which is `true` if there was an error 29 | * `result` which is either a `ResultSet` or an error message depending on the state of `error` 30 | 31 | The result of a query is returned as a `ResultSet` which wraps the results with some convenience functions... 32 | 33 | * `result.rows` - The original string based rows returned by thrift. 34 | * `result.schema` - The schema returned from hive. 35 | * `result.each(callback)` - Iterate through rows converting them to friendly JS objects. 36 | * `result.headers()` - An Array of the column headers. 37 | * `result.toTSV(headers=false)` - produce a TSV version of the whole ResultSet. 38 | 39 | 40 | See the `examples` folder for some more usage hints. 41 | 42 | 43 | Connections 44 | ----------- 45 | 46 | The Hive Thrift Server currently only supports one blocking query at a time. Due to the Async model of node we want to be able to run several queries at once, for this to work we create a new connection for each query to run in and then close it when the query is completed. There is currently no support for connection pooling as most users run a small number of long running hive queries but pooling should be possible if and when it's needed. 47 | 48 | 49 | Notes 50 | ----- 51 | 52 | Thrift module has been cloned from https://github.com/wadey/node-thrift/commit/25c0eb4eb85aa63cfb49a8e8c815bd57e2b8043a 53 | 54 | nodejs bindinga are generated from hive 0.6.1 CDH3B4 -------------------------------------------------------------------------------- /examples/test.js: -------------------------------------------------------------------------------- 1 | hive = require('../node-hive').for({server:"hive.hadoop.forward.co.uk", timeout:10000}); 2 | 3 | hive.fetch("SELECT * FROM weather_data where dated = '2011-07-01' limit 10", function(err, data) { 4 | console.log("SELECT * FROM weather_data where dated = '2011-07-01' limit 10"); 5 | data.each(function(record) { 6 | console.log(record); 7 | }); 8 | }); 9 | 10 | var i = 1; 11 | hive.fetchInBatch(5, "SELECT * FROM weather_data where dated = '2011-07-02' limit 12", function(err, data) { 12 | console.log("SELECT * FROM weather_data where dated = '2011-07-02' limit 12"); 13 | console.log(i++ + "th data:", data.toTSV()); 14 | }, function() { 15 | console.log("fetchInBatch completed") 16 | }); 17 | 18 | hive.execute("DESCRIBE weather_data", function(err, data) { 19 | console.log("DESCRIBE weather_data"); 20 | console.log(data); 21 | }); 22 | -------------------------------------------------------------------------------- /generate.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | thrift -o node_modules --gen js:node -I src/hive-thrift src/hive-thrift/hive_metastore.thrift 4 | thrift -o node_modules --gen js:node -I src/hive-thrift src/hive-thrift/hive_service.thrift 5 | thrift -o node_modules --gen js:node -I src/hive-thrift src/hive-thrift/fb303.thrift 6 | thrift -o node_modules --gen js:node -I src/hive-thrift src/hive-thrift/serde.thrift 7 | thrift -o node_modules --gen js:node -I src/hive-thrift src/hive-thrift/queryplan.thrift 8 | -------------------------------------------------------------------------------- /node-hive.js: -------------------------------------------------------------------------------- 1 | var thrift = require('thrift'), 2 | ttransport = require('thrift/transport'), 3 | ThriftHive = require('gen-nodejs/ThriftHive'), 4 | ResultSet = require('./result_set'); 5 | 6 | var hiveClient = function(config) { 7 | var connect = function(onError, connected) { 8 | var server = config.server; 9 | var port = config.port || 10000; 10 | var options = {transport: ttransport.TBufferedTransport, timeout: config.timeout || 1000}; 11 | 12 | var connection = thrift.createConnection(server, port, options); 13 | var client = thrift.createClient(ThriftHive, connection); 14 | 15 | var propagate = function(func, arguments) { 16 | var args = []; 17 | for (var i=2; i < arguments.length; i++) { 18 | args.push(arguments[i]); 19 | }; 20 | func.apply(null, args); 21 | } 22 | 23 | var continueOnSuccess = function(err, onSuccess) { 24 | if (err) { 25 | connection.end(); 26 | onError(true, err); 27 | } else { 28 | propagate(onSuccess, arguments) 29 | } 30 | }; 31 | 32 | connected({ 33 | execute: function(query, onSuccess) { 34 | client.execute(query, function(err) { 35 | continueOnSuccess(err, onSuccess); 36 | }); 37 | }, 38 | getSchema: function(onSuccess) { 39 | client.getSchema(function(err, schema) { 40 | continueOnSuccess(err, onSuccess, schema); 41 | }); 42 | }, 43 | fetchAll: function(onSuccess) { 44 | client.fetchAll(function(err, data) { 45 | continueOnSuccess(err, onSuccess, data); 46 | }); 47 | }, 48 | fetchN: function(batchSize, onSuccess) { 49 | client.fetchN(batchSize, function(err, data) { 50 | continueOnSuccess(err, onSuccess, data); 51 | }); 52 | }, 53 | closeConnection: function() { 54 | connection.end(); 55 | } 56 | }); 57 | }; 58 | 59 | return { 60 | fetch: function(query, onCompletion) { 61 | connect(onCompletion, function(client) { 62 | client.execute(query, function() { 63 | client.getSchema(function(schema) { 64 | client.fetchAll(function(data) { 65 | client.closeConnection(); 66 | onCompletion(null, ResultSet.create(data, schema)); 67 | }); 68 | }); 69 | }); 70 | }); 71 | }, 72 | 73 | fetchInBatch: function(batchSize, query, onBatchCompletion, onCompletion) { 74 | connect(onBatchCompletion, function(client) { 75 | client.execute(query, function() { 76 | client.getSchema(function(schema) { 77 | var fetchBatch = function() { 78 | client.fetchN(batchSize, function(data) { 79 | if(data.length > 0) { 80 | onBatchCompletion(null, ResultSet.create(data, schema)); 81 | process.nextTick(fetchBatch); 82 | } else { 83 | client.closeConnection(); 84 | if (onCompletion) onCompletion(null, null); 85 | } 86 | }); 87 | }; 88 | fetchBatch(); 89 | }); 90 | }); 91 | }); 92 | }, 93 | 94 | execute: function(query, onCompletion){ 95 | connect(onCompletion, function(client) { 96 | client.execute(query, function(){ 97 | client.closeConnection(); 98 | onCompletion(null, null); 99 | }); 100 | }); 101 | }, 102 | }; 103 | }; 104 | 105 | exports.for = function(config) { 106 | return hiveClient(config); 107 | }; -------------------------------------------------------------------------------- /node_modules/gen-nodejs/FacebookService.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | var Thrift = require('thrift').Thrift; 7 | 8 | var ttypes = require('./fb303_types'); 9 | //HELPER FUNCTIONS AND STRUCTURES 10 | 11 | var FacebookService_getName_args = function(args){ 12 | } 13 | FacebookService_getName_args.prototype = {} 14 | FacebookService_getName_args.prototype.read = function(input){ 15 | var ret = input.readStructBegin() 16 | while (1) 17 | { 18 | var ret = input.readFieldBegin() 19 | var fname = ret.fname 20 | var ftype = ret.ftype 21 | var fid = ret.fid 22 | if (ftype == Thrift.Type.STOP) 23 | break 24 | switch(fid) 25 | { 26 | default: 27 | input.skip(ftype) 28 | } 29 | input.readFieldEnd() 30 | } 31 | input.readStructEnd() 32 | return 33 | } 34 | 35 | FacebookService_getName_args.prototype.write = function(output){ 36 | output.writeStructBegin('FacebookService_getName_args') 37 | output.writeFieldStop() 38 | output.writeStructEnd() 39 | return 40 | } 41 | 42 | var FacebookService_getName_result = function(args){ 43 | this.success = null 44 | if( args != null ){ if (null != args.success) 45 | this.success = args.success 46 | }} 47 | FacebookService_getName_result.prototype = {} 48 | FacebookService_getName_result.prototype.read = function(input){ 49 | var ret = input.readStructBegin() 50 | while (1) 51 | { 52 | var ret = input.readFieldBegin() 53 | var fname = ret.fname 54 | var ftype = ret.ftype 55 | var fid = ret.fid 56 | if (ftype == Thrift.Type.STOP) 57 | break 58 | switch(fid) 59 | { 60 | case 0: if (ftype == Thrift.Type.STRING) { 61 | this.success = input.readString() 62 | } else { 63 | input.skip(ftype) 64 | } 65 | break 66 | default: 67 | input.skip(ftype) 68 | } 69 | input.readFieldEnd() 70 | } 71 | input.readStructEnd() 72 | return 73 | } 74 | 75 | FacebookService_getName_result.prototype.write = function(output){ 76 | output.writeStructBegin('FacebookService_getName_result') 77 | if (null != this.success) { 78 | output.writeFieldBegin('success', Thrift.Type.STRING, 0) 79 | output.writeString(this.success) 80 | output.writeFieldEnd() 81 | } 82 | output.writeFieldStop() 83 | output.writeStructEnd() 84 | return 85 | } 86 | 87 | var FacebookService_getVersion_args = function(args){ 88 | } 89 | FacebookService_getVersion_args.prototype = {} 90 | FacebookService_getVersion_args.prototype.read = function(input){ 91 | var ret = input.readStructBegin() 92 | while (1) 93 | { 94 | var ret = input.readFieldBegin() 95 | var fname = ret.fname 96 | var ftype = ret.ftype 97 | var fid = ret.fid 98 | if (ftype == Thrift.Type.STOP) 99 | break 100 | switch(fid) 101 | { 102 | default: 103 | input.skip(ftype) 104 | } 105 | input.readFieldEnd() 106 | } 107 | input.readStructEnd() 108 | return 109 | } 110 | 111 | FacebookService_getVersion_args.prototype.write = function(output){ 112 | output.writeStructBegin('FacebookService_getVersion_args') 113 | output.writeFieldStop() 114 | output.writeStructEnd() 115 | return 116 | } 117 | 118 | var FacebookService_getVersion_result = function(args){ 119 | this.success = null 120 | if( args != null ){ if (null != args.success) 121 | this.success = args.success 122 | }} 123 | FacebookService_getVersion_result.prototype = {} 124 | FacebookService_getVersion_result.prototype.read = function(input){ 125 | var ret = input.readStructBegin() 126 | while (1) 127 | { 128 | var ret = input.readFieldBegin() 129 | var fname = ret.fname 130 | var ftype = ret.ftype 131 | var fid = ret.fid 132 | if (ftype == Thrift.Type.STOP) 133 | break 134 | switch(fid) 135 | { 136 | case 0: if (ftype == Thrift.Type.STRING) { 137 | this.success = input.readString() 138 | } else { 139 | input.skip(ftype) 140 | } 141 | break 142 | default: 143 | input.skip(ftype) 144 | } 145 | input.readFieldEnd() 146 | } 147 | input.readStructEnd() 148 | return 149 | } 150 | 151 | FacebookService_getVersion_result.prototype.write = function(output){ 152 | output.writeStructBegin('FacebookService_getVersion_result') 153 | if (null != this.success) { 154 | output.writeFieldBegin('success', Thrift.Type.STRING, 0) 155 | output.writeString(this.success) 156 | output.writeFieldEnd() 157 | } 158 | output.writeFieldStop() 159 | output.writeStructEnd() 160 | return 161 | } 162 | 163 | var FacebookService_getStatus_args = function(args){ 164 | } 165 | FacebookService_getStatus_args.prototype = {} 166 | FacebookService_getStatus_args.prototype.read = function(input){ 167 | var ret = input.readStructBegin() 168 | while (1) 169 | { 170 | var ret = input.readFieldBegin() 171 | var fname = ret.fname 172 | var ftype = ret.ftype 173 | var fid = ret.fid 174 | if (ftype == Thrift.Type.STOP) 175 | break 176 | switch(fid) 177 | { 178 | default: 179 | input.skip(ftype) 180 | } 181 | input.readFieldEnd() 182 | } 183 | input.readStructEnd() 184 | return 185 | } 186 | 187 | FacebookService_getStatus_args.prototype.write = function(output){ 188 | output.writeStructBegin('FacebookService_getStatus_args') 189 | output.writeFieldStop() 190 | output.writeStructEnd() 191 | return 192 | } 193 | 194 | var FacebookService_getStatus_result = function(args){ 195 | this.success = null 196 | if( args != null ){ if (null != args.success) 197 | this.success = args.success 198 | }} 199 | FacebookService_getStatus_result.prototype = {} 200 | FacebookService_getStatus_result.prototype.read = function(input){ 201 | var ret = input.readStructBegin() 202 | while (1) 203 | { 204 | var ret = input.readFieldBegin() 205 | var fname = ret.fname 206 | var ftype = ret.ftype 207 | var fid = ret.fid 208 | if (ftype == Thrift.Type.STOP) 209 | break 210 | switch(fid) 211 | { 212 | case 0: if (ftype == Thrift.Type.I32) { 213 | this.success = input.readI32() 214 | } else { 215 | input.skip(ftype) 216 | } 217 | break 218 | default: 219 | input.skip(ftype) 220 | } 221 | input.readFieldEnd() 222 | } 223 | input.readStructEnd() 224 | return 225 | } 226 | 227 | FacebookService_getStatus_result.prototype.write = function(output){ 228 | output.writeStructBegin('FacebookService_getStatus_result') 229 | if (null != this.success) { 230 | output.writeFieldBegin('success', Thrift.Type.I32, 0) 231 | output.writeI32(this.success) 232 | output.writeFieldEnd() 233 | } 234 | output.writeFieldStop() 235 | output.writeStructEnd() 236 | return 237 | } 238 | 239 | var FacebookService_getStatusDetails_args = function(args){ 240 | } 241 | FacebookService_getStatusDetails_args.prototype = {} 242 | FacebookService_getStatusDetails_args.prototype.read = function(input){ 243 | var ret = input.readStructBegin() 244 | while (1) 245 | { 246 | var ret = input.readFieldBegin() 247 | var fname = ret.fname 248 | var ftype = ret.ftype 249 | var fid = ret.fid 250 | if (ftype == Thrift.Type.STOP) 251 | break 252 | switch(fid) 253 | { 254 | default: 255 | input.skip(ftype) 256 | } 257 | input.readFieldEnd() 258 | } 259 | input.readStructEnd() 260 | return 261 | } 262 | 263 | FacebookService_getStatusDetails_args.prototype.write = function(output){ 264 | output.writeStructBegin('FacebookService_getStatusDetails_args') 265 | output.writeFieldStop() 266 | output.writeStructEnd() 267 | return 268 | } 269 | 270 | var FacebookService_getStatusDetails_result = function(args){ 271 | this.success = null 272 | if( args != null ){ if (null != args.success) 273 | this.success = args.success 274 | }} 275 | FacebookService_getStatusDetails_result.prototype = {} 276 | FacebookService_getStatusDetails_result.prototype.read = function(input){ 277 | var ret = input.readStructBegin() 278 | while (1) 279 | { 280 | var ret = input.readFieldBegin() 281 | var fname = ret.fname 282 | var ftype = ret.ftype 283 | var fid = ret.fid 284 | if (ftype == Thrift.Type.STOP) 285 | break 286 | switch(fid) 287 | { 288 | case 0: if (ftype == Thrift.Type.STRING) { 289 | this.success = input.readString() 290 | } else { 291 | input.skip(ftype) 292 | } 293 | break 294 | default: 295 | input.skip(ftype) 296 | } 297 | input.readFieldEnd() 298 | } 299 | input.readStructEnd() 300 | return 301 | } 302 | 303 | FacebookService_getStatusDetails_result.prototype.write = function(output){ 304 | output.writeStructBegin('FacebookService_getStatusDetails_result') 305 | if (null != this.success) { 306 | output.writeFieldBegin('success', Thrift.Type.STRING, 0) 307 | output.writeString(this.success) 308 | output.writeFieldEnd() 309 | } 310 | output.writeFieldStop() 311 | output.writeStructEnd() 312 | return 313 | } 314 | 315 | var FacebookService_getCounters_args = function(args){ 316 | } 317 | FacebookService_getCounters_args.prototype = {} 318 | FacebookService_getCounters_args.prototype.read = function(input){ 319 | var ret = input.readStructBegin() 320 | while (1) 321 | { 322 | var ret = input.readFieldBegin() 323 | var fname = ret.fname 324 | var ftype = ret.ftype 325 | var fid = ret.fid 326 | if (ftype == Thrift.Type.STOP) 327 | break 328 | switch(fid) 329 | { 330 | default: 331 | input.skip(ftype) 332 | } 333 | input.readFieldEnd() 334 | } 335 | input.readStructEnd() 336 | return 337 | } 338 | 339 | FacebookService_getCounters_args.prototype.write = function(output){ 340 | output.writeStructBegin('FacebookService_getCounters_args') 341 | output.writeFieldStop() 342 | output.writeStructEnd() 343 | return 344 | } 345 | 346 | var FacebookService_getCounters_result = function(args){ 347 | this.success = null 348 | if( args != null ){ if (null != args.success) 349 | this.success = args.success 350 | }} 351 | FacebookService_getCounters_result.prototype = {} 352 | FacebookService_getCounters_result.prototype.read = function(input){ 353 | var ret = input.readStructBegin() 354 | while (1) 355 | { 356 | var ret = input.readFieldBegin() 357 | var fname = ret.fname 358 | var ftype = ret.ftype 359 | var fid = ret.fid 360 | if (ftype == Thrift.Type.STOP) 361 | break 362 | switch(fid) 363 | { 364 | case 0: if (ftype == Thrift.Type.MAP) { 365 | { 366 | var _size0 = 0 367 | var rtmp3 368 | this.success = {} 369 | var _ktype1 = 0 370 | var _vtype2 = 0 371 | rtmp3 = input.readMapBegin() 372 | _ktype1= rtmp3.ktype 373 | _vtype2= rtmp3.vtype 374 | _size0= rtmp3.size 375 | for (var _i4 = 0; _i4 < _size0; ++_i4) 376 | { 377 | key5 = null 378 | val6 = null 379 | key5 = input.readString() 380 | val6 = input.readI64() 381 | this.success[key5] = val6 382 | } 383 | input.readMapEnd() 384 | } 385 | } else { 386 | input.skip(ftype) 387 | } 388 | break 389 | default: 390 | input.skip(ftype) 391 | } 392 | input.readFieldEnd() 393 | } 394 | input.readStructEnd() 395 | return 396 | } 397 | 398 | FacebookService_getCounters_result.prototype.write = function(output){ 399 | output.writeStructBegin('FacebookService_getCounters_result') 400 | if (null != this.success) { 401 | output.writeFieldBegin('success', Thrift.Type.MAP, 0) 402 | { 403 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.I64, Thrift.objectLength(this.success)) 404 | { 405 | for(var kiter7 in this.success) { 406 | if (this.success.hasOwnProperty(kiter7)) 407 | { 408 | var viter8 = this.success[kiter7] 409 | output.writeString(kiter7) 410 | output.writeI64(viter8) 411 | } 412 | } 413 | } 414 | output.writeMapEnd() 415 | } 416 | output.writeFieldEnd() 417 | } 418 | output.writeFieldStop() 419 | output.writeStructEnd() 420 | return 421 | } 422 | 423 | var FacebookService_getCounter_args = function(args){ 424 | this.key = null 425 | if( args != null ){ if (null != args.key) 426 | this.key = args.key 427 | }} 428 | FacebookService_getCounter_args.prototype = {} 429 | FacebookService_getCounter_args.prototype.read = function(input){ 430 | var ret = input.readStructBegin() 431 | while (1) 432 | { 433 | var ret = input.readFieldBegin() 434 | var fname = ret.fname 435 | var ftype = ret.ftype 436 | var fid = ret.fid 437 | if (ftype == Thrift.Type.STOP) 438 | break 439 | switch(fid) 440 | { 441 | case 1: if (ftype == Thrift.Type.STRING) { 442 | this.key = input.readString() 443 | } else { 444 | input.skip(ftype) 445 | } 446 | break 447 | default: 448 | input.skip(ftype) 449 | } 450 | input.readFieldEnd() 451 | } 452 | input.readStructEnd() 453 | return 454 | } 455 | 456 | FacebookService_getCounter_args.prototype.write = function(output){ 457 | output.writeStructBegin('FacebookService_getCounter_args') 458 | if (null != this.key) { 459 | output.writeFieldBegin('key', Thrift.Type.STRING, 1) 460 | output.writeString(this.key) 461 | output.writeFieldEnd() 462 | } 463 | output.writeFieldStop() 464 | output.writeStructEnd() 465 | return 466 | } 467 | 468 | var FacebookService_getCounter_result = function(args){ 469 | this.success = null 470 | if( args != null ){ if (null != args.success) 471 | this.success = args.success 472 | }} 473 | FacebookService_getCounter_result.prototype = {} 474 | FacebookService_getCounter_result.prototype.read = function(input){ 475 | var ret = input.readStructBegin() 476 | while (1) 477 | { 478 | var ret = input.readFieldBegin() 479 | var fname = ret.fname 480 | var ftype = ret.ftype 481 | var fid = ret.fid 482 | if (ftype == Thrift.Type.STOP) 483 | break 484 | switch(fid) 485 | { 486 | case 0: if (ftype == Thrift.Type.I64) { 487 | this.success = input.readI64() 488 | } else { 489 | input.skip(ftype) 490 | } 491 | break 492 | default: 493 | input.skip(ftype) 494 | } 495 | input.readFieldEnd() 496 | } 497 | input.readStructEnd() 498 | return 499 | } 500 | 501 | FacebookService_getCounter_result.prototype.write = function(output){ 502 | output.writeStructBegin('FacebookService_getCounter_result') 503 | if (null != this.success) { 504 | output.writeFieldBegin('success', Thrift.Type.I64, 0) 505 | output.writeI64(this.success) 506 | output.writeFieldEnd() 507 | } 508 | output.writeFieldStop() 509 | output.writeStructEnd() 510 | return 511 | } 512 | 513 | var FacebookService_setOption_args = function(args){ 514 | this.key = null 515 | this.value = null 516 | if( args != null ){ if (null != args.key) 517 | this.key = args.key 518 | if (null != args.value) 519 | this.value = args.value 520 | }} 521 | FacebookService_setOption_args.prototype = {} 522 | FacebookService_setOption_args.prototype.read = function(input){ 523 | var ret = input.readStructBegin() 524 | while (1) 525 | { 526 | var ret = input.readFieldBegin() 527 | var fname = ret.fname 528 | var ftype = ret.ftype 529 | var fid = ret.fid 530 | if (ftype == Thrift.Type.STOP) 531 | break 532 | switch(fid) 533 | { 534 | case 1: if (ftype == Thrift.Type.STRING) { 535 | this.key = input.readString() 536 | } else { 537 | input.skip(ftype) 538 | } 539 | break 540 | case 2: if (ftype == Thrift.Type.STRING) { 541 | this.value = input.readString() 542 | } else { 543 | input.skip(ftype) 544 | } 545 | break 546 | default: 547 | input.skip(ftype) 548 | } 549 | input.readFieldEnd() 550 | } 551 | input.readStructEnd() 552 | return 553 | } 554 | 555 | FacebookService_setOption_args.prototype.write = function(output){ 556 | output.writeStructBegin('FacebookService_setOption_args') 557 | if (null != this.key) { 558 | output.writeFieldBegin('key', Thrift.Type.STRING, 1) 559 | output.writeString(this.key) 560 | output.writeFieldEnd() 561 | } 562 | if (null != this.value) { 563 | output.writeFieldBegin('value', Thrift.Type.STRING, 2) 564 | output.writeString(this.value) 565 | output.writeFieldEnd() 566 | } 567 | output.writeFieldStop() 568 | output.writeStructEnd() 569 | return 570 | } 571 | 572 | var FacebookService_setOption_result = function(args){ 573 | } 574 | FacebookService_setOption_result.prototype = {} 575 | FacebookService_setOption_result.prototype.read = function(input){ 576 | var ret = input.readStructBegin() 577 | while (1) 578 | { 579 | var ret = input.readFieldBegin() 580 | var fname = ret.fname 581 | var ftype = ret.ftype 582 | var fid = ret.fid 583 | if (ftype == Thrift.Type.STOP) 584 | break 585 | switch(fid) 586 | { 587 | default: 588 | input.skip(ftype) 589 | } 590 | input.readFieldEnd() 591 | } 592 | input.readStructEnd() 593 | return 594 | } 595 | 596 | FacebookService_setOption_result.prototype.write = function(output){ 597 | output.writeStructBegin('FacebookService_setOption_result') 598 | output.writeFieldStop() 599 | output.writeStructEnd() 600 | return 601 | } 602 | 603 | var FacebookService_getOption_args = function(args){ 604 | this.key = null 605 | if( args != null ){ if (null != args.key) 606 | this.key = args.key 607 | }} 608 | FacebookService_getOption_args.prototype = {} 609 | FacebookService_getOption_args.prototype.read = function(input){ 610 | var ret = input.readStructBegin() 611 | while (1) 612 | { 613 | var ret = input.readFieldBegin() 614 | var fname = ret.fname 615 | var ftype = ret.ftype 616 | var fid = ret.fid 617 | if (ftype == Thrift.Type.STOP) 618 | break 619 | switch(fid) 620 | { 621 | case 1: if (ftype == Thrift.Type.STRING) { 622 | this.key = input.readString() 623 | } else { 624 | input.skip(ftype) 625 | } 626 | break 627 | default: 628 | input.skip(ftype) 629 | } 630 | input.readFieldEnd() 631 | } 632 | input.readStructEnd() 633 | return 634 | } 635 | 636 | FacebookService_getOption_args.prototype.write = function(output){ 637 | output.writeStructBegin('FacebookService_getOption_args') 638 | if (null != this.key) { 639 | output.writeFieldBegin('key', Thrift.Type.STRING, 1) 640 | output.writeString(this.key) 641 | output.writeFieldEnd() 642 | } 643 | output.writeFieldStop() 644 | output.writeStructEnd() 645 | return 646 | } 647 | 648 | var FacebookService_getOption_result = function(args){ 649 | this.success = null 650 | if( args != null ){ if (null != args.success) 651 | this.success = args.success 652 | }} 653 | FacebookService_getOption_result.prototype = {} 654 | FacebookService_getOption_result.prototype.read = function(input){ 655 | var ret = input.readStructBegin() 656 | while (1) 657 | { 658 | var ret = input.readFieldBegin() 659 | var fname = ret.fname 660 | var ftype = ret.ftype 661 | var fid = ret.fid 662 | if (ftype == Thrift.Type.STOP) 663 | break 664 | switch(fid) 665 | { 666 | case 0: if (ftype == Thrift.Type.STRING) { 667 | this.success = input.readString() 668 | } else { 669 | input.skip(ftype) 670 | } 671 | break 672 | default: 673 | input.skip(ftype) 674 | } 675 | input.readFieldEnd() 676 | } 677 | input.readStructEnd() 678 | return 679 | } 680 | 681 | FacebookService_getOption_result.prototype.write = function(output){ 682 | output.writeStructBegin('FacebookService_getOption_result') 683 | if (null != this.success) { 684 | output.writeFieldBegin('success', Thrift.Type.STRING, 0) 685 | output.writeString(this.success) 686 | output.writeFieldEnd() 687 | } 688 | output.writeFieldStop() 689 | output.writeStructEnd() 690 | return 691 | } 692 | 693 | var FacebookService_getOptions_args = function(args){ 694 | } 695 | FacebookService_getOptions_args.prototype = {} 696 | FacebookService_getOptions_args.prototype.read = function(input){ 697 | var ret = input.readStructBegin() 698 | while (1) 699 | { 700 | var ret = input.readFieldBegin() 701 | var fname = ret.fname 702 | var ftype = ret.ftype 703 | var fid = ret.fid 704 | if (ftype == Thrift.Type.STOP) 705 | break 706 | switch(fid) 707 | { 708 | default: 709 | input.skip(ftype) 710 | } 711 | input.readFieldEnd() 712 | } 713 | input.readStructEnd() 714 | return 715 | } 716 | 717 | FacebookService_getOptions_args.prototype.write = function(output){ 718 | output.writeStructBegin('FacebookService_getOptions_args') 719 | output.writeFieldStop() 720 | output.writeStructEnd() 721 | return 722 | } 723 | 724 | var FacebookService_getOptions_result = function(args){ 725 | this.success = null 726 | if( args != null ){ if (null != args.success) 727 | this.success = args.success 728 | }} 729 | FacebookService_getOptions_result.prototype = {} 730 | FacebookService_getOptions_result.prototype.read = function(input){ 731 | var ret = input.readStructBegin() 732 | while (1) 733 | { 734 | var ret = input.readFieldBegin() 735 | var fname = ret.fname 736 | var ftype = ret.ftype 737 | var fid = ret.fid 738 | if (ftype == Thrift.Type.STOP) 739 | break 740 | switch(fid) 741 | { 742 | case 0: if (ftype == Thrift.Type.MAP) { 743 | { 744 | var _size9 = 0 745 | var rtmp3 746 | this.success = {} 747 | var _ktype10 = 0 748 | var _vtype11 = 0 749 | rtmp3 = input.readMapBegin() 750 | _ktype10= rtmp3.ktype 751 | _vtype11= rtmp3.vtype 752 | _size9= rtmp3.size 753 | for (var _i13 = 0; _i13 < _size9; ++_i13) 754 | { 755 | key14 = null 756 | val15 = null 757 | key14 = input.readString() 758 | val15 = input.readString() 759 | this.success[key14] = val15 760 | } 761 | input.readMapEnd() 762 | } 763 | } else { 764 | input.skip(ftype) 765 | } 766 | break 767 | default: 768 | input.skip(ftype) 769 | } 770 | input.readFieldEnd() 771 | } 772 | input.readStructEnd() 773 | return 774 | } 775 | 776 | FacebookService_getOptions_result.prototype.write = function(output){ 777 | output.writeStructBegin('FacebookService_getOptions_result') 778 | if (null != this.success) { 779 | output.writeFieldBegin('success', Thrift.Type.MAP, 0) 780 | { 781 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.STRING, Thrift.objectLength(this.success)) 782 | { 783 | for(var kiter16 in this.success) { 784 | if (this.success.hasOwnProperty(kiter16)) 785 | { 786 | var viter17 = this.success[kiter16] 787 | output.writeString(kiter16) 788 | output.writeString(viter17) 789 | } 790 | } 791 | } 792 | output.writeMapEnd() 793 | } 794 | output.writeFieldEnd() 795 | } 796 | output.writeFieldStop() 797 | output.writeStructEnd() 798 | return 799 | } 800 | 801 | var FacebookService_getCpuProfile_args = function(args){ 802 | this.profileDurationInSec = null 803 | if( args != null ){ if (null != args.profileDurationInSec) 804 | this.profileDurationInSec = args.profileDurationInSec 805 | }} 806 | FacebookService_getCpuProfile_args.prototype = {} 807 | FacebookService_getCpuProfile_args.prototype.read = function(input){ 808 | var ret = input.readStructBegin() 809 | while (1) 810 | { 811 | var ret = input.readFieldBegin() 812 | var fname = ret.fname 813 | var ftype = ret.ftype 814 | var fid = ret.fid 815 | if (ftype == Thrift.Type.STOP) 816 | break 817 | switch(fid) 818 | { 819 | case 1: if (ftype == Thrift.Type.I32) { 820 | this.profileDurationInSec = input.readI32() 821 | } else { 822 | input.skip(ftype) 823 | } 824 | break 825 | default: 826 | input.skip(ftype) 827 | } 828 | input.readFieldEnd() 829 | } 830 | input.readStructEnd() 831 | return 832 | } 833 | 834 | FacebookService_getCpuProfile_args.prototype.write = function(output){ 835 | output.writeStructBegin('FacebookService_getCpuProfile_args') 836 | if (null != this.profileDurationInSec) { 837 | output.writeFieldBegin('profileDurationInSec', Thrift.Type.I32, 1) 838 | output.writeI32(this.profileDurationInSec) 839 | output.writeFieldEnd() 840 | } 841 | output.writeFieldStop() 842 | output.writeStructEnd() 843 | return 844 | } 845 | 846 | var FacebookService_getCpuProfile_result = function(args){ 847 | this.success = null 848 | if( args != null ){ if (null != args.success) 849 | this.success = args.success 850 | }} 851 | FacebookService_getCpuProfile_result.prototype = {} 852 | FacebookService_getCpuProfile_result.prototype.read = function(input){ 853 | var ret = input.readStructBegin() 854 | while (1) 855 | { 856 | var ret = input.readFieldBegin() 857 | var fname = ret.fname 858 | var ftype = ret.ftype 859 | var fid = ret.fid 860 | if (ftype == Thrift.Type.STOP) 861 | break 862 | switch(fid) 863 | { 864 | case 0: if (ftype == Thrift.Type.STRING) { 865 | this.success = input.readString() 866 | } else { 867 | input.skip(ftype) 868 | } 869 | break 870 | default: 871 | input.skip(ftype) 872 | } 873 | input.readFieldEnd() 874 | } 875 | input.readStructEnd() 876 | return 877 | } 878 | 879 | FacebookService_getCpuProfile_result.prototype.write = function(output){ 880 | output.writeStructBegin('FacebookService_getCpuProfile_result') 881 | if (null != this.success) { 882 | output.writeFieldBegin('success', Thrift.Type.STRING, 0) 883 | output.writeString(this.success) 884 | output.writeFieldEnd() 885 | } 886 | output.writeFieldStop() 887 | output.writeStructEnd() 888 | return 889 | } 890 | 891 | var FacebookService_aliveSince_args = function(args){ 892 | } 893 | FacebookService_aliveSince_args.prototype = {} 894 | FacebookService_aliveSince_args.prototype.read = function(input){ 895 | var ret = input.readStructBegin() 896 | while (1) 897 | { 898 | var ret = input.readFieldBegin() 899 | var fname = ret.fname 900 | var ftype = ret.ftype 901 | var fid = ret.fid 902 | if (ftype == Thrift.Type.STOP) 903 | break 904 | switch(fid) 905 | { 906 | default: 907 | input.skip(ftype) 908 | } 909 | input.readFieldEnd() 910 | } 911 | input.readStructEnd() 912 | return 913 | } 914 | 915 | FacebookService_aliveSince_args.prototype.write = function(output){ 916 | output.writeStructBegin('FacebookService_aliveSince_args') 917 | output.writeFieldStop() 918 | output.writeStructEnd() 919 | return 920 | } 921 | 922 | var FacebookService_aliveSince_result = function(args){ 923 | this.success = null 924 | if( args != null ){ if (null != args.success) 925 | this.success = args.success 926 | }} 927 | FacebookService_aliveSince_result.prototype = {} 928 | FacebookService_aliveSince_result.prototype.read = function(input){ 929 | var ret = input.readStructBegin() 930 | while (1) 931 | { 932 | var ret = input.readFieldBegin() 933 | var fname = ret.fname 934 | var ftype = ret.ftype 935 | var fid = ret.fid 936 | if (ftype == Thrift.Type.STOP) 937 | break 938 | switch(fid) 939 | { 940 | case 0: if (ftype == Thrift.Type.I64) { 941 | this.success = input.readI64() 942 | } else { 943 | input.skip(ftype) 944 | } 945 | break 946 | default: 947 | input.skip(ftype) 948 | } 949 | input.readFieldEnd() 950 | } 951 | input.readStructEnd() 952 | return 953 | } 954 | 955 | FacebookService_aliveSince_result.prototype.write = function(output){ 956 | output.writeStructBegin('FacebookService_aliveSince_result') 957 | if (null != this.success) { 958 | output.writeFieldBegin('success', Thrift.Type.I64, 0) 959 | output.writeI64(this.success) 960 | output.writeFieldEnd() 961 | } 962 | output.writeFieldStop() 963 | output.writeStructEnd() 964 | return 965 | } 966 | 967 | var FacebookService_reinitialize_args = function(args){ 968 | } 969 | FacebookService_reinitialize_args.prototype = {} 970 | FacebookService_reinitialize_args.prototype.read = function(input){ 971 | var ret = input.readStructBegin() 972 | while (1) 973 | { 974 | var ret = input.readFieldBegin() 975 | var fname = ret.fname 976 | var ftype = ret.ftype 977 | var fid = ret.fid 978 | if (ftype == Thrift.Type.STOP) 979 | break 980 | switch(fid) 981 | { 982 | default: 983 | input.skip(ftype) 984 | } 985 | input.readFieldEnd() 986 | } 987 | input.readStructEnd() 988 | return 989 | } 990 | 991 | FacebookService_reinitialize_args.prototype.write = function(output){ 992 | output.writeStructBegin('FacebookService_reinitialize_args') 993 | output.writeFieldStop() 994 | output.writeStructEnd() 995 | return 996 | } 997 | 998 | var FacebookService_reinitialize_result = function(args){ 999 | } 1000 | FacebookService_reinitialize_result.prototype = {} 1001 | FacebookService_reinitialize_result.prototype.read = function(input){ 1002 | var ret = input.readStructBegin() 1003 | while (1) 1004 | { 1005 | var ret = input.readFieldBegin() 1006 | var fname = ret.fname 1007 | var ftype = ret.ftype 1008 | var fid = ret.fid 1009 | if (ftype == Thrift.Type.STOP) 1010 | break 1011 | switch(fid) 1012 | { 1013 | default: 1014 | input.skip(ftype) 1015 | } 1016 | input.readFieldEnd() 1017 | } 1018 | input.readStructEnd() 1019 | return 1020 | } 1021 | 1022 | FacebookService_reinitialize_result.prototype.write = function(output){ 1023 | output.writeStructBegin('FacebookService_reinitialize_result') 1024 | output.writeFieldStop() 1025 | output.writeStructEnd() 1026 | return 1027 | } 1028 | 1029 | var FacebookService_shutdown_args = function(args){ 1030 | } 1031 | FacebookService_shutdown_args.prototype = {} 1032 | FacebookService_shutdown_args.prototype.read = function(input){ 1033 | var ret = input.readStructBegin() 1034 | while (1) 1035 | { 1036 | var ret = input.readFieldBegin() 1037 | var fname = ret.fname 1038 | var ftype = ret.ftype 1039 | var fid = ret.fid 1040 | if (ftype == Thrift.Type.STOP) 1041 | break 1042 | switch(fid) 1043 | { 1044 | default: 1045 | input.skip(ftype) 1046 | } 1047 | input.readFieldEnd() 1048 | } 1049 | input.readStructEnd() 1050 | return 1051 | } 1052 | 1053 | FacebookService_shutdown_args.prototype.write = function(output){ 1054 | output.writeStructBegin('FacebookService_shutdown_args') 1055 | output.writeFieldStop() 1056 | output.writeStructEnd() 1057 | return 1058 | } 1059 | 1060 | var FacebookService_shutdown_result = function(args){ 1061 | } 1062 | FacebookService_shutdown_result.prototype = {} 1063 | FacebookService_shutdown_result.prototype.read = function(input){ 1064 | var ret = input.readStructBegin() 1065 | while (1) 1066 | { 1067 | var ret = input.readFieldBegin() 1068 | var fname = ret.fname 1069 | var ftype = ret.ftype 1070 | var fid = ret.fid 1071 | if (ftype == Thrift.Type.STOP) 1072 | break 1073 | switch(fid) 1074 | { 1075 | default: 1076 | input.skip(ftype) 1077 | } 1078 | input.readFieldEnd() 1079 | } 1080 | input.readStructEnd() 1081 | return 1082 | } 1083 | 1084 | FacebookService_shutdown_result.prototype.write = function(output){ 1085 | output.writeStructBegin('FacebookService_shutdown_result') 1086 | output.writeFieldStop() 1087 | output.writeStructEnd() 1088 | return 1089 | } 1090 | 1091 | var FacebookServiceClient = exports.Client = function(output, pClass) { 1092 | this.output = output; 1093 | this.pClass = pClass; 1094 | this.seqid = 0; 1095 | this._reqs = {} 1096 | } 1097 | FacebookServiceClient.prototype = {} 1098 | FacebookServiceClient.prototype.getName = function(callback){ 1099 | this.seqid += 1; 1100 | this._reqs[this.seqid] = callback; 1101 | this.send_getName() 1102 | } 1103 | 1104 | FacebookServiceClient.prototype.send_getName = function(){ 1105 | var output = new this.pClass(this.output); 1106 | output.writeMessageBegin('getName', Thrift.MessageType.CALL, this.seqid) 1107 | var args = new FacebookService_getName_args() 1108 | args.write(output) 1109 | output.writeMessageEnd() 1110 | return this.output.flush() 1111 | } 1112 | 1113 | FacebookServiceClient.prototype.recv_getName = function(input,mtype,rseqid){ 1114 | var callback = this._reqs[rseqid] || function() {}; 1115 | delete this._reqs[rseqid]; 1116 | if (mtype == Thrift.MessageType.EXCEPTION) { 1117 | var x = new Thrift.TApplicationException() 1118 | x.read(input) 1119 | input.readMessageEnd() 1120 | return callback(x); 1121 | } 1122 | var result = new FacebookService_getName_result() 1123 | result.read(input) 1124 | input.readMessageEnd() 1125 | 1126 | if (null != result.success ) { 1127 | return callback(null, result.success); 1128 | } 1129 | return callback("getName failed: unknown result"); 1130 | } 1131 | FacebookServiceClient.prototype.getVersion = function(callback){ 1132 | this.seqid += 1; 1133 | this._reqs[this.seqid] = callback; 1134 | this.send_getVersion() 1135 | } 1136 | 1137 | FacebookServiceClient.prototype.send_getVersion = function(){ 1138 | var output = new this.pClass(this.output); 1139 | output.writeMessageBegin('getVersion', Thrift.MessageType.CALL, this.seqid) 1140 | var args = new FacebookService_getVersion_args() 1141 | args.write(output) 1142 | output.writeMessageEnd() 1143 | return this.output.flush() 1144 | } 1145 | 1146 | FacebookServiceClient.prototype.recv_getVersion = function(input,mtype,rseqid){ 1147 | var callback = this._reqs[rseqid] || function() {}; 1148 | delete this._reqs[rseqid]; 1149 | if (mtype == Thrift.MessageType.EXCEPTION) { 1150 | var x = new Thrift.TApplicationException() 1151 | x.read(input) 1152 | input.readMessageEnd() 1153 | return callback(x); 1154 | } 1155 | var result = new FacebookService_getVersion_result() 1156 | result.read(input) 1157 | input.readMessageEnd() 1158 | 1159 | if (null != result.success ) { 1160 | return callback(null, result.success); 1161 | } 1162 | return callback("getVersion failed: unknown result"); 1163 | } 1164 | FacebookServiceClient.prototype.getStatus = function(callback){ 1165 | this.seqid += 1; 1166 | this._reqs[this.seqid] = callback; 1167 | this.send_getStatus() 1168 | } 1169 | 1170 | FacebookServiceClient.prototype.send_getStatus = function(){ 1171 | var output = new this.pClass(this.output); 1172 | output.writeMessageBegin('getStatus', Thrift.MessageType.CALL, this.seqid) 1173 | var args = new FacebookService_getStatus_args() 1174 | args.write(output) 1175 | output.writeMessageEnd() 1176 | return this.output.flush() 1177 | } 1178 | 1179 | FacebookServiceClient.prototype.recv_getStatus = function(input,mtype,rseqid){ 1180 | var callback = this._reqs[rseqid] || function() {}; 1181 | delete this._reqs[rseqid]; 1182 | if (mtype == Thrift.MessageType.EXCEPTION) { 1183 | var x = new Thrift.TApplicationException() 1184 | x.read(input) 1185 | input.readMessageEnd() 1186 | return callback(x); 1187 | } 1188 | var result = new FacebookService_getStatus_result() 1189 | result.read(input) 1190 | input.readMessageEnd() 1191 | 1192 | if (null != result.success ) { 1193 | return callback(null, result.success); 1194 | } 1195 | return callback("getStatus failed: unknown result"); 1196 | } 1197 | FacebookServiceClient.prototype.getStatusDetails = function(callback){ 1198 | this.seqid += 1; 1199 | this._reqs[this.seqid] = callback; 1200 | this.send_getStatusDetails() 1201 | } 1202 | 1203 | FacebookServiceClient.prototype.send_getStatusDetails = function(){ 1204 | var output = new this.pClass(this.output); 1205 | output.writeMessageBegin('getStatusDetails', Thrift.MessageType.CALL, this.seqid) 1206 | var args = new FacebookService_getStatusDetails_args() 1207 | args.write(output) 1208 | output.writeMessageEnd() 1209 | return this.output.flush() 1210 | } 1211 | 1212 | FacebookServiceClient.prototype.recv_getStatusDetails = function(input,mtype,rseqid){ 1213 | var callback = this._reqs[rseqid] || function() {}; 1214 | delete this._reqs[rseqid]; 1215 | if (mtype == Thrift.MessageType.EXCEPTION) { 1216 | var x = new Thrift.TApplicationException() 1217 | x.read(input) 1218 | input.readMessageEnd() 1219 | return callback(x); 1220 | } 1221 | var result = new FacebookService_getStatusDetails_result() 1222 | result.read(input) 1223 | input.readMessageEnd() 1224 | 1225 | if (null != result.success ) { 1226 | return callback(null, result.success); 1227 | } 1228 | return callback("getStatusDetails failed: unknown result"); 1229 | } 1230 | FacebookServiceClient.prototype.getCounters = function(callback){ 1231 | this.seqid += 1; 1232 | this._reqs[this.seqid] = callback; 1233 | this.send_getCounters() 1234 | } 1235 | 1236 | FacebookServiceClient.prototype.send_getCounters = function(){ 1237 | var output = new this.pClass(this.output); 1238 | output.writeMessageBegin('getCounters', Thrift.MessageType.CALL, this.seqid) 1239 | var args = new FacebookService_getCounters_args() 1240 | args.write(output) 1241 | output.writeMessageEnd() 1242 | return this.output.flush() 1243 | } 1244 | 1245 | FacebookServiceClient.prototype.recv_getCounters = function(input,mtype,rseqid){ 1246 | var callback = this._reqs[rseqid] || function() {}; 1247 | delete this._reqs[rseqid]; 1248 | if (mtype == Thrift.MessageType.EXCEPTION) { 1249 | var x = new Thrift.TApplicationException() 1250 | x.read(input) 1251 | input.readMessageEnd() 1252 | return callback(x); 1253 | } 1254 | var result = new FacebookService_getCounters_result() 1255 | result.read(input) 1256 | input.readMessageEnd() 1257 | 1258 | if (null != result.success ) { 1259 | return callback(null, result.success); 1260 | } 1261 | return callback("getCounters failed: unknown result"); 1262 | } 1263 | FacebookServiceClient.prototype.getCounter = function(key,callback){ 1264 | this.seqid += 1; 1265 | this._reqs[this.seqid] = callback; 1266 | this.send_getCounter(key) 1267 | } 1268 | 1269 | FacebookServiceClient.prototype.send_getCounter = function(key){ 1270 | var output = new this.pClass(this.output); 1271 | output.writeMessageBegin('getCounter', Thrift.MessageType.CALL, this.seqid) 1272 | var args = new FacebookService_getCounter_args() 1273 | args.key = key 1274 | args.write(output) 1275 | output.writeMessageEnd() 1276 | return this.output.flush() 1277 | } 1278 | 1279 | FacebookServiceClient.prototype.recv_getCounter = function(input,mtype,rseqid){ 1280 | var callback = this._reqs[rseqid] || function() {}; 1281 | delete this._reqs[rseqid]; 1282 | if (mtype == Thrift.MessageType.EXCEPTION) { 1283 | var x = new Thrift.TApplicationException() 1284 | x.read(input) 1285 | input.readMessageEnd() 1286 | return callback(x); 1287 | } 1288 | var result = new FacebookService_getCounter_result() 1289 | result.read(input) 1290 | input.readMessageEnd() 1291 | 1292 | if (null != result.success ) { 1293 | return callback(null, result.success); 1294 | } 1295 | return callback("getCounter failed: unknown result"); 1296 | } 1297 | FacebookServiceClient.prototype.setOption = function(key,value,callback){ 1298 | this.seqid += 1; 1299 | this._reqs[this.seqid] = callback; 1300 | this.send_setOption(key, value) 1301 | } 1302 | 1303 | FacebookServiceClient.prototype.send_setOption = function(key,value){ 1304 | var output = new this.pClass(this.output); 1305 | output.writeMessageBegin('setOption', Thrift.MessageType.CALL, this.seqid) 1306 | var args = new FacebookService_setOption_args() 1307 | args.key = key 1308 | args.value = value 1309 | args.write(output) 1310 | output.writeMessageEnd() 1311 | return this.output.flush() 1312 | } 1313 | 1314 | FacebookServiceClient.prototype.recv_setOption = function(input,mtype,rseqid){ 1315 | var callback = this._reqs[rseqid] || function() {}; 1316 | delete this._reqs[rseqid]; 1317 | if (mtype == Thrift.MessageType.EXCEPTION) { 1318 | var x = new Thrift.TApplicationException() 1319 | x.read(input) 1320 | input.readMessageEnd() 1321 | return callback(x); 1322 | } 1323 | var result = new FacebookService_setOption_result() 1324 | result.read(input) 1325 | input.readMessageEnd() 1326 | 1327 | callback(null) 1328 | } 1329 | FacebookServiceClient.prototype.getOption = function(key,callback){ 1330 | this.seqid += 1; 1331 | this._reqs[this.seqid] = callback; 1332 | this.send_getOption(key) 1333 | } 1334 | 1335 | FacebookServiceClient.prototype.send_getOption = function(key){ 1336 | var output = new this.pClass(this.output); 1337 | output.writeMessageBegin('getOption', Thrift.MessageType.CALL, this.seqid) 1338 | var args = new FacebookService_getOption_args() 1339 | args.key = key 1340 | args.write(output) 1341 | output.writeMessageEnd() 1342 | return this.output.flush() 1343 | } 1344 | 1345 | FacebookServiceClient.prototype.recv_getOption = function(input,mtype,rseqid){ 1346 | var callback = this._reqs[rseqid] || function() {}; 1347 | delete this._reqs[rseqid]; 1348 | if (mtype == Thrift.MessageType.EXCEPTION) { 1349 | var x = new Thrift.TApplicationException() 1350 | x.read(input) 1351 | input.readMessageEnd() 1352 | return callback(x); 1353 | } 1354 | var result = new FacebookService_getOption_result() 1355 | result.read(input) 1356 | input.readMessageEnd() 1357 | 1358 | if (null != result.success ) { 1359 | return callback(null, result.success); 1360 | } 1361 | return callback("getOption failed: unknown result"); 1362 | } 1363 | FacebookServiceClient.prototype.getOptions = function(callback){ 1364 | this.seqid += 1; 1365 | this._reqs[this.seqid] = callback; 1366 | this.send_getOptions() 1367 | } 1368 | 1369 | FacebookServiceClient.prototype.send_getOptions = function(){ 1370 | var output = new this.pClass(this.output); 1371 | output.writeMessageBegin('getOptions', Thrift.MessageType.CALL, this.seqid) 1372 | var args = new FacebookService_getOptions_args() 1373 | args.write(output) 1374 | output.writeMessageEnd() 1375 | return this.output.flush() 1376 | } 1377 | 1378 | FacebookServiceClient.prototype.recv_getOptions = function(input,mtype,rseqid){ 1379 | var callback = this._reqs[rseqid] || function() {}; 1380 | delete this._reqs[rseqid]; 1381 | if (mtype == Thrift.MessageType.EXCEPTION) { 1382 | var x = new Thrift.TApplicationException() 1383 | x.read(input) 1384 | input.readMessageEnd() 1385 | return callback(x); 1386 | } 1387 | var result = new FacebookService_getOptions_result() 1388 | result.read(input) 1389 | input.readMessageEnd() 1390 | 1391 | if (null != result.success ) { 1392 | return callback(null, result.success); 1393 | } 1394 | return callback("getOptions failed: unknown result"); 1395 | } 1396 | FacebookServiceClient.prototype.getCpuProfile = function(profileDurationInSec,callback){ 1397 | this.seqid += 1; 1398 | this._reqs[this.seqid] = callback; 1399 | this.send_getCpuProfile(profileDurationInSec) 1400 | } 1401 | 1402 | FacebookServiceClient.prototype.send_getCpuProfile = function(profileDurationInSec){ 1403 | var output = new this.pClass(this.output); 1404 | output.writeMessageBegin('getCpuProfile', Thrift.MessageType.CALL, this.seqid) 1405 | var args = new FacebookService_getCpuProfile_args() 1406 | args.profileDurationInSec = profileDurationInSec 1407 | args.write(output) 1408 | output.writeMessageEnd() 1409 | return this.output.flush() 1410 | } 1411 | 1412 | FacebookServiceClient.prototype.recv_getCpuProfile = function(input,mtype,rseqid){ 1413 | var callback = this._reqs[rseqid] || function() {}; 1414 | delete this._reqs[rseqid]; 1415 | if (mtype == Thrift.MessageType.EXCEPTION) { 1416 | var x = new Thrift.TApplicationException() 1417 | x.read(input) 1418 | input.readMessageEnd() 1419 | return callback(x); 1420 | } 1421 | var result = new FacebookService_getCpuProfile_result() 1422 | result.read(input) 1423 | input.readMessageEnd() 1424 | 1425 | if (null != result.success ) { 1426 | return callback(null, result.success); 1427 | } 1428 | return callback("getCpuProfile failed: unknown result"); 1429 | } 1430 | FacebookServiceClient.prototype.aliveSince = function(callback){ 1431 | this.seqid += 1; 1432 | this._reqs[this.seqid] = callback; 1433 | this.send_aliveSince() 1434 | } 1435 | 1436 | FacebookServiceClient.prototype.send_aliveSince = function(){ 1437 | var output = new this.pClass(this.output); 1438 | output.writeMessageBegin('aliveSince', Thrift.MessageType.CALL, this.seqid) 1439 | var args = new FacebookService_aliveSince_args() 1440 | args.write(output) 1441 | output.writeMessageEnd() 1442 | return this.output.flush() 1443 | } 1444 | 1445 | FacebookServiceClient.prototype.recv_aliveSince = function(input,mtype,rseqid){ 1446 | var callback = this._reqs[rseqid] || function() {}; 1447 | delete this._reqs[rseqid]; 1448 | if (mtype == Thrift.MessageType.EXCEPTION) { 1449 | var x = new Thrift.TApplicationException() 1450 | x.read(input) 1451 | input.readMessageEnd() 1452 | return callback(x); 1453 | } 1454 | var result = new FacebookService_aliveSince_result() 1455 | result.read(input) 1456 | input.readMessageEnd() 1457 | 1458 | if (null != result.success ) { 1459 | return callback(null, result.success); 1460 | } 1461 | return callback("aliveSince failed: unknown result"); 1462 | } 1463 | FacebookServiceClient.prototype.reinitialize = function(callback){ 1464 | this.seqid += 1; 1465 | this._reqs[this.seqid] = callback; 1466 | this.send_reinitialize() 1467 | } 1468 | 1469 | FacebookServiceClient.prototype.send_reinitialize = function(){ 1470 | var output = new this.pClass(this.output); 1471 | output.writeMessageBegin('reinitialize', Thrift.MessageType.CALL, this.seqid) 1472 | var args = new FacebookService_reinitialize_args() 1473 | args.write(output) 1474 | output.writeMessageEnd() 1475 | return this.output.flush() 1476 | } 1477 | FacebookServiceClient.prototype.shutdown = function(callback){ 1478 | this.seqid += 1; 1479 | this._reqs[this.seqid] = callback; 1480 | this.send_shutdown() 1481 | } 1482 | 1483 | FacebookServiceClient.prototype.send_shutdown = function(){ 1484 | var output = new this.pClass(this.output); 1485 | output.writeMessageBegin('shutdown', Thrift.MessageType.CALL, this.seqid) 1486 | var args = new FacebookService_shutdown_args() 1487 | args.write(output) 1488 | output.writeMessageEnd() 1489 | return this.output.flush() 1490 | } 1491 | var FacebookServiceProcessor = exports.Processor = function(handler) { 1492 | this._handler = handler 1493 | } 1494 | FacebookServiceProcessor.prototype.process = function(input, output) { 1495 | var r = input.readMessageBegin() 1496 | if (this['process_' + r.fname]) { 1497 | return this['process_' + r.fname].call(this, r.rseqid, input, output) 1498 | } else { 1499 | input.skip(Thrift.Type.STRUCT) 1500 | input.readMessageEnd() 1501 | var x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname) 1502 | output.writeMessageBegin(r.fname, Thrift.MessageType.Exception, r.rseqid) 1503 | x.write(output) 1504 | output.writeMessageEnd() 1505 | output.flush() 1506 | } 1507 | } 1508 | 1509 | FacebookServiceProcessor.prototype.process_getName = function(seqid, input, output) { 1510 | var args = new FacebookService_getName_args() 1511 | args.read(input) 1512 | input.readMessageEnd() 1513 | var result = new FacebookService_getName_result() 1514 | this._handler.getName(function(success) { 1515 | result.success = success 1516 | output.writeMessageBegin("getName", Thrift.MessageType.REPLY, seqid) 1517 | result.write(output) 1518 | output.writeMessageEnd() 1519 | output.flush() 1520 | }) 1521 | } 1522 | 1523 | FacebookServiceProcessor.prototype.process_getVersion = function(seqid, input, output) { 1524 | var args = new FacebookService_getVersion_args() 1525 | args.read(input) 1526 | input.readMessageEnd() 1527 | var result = new FacebookService_getVersion_result() 1528 | this._handler.getVersion(function(success) { 1529 | result.success = success 1530 | output.writeMessageBegin("getVersion", Thrift.MessageType.REPLY, seqid) 1531 | result.write(output) 1532 | output.writeMessageEnd() 1533 | output.flush() 1534 | }) 1535 | } 1536 | 1537 | FacebookServiceProcessor.prototype.process_getStatus = function(seqid, input, output) { 1538 | var args = new FacebookService_getStatus_args() 1539 | args.read(input) 1540 | input.readMessageEnd() 1541 | var result = new FacebookService_getStatus_result() 1542 | this._handler.getStatus(function(success) { 1543 | result.success = success 1544 | output.writeMessageBegin("getStatus", Thrift.MessageType.REPLY, seqid) 1545 | result.write(output) 1546 | output.writeMessageEnd() 1547 | output.flush() 1548 | }) 1549 | } 1550 | 1551 | FacebookServiceProcessor.prototype.process_getStatusDetails = function(seqid, input, output) { 1552 | var args = new FacebookService_getStatusDetails_args() 1553 | args.read(input) 1554 | input.readMessageEnd() 1555 | var result = new FacebookService_getStatusDetails_result() 1556 | this._handler.getStatusDetails(function(success) { 1557 | result.success = success 1558 | output.writeMessageBegin("getStatusDetails", Thrift.MessageType.REPLY, seqid) 1559 | result.write(output) 1560 | output.writeMessageEnd() 1561 | output.flush() 1562 | }) 1563 | } 1564 | 1565 | FacebookServiceProcessor.prototype.process_getCounters = function(seqid, input, output) { 1566 | var args = new FacebookService_getCounters_args() 1567 | args.read(input) 1568 | input.readMessageEnd() 1569 | var result = new FacebookService_getCounters_result() 1570 | this._handler.getCounters(function(success) { 1571 | result.success = success 1572 | output.writeMessageBegin("getCounters", Thrift.MessageType.REPLY, seqid) 1573 | result.write(output) 1574 | output.writeMessageEnd() 1575 | output.flush() 1576 | }) 1577 | } 1578 | 1579 | FacebookServiceProcessor.prototype.process_getCounter = function(seqid, input, output) { 1580 | var args = new FacebookService_getCounter_args() 1581 | args.read(input) 1582 | input.readMessageEnd() 1583 | var result = new FacebookService_getCounter_result() 1584 | this._handler.getCounter(args.key, function(success) { 1585 | result.success = success 1586 | output.writeMessageBegin("getCounter", Thrift.MessageType.REPLY, seqid) 1587 | result.write(output) 1588 | output.writeMessageEnd() 1589 | output.flush() 1590 | }) 1591 | } 1592 | 1593 | FacebookServiceProcessor.prototype.process_setOption = function(seqid, input, output) { 1594 | var args = new FacebookService_setOption_args() 1595 | args.read(input) 1596 | input.readMessageEnd() 1597 | var result = new FacebookService_setOption_result() 1598 | this._handler.setOption(args.key, args.value, function(success) { 1599 | result.success = success 1600 | output.writeMessageBegin("setOption", Thrift.MessageType.REPLY, seqid) 1601 | result.write(output) 1602 | output.writeMessageEnd() 1603 | output.flush() 1604 | }) 1605 | } 1606 | 1607 | FacebookServiceProcessor.prototype.process_getOption = function(seqid, input, output) { 1608 | var args = new FacebookService_getOption_args() 1609 | args.read(input) 1610 | input.readMessageEnd() 1611 | var result = new FacebookService_getOption_result() 1612 | this._handler.getOption(args.key, function(success) { 1613 | result.success = success 1614 | output.writeMessageBegin("getOption", Thrift.MessageType.REPLY, seqid) 1615 | result.write(output) 1616 | output.writeMessageEnd() 1617 | output.flush() 1618 | }) 1619 | } 1620 | 1621 | FacebookServiceProcessor.prototype.process_getOptions = function(seqid, input, output) { 1622 | var args = new FacebookService_getOptions_args() 1623 | args.read(input) 1624 | input.readMessageEnd() 1625 | var result = new FacebookService_getOptions_result() 1626 | this._handler.getOptions(function(success) { 1627 | result.success = success 1628 | output.writeMessageBegin("getOptions", Thrift.MessageType.REPLY, seqid) 1629 | result.write(output) 1630 | output.writeMessageEnd() 1631 | output.flush() 1632 | }) 1633 | } 1634 | 1635 | FacebookServiceProcessor.prototype.process_getCpuProfile = function(seqid, input, output) { 1636 | var args = new FacebookService_getCpuProfile_args() 1637 | args.read(input) 1638 | input.readMessageEnd() 1639 | var result = new FacebookService_getCpuProfile_result() 1640 | this._handler.getCpuProfile(args.profileDurationInSec, function(success) { 1641 | result.success = success 1642 | output.writeMessageBegin("getCpuProfile", Thrift.MessageType.REPLY, seqid) 1643 | result.write(output) 1644 | output.writeMessageEnd() 1645 | output.flush() 1646 | }) 1647 | } 1648 | 1649 | FacebookServiceProcessor.prototype.process_aliveSince = function(seqid, input, output) { 1650 | var args = new FacebookService_aliveSince_args() 1651 | args.read(input) 1652 | input.readMessageEnd() 1653 | var result = new FacebookService_aliveSince_result() 1654 | this._handler.aliveSince(function(success) { 1655 | result.success = success 1656 | output.writeMessageBegin("aliveSince", Thrift.MessageType.REPLY, seqid) 1657 | result.write(output) 1658 | output.writeMessageEnd() 1659 | output.flush() 1660 | }) 1661 | } 1662 | 1663 | FacebookServiceProcessor.prototype.process_reinitialize = function(seqid, input, output) { 1664 | var args = new FacebookService_reinitialize_args() 1665 | args.read(input) 1666 | input.readMessageEnd() 1667 | this._handler.reinitialize() 1668 | } 1669 | 1670 | FacebookServiceProcessor.prototype.process_shutdown = function(seqid, input, output) { 1671 | var args = new FacebookService_shutdown_args() 1672 | args.read(input) 1673 | input.readMessageEnd() 1674 | this._handler.shutdown() 1675 | } 1676 | 1677 | -------------------------------------------------------------------------------- /node_modules/gen-nodejs/ThriftHive.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | var Thrift = require('thrift').Thrift; 7 | var fb303_ttypes = require('./fb303_types') 8 | var hive_metastore_ttypes = require('./hive_metastore_types') 9 | var queryplan_ttypes = require('./queryplan_types') 10 | 11 | 12 | var ThriftHiveMetastore = require('./ThriftHiveMetastore') 13 | var ThriftHiveMetastoreClient = ThriftHiveMetastore.Client 14 | var ttypes = require('./hive_service_types'); 15 | //HELPER FUNCTIONS AND STRUCTURES 16 | 17 | var ThriftHive_execute_args = function(args){ 18 | this.query = null 19 | if( args != null ){ if (null != args.query) 20 | this.query = args.query 21 | }} 22 | ThriftHive_execute_args.prototype = {} 23 | ThriftHive_execute_args.prototype.read = function(input){ 24 | var ret = input.readStructBegin() 25 | while (1) 26 | { 27 | var ret = input.readFieldBegin() 28 | var fname = ret.fname 29 | var ftype = ret.ftype 30 | var fid = ret.fid 31 | if (ftype == Thrift.Type.STOP) 32 | break 33 | switch(fid) 34 | { 35 | case 1: if (ftype == Thrift.Type.STRING) { 36 | this.query = input.readString() 37 | } else { 38 | input.skip(ftype) 39 | } 40 | break 41 | default: 42 | input.skip(ftype) 43 | } 44 | input.readFieldEnd() 45 | } 46 | input.readStructEnd() 47 | return 48 | } 49 | 50 | ThriftHive_execute_args.prototype.write = function(output){ 51 | output.writeStructBegin('ThriftHive_execute_args') 52 | if (null != this.query) { 53 | output.writeFieldBegin('query', Thrift.Type.STRING, 1) 54 | output.writeString(this.query) 55 | output.writeFieldEnd() 56 | } 57 | output.writeFieldStop() 58 | output.writeStructEnd() 59 | return 60 | } 61 | 62 | var ThriftHive_execute_result = function(args){ 63 | this.ex = null 64 | if( args != null ){ if (null != args.ex) 65 | this.ex = args.ex 66 | }} 67 | ThriftHive_execute_result.prototype = {} 68 | ThriftHive_execute_result.prototype.read = function(input){ 69 | var ret = input.readStructBegin() 70 | while (1) 71 | { 72 | var ret = input.readFieldBegin() 73 | var fname = ret.fname 74 | var ftype = ret.ftype 75 | var fid = ret.fid 76 | if (ftype == Thrift.Type.STOP) 77 | break 78 | switch(fid) 79 | { 80 | case 1: if (ftype == Thrift.Type.STRUCT) { 81 | this.ex = new ttypes.HiveServerException() 82 | this.ex.read(input) 83 | } else { 84 | input.skip(ftype) 85 | } 86 | break 87 | default: 88 | input.skip(ftype) 89 | } 90 | input.readFieldEnd() 91 | } 92 | input.readStructEnd() 93 | return 94 | } 95 | 96 | ThriftHive_execute_result.prototype.write = function(output){ 97 | output.writeStructBegin('ThriftHive_execute_result') 98 | if (null != this.ex) { 99 | output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1) 100 | this.ex.write(output) 101 | output.writeFieldEnd() 102 | } 103 | output.writeFieldStop() 104 | output.writeStructEnd() 105 | return 106 | } 107 | 108 | var ThriftHive_fetchOne_args = function(args){ 109 | } 110 | ThriftHive_fetchOne_args.prototype = {} 111 | ThriftHive_fetchOne_args.prototype.read = function(input){ 112 | var ret = input.readStructBegin() 113 | while (1) 114 | { 115 | var ret = input.readFieldBegin() 116 | var fname = ret.fname 117 | var ftype = ret.ftype 118 | var fid = ret.fid 119 | if (ftype == Thrift.Type.STOP) 120 | break 121 | switch(fid) 122 | { 123 | default: 124 | input.skip(ftype) 125 | } 126 | input.readFieldEnd() 127 | } 128 | input.readStructEnd() 129 | return 130 | } 131 | 132 | ThriftHive_fetchOne_args.prototype.write = function(output){ 133 | output.writeStructBegin('ThriftHive_fetchOne_args') 134 | output.writeFieldStop() 135 | output.writeStructEnd() 136 | return 137 | } 138 | 139 | var ThriftHive_fetchOne_result = function(args){ 140 | this.success = null 141 | this.ex = null 142 | if( args != null ){ if (null != args.success) 143 | this.success = args.success 144 | if (null != args.ex) 145 | this.ex = args.ex 146 | }} 147 | ThriftHive_fetchOne_result.prototype = {} 148 | ThriftHive_fetchOne_result.prototype.read = function(input){ 149 | var ret = input.readStructBegin() 150 | while (1) 151 | { 152 | var ret = input.readFieldBegin() 153 | var fname = ret.fname 154 | var ftype = ret.ftype 155 | var fid = ret.fid 156 | if (ftype == Thrift.Type.STOP) 157 | break 158 | switch(fid) 159 | { 160 | case 0: if (ftype == Thrift.Type.STRING) { 161 | this.success = input.readString() 162 | } else { 163 | input.skip(ftype) 164 | } 165 | break 166 | case 1: if (ftype == Thrift.Type.STRUCT) { 167 | this.ex = new ttypes.HiveServerException() 168 | this.ex.read(input) 169 | } else { 170 | input.skip(ftype) 171 | } 172 | break 173 | default: 174 | input.skip(ftype) 175 | } 176 | input.readFieldEnd() 177 | } 178 | input.readStructEnd() 179 | return 180 | } 181 | 182 | ThriftHive_fetchOne_result.prototype.write = function(output){ 183 | output.writeStructBegin('ThriftHive_fetchOne_result') 184 | if (null != this.success) { 185 | output.writeFieldBegin('success', Thrift.Type.STRING, 0) 186 | output.writeString(this.success) 187 | output.writeFieldEnd() 188 | } 189 | if (null != this.ex) { 190 | output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1) 191 | this.ex.write(output) 192 | output.writeFieldEnd() 193 | } 194 | output.writeFieldStop() 195 | output.writeStructEnd() 196 | return 197 | } 198 | 199 | var ThriftHive_fetchN_args = function(args){ 200 | this.numRows = null 201 | if( args != null ){ if (null != args.numRows) 202 | this.numRows = args.numRows 203 | }} 204 | ThriftHive_fetchN_args.prototype = {} 205 | ThriftHive_fetchN_args.prototype.read = function(input){ 206 | var ret = input.readStructBegin() 207 | while (1) 208 | { 209 | var ret = input.readFieldBegin() 210 | var fname = ret.fname 211 | var ftype = ret.ftype 212 | var fid = ret.fid 213 | if (ftype == Thrift.Type.STOP) 214 | break 215 | switch(fid) 216 | { 217 | case 1: if (ftype == Thrift.Type.I32) { 218 | this.numRows = input.readI32() 219 | } else { 220 | input.skip(ftype) 221 | } 222 | break 223 | default: 224 | input.skip(ftype) 225 | } 226 | input.readFieldEnd() 227 | } 228 | input.readStructEnd() 229 | return 230 | } 231 | 232 | ThriftHive_fetchN_args.prototype.write = function(output){ 233 | output.writeStructBegin('ThriftHive_fetchN_args') 234 | if (null != this.numRows) { 235 | output.writeFieldBegin('numRows', Thrift.Type.I32, 1) 236 | output.writeI32(this.numRows) 237 | output.writeFieldEnd() 238 | } 239 | output.writeFieldStop() 240 | output.writeStructEnd() 241 | return 242 | } 243 | 244 | var ThriftHive_fetchN_result = function(args){ 245 | this.success = null 246 | this.ex = null 247 | if( args != null ){ if (null != args.success) 248 | this.success = args.success 249 | if (null != args.ex) 250 | this.ex = args.ex 251 | }} 252 | ThriftHive_fetchN_result.prototype = {} 253 | ThriftHive_fetchN_result.prototype.read = function(input){ 254 | var ret = input.readStructBegin() 255 | while (1) 256 | { 257 | var ret = input.readFieldBegin() 258 | var fname = ret.fname 259 | var ftype = ret.ftype 260 | var fid = ret.fid 261 | if (ftype == Thrift.Type.STOP) 262 | break 263 | switch(fid) 264 | { 265 | case 0: if (ftype == Thrift.Type.LIST) { 266 | { 267 | var _size0 = 0 268 | var rtmp3 269 | this.success = [] 270 | var _etype3 = 0 271 | rtmp3 = input.readListBegin() 272 | _etype3 = rtmp3.etype 273 | _size0 = rtmp3.size 274 | for (var _i4 = 0; _i4 < _size0; ++_i4) 275 | { 276 | var elem5 = null 277 | elem5 = input.readString() 278 | this.success.push(elem5) 279 | } 280 | input.readListEnd() 281 | } 282 | } else { 283 | input.skip(ftype) 284 | } 285 | break 286 | case 1: if (ftype == Thrift.Type.STRUCT) { 287 | this.ex = new ttypes.HiveServerException() 288 | this.ex.read(input) 289 | } else { 290 | input.skip(ftype) 291 | } 292 | break 293 | default: 294 | input.skip(ftype) 295 | } 296 | input.readFieldEnd() 297 | } 298 | input.readStructEnd() 299 | return 300 | } 301 | 302 | ThriftHive_fetchN_result.prototype.write = function(output){ 303 | output.writeStructBegin('ThriftHive_fetchN_result') 304 | if (null != this.success) { 305 | output.writeFieldBegin('success', Thrift.Type.LIST, 0) 306 | { 307 | output.writeListBegin(Thrift.Type.STRING, this.success.length) 308 | { 309 | for(var iter6 in this.success) 310 | { 311 | if (this.success.hasOwnProperty(iter6)) 312 | { 313 | iter6=this.success[iter6] 314 | output.writeString(iter6) 315 | } 316 | } 317 | } 318 | output.writeListEnd() 319 | } 320 | output.writeFieldEnd() 321 | } 322 | if (null != this.ex) { 323 | output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1) 324 | this.ex.write(output) 325 | output.writeFieldEnd() 326 | } 327 | output.writeFieldStop() 328 | output.writeStructEnd() 329 | return 330 | } 331 | 332 | var ThriftHive_fetchAll_args = function(args){ 333 | } 334 | ThriftHive_fetchAll_args.prototype = {} 335 | ThriftHive_fetchAll_args.prototype.read = function(input){ 336 | var ret = input.readStructBegin() 337 | while (1) 338 | { 339 | var ret = input.readFieldBegin() 340 | var fname = ret.fname 341 | var ftype = ret.ftype 342 | var fid = ret.fid 343 | if (ftype == Thrift.Type.STOP) 344 | break 345 | switch(fid) 346 | { 347 | default: 348 | input.skip(ftype) 349 | } 350 | input.readFieldEnd() 351 | } 352 | input.readStructEnd() 353 | return 354 | } 355 | 356 | ThriftHive_fetchAll_args.prototype.write = function(output){ 357 | output.writeStructBegin('ThriftHive_fetchAll_args') 358 | output.writeFieldStop() 359 | output.writeStructEnd() 360 | return 361 | } 362 | 363 | var ThriftHive_fetchAll_result = function(args){ 364 | this.success = null 365 | this.ex = null 366 | if( args != null ){ if (null != args.success) 367 | this.success = args.success 368 | if (null != args.ex) 369 | this.ex = args.ex 370 | }} 371 | ThriftHive_fetchAll_result.prototype = {} 372 | ThriftHive_fetchAll_result.prototype.read = function(input){ 373 | var ret = input.readStructBegin() 374 | while (1) 375 | { 376 | var ret = input.readFieldBegin() 377 | var fname = ret.fname 378 | var ftype = ret.ftype 379 | var fid = ret.fid 380 | if (ftype == Thrift.Type.STOP) 381 | break 382 | switch(fid) 383 | { 384 | case 0: if (ftype == Thrift.Type.LIST) { 385 | { 386 | var _size7 = 0 387 | var rtmp3 388 | this.success = [] 389 | var _etype10 = 0 390 | rtmp3 = input.readListBegin() 391 | _etype10 = rtmp3.etype 392 | _size7 = rtmp3.size 393 | for (var _i11 = 0; _i11 < _size7; ++_i11) 394 | { 395 | var elem12 = null 396 | elem12 = input.readString() 397 | this.success.push(elem12) 398 | } 399 | input.readListEnd() 400 | } 401 | } else { 402 | input.skip(ftype) 403 | } 404 | break 405 | case 1: if (ftype == Thrift.Type.STRUCT) { 406 | this.ex = new ttypes.HiveServerException() 407 | this.ex.read(input) 408 | } else { 409 | input.skip(ftype) 410 | } 411 | break 412 | default: 413 | input.skip(ftype) 414 | } 415 | input.readFieldEnd() 416 | } 417 | input.readStructEnd() 418 | return 419 | } 420 | 421 | ThriftHive_fetchAll_result.prototype.write = function(output){ 422 | output.writeStructBegin('ThriftHive_fetchAll_result') 423 | if (null != this.success) { 424 | output.writeFieldBegin('success', Thrift.Type.LIST, 0) 425 | { 426 | output.writeListBegin(Thrift.Type.STRING, this.success.length) 427 | { 428 | for(var iter13 in this.success) 429 | { 430 | if (this.success.hasOwnProperty(iter13)) 431 | { 432 | iter13=this.success[iter13] 433 | output.writeString(iter13) 434 | } 435 | } 436 | } 437 | output.writeListEnd() 438 | } 439 | output.writeFieldEnd() 440 | } 441 | if (null != this.ex) { 442 | output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1) 443 | this.ex.write(output) 444 | output.writeFieldEnd() 445 | } 446 | output.writeFieldStop() 447 | output.writeStructEnd() 448 | return 449 | } 450 | 451 | var ThriftHive_getSchema_args = function(args){ 452 | } 453 | ThriftHive_getSchema_args.prototype = {} 454 | ThriftHive_getSchema_args.prototype.read = function(input){ 455 | var ret = input.readStructBegin() 456 | while (1) 457 | { 458 | var ret = input.readFieldBegin() 459 | var fname = ret.fname 460 | var ftype = ret.ftype 461 | var fid = ret.fid 462 | if (ftype == Thrift.Type.STOP) 463 | break 464 | switch(fid) 465 | { 466 | default: 467 | input.skip(ftype) 468 | } 469 | input.readFieldEnd() 470 | } 471 | input.readStructEnd() 472 | return 473 | } 474 | 475 | ThriftHive_getSchema_args.prototype.write = function(output){ 476 | output.writeStructBegin('ThriftHive_getSchema_args') 477 | output.writeFieldStop() 478 | output.writeStructEnd() 479 | return 480 | } 481 | 482 | var ThriftHive_getSchema_result = function(args){ 483 | this.success = null 484 | this.ex = null 485 | if( args != null ){ if (null != args.success) 486 | this.success = args.success 487 | if (null != args.ex) 488 | this.ex = args.ex 489 | }} 490 | ThriftHive_getSchema_result.prototype = {} 491 | ThriftHive_getSchema_result.prototype.read = function(input){ 492 | var ret = input.readStructBegin() 493 | while (1) 494 | { 495 | var ret = input.readFieldBegin() 496 | var fname = ret.fname 497 | var ftype = ret.ftype 498 | var fid = ret.fid 499 | if (ftype == Thrift.Type.STOP) 500 | break 501 | switch(fid) 502 | { 503 | case 0: if (ftype == Thrift.Type.STRUCT) { 504 | this.success = new hive_metastore_ttypes.Schema() 505 | this.success.read(input) 506 | } else { 507 | input.skip(ftype) 508 | } 509 | break 510 | case 1: if (ftype == Thrift.Type.STRUCT) { 511 | this.ex = new ttypes.HiveServerException() 512 | this.ex.read(input) 513 | } else { 514 | input.skip(ftype) 515 | } 516 | break 517 | default: 518 | input.skip(ftype) 519 | } 520 | input.readFieldEnd() 521 | } 522 | input.readStructEnd() 523 | return 524 | } 525 | 526 | ThriftHive_getSchema_result.prototype.write = function(output){ 527 | output.writeStructBegin('ThriftHive_getSchema_result') 528 | if (null != this.success) { 529 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0) 530 | this.success.write(output) 531 | output.writeFieldEnd() 532 | } 533 | if (null != this.ex) { 534 | output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1) 535 | this.ex.write(output) 536 | output.writeFieldEnd() 537 | } 538 | output.writeFieldStop() 539 | output.writeStructEnd() 540 | return 541 | } 542 | 543 | var ThriftHive_getThriftSchema_args = function(args){ 544 | } 545 | ThriftHive_getThriftSchema_args.prototype = {} 546 | ThriftHive_getThriftSchema_args.prototype.read = function(input){ 547 | var ret = input.readStructBegin() 548 | while (1) 549 | { 550 | var ret = input.readFieldBegin() 551 | var fname = ret.fname 552 | var ftype = ret.ftype 553 | var fid = ret.fid 554 | if (ftype == Thrift.Type.STOP) 555 | break 556 | switch(fid) 557 | { 558 | default: 559 | input.skip(ftype) 560 | } 561 | input.readFieldEnd() 562 | } 563 | input.readStructEnd() 564 | return 565 | } 566 | 567 | ThriftHive_getThriftSchema_args.prototype.write = function(output){ 568 | output.writeStructBegin('ThriftHive_getThriftSchema_args') 569 | output.writeFieldStop() 570 | output.writeStructEnd() 571 | return 572 | } 573 | 574 | var ThriftHive_getThriftSchema_result = function(args){ 575 | this.success = null 576 | this.ex = null 577 | if( args != null ){ if (null != args.success) 578 | this.success = args.success 579 | if (null != args.ex) 580 | this.ex = args.ex 581 | }} 582 | ThriftHive_getThriftSchema_result.prototype = {} 583 | ThriftHive_getThriftSchema_result.prototype.read = function(input){ 584 | var ret = input.readStructBegin() 585 | while (1) 586 | { 587 | var ret = input.readFieldBegin() 588 | var fname = ret.fname 589 | var ftype = ret.ftype 590 | var fid = ret.fid 591 | if (ftype == Thrift.Type.STOP) 592 | break 593 | switch(fid) 594 | { 595 | case 0: if (ftype == Thrift.Type.STRUCT) { 596 | this.success = new hive_metastore_ttypes.Schema() 597 | this.success.read(input) 598 | } else { 599 | input.skip(ftype) 600 | } 601 | break 602 | case 1: if (ftype == Thrift.Type.STRUCT) { 603 | this.ex = new ttypes.HiveServerException() 604 | this.ex.read(input) 605 | } else { 606 | input.skip(ftype) 607 | } 608 | break 609 | default: 610 | input.skip(ftype) 611 | } 612 | input.readFieldEnd() 613 | } 614 | input.readStructEnd() 615 | return 616 | } 617 | 618 | ThriftHive_getThriftSchema_result.prototype.write = function(output){ 619 | output.writeStructBegin('ThriftHive_getThriftSchema_result') 620 | if (null != this.success) { 621 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0) 622 | this.success.write(output) 623 | output.writeFieldEnd() 624 | } 625 | if (null != this.ex) { 626 | output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1) 627 | this.ex.write(output) 628 | output.writeFieldEnd() 629 | } 630 | output.writeFieldStop() 631 | output.writeStructEnd() 632 | return 633 | } 634 | 635 | var ThriftHive_getClusterStatus_args = function(args){ 636 | } 637 | ThriftHive_getClusterStatus_args.prototype = {} 638 | ThriftHive_getClusterStatus_args.prototype.read = function(input){ 639 | var ret = input.readStructBegin() 640 | while (1) 641 | { 642 | var ret = input.readFieldBegin() 643 | var fname = ret.fname 644 | var ftype = ret.ftype 645 | var fid = ret.fid 646 | if (ftype == Thrift.Type.STOP) 647 | break 648 | switch(fid) 649 | { 650 | default: 651 | input.skip(ftype) 652 | } 653 | input.readFieldEnd() 654 | } 655 | input.readStructEnd() 656 | return 657 | } 658 | 659 | ThriftHive_getClusterStatus_args.prototype.write = function(output){ 660 | output.writeStructBegin('ThriftHive_getClusterStatus_args') 661 | output.writeFieldStop() 662 | output.writeStructEnd() 663 | return 664 | } 665 | 666 | var ThriftHive_getClusterStatus_result = function(args){ 667 | this.success = null 668 | this.ex = null 669 | if( args != null ){ if (null != args.success) 670 | this.success = args.success 671 | if (null != args.ex) 672 | this.ex = args.ex 673 | }} 674 | ThriftHive_getClusterStatus_result.prototype = {} 675 | ThriftHive_getClusterStatus_result.prototype.read = function(input){ 676 | var ret = input.readStructBegin() 677 | while (1) 678 | { 679 | var ret = input.readFieldBegin() 680 | var fname = ret.fname 681 | var ftype = ret.ftype 682 | var fid = ret.fid 683 | if (ftype == Thrift.Type.STOP) 684 | break 685 | switch(fid) 686 | { 687 | case 0: if (ftype == Thrift.Type.STRUCT) { 688 | this.success = new ttypes.HiveClusterStatus() 689 | this.success.read(input) 690 | } else { 691 | input.skip(ftype) 692 | } 693 | break 694 | case 1: if (ftype == Thrift.Type.STRUCT) { 695 | this.ex = new ttypes.HiveServerException() 696 | this.ex.read(input) 697 | } else { 698 | input.skip(ftype) 699 | } 700 | break 701 | default: 702 | input.skip(ftype) 703 | } 704 | input.readFieldEnd() 705 | } 706 | input.readStructEnd() 707 | return 708 | } 709 | 710 | ThriftHive_getClusterStatus_result.prototype.write = function(output){ 711 | output.writeStructBegin('ThriftHive_getClusterStatus_result') 712 | if (null != this.success) { 713 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0) 714 | this.success.write(output) 715 | output.writeFieldEnd() 716 | } 717 | if (null != this.ex) { 718 | output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1) 719 | this.ex.write(output) 720 | output.writeFieldEnd() 721 | } 722 | output.writeFieldStop() 723 | output.writeStructEnd() 724 | return 725 | } 726 | 727 | var ThriftHive_getQueryPlan_args = function(args){ 728 | } 729 | ThriftHive_getQueryPlan_args.prototype = {} 730 | ThriftHive_getQueryPlan_args.prototype.read = function(input){ 731 | var ret = input.readStructBegin() 732 | while (1) 733 | { 734 | var ret = input.readFieldBegin() 735 | var fname = ret.fname 736 | var ftype = ret.ftype 737 | var fid = ret.fid 738 | if (ftype == Thrift.Type.STOP) 739 | break 740 | switch(fid) 741 | { 742 | default: 743 | input.skip(ftype) 744 | } 745 | input.readFieldEnd() 746 | } 747 | input.readStructEnd() 748 | return 749 | } 750 | 751 | ThriftHive_getQueryPlan_args.prototype.write = function(output){ 752 | output.writeStructBegin('ThriftHive_getQueryPlan_args') 753 | output.writeFieldStop() 754 | output.writeStructEnd() 755 | return 756 | } 757 | 758 | var ThriftHive_getQueryPlan_result = function(args){ 759 | this.success = null 760 | this.ex = null 761 | if( args != null ){ if (null != args.success) 762 | this.success = args.success 763 | if (null != args.ex) 764 | this.ex = args.ex 765 | }} 766 | ThriftHive_getQueryPlan_result.prototype = {} 767 | ThriftHive_getQueryPlan_result.prototype.read = function(input){ 768 | var ret = input.readStructBegin() 769 | while (1) 770 | { 771 | var ret = input.readFieldBegin() 772 | var fname = ret.fname 773 | var ftype = ret.ftype 774 | var fid = ret.fid 775 | if (ftype == Thrift.Type.STOP) 776 | break 777 | switch(fid) 778 | { 779 | case 0: if (ftype == Thrift.Type.STRUCT) { 780 | this.success = new queryplan_ttypes.QueryPlan() 781 | this.success.read(input) 782 | } else { 783 | input.skip(ftype) 784 | } 785 | break 786 | case 1: if (ftype == Thrift.Type.STRUCT) { 787 | this.ex = new ttypes.HiveServerException() 788 | this.ex.read(input) 789 | } else { 790 | input.skip(ftype) 791 | } 792 | break 793 | default: 794 | input.skip(ftype) 795 | } 796 | input.readFieldEnd() 797 | } 798 | input.readStructEnd() 799 | return 800 | } 801 | 802 | ThriftHive_getQueryPlan_result.prototype.write = function(output){ 803 | output.writeStructBegin('ThriftHive_getQueryPlan_result') 804 | if (null != this.success) { 805 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0) 806 | this.success.write(output) 807 | output.writeFieldEnd() 808 | } 809 | if (null != this.ex) { 810 | output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1) 811 | this.ex.write(output) 812 | output.writeFieldEnd() 813 | } 814 | output.writeFieldStop() 815 | output.writeStructEnd() 816 | return 817 | } 818 | 819 | var ThriftHiveClient = exports.Client = function(output, pClass) { 820 | this.output = output; 821 | this.pClass = pClass; 822 | this.seqid = 0; 823 | this._reqs = {} 824 | } 825 | Thrift.inherits(ThriftHiveClient, ThriftHiveMetastoreClient) 826 | ThriftHiveClient.prototype.execute = function(query,callback){ 827 | this.seqid += 1; 828 | this._reqs[this.seqid] = callback; 829 | this.send_execute(query) 830 | } 831 | 832 | ThriftHiveClient.prototype.send_execute = function(query){ 833 | var output = new this.pClass(this.output); 834 | output.writeMessageBegin('execute', Thrift.MessageType.CALL, this.seqid) 835 | var args = new ThriftHive_execute_args() 836 | args.query = query 837 | args.write(output) 838 | output.writeMessageEnd() 839 | return this.output.flush() 840 | } 841 | 842 | ThriftHiveClient.prototype.recv_execute = function(input,mtype,rseqid){ 843 | var callback = this._reqs[rseqid] || function() {}; 844 | delete this._reqs[rseqid]; 845 | if (mtype == Thrift.MessageType.EXCEPTION) { 846 | var x = new Thrift.TApplicationException() 847 | x.read(input) 848 | input.readMessageEnd() 849 | return callback(x); 850 | } 851 | var result = new ThriftHive_execute_result() 852 | result.read(input) 853 | input.readMessageEnd() 854 | 855 | if (null != result.ex) { 856 | return callback(result.ex); 857 | } 858 | callback(null) 859 | } 860 | ThriftHiveClient.prototype.fetchOne = function(callback){ 861 | this.seqid += 1; 862 | this._reqs[this.seqid] = callback; 863 | this.send_fetchOne() 864 | } 865 | 866 | ThriftHiveClient.prototype.send_fetchOne = function(){ 867 | var output = new this.pClass(this.output); 868 | output.writeMessageBegin('fetchOne', Thrift.MessageType.CALL, this.seqid) 869 | var args = new ThriftHive_fetchOne_args() 870 | args.write(output) 871 | output.writeMessageEnd() 872 | return this.output.flush() 873 | } 874 | 875 | ThriftHiveClient.prototype.recv_fetchOne = function(input,mtype,rseqid){ 876 | var callback = this._reqs[rseqid] || function() {}; 877 | delete this._reqs[rseqid]; 878 | if (mtype == Thrift.MessageType.EXCEPTION) { 879 | var x = new Thrift.TApplicationException() 880 | x.read(input) 881 | input.readMessageEnd() 882 | return callback(x); 883 | } 884 | var result = new ThriftHive_fetchOne_result() 885 | result.read(input) 886 | input.readMessageEnd() 887 | 888 | if (null != result.ex) { 889 | return callback(result.ex); 890 | } 891 | if (null != result.success ) { 892 | return callback(null, result.success); 893 | } 894 | return callback("fetchOne failed: unknown result"); 895 | } 896 | ThriftHiveClient.prototype.fetchN = function(numRows,callback){ 897 | this.seqid += 1; 898 | this._reqs[this.seqid] = callback; 899 | this.send_fetchN(numRows) 900 | } 901 | 902 | ThriftHiveClient.prototype.send_fetchN = function(numRows){ 903 | var output = new this.pClass(this.output); 904 | output.writeMessageBegin('fetchN', Thrift.MessageType.CALL, this.seqid) 905 | var args = new ThriftHive_fetchN_args() 906 | args.numRows = numRows 907 | args.write(output) 908 | output.writeMessageEnd() 909 | return this.output.flush() 910 | } 911 | 912 | ThriftHiveClient.prototype.recv_fetchN = function(input,mtype,rseqid){ 913 | var callback = this._reqs[rseqid] || function() {}; 914 | delete this._reqs[rseqid]; 915 | if (mtype == Thrift.MessageType.EXCEPTION) { 916 | var x = new Thrift.TApplicationException() 917 | x.read(input) 918 | input.readMessageEnd() 919 | return callback(x); 920 | } 921 | var result = new ThriftHive_fetchN_result() 922 | result.read(input) 923 | input.readMessageEnd() 924 | 925 | if (null != result.ex) { 926 | return callback(result.ex); 927 | } 928 | if (null != result.success ) { 929 | return callback(null, result.success); 930 | } 931 | return callback("fetchN failed: unknown result"); 932 | } 933 | ThriftHiveClient.prototype.fetchAll = function(callback){ 934 | this.seqid += 1; 935 | this._reqs[this.seqid] = callback; 936 | this.send_fetchAll() 937 | } 938 | 939 | ThriftHiveClient.prototype.send_fetchAll = function(){ 940 | var output = new this.pClass(this.output); 941 | output.writeMessageBegin('fetchAll', Thrift.MessageType.CALL, this.seqid) 942 | var args = new ThriftHive_fetchAll_args() 943 | args.write(output) 944 | output.writeMessageEnd() 945 | return this.output.flush() 946 | } 947 | 948 | ThriftHiveClient.prototype.recv_fetchAll = function(input,mtype,rseqid){ 949 | var callback = this._reqs[rseqid] || function() {}; 950 | delete this._reqs[rseqid]; 951 | if (mtype == Thrift.MessageType.EXCEPTION) { 952 | var x = new Thrift.TApplicationException() 953 | x.read(input) 954 | input.readMessageEnd() 955 | return callback(x); 956 | } 957 | var result = new ThriftHive_fetchAll_result() 958 | result.read(input) 959 | input.readMessageEnd() 960 | 961 | if (null != result.ex) { 962 | return callback(result.ex); 963 | } 964 | if (null != result.success ) { 965 | return callback(null, result.success); 966 | } 967 | return callback("fetchAll failed: unknown result"); 968 | } 969 | ThriftHiveClient.prototype.getSchema = function(callback){ 970 | this.seqid += 1; 971 | this._reqs[this.seqid] = callback; 972 | this.send_getSchema() 973 | } 974 | 975 | ThriftHiveClient.prototype.send_getSchema = function(){ 976 | var output = new this.pClass(this.output); 977 | output.writeMessageBegin('getSchema', Thrift.MessageType.CALL, this.seqid) 978 | var args = new ThriftHive_getSchema_args() 979 | args.write(output) 980 | output.writeMessageEnd() 981 | return this.output.flush() 982 | } 983 | 984 | ThriftHiveClient.prototype.recv_getSchema = function(input,mtype,rseqid){ 985 | var callback = this._reqs[rseqid] || function() {}; 986 | delete this._reqs[rseqid]; 987 | if (mtype == Thrift.MessageType.EXCEPTION) { 988 | var x = new Thrift.TApplicationException() 989 | x.read(input) 990 | input.readMessageEnd() 991 | return callback(x); 992 | } 993 | var result = new ThriftHive_getSchema_result() 994 | result.read(input) 995 | input.readMessageEnd() 996 | 997 | if (null != result.ex) { 998 | return callback(result.ex); 999 | } 1000 | if (null != result.success ) { 1001 | return callback(null, result.success); 1002 | } 1003 | return callback("getSchema failed: unknown result"); 1004 | } 1005 | ThriftHiveClient.prototype.getThriftSchema = function(callback){ 1006 | this.seqid += 1; 1007 | this._reqs[this.seqid] = callback; 1008 | this.send_getThriftSchema() 1009 | } 1010 | 1011 | ThriftHiveClient.prototype.send_getThriftSchema = function(){ 1012 | var output = new this.pClass(this.output); 1013 | output.writeMessageBegin('getThriftSchema', Thrift.MessageType.CALL, this.seqid) 1014 | var args = new ThriftHive_getThriftSchema_args() 1015 | args.write(output) 1016 | output.writeMessageEnd() 1017 | return this.output.flush() 1018 | } 1019 | 1020 | ThriftHiveClient.prototype.recv_getThriftSchema = function(input,mtype,rseqid){ 1021 | var callback = this._reqs[rseqid] || function() {}; 1022 | delete this._reqs[rseqid]; 1023 | if (mtype == Thrift.MessageType.EXCEPTION) { 1024 | var x = new Thrift.TApplicationException() 1025 | x.read(input) 1026 | input.readMessageEnd() 1027 | return callback(x); 1028 | } 1029 | var result = new ThriftHive_getThriftSchema_result() 1030 | result.read(input) 1031 | input.readMessageEnd() 1032 | 1033 | if (null != result.ex) { 1034 | return callback(result.ex); 1035 | } 1036 | if (null != result.success ) { 1037 | return callback(null, result.success); 1038 | } 1039 | return callback("getThriftSchema failed: unknown result"); 1040 | } 1041 | ThriftHiveClient.prototype.getClusterStatus = function(callback){ 1042 | this.seqid += 1; 1043 | this._reqs[this.seqid] = callback; 1044 | this.send_getClusterStatus() 1045 | } 1046 | 1047 | ThriftHiveClient.prototype.send_getClusterStatus = function(){ 1048 | var output = new this.pClass(this.output); 1049 | output.writeMessageBegin('getClusterStatus', Thrift.MessageType.CALL, this.seqid) 1050 | var args = new ThriftHive_getClusterStatus_args() 1051 | args.write(output) 1052 | output.writeMessageEnd() 1053 | return this.output.flush() 1054 | } 1055 | 1056 | ThriftHiveClient.prototype.recv_getClusterStatus = function(input,mtype,rseqid){ 1057 | var callback = this._reqs[rseqid] || function() {}; 1058 | delete this._reqs[rseqid]; 1059 | if (mtype == Thrift.MessageType.EXCEPTION) { 1060 | var x = new Thrift.TApplicationException() 1061 | x.read(input) 1062 | input.readMessageEnd() 1063 | return callback(x); 1064 | } 1065 | var result = new ThriftHive_getClusterStatus_result() 1066 | result.read(input) 1067 | input.readMessageEnd() 1068 | 1069 | if (null != result.ex) { 1070 | return callback(result.ex); 1071 | } 1072 | if (null != result.success ) { 1073 | return callback(null, result.success); 1074 | } 1075 | return callback("getClusterStatus failed: unknown result"); 1076 | } 1077 | ThriftHiveClient.prototype.getQueryPlan = function(callback){ 1078 | this.seqid += 1; 1079 | this._reqs[this.seqid] = callback; 1080 | this.send_getQueryPlan() 1081 | } 1082 | 1083 | ThriftHiveClient.prototype.send_getQueryPlan = function(){ 1084 | var output = new this.pClass(this.output); 1085 | output.writeMessageBegin('getQueryPlan', Thrift.MessageType.CALL, this.seqid) 1086 | var args = new ThriftHive_getQueryPlan_args() 1087 | args.write(output) 1088 | output.writeMessageEnd() 1089 | return this.output.flush() 1090 | } 1091 | 1092 | ThriftHiveClient.prototype.recv_getQueryPlan = function(input,mtype,rseqid){ 1093 | var callback = this._reqs[rseqid] || function() {}; 1094 | delete this._reqs[rseqid]; 1095 | if (mtype == Thrift.MessageType.EXCEPTION) { 1096 | var x = new Thrift.TApplicationException() 1097 | x.read(input) 1098 | input.readMessageEnd() 1099 | return callback(x); 1100 | } 1101 | var result = new ThriftHive_getQueryPlan_result() 1102 | result.read(input) 1103 | input.readMessageEnd() 1104 | 1105 | if (null != result.ex) { 1106 | return callback(result.ex); 1107 | } 1108 | if (null != result.success ) { 1109 | return callback(null, result.success); 1110 | } 1111 | return callback("getQueryPlan failed: unknown result"); 1112 | } 1113 | var ThriftHiveProcessor = exports.Processor = function(handler) { 1114 | this._handler = handler 1115 | } 1116 | ThriftHiveProcessor.prototype.process = function(input, output) { 1117 | var r = input.readMessageBegin() 1118 | if (this['process_' + r.fname]) { 1119 | return this['process_' + r.fname].call(this, r.rseqid, input, output) 1120 | } else { 1121 | input.skip(Thrift.Type.STRUCT) 1122 | input.readMessageEnd() 1123 | var x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname) 1124 | output.writeMessageBegin(r.fname, Thrift.MessageType.Exception, r.rseqid) 1125 | x.write(output) 1126 | output.writeMessageEnd() 1127 | output.flush() 1128 | } 1129 | } 1130 | 1131 | ThriftHiveProcessor.prototype.process_execute = function(seqid, input, output) { 1132 | var args = new ThriftHive_execute_args() 1133 | args.read(input) 1134 | input.readMessageEnd() 1135 | var result = new ThriftHive_execute_result() 1136 | this._handler.execute(args.query, function(success) { 1137 | result.success = success 1138 | output.writeMessageBegin("execute", Thrift.MessageType.REPLY, seqid) 1139 | result.write(output) 1140 | output.writeMessageEnd() 1141 | output.flush() 1142 | }) 1143 | } 1144 | 1145 | ThriftHiveProcessor.prototype.process_fetchOne = function(seqid, input, output) { 1146 | var args = new ThriftHive_fetchOne_args() 1147 | args.read(input) 1148 | input.readMessageEnd() 1149 | var result = new ThriftHive_fetchOne_result() 1150 | this._handler.fetchOne(function(success) { 1151 | result.success = success 1152 | output.writeMessageBegin("fetchOne", Thrift.MessageType.REPLY, seqid) 1153 | result.write(output) 1154 | output.writeMessageEnd() 1155 | output.flush() 1156 | }) 1157 | } 1158 | 1159 | ThriftHiveProcessor.prototype.process_fetchN = function(seqid, input, output) { 1160 | var args = new ThriftHive_fetchN_args() 1161 | args.read(input) 1162 | input.readMessageEnd() 1163 | var result = new ThriftHive_fetchN_result() 1164 | this._handler.fetchN(args.numRows, function(success) { 1165 | result.success = success 1166 | output.writeMessageBegin("fetchN", Thrift.MessageType.REPLY, seqid) 1167 | result.write(output) 1168 | output.writeMessageEnd() 1169 | output.flush() 1170 | }) 1171 | } 1172 | 1173 | ThriftHiveProcessor.prototype.process_fetchAll = function(seqid, input, output) { 1174 | var args = new ThriftHive_fetchAll_args() 1175 | args.read(input) 1176 | input.readMessageEnd() 1177 | var result = new ThriftHive_fetchAll_result() 1178 | this._handler.fetchAll(function(success) { 1179 | result.success = success 1180 | output.writeMessageBegin("fetchAll", Thrift.MessageType.REPLY, seqid) 1181 | result.write(output) 1182 | output.writeMessageEnd() 1183 | output.flush() 1184 | }) 1185 | } 1186 | 1187 | ThriftHiveProcessor.prototype.process_getSchema = function(seqid, input, output) { 1188 | var args = new ThriftHive_getSchema_args() 1189 | args.read(input) 1190 | input.readMessageEnd() 1191 | var result = new ThriftHive_getSchema_result() 1192 | this._handler.getSchema(function(success) { 1193 | result.success = success 1194 | output.writeMessageBegin("getSchema", Thrift.MessageType.REPLY, seqid) 1195 | result.write(output) 1196 | output.writeMessageEnd() 1197 | output.flush() 1198 | }) 1199 | } 1200 | 1201 | ThriftHiveProcessor.prototype.process_getThriftSchema = function(seqid, input, output) { 1202 | var args = new ThriftHive_getThriftSchema_args() 1203 | args.read(input) 1204 | input.readMessageEnd() 1205 | var result = new ThriftHive_getThriftSchema_result() 1206 | this._handler.getThriftSchema(function(success) { 1207 | result.success = success 1208 | output.writeMessageBegin("getThriftSchema", Thrift.MessageType.REPLY, seqid) 1209 | result.write(output) 1210 | output.writeMessageEnd() 1211 | output.flush() 1212 | }) 1213 | } 1214 | 1215 | ThriftHiveProcessor.prototype.process_getClusterStatus = function(seqid, input, output) { 1216 | var args = new ThriftHive_getClusterStatus_args() 1217 | args.read(input) 1218 | input.readMessageEnd() 1219 | var result = new ThriftHive_getClusterStatus_result() 1220 | this._handler.getClusterStatus(function(success) { 1221 | result.success = success 1222 | output.writeMessageBegin("getClusterStatus", Thrift.MessageType.REPLY, seqid) 1223 | result.write(output) 1224 | output.writeMessageEnd() 1225 | output.flush() 1226 | }) 1227 | } 1228 | 1229 | ThriftHiveProcessor.prototype.process_getQueryPlan = function(seqid, input, output) { 1230 | var args = new ThriftHive_getQueryPlan_args() 1231 | args.read(input) 1232 | input.readMessageEnd() 1233 | var result = new ThriftHive_getQueryPlan_result() 1234 | this._handler.getQueryPlan(function(success) { 1235 | result.success = success 1236 | output.writeMessageBegin("getQueryPlan", Thrift.MessageType.REPLY, seqid) 1237 | result.write(output) 1238 | output.writeMessageEnd() 1239 | output.flush() 1240 | }) 1241 | } 1242 | 1243 | -------------------------------------------------------------------------------- /node_modules/gen-nodejs/fb303_types.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | var Thrift = require('thrift').Thrift; 7 | var ttypes = module.exports = {}; 8 | ttypes.fb_status = { 9 | 'DEAD' : 0 10 | ,'STARTING' : 1 11 | ,'ALIVE' : 2 12 | ,'STOPPING' : 3 13 | ,'STOPPED' : 4 14 | ,'WARNING' : 5 15 | } 16 | -------------------------------------------------------------------------------- /node_modules/gen-nodejs/hive_service_types.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | var Thrift = require('thrift').Thrift; 7 | var ttypes = module.exports = {}; 8 | ttypes.JobTrackerState = { 9 | 'INITIALIZING' : 1 10 | ,'RUNNING' : 2 11 | } 12 | var HiveClusterStatus = module.exports.HiveClusterStatus = function(args){ 13 | this.taskTrackers = null 14 | this.mapTasks = null 15 | this.reduceTasks = null 16 | this.maxMapTasks = null 17 | this.maxReduceTasks = null 18 | this.state = null 19 | if( args != null ){ if (null != args.taskTrackers) 20 | this.taskTrackers = args.taskTrackers 21 | if (null != args.mapTasks) 22 | this.mapTasks = args.mapTasks 23 | if (null != args.reduceTasks) 24 | this.reduceTasks = args.reduceTasks 25 | if (null != args.maxMapTasks) 26 | this.maxMapTasks = args.maxMapTasks 27 | if (null != args.maxReduceTasks) 28 | this.maxReduceTasks = args.maxReduceTasks 29 | if (null != args.state) 30 | this.state = args.state 31 | }} 32 | HiveClusterStatus.prototype = {} 33 | HiveClusterStatus.prototype.read = function(input){ 34 | var ret = input.readStructBegin() 35 | while (1) 36 | { 37 | var ret = input.readFieldBegin() 38 | var fname = ret.fname 39 | var ftype = ret.ftype 40 | var fid = ret.fid 41 | if (ftype == Thrift.Type.STOP) 42 | break 43 | switch(fid) 44 | { 45 | case 1: if (ftype == Thrift.Type.I32) { 46 | this.taskTrackers = input.readI32() 47 | } else { 48 | input.skip(ftype) 49 | } 50 | break 51 | case 2: if (ftype == Thrift.Type.I32) { 52 | this.mapTasks = input.readI32() 53 | } else { 54 | input.skip(ftype) 55 | } 56 | break 57 | case 3: if (ftype == Thrift.Type.I32) { 58 | this.reduceTasks = input.readI32() 59 | } else { 60 | input.skip(ftype) 61 | } 62 | break 63 | case 4: if (ftype == Thrift.Type.I32) { 64 | this.maxMapTasks = input.readI32() 65 | } else { 66 | input.skip(ftype) 67 | } 68 | break 69 | case 5: if (ftype == Thrift.Type.I32) { 70 | this.maxReduceTasks = input.readI32() 71 | } else { 72 | input.skip(ftype) 73 | } 74 | break 75 | case 6: if (ftype == Thrift.Type.I32) { 76 | this.state = input.readI32() 77 | } else { 78 | input.skip(ftype) 79 | } 80 | break 81 | default: 82 | input.skip(ftype) 83 | } 84 | input.readFieldEnd() 85 | } 86 | input.readStructEnd() 87 | return 88 | } 89 | 90 | HiveClusterStatus.prototype.write = function(output){ 91 | output.writeStructBegin('HiveClusterStatus') 92 | if (null != this.taskTrackers) { 93 | output.writeFieldBegin('taskTrackers', Thrift.Type.I32, 1) 94 | output.writeI32(this.taskTrackers) 95 | output.writeFieldEnd() 96 | } 97 | if (null != this.mapTasks) { 98 | output.writeFieldBegin('mapTasks', Thrift.Type.I32, 2) 99 | output.writeI32(this.mapTasks) 100 | output.writeFieldEnd() 101 | } 102 | if (null != this.reduceTasks) { 103 | output.writeFieldBegin('reduceTasks', Thrift.Type.I32, 3) 104 | output.writeI32(this.reduceTasks) 105 | output.writeFieldEnd() 106 | } 107 | if (null != this.maxMapTasks) { 108 | output.writeFieldBegin('maxMapTasks', Thrift.Type.I32, 4) 109 | output.writeI32(this.maxMapTasks) 110 | output.writeFieldEnd() 111 | } 112 | if (null != this.maxReduceTasks) { 113 | output.writeFieldBegin('maxReduceTasks', Thrift.Type.I32, 5) 114 | output.writeI32(this.maxReduceTasks) 115 | output.writeFieldEnd() 116 | } 117 | if (null != this.state) { 118 | output.writeFieldBegin('state', Thrift.Type.I32, 6) 119 | output.writeI32(this.state) 120 | output.writeFieldEnd() 121 | } 122 | output.writeFieldStop() 123 | output.writeStructEnd() 124 | return 125 | } 126 | 127 | var HiveServerException = module.exports.HiveServerException = function(args){ 128 | Thrift.TException.call(this, "HiveServerException") 129 | this.name = "HiveServerException" 130 | this.message = null 131 | this.errorCode = null 132 | this.SQLState = null 133 | if( args != null ){ if (null != args.message) 134 | this.message = args.message 135 | if (null != args.errorCode) 136 | this.errorCode = args.errorCode 137 | if (null != args.SQLState) 138 | this.SQLState = args.SQLState 139 | }} 140 | Thrift.inherits(HiveServerException, Thrift.TException) 141 | HiveServerException.prototype.read = function(input){ 142 | var ret = input.readStructBegin() 143 | while (1) 144 | { 145 | var ret = input.readFieldBegin() 146 | var fname = ret.fname 147 | var ftype = ret.ftype 148 | var fid = ret.fid 149 | if (ftype == Thrift.Type.STOP) 150 | break 151 | switch(fid) 152 | { 153 | case 1: if (ftype == Thrift.Type.STRING) { 154 | this.message = input.readString() 155 | } else { 156 | input.skip(ftype) 157 | } 158 | break 159 | case 2: if (ftype == Thrift.Type.I32) { 160 | this.errorCode = input.readI32() 161 | } else { 162 | input.skip(ftype) 163 | } 164 | break 165 | case 3: if (ftype == Thrift.Type.STRING) { 166 | this.SQLState = input.readString() 167 | } else { 168 | input.skip(ftype) 169 | } 170 | break 171 | default: 172 | input.skip(ftype) 173 | } 174 | input.readFieldEnd() 175 | } 176 | input.readStructEnd() 177 | return 178 | } 179 | 180 | HiveServerException.prototype.write = function(output){ 181 | output.writeStructBegin('HiveServerException') 182 | if (null != this.message) { 183 | output.writeFieldBegin('message', Thrift.Type.STRING, 1) 184 | output.writeString(this.message) 185 | output.writeFieldEnd() 186 | } 187 | if (null != this.errorCode) { 188 | output.writeFieldBegin('errorCode', Thrift.Type.I32, 2) 189 | output.writeI32(this.errorCode) 190 | output.writeFieldEnd() 191 | } 192 | if (null != this.SQLState) { 193 | output.writeFieldBegin('SQLState', Thrift.Type.STRING, 3) 194 | output.writeString(this.SQLState) 195 | output.writeFieldEnd() 196 | } 197 | output.writeFieldStop() 198 | output.writeStructEnd() 199 | return 200 | } 201 | 202 | -------------------------------------------------------------------------------- /node_modules/gen-nodejs/queryplan_types.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | var Thrift = require('thrift').Thrift; 7 | var ttypes = module.exports = {}; 8 | ttypes.AdjacencyType = { 9 | 'CONJUNCTIVE' : 0 10 | ,'DISJUNCTIVE' : 1 11 | } 12 | ttypes.NodeType = { 13 | 'OPERATOR' : 0 14 | ,'STAGE' : 1 15 | } 16 | ttypes.OperatorType = { 17 | 'JOIN' : 0 18 | ,'MAPJOIN' : 1 19 | ,'EXTRACT' : 2 20 | ,'FILTER' : 3 21 | ,'FORWARD' : 4 22 | ,'GROUPBY' : 5 23 | ,'LIMIT' : 6 24 | ,'SCRIPT' : 7 25 | ,'SELECT' : 8 26 | ,'TABLESCAN' : 9 27 | ,'FILESINK' : 10 28 | ,'REDUCESINK' : 11 29 | ,'UNION' : 12 30 | ,'UDTF' : 13 31 | ,'LATERALVIEWJOIN' : 14 32 | ,'LATERALVIEWFORWARD' : 15 33 | ,'HASHTABLESINK' : 16 34 | ,'HASHTABLEDUMMY' : 17 35 | } 36 | ttypes.TaskType = { 37 | 'MAP' : 0 38 | ,'REDUCE' : 1 39 | ,'OTHER' : 2 40 | } 41 | ttypes.StageType = { 42 | 'CONDITIONAL' : 0 43 | ,'COPY' : 1 44 | ,'DDL' : 2 45 | ,'MAPRED' : 3 46 | ,'EXPLAIN' : 4 47 | ,'FETCH' : 5 48 | ,'FUNC' : 6 49 | ,'MAPREDLOCAL' : 7 50 | ,'MOVE' : 8 51 | ,'STATS' : 9 52 | } 53 | var Adjacency = module.exports.Adjacency = function(args){ 54 | this.node = null 55 | this.children = null 56 | this.adjacencyType = null 57 | if( args != null ){ if (null != args.node) 58 | this.node = args.node 59 | if (null != args.children) 60 | this.children = args.children 61 | if (null != args.adjacencyType) 62 | this.adjacencyType = args.adjacencyType 63 | }} 64 | Adjacency.prototype = {} 65 | Adjacency.prototype.read = function(input){ 66 | var ret = input.readStructBegin() 67 | while (1) 68 | { 69 | var ret = input.readFieldBegin() 70 | var fname = ret.fname 71 | var ftype = ret.ftype 72 | var fid = ret.fid 73 | if (ftype == Thrift.Type.STOP) 74 | break 75 | switch(fid) 76 | { 77 | case 1: if (ftype == Thrift.Type.STRING) { 78 | this.node = input.readString() 79 | } else { 80 | input.skip(ftype) 81 | } 82 | break 83 | case 2: if (ftype == Thrift.Type.LIST) { 84 | { 85 | var _size0 = 0 86 | var rtmp3 87 | this.children = [] 88 | var _etype3 = 0 89 | rtmp3 = input.readListBegin() 90 | _etype3 = rtmp3.etype 91 | _size0 = rtmp3.size 92 | for (var _i4 = 0; _i4 < _size0; ++_i4) 93 | { 94 | var elem5 = null 95 | elem5 = input.readString() 96 | this.children.push(elem5) 97 | } 98 | input.readListEnd() 99 | } 100 | } else { 101 | input.skip(ftype) 102 | } 103 | break 104 | case 3: if (ftype == Thrift.Type.I32) { 105 | this.adjacencyType = input.readI32() 106 | } else { 107 | input.skip(ftype) 108 | } 109 | break 110 | default: 111 | input.skip(ftype) 112 | } 113 | input.readFieldEnd() 114 | } 115 | input.readStructEnd() 116 | return 117 | } 118 | 119 | Adjacency.prototype.write = function(output){ 120 | output.writeStructBegin('Adjacency') 121 | if (null != this.node) { 122 | output.writeFieldBegin('node', Thrift.Type.STRING, 1) 123 | output.writeString(this.node) 124 | output.writeFieldEnd() 125 | } 126 | if (null != this.children) { 127 | output.writeFieldBegin('children', Thrift.Type.LIST, 2) 128 | { 129 | output.writeListBegin(Thrift.Type.STRING, this.children.length) 130 | { 131 | for(var iter6 in this.children) 132 | { 133 | if (this.children.hasOwnProperty(iter6)) 134 | { 135 | iter6=this.children[iter6] 136 | output.writeString(iter6) 137 | } 138 | } 139 | } 140 | output.writeListEnd() 141 | } 142 | output.writeFieldEnd() 143 | } 144 | if (null != this.adjacencyType) { 145 | output.writeFieldBegin('adjacencyType', Thrift.Type.I32, 3) 146 | output.writeI32(this.adjacencyType) 147 | output.writeFieldEnd() 148 | } 149 | output.writeFieldStop() 150 | output.writeStructEnd() 151 | return 152 | } 153 | 154 | var Graph = module.exports.Graph = function(args){ 155 | this.nodeType = null 156 | this.roots = null 157 | this.adjacencyList = null 158 | if( args != null ){ if (null != args.nodeType) 159 | this.nodeType = args.nodeType 160 | if (null != args.roots) 161 | this.roots = args.roots 162 | if (null != args.adjacencyList) 163 | this.adjacencyList = args.adjacencyList 164 | }} 165 | Graph.prototype = {} 166 | Graph.prototype.read = function(input){ 167 | var ret = input.readStructBegin() 168 | while (1) 169 | { 170 | var ret = input.readFieldBegin() 171 | var fname = ret.fname 172 | var ftype = ret.ftype 173 | var fid = ret.fid 174 | if (ftype == Thrift.Type.STOP) 175 | break 176 | switch(fid) 177 | { 178 | case 1: if (ftype == Thrift.Type.I32) { 179 | this.nodeType = input.readI32() 180 | } else { 181 | input.skip(ftype) 182 | } 183 | break 184 | case 2: if (ftype == Thrift.Type.LIST) { 185 | { 186 | var _size7 = 0 187 | var rtmp3 188 | this.roots = [] 189 | var _etype10 = 0 190 | rtmp3 = input.readListBegin() 191 | _etype10 = rtmp3.etype 192 | _size7 = rtmp3.size 193 | for (var _i11 = 0; _i11 < _size7; ++_i11) 194 | { 195 | var elem12 = null 196 | elem12 = input.readString() 197 | this.roots.push(elem12) 198 | } 199 | input.readListEnd() 200 | } 201 | } else { 202 | input.skip(ftype) 203 | } 204 | break 205 | case 3: if (ftype == Thrift.Type.LIST) { 206 | { 207 | var _size13 = 0 208 | var rtmp3 209 | this.adjacencyList = [] 210 | var _etype16 = 0 211 | rtmp3 = input.readListBegin() 212 | _etype16 = rtmp3.etype 213 | _size13 = rtmp3.size 214 | for (var _i17 = 0; _i17 < _size13; ++_i17) 215 | { 216 | var elem18 = null 217 | elem18 = new ttypes.Adjacency() 218 | elem18.read(input) 219 | this.adjacencyList.push(elem18) 220 | } 221 | input.readListEnd() 222 | } 223 | } else { 224 | input.skip(ftype) 225 | } 226 | break 227 | default: 228 | input.skip(ftype) 229 | } 230 | input.readFieldEnd() 231 | } 232 | input.readStructEnd() 233 | return 234 | } 235 | 236 | Graph.prototype.write = function(output){ 237 | output.writeStructBegin('Graph') 238 | if (null != this.nodeType) { 239 | output.writeFieldBegin('nodeType', Thrift.Type.I32, 1) 240 | output.writeI32(this.nodeType) 241 | output.writeFieldEnd() 242 | } 243 | if (null != this.roots) { 244 | output.writeFieldBegin('roots', Thrift.Type.LIST, 2) 245 | { 246 | output.writeListBegin(Thrift.Type.STRING, this.roots.length) 247 | { 248 | for(var iter19 in this.roots) 249 | { 250 | if (this.roots.hasOwnProperty(iter19)) 251 | { 252 | iter19=this.roots[iter19] 253 | output.writeString(iter19) 254 | } 255 | } 256 | } 257 | output.writeListEnd() 258 | } 259 | output.writeFieldEnd() 260 | } 261 | if (null != this.adjacencyList) { 262 | output.writeFieldBegin('adjacencyList', Thrift.Type.LIST, 3) 263 | { 264 | output.writeListBegin(Thrift.Type.STRUCT, this.adjacencyList.length) 265 | { 266 | for(var iter20 in this.adjacencyList) 267 | { 268 | if (this.adjacencyList.hasOwnProperty(iter20)) 269 | { 270 | iter20=this.adjacencyList[iter20] 271 | iter20.write(output) 272 | } 273 | } 274 | } 275 | output.writeListEnd() 276 | } 277 | output.writeFieldEnd() 278 | } 279 | output.writeFieldStop() 280 | output.writeStructEnd() 281 | return 282 | } 283 | 284 | var Operator = module.exports.Operator = function(args){ 285 | this.operatorId = null 286 | this.operatorType = null 287 | this.operatorAttributes = null 288 | this.operatorCounters = null 289 | this.done = null 290 | this.started = null 291 | if( args != null ){ if (null != args.operatorId) 292 | this.operatorId = args.operatorId 293 | if (null != args.operatorType) 294 | this.operatorType = args.operatorType 295 | if (null != args.operatorAttributes) 296 | this.operatorAttributes = args.operatorAttributes 297 | if (null != args.operatorCounters) 298 | this.operatorCounters = args.operatorCounters 299 | if (null != args.done) 300 | this.done = args.done 301 | if (null != args.started) 302 | this.started = args.started 303 | }} 304 | Operator.prototype = {} 305 | Operator.prototype.read = function(input){ 306 | var ret = input.readStructBegin() 307 | while (1) 308 | { 309 | var ret = input.readFieldBegin() 310 | var fname = ret.fname 311 | var ftype = ret.ftype 312 | var fid = ret.fid 313 | if (ftype == Thrift.Type.STOP) 314 | break 315 | switch(fid) 316 | { 317 | case 1: if (ftype == Thrift.Type.STRING) { 318 | this.operatorId = input.readString() 319 | } else { 320 | input.skip(ftype) 321 | } 322 | break 323 | case 2: if (ftype == Thrift.Type.I32) { 324 | this.operatorType = input.readI32() 325 | } else { 326 | input.skip(ftype) 327 | } 328 | break 329 | case 3: if (ftype == Thrift.Type.MAP) { 330 | { 331 | var _size21 = 0 332 | var rtmp3 333 | this.operatorAttributes = {} 334 | var _ktype22 = 0 335 | var _vtype23 = 0 336 | rtmp3 = input.readMapBegin() 337 | _ktype22= rtmp3.ktype 338 | _vtype23= rtmp3.vtype 339 | _size21= rtmp3.size 340 | for (var _i25 = 0; _i25 < _size21; ++_i25) 341 | { 342 | key26 = null 343 | val27 = null 344 | key26 = input.readString() 345 | val27 = input.readString() 346 | this.operatorAttributes[key26] = val27 347 | } 348 | input.readMapEnd() 349 | } 350 | } else { 351 | input.skip(ftype) 352 | } 353 | break 354 | case 4: if (ftype == Thrift.Type.MAP) { 355 | { 356 | var _size28 = 0 357 | var rtmp3 358 | this.operatorCounters = {} 359 | var _ktype29 = 0 360 | var _vtype30 = 0 361 | rtmp3 = input.readMapBegin() 362 | _ktype29= rtmp3.ktype 363 | _vtype30= rtmp3.vtype 364 | _size28= rtmp3.size 365 | for (var _i32 = 0; _i32 < _size28; ++_i32) 366 | { 367 | key33 = null 368 | val34 = null 369 | key33 = input.readString() 370 | val34 = input.readI64() 371 | this.operatorCounters[key33] = val34 372 | } 373 | input.readMapEnd() 374 | } 375 | } else { 376 | input.skip(ftype) 377 | } 378 | break 379 | case 5: if (ftype == Thrift.Type.BOOL) { 380 | this.done = input.readBool() 381 | } else { 382 | input.skip(ftype) 383 | } 384 | break 385 | case 6: if (ftype == Thrift.Type.BOOL) { 386 | this.started = input.readBool() 387 | } else { 388 | input.skip(ftype) 389 | } 390 | break 391 | default: 392 | input.skip(ftype) 393 | } 394 | input.readFieldEnd() 395 | } 396 | input.readStructEnd() 397 | return 398 | } 399 | 400 | Operator.prototype.write = function(output){ 401 | output.writeStructBegin('Operator') 402 | if (null != this.operatorId) { 403 | output.writeFieldBegin('operatorId', Thrift.Type.STRING, 1) 404 | output.writeString(this.operatorId) 405 | output.writeFieldEnd() 406 | } 407 | if (null != this.operatorType) { 408 | output.writeFieldBegin('operatorType', Thrift.Type.I32, 2) 409 | output.writeI32(this.operatorType) 410 | output.writeFieldEnd() 411 | } 412 | if (null != this.operatorAttributes) { 413 | output.writeFieldBegin('operatorAttributes', Thrift.Type.MAP, 3) 414 | { 415 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.STRING, Thrift.objectLength(this.operatorAttributes)) 416 | { 417 | for(var kiter35 in this.operatorAttributes) { 418 | if (this.operatorAttributes.hasOwnProperty(kiter35)) 419 | { 420 | var viter36 = this.operatorAttributes[kiter35] 421 | output.writeString(kiter35) 422 | output.writeString(viter36) 423 | } 424 | } 425 | } 426 | output.writeMapEnd() 427 | } 428 | output.writeFieldEnd() 429 | } 430 | if (null != this.operatorCounters) { 431 | output.writeFieldBegin('operatorCounters', Thrift.Type.MAP, 4) 432 | { 433 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.I64, Thrift.objectLength(this.operatorCounters)) 434 | { 435 | for(var kiter37 in this.operatorCounters) { 436 | if (this.operatorCounters.hasOwnProperty(kiter37)) 437 | { 438 | var viter38 = this.operatorCounters[kiter37] 439 | output.writeString(kiter37) 440 | output.writeI64(viter38) 441 | } 442 | } 443 | } 444 | output.writeMapEnd() 445 | } 446 | output.writeFieldEnd() 447 | } 448 | if (null != this.done) { 449 | output.writeFieldBegin('done', Thrift.Type.BOOL, 5) 450 | output.writeBool(this.done) 451 | output.writeFieldEnd() 452 | } 453 | if (null != this.started) { 454 | output.writeFieldBegin('started', Thrift.Type.BOOL, 6) 455 | output.writeBool(this.started) 456 | output.writeFieldEnd() 457 | } 458 | output.writeFieldStop() 459 | output.writeStructEnd() 460 | return 461 | } 462 | 463 | var Task = module.exports.Task = function(args){ 464 | this.taskId = null 465 | this.taskType = null 466 | this.taskAttributes = null 467 | this.taskCounters = null 468 | this.operatorGraph = null 469 | this.operatorList = null 470 | this.done = null 471 | this.started = null 472 | if( args != null ){ if (null != args.taskId) 473 | this.taskId = args.taskId 474 | if (null != args.taskType) 475 | this.taskType = args.taskType 476 | if (null != args.taskAttributes) 477 | this.taskAttributes = args.taskAttributes 478 | if (null != args.taskCounters) 479 | this.taskCounters = args.taskCounters 480 | if (null != args.operatorGraph) 481 | this.operatorGraph = args.operatorGraph 482 | if (null != args.operatorList) 483 | this.operatorList = args.operatorList 484 | if (null != args.done) 485 | this.done = args.done 486 | if (null != args.started) 487 | this.started = args.started 488 | }} 489 | Task.prototype = {} 490 | Task.prototype.read = function(input){ 491 | var ret = input.readStructBegin() 492 | while (1) 493 | { 494 | var ret = input.readFieldBegin() 495 | var fname = ret.fname 496 | var ftype = ret.ftype 497 | var fid = ret.fid 498 | if (ftype == Thrift.Type.STOP) 499 | break 500 | switch(fid) 501 | { 502 | case 1: if (ftype == Thrift.Type.STRING) { 503 | this.taskId = input.readString() 504 | } else { 505 | input.skip(ftype) 506 | } 507 | break 508 | case 2: if (ftype == Thrift.Type.I32) { 509 | this.taskType = input.readI32() 510 | } else { 511 | input.skip(ftype) 512 | } 513 | break 514 | case 3: if (ftype == Thrift.Type.MAP) { 515 | { 516 | var _size39 = 0 517 | var rtmp3 518 | this.taskAttributes = {} 519 | var _ktype40 = 0 520 | var _vtype41 = 0 521 | rtmp3 = input.readMapBegin() 522 | _ktype40= rtmp3.ktype 523 | _vtype41= rtmp3.vtype 524 | _size39= rtmp3.size 525 | for (var _i43 = 0; _i43 < _size39; ++_i43) 526 | { 527 | key44 = null 528 | val45 = null 529 | key44 = input.readString() 530 | val45 = input.readString() 531 | this.taskAttributes[key44] = val45 532 | } 533 | input.readMapEnd() 534 | } 535 | } else { 536 | input.skip(ftype) 537 | } 538 | break 539 | case 4: if (ftype == Thrift.Type.MAP) { 540 | { 541 | var _size46 = 0 542 | var rtmp3 543 | this.taskCounters = {} 544 | var _ktype47 = 0 545 | var _vtype48 = 0 546 | rtmp3 = input.readMapBegin() 547 | _ktype47= rtmp3.ktype 548 | _vtype48= rtmp3.vtype 549 | _size46= rtmp3.size 550 | for (var _i50 = 0; _i50 < _size46; ++_i50) 551 | { 552 | key51 = null 553 | val52 = null 554 | key51 = input.readString() 555 | val52 = input.readI64() 556 | this.taskCounters[key51] = val52 557 | } 558 | input.readMapEnd() 559 | } 560 | } else { 561 | input.skip(ftype) 562 | } 563 | break 564 | case 5: if (ftype == Thrift.Type.STRUCT) { 565 | this.operatorGraph = new ttypes.Graph() 566 | this.operatorGraph.read(input) 567 | } else { 568 | input.skip(ftype) 569 | } 570 | break 571 | case 6: if (ftype == Thrift.Type.LIST) { 572 | { 573 | var _size53 = 0 574 | var rtmp3 575 | this.operatorList = [] 576 | var _etype56 = 0 577 | rtmp3 = input.readListBegin() 578 | _etype56 = rtmp3.etype 579 | _size53 = rtmp3.size 580 | for (var _i57 = 0; _i57 < _size53; ++_i57) 581 | { 582 | var elem58 = null 583 | elem58 = new ttypes.Operator() 584 | elem58.read(input) 585 | this.operatorList.push(elem58) 586 | } 587 | input.readListEnd() 588 | } 589 | } else { 590 | input.skip(ftype) 591 | } 592 | break 593 | case 7: if (ftype == Thrift.Type.BOOL) { 594 | this.done = input.readBool() 595 | } else { 596 | input.skip(ftype) 597 | } 598 | break 599 | case 8: if (ftype == Thrift.Type.BOOL) { 600 | this.started = input.readBool() 601 | } else { 602 | input.skip(ftype) 603 | } 604 | break 605 | default: 606 | input.skip(ftype) 607 | } 608 | input.readFieldEnd() 609 | } 610 | input.readStructEnd() 611 | return 612 | } 613 | 614 | Task.prototype.write = function(output){ 615 | output.writeStructBegin('Task') 616 | if (null != this.taskId) { 617 | output.writeFieldBegin('taskId', Thrift.Type.STRING, 1) 618 | output.writeString(this.taskId) 619 | output.writeFieldEnd() 620 | } 621 | if (null != this.taskType) { 622 | output.writeFieldBegin('taskType', Thrift.Type.I32, 2) 623 | output.writeI32(this.taskType) 624 | output.writeFieldEnd() 625 | } 626 | if (null != this.taskAttributes) { 627 | output.writeFieldBegin('taskAttributes', Thrift.Type.MAP, 3) 628 | { 629 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.STRING, Thrift.objectLength(this.taskAttributes)) 630 | { 631 | for(var kiter59 in this.taskAttributes) { 632 | if (this.taskAttributes.hasOwnProperty(kiter59)) 633 | { 634 | var viter60 = this.taskAttributes[kiter59] 635 | output.writeString(kiter59) 636 | output.writeString(viter60) 637 | } 638 | } 639 | } 640 | output.writeMapEnd() 641 | } 642 | output.writeFieldEnd() 643 | } 644 | if (null != this.taskCounters) { 645 | output.writeFieldBegin('taskCounters', Thrift.Type.MAP, 4) 646 | { 647 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.I64, Thrift.objectLength(this.taskCounters)) 648 | { 649 | for(var kiter61 in this.taskCounters) { 650 | if (this.taskCounters.hasOwnProperty(kiter61)) 651 | { 652 | var viter62 = this.taskCounters[kiter61] 653 | output.writeString(kiter61) 654 | output.writeI64(viter62) 655 | } 656 | } 657 | } 658 | output.writeMapEnd() 659 | } 660 | output.writeFieldEnd() 661 | } 662 | if (null != this.operatorGraph) { 663 | output.writeFieldBegin('operatorGraph', Thrift.Type.STRUCT, 5) 664 | this.operatorGraph.write(output) 665 | output.writeFieldEnd() 666 | } 667 | if (null != this.operatorList) { 668 | output.writeFieldBegin('operatorList', Thrift.Type.LIST, 6) 669 | { 670 | output.writeListBegin(Thrift.Type.STRUCT, this.operatorList.length) 671 | { 672 | for(var iter63 in this.operatorList) 673 | { 674 | if (this.operatorList.hasOwnProperty(iter63)) 675 | { 676 | iter63=this.operatorList[iter63] 677 | iter63.write(output) 678 | } 679 | } 680 | } 681 | output.writeListEnd() 682 | } 683 | output.writeFieldEnd() 684 | } 685 | if (null != this.done) { 686 | output.writeFieldBegin('done', Thrift.Type.BOOL, 7) 687 | output.writeBool(this.done) 688 | output.writeFieldEnd() 689 | } 690 | if (null != this.started) { 691 | output.writeFieldBegin('started', Thrift.Type.BOOL, 8) 692 | output.writeBool(this.started) 693 | output.writeFieldEnd() 694 | } 695 | output.writeFieldStop() 696 | output.writeStructEnd() 697 | return 698 | } 699 | 700 | var Stage = module.exports.Stage = function(args){ 701 | this.stageId = null 702 | this.stageType = null 703 | this.stageAttributes = null 704 | this.stageCounters = null 705 | this.taskList = null 706 | this.done = null 707 | this.started = null 708 | if( args != null ){ if (null != args.stageId) 709 | this.stageId = args.stageId 710 | if (null != args.stageType) 711 | this.stageType = args.stageType 712 | if (null != args.stageAttributes) 713 | this.stageAttributes = args.stageAttributes 714 | if (null != args.stageCounters) 715 | this.stageCounters = args.stageCounters 716 | if (null != args.taskList) 717 | this.taskList = args.taskList 718 | if (null != args.done) 719 | this.done = args.done 720 | if (null != args.started) 721 | this.started = args.started 722 | }} 723 | Stage.prototype = {} 724 | Stage.prototype.read = function(input){ 725 | var ret = input.readStructBegin() 726 | while (1) 727 | { 728 | var ret = input.readFieldBegin() 729 | var fname = ret.fname 730 | var ftype = ret.ftype 731 | var fid = ret.fid 732 | if (ftype == Thrift.Type.STOP) 733 | break 734 | switch(fid) 735 | { 736 | case 1: if (ftype == Thrift.Type.STRING) { 737 | this.stageId = input.readString() 738 | } else { 739 | input.skip(ftype) 740 | } 741 | break 742 | case 2: if (ftype == Thrift.Type.I32) { 743 | this.stageType = input.readI32() 744 | } else { 745 | input.skip(ftype) 746 | } 747 | break 748 | case 3: if (ftype == Thrift.Type.MAP) { 749 | { 750 | var _size64 = 0 751 | var rtmp3 752 | this.stageAttributes = {} 753 | var _ktype65 = 0 754 | var _vtype66 = 0 755 | rtmp3 = input.readMapBegin() 756 | _ktype65= rtmp3.ktype 757 | _vtype66= rtmp3.vtype 758 | _size64= rtmp3.size 759 | for (var _i68 = 0; _i68 < _size64; ++_i68) 760 | { 761 | key69 = null 762 | val70 = null 763 | key69 = input.readString() 764 | val70 = input.readString() 765 | this.stageAttributes[key69] = val70 766 | } 767 | input.readMapEnd() 768 | } 769 | } else { 770 | input.skip(ftype) 771 | } 772 | break 773 | case 4: if (ftype == Thrift.Type.MAP) { 774 | { 775 | var _size71 = 0 776 | var rtmp3 777 | this.stageCounters = {} 778 | var _ktype72 = 0 779 | var _vtype73 = 0 780 | rtmp3 = input.readMapBegin() 781 | _ktype72= rtmp3.ktype 782 | _vtype73= rtmp3.vtype 783 | _size71= rtmp3.size 784 | for (var _i75 = 0; _i75 < _size71; ++_i75) 785 | { 786 | key76 = null 787 | val77 = null 788 | key76 = input.readString() 789 | val77 = input.readI64() 790 | this.stageCounters[key76] = val77 791 | } 792 | input.readMapEnd() 793 | } 794 | } else { 795 | input.skip(ftype) 796 | } 797 | break 798 | case 5: if (ftype == Thrift.Type.LIST) { 799 | { 800 | var _size78 = 0 801 | var rtmp3 802 | this.taskList = [] 803 | var _etype81 = 0 804 | rtmp3 = input.readListBegin() 805 | _etype81 = rtmp3.etype 806 | _size78 = rtmp3.size 807 | for (var _i82 = 0; _i82 < _size78; ++_i82) 808 | { 809 | var elem83 = null 810 | elem83 = new ttypes.Task() 811 | elem83.read(input) 812 | this.taskList.push(elem83) 813 | } 814 | input.readListEnd() 815 | } 816 | } else { 817 | input.skip(ftype) 818 | } 819 | break 820 | case 6: if (ftype == Thrift.Type.BOOL) { 821 | this.done = input.readBool() 822 | } else { 823 | input.skip(ftype) 824 | } 825 | break 826 | case 7: if (ftype == Thrift.Type.BOOL) { 827 | this.started = input.readBool() 828 | } else { 829 | input.skip(ftype) 830 | } 831 | break 832 | default: 833 | input.skip(ftype) 834 | } 835 | input.readFieldEnd() 836 | } 837 | input.readStructEnd() 838 | return 839 | } 840 | 841 | Stage.prototype.write = function(output){ 842 | output.writeStructBegin('Stage') 843 | if (null != this.stageId) { 844 | output.writeFieldBegin('stageId', Thrift.Type.STRING, 1) 845 | output.writeString(this.stageId) 846 | output.writeFieldEnd() 847 | } 848 | if (null != this.stageType) { 849 | output.writeFieldBegin('stageType', Thrift.Type.I32, 2) 850 | output.writeI32(this.stageType) 851 | output.writeFieldEnd() 852 | } 853 | if (null != this.stageAttributes) { 854 | output.writeFieldBegin('stageAttributes', Thrift.Type.MAP, 3) 855 | { 856 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.STRING, Thrift.objectLength(this.stageAttributes)) 857 | { 858 | for(var kiter84 in this.stageAttributes) { 859 | if (this.stageAttributes.hasOwnProperty(kiter84)) 860 | { 861 | var viter85 = this.stageAttributes[kiter84] 862 | output.writeString(kiter84) 863 | output.writeString(viter85) 864 | } 865 | } 866 | } 867 | output.writeMapEnd() 868 | } 869 | output.writeFieldEnd() 870 | } 871 | if (null != this.stageCounters) { 872 | output.writeFieldBegin('stageCounters', Thrift.Type.MAP, 4) 873 | { 874 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.I64, Thrift.objectLength(this.stageCounters)) 875 | { 876 | for(var kiter86 in this.stageCounters) { 877 | if (this.stageCounters.hasOwnProperty(kiter86)) 878 | { 879 | var viter87 = this.stageCounters[kiter86] 880 | output.writeString(kiter86) 881 | output.writeI64(viter87) 882 | } 883 | } 884 | } 885 | output.writeMapEnd() 886 | } 887 | output.writeFieldEnd() 888 | } 889 | if (null != this.taskList) { 890 | output.writeFieldBegin('taskList', Thrift.Type.LIST, 5) 891 | { 892 | output.writeListBegin(Thrift.Type.STRUCT, this.taskList.length) 893 | { 894 | for(var iter88 in this.taskList) 895 | { 896 | if (this.taskList.hasOwnProperty(iter88)) 897 | { 898 | iter88=this.taskList[iter88] 899 | iter88.write(output) 900 | } 901 | } 902 | } 903 | output.writeListEnd() 904 | } 905 | output.writeFieldEnd() 906 | } 907 | if (null != this.done) { 908 | output.writeFieldBegin('done', Thrift.Type.BOOL, 6) 909 | output.writeBool(this.done) 910 | output.writeFieldEnd() 911 | } 912 | if (null != this.started) { 913 | output.writeFieldBegin('started', Thrift.Type.BOOL, 7) 914 | output.writeBool(this.started) 915 | output.writeFieldEnd() 916 | } 917 | output.writeFieldStop() 918 | output.writeStructEnd() 919 | return 920 | } 921 | 922 | var Query = module.exports.Query = function(args){ 923 | this.queryId = null 924 | this.queryType = null 925 | this.queryAttributes = null 926 | this.queryCounters = null 927 | this.stageGraph = null 928 | this.stageList = null 929 | this.done = null 930 | this.started = null 931 | if( args != null ){ if (null != args.queryId) 932 | this.queryId = args.queryId 933 | if (null != args.queryType) 934 | this.queryType = args.queryType 935 | if (null != args.queryAttributes) 936 | this.queryAttributes = args.queryAttributes 937 | if (null != args.queryCounters) 938 | this.queryCounters = args.queryCounters 939 | if (null != args.stageGraph) 940 | this.stageGraph = args.stageGraph 941 | if (null != args.stageList) 942 | this.stageList = args.stageList 943 | if (null != args.done) 944 | this.done = args.done 945 | if (null != args.started) 946 | this.started = args.started 947 | }} 948 | Query.prototype = {} 949 | Query.prototype.read = function(input){ 950 | var ret = input.readStructBegin() 951 | while (1) 952 | { 953 | var ret = input.readFieldBegin() 954 | var fname = ret.fname 955 | var ftype = ret.ftype 956 | var fid = ret.fid 957 | if (ftype == Thrift.Type.STOP) 958 | break 959 | switch(fid) 960 | { 961 | case 1: if (ftype == Thrift.Type.STRING) { 962 | this.queryId = input.readString() 963 | } else { 964 | input.skip(ftype) 965 | } 966 | break 967 | case 2: if (ftype == Thrift.Type.STRING) { 968 | this.queryType = input.readString() 969 | } else { 970 | input.skip(ftype) 971 | } 972 | break 973 | case 3: if (ftype == Thrift.Type.MAP) { 974 | { 975 | var _size89 = 0 976 | var rtmp3 977 | this.queryAttributes = {} 978 | var _ktype90 = 0 979 | var _vtype91 = 0 980 | rtmp3 = input.readMapBegin() 981 | _ktype90= rtmp3.ktype 982 | _vtype91= rtmp3.vtype 983 | _size89= rtmp3.size 984 | for (var _i93 = 0; _i93 < _size89; ++_i93) 985 | { 986 | key94 = null 987 | val95 = null 988 | key94 = input.readString() 989 | val95 = input.readString() 990 | this.queryAttributes[key94] = val95 991 | } 992 | input.readMapEnd() 993 | } 994 | } else { 995 | input.skip(ftype) 996 | } 997 | break 998 | case 4: if (ftype == Thrift.Type.MAP) { 999 | { 1000 | var _size96 = 0 1001 | var rtmp3 1002 | this.queryCounters = {} 1003 | var _ktype97 = 0 1004 | var _vtype98 = 0 1005 | rtmp3 = input.readMapBegin() 1006 | _ktype97= rtmp3.ktype 1007 | _vtype98= rtmp3.vtype 1008 | _size96= rtmp3.size 1009 | for (var _i100 = 0; _i100 < _size96; ++_i100) 1010 | { 1011 | key101 = null 1012 | val102 = null 1013 | key101 = input.readString() 1014 | val102 = input.readI64() 1015 | this.queryCounters[key101] = val102 1016 | } 1017 | input.readMapEnd() 1018 | } 1019 | } else { 1020 | input.skip(ftype) 1021 | } 1022 | break 1023 | case 5: if (ftype == Thrift.Type.STRUCT) { 1024 | this.stageGraph = new ttypes.Graph() 1025 | this.stageGraph.read(input) 1026 | } else { 1027 | input.skip(ftype) 1028 | } 1029 | break 1030 | case 6: if (ftype == Thrift.Type.LIST) { 1031 | { 1032 | var _size103 = 0 1033 | var rtmp3 1034 | this.stageList = [] 1035 | var _etype106 = 0 1036 | rtmp3 = input.readListBegin() 1037 | _etype106 = rtmp3.etype 1038 | _size103 = rtmp3.size 1039 | for (var _i107 = 0; _i107 < _size103; ++_i107) 1040 | { 1041 | var elem108 = null 1042 | elem108 = new ttypes.Stage() 1043 | elem108.read(input) 1044 | this.stageList.push(elem108) 1045 | } 1046 | input.readListEnd() 1047 | } 1048 | } else { 1049 | input.skip(ftype) 1050 | } 1051 | break 1052 | case 7: if (ftype == Thrift.Type.BOOL) { 1053 | this.done = input.readBool() 1054 | } else { 1055 | input.skip(ftype) 1056 | } 1057 | break 1058 | case 8: if (ftype == Thrift.Type.BOOL) { 1059 | this.started = input.readBool() 1060 | } else { 1061 | input.skip(ftype) 1062 | } 1063 | break 1064 | default: 1065 | input.skip(ftype) 1066 | } 1067 | input.readFieldEnd() 1068 | } 1069 | input.readStructEnd() 1070 | return 1071 | } 1072 | 1073 | Query.prototype.write = function(output){ 1074 | output.writeStructBegin('Query') 1075 | if (null != this.queryId) { 1076 | output.writeFieldBegin('queryId', Thrift.Type.STRING, 1) 1077 | output.writeString(this.queryId) 1078 | output.writeFieldEnd() 1079 | } 1080 | if (null != this.queryType) { 1081 | output.writeFieldBegin('queryType', Thrift.Type.STRING, 2) 1082 | output.writeString(this.queryType) 1083 | output.writeFieldEnd() 1084 | } 1085 | if (null != this.queryAttributes) { 1086 | output.writeFieldBegin('queryAttributes', Thrift.Type.MAP, 3) 1087 | { 1088 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.STRING, Thrift.objectLength(this.queryAttributes)) 1089 | { 1090 | for(var kiter109 in this.queryAttributes) { 1091 | if (this.queryAttributes.hasOwnProperty(kiter109)) 1092 | { 1093 | var viter110 = this.queryAttributes[kiter109] 1094 | output.writeString(kiter109) 1095 | output.writeString(viter110) 1096 | } 1097 | } 1098 | } 1099 | output.writeMapEnd() 1100 | } 1101 | output.writeFieldEnd() 1102 | } 1103 | if (null != this.queryCounters) { 1104 | output.writeFieldBegin('queryCounters', Thrift.Type.MAP, 4) 1105 | { 1106 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.I64, Thrift.objectLength(this.queryCounters)) 1107 | { 1108 | for(var kiter111 in this.queryCounters) { 1109 | if (this.queryCounters.hasOwnProperty(kiter111)) 1110 | { 1111 | var viter112 = this.queryCounters[kiter111] 1112 | output.writeString(kiter111) 1113 | output.writeI64(viter112) 1114 | } 1115 | } 1116 | } 1117 | output.writeMapEnd() 1118 | } 1119 | output.writeFieldEnd() 1120 | } 1121 | if (null != this.stageGraph) { 1122 | output.writeFieldBegin('stageGraph', Thrift.Type.STRUCT, 5) 1123 | this.stageGraph.write(output) 1124 | output.writeFieldEnd() 1125 | } 1126 | if (null != this.stageList) { 1127 | output.writeFieldBegin('stageList', Thrift.Type.LIST, 6) 1128 | { 1129 | output.writeListBegin(Thrift.Type.STRUCT, this.stageList.length) 1130 | { 1131 | for(var iter113 in this.stageList) 1132 | { 1133 | if (this.stageList.hasOwnProperty(iter113)) 1134 | { 1135 | iter113=this.stageList[iter113] 1136 | iter113.write(output) 1137 | } 1138 | } 1139 | } 1140 | output.writeListEnd() 1141 | } 1142 | output.writeFieldEnd() 1143 | } 1144 | if (null != this.done) { 1145 | output.writeFieldBegin('done', Thrift.Type.BOOL, 7) 1146 | output.writeBool(this.done) 1147 | output.writeFieldEnd() 1148 | } 1149 | if (null != this.started) { 1150 | output.writeFieldBegin('started', Thrift.Type.BOOL, 8) 1151 | output.writeBool(this.started) 1152 | output.writeFieldEnd() 1153 | } 1154 | output.writeFieldStop() 1155 | output.writeStructEnd() 1156 | return 1157 | } 1158 | 1159 | var QueryPlan = module.exports.QueryPlan = function(args){ 1160 | this.queries = null 1161 | this.done = null 1162 | this.started = null 1163 | if( args != null ){ if (null != args.queries) 1164 | this.queries = args.queries 1165 | if (null != args.done) 1166 | this.done = args.done 1167 | if (null != args.started) 1168 | this.started = args.started 1169 | }} 1170 | QueryPlan.prototype = {} 1171 | QueryPlan.prototype.read = function(input){ 1172 | var ret = input.readStructBegin() 1173 | while (1) 1174 | { 1175 | var ret = input.readFieldBegin() 1176 | var fname = ret.fname 1177 | var ftype = ret.ftype 1178 | var fid = ret.fid 1179 | if (ftype == Thrift.Type.STOP) 1180 | break 1181 | switch(fid) 1182 | { 1183 | case 1: if (ftype == Thrift.Type.LIST) { 1184 | { 1185 | var _size114 = 0 1186 | var rtmp3 1187 | this.queries = [] 1188 | var _etype117 = 0 1189 | rtmp3 = input.readListBegin() 1190 | _etype117 = rtmp3.etype 1191 | _size114 = rtmp3.size 1192 | for (var _i118 = 0; _i118 < _size114; ++_i118) 1193 | { 1194 | var elem119 = null 1195 | elem119 = new ttypes.Query() 1196 | elem119.read(input) 1197 | this.queries.push(elem119) 1198 | } 1199 | input.readListEnd() 1200 | } 1201 | } else { 1202 | input.skip(ftype) 1203 | } 1204 | break 1205 | case 2: if (ftype == Thrift.Type.BOOL) { 1206 | this.done = input.readBool() 1207 | } else { 1208 | input.skip(ftype) 1209 | } 1210 | break 1211 | case 3: if (ftype == Thrift.Type.BOOL) { 1212 | this.started = input.readBool() 1213 | } else { 1214 | input.skip(ftype) 1215 | } 1216 | break 1217 | default: 1218 | input.skip(ftype) 1219 | } 1220 | input.readFieldEnd() 1221 | } 1222 | input.readStructEnd() 1223 | return 1224 | } 1225 | 1226 | QueryPlan.prototype.write = function(output){ 1227 | output.writeStructBegin('QueryPlan') 1228 | if (null != this.queries) { 1229 | output.writeFieldBegin('queries', Thrift.Type.LIST, 1) 1230 | { 1231 | output.writeListBegin(Thrift.Type.STRUCT, this.queries.length) 1232 | { 1233 | for(var iter120 in this.queries) 1234 | { 1235 | if (this.queries.hasOwnProperty(iter120)) 1236 | { 1237 | iter120=this.queries[iter120] 1238 | iter120.write(output) 1239 | } 1240 | } 1241 | } 1242 | output.writeListEnd() 1243 | } 1244 | output.writeFieldEnd() 1245 | } 1246 | if (null != this.done) { 1247 | output.writeFieldBegin('done', Thrift.Type.BOOL, 2) 1248 | output.writeBool(this.done) 1249 | output.writeFieldEnd() 1250 | } 1251 | if (null != this.started) { 1252 | output.writeFieldBegin('started', Thrift.Type.BOOL, 3) 1253 | output.writeBool(this.started) 1254 | output.writeFieldEnd() 1255 | } 1256 | output.writeFieldStop() 1257 | output.writeStructEnd() 1258 | return 1259 | } 1260 | 1261 | -------------------------------------------------------------------------------- /node_modules/gen-nodejs/serde_types.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | var Thrift = require('thrift').Thrift; 7 | var ttypes = module.exports = {}; 8 | ttypes.SERIALIZATION_LIB = 'serialization.lib' 9 | ttypes.SERIALIZATION_CLASS = 'serialization.class' 10 | ttypes.SERIALIZATION_FORMAT = 'serialization.format' 11 | ttypes.SERIALIZATION_DDL = 'serialization.ddl' 12 | ttypes.SERIALIZATION_NULL_FORMAT = 'serialization.null.format' 13 | ttypes.SERIALIZATION_LAST_COLUMN_TAKES_REST = 'serialization.last.column.takes.rest' 14 | ttypes.SERIALIZATION_SORT_ORDER = 'serialization.sort.order' 15 | ttypes.SERIALIZATION_USE_JSON_OBJECTS = 'serialization.use.json.object' 16 | ttypes.FIELD_DELIM = 'field.delim' 17 | ttypes.COLLECTION_DELIM = 'colelction.delim' 18 | ttypes.LINE_DELIM = 'line.delim' 19 | ttypes.MAPKEY_DELIM = 'mapkey.delim' 20 | ttypes.QUOTE_CHAR = 'quote.delim' 21 | ttypes.ESCAPE_CHAR = 'escape.delim' 22 | ttypes.VOID_TYPE_NAME = 'void' 23 | ttypes.BOOLEAN_TYPE_NAME = 'boolean' 24 | ttypes.TINYINT_TYPE_NAME = 'tinyint' 25 | ttypes.SMALLINT_TYPE_NAME = 'smallint' 26 | ttypes.INT_TYPE_NAME = 'int' 27 | ttypes.BIGINT_TYPE_NAME = 'bigint' 28 | ttypes.FLOAT_TYPE_NAME = 'float' 29 | ttypes.DOUBLE_TYPE_NAME = 'double' 30 | ttypes.STRING_TYPE_NAME = 'string' 31 | ttypes.DATE_TYPE_NAME = 'date' 32 | ttypes.DATETIME_TYPE_NAME = 'datetime' 33 | ttypes.TIMESTAMP_TYPE_NAME = 'timestamp' 34 | ttypes.LIST_TYPE_NAME = 'array' 35 | ttypes.MAP_TYPE_NAME = 'map' 36 | ttypes.STRUCT_TYPE_NAME = 'struct' 37 | ttypes.UNION_TYPE_NAME = 'uniontype' 38 | ttypes.LIST_COLUMNS = 'columns' 39 | ttypes.LIST_COLUMN_TYPES = 'columns.types' 40 | ttypes.PrimitiveTypes = ['void','boolean','tinyint','smallint','int','bigint','float','double','string','date','datetime','timestamp'] 41 | ttypes.CollectionTypes = ['array','map'] 42 | -------------------------------------------------------------------------------- /node_modules/thrift/binary_parser.js: -------------------------------------------------------------------------------- 1 | // Adapted from: http://github.com/christkv/node-mongodb-native/raw/master/lib/mongodb/bson/binary_parser.js 2 | 3 | var sys = require('sys'); 4 | 5 | //+ Jonas Raoni Soares Silva 6 | //@ http://jsfromhell.com/classes/binary-parser [v1.0] 7 | var chr = String.fromCharCode; 8 | 9 | var p = exports.BinaryParser = function( bigEndian, allowExceptions ){ 10 | this.bigEndian = bigEndian || true; 11 | this.allowExceptions = allowExceptions; 12 | }; 13 | p.bigEndian = true; 14 | 15 | var IBuffer = exports.BinaryParser.IBuffer = function( bigEndian, buffer ){ 16 | this.bigEndian = bigEndian || 1; 17 | this.buffer = []; 18 | this.setBuffer( buffer ); 19 | }; 20 | 21 | IBuffer.prototype.setBuffer = function( data ){ 22 | if( data ){ 23 | for( var l, i = l = data.length, b = this.buffer = new Array( l ); i; b[l - i] = data[--i] ); 24 | this.bigEndian && b.reverse(); 25 | } 26 | }; 27 | 28 | IBuffer.prototype.hasNeededBits = function( neededBits ){ 29 | return this.buffer.length >= -( -neededBits >> 3 ); 30 | }; 31 | 32 | IBuffer.prototype.checkBuffer = function( neededBits ){ 33 | if( !this.hasNeededBits( neededBits ) ) { 34 | console.log("missing: " + neededBits + " " + this.buffer.length); 35 | throw new Error( "checkBuffer::missing bytes" ); 36 | } 37 | }; 38 | 39 | IBuffer.prototype.readBits = function( start, length ){ 40 | //shl fix: Henri Torgemane ~1996 (compressed by Jonas Raoni) 41 | function shl( a, b ){ 42 | for( ; b--; a = ( ( a %= 0x7fffffff + 1 ) & 0x40000000 ) == 0x40000000 ? a * 2 : ( a - 0x40000000 ) * 2 + 0x7fffffff + 1 ); 43 | return a; 44 | } 45 | if( start < 0 || length <= 0 ) 46 | return 0; 47 | this.checkBuffer( start + length ); 48 | for( var offsetLeft, offsetRight = start % 8, curByte = this.buffer.length - ( start >> 3 ) - 1, lastByte = this.buffer.length + ( -( start + length ) >> 3 ), diff = curByte - lastByte, sum = ( ( this.buffer[ curByte ] >> offsetRight ) & ( ( 1 << ( diff ? 8 - offsetRight : length ) ) - 1 ) ) + ( diff && ( offsetLeft = ( start + length ) % 8 ) ? ( this.buffer[ lastByte++ ] & ( ( 1 << offsetLeft ) - 1 ) ) << ( diff-- << 3 ) - offsetRight : 0 ); diff; sum += shl( this.buffer[ lastByte++ ], ( diff-- << 3 ) - offsetRight ) ); 49 | return sum; 50 | }; 51 | 52 | p.warn = function( msg ){ 53 | if( this.allowExceptions ) 54 | throw new Error( msg ); 55 | return 1; 56 | }; 57 | p.decodeFloat = function( data, precisionBits, exponentBits ){ 58 | var b = new this.IBuffer( this.bigEndian, data ); 59 | b.checkBuffer( precisionBits + exponentBits + 1 ); 60 | var bias = Math.pow( 2, exponentBits - 1 ) - 1, signal = b.readBits( precisionBits + exponentBits, 1 ), exponent = b.readBits( precisionBits, exponentBits ), significand = 0, 61 | divisor = 2, curByte = b.buffer.length + ( -precisionBits >> 3 ) - 1; 62 | do{ 63 | for( var byteValue = b.buffer[ ++curByte ], startBit = precisionBits % 8 || 8, mask = 1 << startBit; mask >>= 1; ( byteValue & mask ) && ( significand += 1 / divisor ), divisor *= 2 ); 64 | }while( precisionBits -= startBit ); 65 | return exponent == ( bias << 1 ) + 1 ? significand ? NaN : signal ? -Infinity : +Infinity : ( 1 + signal * -2 ) * ( exponent || significand ? !exponent ? Math.pow( 2, -bias + 1 ) * significand : Math.pow( 2, exponent - bias ) * ( 1 + significand ) : 0 ); 66 | }; 67 | p.decodeInt = function( data, bits, signed, forceBigEndian ){ 68 | //console.log("decodeInt: ", data, bits, signed); 69 | var b = new this.IBuffer( this.bigEndian||forceBigEndian, data ), x = b.readBits( 0, bits ), max = Math.pow( 2, bits ); 70 | return signed && x >= max / 2 ? x - max : x; 71 | }; 72 | p.encodeFloat = function( data, precisionBits, exponentBits ){ 73 | var bias = Math.pow( 2, exponentBits - 1 ) - 1, minExp = -bias + 1, maxExp = bias, minUnnormExp = minExp - precisionBits, 74 | status = isNaN( n = parseFloat( data ) ) || n == -Infinity || n == +Infinity ? n : 0, 75 | exp = 0, len = 2 * bias + 1 + precisionBits + 3, bin = new Array( len ), 76 | signal = ( n = status !== 0 ? 0 : n ) < 0, n = Math.abs( n ), intPart = Math.floor( n ), floatPart = n - intPart, 77 | i, lastBit, rounded, j, result; 78 | for( i = len; i; bin[--i] = 0 ); 79 | for( i = bias + 2; intPart && i; bin[--i] = intPart % 2, intPart = Math.floor( intPart / 2 ) ); 80 | for( i = bias + 1; floatPart > 0 && i; ( bin[++i] = ( ( floatPart *= 2 ) >= 1 ) - 0 ) && --floatPart ); 81 | for( i = -1; ++i < len && !bin[i]; ); 82 | if( bin[( lastBit = precisionBits - 1 + ( i = ( exp = bias + 1 - i ) >= minExp && exp <= maxExp ? i + 1 : bias + 1 - ( exp = minExp - 1 ) ) ) + 1] ){ 83 | if( !( rounded = bin[lastBit] ) ){ 84 | for( j = lastBit + 2; !rounded && j < len; rounded = bin[j++] ); 85 | } 86 | for( j = lastBit + 1; rounded && --j >= 0; ( bin[j] = !bin[j] - 0 ) && ( rounded = 0 ) ); 87 | } 88 | for( i = i - 2 < 0 ? -1 : i - 3; ++i < len && !bin[i]; ); 89 | if( ( exp = bias + 1 - i ) >= minExp && exp <= maxExp ) 90 | ++i; 91 | else if( exp < minExp ){ 92 | exp != bias + 1 - len && exp < minUnnormExp && this.warn( "encodeFloat::float underflow" ); 93 | i = bias + 1 - ( exp = minExp - 1 ); 94 | } 95 | if( intPart || status !== 0 ){ 96 | this.warn( intPart ? "encodeFloat::float overflow" : "encodeFloat::" + status ); 97 | exp = maxExp + 1; 98 | i = bias + 2; 99 | if( status == -Infinity ) 100 | signal = 1; 101 | else if( isNaN( status ) ) 102 | bin[i] = 1; 103 | } 104 | for( n = Math.abs( exp + bias ), j = exponentBits + 1, result = ""; --j; result = ( n % 2 ) + result, n = n >>= 1 ); 105 | for( n = 0, j = 0, i = ( result = ( signal ? "1" : "0" ) + result + bin.slice( i, i + precisionBits ).join( "" ) ).length, r = []; i; j = ( j + 1 ) % 8 ){ 106 | n += ( 1 << j ) * result.charAt( --i ); 107 | if( j == 7 ){ 108 | r[r.length] = n; 109 | n = 0; 110 | } 111 | } 112 | if (n) { 113 | r[r.length] = n; 114 | } 115 | return new Buffer( this.bigEndian ? r.reverse() : r ); 116 | }; 117 | p.encodeInt = function( data, bits, signed, forceBigEndian ){ 118 | var max = Math.pow( 2, bits ); 119 | ( data >= max || data < -( max / 2 ) ) && this.warn( "encodeInt::overflow" ) && ( data = 0 ); 120 | data < 0 && ( data += max ); 121 | for( var r = []; data; r[r.length] = data % 256, data = Math.floor( data / 256 ) ); 122 | for( bits = -( -bits >> 3 ) - r.length; bits--; r[r.length] = 0 ); 123 | return new Buffer((this.bigEndian||forceBigEndian) ? r.reverse() : r ); 124 | }; 125 | p.toSmall = function( data ){ return this.decodeInt( data, 8, true ); }; 126 | p.fromSmall = function( data ){ return this.encodeInt( data, 8, true ); }; 127 | p.toByte = function( data ){ return this.decodeInt( data, 8, false ); }; 128 | p.fromByte = function( data ){ return this.encodeInt( data, 8, false ); }; 129 | p.toShort = function( data ){ return this.decodeInt( data, 16, true ); }; 130 | p.fromShort = function( data ){ return this.encodeInt( data, 16, true ); }; 131 | p.toWord = function( data ){ return this.decodeInt( data, 16, false ); }; 132 | p.fromWord = function( data ){ return this.encodeInt( data, 16, false ); }; 133 | p.toInt = function( data ){ return this.decodeInt( data, 32, true ); }; 134 | p.fromInt = function( data ){ return this.encodeInt( data, 32, true ); }; 135 | p.toLong = function( data ){ return this.decodeInt( data, 64, true ); }; 136 | p.fromLong = function( data ){ return this.encodeInt( data, 64, true ); }; 137 | p.toDWord = function( data ){ return this.decodeInt( data, 32, false ); }; 138 | p.fromDWord = function( data ){ return this.encodeInt( data, 32, false ); }; 139 | p.toQWord = function( data ){ return this.decodeInt( data, 64, true ); }; 140 | p.fromQWord = function( data ){ return this.encodeInt( data, 64, true ); }; 141 | p.toFloat = function( data ){ return this.decodeFloat( data, 23, 8 ); }; 142 | p.fromFloat = function( data ){ return this.encodeFloat( data, 23, 8 ); }; 143 | p.toDouble = function( data ){ return this.decodeFloat( data, 52, 11 ); }; 144 | p.fromDouble = function( data ){ return this.encodeFloat( data, 52, 11 ); }; 145 | 146 | // Factor out the encode so it can be shared by add_header and push_int32 147 | p.encode_int32 = function(number) { 148 | var a, b, c, d, unsigned; 149 | unsigned = (number < 0) ? (number + 0x100000000) : number; 150 | a = Math.floor(unsigned / 0xffffff); 151 | unsigned &= 0xffffff; 152 | b = Math.floor(unsigned / 0xffff); 153 | unsigned &= 0xffff; 154 | c = Math.floor(unsigned / 0xff); 155 | unsigned &= 0xff; 156 | d = Math.floor(unsigned); 157 | return chr(a) + chr(b) + chr(c) + chr(d); 158 | }; 159 | 160 | p.encode_int64 = function(number) { 161 | var a, b, c, d, e, f, g, h, unsigned; 162 | unsigned = (number < 0) ? (number + 0x10000000000000000) : number; 163 | a = Math.floor(unsigned / 0xffffffffffffff); 164 | unsigned &= 0xffffffffffffff; 165 | b = Math.floor(unsigned / 0xffffffffffff); 166 | unsigned &= 0xffffffffffff; 167 | c = Math.floor(unsigned / 0xffffffffff); 168 | unsigned &= 0xffffffffff; 169 | d = Math.floor(unsigned / 0xffffffff); 170 | unsigned &= 0xffffffff; 171 | e = Math.floor(unsigned / 0xffffff); 172 | unsigned &= 0xffffff; 173 | f = Math.floor(unsigned / 0xffff); 174 | unsigned &= 0xffff; 175 | g = Math.floor(unsigned / 0xff); 176 | unsigned &= 0xff; 177 | h = Math.floor(unsigned); 178 | return chr(a) + chr(b) + chr(c) + chr(d) + chr(e) + chr(f) + chr(g) + chr(h); 179 | }; 180 | 181 | /** 182 | UTF8 methods 183 | **/ 184 | 185 | // Take a raw binary string and return a utf8 string 186 | p.decode_utf8 = function(a) { 187 | var string = ""; 188 | var i = 0; 189 | var c = c1 = c2 = 0; 190 | 191 | while ( i < a.length ) { 192 | c = a.charCodeAt(i); 193 | if (c < 128) { 194 | string += String.fromCharCode(c); 195 | i++; 196 | } else if((c > 191) && (c < 224)) { 197 | c2 = a.charCodeAt(i+1); 198 | string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); 199 | i += 2; 200 | } else { 201 | c2 = a.charCodeAt(i+1); 202 | c3 = a.charCodeAt(i+2); 203 | string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); 204 | i += 3; 205 | } 206 | } 207 | return string; 208 | }; 209 | 210 | // Encode a cstring correctly 211 | p.encode_cstring = function(s) { 212 | return unescape(encodeURIComponent(s)) + p.fromByte(0); 213 | }; 214 | 215 | // Take a utf8 string and return a binary string 216 | p.encode_utf8 = function(s) { 217 | var a=""; 218 | for (var n=0; n< s.length; n++) { 219 | var c=s.charCodeAt(n); 220 | if (c<128) { 221 | a += String.fromCharCode(c); 222 | } else if ((c>127)&&(c<2048)) { 223 | a += String.fromCharCode( (c>>6) | 192) ; 224 | a += String.fromCharCode( (c&63) | 128); 225 | } else { 226 | a += String.fromCharCode( (c>>12) | 224); 227 | a += String.fromCharCode( ((c>>6) & 63) | 128); 228 | a += String.fromCharCode( (c&63) | 128); 229 | } 230 | } 231 | return a; 232 | }; 233 | 234 | p.hprint = function(s) { 235 | for (var i=0; i 4 bytes, found only " + data.length); 36 | residual = data; 37 | break; 38 | //throw Error("Expecting > 4 bytes, found only " + data.length); 39 | } 40 | frameLeft = BinaryParser.toInt(data.slice(0,4)); 41 | frame = new Buffer(frameLeft); 42 | framePos = 0; 43 | data = data.slice(4, data.length); 44 | } 45 | 46 | if (data.length >= frameLeft) { 47 | data.copy(frame, framePos, 0, frameLeft); 48 | data = data.slice(frameLeft, data.length); 49 | 50 | frameLeft = 0; 51 | callback(new TFramedTransport(frame)); 52 | } else if (data.length) { 53 | data.copy(frame, framePos, 0, data.length); 54 | frameLeft -= data.length; 55 | framePos += data.length; 56 | data = data.slice(data.length, data.length); 57 | } 58 | } 59 | }; 60 | }; 61 | 62 | TFramedTransport.prototype = { 63 | commitPosition: function(){}, 64 | rollbackPosition: function(){}, 65 | 66 | // TODO: Implement open/close support 67 | isOpen: function() {return true;}, 68 | open: function() {}, 69 | close: function() {}, 70 | 71 | read: function(len) { // this function will be used for each frames. 72 | var end = this.readPos + len; 73 | 74 | if (this.inBuf.length < end) { 75 | throw new Error('read(' + len + ') failed - not enough data'); 76 | } 77 | 78 | var buf = this.inBuf.slice(this.readPos, end); 79 | this.readPos = end; 80 | return buf; 81 | }, 82 | 83 | readAll: function() { 84 | return this.inBuf; 85 | }, 86 | 87 | write: function(buf, encoding) { 88 | if (typeof(buf) === "string") { 89 | // Defaulting to ascii encoding here since that's more like the original 90 | // code, but I feel like 'utf8' would be a better choice. 91 | buf = new Buffer(buf, encoding || 'ascii'); 92 | } 93 | this.outBuffers.push(buf); 94 | this.outCount += buf.length; 95 | }, 96 | 97 | flush: function() { 98 | var out = new Buffer(this.outCount), 99 | pos = 0; 100 | this.outBuffers.forEach(function(buf) { 101 | buf.copy(out, pos, 0); 102 | pos += buf.length; 103 | }); 104 | 105 | if (this.onFlush) { 106 | // TODO: optimize this better, allocate one buffer instead of both: 107 | var msg = new Buffer(out.length + 4); 108 | BinaryParser.fromInt(out.length).copy(msg, 0, 0, 4); 109 | out.copy(msg, 4, 0, out.length); 110 | this.onFlush(msg); 111 | } 112 | 113 | this.outBuffers = []; 114 | this.outCount = 0; 115 | } 116 | }; 117 | 118 | var TBufferedTransport = exports.TBufferedTransport = function(buffer, callback) { 119 | this.defaultReadBufferSize = 1024; 120 | this.writeBufferSize = 512; // Soft Limit 121 | this.inBuf = new Buffer(this.defaultReadBufferSize); 122 | this.readCursor = 0; 123 | this.writeCursor = 0; // for input buffer 124 | this.outBuffers = []; 125 | this.outCount = 0; 126 | this.onFlush = callback; 127 | }; 128 | TBufferedTransport.receiver = function(callback) { 129 | var reader = new TBufferedTransport(); 130 | 131 | return function(data) { 132 | if (reader.writeCursor + data.length > reader.inBuf.length) { 133 | var buf = new Buffer(reader.writeCursor + data.length); 134 | reader.inBuf.copy(buf, 0, 0, reader.writeCursor); 135 | reader.inBuf = buf; 136 | } 137 | data.copy(reader.inBuf, reader.writeCursor, 0); 138 | reader.writeCursor += data.length; 139 | 140 | callback(reader); 141 | }; 142 | }; 143 | 144 | TBufferedTransport.prototype = { 145 | commitPosition: function(){ 146 | var unreadedSize = this.writeCursor - this.readCursor; 147 | var bufSize = (unreadedSize * 2 > this.defaultReadBufferSize) ? unreadedSize * 2 : this.defaultReadBufferSize; 148 | var buf = new Buffer(bufSize); 149 | if (unreadedSize > 0) { 150 | this.inBuf.copy(buf, 0, this.readCursor, unreadedSize); 151 | } 152 | this.readCursor = 0; 153 | this.writeCursor = unreadedSize; 154 | this.inBuf = buf; 155 | }, 156 | rollbackPosition: function(){ 157 | this.readCursor = 0; 158 | }, 159 | 160 | // TODO: Implement open/close support 161 | isOpen: function() {return true;}, 162 | open: function() {}, 163 | close: function() {}, 164 | 165 | read: function(len) { 166 | if (this.readCursor + len > this.writeCursor) { 167 | throw new InputBufferUnderrunError(); 168 | } 169 | var buf = new Buffer(len); 170 | this.inBuf.copy(buf, 0, this.readCursor, this.readCursor + len); 171 | this.readCursor += len; 172 | return buf; 173 | }, 174 | 175 | readAll: function() { 176 | if (this.readCursor >= this.writeCursor) { 177 | throw new InputBufferUnderrunError(); 178 | } 179 | var buf = new Buffer(this.writeCursor - this.readCursor); 180 | this.inBuf.copy(buf, 0, this.readCursor, this.writeCursor - this.readCursor); 181 | this.readCursor = this.writeCursor; 182 | return buf; 183 | }, 184 | 185 | write: function(buf, encoding) { 186 | if (typeof(buf) === "string") { 187 | // Defaulting to ascii encoding here since that's more like the original 188 | // code, but I feel like 'utf8' would be a better choice. 189 | buf = new Buffer(buf, encoding || 'ascii'); 190 | } 191 | if (this.outCount + buf.length > this.writeBufferSize) { 192 | this.flush(); 193 | } 194 | 195 | this.outBuffers.push(buf); 196 | this.outCount += buf.length; 197 | 198 | if (this.outCount >= this.writeBufferSize) { 199 | this.flush(); 200 | } 201 | }, 202 | 203 | flush: function() { 204 | if (this.outCount < 1) { 205 | return; 206 | } 207 | 208 | var msg = new Buffer(this.outCount), 209 | pos = 0; 210 | this.outBuffers.forEach(function(buf) { 211 | buf.copy(msg, pos, 0); 212 | pos += buf.length; 213 | }); 214 | 215 | if (this.onFlush) { 216 | this.onFlush(msg); 217 | } 218 | 219 | this.outBuffers = []; 220 | this.outCount = 0; 221 | } 222 | }; 223 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Forward", 3 | "contributors":["Jae Lee ", "Antonio Terreno ", "Andy Kent"], 4 | "name": "node-hive", 5 | "description": "Node Hive Client Library", 6 | "version": "0.1.1", 7 | "homepage": "https://github.com/forward/node-hive", 8 | "repository": { 9 | "type": "git", 10 | "url": "git://github.com/forward/node-hive.git" 11 | }, 12 | "main": "node-hive", 13 | "engines": { 14 | "node": "v0.4.8" 15 | }, 16 | "dependencies": {}, 17 | "devDependencies": {} 18 | } -------------------------------------------------------------------------------- /result_set.js: -------------------------------------------------------------------------------- 1 | var ResultSet = function(rows, schema) { 2 | this.rows = rows; 3 | this.schema = schema.fieldSchemas; 4 | }; 5 | 6 | ResultSet.prototype.each = function(cb) { 7 | for(var i in this.rows) { 8 | var rowArray = this.rows[i].split("\t"); 9 | var row = {}; 10 | var headers = this.headers(); 11 | var schema = this.schema; 12 | typecast = function(column, stringValue) { 13 | var found = schema.filter(function(s) { return s.name === column }); 14 | var type = 'string'; 15 | if(found.length === 1) type = found[0].type; 16 | if(type === 'double' || type === 'float' || type === 'int') return Number(stringValue); 17 | return stringValue; 18 | }; 19 | for(var a in rowArray) { 20 | row[headers[a]] = typecast(headers[a], rowArray[a]); 21 | } 22 | cb(row); 23 | }; 24 | }; 25 | 26 | ResultSet.prototype.toArray = function() { 27 | var ret = []; 28 | for(var i in this.rows) { 29 | ret.push(this.rows[i].split("\t")); 30 | }; 31 | return ret; 32 | }; 33 | 34 | ResultSet.prototype.headers = function() { 35 | var colCount = this.rows[0].split("\t").length; 36 | var ret = []; 37 | var partitionCount = 1; 38 | var i = 0; 39 | while(i < colCount) { 40 | schemaName = this.schema[i] ? this.schema[i].name : ("_p" + partitionCount++); 41 | ret.push(schemaName); 42 | i++; 43 | } 44 | this.headers = function() { return ret; }; 45 | return ret; 46 | }; 47 | 48 | ResultSet.prototype.toTSV = function(headers) { 49 | var body = this.rows.join("\n"); 50 | if(headers) { 51 | body = this.headers().join("\t") + "\n" + body; 52 | } 53 | return body; 54 | }; 55 | 56 | exports.create = function(rows, schema) { 57 | return (new ResultSet(rows, schema)) 58 | }; -------------------------------------------------------------------------------- /src/hive-thrift/fb303.thrift: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /** 21 | * fb303.thrift 22 | */ 23 | 24 | namespace java com.facebook.fb303 25 | namespace cpp facebook.fb303 26 | namespace perl Facebook.FB303 27 | 28 | /** 29 | * Common status reporting mechanism across all services 30 | */ 31 | enum fb_status { 32 | DEAD = 0, 33 | STARTING = 1, 34 | ALIVE = 2, 35 | STOPPING = 3, 36 | STOPPED = 4, 37 | WARNING = 5, 38 | } 39 | 40 | /** 41 | * Standard base service 42 | */ 43 | service FacebookService { 44 | 45 | /** 46 | * Returns a descriptive name of the service 47 | */ 48 | string getName(), 49 | 50 | /** 51 | * Returns the version of the service 52 | */ 53 | string getVersion(), 54 | 55 | /** 56 | * Gets the status of this service 57 | */ 58 | fb_status getStatus(), 59 | 60 | /** 61 | * User friendly description of status, such as why the service is in 62 | * the dead or warning state, or what is being started or stopped. 63 | */ 64 | string getStatusDetails(), 65 | 66 | /** 67 | * Gets the counters for this service 68 | */ 69 | map getCounters(), 70 | 71 | /** 72 | * Gets the value of a single counter 73 | */ 74 | i64 getCounter(1: string key), 75 | 76 | /** 77 | * Sets an option 78 | */ 79 | void setOption(1: string key, 2: string value), 80 | 81 | /** 82 | * Gets an option 83 | */ 84 | string getOption(1: string key), 85 | 86 | /** 87 | * Gets all options 88 | */ 89 | map getOptions(), 90 | 91 | /** 92 | * Returns a CPU profile over the given time interval (client and server 93 | * must agree on the profile format). 94 | */ 95 | string getCpuProfile(1: i32 profileDurationInSec), 96 | 97 | /** 98 | * Returns the unix time that the server has been running since 99 | */ 100 | i64 aliveSince(), 101 | 102 | /** 103 | * Tell the server to reload its configuration, reopen log files, etc 104 | */ 105 | oneway void reinitialize(), 106 | 107 | /** 108 | * Suggest a shutdown to the server 109 | */ 110 | oneway void shutdown(), 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/hive-thrift/hive_metastore.thrift: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/thrift -java 2 | # 3 | # Thrift Service that the MetaStore is built on 4 | # 5 | 6 | include "fb303.thrift" 7 | 8 | namespace java org.apache.hadoop.hive.metastore.api 9 | namespace php metastore 10 | namespace cpp Apache.Hadoop.Hive 11 | 12 | const string DDL_TIME = "transient_lastDdlTime" 13 | 14 | struct Version { 15 | 1: string version, 16 | 2: string comments 17 | } 18 | 19 | struct FieldSchema { 20 | 1: string name, // name of the field 21 | 2: string type, // type of the field. primitive types defined above, specify list, map for lists & maps 22 | 3: string comment 23 | } 24 | 25 | struct Type { 26 | 1: string name, // one of the types in PrimitiveTypes or CollectionTypes or User defined types 27 | 2: optional string type1, // object type if the name is 'list' (LIST_TYPE), key type if the name is 'map' (MAP_TYPE) 28 | 3: optional string type2, // val type if the name is 'map' (MAP_TYPE) 29 | 4: optional list fields // if the name is one of the user defined types 30 | } 31 | 32 | enum HiveObjectType { 33 | GLOBAL = 1, 34 | DATABASE = 2, 35 | TABLE = 3, 36 | PARTITION = 4, 37 | COLUMN = 5, 38 | } 39 | 40 | enum PrincipalType { 41 | USER = 1, 42 | ROLE = 2, 43 | GROUP = 3, 44 | } 45 | 46 | struct HiveObjectRef{ 47 | 1: HiveObjectType objectType, 48 | 2: string dbName, 49 | 3: string objectName, 50 | 4: list partValues, 51 | 5: string columnName, 52 | } 53 | 54 | struct PrivilegeGrantInfo { 55 | 1: string privilege, 56 | 2: i32 createTime, 57 | 3: string grantor, 58 | 4: PrincipalType grantorType, 59 | 5: bool grantOption, 60 | } 61 | 62 | struct HiveObjectPrivilege { 63 | 1: HiveObjectRef hiveObject, 64 | 2: string principalName, 65 | 3: PrincipalType principalType, 66 | 4: PrivilegeGrantInfo grantInfo, 67 | } 68 | 69 | struct PrivilegeBag { 70 | 1: list privileges, 71 | } 72 | 73 | struct PrincipalPrivilegeSet { 74 | 1: map> userPrivileges, // user name -> privilege grant info 75 | 2: map> groupPrivileges, // group name -> privilege grant info 76 | 3: map> rolePrivileges, //role name -> privilege grant info 77 | } 78 | 79 | struct Role { 80 | 1: string roleName, 81 | 2: i32 createTime, 82 | 3: string ownerName, 83 | } 84 | 85 | // namespace for tables 86 | struct Database { 87 | 1: string name, 88 | 2: string description, 89 | 3: string locationUri, 90 | 4: map parameters, // properties associated with the database 91 | 5: optional PrincipalPrivilegeSet privileges 92 | } 93 | 94 | // This object holds the information needed by SerDes 95 | struct SerDeInfo { 96 | 1: string name, // name of the serde, table name by default 97 | 2: string serializationLib, // usually the class that implements the extractor & loader 98 | 3: map parameters // initialization parameters 99 | } 100 | 101 | // sort order of a column (column name along with asc(1)/desc(0)) 102 | struct Order { 103 | 1: string col, // sort column name 104 | 2: i32 order // asc(1) or desc(0) 105 | } 106 | 107 | // this object holds all the information about physical storage of the data belonging to a table 108 | struct StorageDescriptor { 109 | 1: list cols, // required (refer to types defined above) 110 | 2: string location, // defaults to //tablename 111 | 3: string inputFormat, // SequenceFileInputFormat (binary) or TextInputFormat` or custom format 112 | 4: string outputFormat, // SequenceFileOutputFormat (binary) or IgnoreKeyTextOutputFormat or custom format 113 | 5: bool compressed, // compressed or not 114 | 6: i32 numBuckets, // this must be specified if there are any dimension columns 115 | 7: SerDeInfo serdeInfo, // serialization and deserialization information 116 | 8: list bucketCols, // reducer grouping columns and clustering columns and bucketing columns` 117 | 9: list sortCols, // sort order of the data in each bucket 118 | 10: map parameters // any user supplied key value hash 119 | } 120 | 121 | // table information 122 | struct Table { 123 | 1: string tableName, // name of the table 124 | 2: string dbName, // database name ('default') 125 | 3: string owner, // owner of this table 126 | 4: i32 createTime, // creation time of the table 127 | 5: i32 lastAccessTime, // last access time (usually this will be filled from HDFS and shouldn't be relied on) 128 | 6: i32 retention, // retention time 129 | 7: StorageDescriptor sd, // storage descriptor of the table 130 | 8: list partitionKeys, // partition keys of the table. only primitive types are supported 131 | 9: map parameters, // to store comments or any other user level parameters 132 | 10: string viewOriginalText, // original view text, null for non-view 133 | 11: string viewExpandedText, // expanded view text, null for non-view 134 | 12: string tableType, // table type enum, e.g. EXTERNAL_TABLE 135 | 13: optional PrincipalPrivilegeSet privileges, 136 | } 137 | 138 | struct Partition { 139 | 1: list values // string value is converted to appropriate partition key type 140 | 2: string dbName, 141 | 3: string tableName, 142 | 4: i32 createTime, 143 | 5: i32 lastAccessTime, 144 | 6: StorageDescriptor sd, 145 | 7: map parameters, 146 | 8: optional PrincipalPrivilegeSet privileges 147 | } 148 | 149 | struct Index { 150 | 1: string indexName, // unique with in the whole database namespace 151 | 2: string indexHandlerClass, // reserved 152 | 3: string dbName, 153 | 4: string origTableName, 154 | 5: i32 createTime, 155 | 6: i32 lastAccessTime, 156 | 7: string indexTableName, 157 | 8: StorageDescriptor sd, 158 | 9: map parameters, 159 | 10: bool deferredRebuild 160 | } 161 | 162 | // schema of the table/query results etc. 163 | struct Schema { 164 | // column names, types, comments 165 | 1: list fieldSchemas, // delimiters etc 166 | 2: map properties 167 | } 168 | 169 | exception MetaException { 170 | 1: string message 171 | } 172 | 173 | exception UnknownTableException { 174 | 1: string message 175 | } 176 | 177 | exception UnknownDBException { 178 | 1: string message 179 | } 180 | 181 | exception AlreadyExistsException { 182 | 1: string message 183 | } 184 | 185 | exception InvalidObjectException { 186 | 1: string message 187 | } 188 | 189 | exception NoSuchObjectException { 190 | 1: string message 191 | } 192 | 193 | exception IndexAlreadyExistsException { 194 | 1: string message 195 | } 196 | 197 | exception InvalidOperationException { 198 | 1: string message 199 | } 200 | 201 | exception ConfigValSecurityException { 202 | 1: string message 203 | } 204 | 205 | /** 206 | * This interface is live. 207 | */ 208 | service ThriftHiveMetastore extends fb303.FacebookService 209 | { 210 | void create_database(1:Database database) throws(1:AlreadyExistsException o1, 2:InvalidObjectException o2, 3:MetaException o3) 211 | Database get_database(1:string name) throws(1:NoSuchObjectException o1, 2:MetaException o2) 212 | void drop_database(1:string name, 2:bool deleteData) throws(1:NoSuchObjectException o1, 2:InvalidOperationException o2, 3:MetaException o3) 213 | list get_databases(1:string pattern) throws(1:MetaException o1) 214 | list get_all_databases() throws(1:MetaException o1) 215 | void alter_database(1:string dbname, 2:Database db) throws(1:MetaException o1, 2:NoSuchObjectException o2) 216 | 217 | // returns the type with given name (make seperate calls for the dependent types if needed) 218 | Type get_type(1:string name) throws(1:MetaException o1, 2:NoSuchObjectException o2) 219 | bool create_type(1:Type type) throws(1:AlreadyExistsException o1, 2:InvalidObjectException o2, 3:MetaException o3) 220 | bool drop_type(1:string type) throws(1:MetaException o1, 2:NoSuchObjectException o2) 221 | map get_type_all(1:string name) 222 | throws(1:MetaException o2) 223 | 224 | // Gets a list of FieldSchemas describing the columns of a particular table 225 | list get_fields(1: string db_name, 2: string table_name) throws (1: MetaException o1, 2: UnknownTableException o2, 3: UnknownDBException o3), 226 | 227 | // Gets a list of FieldSchemas describing both the columns and the partition keys of a particular table 228 | list get_schema(1: string db_name, 2: string table_name) throws (1: MetaException o1, 2: UnknownTableException o2, 3: UnknownDBException o3) 229 | 230 | // create a Hive table. Following fields must be set 231 | // tableName 232 | // database (only 'default' for now until Hive QL supports databases) 233 | // owner (not needed, but good to have for tracking purposes) 234 | // sd.cols (list of field schemas) 235 | // sd.inputFormat (SequenceFileInputFormat (binary like falcon tables or u_full) or TextInputFormat) 236 | // sd.outputFormat (SequenceFileInputFormat (binary) or TextInputFormat) 237 | // sd.serdeInfo.serializationLib (SerDe class name eg org.apache.hadoop.hive.serde.simple_meta.MetadataTypedColumnsetSerDe 238 | // * See notes on DDL_TIME 239 | void create_table(1:Table tbl) throws(1:AlreadyExistsException o1, 2:InvalidObjectException o2, 3:MetaException o3, 4:NoSuchObjectException o4) 240 | // drops the table and all the partitions associated with it if the table has partitions 241 | // delete data (including partitions) if deleteData is set to true 242 | void drop_table(1:string dbname, 2:string name, 3:bool deleteData) 243 | throws(1:NoSuchObjectException o1, 2:MetaException o3) 244 | list get_tables(1: string db_name, 2: string pattern) throws (1: MetaException o1) 245 | list get_all_tables(1: string db_name) throws (1: MetaException o1) 246 | 247 | Table get_table(1:string dbname, 2:string tbl_name) 248 | throws (1:MetaException o1, 2:NoSuchObjectException o2) 249 | // alter table applies to only future partitions not for existing partitions 250 | // * See notes on DDL_TIME 251 | void alter_table(1:string dbname, 2:string tbl_name, 3:Table new_tbl) 252 | throws (1:InvalidOperationException o1, 2:MetaException o2) 253 | 254 | // the following applies to only tables that have partitions 255 | // * See notes on DDL_TIME 256 | Partition add_partition(1:Partition new_part) 257 | throws(1:InvalidObjectException o1, 2:AlreadyExistsException o2, 3:MetaException o3) 258 | Partition append_partition(1:string db_name, 2:string tbl_name, 3:list part_vals) 259 | throws (1:InvalidObjectException o1, 2:AlreadyExistsException o2, 3:MetaException o3) 260 | Partition append_partition_by_name(1:string db_name, 2:string tbl_name, 3:string part_name) 261 | throws (1:InvalidObjectException o1, 2:AlreadyExistsException o2, 3:MetaException o3) 262 | bool drop_partition(1:string db_name, 2:string tbl_name, 3:list part_vals, 4:bool deleteData) 263 | throws(1:NoSuchObjectException o1, 2:MetaException o2) 264 | bool drop_partition_by_name(1:string db_name, 2:string tbl_name, 3:string part_name, 4:bool deleteData) 265 | throws(1:NoSuchObjectException o1, 2:MetaException o2) 266 | Partition get_partition(1:string db_name, 2:string tbl_name, 3:list part_vals) 267 | throws(1:MetaException o1, 2:NoSuchObjectException o2) 268 | 269 | Partition get_partition_with_auth(1:string db_name, 2:string tbl_name, 3:list part_vals, 270 | 4: string user_name, 5: list group_names) throws(1:MetaException o1, 2:NoSuchObjectException o2) 271 | 272 | Partition get_partition_by_name(1:string db_name 2:string tbl_name, 3:string part_name) 273 | throws(1:MetaException o1, 2:NoSuchObjectException o2) 274 | 275 | // returns all the partitions for this table in reverse chronological order. 276 | // If max parts is given then it will return only that many. 277 | list get_partitions(1:string db_name, 2:string tbl_name, 3:i16 max_parts=-1) 278 | throws(1:NoSuchObjectException o1, 2:MetaException o2) 279 | list get_partitions_with_auth(1:string db_name, 2:string tbl_name, 3:i16 max_parts=-1, 280 | 4: string user_name, 5: list group_names) throws(1:NoSuchObjectException o1, 2:MetaException o2) 281 | 282 | list get_partition_names(1:string db_name, 2:string tbl_name, 3:i16 max_parts=-1) 283 | throws(1:MetaException o2) 284 | 285 | // get_partition*_ps methods allow filtering by a partial partition specification, 286 | // as needed for dynamic partitions. The values that are not restricted should 287 | // be empty strings. Nulls were considered (instead of "") but caused errors in 288 | // generated Python code. The size of part_vals may be smaller than the 289 | // number of partition columns - the unspecified values are considered the same 290 | // as "". 291 | list get_partitions_ps(1:string db_name 2:string tbl_name 292 | 3:list part_vals, 4:i16 max_parts=-1) 293 | throws(1:MetaException o1) 294 | list get_partitions_ps_with_auth(1:string db_name, 2:string tbl_name, 3:list part_vals, 4:i16 max_parts=-1, 295 | 5: string user_name, 6: list group_names) throws(1:NoSuchObjectException o1, 2:MetaException o2) 296 | 297 | list get_partition_names_ps(1:string db_name, 298 | 2:string tbl_name, 3:list part_vals, 4:i16 max_parts=-1) 299 | throws(1:MetaException o1) 300 | 301 | // get the partitions matching the given partition filter 302 | list get_partitions_by_filter(1:string db_name 2:string tbl_name 303 | 3:string filter, 4:i16 max_parts=-1) 304 | throws(1:MetaException o1, 2:NoSuchObjectException o2) 305 | 306 | // changes the partition to the new partition object. partition is identified from the part values 307 | // in the new_part 308 | // * See notes on DDL_TIME 309 | void alter_partition(1:string db_name, 2:string tbl_name, 3:Partition new_part) 310 | throws(1:InvalidOperationException o1, 2:MetaException o2) 311 | 312 | // gets the value of the configuration key in the metastore server. returns 313 | // defaultValue if the key does not exist. if the configuration key does not 314 | // begin with "hive", "mapred", or "hdfs", a ConfigValSecurityException is 315 | // thrown. 316 | string get_config_value(1:string name, 2:string defaultValue) 317 | throws(1:ConfigValSecurityException o1) 318 | 319 | // converts a partition name into a partition values array 320 | list partition_name_to_vals(1: string part_name) 321 | throws(1: MetaException o1) 322 | // converts a partition name into a partition specification (a mapping from 323 | // the partition cols to the values) 324 | map partition_name_to_spec(1: string part_name) 325 | throws(1: MetaException o1) 326 | 327 | //index 328 | Index add_index(1:Index new_index, 2: Table index_table) 329 | throws(1:InvalidObjectException o1, 2:AlreadyExistsException o2, 3:MetaException o3) 330 | void alter_index(1:string dbname, 2:string base_tbl_name, 3:string idx_name, 4:Index new_idx) 331 | throws (1:InvalidOperationException o1, 2:MetaException o2) 332 | bool drop_index_by_name(1:string db_name, 2:string tbl_name, 3:string index_name, 4:bool deleteData) 333 | throws(1:NoSuchObjectException o1, 2:MetaException o2) 334 | Index get_index_by_name(1:string db_name 2:string tbl_name, 3:string index_name) 335 | throws(1:MetaException o1, 2:NoSuchObjectException o2) 336 | 337 | list get_indexes(1:string db_name, 2:string tbl_name, 3:i16 max_indexes=-1) 338 | throws(1:NoSuchObjectException o1, 2:MetaException o2) 339 | list get_index_names(1:string db_name, 2:string tbl_name, 3:i16 max_indexes=-1) 340 | throws(1:MetaException o2) 341 | 342 | //authorization privileges 343 | 344 | bool create_role(1:Role role) throws(1:MetaException o1) 345 | bool drop_role(1:string role_name) throws(1:MetaException o1) 346 | list get_role_names() throws(1:MetaException o1) 347 | bool grant_role(1:string role_name, 2:string principal_name, 3:PrincipalType principal_type, 348 | 4:string grantor, 5:PrincipalType grantorType, 6:bool grant_option) throws(1:MetaException o1) 349 | bool revoke_role(1:string role_name, 2:string principal_name, 3:PrincipalType principal_type) 350 | throws(1:MetaException o1) 351 | list list_roles(1:string principal_name, 2:PrincipalType principal_type) throws(1:MetaException o1) 352 | 353 | PrincipalPrivilegeSet get_privilege_set(1:HiveObjectRef hiveObject, 2:string user_name, 354 | 3: list group_names) throws(1:MetaException o1) 355 | list list_privileges(1:string principal_name, 2:PrincipalType principal_type, 356 | 3: HiveObjectRef hiveObject) throws(1:MetaException o1) 357 | 358 | bool grant_privileges(1:PrivilegeBag privileges) throws(1:MetaException o1) 359 | bool revoke_privileges(1:PrivilegeBag privileges) throws(1:MetaException o1) 360 | 361 | //Authentication (delegation token) interfaces 362 | 363 | // get metastore server delegation token for use from the map/reduce tasks to authenticate 364 | // to metastore server 365 | string get_delegation_token(1:string renewer_kerberos_principal_name) throws (1:MetaException o1) 366 | 367 | // get metastore server delegation token for use from the map/reduce tasks to authenticate 368 | // to metastore server - this method takes an extra token signature string which is just 369 | // an identifier to associate with the token - this will be used by the token selector code 370 | // to pick the right token given the associated identifier. 371 | string get_delegation_token_with_signature(1:string renewer_kerberos_principal_name, 372 | 2:string token_signature) throws (1:MetaException o1) 373 | 374 | // method to renew delegation token obtained from metastore server 375 | i64 renew_delegation_token(1:string token_str_form) throws (1:MetaException o1) 376 | 377 | // method to cancel delegation token obtained from metastore server 378 | void cancel_delegation_token(1:string token_str_form) throws (1:MetaException o1) 379 | } 380 | 381 | // * Note about the DDL_TIME: When creating or altering a table or a partition, 382 | // if the DDL_TIME is not set, the current time will be used. 383 | 384 | // For storing info about archived partitions in parameters 385 | 386 | // Whether the partition is archived 387 | const string IS_ARCHIVED = "is_archived", 388 | // The original location of the partition, before archiving. After archiving, 389 | // this directory will contain the archive. When the partition 390 | // is dropped, this directory will be deleted 391 | const string ORIGINAL_LOCATION = "original_location", 392 | 393 | // these should be needed only for backward compatibility with filestore 394 | const string META_TABLE_COLUMNS = "columns", 395 | const string META_TABLE_COLUMN_TYPES = "columns.types", 396 | const string BUCKET_FIELD_NAME = "bucket_field_name", 397 | const string BUCKET_COUNT = "bucket_count", 398 | const string FIELD_TO_DIMENSION = "field_to_dimension", 399 | const string META_TABLE_NAME = "name", 400 | const string META_TABLE_DB = "db", 401 | const string META_TABLE_LOCATION = "location", 402 | const string META_TABLE_SERDE = "serde", 403 | const string META_TABLE_PARTITION_COLUMNS = "partition_columns", 404 | const string FILE_INPUT_FORMAT = "file.inputformat", 405 | const string FILE_OUTPUT_FORMAT = "file.outputformat", 406 | const string META_TABLE_STORAGE = "storage_handler", 407 | 408 | 409 | 410 | -------------------------------------------------------------------------------- /src/hive-thrift/hive_service.thrift: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/thrift -java 2 | 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | # 20 | # Thrift Service that the hive service is built on 21 | # 22 | 23 | # 24 | # TODO: include/thrift is shared among different components. It 25 | # should not be under metastore. 26 | 27 | include "fb303.thrift" 28 | include "hive_metastore.thrift" 29 | include "queryplan.thrift" 30 | 31 | namespace java org.apache.hadoop.hive.service 32 | namespace cpp Apache.Hadoop.Hive 33 | 34 | // Enumeration of JobTracker.State 35 | enum JobTrackerState { 36 | INITIALIZING = 1, 37 | RUNNING = 2, 38 | } 39 | 40 | // Map-Reduce cluster status information 41 | struct HiveClusterStatus { 42 | 1: i32 taskTrackers, 43 | 2: i32 mapTasks, 44 | 3: i32 reduceTasks, 45 | 4: i32 maxMapTasks, 46 | 5: i32 maxReduceTasks, 47 | 6: JobTrackerState state, 48 | } 49 | 50 | exception HiveServerException { 51 | 1: string message 52 | 2: i32 errorCode 53 | 3: string SQLState 54 | } 55 | 56 | # Interface for Thrift Hive Server 57 | service ThriftHive extends hive_metastore.ThriftHiveMetastore { 58 | # Execute a query. Takes a HiveQL string 59 | void execute(1:string query) throws(1:HiveServerException ex) 60 | 61 | # Fetch one row. This row is the serialized form 62 | # of the result of the query 63 | string fetchOne() throws(1:HiveServerException ex) 64 | 65 | # Fetch a given number of rows or remaining number of 66 | # rows whichever is smaller. 67 | list fetchN(1:i32 numRows) throws(1:HiveServerException ex) 68 | 69 | # Fetch all rows of the query result 70 | list fetchAll() throws(1:HiveServerException ex) 71 | 72 | # Get a schema object with fields represented with native Hive types 73 | hive_metastore.Schema getSchema() throws(1:HiveServerException ex) 74 | 75 | # Get a schema object with fields represented with Thrift DDL types 76 | hive_metastore.Schema getThriftSchema() throws(1:HiveServerException ex) 77 | 78 | # Get the status information about the Map-Reduce cluster 79 | HiveClusterStatus getClusterStatus() throws(1:HiveServerException ex) 80 | 81 | # Get the queryplan annotated with counter information 82 | queryplan.QueryPlan getQueryPlan() throws(1:HiveServerException ex) 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/hive-thrift/queryplan.thrift: -------------------------------------------------------------------------------- 1 | namespace java org.apache.hadoop.hive.ql.plan.api 2 | namespace cpp Apache.Hadoop.Hive 3 | 4 | enum AdjacencyType { CONJUNCTIVE, DISJUNCTIVE } 5 | struct Adjacency { 6 | 1: string node, 7 | 2: list children, 8 | 3: AdjacencyType adjacencyType, 9 | } 10 | 11 | enum NodeType { OPERATOR, STAGE } 12 | struct Graph { 13 | 1: NodeType nodeType, 14 | 2: list roots, 15 | 3: list adjacencyList, 16 | } 17 | 18 | #Represents a operator along with its counters 19 | enum OperatorType { 20 | JOIN, 21 | MAPJOIN, 22 | EXTRACT, 23 | FILTER, 24 | FORWARD, 25 | GROUPBY, 26 | LIMIT, 27 | SCRIPT, 28 | SELECT, 29 | TABLESCAN, 30 | FILESINK, 31 | REDUCESINK, 32 | UNION, 33 | UDTF, 34 | LATERALVIEWJOIN, 35 | LATERALVIEWFORWARD, 36 | HASHTABLESINK, 37 | HASHTABLEDUMMY, 38 | } 39 | 40 | struct Operator { 41 | 1: string operatorId, 42 | 2: OperatorType operatorType, 43 | 3: map operatorAttributes, 44 | 4: map operatorCounters, 45 | 5: bool done, 46 | 6: bool started, 47 | } 48 | 49 | # Represents whether it is a map-reduce job or not. In future, different tasks can add their dependencies 50 | # The operator graph shows the operator tree 51 | enum TaskType { MAP, REDUCE, OTHER } 52 | struct Task { 53 | 1: string taskId, 54 | 2: TaskType taskType 55 | 3: map taskAttributes, 56 | 4: map taskCounters, 57 | 5: optional Graph operatorGraph, 58 | 6: optional list operatorList, 59 | 7: bool done, 60 | 8: bool started, 61 | } 62 | 63 | # Represents a Stage - unfortunately, it is represented as Task in ql/exec 64 | enum StageType { 65 | CONDITIONAL, 66 | COPY, 67 | DDL, 68 | MAPRED, 69 | EXPLAIN, 70 | FETCH, 71 | FUNC, 72 | MAPREDLOCAL, 73 | MOVE, 74 | STATS, 75 | } 76 | 77 | struct Stage { 78 | 1: string stageId, 79 | 2: StageType stageType, 80 | 3: map stageAttributes, 81 | 4: map stageCounters, 82 | 5: list taskList, 83 | 6: bool done, 84 | 7: bool started, 85 | } 86 | 87 | # Represents a query - 88 | # The graph maintains the stage dependency.In case of conditional tasks, it is represented as if only 89 | # one of the dependencies need to be executed 90 | struct Query { 91 | 1: string queryId, 92 | 2: string queryType, 93 | 3: map queryAttributes, 94 | 4: map queryCounters, 95 | 5: Graph stageGraph, 96 | 6: list stageList, 97 | 7: bool done, 98 | 8: bool started, 99 | } 100 | 101 | # List of all queries - each query maintains if it is done or started 102 | # This can be used to track all the queries in the session 103 | struct QueryPlan { 104 | 1: list queries, 105 | 2: bool done, 106 | 3: bool started, 107 | } 108 | -------------------------------------------------------------------------------- /src/hive-thrift/serde.thrift: -------------------------------------------------------------------------------- 1 | 2 | namespace java org.apache.hadoop.hive.serde 3 | namespace php org.apache.hadoop.hive.serde 4 | namespace py org_apache_hadoop_hive_serde 5 | namespace cpp Hive 6 | 7 | // name of serialization scheme. 8 | const string SERIALIZATION_LIB = "serialization.lib" 9 | const string SERIALIZATION_CLASS = "serialization.class" 10 | const string SERIALIZATION_FORMAT = "serialization.format" 11 | const string SERIALIZATION_DDL = "serialization.ddl" 12 | const string SERIALIZATION_NULL_FORMAT = "serialization.null.format" 13 | const string SERIALIZATION_LAST_COLUMN_TAKES_REST = "serialization.last.column.takes.rest" 14 | const string SERIALIZATION_SORT_ORDER = "serialization.sort.order" 15 | const string SERIALIZATION_USE_JSON_OBJECTS = "serialization.use.json.object" 16 | 17 | const string FIELD_DELIM = "field.delim" 18 | const string COLLECTION_DELIM = "colelction.delim" 19 | const string LINE_DELIM = "line.delim" 20 | const string MAPKEY_DELIM = "mapkey.delim" 21 | const string QUOTE_CHAR = "quote.delim" 22 | const string ESCAPE_CHAR = "escape.delim" 23 | 24 | typedef string PrimitiveType 25 | typedef string CollectionType 26 | 27 | const string VOID_TYPE_NAME = "void"; 28 | const string BOOLEAN_TYPE_NAME = "boolean"; 29 | const string TINYINT_TYPE_NAME = "tinyint"; 30 | const string SMALLINT_TYPE_NAME = "smallint"; 31 | const string INT_TYPE_NAME = "int"; 32 | const string BIGINT_TYPE_NAME = "bigint"; 33 | const string FLOAT_TYPE_NAME = "float"; 34 | const string DOUBLE_TYPE_NAME = "double"; 35 | const string STRING_TYPE_NAME = "string"; 36 | const string DATE_TYPE_NAME = "date"; 37 | const string DATETIME_TYPE_NAME = "datetime"; 38 | const string TIMESTAMP_TYPE_NAME = "timestamp"; 39 | 40 | const string LIST_TYPE_NAME = "array"; 41 | const string MAP_TYPE_NAME = "map"; 42 | const string STRUCT_TYPE_NAME = "struct"; 43 | const string UNION_TYPE_NAME = "uniontype"; 44 | 45 | const string LIST_COLUMNS = "columns"; 46 | const string LIST_COLUMN_TYPES = "columns.types"; 47 | 48 | const set PrimitiveTypes = [ VOID_TYPE_NAME BOOLEAN_TYPE_NAME TINYINT_TYPE_NAME SMALLINT_TYPE_NAME INT_TYPE_NAME BIGINT_TYPE_NAME FLOAT_TYPE_NAME DOUBLE_TYPE_NAME STRING_TYPE_NAME DATE_TYPE_NAME DATETIME_TYPE_NAME TIMESTAMP_TYPE_NAME ], 49 | const set CollectionTypes = [ LIST_TYPE_NAME MAP_TYPE_NAME ], 50 | 51 | 52 | --------------------------------------------------------------------------------