// Build an outer join expression node
boolean isOuterJoin = false;
ExprNode outerJoinEqualsNode = null;
if (!outerJoinDescList.isEmpty())
{
OuterJoinDesc outerJoinDesc = outerJoinDescList.get(0);
if (outerJoinDesc.getOuterJoinType().equals(OuterJoinType.FULL))
{
isOuterJoin = true;
}
else if ((outerJoinDesc.getOuterJoinType().equals(OuterJoinType.LEFT)) &&
(streamViewNum == 0))
{
isOuterJoin = true;
}
else if ((outerJoinDesc.getOuterJoinType().equals(OuterJoinType.RIGHT)) &&
(streamViewNum == 1))
{
isOuterJoin = true;
}
outerJoinEqualsNode = outerJoinDesc.makeExprNode(exprEvaluatorContext);
}
// Determine filter for indexing purposes
ExprNode filterForIndexing = null;
if ((outerJoinEqualsNode != null) && (optionalFilterNode != null)) // both filter and outer join, add
{
filterForIndexing = new ExprAndNodeImpl();
filterForIndexing.addChildNode(optionalFilterNode);
filterForIndexing.addChildNode(outerJoinEqualsNode);
}
else if ((outerJoinEqualsNode == null) && (optionalFilterNode != null))
{
filterForIndexing = optionalFilterNode;
}
else if (outerJoinEqualsNode != null)
{
filterForIndexing = outerJoinEqualsNode;
}
Pair<HistoricalIndexLookupStrategy, PollResultIndexingStrategy> indexStrategies =
determineIndexing(filterForIndexing, streamTypes[polledViewNum], streamTypes[streamViewNum], polledViewNum, streamViewNum);
if (queryPlanLogging && queryPlanLog.isInfoEnabled()) {
queryPlanLog.info("historical lookup strategy: " + indexStrategies.getFirst().toQueryPlan());
queryPlanLog.info("historical index strategy: " + indexStrategies.getSecond().toQueryPlan());
}
HistoricalEventViewable viewable = (HistoricalEventViewable) streamViews[polledViewNum];
ExprEvaluator outerJoinEqualsNodeEval = outerJoinEqualsNode == null ? null : outerJoinEqualsNode.getExprEvaluator();
queryStrategies[streamViewNum] = new HistoricalDataQueryStrategy(streamViewNum, polledViewNum, viewable, isOuterJoin, outerJoinEqualsNodeEval,
indexStrategies.getFirst(), indexStrategies.getSecond());
// for strictly historical joins, create a query strategy for the non-subordinate historical view
if (isAllHistoricalNoSubordinate)
{
isOuterJoin = false;
if (!outerJoinDescList.isEmpty())
{
OuterJoinDesc outerJoinDesc = outerJoinDescList.get(0);
if (outerJoinDesc.getOuterJoinType().equals(OuterJoinType.FULL))
{
isOuterJoin = true;
}
else if ((outerJoinDesc.getOuterJoinType().equals(OuterJoinType.LEFT)) &&
(polledViewNum == 0))
{
isOuterJoin = true;
}
else if ((outerJoinDesc.getOuterJoinType().equals(OuterJoinType.RIGHT)) &&
(polledViewNum == 1))
{
isOuterJoin = true;
}
}