Exemple #1
0
 protected ICollection<EventBean> LookupInternal(EventBean[] events, ExprEvaluatorContext context)
 {
     var x = Eval(_factory.X, events, context, "x");
     var y = Eval(_factory.Y, events, context, "y");
     var width = Eval(_factory.Width, events, context, "width");
     var height = Eval(_factory.Height, events, context, "height");
     return _index.QueryRange(x, y, width, height);
 }
        /// <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));
        }