@tdengine/websocket 3.1.0 → 3.1.2
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/lib/example/all_type_query.d.ts +2 -0
- package/lib/example/all_type_query.d.ts.map +1 -0
- package/lib/example/all_type_query.js +89 -0
- package/lib/example/all_type_stmt.d.ts +2 -0
- package/lib/example/all_type_stmt.d.ts.map +1 -0
- package/lib/example/all_type_stmt.js +130 -0
- package/lib/example/basicBatchTmq.d.ts +2 -0
- package/lib/example/basicBatchTmq.d.ts.map +1 -0
- package/lib/example/basicBatchTmq.js +129 -0
- package/lib/example/basicSql.js +9 -7
- package/lib/example/basicStmt.js +34 -20
- package/lib/example/basicTmq.js +22 -20
- package/lib/example/logs/.007e668bb78549e9a304b8466671945ab2a1553e-audit.json +15 -0
- package/lib/example/logs/app-2024-10-12.log.gz +0 -0
- package/lib/example/logs/app-2024-11-06.log +542 -0
- package/lib/example/test.d.ts +2 -0
- package/lib/example/test.d.ts.map +1 -0
- package/lib/example/test.js +88 -0
- package/lib/src/client/wsClient.d.ts +2 -5
- package/lib/src/client/wsClient.d.ts.map +1 -1
- package/lib/src/client/wsClient.js +4 -54
- package/lib/src/client/wsConnector.js +3 -3
- package/lib/src/client/wsResponse.d.ts +10 -15
- package/lib/src/client/wsResponse.d.ts.map +1 -1
- package/lib/src/client/wsResponse.js +31 -19
- package/lib/src/common/constant.d.ts +23 -1
- package/lib/src/common/constant.d.ts.map +1 -1
- package/lib/src/common/constant.js +25 -22
- package/lib/src/common/log.js +1 -1
- package/lib/src/common/taosResult.d.ts +11 -5
- package/lib/src/common/taosResult.d.ts.map +1 -1
- package/lib/src/common/taosResult.js +106 -76
- package/lib/src/common/utils.d.ts +2 -0
- package/lib/src/common/utils.d.ts.map +1 -1
- package/lib/src/common/utils.js +34 -1
- package/lib/src/sql/wsRows.d.ts.map +1 -1
- package/lib/src/sql/wsRows.js +21 -10
- package/lib/src/sql/wsSql.d.ts.map +1 -1
- package/lib/src/sql/wsSql.js +29 -19
- package/lib/src/stmt/wsParams.js +40 -40
- package/lib/src/tmq/constant.d.ts +15 -0
- package/lib/src/tmq/constant.d.ts.map +1 -1
- package/lib/src/tmq/constant.js +17 -1
- package/lib/src/tmq/tmqResponse.d.ts +20 -8
- package/lib/src/tmq/tmqResponse.d.ts.map +1 -1
- package/lib/src/tmq/tmqResponse.js +214 -89
- package/lib/src/tmq/wsTmq.d.ts +0 -1
- package/lib/src/tmq/wsTmq.d.ts.map +1 -1
- package/lib/src/tmq/wsTmq.js +18 -32
- package/lib/test/bulkPulling/log.test.d.ts +2 -0
- package/lib/test/bulkPulling/log.test.d.ts.map +1 -0
- package/lib/test/bulkPulling/log.test.js +44 -0
- package/lib/test/bulkPulling/schemaless.test.js +7 -6
- package/lib/test/bulkPulling/sql.test.js +38 -18
- package/lib/test/bulkPulling/stmt.func.test.js +72 -56
- package/lib/test/bulkPulling/stmt.type.test.js +1 -5
- package/lib/test/bulkPulling/tmq.test.js +22 -15
- package/lib/test/bulkPulling/wsConnectPool.test.js +9 -2
- package/lib/test/utils.d.ts +0 -1
- package/lib/test/utils.d.ts.map +1 -1
- package/lib/test/utils.js +17 -17
- package/package.json +2 -2
package/lib/src/stmt/wsParams.js
CHANGED
|
@@ -37,97 +37,97 @@ class StmtBindParams {
|
|
|
37
37
|
if (!params || params.length == 0) {
|
|
38
38
|
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SetBooleanColumn params is invalid!");
|
|
39
39
|
}
|
|
40
|
-
let arrayBuffer = this.encodeDigitColumns(params, "boolean", constant_1.TDengineTypeLength['BOOL'], constant_1.TDengineTypeCode
|
|
41
|
-
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode
|
|
40
|
+
let arrayBuffer = this.encodeDigitColumns(params, "boolean", constant_1.TDengineTypeLength['BOOL'], constant_1.TDengineTypeCode.BOOL);
|
|
41
|
+
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode.BOOL, constant_1.TDengineTypeLength['BOOL']));
|
|
42
42
|
}
|
|
43
43
|
setTinyInt(params) {
|
|
44
44
|
if (!params || params.length == 0) {
|
|
45
45
|
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SetTinyIntColumn params is invalid!");
|
|
46
46
|
}
|
|
47
|
-
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['TINYINT'], constant_1.TDengineTypeCode
|
|
48
|
-
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode
|
|
47
|
+
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['TINYINT'], constant_1.TDengineTypeCode.TINYINT);
|
|
48
|
+
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode.TINYINT, constant_1.TDengineTypeLength['TINYINT']));
|
|
49
49
|
}
|
|
50
50
|
setUTinyInt(params) {
|
|
51
51
|
if (!params || params.length == 0) {
|
|
52
52
|
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SetUTinyIntColumn params is invalid!");
|
|
53
53
|
}
|
|
54
|
-
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['TINYINT UNSIGNED'], constant_1.TDengineTypeCode
|
|
55
|
-
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode
|
|
54
|
+
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['TINYINT UNSIGNED'], constant_1.TDengineTypeCode.TINYINT_UNSIGNED);
|
|
55
|
+
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode.TINYINT_UNSIGNED, constant_1.TDengineTypeLength['TINYINT UNSIGNED']));
|
|
56
56
|
}
|
|
57
57
|
setSmallInt(params) {
|
|
58
58
|
if (!params || params.length == 0) {
|
|
59
59
|
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SetSmallIntColumn params is invalid!");
|
|
60
60
|
}
|
|
61
|
-
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['SMALLINT'], constant_1.TDengineTypeCode
|
|
62
|
-
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode
|
|
61
|
+
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['SMALLINT'], constant_1.TDengineTypeCode.SMALLINT);
|
|
62
|
+
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode.SMALLINT, constant_1.TDengineTypeLength['SMALLINT']));
|
|
63
63
|
}
|
|
64
64
|
setUSmallInt(params) {
|
|
65
65
|
if (!params || params.length == 0) {
|
|
66
66
|
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SetSmallIntColumn params is invalid!");
|
|
67
67
|
}
|
|
68
|
-
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['SMALLINT UNSIGNED'], constant_1.TDengineTypeCode
|
|
69
|
-
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode
|
|
68
|
+
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['SMALLINT UNSIGNED'], constant_1.TDengineTypeCode.SMALLINT_UNSIGNED);
|
|
69
|
+
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode.SMALLINT_UNSIGNED, constant_1.TDengineTypeLength['SMALLINT UNSIGNED']));
|
|
70
70
|
}
|
|
71
71
|
setInt(params) {
|
|
72
72
|
if (!params || params.length == 0) {
|
|
73
73
|
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SetIntColumn params is invalid!");
|
|
74
74
|
}
|
|
75
|
-
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['INT'], constant_1.TDengineTypeCode
|
|
76
|
-
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode
|
|
75
|
+
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['INT'], constant_1.TDengineTypeCode.INT);
|
|
76
|
+
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode.INT, constant_1.TDengineTypeLength['INT']));
|
|
77
77
|
}
|
|
78
78
|
setUInt(params) {
|
|
79
79
|
if (!params || params.length == 0) {
|
|
80
80
|
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SetUIntColumn params is invalid!");
|
|
81
81
|
}
|
|
82
|
-
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['INT UNSIGNED'], constant_1.TDengineTypeCode
|
|
83
|
-
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode
|
|
82
|
+
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['INT UNSIGNED'], constant_1.TDengineTypeCode.INT_UNSIGNED);
|
|
83
|
+
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode.INT_UNSIGNED, constant_1.TDengineTypeLength['INT UNSIGNED']));
|
|
84
84
|
}
|
|
85
85
|
setBigint(params) {
|
|
86
86
|
if (!params || params.length == 0) {
|
|
87
87
|
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SetBigIntColumn params is invalid!");
|
|
88
88
|
}
|
|
89
|
-
let arrayBuffer = this.encodeDigitColumns(params, "bigint", constant_1.TDengineTypeLength['BIGINT'], constant_1.TDengineTypeCode
|
|
90
|
-
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode
|
|
89
|
+
let arrayBuffer = this.encodeDigitColumns(params, "bigint", constant_1.TDengineTypeLength['BIGINT'], constant_1.TDengineTypeCode.BIGINT);
|
|
90
|
+
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode.INT, constant_1.TDengineTypeLength['BIGINT']));
|
|
91
91
|
}
|
|
92
92
|
setUBigint(params) {
|
|
93
93
|
if (!params || params.length == 0) {
|
|
94
94
|
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SetUBigIntColumn params is invalid!");
|
|
95
95
|
}
|
|
96
|
-
let arrayBuffer = this.encodeDigitColumns(params, "bigint", constant_1.TDengineTypeLength['BIGINT UNSIGNED'], constant_1.TDengineTypeCode
|
|
97
|
-
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode
|
|
96
|
+
let arrayBuffer = this.encodeDigitColumns(params, "bigint", constant_1.TDengineTypeLength['BIGINT UNSIGNED'], constant_1.TDengineTypeCode.BIGINT_UNSIGNED);
|
|
97
|
+
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode.BIGINT_UNSIGNED, constant_1.TDengineTypeLength['BIGINT UNSIGNED']));
|
|
98
98
|
}
|
|
99
99
|
setFloat(params) {
|
|
100
100
|
if (!params || params.length == 0) {
|
|
101
101
|
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SetFloatColumn params is invalid!");
|
|
102
102
|
}
|
|
103
|
-
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['FLOAT'], constant_1.TDengineTypeCode
|
|
104
|
-
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode
|
|
103
|
+
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['FLOAT'], constant_1.TDengineTypeCode.FLOAT);
|
|
104
|
+
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode.FLOAT, constant_1.TDengineTypeLength['FLOAT']));
|
|
105
105
|
}
|
|
106
106
|
setDouble(params) {
|
|
107
107
|
if (!params || params.length == 0) {
|
|
108
108
|
throw new wsError_1.TaosError(wsError_1.ErrorCode.ERR_INVALID_PARAMS, "SetDoubleColumn params is invalid!");
|
|
109
109
|
}
|
|
110
|
-
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['DOUBLE'], constant_1.TDengineTypeCode
|
|
111
|
-
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode
|
|
110
|
+
let arrayBuffer = this.encodeDigitColumns(params, "number", constant_1.TDengineTypeLength['DOUBLE'], constant_1.TDengineTypeCode.DOUBLE);
|
|
111
|
+
this._params.push(new ColumnInfo(arrayBuffer, constant_1.TDengineTypeCode.DOUBLE, constant_1.TDengineTypeLength['DOUBLE']));
|
|
112
112
|
}
|
|
113
113
|
setVarchar(params) {
|
|
114
114
|
let data = this.encodeVarLengthColumn(params);
|
|
115
|
-
this._params.push(new ColumnInfo(data, constant_1.TDengineTypeCode
|
|
115
|
+
this._params.push(new ColumnInfo(data, constant_1.TDengineTypeCode.VARCHAR, 0));
|
|
116
116
|
}
|
|
117
117
|
setBinary(params) {
|
|
118
|
-
this._params.push(new ColumnInfo(this.encodeVarLengthColumn(params), constant_1.TDengineTypeCode
|
|
118
|
+
this._params.push(new ColumnInfo(this.encodeVarLengthColumn(params), constant_1.TDengineTypeCode.BINARY, 0));
|
|
119
119
|
}
|
|
120
120
|
setNchar(params) {
|
|
121
|
-
this._params.push(new ColumnInfo(this.encodeNcharColumn(params), constant_1.TDengineTypeCode
|
|
121
|
+
this._params.push(new ColumnInfo(this.encodeNcharColumn(params), constant_1.TDengineTypeCode.NCHAR, 0));
|
|
122
122
|
}
|
|
123
123
|
setJson(params) {
|
|
124
|
-
this._params.push(new ColumnInfo(this.encodeVarLengthColumn(params), constant_1.TDengineTypeCode
|
|
124
|
+
this._params.push(new ColumnInfo(this.encodeVarLengthColumn(params), constant_1.TDengineTypeCode.JSON, 0));
|
|
125
125
|
}
|
|
126
126
|
setVarBinary(params) {
|
|
127
|
-
this._params.push(new ColumnInfo(this.encodeVarLengthColumn(params), constant_1.TDengineTypeCode
|
|
127
|
+
this._params.push(new ColumnInfo(this.encodeVarLengthColumn(params), constant_1.TDengineTypeCode.VARBINARY, 0));
|
|
128
128
|
}
|
|
129
129
|
setGeometry(params) {
|
|
130
|
-
this._params.push(new ColumnInfo(this.encodeVarLengthColumn(params), constant_1.TDengineTypeCode
|
|
130
|
+
this._params.push(new ColumnInfo(this.encodeVarLengthColumn(params), constant_1.TDengineTypeCode.GEOMETRY, 0));
|
|
131
131
|
}
|
|
132
132
|
setTimestamp(params) {
|
|
133
133
|
if (!params || params.length == 0) {
|
|
@@ -201,7 +201,7 @@ class StmtBindParams {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
this._dataTotalLen += arrayBuffer.byteLength;
|
|
204
|
-
this._params.push(new ColumnInfo([constant_1.TDengineTypeLength['TIMESTAMP'] * params.length, arrayBuffer], constant_1.TDengineTypeCode
|
|
204
|
+
this._params.push(new ColumnInfo([constant_1.TDengineTypeLength['TIMESTAMP'] * params.length, arrayBuffer], constant_1.TDengineTypeCode.TIMESTAMP, constant_1.TDengineTypeLength['TIMESTAMP']));
|
|
205
205
|
}
|
|
206
206
|
encodeDigitColumns(params, dataType = 'number', typeLen, columnType) {
|
|
207
207
|
let bitMapLen = (0, taosResult_1.bitmapLen)(params.length);
|
|
@@ -220,7 +220,7 @@ class StmtBindParams {
|
|
|
220
220
|
if (!(0, utils_1.isEmpty)(params[i])) {
|
|
221
221
|
if (typeof params[i] == dataType) {
|
|
222
222
|
switch (columnType) {
|
|
223
|
-
case constant_1.TDengineTypeCode
|
|
223
|
+
case constant_1.TDengineTypeCode.BOOL: {
|
|
224
224
|
if (params[i]) {
|
|
225
225
|
dataBuffer.setInt8(i, 1);
|
|
226
226
|
}
|
|
@@ -229,43 +229,43 @@ class StmtBindParams {
|
|
|
229
229
|
}
|
|
230
230
|
break;
|
|
231
231
|
}
|
|
232
|
-
case constant_1.TDengineTypeCode
|
|
232
|
+
case constant_1.TDengineTypeCode.TINYINT: {
|
|
233
233
|
dataBuffer.setInt8(i, params[i]);
|
|
234
234
|
break;
|
|
235
235
|
}
|
|
236
|
-
case constant_1.TDengineTypeCode
|
|
236
|
+
case constant_1.TDengineTypeCode.TINYINT_UNSIGNED: {
|
|
237
237
|
dataBuffer.setUint8(i, params[i]);
|
|
238
238
|
break;
|
|
239
239
|
}
|
|
240
|
-
case constant_1.TDengineTypeCode
|
|
240
|
+
case constant_1.TDengineTypeCode.SMALLINT: {
|
|
241
241
|
dataBuffer.setInt16(i * 2, params[i], true);
|
|
242
242
|
break;
|
|
243
243
|
}
|
|
244
|
-
case constant_1.TDengineTypeCode
|
|
244
|
+
case constant_1.TDengineTypeCode.SMALLINT_UNSIGNED: {
|
|
245
245
|
dataBuffer.setUint16(i * 2, params[i], true);
|
|
246
246
|
break;
|
|
247
247
|
}
|
|
248
|
-
case constant_1.TDengineTypeCode
|
|
248
|
+
case constant_1.TDengineTypeCode.INT: {
|
|
249
249
|
dataBuffer.setInt32(i * 4, params[i], true);
|
|
250
250
|
break;
|
|
251
251
|
}
|
|
252
|
-
case constant_1.TDengineTypeCode
|
|
252
|
+
case constant_1.TDengineTypeCode.INT_UNSIGNED: {
|
|
253
253
|
dataBuffer.setUint32(i * 4, params[i], true);
|
|
254
254
|
break;
|
|
255
255
|
}
|
|
256
|
-
case constant_1.TDengineTypeCode
|
|
256
|
+
case constant_1.TDengineTypeCode.BIGINT: {
|
|
257
257
|
dataBuffer.setBigInt64(i * 8, params[i], true);
|
|
258
258
|
break;
|
|
259
259
|
}
|
|
260
|
-
case constant_1.TDengineTypeCode
|
|
260
|
+
case constant_1.TDengineTypeCode.BIGINT_UNSIGNED: {
|
|
261
261
|
dataBuffer.setBigUint64(i * 8, params[i], true);
|
|
262
262
|
break;
|
|
263
263
|
}
|
|
264
|
-
case constant_1.TDengineTypeCode
|
|
264
|
+
case constant_1.TDengineTypeCode.FLOAT: {
|
|
265
265
|
dataBuffer.setFloat32(i * 4, params[i], true);
|
|
266
266
|
break;
|
|
267
267
|
}
|
|
268
|
-
case constant_1.TDengineTypeCode
|
|
268
|
+
case constant_1.TDengineTypeCode.DOUBLE: {
|
|
269
269
|
dataBuffer.setFloat64(i * 8, params[i], true);
|
|
270
270
|
break;
|
|
271
271
|
}
|
|
@@ -82,4 +82,19 @@ export declare class TMQMessageType {
|
|
|
82
82
|
static ListTopics: string;
|
|
83
83
|
static ResDataType: number;
|
|
84
84
|
}
|
|
85
|
+
export declare class TMQBlockInfo {
|
|
86
|
+
rawBlock?: ArrayBuffer;
|
|
87
|
+
precision?: number;
|
|
88
|
+
schema: Array<TMQRawDataSchema>;
|
|
89
|
+
tableName?: string;
|
|
90
|
+
constructor();
|
|
91
|
+
}
|
|
92
|
+
export declare class TMQRawDataSchema {
|
|
93
|
+
colType: number;
|
|
94
|
+
flag: number;
|
|
95
|
+
bytes: bigint;
|
|
96
|
+
colID: number;
|
|
97
|
+
name: string;
|
|
98
|
+
constructor();
|
|
99
|
+
}
|
|
85
100
|
//# sourceMappingURL=constant.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/tmq/constant.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAY;IACrB,OAAc,QAAQ,EAAE,MAAM,CAAc;IAE5C,OAAc,SAAS,EAAE,MAAM,CAAe;IAE9C;;OAEG;IACH,OAAc,kBAAkB,EAAE,MAAM,CAAwB;IAEhE;;OAEG;IACH,OAAc,uBAAuB,EAAE,MAAM,CAA6B;IAE1E;;OAEG;IACH,OAAc,iBAAiB,EAAE,MAAM,CAAuB;IAE9D;;OAEG;IACH,OAAc,mBAAmB,EAAE,MAAM,CAAyB;IAElE;;OAEG;IACH,OAAc,iBAAiB,EAAE,MAAM,CAAuB;IAE9D;;OAEG;IACH,OAAc,kBAAkB,EAAE,MAAM,CAAwB;IAEhE;;OAEG;IACH,OAAc,2BAA2B,EAAE,MAAM,CAAiC;IAElF;;OAEG;IACH,OAAc,UAAU,EAAE,MAAM,CAAmB;IAEnD;;OAEG;IACH,OAAc,YAAY,EAAE,MAAM,CAAqB;IAEvD;;OAEG;IACH,OAAc,YAAY,EAAE,M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AC5B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAI,MAAM,CAAC;IACf,KAAK,EAAG,MAAM,CAAC;IACf,KAAK,EAAG,MAAM,CAAA;IACd,IAAI,EAAG,MAAM,CAAC;;CASd"}
|
package/lib/src/tmq/constant.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TMQMessageType = exports.TMQConstants = void 0;
|
|
3
|
+
exports.TMQRawDataSchema = exports.TMQBlockInfo = exports.TMQMessageType = exports.TMQConstants = void 0;
|
|
4
4
|
class TMQConstants {
|
|
5
5
|
}
|
|
6
6
|
exports.TMQConstants = TMQConstants;
|
|
@@ -87,3 +87,19 @@ TMQMessageType.Committed = 'committed';
|
|
|
87
87
|
TMQMessageType.Position = 'position';
|
|
88
88
|
TMQMessageType.ListTopics = "list_topics";
|
|
89
89
|
TMQMessageType.ResDataType = 1;
|
|
90
|
+
class TMQBlockInfo {
|
|
91
|
+
constructor() {
|
|
92
|
+
this.schema = [];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.TMQBlockInfo = TMQBlockInfo;
|
|
96
|
+
class TMQRawDataSchema {
|
|
97
|
+
constructor() {
|
|
98
|
+
this.bytes = BigInt(0);
|
|
99
|
+
this.colID = -1;
|
|
100
|
+
this.colType = -1;
|
|
101
|
+
this.flag = -1;
|
|
102
|
+
this.name = "";
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.TMQRawDataSchema = TMQRawDataSchema;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WSQueryResponse } from "../client/wsResponse";
|
|
2
2
|
import { MessageResp, TaosResult } from "../common/taosResult";
|
|
3
|
+
import { TMQBlockInfo, TMQRawDataSchema } from "./constant";
|
|
3
4
|
export declare class WsPollResponse {
|
|
4
5
|
code: number;
|
|
5
6
|
message: string;
|
|
@@ -23,16 +24,28 @@ export declare class WsTmqQueryResponse extends WSQueryResponse {
|
|
|
23
24
|
constructor(resp: MessageResp);
|
|
24
25
|
}
|
|
25
26
|
export declare class TaosTmqResult extends TaosResult {
|
|
26
|
-
topic: string;
|
|
27
27
|
database: string;
|
|
28
28
|
vgroup_id: number;
|
|
29
|
-
|
|
30
|
-
constructor(resp: WsTmqQueryResponse, pollResp: WsPollResponse);
|
|
29
|
+
constructor(pollResp: WsPollResponse);
|
|
31
30
|
}
|
|
32
|
-
export declare class
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
export declare class WSTmqFetchBlockInfo {
|
|
32
|
+
withTableName?: boolean;
|
|
33
|
+
withSchema?: boolean;
|
|
34
|
+
blockInfos?: Array<TMQBlockInfo>;
|
|
35
|
+
schema: Array<TMQRawDataSchema>;
|
|
36
|
+
tableName?: string;
|
|
37
|
+
taosResult: TaosResult;
|
|
38
|
+
schemaLen: number;
|
|
39
|
+
rows: number;
|
|
40
|
+
textDecoder: TextDecoder;
|
|
41
|
+
constructor(dataView: DataView, taosResult: TaosResult);
|
|
42
|
+
getRows(): number;
|
|
43
|
+
private skipHead;
|
|
44
|
+
private getTypeSkip;
|
|
45
|
+
private parseBlockInfos;
|
|
46
|
+
private parseSchemaInfo;
|
|
47
|
+
private parseVariableByteInteger;
|
|
48
|
+
private parseTmqBlock;
|
|
36
49
|
}
|
|
37
50
|
export declare class AssignmentResp {
|
|
38
51
|
req_id: number;
|
|
@@ -76,5 +89,4 @@ export declare class TopicPartition {
|
|
|
76
89
|
end?: number;
|
|
77
90
|
constructor(msg: any);
|
|
78
91
|
}
|
|
79
|
-
export declare function parseTmqBlock(rows: number, resp: WSTmqFetchBlockResponse, taosResult: TaosResult): TaosResult;
|
|
80
92
|
//# sourceMappingURL=tmqResponse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tmqResponse.d.ts","sourceRoot":"","sources":["../../../src/tmq/tmqResponse.ts"],"names":[],"mappings":"AAAA,OAA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AAC,WAAW;IAU5B,kBAAkB,CAAC,eAAe,EAAC,cAAc,EAAE,GAAE,cAAc,EAAE;CAUxE;AAED,qBAAa,aAAc,SAAQ,cAAc;gBACjC,IAAI,EAAC,WAAW;CAI/B;AAED,qBAAa,cAAc;IACvB,KAAK,EAAQ,MAAM,CAAC;IACpB,SAAS,EAAI,MAAM,CAAC;IACpB,MAAY,CAAC,EAAC,MAAM,CAAC;IACrB,KAAY,CAAC,EAAC,MAAM,CAAC;IACrB,GAAY,CAAC,EAAC,MAAM,CAAC;gBACT,GAAG,EAAC,GAAG;CAOtB"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
6
|
+
exports.TopicPartition = exports.CommittedResp = exports.PartitionsResp = exports.SubscriptionResp = exports.AssignmentResp = exports.WSTmqFetchBlockInfo = exports.TaosTmqResult = exports.WsTmqQueryResponse = exports.WsPollResponse = void 0;
|
|
4
7
|
const wsResponse_1 = require("../client/wsResponse");
|
|
5
8
|
const constant_1 = require("../common/constant");
|
|
6
9
|
const taosResult_1 = require("../common/taosResult");
|
|
7
10
|
const wsError_1 = require("../common/wsError");
|
|
11
|
+
const constant_2 = require("./constant");
|
|
12
|
+
const utils_1 = require("../common/utils");
|
|
13
|
+
const log_1 = __importDefault(require("../common/log"));
|
|
8
14
|
class WsPollResponse {
|
|
9
15
|
constructor(resp) {
|
|
10
16
|
this.totalTime = resp.totalTime;
|
|
@@ -39,23 +45,220 @@ class WsTmqQueryResponse extends wsResponse_1.WSQueryResponse {
|
|
|
39
45
|
}
|
|
40
46
|
exports.WsTmqQueryResponse = WsTmqQueryResponse;
|
|
41
47
|
class TaosTmqResult extends taosResult_1.TaosResult {
|
|
42
|
-
constructor(
|
|
43
|
-
super(
|
|
44
|
-
this.
|
|
45
|
-
// this._affectRows = resp.rows;
|
|
46
|
-
this.topic = pollResp.topic;
|
|
48
|
+
constructor(pollResp) {
|
|
49
|
+
super();
|
|
50
|
+
this.setTopic(pollResp.topic);
|
|
47
51
|
this.database = pollResp.database;
|
|
48
52
|
this.vgroup_id = pollResp.vgroup_id;
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
exports.TaosTmqResult = TaosTmqResult;
|
|
52
|
-
class
|
|
53
|
-
constructor(
|
|
54
|
-
this.totalTime = resp.totalTime
|
|
55
|
-
this.blockData = resp.msg
|
|
56
|
+
class WSTmqFetchBlockInfo {
|
|
57
|
+
constructor(dataView, taosResult) {
|
|
58
|
+
// this.totalTime = resp.totalTime
|
|
59
|
+
// this.blockData = resp.msg
|
|
60
|
+
this.textDecoder = new TextDecoder();
|
|
61
|
+
this.taosResult = taosResult;
|
|
62
|
+
this.schema = [];
|
|
63
|
+
this.schemaLen = 0;
|
|
64
|
+
let blockDataView = this.skipHead(dataView);
|
|
65
|
+
this.rows = this.parseBlockInfos(blockDataView);
|
|
66
|
+
}
|
|
67
|
+
getRows() {
|
|
68
|
+
return this.rows;
|
|
69
|
+
}
|
|
70
|
+
skipHead(dataView) {
|
|
71
|
+
let v = dataView.getUint8(0);
|
|
72
|
+
if (v >= 100) {
|
|
73
|
+
let skip = dataView.getUint32(1, true);
|
|
74
|
+
return new DataView(dataView.buffer, dataView.byteOffset + skip + 5);
|
|
75
|
+
}
|
|
76
|
+
let skip1 = this.getTypeSkip(v);
|
|
77
|
+
v = dataView.getUint8(1 + skip1);
|
|
78
|
+
let skip2 = this.getTypeSkip(v);
|
|
79
|
+
return new DataView(dataView.buffer, dataView.byteOffset + skip1 + 2 + skip2);
|
|
80
|
+
}
|
|
81
|
+
getTypeSkip(v) {
|
|
82
|
+
switch (v) {
|
|
83
|
+
case 1:
|
|
84
|
+
return 8;
|
|
85
|
+
case 2:
|
|
86
|
+
case 3:
|
|
87
|
+
return 16;
|
|
88
|
+
default:
|
|
89
|
+
throw (new wsError_1.TDWebSocketClientError(wsError_1.ErrorCode.ERR_INVALID_FETCH_MESSAGE_DATA, `FetchBlockRawResp getTypeSkip error, type: ${v}`));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
parseBlockInfos(dataView) {
|
|
93
|
+
let blockNum = dataView.getUint32(0, true);
|
|
94
|
+
if (blockNum == 0) {
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
this.withTableName = dataView.getUint8(4) == 1 ? true : false;
|
|
98
|
+
this.withSchema = dataView.getUint8(5) == 1 ? true : false;
|
|
99
|
+
// let dataBuffer = dataView.buffer.slice(6)
|
|
100
|
+
let dataBuffer = new DataView(dataView.buffer, dataView.byteOffset + 6);
|
|
101
|
+
let rows = 0;
|
|
102
|
+
// const parseStartTime = new Date().getTime();
|
|
103
|
+
// console.log("parseBlockInfos blockNum="+ blockNum)
|
|
104
|
+
for (let i = 0; i < blockNum; i++) {
|
|
105
|
+
let variableInfo = this.parseVariableByteInteger(dataBuffer);
|
|
106
|
+
this.taosResult.setPrecision(variableInfo[1].getUint8(17));
|
|
107
|
+
dataView = new DataView(variableInfo[1].buffer, variableInfo[1].byteOffset + 17);
|
|
108
|
+
let offset = variableInfo[0] - 17;
|
|
109
|
+
dataBuffer = this.parseSchemaInfo(dataView, offset);
|
|
110
|
+
rows += this.parseTmqBlock(dataView, 1);
|
|
111
|
+
}
|
|
112
|
+
// const parseEndTime = new Date().getTime();
|
|
113
|
+
// console.log("------------->", parseEndTime- parseStartTime, rows);
|
|
114
|
+
log_1.default.info("parseBlockInfos blockNum=" + blockNum + ", withTableName=" + this.withTableName + ", withSchema=" + this.withSchema + ", rows=" + rows);
|
|
115
|
+
return rows;
|
|
116
|
+
}
|
|
117
|
+
parseSchemaInfo(dataBuffer, offset) {
|
|
118
|
+
if (this.withSchema) {
|
|
119
|
+
let isSkip = this.schema.length > 0;
|
|
120
|
+
if (!isSkip) {
|
|
121
|
+
dataBuffer = new DataView(dataBuffer.buffer, dataBuffer.byteOffset + offset);
|
|
122
|
+
let variableInfo = this.parseVariableByteInteger(dataBuffer);
|
|
123
|
+
this.schemaLen = variableInfo[2];
|
|
124
|
+
let cols = (0, utils_1.zigzagDecode)(variableInfo[0]);
|
|
125
|
+
variableInfo = this.parseVariableByteInteger(variableInfo[1]);
|
|
126
|
+
this.schemaLen += variableInfo[2];
|
|
127
|
+
let dataView = variableInfo[1];
|
|
128
|
+
for (let index = 0; index < cols; index++) {
|
|
129
|
+
let schema = new constant_2.TMQRawDataSchema();
|
|
130
|
+
schema.colType = dataView.getInt8(0);
|
|
131
|
+
schema.flag = dataView.getInt8(1);
|
|
132
|
+
variableInfo = this.parseVariableByteInteger(dataView, 2);
|
|
133
|
+
this.schemaLen += 2 + variableInfo[2];
|
|
134
|
+
schema.bytes = BigInt((0, utils_1.zigzagDecode)(variableInfo[0]));
|
|
135
|
+
variableInfo = this.parseVariableByteInteger(variableInfo[1]);
|
|
136
|
+
this.schemaLen += variableInfo[2];
|
|
137
|
+
schema.colID = (0, utils_1.zigzagDecode)(variableInfo[0]);
|
|
138
|
+
variableInfo = this.parseVariableByteInteger(variableInfo[1]);
|
|
139
|
+
this.schemaLen += variableInfo[2];
|
|
140
|
+
schema.name = (0, taosResult_1.getString)(variableInfo[1], 0, variableInfo[0], this.textDecoder);
|
|
141
|
+
if (!isSkip) {
|
|
142
|
+
this.taosResult.setMeta({
|
|
143
|
+
name: schema.name,
|
|
144
|
+
type: schema.colType,
|
|
145
|
+
length: Number(schema.bytes)
|
|
146
|
+
});
|
|
147
|
+
this.schema.push(schema);
|
|
148
|
+
}
|
|
149
|
+
dataView = new DataView(variableInfo[1].buffer, variableInfo[1].byteOffset + variableInfo[0]);
|
|
150
|
+
this.schemaLen += variableInfo[0];
|
|
151
|
+
}
|
|
152
|
+
if (this.withTableName) {
|
|
153
|
+
variableInfo = this.parseVariableByteInteger(dataView);
|
|
154
|
+
this.schemaLen += variableInfo[2];
|
|
155
|
+
this.tableName = (0, taosResult_1.readVarchar)(variableInfo[1].buffer, variableInfo[1].byteOffset, variableInfo[0], this.textDecoder);
|
|
156
|
+
dataView = new DataView(variableInfo[1].buffer, variableInfo[1].byteOffset + variableInfo[0]);
|
|
157
|
+
this.schemaLen += variableInfo[0];
|
|
158
|
+
}
|
|
159
|
+
return dataView;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
return new DataView(dataBuffer.buffer, dataBuffer.byteOffset + this.schemaLen + offset);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return dataBuffer;
|
|
166
|
+
}
|
|
167
|
+
parseVariableByteInteger(dataView, offset = 0) {
|
|
168
|
+
let value = 0;
|
|
169
|
+
let multiplier = 1;
|
|
170
|
+
let count = 0;
|
|
171
|
+
while (true) {
|
|
172
|
+
let encodedByte = dataView.getUint8(count + offset);
|
|
173
|
+
value += (encodedByte & 127) * multiplier;
|
|
174
|
+
if ((encodedByte & 128) == 0) {
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
multiplier *= 128;
|
|
178
|
+
count++;
|
|
179
|
+
}
|
|
180
|
+
return [value, new DataView(dataView.buffer, dataView.byteOffset + count + 1 + offset), count + 1];
|
|
181
|
+
}
|
|
182
|
+
parseTmqBlock(dataView, startOffset) {
|
|
183
|
+
// let dataView = new DataView(dataBuffer)
|
|
184
|
+
let rows = dataView.getInt32(8 + startOffset, true);
|
|
185
|
+
if (rows == 0) {
|
|
186
|
+
return rows;
|
|
187
|
+
}
|
|
188
|
+
let taosData = this.taosResult.getData();
|
|
189
|
+
let metaData = this.taosResult.getMeta();
|
|
190
|
+
if (metaData && rows && taosData) {
|
|
191
|
+
let dataList = new Array(rows);
|
|
192
|
+
//get bitmap length
|
|
193
|
+
let bitMapOffset = getBitmapLen(rows);
|
|
194
|
+
//skip data head
|
|
195
|
+
let bufferOffset = 28 + 5 * this.schema.length + startOffset;
|
|
196
|
+
let metaLens = [];
|
|
197
|
+
for (let i = 0; i < this.schema.length; i++) {
|
|
198
|
+
//get data len
|
|
199
|
+
metaLens.push(dataView.getInt32(bufferOffset + i * 4, true));
|
|
200
|
+
}
|
|
201
|
+
bufferOffset += this.schema.length * 4;
|
|
202
|
+
for (let i = 0; i < this.schema.length; i++) {
|
|
203
|
+
let data = [];
|
|
204
|
+
//get type code
|
|
205
|
+
let isVarType = (0, taosResult_1._isVarType)(this.schema[i].colType);
|
|
206
|
+
//fixed length type
|
|
207
|
+
if (isVarType == constant_1.ColumnsBlockType.SOLID) {
|
|
208
|
+
// let bitMapArr = dataBuffer.slice(bufferOffset, bufferOffset + bitMapOffset);
|
|
209
|
+
let bitMapArr = new Uint8Array(dataView.buffer, dataView.byteOffset + bufferOffset, bitMapOffset);
|
|
210
|
+
bufferOffset += bitMapOffset;
|
|
211
|
+
//decode column data, data is array
|
|
212
|
+
data = (0, taosResult_1.readSolidDataToArray)(dataView, bufferOffset, rows, this.schema[i].colType, bitMapArr);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
//Variable length type
|
|
216
|
+
let start = bufferOffset;
|
|
217
|
+
let offsets = [];
|
|
218
|
+
for (let i = 0; i < rows; i++, start += constant_1.TDengineTypeLength['INT']) {
|
|
219
|
+
//get data length, -1 is null
|
|
220
|
+
offsets.push(dataView.getInt32(start, true));
|
|
221
|
+
}
|
|
222
|
+
for (let i = 0; i < rows; i++) {
|
|
223
|
+
let value = '';
|
|
224
|
+
if (-1 == offsets[i]) {
|
|
225
|
+
value = null;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
let header = start + offsets[i];
|
|
229
|
+
let dataLength = dataView.getInt16(header, true) & 0xFFFF;
|
|
230
|
+
if (isVarType == constant_1.ColumnsBlockType.VARCHAR) {
|
|
231
|
+
//decode var char
|
|
232
|
+
value = (0, taosResult_1.readVarchar)(dataView.buffer, dataView.byteOffset + header + 2, dataLength, this.textDecoder);
|
|
233
|
+
}
|
|
234
|
+
else if (isVarType == constant_1.ColumnsBlockType.GEOMETRY || isVarType == constant_1.ColumnsBlockType.VARBINARY) {
|
|
235
|
+
//decode binary
|
|
236
|
+
value = (0, taosResult_1.readBinary)(dataView.buffer, dataView.byteOffset + header + 2, dataLength);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
//decode nchar
|
|
240
|
+
value = (0, taosResult_1.readNchar)(dataView.buffer, dataView.byteOffset + header + 2, dataLength);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
data.push(value);
|
|
244
|
+
}
|
|
245
|
+
bufferOffset += rows * 4;
|
|
246
|
+
}
|
|
247
|
+
bufferOffset += metaLens[i];
|
|
248
|
+
//column data to row data
|
|
249
|
+
for (let row = 0; row < data.length; row++) {
|
|
250
|
+
if (dataList[row] == null) {
|
|
251
|
+
dataList[row] = [];
|
|
252
|
+
}
|
|
253
|
+
dataList[row].push(data[row]);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
taosData.push(...dataList);
|
|
257
|
+
}
|
|
258
|
+
return rows;
|
|
56
259
|
}
|
|
57
260
|
}
|
|
58
|
-
exports.
|
|
261
|
+
exports.WSTmqFetchBlockInfo = WSTmqFetchBlockInfo;
|
|
59
262
|
class AssignmentResp {
|
|
60
263
|
constructor(resp, topic) {
|
|
61
264
|
this.timing = BigInt(resp.msg.timing);
|
|
@@ -121,84 +324,6 @@ class TopicPartition {
|
|
|
121
324
|
}
|
|
122
325
|
}
|
|
123
326
|
exports.TopicPartition = TopicPartition;
|
|
124
|
-
function parseTmqBlock(rows, resp, taosResult) {
|
|
125
|
-
let dataList = new Array(rows);
|
|
126
|
-
if (!resp || !taosResult) {
|
|
127
|
-
return taosResult;
|
|
128
|
-
}
|
|
129
|
-
let metaList = taosResult.getTaosMeta();
|
|
130
|
-
let taosdata = taosResult.getData();
|
|
131
|
-
if (metaList && rows && taosdata) {
|
|
132
|
-
//get bitmap length
|
|
133
|
-
let bitMapOffset = getBitmapLen(rows);
|
|
134
|
-
//skip data head
|
|
135
|
-
let bufferOffset = 24 + 28 + 5 * metaList.length;
|
|
136
|
-
let dataBuffer = resp.blockData.slice(bufferOffset);
|
|
137
|
-
let metaLens = [];
|
|
138
|
-
for (let i = 0; i < metaList.length; i++) {
|
|
139
|
-
//get data len
|
|
140
|
-
metaLens.push(new DataView(dataBuffer, i * 4, 4).getInt32(0, true));
|
|
141
|
-
}
|
|
142
|
-
bufferOffset = metaList.length * 4;
|
|
143
|
-
for (let i = 0; i < metaList.length; i++) {
|
|
144
|
-
let data = [];
|
|
145
|
-
//get type code
|
|
146
|
-
let isVarType = (0, taosResult_1._isVarType)(metaList[i]);
|
|
147
|
-
//fixed length type
|
|
148
|
-
if (isVarType == constant_1.ColumnsBlockType.SOLID) {
|
|
149
|
-
let bitMapArr = dataBuffer.slice(bufferOffset, bufferOffset + bitMapOffset);
|
|
150
|
-
bufferOffset += bitMapOffset;
|
|
151
|
-
//decode column data, data is array
|
|
152
|
-
data = (0, taosResult_1.readSolidDataToArray)(dataBuffer, bufferOffset, rows, metaList[i], bitMapArr);
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
//Variable length type
|
|
156
|
-
let offset = bufferOffset;
|
|
157
|
-
let offsets = [];
|
|
158
|
-
for (let i = 0; i < rows; i++, offset += constant_1.TDengineTypeLength['INT']) {
|
|
159
|
-
//get data length, -1 is null
|
|
160
|
-
offsets.push(new DataView(dataBuffer, offset, 4).getInt32(0, true));
|
|
161
|
-
}
|
|
162
|
-
let start = offset;
|
|
163
|
-
for (let i = 0; i < rows; i++) {
|
|
164
|
-
let value = '';
|
|
165
|
-
if (-1 == offsets[i]) {
|
|
166
|
-
value = null;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
let header = start + offsets[i];
|
|
170
|
-
let dataLength = new DataView(dataBuffer, header, 2).getInt16(0, true) & 0xFFFF;
|
|
171
|
-
if (isVarType == constant_1.ColumnsBlockType.VARCHAR) {
|
|
172
|
-
//decode var char
|
|
173
|
-
value = (0, taosResult_1.readVarchar)(dataBuffer, header + 2, dataLength);
|
|
174
|
-
}
|
|
175
|
-
else if (isVarType == constant_1.ColumnsBlockType.GEOMETRY || isVarType == constant_1.ColumnsBlockType.VARBINARY) {
|
|
176
|
-
//decode binary
|
|
177
|
-
value = (0, taosResult_1.readBinary)(dataBuffer, header + 2, dataLength);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
//decode nchar
|
|
181
|
-
value = (0, taosResult_1.readNchar)(dataBuffer, header + 2, dataLength);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
data.push(value);
|
|
185
|
-
}
|
|
186
|
-
bufferOffset += rows * 4;
|
|
187
|
-
}
|
|
188
|
-
bufferOffset += metaLens[i];
|
|
189
|
-
//column data to row data
|
|
190
|
-
for (let row = 0; row < data.length; row++) {
|
|
191
|
-
if (dataList[row] == null) {
|
|
192
|
-
dataList[row] = [];
|
|
193
|
-
}
|
|
194
|
-
dataList[row].push(data[row]);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
taosdata.push(...dataList);
|
|
198
|
-
}
|
|
199
|
-
return taosResult;
|
|
200
|
-
}
|
|
201
|
-
exports.parseTmqBlock = parseTmqBlock;
|
|
202
327
|
function getBitmapLen(n) {
|
|
203
328
|
return (n + 0x7) >> 3;
|
|
204
329
|
}
|