@milaboratories/pl-model-common 1.25.1 → 1.25.3
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/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/author_marker.d.ts +9 -6
- package/dist/base32_encode.cjs +40 -46
- package/dist/base32_encode.cjs.map +1 -1
- package/dist/base32_encode.js +40 -45
- package/dist/base32_encode.js.map +1 -1
- package/dist/base64.cjs +5 -4
- package/dist/base64.cjs.map +1 -1
- package/dist/base64.d.ts +10 -6
- package/dist/base64.js +5 -3
- package/dist/base64.js.map +1 -1
- package/dist/block_state.d.ts +21 -23
- package/dist/bmodel/block_config.cjs +9 -10
- package/dist/bmodel/block_config.cjs.map +1 -1
- package/dist/bmodel/block_config.d.ts +53 -72
- package/dist/bmodel/block_config.js +9 -9
- package/dist/bmodel/block_config.js.map +1 -1
- package/dist/bmodel/code.cjs +7 -6
- package/dist/bmodel/code.cjs.map +1 -1
- package/dist/bmodel/code.d.ts +17 -13
- package/dist/bmodel/code.js +6 -4
- package/dist/bmodel/code.js.map +1 -1
- package/dist/bmodel/container.d.ts +46 -44
- package/dist/bmodel/index.cjs +3 -0
- package/dist/bmodel/index.d.ts +5 -6
- package/dist/bmodel/index.js +3 -0
- package/dist/bmodel/normalization.cjs +90 -106
- package/dist/bmodel/normalization.cjs.map +1 -1
- package/dist/bmodel/normalization.d.ts +7 -3
- package/dist/bmodel/normalization.js +90 -105
- package/dist/bmodel/normalization.js.map +1 -1
- package/dist/bmodel/types.d.ts +4 -1
- package/dist/branding.d.ts +5 -5
- package/dist/common_types.d.ts +19 -15
- package/dist/driver_kit.d.ts +25 -17
- package/dist/drivers/ChunkedStreamReader.cjs +168 -203
- package/dist/drivers/ChunkedStreamReader.cjs.map +1 -1
- package/dist/drivers/ChunkedStreamReader.d.ts +104 -100
- package/dist/drivers/ChunkedStreamReader.js +168 -202
- package/dist/drivers/ChunkedStreamReader.js.map +1 -1
- package/dist/drivers/blob.cjs +15 -17
- package/dist/drivers/blob.cjs.map +1 -1
- package/dist/drivers/blob.d.ts +35 -35
- package/dist/drivers/blob.js +14 -15
- package/dist/drivers/blob.js.map +1 -1
- package/dist/drivers/index.cjs +18 -0
- package/dist/drivers/index.d.ts +29 -9
- package/dist/drivers/index.js +18 -0
- package/dist/drivers/interfaces.d.ts +17 -14
- package/dist/drivers/log.cjs +4 -3
- package/dist/drivers/log.cjs.map +1 -1
- package/dist/drivers/log.d.ts +52 -49
- package/dist/drivers/log.js +4 -2
- package/dist/drivers/log.js.map +1 -1
- package/dist/drivers/ls.cjs +16 -19
- package/dist/drivers/ls.cjs.map +1 -1
- package/dist/drivers/ls.d.ts +73 -76
- package/dist/drivers/ls.js +16 -17
- package/dist/drivers/ls.js.map +1 -1
- package/dist/drivers/pframe/column_filter.d.ts +19 -15
- package/dist/drivers/pframe/data_info.cjs +201 -252
- package/dist/drivers/pframe/data_info.cjs.map +1 -1
- package/dist/drivers/pframe/data_info.d.ts +84 -109
- package/dist/drivers/pframe/data_info.js +201 -250
- package/dist/drivers/pframe/data_info.js.map +1 -1
- package/dist/drivers/pframe/data_types.cjs +38 -63
- package/dist/drivers/pframe/data_types.cjs.map +1 -1
- package/dist/drivers/pframe/data_types.d.ts +91 -93
- package/dist/drivers/pframe/data_types.js +38 -61
- package/dist/drivers/pframe/data_types.js.map +1 -1
- package/dist/drivers/pframe/driver.cjs +7 -0
- package/dist/drivers/pframe/driver.cjs.map +1 -0
- package/dist/drivers/pframe/driver.d.ts +50 -45
- package/dist/drivers/pframe/driver.js +6 -0
- package/dist/drivers/pframe/driver.js.map +1 -0
- package/dist/drivers/pframe/filter_spec.d.ts +127 -123
- package/dist/drivers/pframe/find_columns.d.ts +21 -17
- package/dist/drivers/pframe/index.cjs +15 -0
- package/dist/drivers/pframe/index.d.ts +23 -16
- package/dist/drivers/pframe/index.js +15 -0
- package/dist/drivers/pframe/linker_columns.cjs +184 -238
- package/dist/drivers/pframe/linker_columns.cjs.map +1 -1
- package/dist/drivers/pframe/linker_columns.d.ts +45 -38
- package/dist/drivers/pframe/linker_columns.js +184 -236
- package/dist/drivers/pframe/linker_columns.js.map +1 -1
- package/dist/drivers/pframe/pframe.d.ts +26 -21
- package/dist/drivers/pframe/query/index.cjs +1 -0
- package/dist/drivers/pframe/query/index.d.ts +3 -4
- package/dist/drivers/pframe/query/index.js +1 -0
- package/dist/drivers/pframe/query/query_common.d.ts +205 -247
- package/dist/drivers/pframe/query/query_data.d.ts +25 -23
- package/dist/drivers/pframe/query/query_spec.d.ts +30 -29
- package/dist/drivers/pframe/query/utils.cjs +164 -183
- package/dist/drivers/pframe/query/utils.cjs.map +1 -1
- package/dist/drivers/pframe/query/utils.d.ts +13 -12
- package/dist/drivers/pframe/query/utils.js +164 -181
- package/dist/drivers/pframe/query/utils.js.map +1 -1
- package/dist/drivers/pframe/spec/anchored.cjs +178 -216
- package/dist/drivers/pframe/spec/anchored.cjs.map +1 -1
- package/dist/drivers/pframe/spec/anchored.d.ts +53 -49
- package/dist/drivers/pframe/spec/anchored.js +176 -214
- package/dist/drivers/pframe/spec/anchored.js.map +1 -1
- package/dist/drivers/pframe/spec/filtered_column.cjs +8 -7
- package/dist/drivers/pframe/spec/filtered_column.cjs.map +1 -1
- package/dist/drivers/pframe/spec/filtered_column.d.ts +20 -17
- package/dist/drivers/pframe/spec/filtered_column.js +8 -6
- package/dist/drivers/pframe/spec/filtered_column.js.map +1 -1
- package/dist/drivers/pframe/spec/ids.cjs +16 -14
- package/dist/drivers/pframe/spec/ids.cjs.map +1 -1
- package/dist/drivers/pframe/spec/ids.d.ts +13 -8
- package/dist/drivers/pframe/spec/ids.js +14 -12
- package/dist/drivers/pframe/spec/ids.js.map +1 -1
- package/dist/drivers/pframe/spec/index.cjs +6 -0
- package/dist/drivers/pframe/spec/index.d.ts +6 -7
- package/dist/drivers/pframe/spec/index.js +6 -0
- package/dist/drivers/pframe/spec/native_id.cjs +16 -16
- package/dist/drivers/pframe/spec/native_id.cjs.map +1 -1
- package/dist/drivers/pframe/spec/native_id.d.ts +9 -4
- package/dist/drivers/pframe/spec/native_id.js +13 -13
- package/dist/drivers/pframe/spec/native_id.js.map +1 -1
- package/dist/drivers/pframe/spec/selectors.cjs +72 -112
- package/dist/drivers/pframe/spec/selectors.cjs.map +1 -1
- package/dist/drivers/pframe/spec/selectors.d.ts +99 -94
- package/dist/drivers/pframe/spec/selectors.js +72 -110
- package/dist/drivers/pframe/spec/selectors.js.map +1 -1
- package/dist/drivers/pframe/spec/spec.cjs +282 -324
- package/dist/drivers/pframe/spec/spec.cjs.map +1 -1
- package/dist/drivers/pframe/spec/spec.d.ts +263 -272
- package/dist/drivers/pframe/spec/spec.js +281 -322
- package/dist/drivers/pframe/spec/spec.js.map +1 -1
- package/dist/drivers/pframe/table.d.ts +28 -24
- package/dist/drivers/pframe/table_calculate.cjs +117 -147
- package/dist/drivers/pframe/table_calculate.cjs.map +1 -1
- package/dist/drivers/pframe/table_calculate.d.ts +219 -220
- package/dist/drivers/pframe/table_calculate.js +117 -145
- package/dist/drivers/pframe/table_calculate.js.map +1 -1
- package/dist/drivers/pframe/table_common.cjs +13 -14
- package/dist/drivers/pframe/table_common.cjs.map +1 -1
- package/dist/drivers/pframe/table_common.d.ts +24 -19
- package/dist/drivers/pframe/table_common.js +13 -13
- package/dist/drivers/pframe/table_common.js.map +1 -1
- package/dist/drivers/pframe/unique_values.d.ts +23 -18
- package/dist/drivers/upload.d.ts +21 -18
- package/dist/drivers/urls.cjs +5 -6
- package/dist/drivers/urls.cjs.map +1 -1
- package/dist/drivers/urls.d.ts +12 -9
- package/dist/drivers/urls.js +5 -5
- package/dist/drivers/urls.js.map +1 -1
- package/dist/errors.cjs +65 -86
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +36 -33
- package/dist/errors.js +65 -85
- package/dist/errors.js.map +1 -1
- package/dist/flags/block_flags.cjs +7 -6
- package/dist/flags/block_flags.cjs.map +1 -1
- package/dist/flags/block_flags.d.ts +12 -8
- package/dist/flags/block_flags.js +7 -5
- package/dist/flags/block_flags.js.map +1 -1
- package/dist/flags/flag_utils.cjs +69 -108
- package/dist/flags/flag_utils.cjs.map +1 -1
- package/dist/flags/flag_utils.d.ts +40 -42
- package/dist/flags/flag_utils.js +70 -107
- package/dist/flags/flag_utils.js.map +1 -1
- package/dist/flags/type_utils.d.ts +12 -11
- package/dist/httpAuth.cjs +16 -20
- package/dist/httpAuth.cjs.map +1 -1
- package/dist/httpAuth.d.ts +10 -7
- package/dist/httpAuth.js +16 -19
- package/dist/httpAuth.js.map +1 -1
- package/dist/index.cjs +176 -179
- package/dist/index.d.ts +58 -20
- package/dist/index.js +37 -34
- package/dist/json.cjs +10 -8
- package/dist/json.cjs.map +1 -1
- package/dist/json.d.ts +18 -18
- package/dist/json.js +8 -6
- package/dist/json.js.map +1 -1
- package/dist/navigation.cjs +3 -2
- package/dist/navigation.cjs.map +1 -1
- package/dist/navigation.d.ts +18 -21
- package/dist/navigation.js +3 -1
- package/dist/navigation.js.map +1 -1
- package/dist/plid.cjs +16 -20
- package/dist/plid.cjs.map +1 -1
- package/dist/plid.d.ts +11 -7
- package/dist/plid.js +15 -18
- package/dist/plid.js.map +1 -1
- package/dist/pool/entry.d.ts +11 -11
- package/dist/pool/index.d.ts +3 -4
- package/dist/pool/query.cjs +21 -43
- package/dist/pool/query.cjs.map +1 -1
- package/dist/pool/query.d.ts +25 -20
- package/dist/pool/query.js +20 -40
- package/dist/pool/query.js.map +1 -1
- package/dist/pool/spec.cjs +40 -47
- package/dist/pool/spec.cjs.map +1 -1
- package/dist/pool/spec.d.ts +33 -31
- package/dist/pool/spec.js +40 -45
- package/dist/pool/spec.js.map +1 -1
- package/dist/ref.cjs +51 -71
- package/dist/ref.cjs.map +1 -1
- package/dist/ref.d.ts +36 -33
- package/dist/ref.js +50 -69
- package/dist/ref.js.map +1 -1
- package/dist/utag.d.ts +18 -14
- package/dist/util.cjs +8 -7
- package/dist/util.cjs.map +1 -1
- package/dist/util.d.ts +5 -2
- package/dist/util.js +8 -6
- package/dist/util.js.map +1 -1
- package/dist/value_or_error.cjs +7 -3
- package/dist/value_or_error.cjs.map +1 -1
- package/dist/value_or_error.d.ts +9 -6
- package/dist/value_or_error.js +7 -2
- package/dist/value_or_error.js.map +1 -1
- package/package.json +6 -6
- package/src/flags/block_flags.ts +2 -1
- package/src/flags/flag_utils.ts +0 -22
- package/dist/author_marker.d.ts.map +0 -1
- package/dist/base32_encode.d.ts +0 -8
- package/dist/base32_encode.d.ts.map +0 -1
- package/dist/base64.d.ts.map +0 -1
- package/dist/block_state.d.ts.map +0 -1
- package/dist/bmodel/block_config.d.ts.map +0 -1
- package/dist/bmodel/code.d.ts.map +0 -1
- package/dist/bmodel/container.d.ts.map +0 -1
- package/dist/bmodel/index.d.ts.map +0 -1
- package/dist/bmodel/normalization.d.ts.map +0 -1
- package/dist/bmodel/types.d.ts.map +0 -1
- package/dist/branding.d.ts.map +0 -1
- package/dist/common_types.d.ts.map +0 -1
- package/dist/driver_kit.d.ts.map +0 -1
- package/dist/drivers/ChunkedStreamReader.d.ts.map +0 -1
- package/dist/drivers/blob.d.ts.map +0 -1
- package/dist/drivers/index.d.ts.map +0 -1
- package/dist/drivers/interfaces.d.ts.map +0 -1
- package/dist/drivers/log.d.ts.map +0 -1
- package/dist/drivers/ls.d.ts.map +0 -1
- package/dist/drivers/pframe/column_filter.d.ts.map +0 -1
- package/dist/drivers/pframe/data_info.d.ts.map +0 -1
- package/dist/drivers/pframe/data_types.d.ts.map +0 -1
- package/dist/drivers/pframe/driver.d.ts.map +0 -1
- package/dist/drivers/pframe/filter_spec.d.ts.map +0 -1
- package/dist/drivers/pframe/find_columns.d.ts.map +0 -1
- package/dist/drivers/pframe/index.d.ts.map +0 -1
- package/dist/drivers/pframe/linker_columns.d.ts.map +0 -1
- package/dist/drivers/pframe/pframe.d.ts.map +0 -1
- package/dist/drivers/pframe/query/index.d.ts.map +0 -1
- package/dist/drivers/pframe/query/query_common.d.ts.map +0 -1
- package/dist/drivers/pframe/query/query_data.d.ts.map +0 -1
- package/dist/drivers/pframe/query/query_spec.d.ts.map +0 -1
- package/dist/drivers/pframe/query/utils.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/anchored.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/filtered_column.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/ids.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/index.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/native_id.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/selectors.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/spec.d.ts.map +0 -1
- package/dist/drivers/pframe/table.d.ts.map +0 -1
- package/dist/drivers/pframe/table_calculate.d.ts.map +0 -1
- package/dist/drivers/pframe/table_common.d.ts.map +0 -1
- package/dist/drivers/pframe/type_util.d.ts +0 -5
- package/dist/drivers/pframe/type_util.d.ts.map +0 -1
- package/dist/drivers/pframe/unique_values.d.ts.map +0 -1
- package/dist/drivers/upload.d.ts.map +0 -1
- package/dist/drivers/urls.d.ts.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/flags/block_flags.d.ts.map +0 -1
- package/dist/flags/flag_utils.d.ts.map +0 -1
- package/dist/flags/index.d.ts +0 -4
- package/dist/flags/index.d.ts.map +0 -1
- package/dist/flags/type_utils.d.ts.map +0 -1
- package/dist/httpAuth.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/json.d.ts.map +0 -1
- package/dist/navigation.d.ts.map +0 -1
- package/dist/plid.d.ts.map +0 -1
- package/dist/pool/entry.d.ts.map +0 -1
- package/dist/pool/index.d.ts.map +0 -1
- package/dist/pool/query.d.ts.map +0 -1
- package/dist/pool/spec.d.ts.map +0 -1
- package/dist/ref.d.ts.map +0 -1
- package/dist/utag.d.ts.map +0 -1
- package/dist/util.d.ts.map +0 -1
- package/dist/value_or_error.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table_calculate.cjs","sources":["../../../src/drivers/pframe/table_calculate.ts"],"sourcesContent":["import type { PTableColumnId, PTableColumnSpec } from \"./table_common\";\nimport type { PTableVector } from \"./data_types\";\nimport type { PObjectId } from \"../../pool\";\nimport { assertNever } from \"../../util\";\nimport { getAxisId, type PColumn } from \"./spec/spec\";\nimport type { PColumnValues } from \"./data_info\";\nimport type { SpecQuery } from \"./query/query_spec\";\nimport { canonicalizeJson } from \"../../json\";\nimport { mapSpecQueryColumns } from \"./query\";\n\n/** Defines a terminal column node in the join request tree */\nexport interface ColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: \"column\";\n\n /** Local column */\n readonly column: Col;\n}\n\n/**\n * Axis filter slicing target axis from column axes.\n * If the axis has parents or is a parent, slicing cannot be applied (an error will be thrown).\n * */\nexport interface ConstantAxisFilter {\n /** Filter type discriminator */\n readonly type: \"constant\";\n\n /** Index of axis to slice (zero-based) */\n readonly axisIndex: number;\n\n /** Equality filter reference value, see {@link SingleValueEqualPredicate} */\n readonly constant: string | number;\n}\n\n/** Defines a terminal column node in the join request tree */\nexport interface SlicedColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: \"slicedColumn\";\n\n /** Local column */\n readonly column: Col;\n\n /** New column id */\n readonly newId: PObjectId;\n\n /** Non-empty list of axis filters */\n readonly axisFilters: ConstantAxisFilter[];\n}\n\nexport interface ArtificialColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: \"artificialColumn\";\n\n /** Column definition */\n readonly column: Col;\n\n /** New column id */\n readonly newId: PObjectId;\n\n /** Indices of axes to pick from the column (zero-based) */\n readonly axesIndices: number[];\n}\n\n/** Defines a terminal column node in the join request tree */\nexport interface InlineColumnJoinEntry {\n /** Node type discriminator */\n readonly type: \"inlineColumn\";\n\n /** Column definition */\n readonly column: PColumn<PColumnValues>;\n}\n\n/**\n * Defines a join request tree node that will output only records present in\n * all child nodes ({@link entries}).\n * */\nexport interface InnerJoin<Col> {\n /** Node type discriminator */\n readonly type: \"inner\";\n\n /** Child nodes to be inner joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present at\n * least in one of the child nodes ({@link entries}), values for those PColumns\n * that lacks corresponding combinations of axis values will be marked as absent,\n * see {@link PTableVector.absent}.\n * */\nexport interface FullJoin<Col> {\n /** Node type discriminator */\n readonly type: \"full\";\n\n /** Child nodes to be fully outer joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present in\n * {@link primary} child node, and records from the {@link secondary} nodes will\n * be added to the output only if present, values for those PColumns from the\n * {@link secondary} list, that lacks corresponding combinations of axis values\n * will be marked as absent, see {@link PTableVector.absent}.\n *\n * This node can be thought as a chain of SQL LEFT JOIN operations starting from\n * the {@link primary} node and adding {@link secondary} nodes one by one.\n * */\nexport interface OuterJoin<Col> {\n /** Node type discriminator */\n readonly type: \"outer\";\n\n /** Primes the join operation. Left part of LEFT JOIN. */\n readonly primary: JoinEntry<Col>;\n\n /** Driven nodes, giving their values only if primary node have corresponding\n * nodes. Right parts of LEFT JOIN chain. */\n readonly secondary: JoinEntry<Col>[];\n}\n\n/**\n * Base type of all join request tree nodes. Join request tree allows to combine\n * information from multiple PColumns into a PTable. Correlation between records\n * is performed by looking for records with the same values in common axis between\n * the PColumns. Common axis are those axis which have equal {@link AxisId} derived\n * from the columns axes spec.\n * */\nexport type JoinEntry<Col> =\n | ColumnJoinEntry<Col>\n | SlicedColumnJoinEntry<Col>\n | ArtificialColumnJoinEntry<Col>\n | InlineColumnJoinEntry\n | InnerJoin<Col>\n | FullJoin<Col>\n | OuterJoin<Col>;\n\n/** Container representing whole data stored in specific PTable column. */\nexport interface FullPTableColumnData {\n /** Unified spec */\n readonly spec: PTableColumnSpec;\n\n /** Data */\n readonly data: PTableVector;\n}\n\nexport interface SingleValueIsNAPredicate {\n /** Comparison operator */\n readonly operator: \"IsNA\";\n}\n\nexport interface SingleValueEqualPredicate {\n /** Comparison operator */\n readonly operator: \"Equal\";\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueInSetPredicate {\n /** Comparison operator */\n readonly operator: \"InSet\";\n\n /** Reference values, NA values will not match */\n readonly references: (string | number)[];\n}\n\nexport interface SingleValueIEqualPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: \"IEqual\";\n\n /** Reference value, NA values will not match */\n readonly reference: string;\n}\n\nexport interface SingleValueLessPredicate {\n /** Comparison operator */\n readonly operator: \"Less\";\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueLessOrEqualPredicate {\n /** Comparison operator */\n readonly operator: \"LessOrEqual\";\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterPredicate {\n /** Comparison operator */\n readonly operator: \"Greater\";\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterOrEqualPredicate {\n /** Comparison operator */\n readonly operator: \"GreaterOrEqual\";\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueStringContainsPredicate {\n /** Comparison operator */\n readonly operator: \"StringContains\";\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueStringIContainsPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: \"StringIContains\";\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueMatchesPredicate {\n /** Comparison operator */\n readonly operator: \"Matches\";\n\n /** Regular expression, NA values are skipped */\n readonly regex: string;\n}\n\nexport interface SingleValueStringContainsFuzzyPredicate {\n /** Comparison operator */\n readonly operator: \"StringContainsFuzzy\";\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueStringIContainsFuzzyPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: \"StringIContainsFuzzy\";\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueNotPredicateV2 {\n /** Comparison operator */\n readonly operator: \"Not\";\n\n /** Operand to negate */\n readonly operand: SingleValuePredicateV2;\n}\n\nexport interface SingleValueAndPredicateV2 {\n /** Comparison operator */\n readonly operator: \"And\";\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\nexport interface SingleValueOrPredicateV2 {\n /** Comparison operator */\n readonly operator: \"Or\";\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\n/** Filtering predicate for a single axis or column value */\nexport type SingleValuePredicateV2 =\n | SingleValueIsNAPredicate\n | SingleValueEqualPredicate\n | SingleValueInSetPredicate\n | SingleValueLessPredicate\n | SingleValueLessOrEqualPredicate\n | SingleValueGreaterPredicate\n | SingleValueGreaterOrEqualPredicate\n | SingleValueStringContainsPredicate\n | SingleValueMatchesPredicate\n | SingleValueStringContainsFuzzyPredicate\n | SingleValueNotPredicateV2\n | SingleValueAndPredicateV2\n | SingleValueOrPredicateV2\n | SingleValueIEqualPredicate\n | SingleValueStringIContainsPredicate\n | SingleValueStringIContainsFuzzyPredicate;\n\n/**\n * Filter PTable records based on specific axis or column value. If this is an\n * axis value filter and the axis is part of a partitioning key in some of the\n * source PColumns, the filter will be pushed down to those columns, so only\n * specific partitions will be retrieved from the remote storage.\n * */\nexport interface PTableRecordSingleValueFilterV2 {\n /** Filter type discriminator */\n readonly type: \"bySingleColumnV2\";\n\n /** Target axis selector to examine values from */\n readonly column: PTableColumnId;\n\n /** Value predicate */\n readonly predicate: SingleValuePredicateV2;\n}\n\n/** Generic PTable records filter */\nexport type PTableRecordFilter = PTableRecordSingleValueFilterV2;\n\n/** Sorting parameters for a PTable. */\nexport type PTableSorting = {\n /** Unified column identifier */\n readonly column: PTableColumnId;\n\n /** Sorting order */\n readonly ascending: boolean;\n\n /** Sorting in respect to NA and absent values */\n readonly naAndAbsentAreLeastValues: boolean;\n};\n\n/** Information required to instantiate a PTable. */\nexport interface PTableDef<Col> {\n /** Join tree to populate the PTable */\n readonly src: JoinEntry<Col>;\n\n /** Partition filters */\n readonly partitionFilters: PTableRecordFilter[];\n\n /** Record filters */\n readonly filters: PTableRecordFilter[];\n\n /** Table sorting */\n readonly sorting: PTableSorting[];\n}\n\n/** Information required to instantiate a PTable (V2, query-based). */\nexport interface PTableDefV2<Col> {\n /** Pre-built query spec describing joins, filters and sorting */\n readonly query: SpecQuery<Col>;\n}\n\n/** Request to create and retrieve entirety of data of PTable. */\nexport type CalculateTableDataRequest<Col> = {\n /** Join tree to populate the PTable */\n readonly src: JoinEntry<Col>;\n\n /** Record filters */\n readonly filters: PTableRecordFilter[];\n\n /** Table sorting */\n readonly sorting: PTableSorting[];\n};\n\n/** Response for {@link CalculateTableDataRequest} */\nexport type CalculateTableDataResponse = FullPTableColumnData[];\n\nexport function mapPTableDef<C1, C2>(def: PTableDef<C1>, cb: (c: C1) => C2): PTableDef<C2> {\n return { ...def, src: mapJoinEntry(def.src, cb) };\n}\n\nexport function sortPTableDef(def: PTableDef<PObjectId>): PTableDef<PObjectId> {\n function sortFilters(filters: PTableRecordFilter[]): PTableRecordFilter[] {\n return filters.toSorted((lhs, rhs) => {\n if (lhs.column.type === \"axis\" && rhs.column.type === \"axis\") {\n const lhsId = canonicalizeJson(getAxisId(lhs.column.id));\n const rhsId = canonicalizeJson(getAxisId(rhs.column.id));\n return lhsId < rhsId ? -1 : 1;\n } else if (lhs.column.type === \"column\" && rhs.column.type === \"column\") {\n return lhs.column.id < rhs.column.id ? -1 : 1;\n } else {\n return lhs.column.type === \"axis\" ? -1 : 1;\n }\n });\n }\n return {\n src: sortJoinEntry(def.src),\n partitionFilters: sortFilters(def.partitionFilters),\n filters: sortFilters(def.filters),\n sorting: def.sorting,\n };\n}\n\nexport function mapPTableDefV2<C1, C2>(def: PTableDefV2<C1>, cb: (c: C1) => C2): PTableDefV2<C2> {\n return { query: mapSpecQueryColumns(def.query, cb) };\n}\n\nexport function mapJoinEntry<C1, C2>(entry: JoinEntry<C1>, cb: (c: C1) => C2): JoinEntry<C2> {\n switch (entry.type) {\n case \"column\":\n return {\n type: \"column\",\n column: cb(entry.column),\n };\n case \"slicedColumn\":\n return {\n type: \"slicedColumn\",\n column: cb(entry.column),\n newId: entry.newId,\n axisFilters: entry.axisFilters,\n };\n case \"artificialColumn\":\n return {\n type: \"artificialColumn\",\n column: cb(entry.column),\n newId: entry.newId,\n axesIndices: entry.axesIndices,\n };\n case \"inlineColumn\":\n return entry;\n case \"inner\":\n case \"full\":\n return {\n type: entry.type,\n entries: entry.entries.map((col) => mapJoinEntry(col, cb)),\n };\n case \"outer\":\n return {\n type: \"outer\",\n primary: mapJoinEntry(entry.primary, cb),\n secondary: entry.secondary.map((col) => mapJoinEntry(col, cb)),\n };\n default:\n assertNever(entry);\n }\n}\n\nfunction cmpJoinEntries(lhs: JoinEntry<PObjectId>, rhs: JoinEntry<PObjectId>): number {\n if (lhs.type !== rhs.type) {\n return lhs.type < rhs.type ? -1 : 1;\n }\n const type = lhs.type;\n switch (type) {\n case \"column\":\n return lhs.column < (rhs as typeof lhs).column ? -1 : 1;\n case \"slicedColumn\":\n case \"artificialColumn\":\n return lhs.newId < (rhs as typeof lhs).newId ? -1 : 1;\n case \"inlineColumn\": {\n return lhs.column.id < (rhs as typeof lhs).column.id ? -1 : 1;\n }\n case \"inner\":\n case \"full\": {\n const rhsInner = rhs as typeof lhs;\n if (lhs.entries.length !== rhsInner.entries.length) {\n return lhs.entries.length - rhsInner.entries.length;\n }\n for (let i = 0; i < lhs.entries.length; i++) {\n const cmp = cmpJoinEntries(lhs.entries[i], rhsInner.entries[i]);\n if (cmp !== 0) {\n return cmp;\n }\n }\n return 0;\n }\n case \"outer\": {\n const rhsOuter = rhs as typeof lhs;\n const cmp = cmpJoinEntries(lhs.primary, rhsOuter.primary);\n if (cmp !== 0) {\n return cmp;\n }\n if (lhs.secondary.length !== rhsOuter.secondary.length) {\n return lhs.secondary.length - rhsOuter.secondary.length;\n }\n for (let i = 0; i < lhs.secondary.length; i++) {\n const cmp = cmpJoinEntries(lhs.secondary[i], rhsOuter.secondary[i]);\n if (cmp !== 0) {\n return cmp;\n }\n }\n return 0;\n }\n default:\n assertNever(type);\n }\n}\n\nexport function sortJoinEntry(entry: JoinEntry<PObjectId>): JoinEntry<PObjectId> {\n switch (entry.type) {\n case \"column\":\n case \"slicedColumn\":\n case \"inlineColumn\":\n return entry;\n case \"artificialColumn\": {\n const sortedAxesIndices = entry.axesIndices.toSorted((lhs, rhs) => lhs - rhs);\n return {\n ...entry,\n axesIndices: sortedAxesIndices,\n };\n }\n case \"inner\":\n case \"full\": {\n const sortedEntries = entry.entries.map(sortJoinEntry);\n sortedEntries.sort(cmpJoinEntries);\n return {\n ...entry,\n entries: sortedEntries,\n };\n }\n case \"outer\": {\n const sortedSecondary = entry.secondary.map(sortJoinEntry);\n sortedSecondary.sort(cmpJoinEntries);\n return {\n ...entry,\n primary: sortJoinEntry(entry.primary),\n secondary: sortedSecondary,\n };\n }\n default:\n assertNever(entry);\n }\n}\n"],"names":["canonicalizeJson","getAxisId","mapSpecQueryColumns","assertNever"],"mappings":";;;;;;;AA+YM,SAAU,YAAY,CAAS,GAAkB,EAAE,EAAiB,EAAA;AACxE,IAAA,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE;AACnD;AAEM,SAAU,aAAa,CAAC,GAAyB,EAAA;IACrD,SAAS,WAAW,CAAC,OAA6B,EAAA;QAChD,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,GAAG,KAAI;AACnC,YAAA,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE;AAC5D,gBAAA,MAAM,KAAK,GAAGA,qBAAgB,CAACC,cAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACxD,gBAAA,MAAM,KAAK,GAAGD,qBAAgB,CAACC,cAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACxD,gBAAA,OAAO,KAAK,GAAG,KAAK,GAAG,EAAE,GAAG,CAAC;YAC/B;AAAO,iBAAA,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACvE,OAAO,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC;YAC/C;iBAAO;AACL,gBAAA,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,GAAG,EAAE,GAAG,CAAC;YAC5C;AACF,QAAA,CAAC,CAAC;IACJ;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B,EAAA;AACvD,IAAA,QAAQ,KAAK,CAAC,IAAI;AAChB,QAAA,KAAK,QAAQ;AACb,QAAA,KAAK,cAAc;AACnB,QAAA,KAAK,cAAc;AACjB,YAAA,OAAO,KAAK;QACd,KAAK,kBAAkB,EAAE;AACvB,YAAA,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,CAAC;YAC7E,OAAO;AACL,gBAAA,GAAG,KAAK;AACR,gBAAA,WAAW,EAAE,iBAAiB;aAC/B;QACH;AACA,QAAA,KAAK,OAAO;QACZ,KAAK,MAAM,EAAE;YACX,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;AACtD,YAAA,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC;YAClC,OAAO;AACL,gBAAA,GAAG,KAAK;AACR,gBAAA,OAAO,EAAE,aAAa;aACvB;QACH;QACA,KAAK,OAAO,EAAE;YACZ,MAAM,eAAe,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC;AAC1D,YAAA,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC;YACpC,OAAO;AACL,gBAAA,GAAG,KAAK;AACR,gBAAA,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC;AACrC,gBAAA,SAAS,EAAE,eAAe;aAC3B;QACH;AACA,QAAA;YACEA,gBAAW,CAAC,KAAK,CAAC;;AAExB;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"table_calculate.cjs","names":["canonicalizeJson","getAxisId","mapSpecQueryColumns"],"sources":["../../../src/drivers/pframe/table_calculate.ts"],"sourcesContent":["import type { PTableColumnId, PTableColumnSpec } from \"./table_common\";\nimport type { PTableVector } from \"./data_types\";\nimport type { PObjectId } from \"../../pool\";\nimport { assertNever } from \"../../util\";\nimport { getAxisId, type PColumn } from \"./spec/spec\";\nimport type { PColumnValues } from \"./data_info\";\nimport type { SpecQuery } from \"./query/query_spec\";\nimport { canonicalizeJson } from \"../../json\";\nimport { mapSpecQueryColumns } from \"./query\";\n\n/** Defines a terminal column node in the join request tree */\nexport interface ColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: \"column\";\n\n /** Local column */\n readonly column: Col;\n}\n\n/**\n * Axis filter slicing target axis from column axes.\n * If the axis has parents or is a parent, slicing cannot be applied (an error will be thrown).\n * */\nexport interface ConstantAxisFilter {\n /** Filter type discriminator */\n readonly type: \"constant\";\n\n /** Index of axis to slice (zero-based) */\n readonly axisIndex: number;\n\n /** Equality filter reference value, see {@link SingleValueEqualPredicate} */\n readonly constant: string | number;\n}\n\n/** Defines a terminal column node in the join request tree */\nexport interface SlicedColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: \"slicedColumn\";\n\n /** Local column */\n readonly column: Col;\n\n /** New column id */\n readonly newId: PObjectId;\n\n /** Non-empty list of axis filters */\n readonly axisFilters: ConstantAxisFilter[];\n}\n\nexport interface ArtificialColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: \"artificialColumn\";\n\n /** Column definition */\n readonly column: Col;\n\n /** New column id */\n readonly newId: PObjectId;\n\n /** Indices of axes to pick from the column (zero-based) */\n readonly axesIndices: number[];\n}\n\n/** Defines a terminal column node in the join request tree */\nexport interface InlineColumnJoinEntry {\n /** Node type discriminator */\n readonly type: \"inlineColumn\";\n\n /** Column definition */\n readonly column: PColumn<PColumnValues>;\n}\n\n/**\n * Defines a join request tree node that will output only records present in\n * all child nodes ({@link entries}).\n * */\nexport interface InnerJoin<Col> {\n /** Node type discriminator */\n readonly type: \"inner\";\n\n /** Child nodes to be inner joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present at\n * least in one of the child nodes ({@link entries}), values for those PColumns\n * that lacks corresponding combinations of axis values will be marked as absent,\n * see {@link PTableVector.absent}.\n * */\nexport interface FullJoin<Col> {\n /** Node type discriminator */\n readonly type: \"full\";\n\n /** Child nodes to be fully outer joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present in\n * {@link primary} child node, and records from the {@link secondary} nodes will\n * be added to the output only if present, values for those PColumns from the\n * {@link secondary} list, that lacks corresponding combinations of axis values\n * will be marked as absent, see {@link PTableVector.absent}.\n *\n * This node can be thought as a chain of SQL LEFT JOIN operations starting from\n * the {@link primary} node and adding {@link secondary} nodes one by one.\n * */\nexport interface OuterJoin<Col> {\n /** Node type discriminator */\n readonly type: \"outer\";\n\n /** Primes the join operation. Left part of LEFT JOIN. */\n readonly primary: JoinEntry<Col>;\n\n /** Driven nodes, giving their values only if primary node have corresponding\n * nodes. Right parts of LEFT JOIN chain. */\n readonly secondary: JoinEntry<Col>[];\n}\n\n/**\n * Base type of all join request tree nodes. Join request tree allows to combine\n * information from multiple PColumns into a PTable. Correlation between records\n * is performed by looking for records with the same values in common axis between\n * the PColumns. Common axis are those axis which have equal {@link AxisId} derived\n * from the columns axes spec.\n * */\nexport type JoinEntry<Col> =\n | ColumnJoinEntry<Col>\n | SlicedColumnJoinEntry<Col>\n | ArtificialColumnJoinEntry<Col>\n | InlineColumnJoinEntry\n | InnerJoin<Col>\n | FullJoin<Col>\n | OuterJoin<Col>;\n\n/** Container representing whole data stored in specific PTable column. */\nexport interface FullPTableColumnData {\n /** Unified spec */\n readonly spec: PTableColumnSpec;\n\n /** Data */\n readonly data: PTableVector;\n}\n\nexport interface SingleValueIsNAPredicate {\n /** Comparison operator */\n readonly operator: \"IsNA\";\n}\n\nexport interface SingleValueEqualPredicate {\n /** Comparison operator */\n readonly operator: \"Equal\";\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueInSetPredicate {\n /** Comparison operator */\n readonly operator: \"InSet\";\n\n /** Reference values, NA values will not match */\n readonly references: (string | number)[];\n}\n\nexport interface SingleValueIEqualPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: \"IEqual\";\n\n /** Reference value, NA values will not match */\n readonly reference: string;\n}\n\nexport interface SingleValueLessPredicate {\n /** Comparison operator */\n readonly operator: \"Less\";\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueLessOrEqualPredicate {\n /** Comparison operator */\n readonly operator: \"LessOrEqual\";\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterPredicate {\n /** Comparison operator */\n readonly operator: \"Greater\";\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterOrEqualPredicate {\n /** Comparison operator */\n readonly operator: \"GreaterOrEqual\";\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueStringContainsPredicate {\n /** Comparison operator */\n readonly operator: \"StringContains\";\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueStringIContainsPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: \"StringIContains\";\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueMatchesPredicate {\n /** Comparison operator */\n readonly operator: \"Matches\";\n\n /** Regular expression, NA values are skipped */\n readonly regex: string;\n}\n\nexport interface SingleValueStringContainsFuzzyPredicate {\n /** Comparison operator */\n readonly operator: \"StringContainsFuzzy\";\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueStringIContainsFuzzyPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: \"StringIContainsFuzzy\";\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueNotPredicateV2 {\n /** Comparison operator */\n readonly operator: \"Not\";\n\n /** Operand to negate */\n readonly operand: SingleValuePredicateV2;\n}\n\nexport interface SingleValueAndPredicateV2 {\n /** Comparison operator */\n readonly operator: \"And\";\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\nexport interface SingleValueOrPredicateV2 {\n /** Comparison operator */\n readonly operator: \"Or\";\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\n/** Filtering predicate for a single axis or column value */\nexport type SingleValuePredicateV2 =\n | SingleValueIsNAPredicate\n | SingleValueEqualPredicate\n | SingleValueInSetPredicate\n | SingleValueLessPredicate\n | SingleValueLessOrEqualPredicate\n | SingleValueGreaterPredicate\n | SingleValueGreaterOrEqualPredicate\n | SingleValueStringContainsPredicate\n | SingleValueMatchesPredicate\n | SingleValueStringContainsFuzzyPredicate\n | SingleValueNotPredicateV2\n | SingleValueAndPredicateV2\n | SingleValueOrPredicateV2\n | SingleValueIEqualPredicate\n | SingleValueStringIContainsPredicate\n | SingleValueStringIContainsFuzzyPredicate;\n\n/**\n * Filter PTable records based on specific axis or column value. If this is an\n * axis value filter and the axis is part of a partitioning key in some of the\n * source PColumns, the filter will be pushed down to those columns, so only\n * specific partitions will be retrieved from the remote storage.\n * */\nexport interface PTableRecordSingleValueFilterV2 {\n /** Filter type discriminator */\n readonly type: \"bySingleColumnV2\";\n\n /** Target axis selector to examine values from */\n readonly column: PTableColumnId;\n\n /** Value predicate */\n readonly predicate: SingleValuePredicateV2;\n}\n\n/** Generic PTable records filter */\nexport type PTableRecordFilter = PTableRecordSingleValueFilterV2;\n\n/** Sorting parameters for a PTable. */\nexport type PTableSorting = {\n /** Unified column identifier */\n readonly column: PTableColumnId;\n\n /** Sorting order */\n readonly ascending: boolean;\n\n /** Sorting in respect to NA and absent values */\n readonly naAndAbsentAreLeastValues: boolean;\n};\n\n/** Information required to instantiate a PTable. */\nexport interface PTableDef<Col> {\n /** Join tree to populate the PTable */\n readonly src: JoinEntry<Col>;\n\n /** Partition filters */\n readonly partitionFilters: PTableRecordFilter[];\n\n /** Record filters */\n readonly filters: PTableRecordFilter[];\n\n /** Table sorting */\n readonly sorting: PTableSorting[];\n}\n\n/** Information required to instantiate a PTable (V2, query-based). */\nexport interface PTableDefV2<Col> {\n /** Pre-built query spec describing joins, filters and sorting */\n readonly query: SpecQuery<Col>;\n}\n\n/** Request to create and retrieve entirety of data of PTable. */\nexport type CalculateTableDataRequest<Col> = {\n /** Join tree to populate the PTable */\n readonly src: JoinEntry<Col>;\n\n /** Record filters */\n readonly filters: PTableRecordFilter[];\n\n /** Table sorting */\n readonly sorting: PTableSorting[];\n};\n\n/** Response for {@link CalculateTableDataRequest} */\nexport type CalculateTableDataResponse = FullPTableColumnData[];\n\nexport function mapPTableDef<C1, C2>(def: PTableDef<C1>, cb: (c: C1) => C2): PTableDef<C2> {\n return { ...def, src: mapJoinEntry(def.src, cb) };\n}\n\nexport function sortPTableDef(def: PTableDef<PObjectId>): PTableDef<PObjectId> {\n function sortFilters(filters: PTableRecordFilter[]): PTableRecordFilter[] {\n return filters.toSorted((lhs, rhs) => {\n if (lhs.column.type === \"axis\" && rhs.column.type === \"axis\") {\n const lhsId = canonicalizeJson(getAxisId(lhs.column.id));\n const rhsId = canonicalizeJson(getAxisId(rhs.column.id));\n return lhsId < rhsId ? -1 : 1;\n } else if (lhs.column.type === \"column\" && rhs.column.type === \"column\") {\n return lhs.column.id < rhs.column.id ? -1 : 1;\n } else {\n return lhs.column.type === \"axis\" ? -1 : 1;\n }\n });\n }\n return {\n src: sortJoinEntry(def.src),\n partitionFilters: sortFilters(def.partitionFilters),\n filters: sortFilters(def.filters),\n sorting: def.sorting,\n };\n}\n\nexport function mapPTableDefV2<C1, C2>(def: PTableDefV2<C1>, cb: (c: C1) => C2): PTableDefV2<C2> {\n return { query: mapSpecQueryColumns(def.query, cb) };\n}\n\nexport function mapJoinEntry<C1, C2>(entry: JoinEntry<C1>, cb: (c: C1) => C2): JoinEntry<C2> {\n switch (entry.type) {\n case \"column\":\n return {\n type: \"column\",\n column: cb(entry.column),\n };\n case \"slicedColumn\":\n return {\n type: \"slicedColumn\",\n column: cb(entry.column),\n newId: entry.newId,\n axisFilters: entry.axisFilters,\n };\n case \"artificialColumn\":\n return {\n type: \"artificialColumn\",\n column: cb(entry.column),\n newId: entry.newId,\n axesIndices: entry.axesIndices,\n };\n case \"inlineColumn\":\n return entry;\n case \"inner\":\n case \"full\":\n return {\n type: entry.type,\n entries: entry.entries.map((col) => mapJoinEntry(col, cb)),\n };\n case \"outer\":\n return {\n type: \"outer\",\n primary: mapJoinEntry(entry.primary, cb),\n secondary: entry.secondary.map((col) => mapJoinEntry(col, cb)),\n };\n default:\n assertNever(entry);\n }\n}\n\nfunction cmpJoinEntries(lhs: JoinEntry<PObjectId>, rhs: JoinEntry<PObjectId>): number {\n if (lhs.type !== rhs.type) {\n return lhs.type < rhs.type ? -1 : 1;\n }\n const type = lhs.type;\n switch (type) {\n case \"column\":\n return lhs.column < (rhs as typeof lhs).column ? -1 : 1;\n case \"slicedColumn\":\n case \"artificialColumn\":\n return lhs.newId < (rhs as typeof lhs).newId ? -1 : 1;\n case \"inlineColumn\": {\n return lhs.column.id < (rhs as typeof lhs).column.id ? -1 : 1;\n }\n case \"inner\":\n case \"full\": {\n const rhsInner = rhs as typeof lhs;\n if (lhs.entries.length !== rhsInner.entries.length) {\n return lhs.entries.length - rhsInner.entries.length;\n }\n for (let i = 0; i < lhs.entries.length; i++) {\n const cmp = cmpJoinEntries(lhs.entries[i], rhsInner.entries[i]);\n if (cmp !== 0) {\n return cmp;\n }\n }\n return 0;\n }\n case \"outer\": {\n const rhsOuter = rhs as typeof lhs;\n const cmp = cmpJoinEntries(lhs.primary, rhsOuter.primary);\n if (cmp !== 0) {\n return cmp;\n }\n if (lhs.secondary.length !== rhsOuter.secondary.length) {\n return lhs.secondary.length - rhsOuter.secondary.length;\n }\n for (let i = 0; i < lhs.secondary.length; i++) {\n const cmp = cmpJoinEntries(lhs.secondary[i], rhsOuter.secondary[i]);\n if (cmp !== 0) {\n return cmp;\n }\n }\n return 0;\n }\n default:\n assertNever(type);\n }\n}\n\nexport function sortJoinEntry(entry: JoinEntry<PObjectId>): JoinEntry<PObjectId> {\n switch (entry.type) {\n case \"column\":\n case \"slicedColumn\":\n case \"inlineColumn\":\n return entry;\n case \"artificialColumn\": {\n const sortedAxesIndices = entry.axesIndices.toSorted((lhs, rhs) => lhs - rhs);\n return {\n ...entry,\n axesIndices: sortedAxesIndices,\n };\n }\n case \"inner\":\n case \"full\": {\n const sortedEntries = entry.entries.map(sortJoinEntry);\n sortedEntries.sort(cmpJoinEntries);\n return {\n ...entry,\n entries: sortedEntries,\n };\n }\n case \"outer\": {\n const sortedSecondary = entry.secondary.map(sortJoinEntry);\n sortedSecondary.sort(cmpJoinEntries);\n return {\n ...entry,\n primary: sortJoinEntry(entry.primary),\n secondary: sortedSecondary,\n };\n }\n default:\n assertNever(entry);\n }\n}\n"],"mappings":";;;;;;;AA+YA,SAAgB,aAAqB,KAAoB,IAAkC;AACzF,QAAO;EAAE,GAAG;EAAK,KAAK,aAAa,IAAI,KAAK,GAAG;EAAE;;AAGnD,SAAgB,cAAc,KAAi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,QAAQ,MAAM,IAAI;AAC7E,UAAO;IACL,GAAG;IACH,aAAa;IACd;;EAEH,KAAK;EACL,KAAK,QAAQ;GACX,MAAM,gBAAgB,MAAM,QAAQ,IAAI,cAAc;AACtD,iBAAc,KAAK,eAAe;AAClC,UAAO;IACL,GAAG;IACH,SAAS;IACV;;EAEH,KAAK,SAAS;GACZ,MAAM,kBAAkB,MAAM,UAAU,IAAI,cAAc;AAC1D,mBAAgB,KAAK,eAAe;AACpC,UAAO;IACL,GAAG;IACH,SAAS,cAAc,MAAM,QAAQ;IACrC,WAAW;IACZ;;EAEH,QACE,0BAAY,MAAM"}
|
|
@@ -1,65 +1,68 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { PObjectId } from "../../pool/spec.js";
|
|
2
|
+
import "../../pool/index.js";
|
|
3
|
+
import { PColumn } from "./spec/spec.js";
|
|
4
|
+
import { PColumnValues } from "./data_info.js";
|
|
5
|
+
import { PTableVector } from "./data_types.js";
|
|
6
|
+
import { PTableColumnId, PTableColumnSpec } from "./table_common.js";
|
|
7
|
+
import { SpecQuery } from "./query/query_spec.js";
|
|
8
|
+
|
|
9
|
+
//#region src/drivers/pframe/table_calculate.d.ts
|
|
7
10
|
/** Defines a terminal column node in the join request tree */
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
interface ColumnJoinEntry<Col> {
|
|
12
|
+
/** Node type discriminator */
|
|
13
|
+
readonly type: "column";
|
|
14
|
+
/** Local column */
|
|
15
|
+
readonly column: Col;
|
|
13
16
|
}
|
|
14
17
|
/**
|
|
15
18
|
* Axis filter slicing target axis from column axes.
|
|
16
19
|
* If the axis has parents or is a parent, slicing cannot be applied (an error will be thrown).
|
|
17
20
|
* */
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
interface ConstantAxisFilter {
|
|
22
|
+
/** Filter type discriminator */
|
|
23
|
+
readonly type: "constant";
|
|
24
|
+
/** Index of axis to slice (zero-based) */
|
|
25
|
+
readonly axisIndex: number;
|
|
26
|
+
/** Equality filter reference value, see {@link SingleValueEqualPredicate} */
|
|
27
|
+
readonly constant: string | number;
|
|
25
28
|
}
|
|
26
29
|
/** Defines a terminal column node in the join request tree */
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
interface SlicedColumnJoinEntry<Col> {
|
|
31
|
+
/** Node type discriminator */
|
|
32
|
+
readonly type: "slicedColumn";
|
|
33
|
+
/** Local column */
|
|
34
|
+
readonly column: Col;
|
|
35
|
+
/** New column id */
|
|
36
|
+
readonly newId: PObjectId;
|
|
37
|
+
/** Non-empty list of axis filters */
|
|
38
|
+
readonly axisFilters: ConstantAxisFilter[];
|
|
36
39
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
interface ArtificialColumnJoinEntry<Col> {
|
|
41
|
+
/** Node type discriminator */
|
|
42
|
+
readonly type: "artificialColumn";
|
|
43
|
+
/** Column definition */
|
|
44
|
+
readonly column: Col;
|
|
45
|
+
/** New column id */
|
|
46
|
+
readonly newId: PObjectId;
|
|
47
|
+
/** Indices of axes to pick from the column (zero-based) */
|
|
48
|
+
readonly axesIndices: number[];
|
|
46
49
|
}
|
|
47
50
|
/** Defines a terminal column node in the join request tree */
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
interface InlineColumnJoinEntry {
|
|
52
|
+
/** Node type discriminator */
|
|
53
|
+
readonly type: "inlineColumn";
|
|
54
|
+
/** Column definition */
|
|
55
|
+
readonly column: PColumn<PColumnValues>;
|
|
53
56
|
}
|
|
54
57
|
/**
|
|
55
58
|
* Defines a join request tree node that will output only records present in
|
|
56
59
|
* all child nodes ({@link entries}).
|
|
57
60
|
* */
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
interface InnerJoin<Col> {
|
|
62
|
+
/** Node type discriminator */
|
|
63
|
+
readonly type: "inner";
|
|
64
|
+
/** Child nodes to be inner joined */
|
|
65
|
+
readonly entries: JoinEntry<Col>[];
|
|
63
66
|
}
|
|
64
67
|
/**
|
|
65
68
|
* Defines a join request tree node that will output all records present at
|
|
@@ -67,11 +70,11 @@ export interface InnerJoin<Col> {
|
|
|
67
70
|
* that lacks corresponding combinations of axis values will be marked as absent,
|
|
68
71
|
* see {@link PTableVector.absent}.
|
|
69
72
|
* */
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
interface FullJoin<Col> {
|
|
74
|
+
/** Node type discriminator */
|
|
75
|
+
readonly type: "full";
|
|
76
|
+
/** Child nodes to be fully outer joined */
|
|
77
|
+
readonly entries: JoinEntry<Col>[];
|
|
75
78
|
}
|
|
76
79
|
/**
|
|
77
80
|
* Defines a join request tree node that will output all records present in
|
|
@@ -83,14 +86,14 @@ export interface FullJoin<Col> {
|
|
|
83
86
|
* This node can be thought as a chain of SQL LEFT JOIN operations starting from
|
|
84
87
|
* the {@link primary} node and adding {@link secondary} nodes one by one.
|
|
85
88
|
* */
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
interface OuterJoin<Col> {
|
|
90
|
+
/** Node type discriminator */
|
|
91
|
+
readonly type: "outer";
|
|
92
|
+
/** Primes the join operation. Left part of LEFT JOIN. */
|
|
93
|
+
readonly primary: JoinEntry<Col>;
|
|
94
|
+
/** Driven nodes, giving their values only if primary node have corresponding
|
|
95
|
+
* nodes. Right parts of LEFT JOIN chain. */
|
|
96
|
+
readonly secondary: JoinEntry<Col>[];
|
|
94
97
|
}
|
|
95
98
|
/**
|
|
96
99
|
* Base type of all join request tree nodes. Join request tree allows to combine
|
|
@@ -99,201 +102,197 @@ export interface OuterJoin<Col> {
|
|
|
99
102
|
* the PColumns. Common axis are those axis which have equal {@link AxisId} derived
|
|
100
103
|
* from the columns axes spec.
|
|
101
104
|
* */
|
|
102
|
-
|
|
105
|
+
type JoinEntry<Col> = ColumnJoinEntry<Col> | SlicedColumnJoinEntry<Col> | ArtificialColumnJoinEntry<Col> | InlineColumnJoinEntry | InnerJoin<Col> | FullJoin<Col> | OuterJoin<Col>;
|
|
103
106
|
/** Container representing whole data stored in specific PTable column. */
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
interface FullPTableColumnData {
|
|
108
|
+
/** Unified spec */
|
|
109
|
+
readonly spec: PTableColumnSpec;
|
|
110
|
+
/** Data */
|
|
111
|
+
readonly data: PTableVector;
|
|
109
112
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
interface SingleValueIsNAPredicate {
|
|
114
|
+
/** Comparison operator */
|
|
115
|
+
readonly operator: "IsNA";
|
|
113
116
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
interface SingleValueEqualPredicate {
|
|
118
|
+
/** Comparison operator */
|
|
119
|
+
readonly operator: "Equal";
|
|
120
|
+
/** Reference value, NA values will not match */
|
|
121
|
+
readonly reference: string | number;
|
|
119
122
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
interface SingleValueInSetPredicate {
|
|
124
|
+
/** Comparison operator */
|
|
125
|
+
readonly operator: "InSet";
|
|
126
|
+
/** Reference values, NA values will not match */
|
|
127
|
+
readonly references: (string | number)[];
|
|
125
128
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
interface SingleValueIEqualPredicate {
|
|
130
|
+
/** Comparison operator (case insensitive) */
|
|
131
|
+
readonly operator: "IEqual";
|
|
132
|
+
/** Reference value, NA values will not match */
|
|
133
|
+
readonly reference: string;
|
|
131
134
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
interface SingleValueLessPredicate {
|
|
136
|
+
/** Comparison operator */
|
|
137
|
+
readonly operator: "Less";
|
|
138
|
+
/** Reference value, NA values will not match */
|
|
139
|
+
readonly reference: string | number;
|
|
137
140
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
interface SingleValueLessOrEqualPredicate {
|
|
142
|
+
/** Comparison operator */
|
|
143
|
+
readonly operator: "LessOrEqual";
|
|
144
|
+
/** Reference value, NA values will not match */
|
|
145
|
+
readonly reference: string | number;
|
|
143
146
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
interface SingleValueGreaterPredicate {
|
|
148
|
+
/** Comparison operator */
|
|
149
|
+
readonly operator: "Greater";
|
|
150
|
+
/** Reference value, NA values will not match */
|
|
151
|
+
readonly reference: string | number;
|
|
149
152
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
interface SingleValueGreaterOrEqualPredicate {
|
|
154
|
+
/** Comparison operator */
|
|
155
|
+
readonly operator: "GreaterOrEqual";
|
|
156
|
+
/** Reference value, NA values will not match */
|
|
157
|
+
readonly reference: string | number;
|
|
155
158
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
interface SingleValueStringContainsPredicate {
|
|
160
|
+
/** Comparison operator */
|
|
161
|
+
readonly operator: "StringContains";
|
|
162
|
+
/** Reference substring, NA values are skipped */
|
|
163
|
+
readonly substring: string;
|
|
161
164
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
interface SingleValueStringIContainsPredicate {
|
|
166
|
+
/** Comparison operator (case insensitive) */
|
|
167
|
+
readonly operator: "StringIContains";
|
|
168
|
+
/** Reference substring, NA values are skipped */
|
|
169
|
+
readonly substring: string;
|
|
167
170
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
interface SingleValueMatchesPredicate {
|
|
172
|
+
/** Comparison operator */
|
|
173
|
+
readonly operator: "Matches";
|
|
174
|
+
/** Regular expression, NA values are skipped */
|
|
175
|
+
readonly regex: string;
|
|
173
176
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
177
|
+
interface SingleValueStringContainsFuzzyPredicate {
|
|
178
|
+
/** Comparison operator */
|
|
179
|
+
readonly operator: "StringContainsFuzzy";
|
|
180
|
+
/** Reference value, NA values are skipped */
|
|
181
|
+
readonly reference: string;
|
|
182
|
+
/**
|
|
183
|
+
* Integer specifying the upper bound of edit distance between
|
|
184
|
+
* reference and actual value.
|
|
185
|
+
* When {@link substitutionsOnly} is not defined or set to false
|
|
186
|
+
* Levenshtein distance is used (substitutions and indels)
|
|
187
|
+
* @see https://en.wikipedia.org/wiki/Levenshtein_distance
|
|
188
|
+
* When {@link substitutionsOnly} is set to true
|
|
189
|
+
* Hamming distance is used (substitutions only)
|
|
190
|
+
* @see https://en.wikipedia.org/wiki/Hamming_distance
|
|
191
|
+
*/
|
|
192
|
+
readonly maxEdits: number;
|
|
193
|
+
/** Changes the type of edit distance in {@link maxEdits} */
|
|
194
|
+
readonly substitutionsOnly?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Some character in {@link reference} that will match any
|
|
197
|
+
* single character in searched text.
|
|
198
|
+
*/
|
|
199
|
+
readonly wildcard?: string;
|
|
197
200
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
201
|
+
interface SingleValueStringIContainsFuzzyPredicate {
|
|
202
|
+
/** Comparison operator (case insensitive) */
|
|
203
|
+
readonly operator: "StringIContainsFuzzy";
|
|
204
|
+
/** Reference value, NA values are skipped */
|
|
205
|
+
readonly reference: string;
|
|
206
|
+
/**
|
|
207
|
+
* Integer specifying the upper bound of edit distance between
|
|
208
|
+
* reference and actual value.
|
|
209
|
+
* When {@link substitutionsOnly} is not defined or set to false
|
|
210
|
+
* Levenshtein distance is used (substitutions and indels)
|
|
211
|
+
* @see https://en.wikipedia.org/wiki/Levenshtein_distance
|
|
212
|
+
* When {@link substitutionsOnly} is set to true
|
|
213
|
+
* Hamming distance is used (substitutions only)
|
|
214
|
+
* @see https://en.wikipedia.org/wiki/Hamming_distance
|
|
215
|
+
*/
|
|
216
|
+
readonly maxEdits: number;
|
|
217
|
+
/** Changes the type of edit distance in {@link maxEdits} */
|
|
218
|
+
readonly substitutionsOnly?: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Some character in {@link reference} that will match any
|
|
221
|
+
* single character in searched text.
|
|
222
|
+
*/
|
|
223
|
+
readonly wildcard?: string;
|
|
221
224
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
interface SingleValueNotPredicateV2 {
|
|
226
|
+
/** Comparison operator */
|
|
227
|
+
readonly operator: "Not";
|
|
228
|
+
/** Operand to negate */
|
|
229
|
+
readonly operand: SingleValuePredicateV2;
|
|
227
230
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
interface SingleValueAndPredicateV2 {
|
|
232
|
+
/** Comparison operator */
|
|
233
|
+
readonly operator: "And";
|
|
234
|
+
/** Operands to combine */
|
|
235
|
+
readonly operands: SingleValuePredicateV2[];
|
|
233
236
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
interface SingleValueOrPredicateV2 {
|
|
238
|
+
/** Comparison operator */
|
|
239
|
+
readonly operator: "Or";
|
|
240
|
+
/** Operands to combine */
|
|
241
|
+
readonly operands: SingleValuePredicateV2[];
|
|
239
242
|
}
|
|
240
243
|
/** Filtering predicate for a single axis or column value */
|
|
241
|
-
|
|
244
|
+
type SingleValuePredicateV2 = SingleValueIsNAPredicate | SingleValueEqualPredicate | SingleValueInSetPredicate | SingleValueLessPredicate | SingleValueLessOrEqualPredicate | SingleValueGreaterPredicate | SingleValueGreaterOrEqualPredicate | SingleValueStringContainsPredicate | SingleValueMatchesPredicate | SingleValueStringContainsFuzzyPredicate | SingleValueNotPredicateV2 | SingleValueAndPredicateV2 | SingleValueOrPredicateV2 | SingleValueIEqualPredicate | SingleValueStringIContainsPredicate | SingleValueStringIContainsFuzzyPredicate;
|
|
242
245
|
/**
|
|
243
246
|
* Filter PTable records based on specific axis or column value. If this is an
|
|
244
247
|
* axis value filter and the axis is part of a partitioning key in some of the
|
|
245
248
|
* source PColumns, the filter will be pushed down to those columns, so only
|
|
246
249
|
* specific partitions will be retrieved from the remote storage.
|
|
247
250
|
* */
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
251
|
+
interface PTableRecordSingleValueFilterV2 {
|
|
252
|
+
/** Filter type discriminator */
|
|
253
|
+
readonly type: "bySingleColumnV2";
|
|
254
|
+
/** Target axis selector to examine values from */
|
|
255
|
+
readonly column: PTableColumnId;
|
|
256
|
+
/** Value predicate */
|
|
257
|
+
readonly predicate: SingleValuePredicateV2;
|
|
255
258
|
}
|
|
256
259
|
/** Generic PTable records filter */
|
|
257
|
-
|
|
260
|
+
type PTableRecordFilter = PTableRecordSingleValueFilterV2;
|
|
258
261
|
/** Sorting parameters for a PTable. */
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
readonly ascending: boolean;
|
|
264
|
-
/** Sorting in respect to NA and absent values */
|
|
265
|
-
readonly naAndAbsentAreLeastValues: boolean;
|
|
262
|
+
type PTableSorting = {
|
|
263
|
+
/** Unified column identifier */readonly column: PTableColumnId; /** Sorting order */
|
|
264
|
+
readonly ascending: boolean; /** Sorting in respect to NA and absent values */
|
|
265
|
+
readonly naAndAbsentAreLeastValues: boolean;
|
|
266
266
|
};
|
|
267
267
|
/** Information required to instantiate a PTable. */
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
268
|
+
interface PTableDef<Col> {
|
|
269
|
+
/** Join tree to populate the PTable */
|
|
270
|
+
readonly src: JoinEntry<Col>;
|
|
271
|
+
/** Partition filters */
|
|
272
|
+
readonly partitionFilters: PTableRecordFilter[];
|
|
273
|
+
/** Record filters */
|
|
274
|
+
readonly filters: PTableRecordFilter[];
|
|
275
|
+
/** Table sorting */
|
|
276
|
+
readonly sorting: PTableSorting[];
|
|
277
277
|
}
|
|
278
278
|
/** Information required to instantiate a PTable (V2, query-based). */
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
279
|
+
interface PTableDefV2<Col> {
|
|
280
|
+
/** Pre-built query spec describing joins, filters and sorting */
|
|
281
|
+
readonly query: SpecQuery<Col>;
|
|
282
282
|
}
|
|
283
283
|
/** Request to create and retrieve entirety of data of PTable. */
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
readonly filters: PTableRecordFilter[];
|
|
289
|
-
/** Table sorting */
|
|
290
|
-
readonly sorting: PTableSorting[];
|
|
284
|
+
type CalculateTableDataRequest<Col> = {
|
|
285
|
+
/** Join tree to populate the PTable */readonly src: JoinEntry<Col>; /** Record filters */
|
|
286
|
+
readonly filters: PTableRecordFilter[]; /** Table sorting */
|
|
287
|
+
readonly sorting: PTableSorting[];
|
|
291
288
|
};
|
|
292
289
|
/** Response for {@link CalculateTableDataRequest} */
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
290
|
+
type CalculateTableDataResponse = FullPTableColumnData[];
|
|
291
|
+
declare function mapPTableDef<C1, C2>(def: PTableDef<C1>, cb: (c: C1) => C2): PTableDef<C2>;
|
|
292
|
+
declare function sortPTableDef(def: PTableDef<PObjectId>): PTableDef<PObjectId>;
|
|
293
|
+
declare function mapPTableDefV2<C1, C2>(def: PTableDefV2<C1>, cb: (c: C1) => C2): PTableDefV2<C2>;
|
|
294
|
+
declare function mapJoinEntry<C1, C2>(entry: JoinEntry<C1>, cb: (c: C1) => C2): JoinEntry<C2>;
|
|
295
|
+
declare function sortJoinEntry(entry: JoinEntry<PObjectId>): JoinEntry<PObjectId>;
|
|
296
|
+
//#endregion
|
|
297
|
+
export { ArtificialColumnJoinEntry, CalculateTableDataRequest, CalculateTableDataResponse, ColumnJoinEntry, ConstantAxisFilter, FullJoin, FullPTableColumnData, InlineColumnJoinEntry, InnerJoin, JoinEntry, OuterJoin, PTableDef, PTableDefV2, PTableRecordFilter, PTableRecordSingleValueFilterV2, PTableSorting, SingleValueAndPredicateV2, SingleValueEqualPredicate, SingleValueGreaterOrEqualPredicate, SingleValueGreaterPredicate, SingleValueIEqualPredicate, SingleValueInSetPredicate, SingleValueIsNAPredicate, SingleValueLessOrEqualPredicate, SingleValueLessPredicate, SingleValueMatchesPredicate, SingleValueNotPredicateV2, SingleValueOrPredicateV2, SingleValuePredicateV2, SingleValueStringContainsFuzzyPredicate, SingleValueStringContainsPredicate, SingleValueStringIContainsFuzzyPredicate, SingleValueStringIContainsPredicate, SlicedColumnJoinEntry, mapJoinEntry, mapPTableDef, mapPTableDefV2, sortJoinEntry, sortPTableDef };
|
|
299
298
|
//# sourceMappingURL=table_calculate.d.ts.map
|