@abaplint/runtime 2.5.57 → 2.5.58
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/build/src/binary_search.d.ts +1 -1
- package/build/src/binary_search.js +8 -2
- package/build/src/builtin/lines.js +6 -4
- package/build/src/statements/find.js +1 -1
- package/build/src/statements/insert_internal.d.ts +2 -2
- package/build/src/statements/insert_internal.js +19 -3
- package/build/src/statements/loop.js +1 -1
- package/build/src/statements/read_table.d.ts +6 -1
- package/build/src/statements/read_table.js +16 -7
- package/build/src/types/data_reference.d.ts +1 -1
- package/build/src/types/table.d.ts +49 -4
- package/build/src/types/table.js +156 -12
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ICharacter } from "./types/_character";
|
|
2
2
|
import { INumeric } from "./types/_numeric";
|
|
3
|
-
export declare function binarySearchFromRow(array: readonly any[], left: number, right: number, keyField: (i: any) => any, keyValue: INumeric | ICharacter): number;
|
|
3
|
+
export declare function binarySearchFromRow(array: readonly any[], left: number, right: number, keyField: (i: any) => any, keyValue: INumeric | ICharacter, usesTableLine: boolean | undefined): number;
|
|
4
4
|
export declare function binarySearchFrom(array: readonly any[], left: number, right: number, keyField: string, keyValue: INumeric | ICharacter): number;
|
|
5
5
|
export declare function binarySearchTo(array: readonly any[], left: number, right: number, keyField: string, keyValue: INumeric | ICharacter): number;
|
|
@@ -4,12 +4,18 @@ exports.binarySearchTo = exports.binarySearchFrom = exports.binarySearchFromRow
|
|
|
4
4
|
/* eslint-disable max-len */
|
|
5
5
|
const compare_1 = require("./compare");
|
|
6
6
|
const types_1 = require("./types");
|
|
7
|
-
function binarySearchFromRow(array, left, right, keyField, keyValue) {
|
|
7
|
+
function binarySearchFromRow(array, left, right, keyField, keyValue, usesTableLine) {
|
|
8
8
|
const isStructured = array[0] instanceof types_1.Structure;
|
|
9
9
|
while (right - left > 1) {
|
|
10
10
|
const middle = Math.floor(((right - left) / 2) + left);
|
|
11
11
|
const a = array[middle];
|
|
12
|
-
|
|
12
|
+
let row = undefined;
|
|
13
|
+
if (usesTableLine === false && isStructured === true) {
|
|
14
|
+
row = a.get();
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
row = isStructured ? Object.assign({ table_line: a }, a.get()) : { table_line: a };
|
|
18
|
+
}
|
|
13
19
|
if ((0, compare_1.ge)(keyField(row), keyValue)) {
|
|
14
20
|
right = middle;
|
|
15
21
|
}
|
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.lines = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
function lines(input) {
|
|
6
|
-
if (input.val instanceof types_1.FieldSymbol
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
if (input.val instanceof types_1.FieldSymbol) {
|
|
7
|
+
if (input.val.getPointer() === undefined) {
|
|
8
|
+
throw new Error("GETWA_NOT_ASSIGNED");
|
|
9
|
+
}
|
|
10
|
+
return lines({ val: input.val.getPointer() });
|
|
9
11
|
}
|
|
10
|
-
return new types_1.Integer().set(input.val.
|
|
12
|
+
return new types_1.Integer().set(input.val.getLength());
|
|
11
13
|
}
|
|
12
14
|
exports.lines = lines;
|
|
13
15
|
//# sourceMappingURL=lines.js.map
|
|
@@ -108,7 +108,7 @@ function find(input, options) {
|
|
|
108
108
|
line: new types_1.Integer(),
|
|
109
109
|
offset: new types_1.Integer(),
|
|
110
110
|
length: new types_1.Integer(),
|
|
111
|
-
submatches:
|
|
111
|
+
submatches: types_1.TableFactory.construct(new types_1.Structure({ offset: new types_1.Integer(), length: new types_1.Integer() })),
|
|
112
112
|
});
|
|
113
113
|
match.get().line.set(m.line || 0);
|
|
114
114
|
match.get().offset.set(m.index);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ABAPObject, DataReference, FieldSymbol, Structure, Table } from "../types";
|
|
1
|
+
import { ABAPObject, DataReference, FieldSymbol, HashedTable, Structure, Table } from "../types";
|
|
2
2
|
import { ICharacter } from "../types/_character";
|
|
3
3
|
import { INumeric } from "../types/_numeric";
|
|
4
4
|
export interface IInsertInternalOptions {
|
|
5
5
|
index?: INumeric;
|
|
6
6
|
initial?: boolean;
|
|
7
7
|
data?: INumeric | ICharacter | Structure | ABAPObject | Table | FieldSymbol | string;
|
|
8
|
-
table: Table | FieldSymbol;
|
|
8
|
+
table: Table | HashedTable | FieldSymbol;
|
|
9
9
|
referenceInto?: DataReference;
|
|
10
10
|
assigning?: FieldSymbol;
|
|
11
11
|
lines?: boolean;
|
|
@@ -21,8 +21,12 @@ function insertInternal(options) {
|
|
|
21
21
|
options.data = options.data.getPointer();
|
|
22
22
|
}
|
|
23
23
|
const tableOptions = options.table.getOptions();
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
let isSorted = ((_a = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.primaryKey) === null || _a === void 0 ? void 0 : _a.type) === types_1.TableAccessType.sorted
|
|
25
|
+
|| ((_b = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.primaryKey) === null || _b === void 0 ? void 0 : _b.type) === types_1.TableAccessType.hashed;
|
|
26
|
+
if (options.table instanceof types_1.HashedTable) {
|
|
27
|
+
isSorted = false;
|
|
28
|
+
}
|
|
29
|
+
else if (isSorted) {
|
|
26
30
|
const insert = options.data instanceof types_1.Structure ? options.data.get() : { table_line: options.data };
|
|
27
31
|
const compare = (row) => {
|
|
28
32
|
var _a;
|
|
@@ -92,6 +96,18 @@ function insertInternal(options) {
|
|
|
92
96
|
options.referenceInto.assign(val);
|
|
93
97
|
}
|
|
94
98
|
}
|
|
99
|
+
else if (options.table instanceof types_1.HashedTable && data) {
|
|
100
|
+
const { value: val, subrc: subrc } = options.table.insert(data);
|
|
101
|
+
if (options.assigning) {
|
|
102
|
+
options.assigning.assign(val);
|
|
103
|
+
}
|
|
104
|
+
if (options.referenceInto) {
|
|
105
|
+
options.referenceInto.assign(val);
|
|
106
|
+
}
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
abap.builtin.sy.get().subrc.set(subrc);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
95
111
|
else if (data) {
|
|
96
112
|
// todo, for now it just appends, this is not correct, but currently the table type is not known
|
|
97
113
|
const val = options.table.insertIndex(data, options.table.array().length);
|
|
@@ -104,7 +120,7 @@ function insertInternal(options) {
|
|
|
104
120
|
}
|
|
105
121
|
// @ts-ignore
|
|
106
122
|
abap.builtin.sy.get().subrc.set(0);
|
|
107
|
-
if (isSorted) {
|
|
123
|
+
if (isSorted && !(options.table instanceof types_1.HashedTable)) {
|
|
108
124
|
// slow, but works for now
|
|
109
125
|
let by = (_e = (_d = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.primaryKey) === null || _d === void 0 ? void 0 : _d.keyFields) === null || _e === void 0 ? void 0 : _e.map(f => {
|
|
110
126
|
return { component: f.toLowerCase() };
|
|
@@ -60,7 +60,7 @@ function loop(table, options) {
|
|
|
60
60
|
yield __await(yield* __asyncDelegator(__asyncValues(loop(pnt, options))));
|
|
61
61
|
return yield __await(void 0);
|
|
62
62
|
}
|
|
63
|
-
const length = table.
|
|
63
|
+
const length = table.getLength();
|
|
64
64
|
if (length === 0) {
|
|
65
65
|
// @ts-ignore
|
|
66
66
|
abap.builtin.sy.get().subrc.set(4);
|
|
@@ -3,17 +3,22 @@ import { ICharacter } from "../types/_character";
|
|
|
3
3
|
import { INumeric } from "../types/_numeric";
|
|
4
4
|
export interface IReadTableOptions {
|
|
5
5
|
index?: INumeric | FieldSymbol | number;
|
|
6
|
-
withKey?: (i: any) => boolean;
|
|
7
6
|
into?: INumeric | ICharacter | Structure | Table | DataReference;
|
|
8
7
|
from?: INumeric | ICharacter | Structure | Table | DataReference;
|
|
9
8
|
referenceInto?: DataReference;
|
|
10
9
|
assigning?: FieldSymbol;
|
|
11
10
|
binarySearch?: boolean;
|
|
11
|
+
withTableKey?: boolean;
|
|
12
12
|
keyName?: string;
|
|
13
|
+
usesTableLine?: boolean;
|
|
14
|
+
withKey?: (i: any) => boolean;
|
|
13
15
|
withKeyValue?: {
|
|
14
16
|
key: (i: any) => any;
|
|
15
17
|
value: any;
|
|
16
18
|
}[];
|
|
19
|
+
withKeySimple?: {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
};
|
|
17
22
|
}
|
|
18
23
|
export type ReadTableReturn = {
|
|
19
24
|
subrc: number;
|
|
@@ -4,11 +4,17 @@ exports.readTable = void 0;
|
|
|
4
4
|
const binary_search_1 = require("../binary_search");
|
|
5
5
|
const compare_1 = require("../compare");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
|
-
function searchWithKey(arr, withKey, startIndex = 0) {
|
|
7
|
+
function searchWithKey(arr, withKey, startIndex = 0, usesTableLine) {
|
|
8
8
|
const isStructured = arr[0] instanceof types_1.Structure;
|
|
9
9
|
for (let index = startIndex; index < arr.length; index++) {
|
|
10
10
|
const a = arr[index];
|
|
11
|
-
|
|
11
|
+
let row = undefined;
|
|
12
|
+
if (usesTableLine === false && isStructured === true) {
|
|
13
|
+
row = a.get();
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
row = isStructured ? Object.assign({ table_line: a }, a.get()) : { table_line: a };
|
|
17
|
+
}
|
|
12
18
|
if (withKey(row) === true) {
|
|
13
19
|
return {
|
|
14
20
|
found: a,
|
|
@@ -26,8 +32,8 @@ function readTable(table, options) {
|
|
|
26
32
|
var _a, _b;
|
|
27
33
|
let found = undefined;
|
|
28
34
|
let foundIndex = 0;
|
|
29
|
-
const arr = table.array();
|
|
30
35
|
if (options === null || options === void 0 ? void 0 : options.index) {
|
|
36
|
+
const arr = table.array();
|
|
31
37
|
let index = options.index;
|
|
32
38
|
if (typeof index !== "number") {
|
|
33
39
|
if (index instanceof types_1.FieldSymbol) {
|
|
@@ -48,18 +54,20 @@ function readTable(table, options) {
|
|
|
48
54
|
foundIndex = index;
|
|
49
55
|
}
|
|
50
56
|
}
|
|
51
|
-
else if ((options === null || options === void 0 ? void 0 : options.binarySearch) === true
|
|
57
|
+
else if (((options === null || options === void 0 ? void 0 : options.binarySearch) === true || (options === null || options === void 0 ? void 0 : options.withTableKey) === true)
|
|
52
58
|
&& options.withKeyValue
|
|
53
59
|
&& options.withKey) {
|
|
54
60
|
// note: it currently only uses the first key field for binary search, todo
|
|
55
61
|
const first = options.withKeyValue[0];
|
|
56
|
-
const
|
|
57
|
-
const
|
|
62
|
+
const arr = table.array();
|
|
63
|
+
const startIndex = (0, binary_search_1.binarySearchFromRow)(arr, 0, arr.length, first.key, first.value, options.usesTableLine) - 1;
|
|
64
|
+
const searchResult = searchWithKey(arr, options.withKey, startIndex, options.usesTableLine);
|
|
58
65
|
found = searchResult.found;
|
|
59
66
|
foundIndex = searchResult.foundIndex;
|
|
60
67
|
}
|
|
61
68
|
else if (options === null || options === void 0 ? void 0 : options.withKey) {
|
|
62
|
-
const
|
|
69
|
+
const arr = table.array();
|
|
70
|
+
const searchResult = searchWithKey(arr, options.withKey, 0, options.usesTableLine);
|
|
63
71
|
found = searchResult.found;
|
|
64
72
|
foundIndex = searchResult.foundIndex;
|
|
65
73
|
}
|
|
@@ -71,6 +79,7 @@ function readTable(table, options) {
|
|
|
71
79
|
table = table.getPointer();
|
|
72
80
|
}
|
|
73
81
|
if (table instanceof types_1.Table && options.from instanceof types_1.Structure) {
|
|
82
|
+
const arr = table.array();
|
|
74
83
|
const keys = (_b = (_a = table.getOptions()) === null || _a === void 0 ? void 0 : _a.primaryKey) === null || _b === void 0 ? void 0 : _b.keyFields;
|
|
75
84
|
const isStructured = arr[0] instanceof types_1.Structure;
|
|
76
85
|
if (keys !== undefined && isStructured === true) {
|
|
@@ -19,7 +19,7 @@ export declare class DataReference {
|
|
|
19
19
|
clear(): void;
|
|
20
20
|
get(): any;
|
|
21
21
|
array(): any;
|
|
22
|
-
set(value: any): void | Float | ABAPObject | this | Structure;
|
|
22
|
+
set(value: any): void | Float | ABAPObject | this | Table | Structure;
|
|
23
23
|
getOffset(input: {
|
|
24
24
|
offset?: number | INumeric | Hex;
|
|
25
25
|
length?: number | INumeric | Hex;
|
|
@@ -25,7 +25,50 @@ export type ITableOptions = {
|
|
|
25
25
|
secondary?: ITableKey[];
|
|
26
26
|
};
|
|
27
27
|
export type TableRowType = INumeric | Structure | ICharacter | Table | ABAPObject;
|
|
28
|
-
|
|
28
|
+
interface ITable {
|
|
29
|
+
getQualifiedName(): string | undefined;
|
|
30
|
+
getOptions(): ITableOptions | undefined;
|
|
31
|
+
getRowType(): TableRowType;
|
|
32
|
+
getLength(): number;
|
|
33
|
+
clear(): void;
|
|
34
|
+
set(tab: Table | TableRowType): ITable;
|
|
35
|
+
getHeader(): TableRowType;
|
|
36
|
+
}
|
|
37
|
+
export declare class TableFactory {
|
|
38
|
+
static construct(rowType: TableRowType, options?: ITableOptions, qualifiedName?: string): Table | HashedTable;
|
|
39
|
+
}
|
|
40
|
+
export declare class SortedTable {
|
|
41
|
+
}
|
|
42
|
+
export declare class HashedTable implements ITable {
|
|
43
|
+
private value;
|
|
44
|
+
private readonly header;
|
|
45
|
+
private readonly rowType;
|
|
46
|
+
private readonly loops;
|
|
47
|
+
private readonly options;
|
|
48
|
+
private readonly qualifiedName;
|
|
49
|
+
private secondaryIndexes;
|
|
50
|
+
constructor(rowType: TableRowType, options: ITableOptions, qualifiedName?: string);
|
|
51
|
+
getLength(): number;
|
|
52
|
+
getKeyByName(name: string): ITableKey | undefined;
|
|
53
|
+
getSecondaryIndex(name: string): any[];
|
|
54
|
+
insert(data: TableRowType): {
|
|
55
|
+
value: TableRowType | undefined;
|
|
56
|
+
subrc: number;
|
|
57
|
+
};
|
|
58
|
+
array(): readonly any[];
|
|
59
|
+
startLoop(start?: number): LoopIndex;
|
|
60
|
+
unregisterLoop(loop: LoopIndex): void;
|
|
61
|
+
insertIndex(_item: TableRowType, _index: number): void;
|
|
62
|
+
append(_item: TableRowType): void;
|
|
63
|
+
getQualifiedName(): string | undefined;
|
|
64
|
+
getOptions(): ITableOptions;
|
|
65
|
+
getRowType(): TableRowType;
|
|
66
|
+
clear(): void;
|
|
67
|
+
set(_tab: TableRowType): ITable;
|
|
68
|
+
getHeader(): TableRowType;
|
|
69
|
+
private getValue;
|
|
70
|
+
}
|
|
71
|
+
export declare class Table implements ITable {
|
|
29
72
|
private value;
|
|
30
73
|
private readonly header;
|
|
31
74
|
private readonly rowType;
|
|
@@ -34,17 +77,18 @@ export declare class Table {
|
|
|
34
77
|
private readonly qualifiedName;
|
|
35
78
|
private readonly isStructured;
|
|
36
79
|
private secondaryIndexes;
|
|
37
|
-
constructor(rowType: TableRowType, options
|
|
80
|
+
constructor(rowType: TableRowType, options: ITableOptions, qualifiedName?: string);
|
|
81
|
+
getLength(): number;
|
|
38
82
|
getKeyByName(name: string): ITableKey | undefined;
|
|
39
83
|
getSecondaryIndex(name: string): TableRowType[];
|
|
40
84
|
getQualifiedName(): string | undefined;
|
|
41
|
-
getOptions(): ITableOptions
|
|
85
|
+
getOptions(): ITableOptions;
|
|
42
86
|
startLoop(start?: number): LoopIndex;
|
|
43
87
|
unregisterLoop(loop: LoopIndex): void;
|
|
44
88
|
getRowType(): TableRowType;
|
|
45
89
|
array(): readonly any[];
|
|
46
90
|
clear(): void;
|
|
47
|
-
set(tab: Table | TableRowType):
|
|
91
|
+
set(tab: Table | TableRowType): this;
|
|
48
92
|
getHeader(): TableRowType;
|
|
49
93
|
insertIndex(item: TableRowType, index: number): any;
|
|
50
94
|
deleteIndex(index: number): void;
|
|
@@ -53,3 +97,4 @@ export declare class Table {
|
|
|
53
97
|
sort(compareFn: (a: TableRowType, b: TableRowType) => number): void;
|
|
54
98
|
private getValue;
|
|
55
99
|
}
|
|
100
|
+
export {};
|
package/build/src/types/table.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Table = exports.LoopIndex = exports.TableAccessType = void 0;
|
|
3
|
+
exports.Table = exports.HashedTable = exports.SortedTable = exports.TableFactory = exports.LoopIndex = exports.TableAccessType = void 0;
|
|
4
4
|
const integer_1 = require("./integer");
|
|
5
5
|
const string_1 = require("./string");
|
|
6
6
|
const clone_1 = require("../clone");
|
|
@@ -23,6 +23,157 @@ class LoopIndex {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
exports.LoopIndex = LoopIndex;
|
|
26
|
+
// eslint-disable-next-line prefer-const
|
|
27
|
+
let featureHashedTables = false;
|
|
28
|
+
class TableFactory {
|
|
29
|
+
static construct(rowType, options, qualifiedName) {
|
|
30
|
+
var _a;
|
|
31
|
+
if (options === undefined) {
|
|
32
|
+
options = {
|
|
33
|
+
primaryKey: {
|
|
34
|
+
name: "primary_key",
|
|
35
|
+
type: TableAccessType.standard,
|
|
36
|
+
keyFields: [],
|
|
37
|
+
isUnique: false,
|
|
38
|
+
},
|
|
39
|
+
withHeader: false,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (featureHashedTables === true && ((_a = options.primaryKey) === null || _a === void 0 ? void 0 : _a.type) === TableAccessType.hashed) {
|
|
43
|
+
return new HashedTable(rowType, options, qualifiedName);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return new Table(rowType, options, qualifiedName);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.TableFactory = TableFactory;
|
|
51
|
+
class SortedTable {
|
|
52
|
+
}
|
|
53
|
+
exports.SortedTable = SortedTable;
|
|
54
|
+
class HashedTable {
|
|
55
|
+
constructor(rowType, options, qualifiedName) {
|
|
56
|
+
this.value = {};
|
|
57
|
+
this.secondaryIndexes = {};
|
|
58
|
+
this.loops = new Set();
|
|
59
|
+
this.rowType = rowType;
|
|
60
|
+
this.options = options;
|
|
61
|
+
// this.isStructured = rowType instanceof Structure;
|
|
62
|
+
this.options = options;
|
|
63
|
+
if ((options === null || options === void 0 ? void 0 : options.withHeader) === true) {
|
|
64
|
+
this.header = (0, clone_1.clone)(this.rowType);
|
|
65
|
+
}
|
|
66
|
+
this.qualifiedName = qualifiedName === null || qualifiedName === void 0 ? void 0 : qualifiedName.toUpperCase();
|
|
67
|
+
}
|
|
68
|
+
getLength() {
|
|
69
|
+
return Object.keys(this.value).length;
|
|
70
|
+
}
|
|
71
|
+
getKeyByName(name) {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
return (_b = (_a = this.getOptions()) === null || _a === void 0 ? void 0 : _a.secondary) === null || _b === void 0 ? void 0 : _b.find(s => s.name.toUpperCase() === name.toUpperCase());
|
|
74
|
+
}
|
|
75
|
+
getSecondaryIndex(name) {
|
|
76
|
+
if (this.secondaryIndexes[name.toUpperCase()]) {
|
|
77
|
+
return this.secondaryIndexes[name.toUpperCase()];
|
|
78
|
+
}
|
|
79
|
+
const secondary = this.getKeyByName(name);
|
|
80
|
+
if (secondary === undefined) {
|
|
81
|
+
throw `Table, secondary key "${name}" not found`;
|
|
82
|
+
}
|
|
83
|
+
const copy = (0, clone_1.clone)([...this.array()]);
|
|
84
|
+
(0, sort_1.sort)(copy, { by: secondary.keyFields.map(k => { return { component: k.toLowerCase() }; }) });
|
|
85
|
+
this.secondaryIndexes[name.toUpperCase()] = copy;
|
|
86
|
+
return copy;
|
|
87
|
+
}
|
|
88
|
+
insert(data) {
|
|
89
|
+
if (this.loops.size !== 0) {
|
|
90
|
+
throw new Error("Hash table insert inside LOOP");
|
|
91
|
+
}
|
|
92
|
+
let hash = "";
|
|
93
|
+
for (const k of this.options.primaryKey.keyFields) {
|
|
94
|
+
// @ts-ignore
|
|
95
|
+
hash += k + ":" + data.get()[k.toLowerCase()].get();
|
|
96
|
+
}
|
|
97
|
+
if (this.value[hash] !== undefined) {
|
|
98
|
+
return { value: undefined, subrc: 4 };
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
const val = this.getValue(data);
|
|
102
|
+
this.value[hash] = val;
|
|
103
|
+
return { value: val, subrc: 0 };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
array() {
|
|
107
|
+
// used for LOOP
|
|
108
|
+
const ret = [];
|
|
109
|
+
for (const hash in this.value) {
|
|
110
|
+
ret.push(this.value[hash]);
|
|
111
|
+
}
|
|
112
|
+
return ret;
|
|
113
|
+
}
|
|
114
|
+
startLoop(start = 0) {
|
|
115
|
+
const l = new LoopIndex(start);
|
|
116
|
+
this.loops.add(l);
|
|
117
|
+
return l;
|
|
118
|
+
}
|
|
119
|
+
unregisterLoop(loop) {
|
|
120
|
+
this.loops.delete(loop);
|
|
121
|
+
}
|
|
122
|
+
insertIndex(_item, _index) {
|
|
123
|
+
throw new Error("Hash table insert index");
|
|
124
|
+
}
|
|
125
|
+
append(_item) {
|
|
126
|
+
throw new Error("Hash table append");
|
|
127
|
+
}
|
|
128
|
+
getQualifiedName() {
|
|
129
|
+
return this.qualifiedName;
|
|
130
|
+
}
|
|
131
|
+
getOptions() {
|
|
132
|
+
return this.options;
|
|
133
|
+
}
|
|
134
|
+
getRowType() {
|
|
135
|
+
return this.rowType;
|
|
136
|
+
}
|
|
137
|
+
clear() {
|
|
138
|
+
this.value = {};
|
|
139
|
+
}
|
|
140
|
+
set(_tab) {
|
|
141
|
+
throw new Error("Method not implemented, set hashed table");
|
|
142
|
+
}
|
|
143
|
+
getHeader() {
|
|
144
|
+
if (this.header === undefined) {
|
|
145
|
+
throw "table, getHeader";
|
|
146
|
+
}
|
|
147
|
+
return this.header;
|
|
148
|
+
}
|
|
149
|
+
///////////////////////////
|
|
150
|
+
getValue(item) {
|
|
151
|
+
// make sure to do conversion if needed
|
|
152
|
+
if (typeof item === "number") {
|
|
153
|
+
const tmp = (0, clone_1.clone)(this.getRowType());
|
|
154
|
+
tmp.set(new integer_1.Integer().set(item));
|
|
155
|
+
return tmp;
|
|
156
|
+
}
|
|
157
|
+
else if (typeof item === "string") {
|
|
158
|
+
const tmp = (0, clone_1.clone)(this.getRowType());
|
|
159
|
+
tmp.set(new string_1.String().set(item));
|
|
160
|
+
return tmp;
|
|
161
|
+
// @ts-ignore
|
|
162
|
+
// eslint-disable-next-line max-len
|
|
163
|
+
}
|
|
164
|
+
else if (this.isStructured === true && item.getQualifiedName && this.rowType.getQualifiedName && item.getQualifiedName() !== "" && item.getQualifiedName() === this.rowType.getQualifiedName()) {
|
|
165
|
+
// types match, so no need to do conversions, just clone the item
|
|
166
|
+
const val = (0, clone_1.clone)(item);
|
|
167
|
+
return val;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const tmp = (0, clone_1.clone)(this.getRowType());
|
|
171
|
+
tmp.set(item);
|
|
172
|
+
return tmp;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.HashedTable = HashedTable;
|
|
26
177
|
class Table {
|
|
27
178
|
constructor(rowType, options, qualifiedName) {
|
|
28
179
|
this.value = [];
|
|
@@ -34,19 +185,11 @@ class Table {
|
|
|
34
185
|
if ((options === null || options === void 0 ? void 0 : options.withHeader) === true) {
|
|
35
186
|
this.header = (0, clone_1.clone)(this.rowType);
|
|
36
187
|
}
|
|
37
|
-
if (this.options === undefined) {
|
|
38
|
-
this.options = {
|
|
39
|
-
primaryKey: {
|
|
40
|
-
name: "primary_key",
|
|
41
|
-
type: TableAccessType.standard,
|
|
42
|
-
keyFields: [],
|
|
43
|
-
isUnique: false,
|
|
44
|
-
},
|
|
45
|
-
withHeader: false,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
188
|
this.qualifiedName = qualifiedName === null || qualifiedName === void 0 ? void 0 : qualifiedName.toUpperCase();
|
|
49
189
|
}
|
|
190
|
+
getLength() {
|
|
191
|
+
return this.value.length;
|
|
192
|
+
}
|
|
50
193
|
getKeyByName(name) {
|
|
51
194
|
var _a, _b;
|
|
52
195
|
return (_b = (_a = this.getOptions()) === null || _a === void 0 ? void 0 : _a.secondary) === null || _b === void 0 ? void 0 : _b.find(s => s.name.toUpperCase() === name.toUpperCase());
|
|
@@ -106,6 +249,7 @@ class Table {
|
|
|
106
249
|
// this clones the values, and add sorting if required
|
|
107
250
|
(0, insert_internal_1.insertInternal)({ table: this, data: tab, lines: true });
|
|
108
251
|
}
|
|
252
|
+
return this;
|
|
109
253
|
}
|
|
110
254
|
getHeader() {
|
|
111
255
|
if (this.header === undefined) {
|