Package org.apache.lucene.util

Examples of org.apache.lucene.util.BytesRef


      buffer[0] = (byte) (size);
      buffer[1] = (byte) (size >> 8);
      buffer[2] = (byte) (size >> 16);
      buffer[3] = (byte) (size >> 24);
      payloadAttr = addAttribute(PayloadAttribute.class);
      payloadAttr.setPayload(new BytesRef(buffer));
      termAttr = addAttribute(CharTermAttribute.class);
      termAttr.append(term.text());
      returnToken = true;
    }
View Full Code Here


          Terms terms = fds.terms(field);
          if (terms == null) {
            continue;
          }
          TermsEnum termsEnum = terms.iterator(null);
          BytesRef text;
          DocsAndPositionsEnum docsAndPositions = null;
          List<BoboTerm> boboTermList = new ArrayList<BoboTerm>();
          while ((text = termsEnum.next()) != null) {
            BoboTerm boboTerm = new BoboTerm();
            boboTerm.term = text.utf8ToString();
            boboTerm.freq = (int) termsEnum.totalTermFreq();
            docsAndPositions = termsEnum.docsAndPositions(null, docsAndPositions);
            if (docsAndPositions != null) {
              docsAndPositions.nextDoc();
              boboTerm.positions = new ArrayList<Integer>();
View Full Code Here

    }
  }

  @Override
  public int fillBytesRef() {
    BytesRef bytes = getBytesRef();
    collator.getRawCollationKey(toString(), key);
    bytes.bytes = key.bytes;
    bytes.offset = 0;
    bytes.length = key.size;
    return bytes.hashCode();
  }
View Full Code Here

            return null;
          }
          if (count++ == 10000) {
            return null;
          }
          return new BytesRef(doc.get("body"));
        }

        @Override
        public BytesRef payload() {
          return null;
View Full Code Here

            for(String token : docs[upto]) {
              b.append(' ');
              b.append(token);
            }
            upto++;
            return new BytesRef(b.toString());
          }
        }

        @Override
        public long weight() {
View Full Code Here

  private void check(BytesRefSorter sorter) throws Exception {
    for (int i = 0; i < 100; i++) {
      byte [] current = new byte [random().nextInt(256)];
      random().nextBytes(current);
      sorter.add(new BytesRef(current));
    }

    // Create two iterators and check that they're aligned with each other.
    BytesRefIterator i1 = sorter.iterator();
    BytesRefIterator i2 = sorter.iterator();
   
    // Verify sorter contract.
    try {
      sorter.add(new BytesRef(new byte [1]));
      fail("expected contract violation.");
    } catch (IllegalStateException e) {
      // Expected.
    }
    BytesRef spare1;
    BytesRef spare2;
    while ((spare1 = i1.next()) != null && (spare2 = i2.next()) != null) {
      assertEquals(spare1, spare2);
    }
    assertNull(i1.next());
    assertNull(i2.next());
View Full Code Here

    /**
     * Creates a new {@link CachedOrds} from the {@link BinaryDocValues}.
     * Assumes that the {@link BinaryDocValues} is not {@code null}.
     */
    public CachedOrds(BinaryDocValues dv, int maxDoc, CategoryListParams clp) {
      final BytesRef buf = new BytesRef();

      offsets = new int[maxDoc + 1];
      int[] ords = new int[maxDoc]; // let's assume one ordinal per-document as an initial size

      // this aggregator is limited to Integer.MAX_VALUE total ordinals.
View Full Code Here

      }
    }
  }

  public void test0ByteKeys() throws Exception {
    BytesRef key1 = new BytesRef(4);
    key1.length = 4;
    BytesRef key2 = new BytesRef(3);
    key1.length = 3;

    WFSTCompletionLookup suggester = new WFSTCompletionLookup(false);

    suggester.build(new InputArrayIterator(new Input[] {
View Full Code Here

    BufferedReader reader = new BufferedReader(
        new InputStreamReader(
            new FileInputStream(input), "UTF-8"));
   
    BytesRef scratch = new BytesRef();
    String line;
    int count = 0;
    while ((line = reader.readLine()) != null) {
      scratch.copyChars(line);
      builder.add(scratch, count % buckets);
      if ((count++ % 100000) == 0) {
        System.err.println("Line: " + count);
      }
    }
View Full Code Here

    initReaderManager();

    int doc = -1;
    DirectoryReader reader = readerManager.acquire();
    try {
      final BytesRef catTerm = new BytesRef(categoryPath.toString(delimiter));
      TermsEnum termsEnum = null; // reuse
      DocsEnum docs = null; // reuse
      for (AtomicReaderContext ctx : reader.leaves()) {
        Terms terms = ctx.reader().terms(Consts.FULL);
        if (terms != null) {
View Full Code Here

TOP

Related Classes of org.apache.lucene.util.BytesRef

Copyright © 2018 www.massapicom. 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.