public void Set(Term term) { if (term is null) { Reset(); return; } bytes.CopyBytes(term.Bytes); field = term.Field.Intern(); currentFieldNumber = -1; this.term = term; }
public void Set(Term term) { if (term == null) { Reset(); return; } bytes.CopyBytes(term.Bytes); field = StringHelper.Intern(term.Field); currentFieldNumber = -1; this.term = term; }
/// <summary> /// Creates a new BytesRef that points to a copy of the bytes from /// <code>other</code> /// <p> /// The returned BytesRef will have a length of other.length /// and an offset of zero. /// </summary> public static BytesRef DeepCopyOf(BytesRef other) { BytesRef copy = new BytesRef(); copy.CopyBytes(other); return(copy); }
public virtual void TestCopyBytes() { sbyte[] bytes = new sbyte[] { (sbyte)'a', (sbyte)'b', (sbyte)'c', (sbyte)'d' }; BytesRef b = new BytesRef(bytes, 1, 3); // bcd b.CopyBytes(new BytesRef("bcde")); Assert.AreEqual("bcde", b.Utf8ToString()); }
private void CheckTermsOrder(IndexReader r, ISet<string> allTerms, bool isTop) { TermsEnum terms = MultiFields.GetFields(r).Terms("f").Iterator(null); BytesRef last = new BytesRef(); HashSet<string> seenTerms = new HashSet<string>(); while (true) { BytesRef term = terms.Next(); if (term == null) { break; } Assert.IsTrue(last.CompareTo(term) < 0); last.CopyBytes(term); string s = term.Utf8ToString(); Assert.IsTrue(allTerms.Contains(s), "term " + TermDesc(s) + " was not added to index (count=" + allTerms.Count + ")"); seenTerms.Add(s); } if (isTop) { Assert.IsTrue(allTerms.SetEquals(seenTerms)); } // Test seeking: IEnumerator<string> it = seenTerms.GetEnumerator(); while (it.MoveNext()) { BytesRef tr = new BytesRef(it.Current); Assert.AreEqual(TermsEnum.SeekStatus.FOUND, terms.SeekCeil(tr), "seek failed for term=" + TermDesc(tr.Utf8ToString())); } }