Package org.apache.lucene.facet.index

Examples of org.apache.lucene.facet.index.CategoryListPayloadStream


            throw new IOException(
                "Error: Association without ordinal");
          }

          if (payloadStream == null) {
            payloadStream = new CategoryListPayloadStream(
                new SimpleIntEncoder());
          }
          payloadStream.appendIntToStream(ordinalProperty
              .getOrdinal());
          payloadStream.appendIntToStream(associationProperty
View Full Code Here


            .getProperty(OrdinalProperty.class);
        if (ordinalProperty != null && legalCategory()) {
          CategoryPath categoryPath = this.categoryAttribute
              .getCategoryPath();
          int ordinal = ordinalProperty.getOrdinal();
          CategoryListPayloadStream payloadStream = getPayloadStream(
              categoryPath, ordinal);
          int partitionSize = indexingParams.getPartitionSize();
          payloadStream.appendIntToStream(ordinal % partitionSize);
        }
      }
      return true;
    }
    if (this.payloadStreamIterator == null) {
      this.handleEndOfInput();
      this.payloadStreamIterator = this.payloadStreamsByName.entrySet()
          .iterator();
    }
    if (this.payloadStreamIterator.hasNext()) {
      Entry<String, CategoryListPayloadStream> entry = this.payloadStreamIterator
          .next();
      String countingListName = entry.getKey();
      int length = countingListName.length();
      this.termAttribute.resizeBuffer(length);
      countingListName.getChars(0, length, termAttribute.buffer(), 0);
      this.termAttribute.setLength(length);
      CategoryListPayloadStream payloadStream = entry.getValue();
      payload.setData(payloadStream.convertStreamToByteArray());
      this.payloadAttribute.setPayload(payload);
      return true;
    }
    return false;
  }
View Full Code Here

  protected CategoryListPayloadStream getPayloadStream(
      CategoryPath categoryPath, int ordinal) throws IOException {
    CategoryListParams clParams = this.indexingParams.getCategoryListParams(categoryPath);
    String name = PartitionsUtils.partitionNameByOrdinal(indexingParams, clParams, ordinal);
    CategoryListPayloadStream fps = payloadStreamsByName.get(name);
    if (fps == null) {
      IntEncoder encoder = clParams.createEncoder();
      fps = new CategoryListPayloadStream(encoder);
      payloadStreamsByName.put(name, fps);
    }
    return fps;
  }
View Full Code Here

   * a byte stream for later constructing a Payload.
   */
  @Test
  public void testStream() throws Exception {

    CategoryListPayloadStream clps = new CategoryListPayloadStream(
        new UniqueValuesIntEncoder(new DGapIntEncoder(
            new NOnesIntEncoder(3))));

    clps.appendIntToStream(1);
    clps.appendIntToStream(10);
    clps.appendIntToStream(100);
    clps.appendIntToStream(1000);
    clps.appendIntToStream(10000);
    clps.appendIntToStream(100000);
    clps.appendIntToStream(1000000);
    clps.appendIntToStream(10000000);
    clps.appendIntToStream(100000000);
    clps.appendIntToStream(1000000000);
    clps.appendIntToStream(Integer.MAX_VALUE);

    ByteArrayInputStream bais = new ByteArrayInputStream(clps
        .convertStreamToByteArray());
    IntDecoder decoder = new DGapIntDecoder(new NOnesIntDecoder(3));
    decoder.reInit(bais);
    assertEquals("Wrong value in byte stream", 1, decoder.decode());
    assertEquals("Wrong value in byte stream", 10, decoder.decode());
    assertEquals("Wrong value in byte stream", 100, decoder.decode());
    assertEquals("Wrong value in byte stream", 1000, decoder.decode());
    assertEquals("Wrong value in byte stream", 10000, decoder.decode());
    assertEquals("Wrong value in byte stream", 100000, decoder.decode());
    assertEquals("Wrong value in byte stream", 1000000, decoder.decode());
    assertEquals("Wrong value in byte stream", 10000000, decoder.decode());
    assertEquals("Wrong value in byte stream", 100000000, decoder.decode());
    assertEquals("Wrong value in byte stream", 1000000000, decoder.decode());
    assertEquals("Wrong value in byte stream", Integer.MAX_VALUE, decoder.decode());
    assertEquals("End of stream not reached", IntDecoder.EOS, decoder.decode());

    clps.reset();
    decoder.reInit(bais);
    assertEquals("End of stream not reached", IntDecoder.EOS, decoder.decode());
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.index.CategoryListPayloadStream

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.