Search in sources :

Example 16 with MetaStreamEvent

use of io.siddhi.core.event.stream.MetaStreamEvent in project siddhi by wso2.

the class AggregationParser method generateCUDMetaStreamEvent.

private static MetaStreamEvent generateCUDMetaStreamEvent(boolean isProcessingOnExternalTime) {
    MetaStreamEvent metaStreamEvent = new MetaStreamEvent();
    Map<Attribute, int[]> cudInputStreamAttributesList = generateCUDInputStreamAttributes(isProcessingOnExternalTime);
    StreamDefinition inputDefinition = new StreamDefinition();
    for (Attribute attribute : cudInputStreamAttributesList.keySet()) {
        metaStreamEvent.addData(attribute);
        inputDefinition.attribute(attribute.getName(), attribute.getType());
    }
    metaStreamEvent.addInputDefinition(inputDefinition);
    metaStreamEvent.setEventType(MetaStreamEvent.EventType.DEFAULT);
    return metaStreamEvent;
}
Also used : StreamDefinition(io.siddhi.query.api.definition.StreamDefinition) Attribute(io.siddhi.query.api.definition.Attribute) OutputAttribute(io.siddhi.query.api.execution.query.selection.OutputAttribute) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent)

Example 17 with MetaStreamEvent

use of io.siddhi.core.event.stream.MetaStreamEvent in project siddhi by wso2.

the class TestStoreContainingInMemoryTable method update.

@Override
protected void update(CompiledCondition updateCondition, List<Map<String, Object>> updateConditionParameterMaps, Map<String, CompiledExpression> updateSetExpressions, List<Map<String, Object>> updateSetParameterMaps) 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.update(convForUpdate(updateSetParameterMaps), updateCondition, compiledUpdateSet);
}
Also used : Variable(io.siddhi.query.api.expression.Variable) 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)

Example 18 with MetaStreamEvent

use of io.siddhi.core.event.stream.MetaStreamEvent 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)

Example 19 with MetaStreamEvent

use of io.siddhi.core.event.stream.MetaStreamEvent in project siddhi by wso2.

the class TestStoreForCacheMiss method init.

@Override
protected void init(TableDefinition tableDefinition, ConfigReader configReader) {
    inMemoryTable = new InMemoryTable();
    MetaStreamEvent cacheTableMetaStreamEvent = new MetaStreamEvent();
    cacheTableMetaStreamEvent.addInputDefinition(tableDefinition);
    for (Attribute attribute : tableDefinition.getAttributeList()) {
        cacheTableMetaStreamEvent.addOutputData(attribute);
    }
    StreamEventCloner testTableStreamEventCloner = new StreamEventCloner(cacheTableMetaStreamEvent, storeEventPool);
    TableDefinition testStoreContainingIMTableDefinition = TableDefinition.id(tableDefinition.getId());
    for (Attribute attribute : tableDefinition.getAttributeList()) {
        testStoreContainingIMTableDefinition.attribute(attribute.getName(), attribute.getType());
    }
    for (Annotation annotation : tableDefinition.getAnnotations()) {
        if (!annotation.getName().equalsIgnoreCase("Store")) {
            testStoreContainingIMTableDefinition.annotation(annotation);
        }
    }
    inMemoryTable.init(testStoreContainingIMTableDefinition, storeEventPool, testTableStreamEventCloner, configReader, siddhiAppContext, recordTableHandler);
}
Also used : InMemoryTable(io.siddhi.core.table.InMemoryTable) Attribute(io.siddhi.query.api.definition.Attribute) StreamEventCloner(io.siddhi.core.event.stream.StreamEventCloner) TableDefinition(io.siddhi.query.api.definition.TableDefinition) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) Annotation(io.siddhi.query.api.annotation.Annotation)

Example 20 with MetaStreamEvent

use of io.siddhi.core.event.stream.MetaStreamEvent in project siddhi by wso2.

the class TestStoreForCachePreLoading method init.

@Override
protected void init(TableDefinition tableDefinition, ConfigReader configReader) {
    inMemoryTable = new InMemoryTable();
    MetaStreamEvent cacheTableMetaStreamEvent = new MetaStreamEvent();
    cacheTableMetaStreamEvent.addInputDefinition(tableDefinition);
    for (Attribute attribute : tableDefinition.getAttributeList()) {
        cacheTableMetaStreamEvent.addOutputData(attribute);
    }
    StreamEventCloner testTableStreamEventCloner = new StreamEventCloner(cacheTableMetaStreamEvent, storeEventPool);
    TableDefinition testStoreContainingIMTableDefinition = TableDefinition.id(tableDefinition.getId());
    for (Attribute attribute : tableDefinition.getAttributeList()) {
        testStoreContainingIMTableDefinition.attribute(attribute.getName(), attribute.getType());
    }
    for (Annotation annotation : tableDefinition.getAnnotations()) {
        if (!annotation.getName().equalsIgnoreCase("Store")) {
            testStoreContainingIMTableDefinition.annotation(annotation);
        }
    }
    inMemoryTable.init(testStoreContainingIMTableDefinition, storeEventPool, testTableStreamEventCloner, configReader, siddhiAppContext, recordTableHandler);
    ComplexEventChunk<StreamEvent> originalData = new ComplexEventChunk<>();
    StreamEvent data1 = new StreamEvent(0, 0, 3);
    data1.setOutputData(new Object[] { "WSO2", 55.6f, 100L });
    originalData.add(data1);
    StreamEvent data2 = new StreamEvent(0, 0, 3);
    data2.setOutputData(new Object[] { "IBM", 75.6f, 100L });
    originalData.add(data2);
    inMemoryTable.add(originalData);
}
Also used : InMemoryTable(io.siddhi.core.table.InMemoryTable) ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) Attribute(io.siddhi.query.api.definition.Attribute) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) StreamEventCloner(io.siddhi.core.event.stream.StreamEventCloner) TableDefinition(io.siddhi.query.api.definition.TableDefinition) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) Annotation(io.siddhi.query.api.annotation.Annotation)

Aggregations

MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)63 Attribute (io.siddhi.query.api.definition.Attribute)35 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)34 StreamEvent (io.siddhi.core.event.stream.StreamEvent)21 StreamEventFactory (io.siddhi.core.event.stream.StreamEventFactory)17 VariableExpressionExecutor (io.siddhi.core.executor.VariableExpressionExecutor)17 ArrayList (java.util.ArrayList)17 StreamEventCloner (io.siddhi.core.event.stream.StreamEventCloner)14 MatchingMetaInfoHolder (io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder)14 Variable (io.siddhi.query.api.expression.Variable)14 SiddhiAppCreationException (io.siddhi.core.exception.SiddhiAppCreationException)13 HashMap (java.util.HashMap)13 AbstractDefinition (io.siddhi.query.api.definition.AbstractDefinition)12 Expression (io.siddhi.query.api.expression.Expression)12 ExpressionExecutor (io.siddhi.core.executor.ExpressionExecutor)10 StreamDefinition (io.siddhi.query.api.definition.StreamDefinition)10 Map (java.util.Map)10 Test (org.testng.annotations.Test)10 ConstantExpressionExecutor (io.siddhi.core.executor.ConstantExpressionExecutor)9 TableDefinition (io.siddhi.query.api.definition.TableDefinition)9