@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,168 +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 POW_8 = Math.pow(2, 8);
|
|
21
|
-
var POW_16 = Math.pow(2, 16);
|
|
22
|
-
var POW_24 = Math.pow(2, 24);
|
|
23
|
-
var POW_32 = Math.pow(2, 32);
|
|
24
|
-
var POW_40 = Math.pow(2, 40);
|
|
25
|
-
var POW_48 = Math.pow(2, 48);
|
|
26
|
-
var POW_52 = Math.pow(2, 52);
|
|
27
|
-
var POW_1022 = Math.pow(2, 1022);
|
|
28
|
-
|
|
29
|
-
exports.readByte = function(b){
|
|
30
|
-
return b > 127 ? b-256 : b;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
exports.readI16 = function(buff, off) {
|
|
34
|
-
off = off || 0;
|
|
35
|
-
var v = buff[off + 1];
|
|
36
|
-
v += buff[off] << 8;
|
|
37
|
-
if (buff[off] & 128) {
|
|
38
|
-
v -= POW_16;
|
|
39
|
-
}
|
|
40
|
-
return v;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
exports.readI32 = function(buff, off) {
|
|
44
|
-
off = off || 0;
|
|
45
|
-
var v = buff[off + 3];
|
|
46
|
-
v += buff[off + 2] << 8;
|
|
47
|
-
v += buff[off + 1] << 16;
|
|
48
|
-
v += buff[off] * POW_24;
|
|
49
|
-
if (buff[off] & 0x80) {
|
|
50
|
-
v -= POW_32;
|
|
51
|
-
}
|
|
52
|
-
return v;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
exports.writeI16 = function(buff, v) {
|
|
56
|
-
buff[1] = v & 0xff;
|
|
57
|
-
v >>= 8;
|
|
58
|
-
buff[0] = v & 0xff;
|
|
59
|
-
return buff;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
exports.writeI32 = function(buff, v) {
|
|
63
|
-
buff[3] = v & 0xff;
|
|
64
|
-
v >>= 8;
|
|
65
|
-
buff[2] = v & 0xff;
|
|
66
|
-
v >>= 8;
|
|
67
|
-
buff[1] = v & 0xff;
|
|
68
|
-
v >>= 8;
|
|
69
|
-
buff[0] = v & 0xff;
|
|
70
|
-
return buff;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
exports.readDouble = function(buff, off) {
|
|
74
|
-
off = off || 0;
|
|
75
|
-
var signed = buff[off] & 0x80;
|
|
76
|
-
var e = (buff[off+1] & 0xF0) >> 4;
|
|
77
|
-
e += (buff[off] & 0x7F) << 4;
|
|
78
|
-
|
|
79
|
-
var m = buff[off+7];
|
|
80
|
-
m += buff[off+6] << 8;
|
|
81
|
-
m += buff[off+5] << 16;
|
|
82
|
-
m += buff[off+4] * POW_24;
|
|
83
|
-
m += buff[off+3] * POW_32;
|
|
84
|
-
m += buff[off+2] * POW_40;
|
|
85
|
-
m += (buff[off+1] & 0x0F) * POW_48;
|
|
86
|
-
|
|
87
|
-
switch (e) {
|
|
88
|
-
case 0:
|
|
89
|
-
e = -1022;
|
|
90
|
-
break;
|
|
91
|
-
case 2047:
|
|
92
|
-
return m ? NaN : (signed ? -Infinity : Infinity);
|
|
93
|
-
default:
|
|
94
|
-
m += POW_52;
|
|
95
|
-
e -= 1023;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (signed) {
|
|
99
|
-
m *= -1;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return m * Math.pow(2, e - 52);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
/*
|
|
106
|
-
* Based on code from the jspack module:
|
|
107
|
-
* http://code.google.com/p/jspack/
|
|
108
|
-
*/
|
|
109
|
-
exports.writeDouble = function(buff, v) {
|
|
110
|
-
var m, e, c;
|
|
111
|
-
|
|
112
|
-
buff[0] = (v < 0 ? 0x80 : 0x00);
|
|
113
|
-
|
|
114
|
-
v = Math.abs(v);
|
|
115
|
-
if (v !== v) {
|
|
116
|
-
// NaN, use QNaN IEEE format
|
|
117
|
-
m = 2251799813685248;
|
|
118
|
-
e = 2047;
|
|
119
|
-
} else if (v === Infinity) {
|
|
120
|
-
m = 0;
|
|
121
|
-
e = 2047;
|
|
122
|
-
} else {
|
|
123
|
-
e = Math.floor(Math.log(v) / Math.LN2);
|
|
124
|
-
c = Math.pow(2, -e);
|
|
125
|
-
if (v * c < 1) {
|
|
126
|
-
e--;
|
|
127
|
-
c *= 2;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (e + 1023 >= 2047)
|
|
131
|
-
{
|
|
132
|
-
// Overflow
|
|
133
|
-
m = 0;
|
|
134
|
-
e = 2047;
|
|
135
|
-
}
|
|
136
|
-
else if (e + 1023 >= 1)
|
|
137
|
-
{
|
|
138
|
-
// Normalized - term order matters, as Math.pow(2, 52-e) and v*Math.pow(2, 52) can overflow
|
|
139
|
-
m = (v*c-1) * POW_52;
|
|
140
|
-
e += 1023;
|
|
141
|
-
}
|
|
142
|
-
else
|
|
143
|
-
{
|
|
144
|
-
// Denormalized - also catches the '0' case, somewhat by chance
|
|
145
|
-
m = (v * POW_1022) * POW_52;
|
|
146
|
-
e = 0;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
buff[1] = (e << 4) & 0xf0;
|
|
151
|
-
buff[0] |= (e >> 4) & 0x7f;
|
|
152
|
-
|
|
153
|
-
buff[7] = m & 0xff;
|
|
154
|
-
m = Math.floor(m / POW_8);
|
|
155
|
-
buff[6] = m & 0xff;
|
|
156
|
-
m = Math.floor(m / POW_8);
|
|
157
|
-
buff[5] = m & 0xff;
|
|
158
|
-
m = Math.floor(m / POW_8);
|
|
159
|
-
buff[4] = m & 0xff;
|
|
160
|
-
m >>= 8;
|
|
161
|
-
buff[3] = m & 0xff;
|
|
162
|
-
m >>= 8;
|
|
163
|
-
buff[2] = m & 0xff;
|
|
164
|
-
m >>= 8;
|
|
165
|
-
buff[1] |= m & 0x0f;
|
|
166
|
-
|
|
167
|
-
return buff;
|
|
168
|
-
};
|
|
@@ -1,367 +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 log = require('./log');
|
|
21
|
-
var binary = require('./binary');
|
|
22
|
-
var Int64 = require('node-int64');
|
|
23
|
-
var Thrift = require('./thrift');
|
|
24
|
-
var Type = Thrift.Type;
|
|
25
|
-
|
|
26
|
-
module.exports = TBinaryProtocol;
|
|
27
|
-
|
|
28
|
-
// JavaScript supports only numeric doubles, therefore even hex values are always signed.
|
|
29
|
-
// The largest integer value which can be represented in JavaScript is +/-2^53.
|
|
30
|
-
// Bitwise operations convert numbers to 32 bit integers but perform sign extension
|
|
31
|
-
// upon assigning values back to variables.
|
|
32
|
-
var VERSION_MASK = -65536, // 0xffff0000
|
|
33
|
-
VERSION_1 = -2147418112, // 0x80010000
|
|
34
|
-
TYPE_MASK = 0x000000ff;
|
|
35
|
-
|
|
36
|
-
TBinaryProtocol.VERSION_MASK = VERSION_MASK;
|
|
37
|
-
TBinaryProtocol.VERSION_1 = VERSION_1;
|
|
38
|
-
TBinaryProtocol.TYPE_MASK = TYPE_MASK
|
|
39
|
-
|
|
40
|
-
function TBinaryProtocol(trans, strictRead, strictWrite) {
|
|
41
|
-
this.trans = trans;
|
|
42
|
-
this.strictRead = (strictRead !== undefined ? strictRead : false);
|
|
43
|
-
this.strictWrite = (strictWrite !== undefined ? strictWrite : true);
|
|
44
|
-
this._seqid = null;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
TBinaryProtocol.prototype.flush = function() {
|
|
48
|
-
return this.trans.flush();
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
TBinaryProtocol.prototype.writeMessageBegin = function(name, type, seqid) {
|
|
52
|
-
if (this.strictWrite) {
|
|
53
|
-
this.writeI32(VERSION_1 | type);
|
|
54
|
-
this.writeString(name);
|
|
55
|
-
this.writeI32(seqid);
|
|
56
|
-
} else {
|
|
57
|
-
this.writeString(name);
|
|
58
|
-
this.writeByte(type);
|
|
59
|
-
this.writeI32(seqid);
|
|
60
|
-
}
|
|
61
|
-
// Record client seqid to find callback again
|
|
62
|
-
if (this._seqid !== null) {
|
|
63
|
-
log.warning('SeqId already set', { 'name': name });
|
|
64
|
-
} else {
|
|
65
|
-
this._seqid = seqid;
|
|
66
|
-
this.trans.setCurrSeqId(seqid);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
TBinaryProtocol.prototype.writeMessageEnd = function() {
|
|
71
|
-
if (this._seqid !== null) {
|
|
72
|
-
this._seqid = null;
|
|
73
|
-
} else {
|
|
74
|
-
log.warning('No seqid to unset');
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
TBinaryProtocol.prototype.writeStructBegin = function(name) {
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
TBinaryProtocol.prototype.writeStructEnd = function() {
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
TBinaryProtocol.prototype.writeFieldBegin = function(name, type, id) {
|
|
85
|
-
this.writeByte(type);
|
|
86
|
-
this.writeI16(id);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
TBinaryProtocol.prototype.writeFieldEnd = function() {
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
TBinaryProtocol.prototype.writeFieldStop = function() {
|
|
93
|
-
this.writeByte(Type.STOP);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
TBinaryProtocol.prototype.writeMapBegin = function(ktype, vtype, size) {
|
|
97
|
-
this.writeByte(ktype);
|
|
98
|
-
this.writeByte(vtype);
|
|
99
|
-
this.writeI32(size);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
TBinaryProtocol.prototype.writeMapEnd = function() {
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
TBinaryProtocol.prototype.writeListBegin = function(etype, size) {
|
|
106
|
-
this.writeByte(etype);
|
|
107
|
-
this.writeI32(size);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
TBinaryProtocol.prototype.writeListEnd = function() {
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
TBinaryProtocol.prototype.writeSetBegin = function(etype, size) {
|
|
114
|
-
this.writeByte(etype);
|
|
115
|
-
this.writeI32(size);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
TBinaryProtocol.prototype.writeSetEnd = function() {
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
TBinaryProtocol.prototype.writeBool = function(bool) {
|
|
122
|
-
if (bool) {
|
|
123
|
-
this.writeByte(1);
|
|
124
|
-
} else {
|
|
125
|
-
this.writeByte(0);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
TBinaryProtocol.prototype.writeByte = function(b) {
|
|
130
|
-
this.trans.write(new Buffer([b]));
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
TBinaryProtocol.prototype.writeI16 = function(i16) {
|
|
134
|
-
this.trans.write(binary.writeI16(new Buffer(2), i16));
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
TBinaryProtocol.prototype.writeI32 = function(i32) {
|
|
138
|
-
this.trans.write(binary.writeI32(new Buffer(4), i32));
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
TBinaryProtocol.prototype.writeI64 = function(i64) {
|
|
142
|
-
if (i64.buffer) {
|
|
143
|
-
this.trans.write(i64.buffer);
|
|
144
|
-
} else {
|
|
145
|
-
this.trans.write(new Int64(i64).buffer);
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
TBinaryProtocol.prototype.writeDouble = function(dub) {
|
|
150
|
-
this.trans.write(binary.writeDouble(new Buffer(8), dub));
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
TBinaryProtocol.prototype.writeStringOrBinary = function(name, encoding, arg) {
|
|
154
|
-
if (typeof(arg) === 'string') {
|
|
155
|
-
this.writeI32(Buffer.byteLength(arg, encoding));
|
|
156
|
-
this.trans.write(new Buffer(arg, encoding));
|
|
157
|
-
} else if ((arg instanceof Buffer) ||
|
|
158
|
-
(Object.prototype.toString.call(arg) == '[object Uint8Array]')) {
|
|
159
|
-
// Buffers in Node.js under Browserify may extend UInt8Array instead of
|
|
160
|
-
// defining a new object. We detect them here so we can write them
|
|
161
|
-
// correctly
|
|
162
|
-
this.writeI32(arg.length);
|
|
163
|
-
this.trans.write(arg);
|
|
164
|
-
} else {
|
|
165
|
-
throw new Error(name + ' called without a string/Buffer argument: ' + arg);
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
TBinaryProtocol.prototype.writeString = function(arg) {
|
|
170
|
-
this.writeStringOrBinary('writeString', 'utf8', arg);
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
TBinaryProtocol.prototype.writeBinary = function(arg) {
|
|
174
|
-
this.writeStringOrBinary('writeBinary', 'binary', arg);
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
TBinaryProtocol.prototype.readMessageBegin = function() {
|
|
178
|
-
var sz = this.readI32();
|
|
179
|
-
var type, name, seqid;
|
|
180
|
-
|
|
181
|
-
if (sz < 0) {
|
|
182
|
-
var version = sz & VERSION_MASK;
|
|
183
|
-
if (version != VERSION_1) {
|
|
184
|
-
throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.BAD_VERSION, "Bad version in readMessageBegin: " + sz);
|
|
185
|
-
}
|
|
186
|
-
type = sz & TYPE_MASK;
|
|
187
|
-
name = this.readString();
|
|
188
|
-
seqid = this.readI32();
|
|
189
|
-
} else {
|
|
190
|
-
if (this.strictRead) {
|
|
191
|
-
throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.BAD_VERSION, "No protocol version header");
|
|
192
|
-
}
|
|
193
|
-
name = this.trans.read(sz);
|
|
194
|
-
type = this.readByte();
|
|
195
|
-
seqid = this.readI32();
|
|
196
|
-
}
|
|
197
|
-
return {fname: name, mtype: type, rseqid: seqid};
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
TBinaryProtocol.prototype.readMessageEnd = function() {
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
TBinaryProtocol.prototype.readStructBegin = function() {
|
|
204
|
-
return {fname: ''};
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
TBinaryProtocol.prototype.readStructEnd = function() {
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
TBinaryProtocol.prototype.readFieldBegin = function() {
|
|
211
|
-
var type = this.readByte();
|
|
212
|
-
if (type == Type.STOP) {
|
|
213
|
-
return {fname: null, ftype: type, fid: 0};
|
|
214
|
-
}
|
|
215
|
-
var id = this.readI16();
|
|
216
|
-
return {fname: null, ftype: type, fid: id};
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
TBinaryProtocol.prototype.readFieldEnd = function() {
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
TBinaryProtocol.prototype.readMapBegin = function() {
|
|
223
|
-
var ktype = this.readByte();
|
|
224
|
-
var vtype = this.readByte();
|
|
225
|
-
var size = this.readI32();
|
|
226
|
-
return {ktype: ktype, vtype: vtype, size: size};
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
TBinaryProtocol.prototype.readMapEnd = function() {
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
TBinaryProtocol.prototype.readListBegin = function() {
|
|
233
|
-
var etype = this.readByte();
|
|
234
|
-
var size = this.readI32();
|
|
235
|
-
return {etype: etype, size: size};
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
TBinaryProtocol.prototype.readListEnd = function() {
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
TBinaryProtocol.prototype.readSetBegin = function() {
|
|
242
|
-
var etype = this.readByte();
|
|
243
|
-
var size = this.readI32();
|
|
244
|
-
return {etype: etype, size: size};
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
TBinaryProtocol.prototype.readSetEnd = function() {
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
TBinaryProtocol.prototype.readBool = function() {
|
|
251
|
-
var b = this.readByte();
|
|
252
|
-
if (b === 0) {
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
return true;
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
TBinaryProtocol.prototype.readByte = function() {
|
|
259
|
-
return this.trans.readByte();
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
TBinaryProtocol.prototype.readI16 = function() {
|
|
263
|
-
return this.trans.readI16();
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
TBinaryProtocol.prototype.readI32 = function() {
|
|
267
|
-
return this.trans.readI32();
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
TBinaryProtocol.prototype.readI64 = function() {
|
|
271
|
-
var buff = this.trans.read(8);
|
|
272
|
-
return new Int64(buff);
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
TBinaryProtocol.prototype.readDouble = function() {
|
|
276
|
-
return this.trans.readDouble();
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
TBinaryProtocol.prototype.readBinary = function() {
|
|
280
|
-
var len = this.readI32();
|
|
281
|
-
if (len === 0) {
|
|
282
|
-
return new Buffer(0);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
if (len < 0) {
|
|
286
|
-
throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.NEGATIVE_SIZE, "Negative binary size");
|
|
287
|
-
}
|
|
288
|
-
return this.trans.read(len);
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
TBinaryProtocol.prototype.readString = function() {
|
|
292
|
-
var len = this.readI32();
|
|
293
|
-
if (len === 0) {
|
|
294
|
-
return "";
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
if (len < 0) {
|
|
298
|
-
throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.NEGATIVE_SIZE, "Negative string size");
|
|
299
|
-
}
|
|
300
|
-
return this.trans.readString(len);
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
TBinaryProtocol.prototype.getTransport = function() {
|
|
304
|
-
return this.trans;
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
TBinaryProtocol.prototype.skip = function(type) {
|
|
308
|
-
switch (type) {
|
|
309
|
-
case Type.BOOL:
|
|
310
|
-
this.readBool();
|
|
311
|
-
break;
|
|
312
|
-
case Type.BYTE:
|
|
313
|
-
this.readByte();
|
|
314
|
-
break;
|
|
315
|
-
case Type.I16:
|
|
316
|
-
this.readI16();
|
|
317
|
-
break;
|
|
318
|
-
case Type.I32:
|
|
319
|
-
this.readI32();
|
|
320
|
-
break;
|
|
321
|
-
case Type.I64:
|
|
322
|
-
this.readI64();
|
|
323
|
-
break;
|
|
324
|
-
case Type.DOUBLE:
|
|
325
|
-
this.readDouble();
|
|
326
|
-
break;
|
|
327
|
-
case Type.STRING:
|
|
328
|
-
this.readString();
|
|
329
|
-
break;
|
|
330
|
-
case Type.STRUCT:
|
|
331
|
-
this.readStructBegin();
|
|
332
|
-
while (true) {
|
|
333
|
-
var r = this.readFieldBegin();
|
|
334
|
-
if (r.ftype === Type.STOP) {
|
|
335
|
-
break;
|
|
336
|
-
}
|
|
337
|
-
this.skip(r.ftype);
|
|
338
|
-
this.readFieldEnd();
|
|
339
|
-
}
|
|
340
|
-
this.readStructEnd();
|
|
341
|
-
break;
|
|
342
|
-
case Type.MAP:
|
|
343
|
-
var mapBegin = this.readMapBegin();
|
|
344
|
-
for (var i = 0; i < mapBegin.size; ++i) {
|
|
345
|
-
this.skip(mapBegin.ktype);
|
|
346
|
-
this.skip(mapBegin.vtype);
|
|
347
|
-
}
|
|
348
|
-
this.readMapEnd();
|
|
349
|
-
break;
|
|
350
|
-
case Type.SET:
|
|
351
|
-
var setBegin = this.readSetBegin();
|
|
352
|
-
for (var i2 = 0; i2 < setBegin.size; ++i2) {
|
|
353
|
-
this.skip(setBegin.etype);
|
|
354
|
-
}
|
|
355
|
-
this.readSetEnd();
|
|
356
|
-
break;
|
|
357
|
-
case Type.LIST:
|
|
358
|
-
var listBegin = this.readListBegin();
|
|
359
|
-
for (var i3 = 0; i3 < listBegin.size; ++i3) {
|
|
360
|
-
this.skip(listBegin.etype);
|
|
361
|
-
}
|
|
362
|
-
this.readListEnd();
|
|
363
|
-
break;
|
|
364
|
-
default:
|
|
365
|
-
throw new Error("Invalid type: " + type);
|
|
366
|
-
}
|
|
367
|
-
};
|
|
@@ -1,49 +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 wsConnection = require('./ws_connection');
|
|
22
|
-
exports.WSConnection = wsConnection.WSConnection;
|
|
23
|
-
exports.createWSConnection = wsConnection.createWSConnection;
|
|
24
|
-
exports.createWSClient = wsConnection.createWSClient;
|
|
25
|
-
|
|
26
|
-
var xhrConnection = require('./xhr_connection');
|
|
27
|
-
exports.XHRConnection = xhrConnection.XHRConnection;
|
|
28
|
-
exports.createXHRConnection = xhrConnection.createXHRConnection;
|
|
29
|
-
exports.createXHRClient = xhrConnection.createXHRClient;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
exports.Int64 = require('node-int64');
|
|
33
|
-
exports.Q = require('q');
|
|
34
|
-
|
|
35
|
-
var mpxProtocol = require('./multiplexed_protocol');
|
|
36
|
-
exports.Multiplexer = mpxProtocol.Multiplexer;
|
|
37
|
-
|
|
38
|
-
/*
|
|
39
|
-
* Export transport and protocol so they can be used outside of a
|
|
40
|
-
* cassandra/server context
|
|
41
|
-
*/
|
|
42
|
-
exports.TBufferedTransport = require('./buffered_transport');
|
|
43
|
-
exports.TFramedTransport = require('./framed_transport');
|
|
44
|
-
exports.TWebSocketTransport = require('./ws_transport');
|
|
45
|
-
|
|
46
|
-
exports.Protocol = require('./json_protocol');
|
|
47
|
-
exports.TJSONProtocol = require('./json_protocol');
|
|
48
|
-
exports.TBinaryProtocol = require('./binary_protocol');
|
|
49
|
-
exports.TCompactProtocol = require('./compact_protocol');
|