Package org.apache.lucene.util

Examples of org.apache.lucene.util.IntsRef


    return !validIterators.isEmpty();
  }
 
  @Override
  public void getOrdinals(int docID, IntsRef ints) throws IOException {
    IntsRef tmp = new IntsRef(ints.length);
    for (CategoryListIterator cli : validIterators) {
      cli.getOrdinals(docID, tmp);
      if (ints.ints.length < ints.length + tmp.length) {
        ints.grow(ints.length + tmp.length);
      }
View Full Code Here


  private static long LIMIT = 3L*1024*1024*1024;

  public void test() throws Exception {
    int[] ints = new int[7];
    IntsRef input = new IntsRef(ints, 0, ints.length);
    long seed = random().nextLong();

    Directory dir = new MMapDirectory(_TestUtil.getTempDir("2BFST"));

    for(int doPackIter=0;doPackIter<2;doPackIter++) {
      boolean doPack = doPackIter == 1;

      // Build FST w/ NoOutputs and stop when nodeCount > 2.2B
      if (!doPack) {
        System.out.println("\nTEST: 3B nodes; doPack=false output=NO_OUTPUTS");
        Outputs<Object> outputs = NoOutputs.getSingleton();
        Object NO_OUTPUT = outputs.getNoOutput();
        final Builder<Object> b = new Builder<Object>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, Integer.MAX_VALUE, outputs,
                                                      null, doPack, PackedInts.COMPACT, true, 15);

        int count = 0;
        Random r = new Random(seed);
        int[] ints2 = new int[200];
        IntsRef input2 = new IntsRef(ints2, 0, ints2.length);
        while(true) {
          //System.out.println("add: " + input + " -> " + output);
          for(int i=10;i<ints2.length;i++) {
            ints2[i] = r.nextInt(256);
          }
View Full Code Here

  public void testListOfOutputs() throws Exception {
    PositiveIntOutputs _outputs = PositiveIntOutputs.getSingleton();
    ListOfOutputs<Long> outputs = new ListOfOutputs<Long>(_outputs);
    final Builder<Object> builder = new Builder<Object>(FST.INPUT_TYPE.BYTE1, outputs);

    final IntsRef scratch = new IntsRef();
    // Add the same input more than once and the outputs
    // are merged:
    builder.add(Util.toIntsRef(new BytesRef("a"), scratch), 1L);
    builder.add(Util.toIntsRef(new BytesRef("a"), scratch), 3L);
    builder.add(Util.toIntsRef(new BytesRef("a"), scratch), 0L);
View Full Code Here

  public void testListOfOutputsEmptyString() throws Exception {
    PositiveIntOutputs _outputs = PositiveIntOutputs.getSingleton();
    ListOfOutputs<Long> outputs = new ListOfOutputs<Long>(_outputs);
    final Builder<Object> builder = new Builder<Object>(FST.INPUT_TYPE.BYTE1, outputs);

    final IntsRef scratch = new IntsRef();
    builder.add(scratch, 0L);
    builder.add(scratch, 1L);
    builder.add(scratch, 17L);
    builder.add(scratch, 1L);
View Full Code Here

      final BytesRef lastTerm = new BytesRef(10);
      long lastDocsStart = -1;
      int docFreq = 0;
      long totalTermFreq = 0;
      OpenBitSet visitedDocs = new OpenBitSet();
      final IntsRef scratchIntsRef = new IntsRef();
      while(true) {
        SimpleTextUtil.readLine(in, scratch);
        if (scratch.equals(END) || StringHelper.startsWith(scratch, FIELD)) {
          if (lastDocsStart != -1) {
            b.add(Util.toIntsRef(lastTerm, scratchIntsRef),
View Full Code Here

    }
    IndexReader reader = writer.getReader();
    writer.close();

    int totalCategories = 0;
    IntsRef ordinals = new IntsRef();
    CategoryListIterator cli = new DocValuesCategoryListIterator("f", encoder.createMatchingDecoder());
    for (AtomicReaderContext context : reader.leaves()) {
      assertTrue("failed to initalize iterator", cli.setNextReader(context));
      int maxDoc = context.reader().maxDoc();
      int dataIdx = context.docBase;
View Full Code Here

    IndexReader reader = writer.getReader();
    writer.close();

    int totalCategories = 0;
    IntsRef ordinals = new IntsRef();
    CategoryListIterator cli = new DocValuesCategoryListIterator("f", encoder.createMatchingDecoder());
    for (AtomicReaderContext context : reader.leaves()) {
      assertTrue("failed to initalize iterator", cli.setNextReader(context));
      int maxDoc = context.reader().maxDoc();
      int dataIdx = context.docBase;
View Full Code Here

      iterators[i] = new DocValuesCategoryListIterator(clp.field, decoder);
    }
    MultiCategoryListIterator cli = new MultiCategoryListIterator(iterators);
    for (AtomicReaderContext context : indexReader.leaves()) {
      assertTrue("failed to init multi-iterator", cli.setNextReader(context));
      IntsRef ordinals = new IntsRef();
      final int maxDoc = context.reader().maxDoc();
      for (int i = 0; i < maxDoc; i++) {
        cli.getOrdinals(i, ordinals);
        assertTrue("document " + i + " does not have categories", ordinals.length > 0);
        for (int j = 0; j < ordinals.length; j++) {
View Full Code Here

    if (iterator.hasPayloads()) {
      throw new IllegalArgumentException("this suggester doesn't support payloads");
    }
    BytesRef scratch = new BytesRef();
    InputIterator iter = new WFSTInputIterator(iterator);
    IntsRef scratchInts = new IntsRef();
    BytesRef previous = null;
    PositiveIntOutputs outputs = PositiveIntOutputs.getSingleton();
    Builder<Long> builder = new Builder<Long>(FST.INPUT_TYPE.BYTE1, outputs);
    while ((scratch = iter.next()) != null) {
      long cost = iter.weight();
View Full Code Here

        shareMaxTailLength, outputs, null, false,
        PackedInts.DEFAULT, true, 15);
   
    BytesRef scratch = new BytesRef();
    BytesRef entry;
    final IntsRef scratchIntsRef = new IntsRef();
    int count = 0;
    BytesRefIterator iter = sorter.iterator();
    while((entry = iter.next()) != null) {
      count++;
      if (scratch.compareTo(entry) != 0) {
View Full Code Here

TOP

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

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.