Package org.apache.lucene.util

Examples of org.apache.lucene.util.IntsRef


   * have clean attributes data. Because of that, the attributes datatypeURI and
   * node have to saved in order to be restored after.
   */
  private void copyInnerStreamAttributes() {
    // backup datatype and node path
    final IntsRef nodePath = IntsRef.deepCopyOf(nodeAtt.node());
    final char[] dt = dtypeAtt.datatypeURI();
    // clear attributes
    input.clearAttributes();
    // copy inner attributes
    final int len = tokenTermAtt.length();
View Full Code Here


  private void doTest(final int[] values, final int blockSize,
                      final BlockCompressor compressor,
                      final BlockDecompressor decompressor)
  throws Exception {
    final BytesRef compressedData = new BytesRef(compressor.maxCompressedSize(blockSize));
    final IntsRef input = new IntsRef(blockSize);
    final IntsRef output = new IntsRef(blockSize);

    for (int i = 0; i < values.length; i += blockSize) {

      int offset = 0;
View Full Code Here

  VIntPayloadCodec codec = new VIntPayloadCodec();

  @Test
  public void testSimpleVInt()
  throws Exception {
    IntsRef ints = new IntsRef(new int[] { 12,43 }, 0, 2);
    int pos = 256;
    BytesRef bytes = codec.encode(ints, pos);
    codec.decode(bytes);

    IntsRef node = codec.getNode();
    assertEquals(ints.ints[0], node.ints[node.offset]);
    assertEquals(ints.ints[1], node.ints[node.offset + 1]);
    assertEquals(pos, codec.getPosition());

    ints = new IntsRef(new int[] { 3, 2 }, 0, 2);
    pos = 2;
    bytes = codec.encode(ints, pos);
    codec.decode(bytes);

    node = codec.getNode();
    assertEquals(ints.ints[0], node.ints[node.offset]);
    assertEquals(ints.ints[1], node.ints[node.offset + 1]);
    assertEquals(pos, codec.getPosition());

    ints = new IntsRef(new int[] { 0, 1 }, 0, 2);
    pos = 0;
    bytes = codec.encode(ints, pos);
    codec.decode(bytes);

    node = codec.getNode();
View Full Code Here

    final Random r = LuceneTestCase.random();
    for (int i = 0; i < 10000; i++) {
      final int value1 = r.nextInt(Integer.MAX_VALUE);
      final int value2 = r.nextInt(Integer.MAX_VALUE);

      final IntsRef ints = new IntsRef(new int[] { value1,value2 }, 0, 2);
      final int pos = r.nextInt(Integer.MAX_VALUE);
      final BytesRef bytes = codec.encode(ints, pos);
      codec.decode(bytes);

      final IntsRef node = codec.getNode();
      assertEquals(ints.ints[0], node.ints[node.offset]);
      assertEquals(ints.ints[1], node.ints[node.offset + 1]);
      assertEquals(pos, codec.getPosition());
    }
  }
View Full Code Here

    for (int i = 0; i < 10000; i++) {
      final int value1 = r.nextInt(Integer.MAX_VALUE);
      final int value2 = r.nextInt(Integer.MAX_VALUE);
      final int value3 = r.nextInt(Integer.MAX_VALUE);

      final IntsRef ints = new IntsRef(new int[] { value1,value2,value3 }, 0, 3);
      final int pos = r.nextInt(Integer.MAX_VALUE);
      final BytesRef bytes = codec.encode(ints, pos);
      codec.decode(bytes);

      final IntsRef node = codec.getNode();
      assertEquals(ints.ints[0], node.ints[node.offset]);
      assertEquals(ints.ints[1], node.ints[node.offset + 1]);
      assertEquals(ints.ints[2], node.ints[node.offset + 2]);
      assertEquals(pos, codec.getPosition());
    }
View Full Code Here

public class TestNodeUtils {

  @Test
  public void testCompare() {
    IntsRef n1 = node(0, 0, 0);
    IntsRef n2 = node(1, 0, 0);
    assertTrue(NodeUtils.compare(n1, n2) < 0);

    n1 = node(1, 1, 0);
    n2 = node(1, 0, 0);
    assertTrue(NodeUtils.compare(n1, n2) > 0);
View Full Code Here

    private int currentPos = 0;

    public PosBlockWriter() {
      // ensure that the input buffers has the minimum size required
      // maxBlockSize is just use as a minimum initial capacity for the buffers
      posBuffer = new IntsRef(this.getMinimumBufferSize(maxBlockSize, posCompressor.getWindowSize()));
    }
View Full Code Here

    assertTrue(NodeUtils.compare(n1, n2) < 0);
  }

  @Test
  public void testCompareAncestor() {
    IntsRef n1 = node(0, 0, 0);
    IntsRef n2 = node(1, 0, 0);
    assertTrue(NodeUtils.compareAncestor(n1, n2) < 0);

    n1 = node(1, 1, 0);
    n2 = node(1, 0, 0);
    assertTrue(NodeUtils.compareAncestor(n1, n2) > 0);
View Full Code Here

    final int[][] constraints = new int[][] {
      new int[] { 1,8 },
      new int[] { 5,5 },
    };

    IntsRef node = node(1,0,5);
    assertTrue(NodeUtils.isConstraintSatisfied(node, 3, levelIndex, constraints));

    node = node(8,10,5);
    assertTrue(NodeUtils.isConstraintSatisfied(node, 3, levelIndex, constraints));
View Full Code Here

    assertFalse(NodeUtils.isConstraintSatisfied(node, 3, levelIndex, constraints));
  }

  @Test
  public void testIsLevelConstraintSatisfied() {
    IntsRef node = node(1,5,1);
    assertTrue(NodeUtils.isConstraintSatisfied(node, 3));

    node = node(1,5,1);
    assertFalse(NodeUtils.isConstraintSatisfied(node, 2));
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.