stream source scan table source lookup table source
The Memory source connector enables eKuiper to retrieve data from in-memory sources, primarily the memory sink. This connector plays an essential role in scenarios that require swift data retrieval without the overhead of disk or external service reads.
There's no need for additional configurations when integrating the Memory Source Connector with an eKuiper rule. Moreover, this connector is versatile, performing roles like a stream source, scan table source, or lookup table source.
As a stream source, the connector continuously fetches data from a designated in-memory topic, making it ideal for real-time data processing.
Example:
CREATE STREAM stream1 (
name STRING,
size BIGINT,
id BIGINT
) WITH (DATASOURCE="devices/result", FORMAT="json", TYPE="memory");
In this example, a memory stream source is defined to continuously pull data from the devices/result
in-memory topic.
For querying or analyzing more static datasets, the Memory Source Connector can act as a scan table source.
Example:
CREATE TABLE memoryTableDemo () WITH (DATASOURCE="topicB", FORMAT="JSON", TYPE="memory");
In this example, table memoryTableDemo
allows for querying JSON-formatted data from the topicB
in-memory topic.
This mode allows the Memory Source Connector to serve as a lookup table source, enhancing data enrichment during stream processing.
Example:
CREATE TABLE memoryLookupTableDemo () WITH (DATASOURCE="topicC", FORMAT="JSON", TYPE="memory");
Besides specifying a DATASOURCE
, which corresponds to a memory topic, you also need to specify the KEY
property, which serves as the primary key for the virtual table, ensuring efficient data access.
Once set up, the memory lookup table will begin accumulating data from the specified memory topic. This data is indexed by the key field, allowing for rapid retrieval.
"Topic" in the Memory Source Connector signifies different in-memory data channels. Using the DATASOURCE
property when defining a stream or table, users can pinpoint the memory topic they wish to access.
Similar to MQTT topics, wildcards are available:
Examples:
home/device1/+/sensor1
would mean you're interested in messages from any device's sensor1
located directly under home/device1/
.home/device1/#
would mean you're interested in messages from device1
and any of its sub-devices or sensors under the home
directory.The Memory Source Connector can be instrumental in constructing rule pipelines. These pipelines enable multiple rules to be chained, where one rule's output can be another's input. The internal format ensures data transfer efficiency, eliminating encoding or decoding needs. It's noteworthy that in this scenario, the format
attribute of the memory source is ignored, ensuring optimal performance.