コード例 #1
0
            internal SortingDocsEnum(int maxDoc, SortingDocsEnum reuse, DocsEnum input, bool withFreqs, Sorter.DocMap docMap)
                : base(input)
            {
                this.maxDoc    = maxDoc;
                this.withFreqs = withFreqs;
                if (reuse != null)
                {
                    if (reuse.maxDoc == maxDoc)
                    {
                        sorter = reuse.sorter;
                    }
                    else
                    {
                        sorter = new DocFreqSorter(maxDoc);
                    }
                    docs  = reuse.docs;
                    freqs = reuse.freqs; // maybe null
                }
                else
                {
                    docs   = new int[64];
                    sorter = new DocFreqSorter(maxDoc);
                }
                docIt = -1;
                int i = 0;
                int doc;

                if (withFreqs)
                {
                    if (freqs is null || freqs.Length < docs.Length)
                    {
                        freqs = new int[docs.Length];
                    }
                    while ((doc = input.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                    {
                        if (i >= docs.Length)
                        {
                            docs  = ArrayUtil.Grow(docs, docs.Length + 1);
                            freqs = ArrayUtil.Grow(freqs, freqs.Length + 1);
                        }
                        docs[i]  = docMap.OldToNew(doc);
                        freqs[i] = input.Freq;
                        ++i;
                    }
                }
                else
                {
                    freqs = null;
                    while ((doc = input.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                    {
                        if (i >= docs.Length)
                        {
                            docs = ArrayUtil.Grow(docs, docs.Length + 1);
                        }
                        docs[i++] = docMap.OldToNew(doc);
                    }
                }
                // TimSort can save much time compared to other sorts in case of
                // reverse sorting, or when sorting a concatenation of sorted readers
                sorter.Reset(docs, freqs);
                sorter.Sort(0, i);
                upto = i;
            }
コード例 #2
0
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: SortingDocsEnum(int maxDoc, SortingDocsEnum reuse, final org.apache.lucene.index.DocsEnum in, boolean withFreqs, final Sorter.DocMap docMap) throws java.io.IOException
 //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
 internal SortingDocsEnum(int maxDoc, SortingDocsEnum reuse, DocsEnum @in, bool withFreqs, Sorter.DocMap docMap)
     : base(@in)
 {
     this.maxDoc = maxDoc;
       this.withFreqs = withFreqs;
       if (reuse != null)
       {
     if (reuse.maxDoc == maxDoc)
     {
       sorter = reuse.sorter;
     }
     else
     {
       sorter = new DocFreqSorter(maxDoc);
     }
     docs = reuse.docs;
     freqs = reuse.freqs; // maybe null
       }
       else
       {
     docs = new int[64];
     sorter = new DocFreqSorter(maxDoc);
       }
       docIt = -1;
       int i = 0;
       int doc;
       if (withFreqs)
       {
     if (freqs == null || freqs.Length < docs.Length)
     {
       freqs = new int[docs.Length];
     }
     while ((doc = @in.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
     {
       if (i >= docs.Length)
       {
     docs = ArrayUtil.grow(docs, docs.Length + 1);
     freqs = ArrayUtil.grow(freqs, freqs.Length + 1);
       }
       docs[i] = docMap.oldToNew(doc);
       freqs[i] = @in.freq();
       ++i;
     }
       }
       else
       {
     freqs = null;
     while ((doc = @in.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
     {
       if (i >= docs.Length)
       {
     docs = ArrayUtil.grow(docs, docs.Length + 1);
       }
       docs[i++] = docMap.oldToNew(doc);
     }
       }
       // TimSort can save much time compared to other sorts in case of
       // reverse sorting, or when sorting a concatenation of sorted readers
       sorter.reset(docs, freqs);
       sorter.sort(0, i);
       upto = i;
 }