public override void SetNextReader(IndexReader reader, int docBase, IState state) { var currentReaderValues = FieldCache_Fields.DEFAULT.GetStringIndex(reader, _field, state); _order = currentReaderValues.order; _lookup = currentReaderValues.lookup; }
protected internal static int BinarySearch(UnmanagedStringArray a, UnmanagedStringArray.UnmanagedString key, int low, int high) { while (low <= high) { int mid = Number.URShift((low + high), 1); var midVal = a[mid]; int cmp; if (midVal.IsNull == false) { cmp = UnmanagedStringArray.UnmanagedString.CompareOrdinal(midVal, key); } else { cmp = -1; } if (cmp < 0) { low = mid + 1; } else if (cmp > 0) { high = mid - 1; } else { return(mid); } } return(-(low + 1)); }
public override void SetNextReader(IndexReader reader, int docBase, IState state) { StringIndex currentReaderValues = Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetStringIndex(reader, field, state); currentReaderGen++; order = currentReaderValues.order; lookup = currentReaderValues.lookup; System.Diagnostics.Debug.Assert(lookup.Length > 0); if (bottomSlot != -1) { Convert(bottomSlot); bottomOrd = ords[bottomSlot]; } }
/// <summary>Creates one of these objects </summary> public StringIndex(int[] values, int[] reverseOrder, UnmanagedStringArray lookup) { this.order = values; this.reverseOrder = reverseOrder; this.lookup = lookup; }
protected internal static int BinarySearch(UnmanagedStringArray a, UnmanagedStringArray.UnmanagedString key) { return(BinarySearch(a, key, 0, a.Length - 1)); }
protected internal override StringIndex CreateValue(IndexReader reader, Entry entryKey, IState state) { System.String field = StringHelper.Intern(entryKey.field); int[] retArray = new int[reader.MaxDoc]; int[] retArrayOrdered = new int[reader.MaxDoc]; for (int i = 0; i < retArrayOrdered.Length; i++) { retArrayOrdered[i] = -1; } var length = reader.MaxDoc + 1; UnmanagedStringArray mterms = new UnmanagedStringArray(length); TermDocs termDocs = reader.TermDocs(state); SegmentTermEnum termEnum = (SegmentTermEnum)reader.Terms(new Term(field), state); int t = 0; // current term number int docIndex = 0; // an entry for documents that have no terms in this field // should a document with no terms be at top or bottom? // this puts them at the top - if it is changed, FieldDocSortedHitQueue // needs to change as well. t++; try { do { if (termEnum.termBuffer.Field != field || t >= length) { break; } // store term text mterms.Add(termEnum.termBuffer.TextAsSpan); termDocs.Seek(termEnum, state); while (termDocs.Next(state)) { var pt = retArray[termDocs.Doc]; retArray[termDocs.Doc] = t; if (pt == 0) { retArrayOrdered[docIndex++] = termDocs.Doc; } } t++; }while (termEnum.Next(state)); } finally { termDocs.Close(); termEnum.Close(); } StringIndex value_Renamed = new StringIndex(retArray, retArrayOrdered, mterms); return(value_Renamed); }