/// <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));
        }