/// <summary> /// The SnapshotCustomIndex /// </summary> /// <param name="queryGraphValue">The <see cref="QueryGraphValue"/></param> /// <param name="indexRepository">The <see cref="EventTableIndexRepository"/></param> /// <param name="attributes">The <see cref="Attribute"/> array</param> /// <param name="agentInstanceContext">The <see cref="AgentInstanceContext"/></param> /// <param name="queryPlanLogging">The <see cref="bool"/></param> /// <param name="queryPlanLogDestination">The <see cref="ILog"/></param> /// <param name="objectName">The <see cref="string"/></param> /// <returns>The <see cref="ICollection{EventBean}"/></returns> private static NullableObject <ICollection <EventBean> > SnapshotCustomIndex( QueryGraphValue queryGraphValue, EventTableIndexRepository indexRepository, Attribute[] attributes, AgentInstanceContext agentInstanceContext, bool queryPlanLogging, ILog queryPlanLogDestination, string objectName) { EventTable table = null; string indexName = null; QueryGraphValueEntryCustomOperation values = null; // find matching index var found = false; foreach (var valueDesc in queryGraphValue.Items) { if (valueDesc.Entry is QueryGraphValueEntryCustom) { var customIndex = (QueryGraphValueEntryCustom)valueDesc.Entry; foreach (var entry in indexRepository.TableIndexesRefCount) { if (entry.Key.AdvancedIndexDesc == null) { continue; } var metadata = indexRepository.EventTableIndexMetadata.Indexes.Get(entry.Key); if (metadata == null || metadata.ExplicitIndexNameIfExplicit == null) { continue; } EventAdvancedIndexProvisionDesc provision = metadata.QueryPlanIndexItem.AdvancedIndexProvisionDesc; if (provision == null) { continue; } foreach (var op in customIndex.Operations) { if (!provision.Factory.ProvidesIndexForOperation(op.Key.OperationName, op.Value.PositionalExpressions)) { continue; } if (ExprNodeUtility.DeepEquals(entry.Key.AdvancedIndexDesc.IndexedExpressions, op.Key.ExprNodes, true)) { values = op.Value; table = entry.Value.Table; indexName = metadata.ExplicitIndexNameIfExplicit; found = true; break; } } if (found) { break; } } } if (found) { break; } } if (table == null) { return(null); } // report queryPlanReport(indexName, table, attributes, agentInstanceContext, queryPlanLogging, queryPlanLogDestination, objectName); // execute EventTableQuadTree index = (EventTableQuadTree)table; var x = Eval(values.PositionalExpressions.Get(0).ExprEvaluator, agentInstanceContext, "x"); var y = Eval(values.PositionalExpressions.Get(1).ExprEvaluator, agentInstanceContext, "y"); var width = Eval(values.PositionalExpressions.Get(2).ExprEvaluator, agentInstanceContext, "width"); var height = Eval(values.PositionalExpressions.Get(3).ExprEvaluator, agentInstanceContext, "height"); var result = index.QueryRange(x, y, width, height); return(new NullableObject <ICollection <EventBean> >(result)); }
private static NullableObject<ICollection<EventBean>> SnapshotCustomIndex( QueryGraphValue queryGraphValue, EventTableIndexRepository indexRepository, Attribute[] annotations, AgentInstanceContext agentInstanceContext, string objectName) { EventTable table = null; string indexName = null; QueryGraphValueEntryCustomOperation values = null; // find matching index var found = false; foreach (var valueDesc in queryGraphValue.Items) { if (valueDesc.Entry is QueryGraphValueEntryCustom) { var customIndex = (QueryGraphValueEntryCustom) valueDesc.Entry; foreach (var entry in indexRepository.TableIndexesRefCount) { if (entry.Key.AdvancedIndexDesc == null) { continue; } var metadata = indexRepository.EventTableIndexMetadata.Indexes.Get(entry.Key); if (metadata == null || metadata.ExplicitIndexNameIfExplicit == null) { continue; } var provision = metadata.OptionalQueryPlanIndexItem.AdvancedIndexProvisionDesc; if (provision == null) { continue; } foreach (var op in customIndex.Operations) { if (!provision.Factory.Forge.ProvidesIndexForOperation(op.Key.OperationName)) { continue; } var indexProperties = entry.Key.AdvancedIndexDesc.IndexExpressions; var expressions = op.Key.Expressions; if (Arrays.AreEqual(indexProperties, expressions)) { values = op.Value; table = entry.Value.Table; indexName = metadata.ExplicitIndexNameIfExplicit; found = true; break; } } if (found) { break; } } } if (found) { break; } } if (table == null) { return null; } // report QueryPlanReport(indexName, table, annotations, agentInstanceContext, objectName); // execute var index = (EventTableQuadTree) table; var x = Eval(values.PositionalExpressions.Get(0), agentInstanceContext, "x"); var y = Eval(values.PositionalExpressions.Get(1), agentInstanceContext, "y"); var width = Eval(values.PositionalExpressions.Get(2), agentInstanceContext, "width"); var height = Eval(values.PositionalExpressions.Get(3), agentInstanceContext, "height"); return new NullableObject<ICollection<EventBean>>( index.QueryRange(x, y, width, height)); }
/// <summary> /// The SnapshotInKeyword /// </summary> /// <param name="queryGraphValue">The <see cref="QueryGraphValue"/></param> /// <param name="indexRepository">The <see cref="EventTableIndexRepository"/></param> /// <param name="virtualDataWindow">The <see cref="VirtualDWView"/></param> /// <param name="attributes">The <see cref="Attribute" /> array</param> /// <param name="agentInstanceContext">The <see cref="AgentInstanceContext"/></param> /// <param name="queryPlanLogging">The <see cref="bool"/></param> /// <param name="queryPlanLogDestination">The <see cref="ILog"/></param> /// <param name="objectName">The <see cref="string"/></param> /// <returns>The collection of event beans</returns> private static NullableObject <ICollection <EventBean> > SnapshotInKeyword( QueryGraphValue queryGraphValue, EventTableIndexRepository indexRepository, VirtualDWView virtualDataWindow, Attribute[] attributes, AgentInstanceContext agentInstanceContext, bool queryPlanLogging, ILog queryPlanLogDestination, string objectName) { var inkwSingles = queryGraphValue.InKeywordSingles; if (inkwSingles.Indexed.Length == 0) { return(null); } var tablePair = FindIndex( new HashSet <string>(inkwSingles.Indexed), Collections.GetEmptySet <string>(), indexRepository, virtualDataWindow, attributes); if (tablePair == null) { return(null); } queryPlanReport(tablePair.Second.IndexName, tablePair.Second.EventTable, attributes, agentInstanceContext, queryPlanLogging, queryPlanLogDestination, objectName); var evaluateParamsTrue = new EvaluateParams(null, true, agentInstanceContext); // table lookup with in-clause: determine combinations var tableHashProps = tablePair.First.HashIndexedProps; var combinations = new Object[tableHashProps.Length][]; for (var tableHashPropNum = 0; tableHashPropNum < tableHashProps.Length; tableHashPropNum++) { for (var i = 0; i < inkwSingles.Indexed.Length; i++) { if (inkwSingles.Indexed[i].Equals(tableHashProps[tableHashPropNum].IndexPropName)) { var keysExpressions = inkwSingles.Key[i]; var values = new Object[keysExpressions.KeyExprs.Count]; combinations[tableHashPropNum] = values; for (var j = 0; j < keysExpressions.KeyExprs.Count; j++) { values[j] = keysExpressions.KeyExprs[j].ExprEvaluator.Evaluate(evaluateParamsTrue); } } } } // enumerate combinations var enumeration = CombinationEnumeration.New(combinations); var events = new HashSet <EventBean>(); foreach (Object[] keys in enumeration) { var result = FafTableLookup(virtualDataWindow, tablePair.First, tablePair.Second.EventTable, keys, null, attributes); events.AddAll(result); } return(new NullableObject <ICollection <EventBean> >(events)); }
private static NullableObject<ICollection<EventBean>> SnapshotInKeyword( QueryGraphValue queryGraphValue, EventTableIndexRepository indexRepository, VirtualDWView virtualDataWindow, Attribute[] annotations, AgentInstanceContext agentInstanceContext, string objectName) { var inkwSingles = queryGraphValue.InKeywordSingles; if (inkwSingles.Indexed.Length == 0) { return null; } Pair<IndexMultiKey, EventTableAndNamePair> tablePair = FindIndex( new HashSet<string>(inkwSingles.Indexed), new EmptySet<string>(), indexRepository, virtualDataWindow, annotations); if (tablePair == null) { return null; } QueryPlanReport( tablePair.Second.IndexName, tablePair.Second.EventTable, annotations, agentInstanceContext, objectName); // table lookup with in-clause: determine combinations var tableHashProps = tablePair.First.HashIndexedProps; var combinations = new object[tableHashProps.Length][]; for (var tableHashPropNum = 0; tableHashPropNum < tableHashProps.Length; tableHashPropNum++) { for (var i = 0; i < inkwSingles.Indexed.Length; i++) { if (inkwSingles.Indexed[i].Equals(tableHashProps[tableHashPropNum].IndexPropName)) { QueryGraphValueEntryInKeywordSingleIdx keysExpressions = inkwSingles.Key[i]; var values = new object[keysExpressions.KeyExprs.Length]; combinations[tableHashPropNum] = values; for (var j = 0; j < keysExpressions.KeyExprs.Length; j++) { values[j] = keysExpressions.KeyExprs[j].Evaluate(null, true, agentInstanceContext); } } } } // enumerate combinations var enumeration = new CombinationEnumeration(combinations); var events = new HashSet<EventBean>(); while (enumeration.MoveNext()) { object[] keys = enumeration.Current; var result = FafTableLookup( virtualDataWindow, tablePair.First, tablePair.Second.EventTable, keys, null, annotations, agentInstanceContext); events.AddAll(result); } return new NullableObject<ICollection<EventBean>>(events); }