@databricks/sql 1.5.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DBSQLClient.d.ts +17 -8
- package/dist/DBSQLClient.js +82 -82
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLOperation/FetchResultsHelper.d.ts +3 -3
- package/dist/DBSQLOperation/FetchResultsHelper.js +4 -3
- package/dist/DBSQLOperation/FetchResultsHelper.js.map +1 -1
- package/dist/DBSQLOperation/index.d.ts +10 -7
- package/dist/DBSQLOperation/index.js +110 -41
- package/dist/DBSQLOperation/index.js.map +1 -1
- package/dist/DBSQLParameter.d.ts +6 -2
- package/dist/DBSQLParameter.js +15 -1
- package/dist/DBSQLParameter.js.map +1 -1
- package/dist/DBSQLSession.d.ts +5 -6
- package/dist/DBSQLSession.js +66 -36
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/AuthorizationCode.d.ts +3 -3
- package/dist/connection/auth/DatabricksOAuth/AuthorizationCode.js +3 -4
- package/dist/connection/auth/DatabricksOAuth/AuthorizationCode.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.d.ts +6 -3
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js +27 -8
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/index.d.ts +4 -6
- package/dist/connection/auth/DatabricksOAuth/index.js +1 -1
- package/dist/connection/auth/DatabricksOAuth/index.js.map +1 -1
- package/dist/connection/auth/PlainHttpAuthentication.d.ts +6 -3
- package/dist/connection/auth/PlainHttpAuthentication.js +1 -0
- package/dist/connection/auth/PlainHttpAuthentication.js.map +1 -1
- package/dist/connection/connections/HttpConnection.d.ts +16 -9
- package/dist/connection/connections/HttpConnection.js +60 -51
- package/dist/connection/connections/HttpConnection.js.map +1 -1
- package/dist/connection/connections/ThriftHttpConnection.d.ts +38 -0
- package/dist/connection/connections/ThriftHttpConnection.js +134 -0
- package/dist/connection/connections/ThriftHttpConnection.js.map +1 -0
- package/dist/connection/contracts/IAuthentication.d.ts +2 -2
- package/dist/connection/contracts/IConnectionOptions.d.ts +17 -19
- package/dist/connection/contracts/IConnectionProvider.d.ts +6 -3
- package/dist/contracts/IClientContext.d.ts +10 -0
- package/dist/{connection/contracts/IThriftConnection.js → contracts/IClientContext.js} +1 -1
- package/dist/contracts/IClientContext.js.map +1 -0
- package/dist/contracts/IDBSQLClient.d.ts +2 -0
- package/dist/contracts/IDBSQLSession.d.ts +1 -0
- package/dist/contracts/IDriver.d.ts +24 -0
- package/dist/contracts/IDriver.js +3 -0
- package/dist/contracts/IDriver.js.map +1 -0
- package/dist/errors/ParameterError.d.ts +2 -0
- package/dist/errors/ParameterError.js +6 -0
- package/dist/errors/ParameterError.js.map +1 -0
- package/dist/hive/HiveDriver.d.ts +8 -5
- package/dist/hive/HiveDriver.js +23 -23
- package/dist/hive/HiveDriver.js.map +1 -1
- package/dist/result/ArrowResult.d.ts +3 -1
- package/dist/result/ArrowResult.js +4 -2
- package/dist/result/ArrowResult.js.map +1 -1
- package/dist/result/CloudFetchResult.d.ts +2 -1
- package/dist/result/CloudFetchResult.js +5 -3
- package/dist/result/CloudFetchResult.js.map +1 -1
- package/dist/result/JsonResult.d.ts +3 -1
- package/dist/result/JsonResult.js +2 -1
- package/dist/result/JsonResult.js.map +1 -1
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.js +1 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -4
- package/dist/DBSQLOperation/OperationStatusHelper.d.ts +0 -16
- package/dist/DBSQLOperation/OperationStatusHelper.js +0 -138
- package/dist/DBSQLOperation/OperationStatusHelper.js.map +0 -1
- package/dist/connection/contracts/IThriftConnection.d.ts +0 -4
- package/dist/connection/contracts/IThriftConnection.js.map +0 -1
- package/dist/node_modules/thrift/LICENSE +0 -306
- package/dist/node_modules/thrift/README.md +0 -210
- package/dist/node_modules/thrift/lib/nodejs/README.md +0 -142
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/binary.js +0 -168
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/binary_protocol.js +0 -367
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/browser.js +0 -49
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/buffered_transport.js +0 -186
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/compact_protocol.js +0 -915
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/connection.js +0 -396
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/create_client.js +0 -54
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/framed_transport.js +0 -185
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/header_protocol.js +0 -258
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/header_transport.js +0 -341
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/http_connection.js +0 -292
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/index.js +0 -76
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/input_buffer_underrun_error.js +0 -32
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/int64_util.js +0 -91
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/json_parse.js +0 -299
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/json_protocol.js +0 -799
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/log.js +0 -87
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/multiplexed_processor.js +0 -63
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/multiplexed_protocol.js +0 -73
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/protocol.js +0 -22
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/server.js +0 -123
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/thrift.js +0 -241
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/transport.js +0 -22
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/web_server.js +0 -567
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/ws_connection.js +0 -286
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/ws_transport.js +0 -206
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/xhr_connection.js +0 -280
- package/dist/node_modules/thrift/package.json +0 -72
- package/dist/utils/areHeadersEqual.d.ts +0 -2
- package/dist/utils/areHeadersEqual.js +0 -49
- package/dist/utils/areHeadersEqual.js.map +0 -1
|
@@ -1,292 +0,0 @@
|
|
|
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
|
-
var util = require('util');
|
|
20
|
-
var http = require('http');
|
|
21
|
-
var https = require('https');
|
|
22
|
-
var EventEmitter = require('events').EventEmitter;
|
|
23
|
-
var thrift = require('./thrift');
|
|
24
|
-
|
|
25
|
-
var TBufferedTransport = require('./buffered_transport');
|
|
26
|
-
var TBinaryProtocol = require('./binary_protocol');
|
|
27
|
-
var InputBufferUnderrunError = require('./input_buffer_underrun_error');
|
|
28
|
-
|
|
29
|
-
var createClient = require('./create_client');
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @class
|
|
33
|
-
* @name ConnectOptions
|
|
34
|
-
* @property {string} transport - The Thrift layered transport to use (TBufferedTransport, etc).
|
|
35
|
-
* @property {string} protocol - The Thrift serialization protocol to use (TBinaryProtocol, etc.).
|
|
36
|
-
* @property {string} path - The URL path to POST to (e.g. "/", "/mySvc", "/thrift/quoteSvc", etc.).
|
|
37
|
-
* @property {object} headers - A standard Node.js header hash, an object hash containing key/value
|
|
38
|
-
* pairs where the key is the header name string and the value is the header value string.
|
|
39
|
-
* @property {boolean} https - True causes the connection to use https, otherwise http is used.
|
|
40
|
-
* @property {object} nodeOptions - Options passed on to node.
|
|
41
|
-
* @example
|
|
42
|
-
* //Use a connection that requires ssl/tls, closes the connection after each request,
|
|
43
|
-
* // uses the buffered transport layer, uses the JSON protocol and directs RPC traffic
|
|
44
|
-
* // to https://thrift.example.com:9090/hello
|
|
45
|
-
* var thrift = require('thrift');
|
|
46
|
-
* var options = {
|
|
47
|
-
* transport: thrift.TBufferedTransport,
|
|
48
|
-
* protocol: thrift.TJSONProtocol,
|
|
49
|
-
* path: "/hello",
|
|
50
|
-
* headers: {"Connection": "close"},
|
|
51
|
-
* https: true
|
|
52
|
-
* };
|
|
53
|
-
* var con = thrift.createHttpConnection("thrift.example.com", 9090, options);
|
|
54
|
-
* var client = thrift.createHttpClient(myService, connection);
|
|
55
|
-
* client.myServiceFunction();
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Initializes a Thrift HttpConnection instance (use createHttpConnection() rather than
|
|
60
|
-
* instantiating directly).
|
|
61
|
-
* @constructor
|
|
62
|
-
* @param {ConnectOptions} options - The configuration options to use.
|
|
63
|
-
* @throws {error} Exceptions other than InputBufferUnderrunError are rethrown
|
|
64
|
-
* @event {error} The "error" event is fired when a Node.js error event occurs during
|
|
65
|
-
* request or response processing, in which case the node error is passed on. An "error"
|
|
66
|
-
* event may also be fired when the connection can not map a response back to the
|
|
67
|
-
* appropriate client (an internal error), generating a TApplicationException.
|
|
68
|
-
* @classdesc HttpConnection objects provide Thrift end point transport
|
|
69
|
-
* semantics implemented over the Node.js http.request() method.
|
|
70
|
-
* @see {@link createHttpConnection}
|
|
71
|
-
*/
|
|
72
|
-
var HttpConnection = exports.HttpConnection = function(options) {
|
|
73
|
-
//Initialize the emitter base object
|
|
74
|
-
EventEmitter.call(this);
|
|
75
|
-
|
|
76
|
-
//Set configuration
|
|
77
|
-
var self = this;
|
|
78
|
-
this.options = options || {};
|
|
79
|
-
this.host = this.options.host;
|
|
80
|
-
this.port = this.options.port;
|
|
81
|
-
this.socketPath = this.options.socketPath;
|
|
82
|
-
this.https = this.options.https || false;
|
|
83
|
-
this.transport = this.options.transport || TBufferedTransport;
|
|
84
|
-
this.protocol = this.options.protocol || TBinaryProtocol;
|
|
85
|
-
|
|
86
|
-
//Prepare Node.js options
|
|
87
|
-
this.nodeOptions = {
|
|
88
|
-
host: this.host,
|
|
89
|
-
port: this.port,
|
|
90
|
-
socketPath: this.socketPath,
|
|
91
|
-
path: this.options.path || '/',
|
|
92
|
-
method: 'POST',
|
|
93
|
-
headers: this.options.headers || {},
|
|
94
|
-
responseType: this.options.responseType || null
|
|
95
|
-
};
|
|
96
|
-
for (var attrname in this.options.nodeOptions) {
|
|
97
|
-
this.nodeOptions[attrname] = this.options.nodeOptions[attrname];
|
|
98
|
-
}
|
|
99
|
-
/*jshint -W069 */
|
|
100
|
-
if (! this.nodeOptions.headers['Connection']) {
|
|
101
|
-
this.nodeOptions.headers['Connection'] = 'keep-alive';
|
|
102
|
-
}
|
|
103
|
-
/*jshint +W069 */
|
|
104
|
-
|
|
105
|
-
//The sequence map is used to map seqIDs back to the
|
|
106
|
-
// calling client in multiplexed scenarios
|
|
107
|
-
this.seqId2Service = {};
|
|
108
|
-
|
|
109
|
-
function decodeCallback(transport_with_data, handleError) {
|
|
110
|
-
var proto = new self.protocol(transport_with_data);
|
|
111
|
-
try {
|
|
112
|
-
while (true) {
|
|
113
|
-
var header = proto.readMessageBegin();
|
|
114
|
-
var dummy_seqid = header.rseqid * -1;
|
|
115
|
-
var client = self.client;
|
|
116
|
-
//The Multiplexed Protocol stores a hash of seqid to service names
|
|
117
|
-
// in seqId2Service. If the SeqId is found in the hash we need to
|
|
118
|
-
// lookup the appropriate client for this call.
|
|
119
|
-
// The client var is a single client object when not multiplexing,
|
|
120
|
-
// when using multiplexing it is a service name keyed hash of client
|
|
121
|
-
// objects.
|
|
122
|
-
//NOTE: The 2 way interdependencies between protocols, transports,
|
|
123
|
-
// connections and clients in the Node.js implementation are irregular
|
|
124
|
-
// and make the implementation difficult to extend and maintain. We
|
|
125
|
-
// should bring this stuff inline with typical thrift I/O stack
|
|
126
|
-
// operation soon.
|
|
127
|
-
// --ra
|
|
128
|
-
var service_name = self.seqId2Service[header.rseqid];
|
|
129
|
-
if (service_name) {
|
|
130
|
-
client = self.client[service_name];
|
|
131
|
-
delete self.seqId2Service[header.rseqid];
|
|
132
|
-
}
|
|
133
|
-
/*jshint -W083 */
|
|
134
|
-
client._reqs[dummy_seqid] = function(err, success){
|
|
135
|
-
transport_with_data.commitPosition();
|
|
136
|
-
var clientCallback = client._reqs[header.rseqid];
|
|
137
|
-
delete client._reqs[header.rseqid];
|
|
138
|
-
if (clientCallback) {
|
|
139
|
-
process.nextTick(function() {
|
|
140
|
-
clientCallback(err, success);
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
/*jshint +W083 */
|
|
145
|
-
if(client['recv_' + header.fname]) {
|
|
146
|
-
client['recv_' + header.fname](proto, header.mtype, dummy_seqid);
|
|
147
|
-
} else {
|
|
148
|
-
delete client._reqs[dummy_seqid];
|
|
149
|
-
handleError(
|
|
150
|
-
new thrift.TApplicationException(
|
|
151
|
-
thrift.TApplicationExceptionType.WRONG_METHOD_NAME,
|
|
152
|
-
"Received a response to an unknown RPC function")
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
catch (e) {
|
|
158
|
-
if (e instanceof InputBufferUnderrunError) {
|
|
159
|
-
transport_with_data.rollbackPosition();
|
|
160
|
-
} else {
|
|
161
|
-
handleError(e);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
//Response handler
|
|
168
|
-
//////////////////////////////////////////////////
|
|
169
|
-
this.responseCallback = function(response, handleError) {
|
|
170
|
-
var data = [];
|
|
171
|
-
var dataLen = 0;
|
|
172
|
-
|
|
173
|
-
if (response.statusCode !== 200) {
|
|
174
|
-
handleError(new THTTPException(response));
|
|
175
|
-
response.destroy();
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
response.on('error', handleError);
|
|
180
|
-
|
|
181
|
-
// When running directly under node, chunk will be a buffer,
|
|
182
|
-
// however, when running in a Browser (e.g. Browserify), chunk
|
|
183
|
-
// will be a string or an ArrayBuffer.
|
|
184
|
-
response.on('data', function (chunk) {
|
|
185
|
-
if ((typeof chunk == 'string') ||
|
|
186
|
-
(Object.prototype.toString.call(chunk) == '[object Uint8Array]')) {
|
|
187
|
-
// Wrap ArrayBuffer/string in a Buffer so data[i].copy will work
|
|
188
|
-
data.push(new Buffer(chunk));
|
|
189
|
-
} else {
|
|
190
|
-
data.push(chunk);
|
|
191
|
-
}
|
|
192
|
-
dataLen += chunk.length;
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
response.on('end', function(){
|
|
196
|
-
var buf = new Buffer(dataLen);
|
|
197
|
-
for (var i=0, len=data.length, pos=0; i<len; i++) {
|
|
198
|
-
data[i].copy(buf, pos);
|
|
199
|
-
pos += data[i].length;
|
|
200
|
-
}
|
|
201
|
-
//Get the receiver function for the transport and
|
|
202
|
-
// call it with the buffer
|
|
203
|
-
self.transport.receiver(function(transport_with_data) {
|
|
204
|
-
return decodeCallback(transport_with_data, handleError);
|
|
205
|
-
})(buf);
|
|
206
|
-
});
|
|
207
|
-
};
|
|
208
|
-
};
|
|
209
|
-
util.inherits(HttpConnection, EventEmitter);
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Writes Thrift message data to the connection
|
|
213
|
-
* @param {Buffer} data - A Node.js Buffer containing the data to write
|
|
214
|
-
* @returns {void} No return value.
|
|
215
|
-
* @event {error} the "error" event is raised upon request failure passing the
|
|
216
|
-
* Node.js error object to the listener.
|
|
217
|
-
*/
|
|
218
|
-
HttpConnection.prototype.write = function(data, seqid) {
|
|
219
|
-
var self = this;
|
|
220
|
-
var opts = self.nodeOptions;
|
|
221
|
-
opts.headers["Content-length"] = data.length;
|
|
222
|
-
if (!opts.headers["Content-Type"])
|
|
223
|
-
opts.headers["Content-Type"] = "application/x-thrift";
|
|
224
|
-
|
|
225
|
-
// The purpose of this handler is to pass an error to corresponding operation's callback if
|
|
226
|
-
// error is associated with any. If error cannot be associated with any operation, it will be
|
|
227
|
-
// emitted as 'error' event
|
|
228
|
-
function handleError(err) {
|
|
229
|
-
var client = self.client;
|
|
230
|
-
var callback = client._reqs[seqid] || function() {
|
|
231
|
-
self.emit("error", err);
|
|
232
|
-
};
|
|
233
|
-
delete client._reqs[seqid];
|
|
234
|
-
callback(err);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function responseCallback(response) {
|
|
238
|
-
return self.responseCallback(response, handleError);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
var req = (self.https) ?
|
|
242
|
-
https.request(opts, responseCallback) :
|
|
243
|
-
http.request(opts, responseCallback);
|
|
244
|
-
req.on('timeout', () => {
|
|
245
|
-
// Ignore all subsequent errors on this request
|
|
246
|
-
req.off('error', handleError);
|
|
247
|
-
req.on('error', () => {});
|
|
248
|
-
// Emit a single error and destroy request
|
|
249
|
-
handleError(new thrift.TApplicationException(thrift.TApplicationExceptionType.PROTOCOL_ERROR, 'Request timed out'));
|
|
250
|
-
req.destroy();
|
|
251
|
-
});
|
|
252
|
-
req.on('error', handleError);
|
|
253
|
-
req.write(data);
|
|
254
|
-
req.end();
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Creates a new HttpConnection object, used by Thrift clients to connect
|
|
259
|
-
* to Thrift HTTP based servers.
|
|
260
|
-
* @param {string} host - The host name or IP to connect to.
|
|
261
|
-
* @param {number} port - The TCP port to connect to.
|
|
262
|
-
* @param {ConnectOptions} options - The configuration options to use.
|
|
263
|
-
* @returns {HttpConnection} The connection object.
|
|
264
|
-
* @see {@link ConnectOptions}
|
|
265
|
-
*/
|
|
266
|
-
exports.createHttpConnection = function(host, port, options) {
|
|
267
|
-
options.host = host;
|
|
268
|
-
options.port = port || 80;
|
|
269
|
-
return new HttpConnection(options);
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
exports.createHttpUDSConnection = function(path, options) {
|
|
273
|
-
options.socketPath = path;
|
|
274
|
-
return new HttpConnection(options);
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
exports.createHttpClient = createClient
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
function THTTPException(response) {
|
|
281
|
-
thrift.TApplicationException.call(this);
|
|
282
|
-
if (Error.captureStackTrace !== undefined) {
|
|
283
|
-
Error.captureStackTrace(this, this.constructor);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
this.name = this.constructor.name;
|
|
287
|
-
this.statusCode = response.statusCode;
|
|
288
|
-
this.response = response;
|
|
289
|
-
this.type = thrift.TApplicationExceptionType.PROTOCOL_ERROR;
|
|
290
|
-
this.message = "Received a response with a bad HTTP status code: " + response.statusCode;
|
|
291
|
-
}
|
|
292
|
-
util.inherits(THTTPException, thrift.TApplicationException);
|
|
@@ -1,76 +0,0 @@
|
|
|
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
|
-
exports.Thrift = require('./thrift');
|
|
20
|
-
|
|
21
|
-
var log = require('./log');
|
|
22
|
-
exports.setLogFunc = log.setLogFunc;
|
|
23
|
-
exports.setLogLevel = log.setLogLevel;
|
|
24
|
-
exports.getLogLevel = log.getLogLevel;
|
|
25
|
-
|
|
26
|
-
var connection = require('./connection');
|
|
27
|
-
exports.Connection = connection.Connection;
|
|
28
|
-
exports.createClient = connection.createClient;
|
|
29
|
-
exports.createConnection = connection.createConnection;
|
|
30
|
-
exports.createUDSConnection = connection.createUDSConnection;
|
|
31
|
-
exports.createSSLConnection = connection.createSSLConnection;
|
|
32
|
-
exports.createStdIOClient = connection.createStdIOClient;
|
|
33
|
-
exports.createStdIOConnection = connection.createStdIOConnection;
|
|
34
|
-
|
|
35
|
-
var httpConnection = require('./http_connection');
|
|
36
|
-
exports.HttpConnection = httpConnection.HttpConnection;
|
|
37
|
-
exports.createHttpConnection = httpConnection.createHttpConnection;
|
|
38
|
-
exports.createHttpUDSConnection = httpConnection.createHttpUDSConnection;
|
|
39
|
-
exports.createHttpClient = httpConnection.createHttpClient;
|
|
40
|
-
|
|
41
|
-
var wsConnection = require('./ws_connection');
|
|
42
|
-
exports.WSConnection = wsConnection.WSConnection;
|
|
43
|
-
exports.createWSConnection = wsConnection.createWSConnection;
|
|
44
|
-
exports.createWSClient = wsConnection.createWSClient;
|
|
45
|
-
|
|
46
|
-
var xhrConnection = require('./xhr_connection');
|
|
47
|
-
exports.XHRConnection = xhrConnection.XHRConnection;
|
|
48
|
-
exports.createXHRConnection = xhrConnection.createXHRConnection;
|
|
49
|
-
exports.createXHRClient = xhrConnection.createXHRClient;
|
|
50
|
-
|
|
51
|
-
var server = require('./server');
|
|
52
|
-
exports.createServer = server.createServer;
|
|
53
|
-
exports.createMultiplexServer = server.createMultiplexServer;
|
|
54
|
-
|
|
55
|
-
var web_server = require('./web_server');
|
|
56
|
-
exports.createWebServer = web_server.createWebServer;
|
|
57
|
-
|
|
58
|
-
exports.Int64 = require('node-int64');
|
|
59
|
-
exports.Q = require('q');
|
|
60
|
-
|
|
61
|
-
var mpxProcessor = require('./multiplexed_processor');
|
|
62
|
-
var mpxProtocol = require('./multiplexed_protocol');
|
|
63
|
-
exports.MultiplexedProcessor = mpxProcessor.MultiplexedProcessor;
|
|
64
|
-
exports.Multiplexer = mpxProtocol.Multiplexer;
|
|
65
|
-
|
|
66
|
-
/*
|
|
67
|
-
* Export transport and protocol so they can be used outside of a
|
|
68
|
-
* cassandra/server context
|
|
69
|
-
*/
|
|
70
|
-
exports.TBufferedTransport = require('./buffered_transport');
|
|
71
|
-
exports.TFramedTransport = require('./framed_transport');
|
|
72
|
-
|
|
73
|
-
exports.TJSONProtocol = require('./json_protocol');
|
|
74
|
-
exports.TBinaryProtocol = require('./binary_protocol');
|
|
75
|
-
exports.TCompactProtocol = require('./compact_protocol');
|
|
76
|
-
exports.THeaderProtocol = require('./header_protocol');
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
var util = require("util");
|
|
20
|
-
|
|
21
|
-
module.exports = InputBufferUnderrunError;
|
|
22
|
-
|
|
23
|
-
function InputBufferUnderrunError(message) {
|
|
24
|
-
Error.call(this);
|
|
25
|
-
if (Error.captureStackTrace !== undefined) {
|
|
26
|
-
Error.captureStackTrace(this, this.constructor);
|
|
27
|
-
}
|
|
28
|
-
this.name = this.constructor.name;
|
|
29
|
-
this.message = message;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
util.inherits(InputBufferUnderrunError, Error);
|
|
@@ -1,91 +0,0 @@
|
|
|
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
|
-
var Int64 = require('node-int64');
|
|
21
|
-
|
|
22
|
-
var Int64Util = module.exports = {};
|
|
23
|
-
|
|
24
|
-
var POW2_24 = Math.pow(2, 24);
|
|
25
|
-
var POW2_31 = Math.pow(2, 31);
|
|
26
|
-
var POW2_32 = Math.pow(2, 32);
|
|
27
|
-
var POW10_11 = Math.pow(10, 11);
|
|
28
|
-
|
|
29
|
-
Int64Util.toDecimalString = function(i64) {
|
|
30
|
-
var b = i64.buffer;
|
|
31
|
-
var o = i64.offset;
|
|
32
|
-
if ((!b[o] && !(b[o + 1] & 0xe0)) ||
|
|
33
|
-
(!~b[o] && !~(b[o + 1] & 0xe0))) {
|
|
34
|
-
// The magnitude is small enough.
|
|
35
|
-
return i64.toString();
|
|
36
|
-
} else {
|
|
37
|
-
var negative = b[o] & 0x80;
|
|
38
|
-
if (negative) {
|
|
39
|
-
// 2's complement
|
|
40
|
-
var incremented = false;
|
|
41
|
-
var buffer = new Buffer(8);
|
|
42
|
-
for (var i = 7; i >= 0; --i) {
|
|
43
|
-
buffer[i] = (~b[o + i] + (incremented ? 0 : 1)) & 0xff;
|
|
44
|
-
incremented |= b[o + i];
|
|
45
|
-
}
|
|
46
|
-
b = buffer;
|
|
47
|
-
}
|
|
48
|
-
var high2 = b[o + 1] + (b[o] << 8);
|
|
49
|
-
// Lesser 11 digits with exceeding values but is under 53 bits capacity.
|
|
50
|
-
var low = b[o + 7] + (b[o + 6] << 8) + (b[o + 5] << 16)
|
|
51
|
-
+ b[o + 4] * POW2_24 // Bit shift renders 32th bit as sign, so use multiplication
|
|
52
|
-
+ (b[o + 3] + (b[o + 2] << 8)) * POW2_32 + high2 * 74976710656; // The literal is 2^48 % 10^11
|
|
53
|
-
// 12th digit and greater.
|
|
54
|
-
var high = Math.floor(low / POW10_11) + high2 * 2814; // The literal is 2^48 / 10^11
|
|
55
|
-
// Make it exactly 11 with leading zeros.
|
|
56
|
-
low = ('00000000000' + String(low % POW10_11)).slice(-11);
|
|
57
|
-
return (negative ? '-' : '') + String(high) + low;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
Int64Util.fromDecimalString = function(text) {
|
|
62
|
-
var negative = text.charAt(0) === '-';
|
|
63
|
-
if (text.length < (negative ? 17 : 16)) {
|
|
64
|
-
// The magnitude is smaller than 2^53.
|
|
65
|
-
return new Int64(+text);
|
|
66
|
-
} else if (text.length > (negative ? 20 : 19)) {
|
|
67
|
-
throw new RangeError('Too many digits for Int64: ' + text);
|
|
68
|
-
} else {
|
|
69
|
-
// Most significant (up to 5) digits
|
|
70
|
-
var high5 = +text.slice(negative ? 1 : 0, -15);
|
|
71
|
-
var low = +text.slice(-15) + high5 * 2764472320; // The literal is 10^15 % 2^32
|
|
72
|
-
var high = Math.floor(low / POW2_32) + high5 * 232830; // The literal is 10^15 / 2^&32
|
|
73
|
-
low = low % POW2_32;
|
|
74
|
-
if (high >= POW2_31 &&
|
|
75
|
-
!(negative && high == POW2_31 && low == 0) // Allow minimum Int64
|
|
76
|
-
) {
|
|
77
|
-
throw new RangeError('The magnitude is too large for Int64.');
|
|
78
|
-
}
|
|
79
|
-
if (negative) {
|
|
80
|
-
// 2's complement
|
|
81
|
-
high = ~high;
|
|
82
|
-
if (low === 0) {
|
|
83
|
-
high = (high + 1) & 0xffffffff;
|
|
84
|
-
} else {
|
|
85
|
-
low = ~low + 1;
|
|
86
|
-
}
|
|
87
|
-
high = 0x80000000 | high;
|
|
88
|
-
}
|
|
89
|
-
return new Int64(high, low);
|
|
90
|
-
}
|
|
91
|
-
};
|