コード例 #1
0
            public virtual DocIdSet GetDocIdSet()
            {
                if (Debugging.AssertsEnabled)
                {
                    Debugging.Assert(curVNode == null, "Called more than once?");
                }
                if (m_termsEnum == null)
                {
                    return(null);
                }
                //advance
                if (!m_termsEnum.MoveNext())
                {
                    return(null);// all done
                }
                thisTerm = m_termsEnum.Term;

                curVNode = new VNode(null);
                curVNode.Reset(m_outerInstance.m_grid.WorldCell);

                Start();

                AddIntersectingChildren();

                while (thisTerm != null)//terminates for other reasons too!
                {
                    //Advance curVNode pointer
                    if (curVNode.children != null)
                    {
                        //-- HAVE CHILDREN: DESCEND

                        // LUCENENET NOTE: Must call this line before calling MoveNext()
                        // on the enumerator.

                        //if we put it there then it has something
                        PreSiblings(curVNode);

                        // LUCENENET IMPORTANT: Must not call this inline with Debug.Assert
                        // because the compiler removes Debug.Assert statements in release mode!!
                        bool hasNext = curVNode.children.MoveNext();
                        if (Debugging.AssertsEnabled)
                        {
                            Debugging.Assert(hasNext);
                        }

                        curVNode = curVNode.children.Current;
                    }
                    else
                    {
                        //-- NO CHILDREN: ADVANCE TO NEXT SIBLING
                        VNode parentVNode = curVNode.parent;
                        while (true)
                        {
                            if (parentVNode == null)
                            {
                                goto main_break;// all done
                            }
                            if (parentVNode.children.MoveNext())
                            {
                                //advance next sibling
                                curVNode = parentVNode.children.Current;
                                break;
                            }
                            else
                            {
                                //reached end of siblings; pop up
                                PostSiblings(parentVNode);
                                parentVNode.children = null;
                                //GC
                                parentVNode = parentVNode.parent;
                            }
                        }
                    }
                    //Seek to curVNode's cell (or skip if termsEnum has moved beyond)
                    curVNodeTerm.Bytes  = curVNode.cell.GetTokenBytes();
                    curVNodeTerm.Length = curVNodeTerm.Bytes.Length;
                    int compare = m_termsEnum.Comparer.Compare(thisTerm, curVNodeTerm);
                    if (compare > 0)
                    {
                        // leap frog (termsEnum is beyond where we would otherwise seek)
                        if (Debugging.AssertsEnabled)
                        {
                            Debugging.Assert(!m_context.AtomicReader.GetTerms(m_outerInstance.m_fieldName).GetEnumerator().SeekExact(curVNodeTerm), "should be absent");
                        }
                    }
                    else
                    {
                        if (compare < 0)
                        {
                            // Seek !
                            TermsEnum.SeekStatus seekStatus = m_termsEnum.SeekCeil(curVNodeTerm);
                            if (seekStatus == TermsEnum.SeekStatus.END)
                            {
                                break;// all done
                            }
                            thisTerm = m_termsEnum.Term;
                            if (seekStatus == TermsEnum.SeekStatus.NOT_FOUND)
                            {
                                continue; // leap frog
                            }
                        }
                        // Visit!
                        bool descend = Visit(curVNode.cell);
                        //advance
                        if (!m_termsEnum.MoveNext())
                        {
                            thisTerm = null;
                            break;// all done
                        }
                        thisTerm = m_termsEnum.Term;
                        if (descend)
                        {
                            AddIntersectingChildren();
                        }
                    }
                    ;
                }//main loop
                main_break : { }

                return(Finish());
            }
コード例 #2
0
            /// <exception cref="System.IO.IOException"></exception>
            public virtual DocIdSet GetDocIdSet()
            {
                Debug.Assert(curVNode == null, "Called more than once?");
                if (termsEnum == null)
                {
                    return(null);
                }
                //advance
                if ((thisTerm = termsEnum.Next()) == null)
                {
                    return(null);
                }
                // all done
                curVNode = new VNode(null);
                curVNode.Reset(_enclosing.grid.WorldCell);
                Start();
                AddIntersectingChildren();
                while (thisTerm != null)
                {
                    //terminates for other reasons too!
                    //Advance curVNode pointer
                    if (curVNode.children != null)
                    {
                        //-- HAVE CHILDREN: DESCEND
                        Debug.Assert(curVNode.children.MoveNext());
                        //if we put it there then it has something
                        PreSiblings(curVNode);
                        curVNode = curVNode.children.Current;
                    }
                    else
                    {
                        //-- NO CHILDREN: ADVANCE TO NEXT SIBLING
                        VNode parentVNode = curVNode.parent;
                        while (true)
                        {
                            if (parentVNode == null)
                            {
                                goto main_break;
                            }
                            // all done
                            if (parentVNode.children.MoveNext())
                            {
                                //advance next sibling
                                curVNode = parentVNode.children.Current;
                                break;
                            }
                            else
                            {
                                //reached end of siblings; pop up
                                PostSiblings(parentVNode);
                                parentVNode.children = null;
                                //GC
                                parentVNode = parentVNode.parent;
                            }
                        }
                    }
                    //Seek to curVNode's cell (or skip if termsEnum has moved beyond)
                    curVNodeTerm.bytes  = curVNode.cell.GetTokenBytes().ToSByteArray();
                    curVNodeTerm.length = curVNodeTerm.bytes.Length;
                    int compare = termsEnum.Comparator.Compare(thisTerm, curVNodeTerm
                                                               );
                    if (compare > 0)
                    {
                        // leap frog (termsEnum is beyond where we would otherwise seek)
                        Debug.Assert(
                            !((AtomicReader)context.Reader).Terms(_enclosing.fieldName).Iterator(null).SeekExact(
                                curVNodeTerm, false), "should be absent"
                            );
                    }
                    else
                    {
                        if (compare < 0)
                        {
                            // Seek !
                            TermsEnum.SeekStatus seekStatus = termsEnum.SeekCeil(curVNodeTerm, true
                                                                                 );
                            if (seekStatus == TermsEnum.SeekStatus.END)
                            {
                                break;
                            }
                            // all done
                            thisTerm = termsEnum.Term;
                            if (seekStatus == TermsEnum.SeekStatus.NOT_FOUND)
                            {
                                continue;
                            }
                        }
                        // leap frog
                        // Visit!
                        bool descend = Visit(curVNode.cell);
                        //advance
                        if ((thisTerm = termsEnum.Next()) == null)
                        {
                            break;
                        }
                        // all done
                        if (descend)
                        {
                            AddIntersectingChildren();
                        }
                    }
                    ;
                }
main_break:
                ;
                //main loop
                return(Finish());
            }