/** * Construct and return a WindowDefinition object using the given id. * * @param id the window id * @return new instance of WindowDefinition */ public static WindowDefinition id(String id) { return new WindowDefinition(id); }
@Override public String toString() { return super.toString("aggregation"); }
public static StreamDefinition id(String streamId) { return new StreamDefinition(streamId); }
protected void checkAttribute(String attributeName) { for (Attribute attribute : attributeList) { if (attribute.getName().equals(attributeName)) { throw new DuplicateAttributeException("'" + attributeName + "' is already defined for with type '" + attribute.getType() + "' for '" + id + "'; " + this.toString(), attribute.getQueryContextStartIndex(), attribute.getQueryContextEndIndex()); } } }
public Attribute.Type getAttributeType(String attributeName) { for (Attribute attribute : attributeList) { if (attribute.getName().equals(attributeName)) { return attribute.getType(); } } throw new AttributeNotExistException("Cannot find attribute type as '" + attributeName + "' does not exist in" + " '" + id + "'; " + this.toString()); }
public int getAttributePosition(String attributeName) { for (int i = 0, attributeListSize = attributeList.size(); i < attributeListSize; i++) { Attribute attribute = attributeList.get(i); if (attribute.getName().equals(attributeName)) { return i; } } throw new AttributeNotExistException("Cannot get attribute position as '" + attributeName + "' does not exist" + " in '" + id + "'; " + this.toString()); }
public String[] getAttributeNameArray() { int attributeListSize = attributeList.size(); String[] attributeNameArray = new String[attributeListSize]; for (int i = 0; i < attributeListSize; i++) { attributeNameArray[i] = attributeList.get(i).getName(); } return attributeNameArray; }
public SiddhiApp defineStream(StreamDefinition streamDefinition) { if (streamDefinition == null) { throw new SiddhiAppValidationException("Stream Definition should not be null"); } else if (streamDefinition.getId() == null) { throw new SiddhiAppValidationException("Stream Id should not be null for Stream Definition", streamDefinition.getQueryContextStartIndex(), streamDefinition.getQueryContextEndIndex()); } checkDuplicateDefinition(streamDefinition); this.streamDefinitionMap.put(streamDefinition.getId(), streamDefinition); return this; }
private void checkDuplicateDefinition(AbstractDefinition definition) { TableDefinition existingTableDefinition = tableDefinitionMap.get(definition.getId()); if (existingTableDefinition != null && (!existingTableDefinition.equals(definition) || definition instanceof StreamDefinition)) { throw new DuplicateDefinitionException("Table Definition with same Stream Id '" + definition.getId() + "' already exist : " + existingTableDefinition + ", hence cannot add " + definition, definition.getQueryContextStartIndex(), definition.getQueryContextEndIndex()); StreamDefinition existingStreamDefinition = streamDefinitionMap.get(definition.getId()); if (existingStreamDefinition != null && (!existingStreamDefinition.equals(definition) || definition instanceof TableDefinition)) { throw new DuplicateDefinitionException("Stream Definition with same Stream Id '" + definition.getId() + "' already exist : " + existingStreamDefinition + ", hence cannot add " + definition, definition.getQueryContextStartIndex(), definition.getQueryContextEndIndex()); WindowDefinition existingWindowDefinition = windowDefinitionMap.get(definition.getId()); if (existingWindowDefinition != null && (!existingWindowDefinition.equals(definition) || definition instanceof WindowDefinition)) { throw new DuplicateDefinitionException("Stream Definition with same Window Id '" + definition.getId() + "' already exist : " + existingWindowDefinition + ", hence cannot add " + definition, definition.getQueryContextStartIndex(), definition.getQueryContextEndIndex()); AggregationDefinition existingAggregationDefinition = aggregationDefinitionMap.get(definition.getId()); if (existingAggregationDefinition != null && (!existingAggregationDefinition.equals(definition) || definition instanceof AggregationDefinition)) { throw new DuplicateDefinitionException("Aggregate Definition with same Aggregate Id '" + definition.getId() + "' already exist : " + existingAggregationDefinition + ", hence cannot add " + definition,
public TableDefinition attribute(String attributeName, Attribute.Type type) { checkAttribute(attributeName); this.attributeList.add(new Attribute(attributeName, type)); return this; }
public StreamDefinition attribute(String attributeName, Attribute.Type type) { checkAttribute(attributeName); this.attributeList.add(new Attribute(attributeName, type)); return this; }
public SiddhiApp defineWindow(WindowDefinition windowDefinition) { if (windowDefinition == null) { throw new SiddhiAppValidationException("Window Definition should not be null"); } else if (windowDefinition.getId() == null) { throw new SiddhiAppValidationException("Window Id should not be null for Window Definition", windowDefinition.getQueryContextStartIndex(), windowDefinition.getQueryContextEndIndex()); } checkDuplicateDefinition(windowDefinition); this.windowDefinitionMap.put(windowDefinition.getId(), windowDefinition); return this; }
private void checkDuplicateFunctionExist(FunctionDefinition functionDefinition) { if (this.functionDefinitionMap.get(functionDefinition.getId()) != null) { throw new DuplicateDefinitionException("The function definition with the same id exists " + functionDefinition.getId(), functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } }
@Override public String toString() { return super.toString("window") + " " + window.toString(); } }
public static AggregationDefinition id(String aggregationName) { return new AggregationDefinition(aggregationName); }
public static TriggerDefinition id(String id) { return new TriggerDefinition(id); }
public static TableDefinition id(String id) { return new TableDefinition(id); }
@Override public int hashCode() { int result = name != null ? name.hashCode() : 0; result = 31 * result + (type != null ? type.hashCode() : 0); return result; }
@Override public String toString() { return toString("stream"); }
@Override public String toString() { return super.toString("table"); }