@clickhouse/client 0.2.3 → 0.2.4
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/README.md +1 -1
- package/dist/result_set.js +43 -18
- package/dist/result_set.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/result_set.js
CHANGED
|
@@ -25,8 +25,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.ResultSet = void 0;
|
|
27
27
|
const client_common_1 = require("@clickhouse/client-common");
|
|
28
|
+
const buffer_1 = require("buffer");
|
|
28
29
|
const stream_1 = __importStar(require("stream"));
|
|
29
30
|
const utils_1 = require("./utils");
|
|
31
|
+
const NEWLINE = 0x0a;
|
|
30
32
|
class ResultSet {
|
|
31
33
|
constructor(_stream, format, query_id) {
|
|
32
34
|
Object.defineProperty(this, "_stream", {
|
|
@@ -68,30 +70,53 @@ class ResultSet {
|
|
|
68
70
|
throw Error(streamAlreadyConsumedMessage);
|
|
69
71
|
}
|
|
70
72
|
(0, client_common_1.validateStreamFormat)(this.format);
|
|
71
|
-
let
|
|
73
|
+
let incompleteChunks = [];
|
|
72
74
|
const toRows = new stream_1.Transform({
|
|
73
|
-
transform(chunk,
|
|
74
|
-
decodedChunk += chunk.toString();
|
|
75
|
+
transform(chunk, _encoding, callback) {
|
|
75
76
|
const rows = [];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return (0, client_common_1.decode)(text, 'JSON');
|
|
86
|
-
},
|
|
87
|
-
});
|
|
77
|
+
let lastIdx = 0;
|
|
78
|
+
// first pass on the current chunk
|
|
79
|
+
// using the incomplete row from the previous chunks
|
|
80
|
+
let idx = chunk.indexOf(NEWLINE);
|
|
81
|
+
if (idx !== -1) {
|
|
82
|
+
let text;
|
|
83
|
+
if (incompleteChunks.length > 0) {
|
|
84
|
+
text = buffer_1.Buffer.concat([...incompleteChunks, chunk.subarray(0, idx)], incompleteChunks.reduce((sz, buf) => sz + buf.length, 0) + idx).toString();
|
|
85
|
+
incompleteChunks = [];
|
|
88
86
|
}
|
|
89
87
|
else {
|
|
90
|
-
|
|
88
|
+
text = chunk.subarray(0, idx).toString();
|
|
89
|
+
}
|
|
90
|
+
rows.push({
|
|
91
|
+
text,
|
|
92
|
+
json() {
|
|
93
|
+
return JSON.parse(text);
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
lastIdx = idx + 1; // skipping newline character
|
|
97
|
+
// consequent passes on the current chunk with at least one row parsed
|
|
98
|
+
// all previous chunks with incomplete rows were already processed
|
|
99
|
+
do {
|
|
100
|
+
idx = chunk.indexOf(NEWLINE, lastIdx);
|
|
101
|
+
if (idx !== -1) {
|
|
102
|
+
const text = chunk.subarray(lastIdx, idx).toString();
|
|
103
|
+
rows.push({
|
|
104
|
+
text,
|
|
105
|
+
json() {
|
|
106
|
+
return JSON.parse(text);
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
// to be processed during the first pass for the next chunk
|
|
112
|
+
incompleteChunks.push(chunk.subarray(lastIdx));
|
|
91
113
|
this.push(rows);
|
|
92
114
|
}
|
|
93
|
-
|
|
94
|
-
}
|
|
115
|
+
lastIdx = idx + 1; // skipping newline character
|
|
116
|
+
} while (idx !== -1);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
incompleteChunks.push(chunk); // this chunk does not contain a full row
|
|
95
120
|
}
|
|
96
121
|
callback();
|
|
97
122
|
},
|
package/dist/result_set.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result_set.js","sourceRoot":"","sources":["../../../packages/client-node/src/result_set.ts"],"names":[],"mappings":";;;;;;;;;;;;;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AA;gCACzB,CAAC;6BACF,CAAC,CAAA;yBACH;6BAAM;4BACL,2DAA2D;4BAC3D,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;4BAC9C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;yBAChB;wBACD,OAAO,GAAG,GAAG,GAAG,CAAC,CAAA,CAAC,6BAA6B;qBAChD,QAAQ,GAAG,KAAK,CAAC,CAAC,EAAC;iBACrB;qBAAM;oBACL,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA,CAAC,yCAAyC;iBACvE;gBACD,QAAQ,EAAE,CAAA;YACZ,CAAC;YACD,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,IAAI;SACjB,CAAC,CAAA;QAEF,OAAO,gBAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,UAAU,CAAC,GAAG;YAClE,IAAI,GAAG,EAAE;gBACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;aACnB;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAA;IACxB,CAAC;CACF;AAnGD,8BAmGC;AAED,MAAM,4BAA4B,GAAG,kCAAkC,CAAA"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "0.2.
|
|
1
|
+
declare const _default: "0.2.4";
|
|
2
2
|
export default _default;
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@clickhouse/client",
|
|
3
3
|
"description": "Official JS client for ClickHouse DB - Node.js implementation",
|
|
4
4
|
"homepage": "https://clickhouse.com",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.4",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"clickhouse",
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@clickhouse/client-common": "0.2.
|
|
26
|
+
"@clickhouse/client-common": "0.2.4"
|
|
27
27
|
}
|
|
28
28
|
}
|