Beispiel #1
0
        internal void PushResultSet(QueryBranchResultSet resultSet)
        {
            Fx.Assert(null != resultSet, "");

            resultSet.Next  = this.resultPool;
            this.resultPool = resultSet;
        }
Beispiel #2
0
        internal override void Match(int valIndex, ref Value val, QueryBranchResultSet results)
        {
            QueryBranch branch = null;

            if (ValueDataType.Sequence == val.Type)
            {
                NodeSequence sequence = val.Sequence;
                for (int i = 0; i < sequence.Count; i++)
                {
                    branch = this[sequence.Items[i].StringValue()];
                    if (branch != null)
                    {
                        results.Add(branch, valIndex);
                    }
                }
            }
            else
            {
                branch = this[val.String];
                if (branch != null)
                {
                    results.Add(branch, valIndex);
                }
            }
        }
Beispiel #3
0
        public override void Trim()
        {
            // Trim stacks
            base.Trim();
            // Trim local pools individually
            QueryBranchResultSet result = this.resultPool;

            while (null != result)
            {
                result.Trim();
                result = result.Next;
            }
            NodeSequence sequence = this.sequencePool;

            while (null != sequencePool)
            {
                sequencePool.Trim();
                sequence = sequence.Next;
            }
            ProcessingContext context = this.contextPool;

            while (null != context)
            {
                context.Trim();
                context = context.Next;
            }
        }
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame topArg = context.TopArg;
            int        count  = topArg.Count;

            if (count > 0)
            {
                QueryBranchResultSet resultTable = context.Processor.CreateResultSet();
                BranchMatcher        matcher     = new BranchMatcher(count, resultTable);
                for (int i = 0; i < count; i++)
                {
                    this.CollectMatches(i, ref context.Values[topArg[i]], resultTable);
                }
                context.PopFrame();
                if (resultTable.Count > 1)
                {
                    resultTable.Sort();
                }
                if ((this.alwaysBranches != null) && (this.alwaysBranches.Count > 0))
                {
                    matcher.InvokeNonMatches(context, this.alwaysBranches);
                }
                matcher.InvokeMatches(context);
                matcher.Release(context);
            }
            else
            {
                context.PopFrame();
            }
            return(base.next);
        }
Beispiel #5
0
        internal override void Match(int valIndex, ref Value val, QueryBranchResultSet results)
        {
            QueryBranch branch = null;

            if (ValueDataType.Sequence == val.Type)
            {
                NodeSequence sequence = val.Sequence;
                for (int i = 0; i < sequence.Count; ++i)
                {
                    branch = this[sequence.Items[i].NumberValue()];
                    if (null != branch)
                    {
                        results.Add(branch, valIndex);
                    }
                }
            }
            else
            {
                branch = this[val.ToDouble()];
                if (null != branch)
                {
                    results.Add(branch, valIndex);
                }
            }
        }
Beispiel #6
0
        internal QueryBranchResultSet PopResultSet()
        {
            QueryBranchResultSet resultSet = this.resultPool;

            if (null != resultSet)
            {
                this.resultPool = resultSet.Next;
                resultSet.Next  = null;
            }
            return(resultSet);
        }
        internal QueryBranchResultSet PopResultSet()
        {
            QueryBranchResultSet resultPool = this.resultPool;

            if (resultPool != null)
            {
                this.resultPool = resultPool.Next;
                resultPool.Next = null;
            }
            return(resultPool);
        }
        internal QueryBranchResultSet CreateResultSet()
        {
            QueryBranchResultSet set = this.PopResultSet();

            if (set == null)
            {
                return(new QueryBranchResultSet());
            }
            set.Clear();
            return(set);
        }
        private void Match(int valIndex, string segment, QueryBranchResultSet results)
        {
            TrieTraverser traverser = new TrieTraverser(this.trie.Root, segment);

            while (traverser.MoveNext())
            {
                object data = traverser.Segment.Data;
                if (data != null)
                {
                    results.Add((QueryBranch)data, valIndex);
                }
            }
        }
Beispiel #10
0
        internal QueryBranchResultSet CreateResultSet()
        {
            QueryBranchResultSet resultSet = this.PopResultSet();

            if (null == resultSet)
            {
                resultSet = new QueryBranchResultSet();
            }
            else
            {
                resultSet.Clear();
            }
            return(resultSet);
        }
 internal override void Match(int valIndex, ref Value val, QueryBranchResultSet results)
 {
     if (ValueDataType.Sequence == val.Type)
     {
         NodeSequence sequence = val.Sequence;
         for (int i = 0; i < sequence.Count; i++)
         {
             this.Match(valIndex, sequence.Items[i].StringValue(), results);
         }
     }
     else
     {
         this.Match(valIndex, val.String, results);
     }
 }
Beispiel #12
0
        void Match(int valIndex, double point, QueryBranchResultSet results)
        {
            IntervalTreeTraverser traverser = new IntervalTreeTraverser(point, this.intervalTree.Root);

            while (traverser.MoveNext())
            {
                IntervalCollection matches = traverser.Slot;
                for (int i = 0, count = matches.Count; i < count; ++i)
                {
                    QueryBranch branch = matches[i].Branch;
                    if (null != branch)
                    {
                        results.Add(branch, valIndex);
                    }
                }
            }
        }
Beispiel #13
0
        private void Match(int valIndex, double point, QueryBranchResultSet results)
        {
            IntervalTreeTraverser traverser = new IntervalTreeTraverser(point, this.intervalTree.Root);

            while (traverser.MoveNext())
            {
                IntervalCollection slot = traverser.Slot;
                int num   = 0;
                int count = slot.Count;
                while (num < count)
                {
                    QueryBranch branch = slot[num].Branch;
                    if (branch != null)
                    {
                        results.Add(branch, valIndex);
                    }
                    num++;
                }
            }
        }
Beispiel #14
0
 public override void Reset()
 {
     base.Release();
     // Trim local pools by releasing all references
     while (null != this.PopResultSet())
     {
         ;
     }
     this.resultPool = null;
     while (null != this.PopSequence())
     {
         ;
     }
     this.sequencePool = null;
     while (null != this.PopContext())
     {
         ;
     }
     this.contextPool = null;
 }
Beispiel #15
0
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame arg      = context.TopArg;
            int        argCount = arg.Count;

            if (argCount > 0)
            {
                QueryBranchResultSet resultSet = context.Processor.CreateResultSet();
                BranchMatcher        matcher   = new BranchMatcher(argCount, resultSet);
                // Operate on values at the the top frame of the value stack
                // For each source value, find the branch that could be taken
                for (int i = 0; i < argCount; ++i)
                {
                    this.CollectMatches(i, ref context.Values[arg[i]], resultSet);
                }
                // Done with whatever we were testing equality against
                context.PopFrame();
                if (resultSet.Count > 1)
                {
                    // Sort results
                    resultSet.Sort();
                }

                // First, do non-true branches..
                if (null != this.alwaysBranches && this.alwaysBranches.Count > 0)
                {
                    matcher.InvokeNonMatches(context, this.alwaysBranches);
                }

                // Iterate through matches, invoking each matched branch
                matcher.InvokeMatches(context);

                matcher.Release(context);
            }
            else
            {
                context.PopFrame();
            }
            return(this.next);
        }
 internal virtual void CollectMatches(int valIndex, ref Value val, QueryBranchResultSet results)
 {
     this.branchIndex.Match(valIndex, ref val, results);
 }
 internal void ReleaseResults(QueryBranchResultSet resultSet)
 {
     this.PushResultSet(resultSet);
 }
 internal void PushResultSet(QueryBranchResultSet resultSet)
 {
     resultSet.Next  = this.resultPool;
     this.resultPool = resultSet;
 }
Beispiel #19
0
 internal void ReleaseResults(QueryBranchResultSet resultSet)
 {
     Fx.Assert(null != resultSet, "");
     this.PushResultSet(resultSet);
 }
Beispiel #20
0
 internal abstract void Match(int valIndex, ref Value val, QueryBranchResultSet results);
 internal BranchMatcher(int resultCount, QueryBranchResultSet resultTable)
 {
     this.resultCount = resultCount;
     this.resultTable = resultTable;
 }