예제 #1
0
        public void Set(Term term)
        {
            if (term is null)
            {
                Reset();
                return;
            }
            bytes.CopyBytes(term.Bytes);
            field = term.Field.Intern();

            currentFieldNumber = -1;
            this.term          = term;
        }
예제 #2
0
        public void Set(Term term)
        {
            if (term == null)
            {
                Reset();
                return;
            }
            bytes.CopyBytes(term.Bytes);
            field = StringHelper.Intern(term.Field);

            currentFieldNumber = -1;
            this.term          = term;
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        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());
        }
예제 #5
0
        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()));
            }
        }