public ExprTableEvalStrategy MakeStrategy(TableAndLockProvider provider) { switch (StrategyEnum) { case ExprTableEvalStrategyEnum.UNGROUPED_TOP: return new ExprTableEvalStrategyUngroupedTopLevel((TableAndLockProviderUngrouped) provider, this); case ExprTableEvalStrategyEnum.GROUPED_TOP: return new ExprTableEvalStrategyGroupedTopLevel((TableAndLockProviderGrouped) provider, this); case ExprTableEvalStrategyEnum.UNGROUPED_AGG_SIMPLE: return new ExprTableEvalStrategyUngroupedAggSimple((TableAndLockProviderUngrouped) provider, this); case ExprTableEvalStrategyEnum.GROUPED_AGG_SIMPLE: return new ExprTableEvalStrategyGroupedAggSimple((TableAndLockProviderGrouped) provider, this); case ExprTableEvalStrategyEnum.UNGROUPED_PLAINCOL: return new ExprTableEvalStrategyUngroupedProp((TableAndLockProviderUngrouped) provider, this); case ExprTableEvalStrategyEnum.GROUPED_PLAINCOL: return new ExprTableEvalStrategyGroupedProp((TableAndLockProviderGrouped) provider, this); case ExprTableEvalStrategyEnum.UNGROUPED_AGG_ACCESSREAD: return new ExprTableEvalStrategyUngroupedAggAccessRead( (TableAndLockProviderUngrouped) provider, this); case ExprTableEvalStrategyEnum.GROUPED_AGG_ACCESSREAD: return new ExprTableEvalStrategyGroupedAggAccessRead((TableAndLockProviderGrouped) provider, this); case ExprTableEvalStrategyEnum.KEYS: return new ExprTableEvalStrategyGroupedKeys((TableAndLockProviderGrouped) provider, this); default: throw new IllegalStateException("Unrecognized strategy " + StrategyEnum); } }
public static IDictionary <ExprTableAccessNode, ExprTableAccessEvalStrategy> AttachTableAccess( EPServicesContext services, AgentInstanceContext agentInstanceContext, ExprTableAccessNode[] tableNodes) { if (tableNodes == null || tableNodes.Length == 0) { return(Collections.GetEmptyMap <ExprTableAccessNode, ExprTableAccessEvalStrategy>()); } IDictionary <ExprTableAccessNode, ExprTableAccessEvalStrategy> strategies = new Dictionary <ExprTableAccessNode, ExprTableAccessEvalStrategy>(); foreach (var tableNode in tableNodes) { var writesToTables = agentInstanceContext.StatementContext.IsWritesToTables; TableAndLockProvider provider = services.TableService.GetStateProvider(tableNode.TableName, agentInstanceContext.AgentInstanceId, writesToTables); TableMetadata tableMetadata = services.TableService.GetTableMetadata(tableNode.TableName); ExprTableAccessEvalStrategy strategy = ExprTableEvalStrategyFactory.GetTableAccessEvalStrategy(tableNode, provider, tableMetadata); strategies.Put(tableNode, strategy); } return(strategies); }
public static ExprTableAccessEvalStrategy GetTableAccessEvalStrategy( ExprTableAccessNode tableNode, TableAndLockProvider provider, TableMetadata tableMetadata) { var groupKeyEvals = tableNode.GroupKeyEvaluators; TableAndLockProviderUngrouped ungrouped; TableAndLockProviderGrouped grouped; if (provider is TableAndLockProviderUngrouped) { ungrouped = (TableAndLockProviderUngrouped)provider; grouped = null; } else { grouped = (TableAndLockProviderGrouped)provider; ungrouped = null; } // handle sub-property access if (tableNode is ExprTableAccessNodeSubprop) { var subprop = (ExprTableAccessNodeSubprop)tableNode; var column = tableMetadata.TableColumns.Get(subprop.SubpropName); return(GetTableAccessSubprop(subprop, column, ungrouped, grouped)); } // handle top-level access if (tableNode is ExprTableAccessNodeTopLevel) { if (ungrouped != null) { return(new ExprTableEvalStrategyUngroupedTopLevel(ungrouped, tableMetadata.TableColumns)); } if (tableNode.GroupKeyEvaluators.Length > 1) { return(new ExprTableEvalStrategyGroupByTopLevelMulti( grouped, tableMetadata.TableColumns, groupKeyEvals)); } return(new ExprTableEvalStrategyGroupByTopLevelSingle( grouped, tableMetadata.TableColumns, groupKeyEvals[0])); } // handle "keys" function access if (tableNode is ExprTableAccessNodeKeys) { return(new ExprTableEvalStrategyGroupByKeys(grouped)); } // handle access-aggregator accessors if (tableNode is ExprTableAccessNodeSubpropAccessor) { var accessorProvider = (ExprTableAccessNodeSubpropAccessor)tableNode; var column = (TableMetadataColumnAggregation)tableMetadata.TableColumns.Get(accessorProvider.SubpropName); if (ungrouped != null) { var pairX = column.AccessAccessorSlotPair; return(new ExprTableEvalStrategyUngroupedAccess(ungrouped, pairX.Slot, accessorProvider.Accessor)); } var pair = new AggregationAccessorSlotPair( column.AccessAccessorSlotPair.Slot, accessorProvider.Accessor); if (tableNode.GroupKeyEvaluators.Length > 1) { return(new ExprTableEvalStrategyGroupByAccessMulti(grouped, pair, groupKeyEvals)); } return(new ExprTableEvalStrategyGroupByAccessSingle(grouped, pair, groupKeyEvals[0])); } throw new IllegalStateException("Unrecognized table access node " + tableNode); }