Examples of IntDecoder


Examples of org.apache.lucene.util.encoding.IntDecoder

    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

Examples of org.apache.lucene.util.encoding.IntDecoder

    endTime = System.currentTimeMillis();

    long encodeTime = endTime - startTime;

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    IntDecoder decoder = encoder.createMatchingDecoder();
    decoder.reInit(bais);
   
    // -- Looping 100 times as a warm up --------------------------
    for (int i = 100; i != 0; --i) {
      bais.mark(baos.size());
      while (decoder.decode() != IntDecoder.EOS) {
      }
      bais.reset();
      decoder.reInit(bais);
    }
    // -----------------------------------------------------------

    decoder.reInit(bais);
    startTime = System.currentTimeMillis();
    for (int i = loopFactor; i > 0; --i) {
      bais.mark(baos.size());
      while (decoder.decode() != IntDecoder.EOS) {
      }
      bais.reset();
      decoder.reInit(bais);
    }

    endTime = System.currentTimeMillis();
    long decodeTime = endTime - startTime;
View Full Code Here

Examples of org.apache.lucene.util.encoding.IntDecoder

    IntEncoder enc = new VInt8IntEncoder();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    enc.reInit(baos);
    enc.encode(-1);
   
    IntDecoder dec = enc.createMatchingDecoder();
    dec.reInit(new ByteArrayInputStream(baos.toByteArray()));
    assertEquals(-1, dec.decode());
  }
View Full Code Here

Examples of org.apache.lucene.util.encoding.IntDecoder

  private static void encoderTest(IntEncoder encoder) {

    // ensure toString is implemented
    String toString = encoder.toString();
    assertFalse(toString.startsWith(encoder.getClass().getName() + "@"));
    IntDecoder decoder = encoder.createMatchingDecoder();
    toString = decoder.toString();
    assertFalse(toString.startsWith(decoder.getClass().getName() + "@"));
   
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    try {
      encoding(encoder, baos);
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.