/// <summary>Returns the position of a Term in the set or -1. </summary> internal long GetPosition(Term term) { if (size == 0) { return(-1); } int indexOffset = GetIndexOffset(term); SeekEnum(indexOffset); SegmentTermEnum enumerator = GetEnum(); while (term.CompareTo(enumerator.Term()) > 0 && enumerator.Next()) { } if (term.CompareTo(enumerator.Term()) == 0) { return(enumerator.position); } else { return(-1); } }
private Term ScanEnum(int position) { SegmentTermEnum enumerator = GetEnum(); while (enumerator.position < position) { if (!enumerator.Next()) { return(null); } } return(enumerator.Term()); }
/// <summary>Scans within block for matching term. </summary> private TermInfo ScanEnum(Term term) { SegmentTermEnum enumerator = GetEnum(); while (term.CompareTo(enumerator.Term()) > 0 && enumerator.Next()) { } if (enumerator.Term() != null && term.CompareTo(enumerator.Term()) == 0) { return(enumerator.TermInfo()); } else { return(null); } }
private void ReadIndex() { SegmentTermEnum indexEnum = new SegmentTermEnum(directory.OpenFile(segment + ".tii"), fieldInfos, true); try { int indexSize = (int)indexEnum.size; indexTerms = new Term[indexSize]; indexInfos = new TermInfo[indexSize]; indexPointers = new long[indexSize]; for (int i = 0; indexEnum.Next(); i++) { indexTerms[i] = indexEnum.Term(); indexInfos[i] = indexEnum.TermInfo(); indexPointers[i] = indexEnum.indexPointer; } } finally { indexEnum.Close(); } }
private void ReadIndex() { SegmentTermEnum indexEnum = new SegmentTermEnum(directory.OpenFile(segment + ".tii"), fieldInfos, true); try { int indexSize = (int) indexEnum.size; indexTerms = new Term[indexSize]; indexInfos = new TermInfo[indexSize]; indexPointers = new long[indexSize]; for (int i = 0; indexEnum.Next(); i++) { indexTerms[i] = indexEnum.Term(); indexInfos[i] = indexEnum.TermInfo(); indexPointers[i] = indexEnum.indexPointer; } } finally { indexEnum.Close(); } }