@l-v-yonsama/multi-platform-database-drivers 0.1.101 → 0.1.103
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/BaseDriver.js +4 -1
- package/built/src/drivers/BaseDriver.js.map +1 -1
- package/built/src/drivers/MySQLDriver.d.ts +5 -3
- package/built/src/drivers/MySQLDriver.js +12 -14
- package/built/src/drivers/MySQLDriver.js.map +1 -1
- package/built/src/drivers/PostgresDriver.d.ts +5 -3
- package/built/src/drivers/PostgresDriver.js +8 -12
- package/built/src/drivers/PostgresDriver.js.map +1 -1
- package/built/src/drivers/RDSBaseDriver.d.ts +12 -9
- package/built/src/drivers/RDSBaseDriver.js +29 -12
- 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 +10 -4
- 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 +4 -2
- package/built/src/helpers/ResourceHelper.js +51 -13
- package/built/src/helpers/ResourceHelper.js.map +1 -1
- package/built/src/helpers/SQLHelper.d.ts +2 -0
- package/built/src/helpers/SQLHelper.js +50 -3
- package/built/src/helpers/SQLHelper.js.map +1 -1
- package/built/src/resource/ResultSetDataBuilder.d.ts +54 -0
- package/built/src/resource/{ResultSetDataHolder.js → ResultSetDataBuilder.js} +249 -289
- 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 +23 -14
- 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/index.d.ts +1 -1
- package/built/src/types/resource/index.js +1 -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 +0 -3
- 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.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,110 @@ 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
|
-
if (this.meta) {
|
|
116
|
-
return ((_c = (_b = (_a = Object.values(this.meta)) === null || _a === void 0 ? void 0 : _a.flat()) === null || _b === void 0 ? void 0 : _b.some((it) => it.type == type)) !== null && _c !== void 0 ? _c : false);
|
|
117
|
-
}
|
|
118
|
-
return false;
|
|
99
|
+
static hasAnnotation(row, type) {
|
|
100
|
+
return this.hasAnyAnnotation(row, [type]);
|
|
119
101
|
}
|
|
120
102
|
}
|
|
121
|
-
exports.
|
|
122
|
-
class
|
|
103
|
+
exports.RowHelper = RowHelper;
|
|
104
|
+
class ResultSetDataBuilder {
|
|
123
105
|
constructor(keys) {
|
|
124
|
-
this.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
106
|
+
this.rs = {
|
|
107
|
+
created: new Date(),
|
|
108
|
+
keys: toRdhKeys(keys),
|
|
109
|
+
rows: [],
|
|
110
|
+
meta: {},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
build() {
|
|
114
|
+
return this.rs;
|
|
115
|
+
}
|
|
116
|
+
updateMeta(params) {
|
|
117
|
+
Object.entries(params).forEach(([k, v]) => {
|
|
118
|
+
this.rs.meta[k] = v;
|
|
119
|
+
});
|
|
129
120
|
}
|
|
130
121
|
clearAllAnotations() {
|
|
131
|
-
this.rows.forEach((row) =>
|
|
122
|
+
this.rs.rows.forEach((row) => RowHelper.clearAllAnnotations(row));
|
|
132
123
|
}
|
|
133
124
|
static createEmpty() {
|
|
134
|
-
const rdh = new
|
|
125
|
+
const rdh = new ResultSetDataBuilder([
|
|
135
126
|
{
|
|
136
127
|
name: 'message',
|
|
137
128
|
comment: '',
|
|
@@ -140,17 +131,17 @@ class ResultSetDataHolder {
|
|
|
140
131
|
},
|
|
141
132
|
]);
|
|
142
133
|
rdh.addRow({ message: 'empty result set' });
|
|
143
|
-
return rdh;
|
|
134
|
+
return rdh.build();
|
|
144
135
|
}
|
|
145
136
|
static from(list, options) {
|
|
146
137
|
if (list === undefined || list === null || list === '') {
|
|
147
138
|
throw new Error(typeof list + ' has no value.');
|
|
148
139
|
}
|
|
149
|
-
const clone = () => {
|
|
140
|
+
const clone = (obj) => {
|
|
150
141
|
var _a;
|
|
151
|
-
const plainObj = JSON.parse(JSON.stringify(
|
|
152
|
-
const
|
|
153
|
-
const dateKeys =
|
|
142
|
+
const plainObj = JSON.parse(JSON.stringify(obj));
|
|
143
|
+
const rdb = new ResultSetDataBuilder(plainObj.keys);
|
|
144
|
+
const dateKeys = rdb.rs.keys
|
|
154
145
|
.filter((k) => (0, GeneralColumnUtil_1.isDateTimeOrDate)(k.type))
|
|
155
146
|
.map((k) => k.name);
|
|
156
147
|
(_a = plainObj.rows) === null || _a === void 0 ? void 0 : _a.forEach((row) => {
|
|
@@ -158,27 +149,29 @@ class ResultSetDataHolder {
|
|
|
158
149
|
for (const dateKey of dateKeys) {
|
|
159
150
|
values[dateKey] = (0, util_1.toDate)(values[dateKey]);
|
|
160
151
|
}
|
|
161
|
-
|
|
152
|
+
rdb.addRow(values, meta);
|
|
162
153
|
});
|
|
163
154
|
if (plainObj.meta) {
|
|
164
155
|
Object.keys(plainObj.meta).forEach((key) => {
|
|
165
|
-
|
|
156
|
+
rdb.rs.meta[key] = plainObj.meta[key];
|
|
166
157
|
});
|
|
167
158
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return
|
|
159
|
+
rdb.rs['created'] = (0, util_1.toDate)(plainObj.created);
|
|
160
|
+
rdb.rs.sqlStatement = plainObj.sqlStatement;
|
|
161
|
+
rdb.rs.shuffledIndexes = plainObj.shuffledIndexes;
|
|
162
|
+
rdb.rs.shuffledNextCounter = plainObj.shuffledNextCounter;
|
|
163
|
+
rdb.rs.mergeCells = plainObj.mergeCells;
|
|
164
|
+
rdb.rs.queryConditions = plainObj.queryConditions;
|
|
165
|
+
return rdb;
|
|
175
166
|
};
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
167
|
+
if ((0, types_1.isResultSetData)(list)) {
|
|
168
|
+
return clone(list);
|
|
169
|
+
}
|
|
170
|
+
if (isResultSetDataBuilder(list)) {
|
|
171
|
+
return clone(list.rs);
|
|
179
172
|
}
|
|
180
173
|
const t = typeof list;
|
|
181
|
-
let ret
|
|
174
|
+
let ret;
|
|
182
175
|
const strTitles = [];
|
|
183
176
|
if (options === null || options === void 0 ? void 0 : options.keyNames) {
|
|
184
177
|
strTitles.push(...options.keyNames);
|
|
@@ -191,7 +184,7 @@ class ResultSetDataHolder {
|
|
|
191
184
|
while (strTitles.length < elm.length) {
|
|
192
185
|
strTitles.push(`K${i++}`);
|
|
193
186
|
}
|
|
194
|
-
ret = new
|
|
187
|
+
ret = new ResultSetDataBuilder(strTitles);
|
|
195
188
|
for (let r = 0; r < list.length; r++) {
|
|
196
189
|
elm = list[r];
|
|
197
190
|
const values = {};
|
|
@@ -204,9 +197,6 @@ class ResultSetDataHolder {
|
|
|
204
197
|
}
|
|
205
198
|
}
|
|
206
199
|
else {
|
|
207
|
-
if (list.keys && list.rows) {
|
|
208
|
-
return clone();
|
|
209
|
-
}
|
|
210
200
|
switch (t) {
|
|
211
201
|
case 'object':
|
|
212
202
|
if (strTitles.length !== 2) {
|
|
@@ -215,7 +205,7 @@ class ResultSetDataHolder {
|
|
|
215
205
|
strTitles.push('TYPE');
|
|
216
206
|
strTitles.push('VALUE');
|
|
217
207
|
}
|
|
218
|
-
ret = new
|
|
208
|
+
ret = new ResultSetDataBuilder(strTitles);
|
|
219
209
|
Object.keys(list).forEach((k) => {
|
|
220
210
|
const v = list[k];
|
|
221
211
|
let type = typeof v;
|
|
@@ -241,7 +231,7 @@ class ResultSetDataHolder {
|
|
|
241
231
|
}
|
|
242
232
|
describe() {
|
|
243
233
|
const desc_keys = new Array();
|
|
244
|
-
this.keys
|
|
234
|
+
this.rs.keys
|
|
245
235
|
.filter((k) => (0, GeneralColumnUtil_1.isNumericLike)(k.type))
|
|
246
236
|
.forEach((k) => {
|
|
247
237
|
var _a;
|
|
@@ -252,7 +242,7 @@ class ResultSetDataHolder {
|
|
|
252
242
|
});
|
|
253
243
|
});
|
|
254
244
|
desc_keys.unshift(createRdhKey({ name: 'stat', type: types_1.GeneralColumnType.TEXT }));
|
|
255
|
-
const ret = new
|
|
245
|
+
const ret = new ResultSetDataBuilder(desc_keys);
|
|
256
246
|
const count_values = { stat: 'count' };
|
|
257
247
|
const mean_values = { stat: 'mean' };
|
|
258
248
|
const std_values = { stat: 'std' };
|
|
@@ -261,7 +251,7 @@ class ResultSetDataHolder {
|
|
|
261
251
|
const median_values = { stat: '50%' };
|
|
262
252
|
const quatile75_values = { stat: '75%' };
|
|
263
253
|
const max_values = { stat: 'max' };
|
|
264
|
-
this.keys.forEach((key) => {
|
|
254
|
+
this.rs.keys.forEach((key) => {
|
|
265
255
|
const num_list = this.toVector(key.name, true);
|
|
266
256
|
count_values[key.name] = num_list.length;
|
|
267
257
|
mean_values[key.name] = num_list.length === 0 ? '-' : ss.mean(num_list);
|
|
@@ -284,7 +274,7 @@ class ResultSetDataHolder {
|
|
|
284
274
|
ret.addRow(median_values);
|
|
285
275
|
ret.addRow(quatile75_values);
|
|
286
276
|
ret.addRow(max_values);
|
|
287
|
-
return ret;
|
|
277
|
+
return ret.build();
|
|
288
278
|
}
|
|
289
279
|
splitRows(test_percentage, with_shuffle = false) {
|
|
290
280
|
if (test_percentage >= 100) {
|
|
@@ -293,22 +283,24 @@ class ResultSetDataHolder {
|
|
|
293
283
|
if (test_percentage < 0) {
|
|
294
284
|
test_percentage = 0;
|
|
295
285
|
}
|
|
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();
|
|
286
|
+
const numTestExamples = Math.round((this.rs.rows.length * test_percentage) / 100);
|
|
287
|
+
const numTrainExamples = this.rs.rows.length - numTestExamples;
|
|
288
|
+
const train = new ResultSetDataBuilder(this.rs.keys);
|
|
289
|
+
const test = new ResultSetDataBuilder(this.rs.keys);
|
|
290
|
+
const cloned_rows = this.rs.rows.slice();
|
|
301
291
|
if (with_shuffle) {
|
|
302
292
|
(0, shuffle_array_1.default)(cloned_rows);
|
|
303
293
|
}
|
|
304
|
-
train.rows
|
|
305
|
-
test.rows
|
|
306
|
-
|
|
294
|
+
train.rs.rows.splice(0, train.rs.rows.length);
|
|
295
|
+
test.rs.rows.splice(0, test.rs.rows.length);
|
|
296
|
+
train.rs.rows.push(...cloned_rows.slice(0, numTrainExamples));
|
|
297
|
+
test.rs.rows.push(...cloned_rows.slice(numTrainExamples));
|
|
298
|
+
return [train.build(), test.build()];
|
|
307
299
|
}
|
|
308
|
-
sampleXKeysGroupByClass(numExamplesPerClass, xKeys,
|
|
309
|
-
const ret =
|
|
300
|
+
sampleXKeysGroupByClass(numExamplesPerClass, xKeys, clazzKey, shuffle = false) {
|
|
301
|
+
const ret = { clazzKey, sampleKeys: xKeys };
|
|
310
302
|
const localIndexes = new Array();
|
|
311
|
-
for (let i = 0; i < this.rows.length; i++) {
|
|
303
|
+
for (let i = 0; i < this.rs.rows.length; i++) {
|
|
312
304
|
localIndexes.push(i);
|
|
313
305
|
}
|
|
314
306
|
if (shuffle) {
|
|
@@ -316,31 +308,33 @@ class ResultSetDataHolder {
|
|
|
316
308
|
(0, shuffle_array_1.default)(localIndexes);
|
|
317
309
|
}
|
|
318
310
|
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[
|
|
311
|
+
for (let j = 0; j < this.rs.rows.length; j++) {
|
|
312
|
+
const row = this.rs.rows[localIndexes[j]];
|
|
313
|
+
const clazz_value = row.values[clazzKey];
|
|
322
314
|
uniqClassValueSets.add(clazz_value);
|
|
323
315
|
}
|
|
324
316
|
const uniqClassValues = Array.from(uniqClassValueSets).sort();
|
|
325
317
|
uniqClassValues.forEach((uniq) => {
|
|
326
|
-
const pair =
|
|
327
|
-
|
|
318
|
+
const pair = {
|
|
319
|
+
clazzValue: uniq,
|
|
320
|
+
sampleValues: [],
|
|
321
|
+
};
|
|
328
322
|
ret.pairs.push(pair);
|
|
329
323
|
});
|
|
330
|
-
for (let j = 0; j < this.rows.length; j++) {
|
|
331
|
-
const row = this.rows[localIndexes[j]];
|
|
324
|
+
for (let j = 0; j < this.rs.rows.length; j++) {
|
|
325
|
+
const row = this.rs.rows[localIndexes[j]];
|
|
332
326
|
const innerX = new Array();
|
|
333
327
|
xKeys.forEach((k) => {
|
|
334
328
|
innerX.push(row.values[k]);
|
|
335
329
|
});
|
|
336
|
-
const clazz_value = row.values[
|
|
337
|
-
const pair = ret.pairs.find((pair) => pair.
|
|
338
|
-
if (pair && pair.
|
|
339
|
-
pair.
|
|
330
|
+
const clazz_value = row.values[clazzKey];
|
|
331
|
+
const pair = ret.pairs.find((pair) => pair.clazzValue === clazz_value);
|
|
332
|
+
if (pair && pair.sampleValues.length < numExamplesPerClass) {
|
|
333
|
+
pair.sampleValues.push(innerX);
|
|
340
334
|
}
|
|
341
335
|
let num_full_clazz = 0;
|
|
342
336
|
ret.pairs.forEach((pair) => {
|
|
343
|
-
if (pair.
|
|
337
|
+
if (pair.sampleValues.length >= numExamplesPerClass) {
|
|
344
338
|
num_full_clazz++;
|
|
345
339
|
}
|
|
346
340
|
});
|
|
@@ -351,42 +345,42 @@ class ResultSetDataHolder {
|
|
|
351
345
|
return ret;
|
|
352
346
|
}
|
|
353
347
|
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);
|
|
348
|
+
if (this.rs.shuffledNextCounter === undefined) {
|
|
349
|
+
this.rs.shuffledNextCounter = 0;
|
|
350
|
+
this.rs.shuffledIndexes = new Array();
|
|
351
|
+
for (let i = 0; i < this.rs.rows.length; i++) {
|
|
352
|
+
this.rs.shuffledIndexes.push(i);
|
|
359
353
|
}
|
|
360
|
-
(0, shuffle_array_1.default)(this.shuffledIndexes);
|
|
354
|
+
(0, shuffle_array_1.default)(this.rs.shuffledIndexes);
|
|
361
355
|
}
|
|
362
356
|
const x = new Array();
|
|
363
357
|
const y = new Array();
|
|
364
358
|
for (let j = 0; j < batch_size; j++) {
|
|
365
|
-
const row = this.rows[this.shuffledIndexes[this.shuffledNextCounter]];
|
|
359
|
+
const row = this.rs.rows[this.rs.shuffledIndexes[this.rs.shuffledNextCounter]];
|
|
366
360
|
const innerX = new Array();
|
|
367
361
|
xKeys.forEach((k) => {
|
|
368
362
|
innerX.push(row.values[k]);
|
|
369
363
|
});
|
|
370
364
|
x.push(innerX);
|
|
371
365
|
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;
|
|
366
|
+
this.rs.shuffledNextCounter++;
|
|
367
|
+
if (this.rs.rows.length <= this.rs.shuffledNextCounter) {
|
|
368
|
+
(0, shuffle_array_1.default)(this.rs.shuffledIndexes);
|
|
369
|
+
this.rs.shuffledNextCounter = 0;
|
|
376
370
|
}
|
|
377
371
|
}
|
|
378
372
|
return [x, y];
|
|
379
373
|
}
|
|
380
374
|
hasKey(key) {
|
|
381
|
-
return this.keys.some((k) => k.name === key);
|
|
375
|
+
return this.rs.keys.some((k) => k.name === key);
|
|
382
376
|
}
|
|
383
377
|
drop(key) {
|
|
384
378
|
if (this.hasKey(key)) {
|
|
385
|
-
this.rows.forEach((v) => {
|
|
379
|
+
this.rs.rows.forEach((v) => {
|
|
386
380
|
delete v.values[key];
|
|
387
381
|
});
|
|
388
|
-
const idx = this.keys.findIndex((k) => k.name === key);
|
|
389
|
-
this.keys.splice(idx, 1);
|
|
382
|
+
const idx = this.rs.keys.findIndex((k) => k.name === key);
|
|
383
|
+
this.rs.keys.splice(idx, 1);
|
|
390
384
|
}
|
|
391
385
|
}
|
|
392
386
|
assign(key, list) {
|
|
@@ -397,13 +391,13 @@ class ResultSetDataHolder {
|
|
|
397
391
|
this.drop(key);
|
|
398
392
|
if (constructor === 'Float32Array' || constructor === 'Float64Array') {
|
|
399
393
|
list = Array.from(list);
|
|
400
|
-
this.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.NUMERIC }));
|
|
394
|
+
this.rs.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.NUMERIC }));
|
|
401
395
|
}
|
|
402
396
|
else if (constructor === 'Int8Array' ||
|
|
403
397
|
constructor === 'Int16Array' ||
|
|
404
398
|
constructor === 'Int32Array') {
|
|
405
399
|
list = Array.from(list);
|
|
406
|
-
this.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.INTEGER }));
|
|
400
|
+
this.rs.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.INTEGER }));
|
|
407
401
|
}
|
|
408
402
|
else {
|
|
409
403
|
const types = new Set();
|
|
@@ -413,20 +407,20 @@ class ResultSetDataHolder {
|
|
|
413
407
|
}
|
|
414
408
|
});
|
|
415
409
|
if (types.size === 1 && types.has('number')) {
|
|
416
|
-
this.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.NUMERIC }));
|
|
410
|
+
this.rs.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.NUMERIC }));
|
|
417
411
|
}
|
|
418
412
|
else {
|
|
419
|
-
this.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.UNKNOWN }));
|
|
413
|
+
this.rs.keys.push(createRdhKey({ name: key, type: types_1.GeneralColumnType.UNKNOWN }));
|
|
420
414
|
}
|
|
421
415
|
}
|
|
422
416
|
list.forEach((v, i) => {
|
|
423
|
-
this.rows[i].values[key] = v;
|
|
417
|
+
this.rs.rows[i].values[key] = v;
|
|
424
418
|
});
|
|
425
419
|
}
|
|
426
420
|
assignFromDictionary(new_key, existing_key, dictionary) {
|
|
427
421
|
this.drop(new_key);
|
|
428
|
-
this.keys.push(createRdhKey({ name: new_key, type: types_1.GeneralColumnType.TEXT }));
|
|
429
|
-
this.rows.forEach((row) => {
|
|
422
|
+
this.rs.keys.push(createRdhKey({ name: new_key, type: types_1.GeneralColumnType.TEXT }));
|
|
423
|
+
this.rs.rows.forEach((row) => {
|
|
430
424
|
const existing_val = row.values[existing_key];
|
|
431
425
|
if (existing_val === undefined ||
|
|
432
426
|
existing_val === '' ||
|
|
@@ -445,7 +439,7 @@ class ResultSetDataHolder {
|
|
|
445
439
|
}
|
|
446
440
|
toVector(key_name, is_only_number = false) {
|
|
447
441
|
const retList = new Array();
|
|
448
|
-
this.rows.forEach((row) => {
|
|
442
|
+
this.rs.rows.forEach((row) => {
|
|
449
443
|
const v = row.values[key_name];
|
|
450
444
|
if (is_only_number) {
|
|
451
445
|
if (isFinite(v) && v !== '' && v !== null) {
|
|
@@ -460,7 +454,7 @@ class ResultSetDataHolder {
|
|
|
460
454
|
}
|
|
461
455
|
toMatrixArray(key_names) {
|
|
462
456
|
const retList = new Array();
|
|
463
|
-
this.rows.forEach((row) => {
|
|
457
|
+
this.rs.rows.forEach((row) => {
|
|
464
458
|
const retRow = new Array();
|
|
465
459
|
if (key_names && key_names.length > 0) {
|
|
466
460
|
key_names.forEach((key_name) => {
|
|
@@ -468,7 +462,7 @@ class ResultSetDataHolder {
|
|
|
468
462
|
});
|
|
469
463
|
}
|
|
470
464
|
else {
|
|
471
|
-
this.keys.forEach((key) => {
|
|
465
|
+
this.rs.keys.forEach((key) => {
|
|
472
466
|
retRow.push(row.values[key.name]);
|
|
473
467
|
});
|
|
474
468
|
}
|
|
@@ -479,8 +473,8 @@ class ResultSetDataHolder {
|
|
|
479
473
|
toCsv(params) {
|
|
480
474
|
const { withType, withComment, keyNames } = Object.assign({ withType: false, withComment: false, keyNames: [] }, params);
|
|
481
475
|
const rdhKeys = keyNames.length > 0
|
|
482
|
-
? this.keys.filter((k) => keyNames.includes(k.name))
|
|
483
|
-
: this.keys;
|
|
476
|
+
? this.rs.keys.filter((k) => keyNames.includes(k.name))
|
|
477
|
+
: this.rs.keys;
|
|
484
478
|
if (rdhKeys.length < 0) {
|
|
485
479
|
return 'No Keys.';
|
|
486
480
|
}
|
|
@@ -494,7 +488,7 @@ class ResultSetDataHolder {
|
|
|
494
488
|
.map((k) => this.toCsvString((0, GeneralColumnUtil_1.displayGeneralColumnType)(k.type)))
|
|
495
489
|
.join(','));
|
|
496
490
|
}
|
|
497
|
-
this.rows.forEach((row) => {
|
|
491
|
+
this.rs.rows.forEach((row) => {
|
|
498
492
|
const retRow = new Array();
|
|
499
493
|
rdhKeys.forEach((key) => {
|
|
500
494
|
retRow.push(this.toCsvString(row.values[key.name], key.type));
|
|
@@ -506,8 +500,8 @@ class ResultSetDataHolder {
|
|
|
506
500
|
toMarkdown(params) {
|
|
507
501
|
const { withType, withComment, keyNames } = Object.assign({ withType: false, withComment: false, keyNames: [] }, params);
|
|
508
502
|
const rdhKeys = keyNames.length > 0
|
|
509
|
-
? this.keys.filter((k) => keyNames.includes(k.name))
|
|
510
|
-
: this.keys;
|
|
503
|
+
? this.rs.keys.filter((k) => keyNames.includes(k.name))
|
|
504
|
+
: this.rs.keys;
|
|
511
505
|
if (rdhKeys.length < 0) {
|
|
512
506
|
return 'No Keys.';
|
|
513
507
|
}
|
|
@@ -523,7 +517,7 @@ class ResultSetDataHolder {
|
|
|
523
517
|
.map((k) => this.toMarkdownString((0, GeneralColumnUtil_1.displayGeneralColumnType)(k.type)))
|
|
524
518
|
.join(' | '));
|
|
525
519
|
}
|
|
526
|
-
this.rows.forEach((row) => {
|
|
520
|
+
this.rs.rows.forEach((row) => {
|
|
527
521
|
const retRow = new Array();
|
|
528
522
|
rdhKeys.forEach((key) => {
|
|
529
523
|
retRow.push(this.toMarkdownString(row.values[key.name], key.type));
|
|
@@ -532,49 +526,96 @@ class ResultSetDataHolder {
|
|
|
532
526
|
});
|
|
533
527
|
return retList.join(os.EOL);
|
|
534
528
|
}
|
|
529
|
+
toString(params) {
|
|
530
|
+
const { maxPrintLines, withType, withComment, keyNames } = Object.assign({ maxPrintLines: 8, withType: false, withComment: false, keyNames: [] }, params);
|
|
531
|
+
const rdhKeys = keyNames.length > 0
|
|
532
|
+
? this.rs.keys.filter((k) => keyNames.includes(k.name))
|
|
533
|
+
: this.rs.keys;
|
|
534
|
+
if (rdhKeys.length < 0) {
|
|
535
|
+
return 'No Keys.';
|
|
536
|
+
}
|
|
537
|
+
const buf = list_it_1.default.buffer();
|
|
538
|
+
buf.d('ROW');
|
|
539
|
+
rdhKeys.forEach((k) => buf.d(this.toShortString(k.name)));
|
|
540
|
+
buf.nl();
|
|
541
|
+
if (withComment) {
|
|
542
|
+
buf.d('');
|
|
543
|
+
rdhKeys.forEach((k) => { var _a; return buf.d((_a = this.toShortString(k.comment)) !== null && _a !== void 0 ? _a : ''); });
|
|
544
|
+
buf.nl();
|
|
545
|
+
}
|
|
546
|
+
if (withType) {
|
|
547
|
+
buf.d((0, GeneralColumnUtil_1.displayGeneralColumnType)(types_1.GeneralColumnType.INTEGER));
|
|
548
|
+
rdhKeys.forEach((k) => {
|
|
549
|
+
buf.d((0, GeneralColumnUtil_1.displayGeneralColumnType)(k.type));
|
|
550
|
+
});
|
|
551
|
+
buf.nl();
|
|
552
|
+
}
|
|
553
|
+
if (this.rs.rows.length <= maxPrintLines) {
|
|
554
|
+
this.rs.rows.forEach((v, idx) => {
|
|
555
|
+
buf.d(idx + 1);
|
|
556
|
+
rdhKeys.forEach((k) => {
|
|
557
|
+
buf.d(this.toShortString(v.values[k.name], k.type));
|
|
558
|
+
});
|
|
559
|
+
buf.nl();
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
const num_of_head = Math.ceil(maxPrintLines / 2);
|
|
564
|
+
this.rs.rows.slice(0, num_of_head).forEach((v, idx) => {
|
|
565
|
+
buf.d(idx + 1);
|
|
566
|
+
rdhKeys.forEach((k) => {
|
|
567
|
+
buf.d(this.toShortString(v.values[k.name], k.type));
|
|
568
|
+
});
|
|
569
|
+
buf.nl();
|
|
570
|
+
});
|
|
571
|
+
buf.d('...');
|
|
572
|
+
rdhKeys.forEach(() => {
|
|
573
|
+
buf.d('...');
|
|
574
|
+
});
|
|
575
|
+
buf.nl();
|
|
576
|
+
this.rs.rows
|
|
577
|
+
.slice(this.rs.rows.length - num_of_head, this.rs.rows.length)
|
|
578
|
+
.forEach((v, idx) => {
|
|
579
|
+
buf.d(this.rs.rows.length - num_of_head + idx + 1);
|
|
580
|
+
rdhKeys.forEach((k) => {
|
|
581
|
+
buf.d(this.toShortString(v.values[k.name], k.type));
|
|
582
|
+
});
|
|
583
|
+
buf.nl();
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
if (this.rs.rows.length === 0) {
|
|
587
|
+
return buf.toString() + 'No records.';
|
|
588
|
+
}
|
|
589
|
+
return buf.toString();
|
|
590
|
+
}
|
|
535
591
|
addRow(recordData, default_meta) {
|
|
536
592
|
let meta = {};
|
|
537
593
|
if (default_meta) {
|
|
538
594
|
meta = default_meta;
|
|
539
595
|
}
|
|
540
596
|
const values = {};
|
|
541
|
-
this.keys.forEach((key) => {
|
|
597
|
+
this.rs.keys.forEach((key) => {
|
|
542
598
|
const v = recordData[key.name];
|
|
543
599
|
values[key.name] = v;
|
|
544
600
|
});
|
|
545
|
-
this.rows.push(
|
|
601
|
+
this.rs.rows.push({ meta, values });
|
|
546
602
|
}
|
|
547
603
|
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
|
-
});
|
|
604
|
+
this.rs.rows.splice(0, this.rs.rows.length);
|
|
557
605
|
}
|
|
558
606
|
setSqlStatement(sqlStatement) {
|
|
559
|
-
this.sqlStatement = sqlStatement;
|
|
607
|
+
this.rs.sqlStatement = sqlStatement;
|
|
560
608
|
}
|
|
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;
|
|
609
|
+
hasAnyAnnotation(types) {
|
|
610
|
+
return this.rs.rows.some((row) => RowHelper.hasAnyAnnotation(row, types));
|
|
570
611
|
}
|
|
571
612
|
fillnull(how) {
|
|
572
|
-
this.keys
|
|
613
|
+
this.rs.keys
|
|
573
614
|
.filter((k) => (0, GeneralColumnUtil_1.isNumericLike)(k.type))
|
|
574
615
|
.forEach((k) => {
|
|
575
616
|
const num_list = new Array();
|
|
576
|
-
for (let i = 0; i < this.rows.length; i++) {
|
|
577
|
-
const v = this.rows[i].values[k.name];
|
|
617
|
+
for (let i = 0; i < this.rs.rows.length; i++) {
|
|
618
|
+
const v = this.rs.rows[i].values[k.name];
|
|
578
619
|
if (isFinite(v) && v !== '') {
|
|
579
620
|
num_list.push(v);
|
|
580
621
|
}
|
|
@@ -588,19 +629,19 @@ class ResultSetDataHolder {
|
|
|
588
629
|
new_value = ss.median(num_list);
|
|
589
630
|
break;
|
|
590
631
|
}
|
|
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;
|
|
632
|
+
for (let i = 0; i < this.rs.rows.length; i++) {
|
|
633
|
+
if (this.rs.rows[i].values[k.name] === null) {
|
|
634
|
+
this.rs.rows[i].values[k.name] = new_value;
|
|
594
635
|
}
|
|
595
636
|
}
|
|
596
637
|
});
|
|
597
638
|
}
|
|
598
639
|
resetKeyTypeByRows() {
|
|
599
|
-
this.keys.forEach((k) => {
|
|
600
|
-
const length = this.rows.length;
|
|
640
|
+
this.rs.keys.forEach((k) => {
|
|
641
|
+
const length = this.rs.rows.length;
|
|
601
642
|
const types = new Set();
|
|
602
643
|
for (let i = 0; i < length; i++) {
|
|
603
|
-
const v = this.rows[i].values[k.name];
|
|
644
|
+
const v = this.rs.rows[i].values[k.name];
|
|
604
645
|
if (v === '' || v === null) {
|
|
605
646
|
continue;
|
|
606
647
|
}
|
|
@@ -609,39 +650,20 @@ class ResultSetDataHolder {
|
|
|
609
650
|
if (types.size === 1 && types.has('number')) {
|
|
610
651
|
k.type = types_1.GeneralColumnType.NUMERIC;
|
|
611
652
|
for (let i = 0; i < length; i++) {
|
|
612
|
-
if (this.rows[i].values[k.name] === '') {
|
|
613
|
-
this.rows[i].values[k.name] = null;
|
|
653
|
+
if (this.rs.rows[i].values[k.name] === '') {
|
|
654
|
+
this.rs.rows[i].values[k.name] = null;
|
|
614
655
|
}
|
|
615
656
|
}
|
|
616
657
|
}
|
|
617
658
|
});
|
|
618
659
|
}
|
|
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
660
|
keynames(is_only_numeric_like = false) {
|
|
630
661
|
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);
|
|
662
|
+
return this.rs.keys
|
|
663
|
+
.filter((k) => (0, GeneralColumnUtil_1.isNumericLike)(k.type))
|
|
664
|
+
.map((k) => k.name);
|
|
644
665
|
}
|
|
666
|
+
return this.rs.keys.map((k) => k.name);
|
|
645
667
|
}
|
|
646
668
|
toShortString(o, keyType) {
|
|
647
669
|
if (o === null || o === undefined) {
|
|
@@ -678,68 +700,6 @@ class ResultSetDataHolder {
|
|
|
678
700
|
}
|
|
679
701
|
return `${s.replace(/\|/g, '|').replace(/(\r?\n)/g, '<br>')}`;
|
|
680
702
|
}
|
|
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
703
|
}
|
|
744
|
-
exports.
|
|
745
|
-
//# sourceMappingURL=
|
|
704
|
+
exports.ResultSetDataBuilder = ResultSetDataBuilder;
|
|
705
|
+
//# sourceMappingURL=ResultSetDataBuilder.js.map
|