internal virtual MonotonicAppendingLongBuffer getDeletes(IList <AtomicReader> readers) { MonotonicAppendingLongBuffer deletes = new MonotonicAppendingLongBuffer(); int deleteCount = 0; foreach (AtomicReader reader in readers) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int maxDoc = reader.maxDoc(); int maxDoc = reader.maxDoc(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.lucene.util.Bits liveDocs = reader.getLiveDocs(); Bits liveDocs = reader.LiveDocs; for (int i = 0; i < maxDoc; ++i) { if (liveDocs != null && !liveDocs.get(i)) { ++deleteCount; } else { deletes.add(deleteCount); } } } deletes.freeze(); return(deletes); }
/// <summary> /// Computes the old-to-new permutation over the given comparator. </summary> //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: private static Sorter.DocMap sort(final int maxDoc, DocComparator comparator) private static Sorter.DocMap sort(int maxDoc, DocComparator comparator) { // check if the index is sorted bool sorted = true; for (int i = 1; i < maxDoc; ++i) { if (comparator.compare(i - 1, i) > 0) { sorted = false; break; } } if (sorted) { return(null); } // sort doc IDs //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int[] docs = new int[maxDoc]; int[] docs = new int[maxDoc]; for (int i = 0; i < maxDoc; i++) { docs[i] = i; } DocValueSorter sorter = new DocValueSorter(docs, comparator); // It can be common to sort a reader, add docs, sort it again, ... and in // that case timSort can save a lot of time sorter.sort(0, docs.Length); // docs is now the newToOld mapping // The reason why we use MonotonicAppendingLongBuffer here is that it // wastes very little memory if the index is in random order but can save // a lot of memory if the index is already "almost" sorted //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.lucene.util.packed.MonotonicAppendingLongBuffer newToOld = new org.apache.lucene.util.packed.MonotonicAppendingLongBuffer(); MonotonicAppendingLongBuffer newToOld = new MonotonicAppendingLongBuffer(); for (int i = 0; i < maxDoc; ++i) { newToOld.add(docs[i]); } newToOld.freeze(); for (int i = 0; i < maxDoc; ++i) { docs[(int)newToOld.get(i)] = i; } // docs is now the oldToNew mapping //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.lucene.util.packed.MonotonicAppendingLongBuffer oldToNew = new org.apache.lucene.util.packed.MonotonicAppendingLongBuffer(); MonotonicAppendingLongBuffer oldToNew = new MonotonicAppendingLongBuffer(); for (int i = 0; i < maxDoc; ++i) { oldToNew.add(docs[i]); } oldToNew.freeze(); return(new DocMapAnonymousInnerClassHelper(maxDoc, newToOld, oldToNew)); }