Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
calculate_lookup_table_keys_and_values [2026/07/07 16:09] hermann |
calculate_lookup_table_keys_and_values [2026/07/15 01:21] (current) hermann |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Calculate Value ====== | + | ====== Calculate Lookup Table Keys And Values ====== |
| ===== Description ===== | ===== Description ===== | ||
| - | Evaluates an expression **once** and returns a single **scalar value**. Unlike the map and lookup table calculators, there is no current cell, row, or spatial grid — the expression is evaluated in a purely scalar context. | + | Generates a new lookup table by evaluating **two separate expressions** once per row of a base lookup table — one expression for the output key and one for the output value. This allows complete transformation of a table's key-value structure, or construction of an entirely new lookup table row by row. |
| - | This functor is one of five in the [[calculate_functors|calculator family]]. Use it to compute a single parameter — such as a global threshold, a weighted sum of scalar inputs, or a value derived from a table — that can then be passed as input to other functors. | + | This functor is one of five in the [[calculate_functors|calculator family]]. Use it when you need to recompute both the keys and the values of a lookup table. If only the values need to be recomputed and the keys should be inherited from the base table, use [[Calculate Lookup Table Values]] instead. |
| - | The **abbreviated syntax** (also called **shorthand**) for this functor is ''$''. See [[ego_script#calculator_functor_shorthand|Calculator functor shorthand]] in the EGO Script documentation for the full syntax of both the verbose and abbreviated forms, and [[calculate_functors|Calculate Functors — Complete Operator Documentation]] for the complete expression language reference. | + | The **abbreviated syntax** (also called **shorthand**) for this functor is ''%%''. See [[ego_script#calculator_functor_shorthand|Calculator functor shorthand]] in the EGO Script documentation for the full syntax of both the verbose and abbreviated forms, and [[calculate_functors|Calculate Functors — Complete Operator Documentation]] for the complete expression language reference. |
| ===== Inputs ===== | ===== Inputs ===== | ||
| ^ Name ^ Type ^ Description ^ | ^ Name ^ Type ^ Description ^ | ||
| - | | Expression | [[Image Expression Type]] | The algebraic or logical formula that evaluates to a single numeric result. Must be enclosed in square brackets ''[ ]'' in EGO Script. | | + | | Key Column Expression | [[Image Expression Type]] | The formula evaluated for each row to produce the output key. Must be enclosed in square brackets ''[ ]'' in EGO Script. | |
| + | | Value Column Expression | [[Image Expression Type]] | The formula evaluated for each row to produce the output value. Must be enclosed in square brackets ''[ ]'' in EGO Script. | | ||
| ===== Optional Inputs ===== | ===== Optional Inputs ===== | ||
| ^ Name ^ Type ^ Default ^ Description ^ | ^ Name ^ Type ^ Default ^ Description ^ | ||
| - | | Default Value | [[Real Value Type]] | None | Value returned if the expression produces an algebraic error. When provided, acts as a catch-all fallback equivalent to wrapping the entire expression in the ''?'' operator. | | + | | Key Column Name | [[Name Type]] | None | Name of the key column in the output lookup table. If omitted, the corresponding name from the base table is used. | |
| + | | Value Column Name | [[Name Type]] | None | Name of the value column in the output lookup table. If omitted, the corresponding name from the base table is used. | | ||
| + | | Base Lookup Table | [[Lookup Table Type]] | None | The lookup table whose row set drives iteration. When not provided, the [[Number Table]] hook with the lowest list index that is connected to a **lookup table** (not a regular table) is used as the row source (verbose form), or the first lookup table referenced by name in the expression (abbreviated form) — not a union of all connected tables. Prefer this port over a ''Number Table'' hook when the table is needed only to define the row set and is not referenced in the expression, to keep abbreviated syntax available. | | ||
| ===== Output ===== | ===== Output ===== | ||
| ^ Name ^ Type ^ Description ^ | ^ Name ^ Type ^ Description ^ | ||
| - | | Result | [[Real Value Type]] | The computed scalar value. | | + | | Result | [[Lookup Table Type]] | A lookup table with both keys and values computed by the respective expressions. | |
| ===== Group ===== | ===== Group ===== | ||
| Line 32: | Line 35: | ||
| ==== Connecting data inputs ==== | ==== Connecting data inputs ==== | ||
| - | Tables, lookup tables, and scalar values referenced in the expression must be connected to the functor's ports before writing the expression, using **hook** functors: | + | Tables, lookup tables, and scalar values referenced in either expression must be connected to the functor's ports before writing the expressions, using **hook** functors: |
| * Tables and lookup tables → [[Number Table]] → referenced in the expression as ''t1'', ''t2'', …, ''t100'' | * Tables and lookup tables → [[Number Table]] → referenced in the expression as ''t1'', ''t2'', …, ''t100'' | ||
| * Scalar values → [[Number Value]] → referenced as ''v1'', ''v2'', …, ''v100'' | * Scalar values → [[Number Value]] → referenced as ''v1'', ''v2'', …, ''v100'' | ||
| - | Maps cannot be connected — there is no cell context in this functor. In the abbreviated syntax, tables are referenced as ''%variableName'' and values as ''$variableName''. | + | Maps cannot be connected — there is no cell context in this functor. In the abbreviated syntax, tables are referenced as ''%variableName'' and values as ''$variableName''. Both expressions share the same set of connected operands. |
| + | |||
| + | ==== Row iteration context ==== | ||
| + | |||
| + | Both expressions are evaluated once per row of the base lookup table. Two keywords reflect the current row inside each expression: | ||
| + | |||
| + | * ''line'' — the **key** of the current row | ||
| + | * ''column'' — the **value already associated with that key** in the base lookup table | ||
| + | |||
| + | If the key expression produces a key that already exists in the output table, the newly computed value replaces the existing one. | ||
| ==== Available expression features ==== | ==== Available expression features ==== | ||
| - | Image operators (''iX''), the ''line'' and ''column'' spatial keywords, neighbourhood functions, neighbourhood indexing, and convolution are not available — there is no cell or row context. Available features are arithmetic and logical operators and table and lookup table queries (''tX[...]'') in all single-key and multi-column forms. See [[calculate_functors#the_expression_language|The Expression Language]] for the complete reference, or [[Image Expression Type]] for the navigable operator index. | + | Identical to [[Calculate Lookup Table Values]]: arithmetic and logical operators, scalar references (''vX''), table and lookup table queries (''tX[...]'') in all single-key and multi-column forms, and the ''line'' and ''column'' row-context keywords are available. Image operators (''iX''), neighbourhood functions, neighbourhood indexing, and convolution are not available. See [[calculate_functors#the_expression_language|The Expression Language]] for the complete reference, or [[Image Expression Type]] for the navigable operator index. |
| ==== Null value handling ==== | ==== Null value handling ==== | ||
| Line 49: | Line 61: | ||
| ===== Internal Name ===== | ===== Internal Name ===== | ||
| - | ''CalculateValue'' | + | ''CalculateLookupTableKeysAndValues'' |
| - | + | ||
| - | ===== Usage examples ===== | + | |
| - | * [[calculate_functors#calculatevalue_examples|CalculateValue practical examples]] in the Calculate Functors documentation | ||
| - | * [[lesson_8|Lesson 8: Inserting and getting a specific value into a table]] | ||