Skip to main content

KeyValue

This extension converts events having Key-Value maps to/from stream proceesor events.

Features

  • keyvalue (Sink Mapper)

    The Event to Key-Value Map output mapper extension allows you to convert events processed by GDN Stream Processor to key-value map events before publishing them. You can either use pre-defined keys where conversion takes place without extra configurations, or use custom keys with which the messages can be published.

  • keyvalue (Source Mapper)

    Key-Value Map to Event input mapper extension allows transports that accept events as key value maps to convert those events to events. You can either receive pre-defined keys where conversion takes place without extra configurations, or use custom keys to map from the message.

keyvalue (Sink Mapper)

The Event to Key-Value Map output mapper extension allows you to convert events processed by GDN Stream Processor to key-value map events before publishing them. You can either use pre-defined keys where conversion takes place without extra configurations, or use custom keys with which the messages can be published.

Syntax

CREATE SINK <name> WITH (type="keyvalue")

EXAMPLE 1

CREATE SINK FooStream WITH (type='inMemory', topic='stock', map.type='keyvalue') (symbol string, price float, volume long);

This query performs a default Key-Value output mapping. The expected output is something similar to the following: symbol:'GDN' price :55.6f volume: 100L

EXAMPLE 2

CREATE SINK FooStream WITH (type='inMemory', topic='stock', map.type='keyvalue', map.payload="a='symbol',b='price',c='volume'") (symbol string, price float, volume long)

This query performs a custom Key-Value output mapping where values are passed as objects. Values for symbol, price, and volume attributes are published with the keys a, b and c respectively. The expected output is a map similar to the following: a:'GDN' b : 55.6f c: 100L

EXAMPLE 3

CREATE SINK FooStream WITH (type='inMemory', topic='stock', map.type='keyvalue', map.payload="a='{{symbol}} is here',b='`price`',c='volume'") (symbol string, price float, volume long);

This query performs a custom Key-Value output mapping where the values of the a and b attributes are strings and c is object. The expected output should be a Map similar to the following: a:'GDN is here' b:'price' c: 100L

keyvalue (Source Mapper)

Key-Value Map to Event input mapper extension allows transports that accept events as key value maps to convert those events to events. You can either receive pre-defined keys where conversion takes place without extra configurations, or use custom keys to map from the message.

Syntax

CREATE SOURCE <name> WITH (type="keyvalue", fail.on.missing.attribute="<BOOL>")

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
fail.on.missing.attributeIf this parameter is set to true, if an event arrives without a matching key for a specific attribute in the connected stream, it is dropped and not processed by the Stream Processor. If this parameter is set to false the Stream Processor adds the required key to such events with a null value, and the event is converted to a event so that you could handle them as required before they are further processed.trueBOOLYesNo

EXAMPLE 1

CREATE SOURCE FooStream WITH (type='inMemory', topic='stock', map.type='keyvalue') 

This query performs a default key value input mapping. The expected input is a map similar to the following: symbol: 'GDN' price:55.6f volume: 100

EXAMPLE 2

CREATE SOURCE FooStream WITH (type='inMemory', topic='stock', map.type='keyvalue', fail.on.missing.attribute='true', map.attributes="symbol = 's', price = 'p', volume = 'v'") (symbol string, price float, volume long);

This query performs a custom key value input mapping. The matching keys for the symbol, price and volume attributes are be s, p, and v respectively. The expected input is a map similar to the following: s: 'GDN' p: 55.6 v: 100