public override SeekStatus SeekCeil(BytesRef text) { int ord = Values.LookupTerm(text); if (ord >= 0) { CurrentOrd = ord; Term_Renamed.Offset = 0; // TODO: is there a cleaner way? // term.bytes may be pointing to codec-private byte[] // storage, so we must force new byte[] allocation: Term_Renamed.Bytes = new sbyte[text.Length]; Term_Renamed.CopyBytes(text); return(SeekStatus.FOUND); } else { CurrentOrd = -ord - 1; if (CurrentOrd == Values.ValueCount) { return(SeekStatus.END); } else { // TODO: hmm can we avoid this "extra" lookup?: Values.LookupOrd(CurrentOrd, Term_Renamed); return(SeekStatus.NOT_FOUND); } } }
public override void LookupOrd(int ord, BytesRef result) { Debug.Assert(ord >= 0 && ord < valueCount); Debug.Assert(result.IsValid()); @in.LookupOrd(ord, result); Debug.Assert(result.IsValid()); }
public override void LookupOrd(int ord, BytesRef result) { Debug.Assert(ord >= 0 && ord < ValueCount_Renamed); Debug.Assert(result.Valid); @in.LookupOrd(ord, result); Debug.Assert(result.Valid); }
public override void LookupOrd(int ord, BytesRef result) { if (Debugging.AssertsEnabled) { Debugging.Assert(ord >= 0 && ord < valueCount); } if (Debugging.AssertsEnabled) { Debugging.Assert(result.IsValid()); } @in.LookupOrd(ord, result); if (Debugging.AssertsEnabled) { Debugging.Assert(result.IsValid()); } }
public override void LookupOrd(long ord, BytesRef result) { // cast is ok: single-valued cannot exceed Integer.MAX_VALUE @in.LookupOrd((int)ord, result); }
private static void CheckSortedDocValues(string fieldName, AtomicReader reader, SortedDocValues dv, Bits docsWithField) { CheckBinaryDocValues(fieldName, reader, dv, docsWithField); int maxOrd = dv.ValueCount - 1; FixedBitSet seenOrds = new FixedBitSet(dv.ValueCount); int maxOrd2 = -1; for (int i = 0; i < reader.MaxDoc; i++) { int ord = dv.GetOrd(i); if (ord == -1) { if (docsWithField.Get(i)) { throw new Exception("dv for field: " + fieldName + " has -1 ord but is not marked missing for doc: " + i); } } else if (ord < -1 || ord > maxOrd) { throw new Exception("ord out of bounds: " + ord); } else { if (!docsWithField.Get(i)) { throw new Exception("dv for field: " + fieldName + " is missing but has ord=" + ord + " for doc: " + i); } maxOrd2 = Math.Max(maxOrd2, ord); seenOrds.Set(ord); } } if (maxOrd != maxOrd2) { throw new Exception("dv for field: " + fieldName + " reports wrong maxOrd=" + maxOrd + " but this is not the case: " + maxOrd2); } if (seenOrds.Cardinality() != dv.ValueCount) { throw new Exception("dv for field: " + fieldName + " has holes in its ords, valueCount=" + dv.ValueCount + " but only used: " + seenOrds.Cardinality()); } BytesRef lastValue = null; BytesRef scratch = new BytesRef(); for (int i = 0; i <= maxOrd; i++) { dv.LookupOrd(i, scratch); Debug.Assert(scratch.Valid); if (lastValue != null) { if (scratch.CompareTo(lastValue) <= 0) { throw new Exception("dv for field: " + fieldName + " has ords out of order: " + lastValue + " >=" + scratch); } } lastValue = BytesRef.DeepCopyOf(scratch); } }