memlookup
Creates, queries, or drops an in-memory mapping table using query results. The created in-memory mapping table can be queried by the lookup command.
Command properties
| Property | Description |
|---|---|
| Command type | Driver or Transforming |
| Required permission | None |
| License usage | Not counted |
| Parallel execution | Not supported |
| Distributed execution | Not supported |
Syntax
To list in-memory mapping tables:
To query the data in a specific in-memory mapping table:
To create an in-memory mapping table:
To drop an in-memory mapping table:
Options
op={list|build|drop}- Operation to perform. (Default:
list)
list: Lists in-memory mapping tables, or ifnameis specified, queries the data in that mapping table.build: Creates an in-memory mapping table using input records passed from the previous stage.drop: Drops the specified in-memory mapping table.
name=STR- Name of the in-memory mapping table. Required for
buildanddropoperations. key=STR- Name of the key field for the mapping table. Required for the
buildoperation.
Target
[FIELD, ...]- List of fields to store in the mapping table for the
buildoperation. Separate multiple fields with commas (,).
Output fields
When op=list without specifying name:
| Field | Type | Description |
|---|---|---|
name | string | Name of the in-memory mapping table |
key | string | Name of the key field in the mapping table |
size | integer | Number of records stored in the mapping table |
When op=list with name specified, outputs all fields stored in that mapping table.
Error codes
Parse errors
| Error code | Message | Description |
|---|---|---|
| 22000 | unsupported-memlookup-op | A value other than list, build, or drop was specified for the op option. |
| 22001 | Enter the mapping table name. | name was not specified for the build operation. |
| 22002 | No mapping table key specified. | key was not specified for the build operation. |
| 22003 | Enter the mapping table name. | name was not specified for the drop operation. |
| 22004 | [name] is an invalid mapping table. | A non-existent in-memory mapping table was specified for the list operation. |
Runtime errors
| Error code | Message | Description | Post-processing behavior |
|---|---|---|---|
| 22005 | [name] is an invalid mapping table. | A non-existent in-memory mapping table was queried in the list operation. | Aborts the query. |
Description
The memlookup command creates and manages in-memory mapping tables using query results. The created mapping table can be used with the lookup command in the same way as a regular mapping table.
When op=list without specifying name, it acts as a driver query and outputs the metadata of all in-memory mapping tables. When name is specified, it outputs all data in that mapping table.
When op=build, it acts as a transforming query. It constructs the mapping table based on the key field value of input records from the previous stage. Records where the key field value is null are ignored. If the same key appears multiple times, only the first record is stored. The maximum number of records that can be stored in a mapping table is 100,000. If the query is cancelled, the mapping table is not registered. If an in-memory mapping table with the same name already exists, it is overwritten.
When op=drop, it drops the specified in-memory mapping table at query start. If the target does not exist or is not an in-memory mapping table, the operation is ignored.
Examples
-
List in-memory mapping tables
memlookupOutputs the name, key field, and record count of all registered in-memory mapping tables.
-
Create an in-memory mapping table
json "[{'ip': '192.0.2.1', 'hostname': 'web-01', 'zone': 'dmz'}, {'ip': '192.0.2.2', 'hostname': 'db-01', 'zone': 'internal'}]" | memlookup op=build name=ip_hosts key=ip hostname, zoneCreates an
ip_hostsin-memory mapping table withipas the key and including thehostnameandzonefields. -
Query data in an in-memory mapping table
memlookup op=list name=ip_hostsOutputs all records stored in the
ip_hostsin-memory mapping table. -
Use an in-memory mapping table with lookup
json "[{'src_ip': '192.0.2.1'}, {'src_ip': '192.0.2.2'}]" | lookup ip_hosts src_ip as ip output hostnameQueries the
ip_hostsmapping table created withmemlookupusing thelookupcommand. -
Drop an in-memory mapping table
memlookup op=drop name=ip_hostsDrops the
ip_hostsin-memory mapping table.