@l-v-yonsama/multi-platform-database-drivers 0.1.102 → 0.1.105
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/built/src/drivers/BaseDriver.d.ts +3 -3
- package/built/src/drivers/MySQLDriver.d.ts +3 -3
- package/built/src/drivers/MySQLDriver.js +7 -7
- package/built/src/drivers/MySQLDriver.js.map +1 -1
- package/built/src/drivers/PostgresDriver.d.ts +3 -3
- package/built/src/drivers/PostgresDriver.js +6 -6
- package/built/src/drivers/PostgresDriver.js.map +1 -1
- package/built/src/drivers/RDSBaseDriver.d.ts +6 -6
- package/built/src/drivers/RDSBaseDriver.js +22 -16
- package/built/src/drivers/RDSBaseDriver.js.map +1 -1
- package/built/src/drivers/RedisDriver.d.ts +3 -3
- package/built/src/drivers/RedisDriver.js +13 -11
- package/built/src/drivers/RedisDriver.js.map +1 -1
- package/built/src/drivers/aws/AwsCloudwatchServiceClient.d.ts +5 -5
- package/built/src/drivers/aws/AwsCloudwatchServiceClient.js +7 -7
- package/built/src/drivers/aws/AwsCloudwatchServiceClient.js.map +1 -1
- package/built/src/drivers/aws/AwsS3ServiceClient.d.ts +3 -3
- package/built/src/drivers/aws/AwsS3ServiceClient.js +3 -3
- package/built/src/drivers/aws/AwsS3ServiceClient.js.map +1 -1
- package/built/src/drivers/aws/AwsSQSServiceClient.d.ts +3 -3
- package/built/src/drivers/aws/AwsSQSServiceClient.js +3 -3
- package/built/src/drivers/aws/AwsSQSServiceClient.js.map +1 -1
- package/built/src/examples/mysql.js.map +1 -1
- package/built/src/examples/rules.d.ts +1 -0
- package/built/src/examples/rules.js +31 -0
- package/built/src/examples/rules.js.map +1 -0
- package/built/src/helpers/ResourceHelper.d.ts +3 -2
- package/built/src/helpers/ResourceHelper.js +74 -13
- package/built/src/helpers/ResourceHelper.js.map +1 -1
- package/built/src/helpers/SQLHelper.js +2 -2
- package/built/src/helpers/SQLHelper.js.map +1 -1
- package/built/src/resource/ResultSetDataBuilder.d.ts +56 -0
- package/built/src/resource/{ResultSetDataHolder.js → ResultSetDataBuilder.js} +253 -290
- package/built/src/resource/ResultSetDataBuilder.js.map +1 -0
- package/built/src/resource/index.d.ts +1 -2
- package/built/src/resource/index.js +1 -2
- package/built/src/resource/index.js.map +1 -1
- package/built/src/types/resource/Annonations.d.ts +30 -21
- package/built/src/types/resource/Annonations.js +9 -15
- package/built/src/types/resource/Annonations.js.map +1 -1
- package/built/src/types/resource/ResultSetDataType.d.ts +64 -0
- package/built/src/types/resource/ResultSetDataType.js +6 -0
- package/built/src/types/resource/ResultSetDataType.js.map +1 -0
- package/built/src/types/resource/Rules.d.ts +14 -0
- package/built/src/types/resource/{ResultSetHelperMetadata.js → Rules.js} +1 -1
- package/built/src/types/resource/Rules.js.map +1 -0
- package/built/src/types/resource/index.d.ts +2 -1
- package/built/src/types/resource/index.js +2 -1
- package/built/src/types/resource/index.js.map +1 -1
- package/built/src/util.d.ts +1 -2
- package/built/src/util.js +1 -18
- package/built/src/util.js.map +1 -1
- package/package.json +4 -1
- package/built/src/resource/MultipleResultSetDataHolder.d.ts +0 -30
- package/built/src/resource/MultipleResultSetDataHolder.js +0 -107
- package/built/src/resource/MultipleResultSetDataHolder.js.map +0 -1
- package/built/src/resource/ResultSetDataHolder.d.ts +0 -99
- package/built/src/resource/ResultSetDataHolder.js.map +0 -1
- package/built/src/types/resource/ResultSetHelperMetadata.d.ts +0 -9
- package/built/src/types/resource/ResultSetHelperMetadata.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ResultSetDataBuilder = exports.RdhHelper = exports.RowHelper = exports.isResultSetDataBuilder = exports.createRdhKey = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const os = tslib_1.__importStar(require("os"));
|
|
6
6
|
const list_it_1 = tslib_1.__importDefault(require("list-it"));
|
|
@@ -10,22 +10,6 @@ const types_1 = require("../types");
|
|
|
10
10
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
11
11
|
const GeneralColumnUtil_1 = require("./GeneralColumnUtil");
|
|
12
12
|
const util_1 = require("../util");
|
|
13
|
-
class SampleClassPair {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.sample_values = [];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.SampleClassPair = SampleClassPair;
|
|
19
|
-
class SampleGroupByClass {
|
|
20
|
-
constructor(clazz_key, sample_keys) {
|
|
21
|
-
this.pairs = [];
|
|
22
|
-
this.sample_keys = [];
|
|
23
|
-
this.is_shuffled = false;
|
|
24
|
-
this.sample_keys = sample_keys;
|
|
25
|
-
this.clazz_key = clazz_key;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.SampleGroupByClass = SampleGroupByClass;
|
|
29
13
|
function createRdhKey({ name, type, width, comment, }) {
|
|
30
14
|
return {
|
|
31
15
|
name,
|
|
@@ -35,103 +19,113 @@ function createRdhKey({ name, type, width, comment, }) {
|
|
|
35
19
|
};
|
|
36
20
|
}
|
|
37
21
|
exports.createRdhKey = createRdhKey;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
this.meta[key].push(new types_1.CellAnnotation(type, options));
|
|
48
|
-
}
|
|
49
|
-
clearAllAnnotations() {
|
|
50
|
-
this.meta = {};
|
|
51
|
-
}
|
|
52
|
-
clearAnnotations(type) {
|
|
53
|
-
if (this.meta) {
|
|
54
|
-
const meta_keys = Object.keys(this.meta);
|
|
55
|
-
if (meta_keys && meta_keys.length > 0) {
|
|
56
|
-
for (let i = 0; i < meta_keys.length; i++) {
|
|
57
|
-
const annotations = this.meta[meta_keys[i]];
|
|
58
|
-
if (annotations) {
|
|
59
|
-
for (let j = 0; j < annotations.length; j++) {
|
|
60
|
-
if (annotations[j].type === type) {
|
|
61
|
-
annotations.splice(j, 1);
|
|
62
|
-
j--;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
22
|
+
function isResultSetDataBuilder(item) {
|
|
23
|
+
return item.rs && (0, types_1.isResultSetData)(item.rs);
|
|
24
|
+
}
|
|
25
|
+
exports.isResultSetDataBuilder = isResultSetDataBuilder;
|
|
26
|
+
function toRdhKeys(keys) {
|
|
27
|
+
return keys.map((k) => {
|
|
28
|
+
if (typeof k === 'string') {
|
|
29
|
+
return createRdhKey({ name: k });
|
|
68
30
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
31
|
+
else {
|
|
32
|
+
return k;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
class RowHelper {
|
|
37
|
+
static getRuleEngineValues(row, keys) {
|
|
38
|
+
const ret = {};
|
|
39
|
+
keys.forEach((key) => {
|
|
40
|
+
const v = row.values[key.name];
|
|
41
|
+
if ((0, GeneralColumnUtil_1.isDateTimeOrDate)(key.type)) {
|
|
42
|
+
if (v === null || v === undefined) {
|
|
43
|
+
ret[key.name] = v;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
ret[key.name] = (0, dayjs_1.default)(v).format('YYYY-MM-DD HH:mm:ss');
|
|
82
47
|
}
|
|
83
48
|
}
|
|
49
|
+
else {
|
|
50
|
+
ret[key.name] = v;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return ret;
|
|
54
|
+
}
|
|
55
|
+
static pushAnnotation(row, key, annotation) {
|
|
56
|
+
if (row.meta[key] === undefined) {
|
|
57
|
+
row.meta[key] = new Array();
|
|
84
58
|
}
|
|
85
|
-
|
|
59
|
+
row.meta[key].push(annotation);
|
|
86
60
|
}
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
const annotations =
|
|
61
|
+
static getFirstAnnotationOf(row, key, type) {
|
|
62
|
+
if (row.meta[key]) {
|
|
63
|
+
const annotations = row.meta[key];
|
|
90
64
|
if (annotations) {
|
|
91
65
|
return annotations.find((a) => a.type === type);
|
|
92
66
|
}
|
|
93
67
|
}
|
|
94
68
|
return undefined;
|
|
95
69
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
70
|
+
static clearAllAnnotations(row) {
|
|
71
|
+
Object.keys(row.meta).forEach((key) => {
|
|
72
|
+
delete row.meta[key];
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
static clearAnnotationByType(row, type) {
|
|
76
|
+
const meta_keys = Object.keys(row.meta);
|
|
77
|
+
if (meta_keys.length > 0) {
|
|
78
|
+
for (let i = 0; i < meta_keys.length; i++) {
|
|
79
|
+
const annotations = row.meta[meta_keys[i]];
|
|
80
|
+
if (!annotations) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
for (let j = 0; j < annotations.length; j++) {
|
|
84
|
+
if (annotations[j].type === type) {
|
|
85
|
+
annotations.splice(j, 1);
|
|
86
|
+
j--;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
102
89
|
}
|
|
103
90
|
}
|
|
104
|
-
return r;
|
|
105
91
|
}
|
|
106
|
-
hasAnyAnnotation(types) {
|
|
92
|
+
static hasAnyAnnotation(row, types) {
|
|
107
93
|
var _a, _b, _c;
|
|
108
|
-
if (
|
|
109
|
-
return ((_c = (_b = (_a = Object.values(
|
|
94
|
+
if (row.meta && types.length) {
|
|
95
|
+
return ((_c = (_b = (_a = Object.values(row.meta)) === null || _a === void 0 ? void 0 : _a.flat()) === null || _b === void 0 ? void 0 : _b.some((it) => types.includes(it.type))) !== null && _c !== void 0 ? _c : false);
|
|
110
96
|
}
|
|
111
97
|
return false;
|
|
112
98
|
}
|
|
113
|
-
hasAnnotation(type) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
99
|
+
static hasAnnotation(row, type) {
|
|
100
|
+
return this.hasAnyAnnotation(row, [type]);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.RowHelper = RowHelper;
|
|
104
|
+
class RdhHelper {
|
|
105
|
+
static clearAllAnotations(rdh) {
|
|
106
|
+
rdh.rows.forEach((row) => RowHelper.clearAllAnnotations(row));
|
|
119
107
|
}
|
|
120
108
|
}
|
|
121
|
-
exports.
|
|
122
|
-
class
|
|
109
|
+
exports.RdhHelper = RdhHelper;
|
|
110
|
+
class ResultSetDataBuilder {
|
|
123
111
|
constructor(keys) {
|
|
124
|
-
this.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
112
|
+
this.rs = {
|
|
113
|
+
created: new Date(),
|
|
114
|
+
keys: toRdhKeys(keys),
|
|
115
|
+
rows: [],
|
|
116
|
+
meta: {},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
build() {
|
|
120
|
+
return this.rs;
|
|
129
121
|
}
|
|
130
|
-
|
|
131
|
-
|
|
122
|
+
updateMeta(params) {
|
|
123
|
+
Object.entries(params).forEach(([k, v]) => {
|
|
124
|
+
this.rs.meta[k] = v;
|
|
125
|
+
});
|
|
132
126
|
}
|
|
133
127
|
static createEmpty() {
|
|
134
|
-
const rdh = new
|
|
128
|
+
const rdh = new ResultSetDataBuilder([
|
|
135
129
|
{
|
|
136
130
|
name: 'message',
|
|
137
131
|
comment: '',
|
|
@@ -140,17 +134,17 @@ class ResultSetDataHolder {
|
|
|
140
134
|
},
|
|
141
135
|
]);
|
|
142
136
|
rdh.addRow({ message: 'empty result set' });
|
|
143
|
-
return rdh;
|
|
137
|
+
return rdh.build();
|
|
144
138
|
}
|
|
145
139
|
static from(list, options) {
|
|
146
140
|
if (list === undefined || list === null || list === '') {
|
|
147
141
|
throw new Error(typeof list + ' has no value.');
|
|
148
142
|
}
|
|
149
|
-
const clone = () => {
|
|
143
|
+
const clone = (obj) => {
|
|
150
144
|
var _a;
|
|
151
|
-
const plainObj = JSON.parse(JSON.stringify(
|
|
152
|
-
const
|
|
153
|
-
const dateKeys =
|
|
145
|
+
const plainObj = JSON.parse(JSON.stringify(obj));
|
|
146
|
+
const rdb = new ResultSetDataBuilder(plainObj.keys);
|
|
147
|
+
const dateKeys = rdb.rs.keys
|
|
154
148
|
.filter((k) => (0, GeneralColumnUtil_1.isDateTimeOrDate)(k.type))
|
|
155
149
|
.map((k) => k.name);
|
|
156
150
|
(_a = plainObj.rows) === null || _a === void 0 ? void 0 : _a.forEach((row) => {
|
|
@@ -158,27 +152,29 @@ class ResultSetDataHolder {
|
|
|
158
152
|
for (const dateKey of dateKeys) {
|
|
159
153
|
values[dateKey] = (0, util_1.toDate)(values[dateKey]);
|
|
160
154
|
}
|
|
161
|
-
|
|
155
|
+
rdb.addRow(values, meta);
|
|
162
156
|
});
|
|
163
157
|
if (plainObj.meta) {
|
|
164
158
|
Object.keys(plainObj.meta).forEach((key) => {
|
|
165
|
-
|
|
159
|
+
rdb.rs.meta[key] = plainObj.meta[key];
|
|
166
160
|
});
|
|
167
161
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return
|
|
162
|
+
rdb.rs['created'] = (0, util_1.toDate)(plainObj.created);
|
|
163
|
+
rdb.rs.sqlStatement = plainObj.sqlStatement;
|
|
164
|
+
rdb.rs.shuffledIndexes = plainObj.shuffledIndexes;
|
|
165
|
+
rdb.rs.shuffledNextCounter = plainObj.shuffledNextCounter;
|
|
166
|
+
rdb.rs.mergeCells = plainObj.mergeCells;
|
|
167
|
+
rdb.rs.queryConditions = plainObj.queryConditions;
|
|
168
|
+
return rdb;
|
|
175
169
|
};
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
170
|
+
if ((0, types_1.isResultSetData)(list)) {
|
|
171
|
+
return clone(list);
|
|
172
|
+
}
|
|
173
|
+
if (isResultSetDataBuilder(list)) {
|
|
174
|
+
return clone(list.rs);
|
|
179
175
|
}
|
|
180
176
|
const t = typeof list;
|
|
181
|
-
let ret
|
|
177
|
+
let ret;
|
|
182
178
|
const strTitles = [];
|
|
183
179
|
if (options === null || options === void 0 ? void 0 : options.keyNames) {
|
|
184
180
|
strTitles.push(...options.keyNames);
|
|
@@ -191,7 +187,7 @@ class ResultSetDataHolder {
|
|
|
191
187
|
while (strTitles.length < elm.length) {
|
|
192
188
|
strTitles.push(`K${i++}`);
|
|
193
189
|
}
|
|
194
|
-
ret = new
|
|
190
|
+
ret = new ResultSetDataBuilder(strTitles);
|
|
195
191
|
for (let r = 0; r < list.length; r++) {
|
|
196
192
|
elm = list[r];
|
|
197
193
|
const values = {};
|
|
@@ -204,9 +200,6 @@ class ResultSetDataHolder {
|
|
|
204
200
|
}
|
|
205
201
|
}
|
|
206
202
|
else {
|
|
207
|
-
if (list.keys && list.rows) {
|
|
208
|
-
return clone();
|
|
209
|
-
}
|
|
210
203
|
switch (t) {
|
|
211
204
|
case 'object':
|
|
212
205
|
if (strTitles.length !== 2) {
|
|
@@ -215,7 +208,7 @@ class ResultSetDataHolder {
|
|
|
215
208
|
strTitles.push('TYPE');
|
|
216
209
|
strTitles.push('VALUE');
|
|
217
210
|
}
|
|
218
|
-
ret = new
|
|
211
|
+
ret = new ResultSetDataBuilder(strTitles);
|
|
219
212
|
Object.keys(list).forEach((k) => {
|
|
220
213
|
const v = list[k];
|
|
221
214
|
let type = typeof v;
|
|
@@ -241,7 +234,7 @@ class ResultSetDataHolder {
|
|
|
241
234
|
}
|
|
242
235
|
describe() {
|
|
243
236
|
const desc_keys = new Array();
|
|
244
|
-
this.keys
|
|
237
|
+
this.rs.keys
|
|
245
238
|
.filter((k) => (0, GeneralColumnUtil_1.isNumericLike)(k.type))
|
|
246
239
|
.forEach((k) => {
|
|
247
240
|
var _a;
|
|
@@ -252,7 +245,7 @@ class ResultSetDataHolder {
|
|
|
252
245
|
});
|
|
253
246
|
});
|
|
254
247
|
desc_keys.unshift(createRdhKey({ name: 'stat', type: types_1.GeneralColumnType.TEXT }));
|
|
255
|
-
const ret = new
|
|
248
|
+
const ret = new ResultSetDataBuilder(desc_keys);
|
|
256
249
|
const count_values = { stat: 'count' };
|
|
257
250
|
const mean_values = { stat: 'mean' };
|
|
258
251
|
const std_values = { stat: 'std' };
|
|
@@ -261,7 +254,7 @@ class ResultSetDataHolder {
|
|
|
261
254
|
const median_values = { stat: '50%' };
|
|
262
255
|
const quatile75_values = { stat: '75%' };
|
|
263
256
|
const max_values = { stat: 'max' };
|
|
264
|
-
this.keys.forEach((key) => {
|
|
257
|
+
this.rs.keys.forEach((key) => {
|
|
265
258
|
const num_list = this.toVector(key.name, true);
|
|
266
259
|
count_values[key.name] = num_list.length;
|
|
267
260
|
mean_values[key.name] = num_list.length === 0 ? '-' : ss.mean(num_list);
|
|
@@ -284,7 +277,7 @@ class ResultSetDataHolder {
|
|
|
284
277
|
ret.addRow(median_values);
|
|
285
278
|
ret.addRow(quatile75_values);
|
|
286
279
|
ret.addRow(max_values);
|
|
287
|
-
return ret;
|
|
280
|
+
return ret.build();
|
|
288
281
|
}
|
|
289
282
|
splitRows(test_percentage, with_shuffle = false) {
|
|
290
283
|
if (test_percentage >= 100) {
|
|
@@ -293,22 +286,24 @@ class ResultSetDataHolder {
|
|
|
293
286
|
if (test_percentage < 0) {
|
|
294
287
|
test_percentage = 0;
|
|
295
288
|
}
|
|
296
|
-
const numTestExamples = Math.round((this.rows.length * test_percentage) / 100);
|
|
297
|
-
const numTrainExamples = this.rows.length - numTestExamples;
|
|
298
|
-
const train = new
|
|
299
|
-
const test = new
|
|
300
|
-
const cloned_rows = this.rows.slice();
|
|
289
|
+
const numTestExamples = Math.round((this.rs.rows.length * test_percentage) / 100);
|
|
290
|
+
const numTrainExamples = this.rs.rows.length - numTestExamples;
|
|
291
|
+
const train = new ResultSetDataBuilder(this.rs.keys);
|
|
292
|
+
const test = new ResultSetDataBuilder(this.rs.keys);
|
|
293
|
+
const cloned_rows = this.rs.rows.slice();
|
|
301
294
|
if (with_shuffle) {
|
|
302
295
|
(0, shuffle_array_1.default)(cloned_rows);
|
|
303
296
|
}
|
|
304
|
-
train.rows
|
|
305
|
-
test.rows
|
|
306
|
-
|
|
297
|
+
train.rs.rows.splice(0, train.rs.rows.length);
|
|
298
|
+
test.rs.rows.splice(0, test.rs.rows.length);
|
|
299
|
+
train.rs.rows.push(...cloned_rows.slice(0, numTrainExamples));
|
|
300
|
+
test.rs.rows.push(...cloned_rows.slice(numTrainExamples));
|
|
301
|
+
return [train.build(), test.build()];
|
|
307
302
|
}
|
|
308
|
-
sampleXKeysGroupByClass(numExamplesPerClass, xKeys,
|
|
309
|
-
const ret =
|
|
303
|
+
sampleXKeysGroupByClass(numExamplesPerClass, xKeys, clazzKey, shuffle = false) {
|
|
304
|
+
const ret = { clazzKey, sampleKeys: xKeys };
|
|
310
305
|
const localIndexes = new Array();
|
|
311
|
-
for (let i = 0; i < this.rows.length; i++) {
|
|
306
|
+
for (let i = 0; i < this.rs.rows.length; i++) {
|
|
312
307
|
localIndexes.push(i);
|
|
313
308
|
}
|
|
314
309
|
if (shuffle) {
|
|
@@ -316,31 +311,33 @@ class ResultSetDataHolder {
|
|
|
316
311
|
(0, shuffle_array_1.default)(localIndexes);
|
|
317
312
|
}
|
|
318
313
|
const uniqClassValueSets = new Set();
|
|
319
|
-
for (let j = 0; j < this.rows.length; j++) {
|
|
320
|
-
const row = this.rows[localIndexes[j]];
|
|
321
|
-
const clazz_value = row.values[
|
|
314
|
+
for (let j = 0; j < this.rs.rows.length; j++) {
|
|
315
|
+
const row = this.rs.rows[localIndexes[j]];
|
|
316
|
+
const clazz_value = row.values[clazzKey];
|
|
322
317
|
uniqClassValueSets.add(clazz_value);
|
|
323
318
|
}
|
|
324
319
|
const uniqClassValues = Array.from(uniqClassValueSets).sort();
|
|
325
320
|
uniqClassValues.forEach((uniq) => {
|
|
326
|
-
const pair =
|
|
327
|
-
|
|
321
|
+
const pair = {
|
|
322
|
+
clazzValue: uniq,
|
|
323
|
+
sampleValues: [],
|
|
324
|
+
};
|
|
328
325
|
ret.pairs.push(pair);
|
|
329
326
|
});
|
|
330
|
-
for (let j = 0; j < this.rows.length; j++) {
|
|
331
|
-
const row = this.rows[localIndexes[j]];
|
|
327
|
+
for (let j = 0; j < this.rs.rows.length; j++) {
|
|
328
|
+
const row = this.rs.rows[localIndexes[j]];
|
|
332
329
|
const innerX = new Array();
|
|
333
330
|
xKeys.forEach((k) => {
|
|
334
331
|
innerX.push(row.values[k]);
|
|
335
332
|
});
|
|
336
|
-
const clazz_value = row.values[
|
|
337
|
-
const pair = ret.pairs.find((pair) => pair.
|
|
338
|
-
if (pair && pair.
|
|
339
|
-
pair.
|
|
333
|
+
const clazz_value = row.values[clazzKey];
|
|
334
|
+
const pair = ret.pairs.find((pair) => pair.clazzValue === clazz_value);
|
|
335
|
+
if (pair && pair.sampleValues.length < numExamplesPerClass) {
|
|
336
|
+
pair.sampleValues.push(innerX);
|
|
340
337
|
}
|
|
341
338
|
let num_full_clazz = 0;
|
|
342
339
|
ret.pairs.forEach((pair) => {
|
|
343
|
-
if (pair.
|
|
340
|
+
if (pair.sampleValues.length >= numExamplesPerClass) {
|
|
344
341
|
num_full_clazz++;
|
|
345
342
|
}
|
|
346
343
|
});
|
|
@@ -351,42 +348,42 @@ class ResultSetDataHolder {
|
|
|
351
348
|
return ret;
|
|
352
349
|
}
|
|
353
350
|
nextXYBatch(batch_size, xKeys, yKey) {
|
|
354
|
-
if (this.shuffledNextCounter === undefined) {
|
|
355
|
-
this.shuffledNextCounter = 0;
|
|
356
|
-
this.shuffledIndexes = new Array();
|
|
357
|
-
for (let i = 0; i < this.rows.length; i++) {
|
|
358
|
-
this.shuffledIndexes.push(i);
|
|
351
|
+
if (this.rs.shuffledNextCounter === undefined) {
|
|
352
|
+
this.rs.shuffledNextCounter = 0;
|
|
353
|
+
this.rs.shuffledIndexes = new Array();
|
|
354
|
+
for (let i = 0; i < this.rs.rows.length; i++) {
|
|
355
|
+
this.rs.shuffledIndexes.push(i);
|
|
359
356
|
}
|
|
360
|
-
(0, shuffle_array_1.default)(this.shuffledIndexes);
|
|
357
|
+
(0, shuffle_array_1.default)(this.rs.shuffledIndexes);
|
|
361
358
|
}
|
|
362
359
|
const x = new Array();
|
|
363
360
|
const y = new Array();
|
|
364
361
|
for (let j = 0; j < batch_size; j++) {
|
|
365
|
-
const row = this.rows[this.shuffledIndexes[this.shuffledNextCounter]];
|
|
362
|
+
const row = this.rs.rows[this.rs.shuffledIndexes[this.rs.shuffledNextCounter]];
|
|
366
363
|
const innerX = new Array();
|
|
367
364
|
xKeys.forEach((k) => {
|
|
368
365
|
innerX.push(row.values[k]);
|
|
369
366
|
});
|
|
370
367
|
x.push(innerX);
|
|
371
368
|
y.push(row.values[yKey]);
|
|
372
|
-
this.shuffledNextCounter++;
|
|
373
|
-
if (this.rows.length <= this.shuffledNextCounter) {
|
|
374
|
-
(0, shuffle_array_1.default)(this.shuffledIndexes);
|
|
375
|
-
this.shuffledNextCounter = 0;
|
|
369
|
+
this.rs.shuffledNextCounter++;
|
|
370
|
+
if (this.rs.rows.length <= this.rs.shuffledNextCounter) {
|
|
371
|
+
(0, shuffle_array_1.default)(this.rs.shuffledIndexes);
|
|
372
|
+
this.rs.shuffledNextCounter = 0;
|
|
376
373
|
}
|
|
377
374
|
}
|
|
378
375
|
return [x, y];
|
|
379
376
|
}
|
|
380
377
|
hasKey(key) {
|
|
381
|
-
return this.keys.some((k) => k.name === key);
|
|
378
|
+
return this.rs.keys.some((k) => k.name === key);
|
|
382
379
|
}
|
|
383
380
|
drop(key) {
|
|
384
381
|
if (this.hasKey(key)) {
|
|
385
|
-
this.rows.forEach((v) => {
|
|
382
|
+
this.rs.rows.forEach((v) => {
|
|
386
383
|
delete v.values[key];
|
|
387
384
|
});
|
|
388
|
-
const idx = this.keys.findIndex((k) => k.name === key);
|
|
389
|
-
this.keys.splice(idx, 1);
|
|
385
|
+
const idx = this.rs.keys.findIndex((k) => k.name === key);
|
|
386
|
+
this.rs.keys.splice(idx, 1);
|
|
390
387
|
}
|
|
391
388
|
}
|
|
392
389
|
assign(key, list) {
|
|
@@ -397,13 +394,13 @@ class ResultSetDataHolder {
|
|
|
397
394
|
this.drop(key);
|
|
398
395
|
if (constructor === 'Float32Array' || constructor === 'Float64Array') {
|
|
399
396
|
list = Array.from(list);
|
|
400
|
-
this.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.NUMERIC }));
|
|
397
|
+
this.rs.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.NUMERIC }));
|
|
401
398
|
}
|
|
402
399
|
else if (constructor === 'Int8Array' ||
|
|
403
400
|
constructor === 'Int16Array' ||
|
|
404
401
|
constructor === 'Int32Array') {
|
|
405
402
|
list = Array.from(list);
|
|
406
|
-
this.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.INTEGER }));
|
|
403
|
+
this.rs.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.INTEGER }));
|
|
407
404
|
}
|
|
408
405
|
else {
|
|
409
406
|
const types = new Set();
|
|
@@ -413,20 +410,20 @@ class ResultSetDataHolder {
|
|
|
413
410
|
}
|
|
414
411
|
});
|
|
415
412
|
if (types.size === 1 && types.has('number')) {
|
|
416
|
-
this.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.NUMERIC }));
|
|
413
|
+
this.rs.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.NUMERIC }));
|
|
417
414
|
}
|
|
418
415
|
else {
|
|
419
|
-
this.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.UNKNOWN }));
|
|
416
|
+
this.rs.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.UNKNOWN }));
|
|
420
417
|
}
|
|
421
418
|
}
|
|
422
419
|
list.forEach((v, i) => {
|
|
423
|
-
this.rows[i].values[key] = v;
|
|
420
|
+
this.rs.rows[i].values[key] = v;
|
|
424
421
|
});
|
|
425
422
|
}
|
|
426
423
|
assignFromDictionary(new_key, existing_key, dictionary) {
|
|
427
424
|
this.drop(new_key);
|
|
428
|
-
this.keys.push(createRdhKey({ name: new_key, type: types_1.GeneralColumnType.TEXT }));
|
|
429
|
-
this.rows.forEach((row) => {
|
|
425
|
+
this.rs.keys.push(createRdhKey({ name: new_key, type: types_1.GeneralColumnType.TEXT }));
|
|
426
|
+
this.rs.rows.forEach((row) => {
|
|
430
427
|
const existing_val = row.values[existing_key];
|
|
431
428
|
if (existing_val === undefined ||
|
|
432
429
|
existing_val === '' ||
|
|
@@ -445,7 +442,7 @@ class ResultSetDataHolder {
|
|
|
445
442
|
}
|
|
446
443
|
toVector(key_name, is_only_number = false) {
|
|
447
444
|
const retList = new Array();
|
|
448
|
-
this.rows.forEach((row) => {
|
|
445
|
+
this.rs.rows.forEach((row) => {
|
|
449
446
|
const v = row.values[key_name];
|
|
450
447
|
if (is_only_number) {
|
|
451
448
|
if (isFinite(v) && v !== '' && v !== null) {
|
|
@@ -460,7 +457,7 @@ class ResultSetDataHolder {
|
|
|
460
457
|
}
|
|
461
458
|
toMatrixArray(key_names) {
|
|
462
459
|
const retList = new Array();
|
|
463
|
-
this.rows.forEach((row) => {
|
|
460
|
+
this.rs.rows.forEach((row) => {
|
|
464
461
|
const retRow = new Array();
|
|
465
462
|
if (key_names && key_names.length > 0) {
|
|
466
463
|
key_names.forEach((key_name) => {
|
|
@@ -468,7 +465,7 @@ class ResultSetDataHolder {
|
|
|
468
465
|
});
|
|
469
466
|
}
|
|
470
467
|
else {
|
|
471
|
-
this.keys.forEach((key) => {
|
|
468
|
+
this.rs.keys.forEach((key) => {
|
|
472
469
|
retRow.push(row.values[key.name]);
|
|
473
470
|
});
|
|
474
471
|
}
|
|
@@ -479,8 +476,8 @@ class ResultSetDataHolder {
|
|
|
479
476
|
toCsv(params) {
|
|
480
477
|
const { withType, withComment, keyNames } = Object.assign({ withType: false, withComment: false, keyNames: [] }, params);
|
|
481
478
|
const rdhKeys = keyNames.length > 0
|
|
482
|
-
? this.keys.filter((k) => keyNames.includes(k.name))
|
|
483
|
-
: this.keys;
|
|
479
|
+
? this.rs.keys.filter((k) => keyNames.includes(k.name))
|
|
480
|
+
: this.rs.keys;
|
|
484
481
|
if (rdhKeys.length < 0) {
|
|
485
482
|
return 'No Keys.';
|
|
486
483
|
}
|
|
@@ -494,7 +491,7 @@ class ResultSetDataHolder {
|
|
|
494
491
|
.map((k) => this.toCsvString((0, GeneralColumnUtil_1.displayGeneralColumnType)(k.type)))
|
|
495
492
|
.join(','));
|
|
496
493
|
}
|
|
497
|
-
this.rows.forEach((row) => {
|
|
494
|
+
this.rs.rows.forEach((row) => {
|
|
498
495
|
const retRow = new Array();
|
|
499
496
|
rdhKeys.forEach((key) => {
|
|
500
497
|
retRow.push(this.toCsvString(row.values[key.name], key.type));
|
|
@@ -506,8 +503,8 @@ class ResultSetDataHolder {
|
|
|
506
503
|
toMarkdown(params) {
|
|
507
504
|
const { withType, withComment, keyNames } = Object.assign({ withType: false, withComment: false, keyNames: [] }, params);
|
|
508
505
|
const rdhKeys = keyNames.length > 0
|
|
509
|
-
? this.keys.filter((k) => keyNames.includes(k.name))
|
|
510
|
-
: this.keys;
|
|
506
|
+
? this.rs.keys.filter((k) => keyNames.includes(k.name))
|
|
507
|
+
: this.rs.keys;
|
|
511
508
|
if (rdhKeys.length < 0) {
|
|
512
509
|
return 'No Keys.';
|
|
513
510
|
}
|
|
@@ -523,7 +520,7 @@ class ResultSetDataHolder {
|
|
|
523
520
|
.map((k) => this.toMarkdownString((0, GeneralColumnUtil_1.displayGeneralColumnType)(k.type)))
|
|
524
521
|
.join(' | '));
|
|
525
522
|
}
|
|
526
|
-
this.rows.forEach((row) => {
|
|
523
|
+
this.rs.rows.forEach((row) => {
|
|
527
524
|
const retRow = new Array();
|
|
528
525
|
rdhKeys.forEach((key) => {
|
|
529
526
|
retRow.push(this.toMarkdownString(row.values[key.name], key.type));
|
|
@@ -532,49 +529,96 @@ class ResultSetDataHolder {
|
|
|
532
529
|
});
|
|
533
530
|
return retList.join(os.EOL);
|
|
534
531
|
}
|
|
532
|
+
toString(params) {
|
|
533
|
+
const { maxPrintLines, withType, withComment, keyNames } = Object.assign({ maxPrintLines: 8, withType: false, withComment: false, keyNames: [] }, params);
|
|
534
|
+
const rdhKeys = keyNames.length > 0
|
|
535
|
+
? this.rs.keys.filter((k) => keyNames.includes(k.name))
|
|
536
|
+
: this.rs.keys;
|
|
537
|
+
if (rdhKeys.length < 0) {
|
|
538
|
+
return 'No Keys.';
|
|
539
|
+
}
|
|
540
|
+
const buf = list_it_1.default.buffer();
|
|
541
|
+
buf.d('ROW');
|
|
542
|
+
rdhKeys.forEach((k) => buf.d(this.toShortString(k.name)));
|
|
543
|
+
buf.nl();
|
|
544
|
+
if (withComment) {
|
|
545
|
+
buf.d('');
|
|
546
|
+
rdhKeys.forEach((k) => { var _a; return buf.d((_a = this.toShortString(k.comment)) !== null && _a !== void 0 ? _a : ''); });
|
|
547
|
+
buf.nl();
|
|
548
|
+
}
|
|
549
|
+
if (withType) {
|
|
550
|
+
buf.d((0, GeneralColumnUtil_1.displayGeneralColumnType)(types_1.GeneralColumnType.INTEGER));
|
|
551
|
+
rdhKeys.forEach((k) => {
|
|
552
|
+
buf.d((0, GeneralColumnUtil_1.displayGeneralColumnType)(k.type));
|
|
553
|
+
});
|
|
554
|
+
buf.nl();
|
|
555
|
+
}
|
|
556
|
+
if (this.rs.rows.length <= maxPrintLines) {
|
|
557
|
+
this.rs.rows.forEach((v, idx) => {
|
|
558
|
+
buf.d(idx + 1);
|
|
559
|
+
rdhKeys.forEach((k) => {
|
|
560
|
+
buf.d(this.toShortString(v.values[k.name], k.type));
|
|
561
|
+
});
|
|
562
|
+
buf.nl();
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
else {
|
|
566
|
+
const num_of_head = Math.ceil(maxPrintLines / 2);
|
|
567
|
+
this.rs.rows.slice(0, num_of_head).forEach((v, idx) => {
|
|
568
|
+
buf.d(idx + 1);
|
|
569
|
+
rdhKeys.forEach((k) => {
|
|
570
|
+
buf.d(this.toShortString(v.values[k.name], k.type));
|
|
571
|
+
});
|
|
572
|
+
buf.nl();
|
|
573
|
+
});
|
|
574
|
+
buf.d('...');
|
|
575
|
+
rdhKeys.forEach(() => {
|
|
576
|
+
buf.d('...');
|
|
577
|
+
});
|
|
578
|
+
buf.nl();
|
|
579
|
+
this.rs.rows
|
|
580
|
+
.slice(this.rs.rows.length - num_of_head, this.rs.rows.length)
|
|
581
|
+
.forEach((v, idx) => {
|
|
582
|
+
buf.d(this.rs.rows.length - num_of_head + idx + 1);
|
|
583
|
+
rdhKeys.forEach((k) => {
|
|
584
|
+
buf.d(this.toShortString(v.values[k.name], k.type));
|
|
585
|
+
});
|
|
586
|
+
buf.nl();
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
if (this.rs.rows.length === 0) {
|
|
590
|
+
return buf.toString() + 'No records.';
|
|
591
|
+
}
|
|
592
|
+
return buf.toString();
|
|
593
|
+
}
|
|
535
594
|
addRow(recordData, default_meta) {
|
|
536
595
|
let meta = {};
|
|
537
596
|
if (default_meta) {
|
|
538
597
|
meta = default_meta;
|
|
539
598
|
}
|
|
540
599
|
const values = {};
|
|
541
|
-
this.keys.forEach((key) => {
|
|
600
|
+
this.rs.keys.forEach((key) => {
|
|
542
601
|
const v = recordData[key.name];
|
|
543
602
|
values[key.name] = v;
|
|
544
603
|
});
|
|
545
|
-
this.rows.push(
|
|
604
|
+
this.rs.rows.push({ meta, values });
|
|
546
605
|
}
|
|
547
606
|
clearRows() {
|
|
548
|
-
this.rows.splice(0, this.rows.length);
|
|
549
|
-
}
|
|
550
|
-
copyFrom(that) {
|
|
551
|
-
this.clearRows();
|
|
552
|
-
this.keys.splice(0, this.keys.length);
|
|
553
|
-
this.setKeys(that.keys);
|
|
554
|
-
that.rows.forEach((v) => {
|
|
555
|
-
this.addRow(v);
|
|
556
|
-
});
|
|
607
|
+
this.rs.rows.splice(0, this.rs.rows.length);
|
|
557
608
|
}
|
|
558
609
|
setSqlStatement(sqlStatement) {
|
|
559
|
-
this.sqlStatement = sqlStatement;
|
|
610
|
+
this.rs.sqlStatement = sqlStatement;
|
|
560
611
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
for (let i = 0; i < this.rows.length; i++) {
|
|
564
|
-
if (this.rows[i].hasAnnotation(type)) {
|
|
565
|
-
r = true;
|
|
566
|
-
break;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
return r;
|
|
612
|
+
hasAnyAnnotation(types) {
|
|
613
|
+
return this.rs.rows.some((row) => RowHelper.hasAnyAnnotation(row, types));
|
|
570
614
|
}
|
|
571
615
|
fillnull(how) {
|
|
572
|
-
this.keys
|
|
616
|
+
this.rs.keys
|
|
573
617
|
.filter((k) => (0, GeneralColumnUtil_1.isNumericLike)(k.type))
|
|
574
618
|
.forEach((k) => {
|
|
575
619
|
const num_list = new Array();
|
|
576
|
-
for (let i = 0; i < this.rows.length; i++) {
|
|
577
|
-
const v = this.rows[i].values[k.name];
|
|
620
|
+
for (let i = 0; i < this.rs.rows.length; i++) {
|
|
621
|
+
const v = this.rs.rows[i].values[k.name];
|
|
578
622
|
if (isFinite(v) && v !== '') {
|
|
579
623
|
num_list.push(v);
|
|
580
624
|
}
|
|
@@ -588,19 +632,19 @@ class ResultSetDataHolder {
|
|
|
588
632
|
new_value = ss.median(num_list);
|
|
589
633
|
break;
|
|
590
634
|
}
|
|
591
|
-
for (let i = 0; i < this.rows.length; i++) {
|
|
592
|
-
if (this.rows[i].values[k.name] === null) {
|
|
593
|
-
this.rows[i].values[k.name] = new_value;
|
|
635
|
+
for (let i = 0; i < this.rs.rows.length; i++) {
|
|
636
|
+
if (this.rs.rows[i].values[k.name] === null) {
|
|
637
|
+
this.rs.rows[i].values[k.name] = new_value;
|
|
594
638
|
}
|
|
595
639
|
}
|
|
596
640
|
});
|
|
597
641
|
}
|
|
598
642
|
resetKeyTypeByRows() {
|
|
599
|
-
this.keys.forEach((k) => {
|
|
600
|
-
const length = this.rows.length;
|
|
643
|
+
this.rs.keys.forEach((k) => {
|
|
644
|
+
const length = this.rs.rows.length;
|
|
601
645
|
const types = new Set();
|
|
602
646
|
for (let i = 0; i < length; i++) {
|
|
603
|
-
const v = this.rows[i].values[k.name];
|
|
647
|
+
const v = this.rs.rows[i].values[k.name];
|
|
604
648
|
if (v === '' || v === null) {
|
|
605
649
|
continue;
|
|
606
650
|
}
|
|
@@ -609,39 +653,20 @@ class ResultSetDataHolder {
|
|
|
609
653
|
if (types.size === 1 && types.has('number')) {
|
|
610
654
|
k.type = types_1.GeneralColumnType.NUMERIC;
|
|
611
655
|
for (let i = 0; i < length; i++) {
|
|
612
|
-
if (this.rows[i].values[k.name] === '') {
|
|
613
|
-
this.rows[i].values[k.name] = null;
|
|
656
|
+
if (this.rs.rows[i].values[k.name] === '') {
|
|
657
|
+
this.rs.rows[i].values[k.name] = null;
|
|
614
658
|
}
|
|
615
659
|
}
|
|
616
660
|
}
|
|
617
661
|
});
|
|
618
662
|
}
|
|
619
|
-
setKeys(keys) {
|
|
620
|
-
keys.forEach((k) => {
|
|
621
|
-
if (typeof k === 'string') {
|
|
622
|
-
this.keys.push(createRdhKey({ name: k }));
|
|
623
|
-
}
|
|
624
|
-
else {
|
|
625
|
-
this.keys.push(k);
|
|
626
|
-
}
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
663
|
keynames(is_only_numeric_like = false) {
|
|
630
664
|
if (is_only_numeric_like) {
|
|
631
|
-
return this.keys
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
}
|
|
635
|
-
addKey(k) {
|
|
636
|
-
if (this.keys === undefined) {
|
|
637
|
-
this.keys = [];
|
|
638
|
-
}
|
|
639
|
-
if (typeof k === 'string') {
|
|
640
|
-
this.keys.push(createRdhKey({ name: k }));
|
|
641
|
-
}
|
|
642
|
-
else {
|
|
643
|
-
this.keys.push(k);
|
|
665
|
+
return this.rs.keys
|
|
666
|
+
.filter((k) => (0, GeneralColumnUtil_1.isNumericLike)(k.type))
|
|
667
|
+
.map((k) => k.name);
|
|
644
668
|
}
|
|
669
|
+
return this.rs.keys.map((k) => k.name);
|
|
645
670
|
}
|
|
646
671
|
toShortString(o, keyType) {
|
|
647
672
|
if (o === null || o === undefined) {
|
|
@@ -678,68 +703,6 @@ class ResultSetDataHolder {
|
|
|
678
703
|
}
|
|
679
704
|
return `${s.replace(/\|/g, '|').replace(/(\r?\n)/g, '<br>')}`;
|
|
680
705
|
}
|
|
681
|
-
toString(params) {
|
|
682
|
-
const { maxPrintLines, withType, withComment, keyNames } = Object.assign({ maxPrintLines: 8, withType: false, withComment: false, keyNames: [] }, params);
|
|
683
|
-
const rdhKeys = keyNames.length > 0
|
|
684
|
-
? this.keys.filter((k) => keyNames.includes(k.name))
|
|
685
|
-
: this.keys;
|
|
686
|
-
if (rdhKeys.length < 0) {
|
|
687
|
-
return 'No Keys.';
|
|
688
|
-
}
|
|
689
|
-
const buf = list_it_1.default.buffer();
|
|
690
|
-
buf.d('ROW');
|
|
691
|
-
rdhKeys.forEach((k) => buf.d(this.toShortString(k.name)));
|
|
692
|
-
buf.nl();
|
|
693
|
-
if (withComment) {
|
|
694
|
-
buf.d('');
|
|
695
|
-
rdhKeys.forEach((k) => { var _a; return buf.d((_a = this.toShortString(k.comment)) !== null && _a !== void 0 ? _a : ''); });
|
|
696
|
-
buf.nl();
|
|
697
|
-
}
|
|
698
|
-
if (withType) {
|
|
699
|
-
buf.d((0, GeneralColumnUtil_1.displayGeneralColumnType)(types_1.GeneralColumnType.INTEGER));
|
|
700
|
-
rdhKeys.forEach((k) => {
|
|
701
|
-
buf.d((0, GeneralColumnUtil_1.displayGeneralColumnType)(k.type));
|
|
702
|
-
});
|
|
703
|
-
buf.nl();
|
|
704
|
-
}
|
|
705
|
-
if (this.rows.length <= maxPrintLines) {
|
|
706
|
-
this.rows.forEach((v, idx) => {
|
|
707
|
-
buf.d(idx + 1);
|
|
708
|
-
rdhKeys.forEach((k) => {
|
|
709
|
-
buf.d(this.toShortString(v.values[k.name], k.type));
|
|
710
|
-
});
|
|
711
|
-
buf.nl();
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
else {
|
|
715
|
-
const num_of_head = Math.ceil(maxPrintLines / 2);
|
|
716
|
-
this.rows.slice(0, num_of_head).forEach((v, idx) => {
|
|
717
|
-
buf.d(idx + 1);
|
|
718
|
-
rdhKeys.forEach((k) => {
|
|
719
|
-
buf.d(this.toShortString(v.values[k.name], k.type));
|
|
720
|
-
});
|
|
721
|
-
buf.nl();
|
|
722
|
-
});
|
|
723
|
-
buf.d('...');
|
|
724
|
-
rdhKeys.forEach(() => {
|
|
725
|
-
buf.d('...');
|
|
726
|
-
});
|
|
727
|
-
buf.nl();
|
|
728
|
-
this.rows
|
|
729
|
-
.slice(this.rows.length - num_of_head, this.rows.length)
|
|
730
|
-
.forEach((v, idx) => {
|
|
731
|
-
buf.d(this.rows.length - num_of_head + idx + 1);
|
|
732
|
-
rdhKeys.forEach((k) => {
|
|
733
|
-
buf.d(this.toShortString(v.values[k.name], k.type));
|
|
734
|
-
});
|
|
735
|
-
buf.nl();
|
|
736
|
-
});
|
|
737
|
-
}
|
|
738
|
-
if (this.rows.length === 0) {
|
|
739
|
-
return buf.toString() + 'No records.';
|
|
740
|
-
}
|
|
741
|
-
return buf.toString();
|
|
742
|
-
}
|
|
743
706
|
}
|
|
744
|
-
exports.
|
|
745
|
-
//# sourceMappingURL=
|
|
707
|
+
exports.ResultSetDataBuilder = ResultSetDataBuilder;
|
|
708
|
+
//# sourceMappingURL=ResultSetDataBuilder.js.map
|