Search in sources :

Example 1 with AddingStreamEventExtractor

use of io.siddhi.core.util.collection.AddingStreamEventExtractor in project siddhi by wso2.

the class TestStoreContainingInMemoryTable method updateOrAdd.

@Override
protected void updateOrAdd(CompiledCondition updateCondition, List<Map<String, Object>> updateConditionParameterMaps, Map<String, CompiledExpression> updateSetExpressions, List<Map<String, Object>> updateSetParameterMaps, List<Object[]> addingRecords) throws ConnectionUnavailableException {
    MetaStreamEvent tableMetaStreamEvent = new MetaStreamEvent();
    tableMetaStreamEvent.setEventType(MetaStreamEvent.EventType.TABLE);
    TableDefinition matchingTableDefinition = TableDefinition.id("");
    for (Attribute attribute : inMemoryTable.getTableDefinition().getAttributeList()) {
        tableMetaStreamEvent.addOutputData(attribute);
        matchingTableDefinition.attribute(attribute.getName(), attribute.getType());
    }
    tableMetaStreamEvent.addInputDefinition(matchingTableDefinition);
    MatchingMetaInfoHolder matchingMetaInfoHolder = MatcherParser.constructMatchingMetaStateHolder(tableMetaStreamEvent, 0, inMemoryTable.getTableDefinition(), 0);
    UpdateSet updateSet = new UpdateSet();
    for (Attribute attribute : matchingMetaInfoHolder.getMatchingStreamDefinition().getAttributeList()) {
        updateSet.set(new Variable(attribute.getName()), new Variable(attribute.getName()));
    }
    CompiledUpdateSet compiledUpdateSet = inMemoryTable.compileUpdateSet(updateSet, matchingMetaInfoHolder, null, tableMap, null);
    inMemoryTable.updateOrAdd(convForUpdate(updateSetParameterMaps), updateCondition, compiledUpdateSet, new AddingStreamEventExtractor(matchingMetaInfoHolder.getMatchingStreamEventIndex()));
}
Also used : Variable(io.siddhi.query.api.expression.Variable) AddingStreamEventExtractor(io.siddhi.core.util.collection.AddingStreamEventExtractor) Attribute(io.siddhi.query.api.definition.Attribute) MatchingMetaInfoHolder(io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder) TableDefinition(io.siddhi.query.api.definition.TableDefinition) CompiledUpdateSet(io.siddhi.core.table.CompiledUpdateSet) UpdateSet(io.siddhi.query.api.execution.query.output.stream.UpdateSet) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) CompiledUpdateSet(io.siddhi.core.table.CompiledUpdateSet)

Aggregations

MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)1 CompiledUpdateSet (io.siddhi.core.table.CompiledUpdateSet)1 AddingStreamEventExtractor (io.siddhi.core.util.collection.AddingStreamEventExtractor)1 MatchingMetaInfoHolder (io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder)1 Attribute (io.siddhi.query.api.definition.Attribute)1 TableDefinition (io.siddhi.query.api.definition.TableDefinition)1 UpdateSet (io.siddhi.query.api.execution.query.output.stream.UpdateSet)1 Variable (io.siddhi.query.api.expression.Variable)1