Package org.apache.accumulo.core.file.rfile.MultiLevelIndex

Examples of org.apache.accumulo.core.file.rfile.MultiLevelIndex.Reader


    byte[] data = baos.toByteArray();
    SeekableByteArrayInputStream bais = new SeekableByteArrayInputStream(data);
    FSDataInputStream in = new FSDataInputStream(bais);
    CachableBlockFile.Reader _cbr = new CachableBlockFile.Reader(in, data.length, CachedConfiguration.getInstance());
   
    Reader reader = new Reader(_cbr, RFile.RINDEX_VER_6);
    BlockRead rootIn = _cbr.getMetaBlock("root");
    reader.readFields(rootIn);
    rootIn.close();
    IndexIterator liter = reader.lookup(new Key("000000"));
    int count = 0;
    while (liter.hasNext()) {
      assertEquals(count, liter.nextIndex());
      assertEquals(count, liter.peek().getNumEntries());
      assertEquals(count, liter.next().getNumEntries());
      count++;
    }
   
    assertEquals(num + 1, count);
   
    while (liter.hasPrevious()) {
      count--;
      assertEquals(count, liter.previousIndex());
      assertEquals(count, liter.peekPrevious().getNumEntries());
      assertEquals(count, liter.previous().getNumEntries());
    }
   
    assertEquals(0, count);
   
    // go past the end
    liter = reader.lookup(new Key(String.format("%05d000", num + 1)));
    assertFalse(liter.hasNext());
   
    Random rand = new Random();
    for (int i = 0; i < 100; i++) {
      int k = rand.nextInt(num * 1000);
      int expected;
      if (k % 1000 == 0)
        expected = k / 1000; // end key is inclusive
      else
        expected = k / 1000 + 1;
      liter = reader.lookup(new Key(String.format("%08d", k)));
      IndexEntry ie = liter.next();
      assertEquals(expected, ie.getNumEntries());
    }
   
  }
View Full Code Here


    byte[] data = baos.toByteArray();
    SeekableByteArrayInputStream bais = new SeekableByteArrayInputStream(data);
    FSDataInputStream in = new FSDataInputStream(bais);
    CachableBlockFile.Reader _cbr = new CachableBlockFile.Reader(in, data.length, CachedConfiguration.getInstance());
   
    Reader reader = new Reader(_cbr, RFile.RINDEX_VER_7);
    BlockRead rootIn = _cbr.getMetaBlock("root");
    reader.readFields(rootIn);
    rootIn.close();
    IndexIterator liter = reader.lookup(new Key("000000"));
    int count = 0;
    while (liter.hasNext()) {
      assertEquals(count, liter.nextIndex());
      assertEquals(count, liter.peek().getNumEntries());
      assertEquals(count, liter.next().getNumEntries());
      count++;
    }
   
    assertEquals(num + 1, count);
   
    while (liter.hasPrevious()) {
      count--;
      assertEquals(count, liter.previousIndex());
      assertEquals(count, liter.peekPrevious().getNumEntries());
      assertEquals(count, liter.previous().getNumEntries());
    }
   
    assertEquals(0, count);
   
    // go past the end
    liter = reader.lookup(new Key(String.format("%05d000", num + 1)));
    assertFalse(liter.hasNext());
   
    Random rand = new Random();
    for (int i = 0; i < 100; i++) {
      int k = rand.nextInt(num * 1000);
      int expected;
      if (k % 1000 == 0)
        expected = k / 1000; // end key is inclusive
      else
        expected = k / 1000 + 1;
      liter = reader.lookup(new Key(String.format("%08d", k)));
      IndexEntry ie = liter.next();
      assertEquals(expected, ie.getNumEntries());
    }
   
  }
View Full Code Here

    byte[] data = baos.toByteArray();
    SeekableByteArrayInputStream bais = new SeekableByteArrayInputStream(data);
    FSDataInputStream in = new FSDataInputStream(bais);
    CachableBlockFile.Reader _cbr = new CachableBlockFile.Reader(in, data.length, CachedConfiguration.getInstance(), aconf);
   
    Reader reader = new Reader(_cbr, RFile.RINDEX_VER_7);
    BlockRead rootIn = _cbr.getMetaBlock("root");
    reader.readFields(rootIn);
    rootIn.close();
    IndexIterator liter = reader.lookup(new Key("000000"));
    int count = 0;
    while (liter.hasNext()) {
      assertEquals(count, liter.nextIndex());
      assertEquals(count, liter.peek().getNumEntries());
      assertEquals(count, liter.next().getNumEntries());
      count++;
    }
   
    assertEquals(num + 1, count);
   
    while (liter.hasPrevious()) {
      count--;
      assertEquals(count, liter.previousIndex());
      assertEquals(count, liter.peekPrevious().getNumEntries());
      assertEquals(count, liter.previous().getNumEntries());
    }
   
    assertEquals(0, count);
   
    // go past the end
    liter = reader.lookup(new Key(String.format("%05d000", num + 1)));
    assertFalse(liter.hasNext());
   
    Random rand = new Random();
    for (int i = 0; i < 100; i++) {
      int k = rand.nextInt(num * 1000);
      int expected;
      if (k % 1000 == 0)
        expected = k / 1000; // end key is inclusive
      else
        expected = k / 1000 + 1;
      liter = reader.lookup(new Key(String.format("%08d", k)));
      IndexEntry ie = liter.next();
      assertEquals(expected, ie.getNumEntries());
    }
   
  }
View Full Code Here

    byte[] data = baos.toByteArray();
    SeekableByteArrayInputStream bais = new SeekableByteArrayInputStream(data);
    FSDataInputStream in = new FSDataInputStream(bais);
    CachableBlockFile.Reader _cbr = new CachableBlockFile.Reader(in, data.length, CachedConfiguration.getInstance());
   
    Reader reader = new Reader(_cbr, RFile.RINDEX_VER_6);
    BlockRead rootIn = _cbr.getMetaBlock("root");
    reader.readFields(rootIn);
    rootIn.close();
    IndexIterator liter = reader.lookup(new Key("000000"));
    int count = 0;
    while (liter.hasNext()) {
      assertEquals(count, liter.nextIndex());
      assertEquals(count, liter.peek().getNumEntries());
      assertEquals(count, liter.next().getNumEntries());
      count++;
    }
   
    assertEquals(num + 1, count);
   
    while (liter.hasPrevious()) {
      count--;
      assertEquals(count, liter.previousIndex());
      assertEquals(count, liter.peekPrevious().getNumEntries());
      assertEquals(count, liter.previous().getNumEntries());
    }
   
    assertEquals(0, count);
   
    // go past the end
    liter = reader.lookup(new Key(String.format("%05d000", num + 1)));
    assertFalse(liter.hasNext());
   
    Random rand = new Random();
    for (int i = 0; i < 100; i++) {
      int k = rand.nextInt(num * 1000);
      int expected;
      if (k % 1000 == 0)
        expected = k / 1000; // end key is inclusive
      else
        expected = k / 1000 + 1;
      liter = reader.lookup(new Key(String.format("%08d", k)));
      IndexEntry ie = liter.next();
      assertEquals(expected, ie.getNumEntries());
    }
   
  }
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.file.rfile.MultiLevelIndex.Reader

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.