public static <T extends Tuple> TypeInformation<T> getTupleTypeInformation(AbstractDefinition definition) { int tupleSize = definition.getAttributeList().size(); TypeInformation[] typeInformations = new TypeInformation[tupleSize]; List<Attribute> attributes = definition.getAttributeList(); try { for (int i = 0; i < attributes.size() ; i++) { Class<?> clazz = getJavaType(attributes.get(i).getType()); typeInformations[i] = TypeInformation.of(clazz); } return Types.TUPLE(typeInformations); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("Failed to get Type Information.", ex); } }
public static <T extends Tuple> TypeInformation<T> getTupleTypeInformation(AbstractDefinition definition) { List<TypeInformation> types = new ArrayList<>(); for (Attribute attribute : definition.getAttributeList()) { types.add(TypeInformation.of(getJavaType(attribute.getType()))); } try { return Types.TUPLE(types.toArray(new TypeInformation[0])); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("Unable to parse ", ex); } }
/** * Construct Stream Definition query string for a given Siddhi Stream Definition * * @param siddhiStreamDefinition * @return */ public static String getDefinitionString(org.wso2.siddhi.query.api.definition.AbstractDefinition siddhiStreamDefinition) { StringBuilder builder = new StringBuilder(); builder.append(EventProcessorConstants.DEFINE_STREAM); builder.append(siddhiStreamDefinition.getId()); builder.append(EventProcessorConstants.OPENING_BRACKETS); for (Attribute attribute : siddhiStreamDefinition.getAttributeList()) { builder.append(attribute.getName() + EventProcessorConstants.SPACE + attribute.getType().toString().toLowerCase() + EventProcessorConstants.COMMA); } builder.deleteCharAt(builder.length() - 2); //remove last comma builder.append(EventProcessorConstants.CLOSING_BRACKETS); return builder.toString(); }
attributeList.add(ab.getAttributeList());
private void initMetaStateEvent() { this.outputAttrs = matchingMetaStateHolder.getMatchingStreamDefinition().getAttributeList(); for (MetaStreamEvent metaStreamEvent : matchingMetaStateHolder.getMetaStateEvent().getMetaStreamEvents()) { String referenceId = metaStreamEvent.getInputReferenceId(); AbstractDefinition abstractDefinition = metaStreamEvent.getLastInputDefinition(); if (!abstractDefinition.getId().trim().equals("")) { if (abstractDefinition instanceof TableDefinition) { this.eventTableRefs.add(abstractDefinition.getId()); if (referenceId != null) { this.eventTableRefs.add(referenceId); } } } } if (tableDefinition instanceof TableDefinition) { this.eventTableRefs.add(tableDefinition.getId()); } }
/** * Starts the siddhi execution plan * * @param siddhiManager The manager that will manage the execution plan * @param siddhiCallback The callback to be called when the execution plan creates a new message * @throws ExecutionPlanException */ public void start(SiddhiManager siddhiManager, SiddhiCallback siddhiCallback) throws ExecutionPlanException { this.executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(getFullExecutionPlan()); for (Map.Entry<String, String> entry : outputTopics.entrySet()) { String streamName = entry.getKey(); String topic = entry.getValue(); AbstractDefinition abstractDefinition = executionPlanRuntime.getStreamDefinitionMap().get(streamName); if (abstractDefinition != null) { List<Attribute> attributes = abstractDefinition.getAttributeList(); StreamCallback streamCallback = siddhiCallback.getCallback(streamName, topic, attributes); executionPlanRuntime.addCallback(streamName, streamCallback); } else { throw new InvalidExecutionPlanException("You specified a output that is not present on the execution plan"); } } executionPlanRuntime.start(); log.info("Started execution plan with id {} version {}", id, version, fullExecutionPlan); }
updateConditionAttributeList.addAll(matchingMetaStateHolder.getMatchingStreamDefinition().getAttributeList()); executionPlanContext, variableExpressionExecutors, eventTableMap, queryName); return new RDBMSOperator(executionInfo, expressionExecutorList, dbHandler, inMemoryEventTableOperator, matchingMetaStateHolder.getMatchingStreamDefinition().getAttributeList().size());
public static StreamDefinition convertFromSiddiDefinition(AbstractDefinition siddhiDefinition) { StreamDefinition streamDefinition = new StreamDefinition(); streamDefinition.setStreamId(siddhiDefinition.getId()); List<StreamColumn> columns = new ArrayList<>(siddhiDefinition.getAttributeNameArray().length); for (Attribute attribute : siddhiDefinition.getAttributeList()) { StreamColumn column = new StreamColumn(); column.setType(convertFromSiddhiAttributeType(attribute.getType())); column.setName(attribute.getName()); columns.add(column); } streamDefinition.setColumns(columns); streamDefinition.setTimeseries(true); streamDefinition.setDescription("Auto-generated stream schema from siddhi for " + siddhiDefinition.getId()); return streamDefinition; } }