1

使用泰达4.2架构。如何循环调用LookUpCache算子?

我输入为 a1;b1;c1|a2;b2;c2|a3;b3;c3

现在我想使用 a1 、 a2 和 a3 作为查找键并为每个生成一个元组(作为输出)。我已经使用标记器提取了 a1、a2、a3,但是如何将它提供给 LookupCache 运算符,以便它一个一个地使用所有键并生成 3 个元组。

4

1 回答 1

0

使用泰达应用框架,您需要准备 TypesCommon.ReaderOutStreamType 模式,它是解析的输出和数据丰富的输入。它使用 xxx.streams.custom::TypesCustom.LookupType 类型中指定的属性进行扩展。

在 xxx.streams.custom. TypesCustom.spl

    static LookupType = tuple<
        // ------------------------------------------------
        // custom code begin
        // ------------------------------------------------
        // add your custom attributes here
        // key attribute for LookupCache, e.g. a1, a2, a3 from input
        rstring a
        // ------------------------------------------------
        // custom code end
        // ------------------------------------------------
    >;

在 xxx.chainprocessor.transformer.custom。DataProcessor.spl 您可以准备为您的查找提取关键属性,填充属性并从单个输入元组(InReca提交 n 个元组(LookupStream )到 LookupCache 运算符

    (stream<I> LookupStream as O) as PrepareLookup = Custom(InRec as I) {
        logic
            onTuple I: {
                mutable list<rstring> list1 = tokenize(attrInput, "|", true);
                for (rstring val in list1) {
                    mutable list<rstring> list2 = tokenize(val, ";", true);
                    I.a = list2[0];
                    submit(I, O); // submit for a1, a2 ...
                }   
            }
            onPunct I: {
                if (currentPunct() == Sys.WindowMarker) {
                    submit(Sys.WindowMarker, O);
                }
            }
    }


    stream<I> EnrichedRecords = LookupCache(LookupStream as I) {
        param
            segmentName:    "yourSeg"; // The name of the physical memory segment
            containerName:  "yourContainer"; // The name of the store
            useMutex:   false; // Don't protect data with mutex
            mutexName:  "";
            key:        I.a;
            keyType:        rstring;           // SPL type of key
            found:      I.lookupFound;     // attribute that takes lookup success
            valueType:  TypesCustom.YourType_t; //type of lookup table value as also defined in LookupManager
            disableLookup:  $disableLookup;   // always pass through this parameter
            applControlDir: $applControlDir;   // always pass through this parameter
    }
于 2017-10-12T11:14:19.910 回答