Package org.apache.lucene.util

Examples of org.apache.lucene.util.BytesRef.utf8ToString()


    final BytesRef result = c.floor(b, b);
    if (expected == null) {
      assertNull(result);
    } else {
      assertNotNull(result);
      assertEquals("actual=" + result.utf8ToString() + " vs expected=" + expected + " (input=" + input + ")",
                   result, new BytesRef(expected));
    }
  }

  private void testTerms(String[] terms) throws Exception {
View Full Code Here


        Terms terms = context.reader().terms(clp.field);
        if (terms != null) {
          TermsEnum te = terms.iterator(null);
          BytesRef termBytes = null;
          while ((termBytes = te.next()) != null) {
            String term = termBytes.utf8ToString();
            if (term.startsWith(PAYLOAD_TERM_TEXT )) {
              if (term.equals(PAYLOAD_TERM_TEXT)) {
                fieldTerms.put(clp.field, new Term(clp.field, term));
              } else {
                fieldTerms.put(clp.field + term.substring(PAYLOAD_TERM_TEXT.length()), new Term(clp.field, term));
View Full Code Here

        BytesRefIterator iter = dict.getWordsIterator();
        BytesRef currentTerm;
       
        terms: while ((currentTerm = iter.next()) != null) {
 
          String word = currentTerm.utf8ToString();
          int len = word.length();
          if (len < 3) {
            continue; // too short we bail but "too long" is fine...
          }
 
View Full Code Here

        stringList.add(randomRealisticUnicodeString);
      }
      for (int i = 0; i < entries; i++) {
        assertNotNull(list.get(spare, i));
        assertEquals("entry " + i + " doesn't match", stringList.get(i),
            spare.utf8ToString());
      }
     
      // check random
      for (int i = 0; i < entries; i++) {
        int e = random.nextInt(entries);
View Full Code Here

      // check random
      for (int i = 0; i < entries; i++) {
        int e = random.nextInt(entries);
        assertNotNull(list.get(spare, e));
        assertEquals("entry " + i + " doesn't match", stringList.get(e),
            spare.utf8ToString());
      }
      for (int i = 0; i < 2; i++) {
       
        BytesRefIterator iterator = list.iterator();
        for (String string : stringList) {
View Full Code Here

      BytesRefIterator iter = list.iterator(BytesRef
          .getUTF8SortedAsUTF16Comparator());
      int i = 0;
      while ((spare = iter.next()) != null) {
        assertEquals("entry " + i + " doesn't match", stringList.get(i),
            spare.utf8ToString());
        i++;
      }
      assertNull(iter.next());
      assertEquals(i, stringList.size());
    }
View Full Code Here

      long ord;
      while ((ord = iter.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {
        te.seekExact(ord);
        final BytesRef expected = termsArray[answers[upto++]];
        if (VERBOSE) {
          System.out.println("  exp=" + expected.utf8ToString() + " actual=" + te.term().utf8ToString());
        }
        assertEquals("expected=" + expected.utf8ToString() + " actual=" + te.term().utf8ToString() + " ord=" + ord, expected, te.term());
      }
      assertEquals(answers.length, upto);
    }
View Full Code Here

        te.seekExact(ord);
        final BytesRef expected = termsArray[answers[upto++]];
        if (VERBOSE) {
          System.out.println("  exp=" + expected.utf8ToString() + " actual=" + te.term().utf8ToString());
        }
        assertEquals("expected=" + expected.utf8ToString() + " actual=" + te.term().utf8ToString() + " ord=" + ord, expected, te.term());
      }
      assertEquals(answers.length, upto);
    }
  }
 
View Full Code Here

          while(tp.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
            int freq = tp.freq();
            for (int i = 0; i < freq; i++) {
              tp.nextPosition();
              final BytesRef payload = tp.getPayload();
              assertEquals(termText, payload.utf8ToString());
            }
          }
        }
        reader.close();
        dir.close();
View Full Code Here

      assertEquals(numTerms-1, terms.size());
    }
    TermsEnum termsEnum = terms.iterator(null);
    BytesRef term;
    while ((term = termsEnum.next()) != null) {
      int value = Integer.parseInt(term.utf8ToString());
      assertEquals(value, termsEnum.docFreq());
      // don't really need to check more than this, as CheckIndex
      // will verify that docFreq == actual number of documents seen
      // from a docsAndPositionsEnum.
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.