示例#1
0
            /// <summary>NOTE: modifies and returns either "this" or "other"</summary>
            public virtual SmallDocSet Union(SmallDocSet other)
            {
                SmallDocSet bigger;
                SmallDocSet smaller;

                if (other.intSet.Count > this.intSet.Count)
                {
                    bigger  = other;
                    smaller = this;
                }
                else
                {
                    bigger  = this;
                    smaller = other;
                }
                //modify bigger
                foreach (int v in smaller.intSet.Keys)
                {
                    if (v == smaller.intSet.EmptyVal)
                    {
                        continue;
                    }
                    bigger.Set(v);
                }
                return(bigger);
            }
示例#2
0
            /// <summary>NOTE: modifies and returns either "this" or "other"</summary>
            /// <exception cref="ArgumentNullException"><paramref name="other"/> is <c>null</c>.</exception>
            public virtual SmallDocSet Union(SmallDocSet other)
            {
                if (other is null)
                {
                    throw new ArgumentNullException(nameof(other));
                }

                SmallDocSet bigger;
                SmallDocSet smaller;

                if (other.intSet.Count > this.intSet.Count)
                {
                    bigger  = other;
                    smaller = this;
                }
                else
                {
                    bigger  = this;
                    smaller = other;
                }
                //modify bigger
                foreach (int v in smaller.intSet.Keys)
                {
                    if (v == smaller.intSet.EmptyVal)
                    {
                        continue;
                    }
                    bigger.Set(v);
                }
                return(bigger);
            }
示例#3
0
            private SmallDocSet?CollectDocs(IBits acceptContains)
            {
                // LUCENENET specific - guard against null m_termsEnum
                if (m_termsEnum is null)
                {
                    //signals all done
                    return(null);
                }

                SmallDocSet?set = null;

                m_docsEnum = m_termsEnum.Docs(acceptContains, m_docsEnum, DocsFlags.NONE);
                int docid;

                while ((docid = m_docsEnum.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                {
                    if (set is null)
                    {
                        int size = this.m_termsEnum.DocFreq;
                        if (size <= 0)
                        {
                            size = 16;
                        }
                        set = new SmallDocSet(size);
                    }
                    set.Set(docid);
                }
                return(set);
            }
            //see getLeafDocs
            /// <summary>This is the primary algorithm; recursive.</summary>
            /// <remarks>This is the primary algorithm; recursive.  Returns null if finds none.</remarks>
            /// <exception cref="System.IO.IOException"></exception>
            internal SmallDocSet Visit(Cell cell, IBits acceptContains
                                       )
            {
                if (termsEnum == null)
                {
                    //signals all done
                    return(null);
                }
                //Leaf docs match all query shape
                SmallDocSet leafDocs = GetLeafDocs(cell, acceptContains);
                // Get the AND of all child results
                SmallDocSet        combinedSubResults = null;
                ICollection <Cell> subCells           = cell.GetSubCells(_enclosing.queryShape);

                foreach (Cell subCell in subCells)
                {
                    if (!SeekExact(subCell))
                    {
                        combinedSubResults = null;
                    }
                    else
                    {
                        if (subCell.Level == _enclosing.detailLevel)
                        {
                            combinedSubResults = GetDocs(subCell, acceptContains);
                        }
                        else
                        {
                            if (subCell.GetShapeRel() == SpatialRelation.WITHIN)
                            {
                                combinedSubResults = GetLeafDocs(subCell, acceptContains);
                            }
                            else
                            {
                                combinedSubResults = Visit(subCell, acceptContains);
                            }
                        }
                    }
                    //recursion
                    if (combinedSubResults == null)
                    {
                        break;
                    }
                    acceptContains = combinedSubResults;
                }
                //has the 'AND' effect on next iteration
                // Result: OR the leaf docs with AND of all child results
                if (combinedSubResults != null)
                {
                    if (leafDocs == null)
                    {
                        return(combinedSubResults);
                    }
                    return(leafDocs.Union(combinedSubResults));
                }
                return(leafDocs);
            }
示例#5
0
            private SmallDocSet CollectDocs(Bits acceptContains)
            {
                SmallDocSet set = null;

                docsEnum = termsEnum.Docs(acceptContains, docsEnum, DocsEnum.FLAG_NONE);
                int docid;

                while ((docid = docsEnum.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                {
                    if (set == null)
                    {
                        int size = this.termsEnum.DocFreq();
                        if (size <= 0)
                        {
                            size = 16;
                        }
                        set = new SmallDocSet(size);
                    }
                    set.Set(docid);
                }
                return(set);
            }
示例#6
0
            internal Cell nextCell;//see getLeafDocs

            /// <remarks>This is the primary algorithm; recursive.  Returns null if finds none.</remarks>
            /// <exception cref="System.IO.IOException"></exception>
            internal SmallDocSet Visit(Cell cell, Bits acceptContains)
            {
                if (termsEnum == null)
                {
                    //signals all done
                    return(null);
                }

                ContainsPrefixTreeFilter outerInstance = (ContainsPrefixTreeFilter)base.outerInstance;

                //Leaf docs match all query shape
                SmallDocSet leafDocs = GetLeafDocs(cell, acceptContains);
                // Get the AND of all child results (into combinedSubResults)
                SmallDocSet combinedSubResults = null;
                //   Optimization: use null subCellsFilter when we know cell is within the query shape.
                IShape subCellsFilter = outerInstance.queryShape;

                if (cell.Level != 0 && ((cell.ShapeRel == SpatialRelation.NOT_SET || cell.ShapeRel == SpatialRelation.WITHIN)))
                {
                    subCellsFilter = null;
                    Debug.Assert(cell.Shape.Relate(outerInstance.queryShape) == SpatialRelation.WITHIN);
                }
                ICollection <Cell> subCells = cell.GetSubCells(subCellsFilter);

                foreach (Cell subCell in subCells)
                {
                    if (!SeekExact(subCell))
                    {
                        combinedSubResults = null;
                    }
                    else if (subCell.Level == outerInstance.detailLevel)
                    {
                        combinedSubResults = GetDocs(subCell, acceptContains);
                    }
                    else if (!outerInstance.multiOverlappingIndexedShapes &&
                             subCell.ShapeRel == SpatialRelation.WITHIN)
                    {
                        combinedSubResults = GetLeafDocs(subCell, acceptContains); //recursion
                    }
                    else
                    {
                        combinedSubResults = Visit(subCell, acceptContains);
                    }

                    if (combinedSubResults == null)
                    {
                        break;
                    }

                    acceptContains = combinedSubResults;//has the 'AND' effect on next iteration
                }

                // Result: OR the leaf docs with AND of all child results
                if (combinedSubResults != null)
                {
                    if (leafDocs == null)
                    {
                        return(combinedSubResults);
                    }
                    return(leafDocs.Union(combinedSubResults));//union is 'or'
                }
                return(leafDocs);
            }