EPServicesContext servicesContext = context.getServicesContext();
AgentInstanceContext agentInstanceContext = context.getAgentInstanceContext();
// validate
if (select.getInsertIntoDesc() != null) {
throw new ExprValidationException("Insert-into clause is not supported");
}
if (select.getSelectStreamSelectorEnum() != SelectClauseStreamSelectorEnum.ISTREAM_ONLY) {
throw new ExprValidationException("Selecting remove-stream is not supported");
}
ExprNodeSubselectDeclaredDotVisitor visitor = StatementSpecRawAnalyzer.walkSubselectAndDeclaredDotExpr(select);
if (!visitor.getSubselects().isEmpty()) {
throw new ExprValidationException("Subselects are not supported");
}
Map<Integer, FilterStreamSpecRaw> streams = new HashMap<Integer, FilterStreamSpecRaw>();
for (int streamNum = 0; streamNum < select.getStreamSpecs().size(); streamNum++) {
StreamSpecRaw rawStreamSpec = select.getStreamSpecs().get(streamNum);
if (!(rawStreamSpec instanceof FilterStreamSpecRaw)) {
throw new ExprValidationException("From-clause must contain only streams and cannot contain patterns or other constructs");
}
streams.put(streamNum, (FilterStreamSpecRaw) rawStreamSpec);
}
// compile offered streams
List<StreamSpecCompiled> streamSpecCompileds = new ArrayList<StreamSpecCompiled>();
for (int streamNum = 0; streamNum < select.getStreamSpecs().size(); streamNum++) {
FilterStreamSpecRaw filter = streams.get(streamNum);
Map.Entry<Integer, DataFlowOpInputPort> inputPort = findInputPort(filter.getRawFilterSpec().getEventTypeName(), context.getInputPorts());
if (inputPort == null) {
throw new ExprValidationException("Failed to find stream '" + filter.getRawFilterSpec().getEventTypeName() + "' among input ports, input ports are " + Arrays.toString(getInputPortNames(context.getInputPorts())));
}
EventType eventType = inputPort.getValue().getTypeDesc().getEventType();
String streamAlias = filter.getOptionalStreamName();
FilterSpecCompiled filterSpecCompiled = new FilterSpecCompiled(eventType, streamAlias, Collections.<FilterSpecParam>emptyList(), null);
FilterStreamSpecCompiled filterStreamSpecCompiled = new FilterStreamSpecCompiled(filterSpecCompiled, select.getStreamSpecs().get(0).getViewSpecs(), streamAlias, new StreamSpecOptions());
streamSpecCompileds.add(filterStreamSpecCompiled);
}
// create compiled statement spec
SelectClauseSpecCompiled selectClauseCompiled = StatementLifecycleSvcUtil.compileSelectClause(select.getSelectClauseSpec());
// determine if snapshot output is needed
OutputLimitSpec outputLimitSpec = select.getOutputLimitSpec();
isOutputLimited = outputLimitSpec != null;
if (iterate) {
if (outputLimitSpec != null) {
throw new ExprValidationException("Output rate limiting is not supported with 'iterate'");
}
outputLimitSpec = new OutputLimitSpec(OutputLimitLimitType.SNAPSHOT, OutputLimitRateType.TERM);
}
Annotation[] mergedAnnotations = AnnotationUtil.mergeAnnotations(statementContext.getAnnotations(), context.getOperatorAnnotations());