Package org.apache.accumulo.core.file.blockfile

Examples of org.apache.accumulo.core.file.blockfile.ABlockReader


    out.close();
    final byte[] data = baos.toByteArray();
   
    CacheEntry ce = new MyCacheEntry(data);

    ABlockReader cacheBlock = new CachableBlockFile.CachedBlockRead(ce, data);
    BlockIndex blockIndex = null;
   
    for (int i = 0; i < 129; i++)
      blockIndex = BlockIndex.getIndex(cacheBlock, new IndexEntry(prevKey, num, 0, 0, 0));
   
    BlockIndexEntry[] indexEntries = blockIndex.getIndexEntries();
   
    for (int i = 0; i < indexEntries.length; i++) {
      int row = Integer.parseInt(indexEntries[i].getPrevKey().getRowData().toString());
     
      BlockIndexEntry bie;
     

      bie = blockIndex.seekBlock(new Key(RFileTest.nf("", row), "cf1", "cq1"), cacheBlock);
      if (i == 0)
        Assert.assertSame(null, bie);
      else
        Assert.assertSame(indexEntries[i - 1], bie);
     
      Assert.assertSame(bie, blockIndex.seekBlock(new Key(RFileTest.nf("", row - 1), "cf1", "cq1"), cacheBlock));

      bie = blockIndex.seekBlock(new Key(RFileTest.nf("", row + 1), "cf1", "cq1"), cacheBlock);
      Assert.assertSame(indexEntries[i], bie);

      RelativeKey rk = new RelativeKey();
      rk.setPrevKey(bie.getPrevKey());
      rk.readFields(cacheBlock);
     
      Assert.assertEquals(rk.getKey(), new Key(RFileTest.nf("", row + 1), "cf1", "cq1"));

    }
    cacheBlock.close();
  }
View Full Code Here


    out.close();
    final byte[] data = baos.toByteArray();
   
    CacheEntry ce = new MyCacheEntry(data);

    ABlockReader cacheBlock = new CachableBlockFile.CachedBlockRead(ce, data);
    BlockIndex blockIndex = null;
   
    for (int i = 0; i < 257; i++)
      blockIndex = BlockIndex.getIndex(cacheBlock, new IndexEntry(prevKey, num, 0, 0, 0));
   
    Assert.assertSame(null, blockIndex.seekBlock(new Key(RFileTest.nf("", 0), "cf1", "cq1"), cacheBlock));
    Assert.assertSame(null, blockIndex.seekBlock(new Key(RFileTest.nf("", 1), "cf1", "cq1"), cacheBlock));
   
    for (int i = 2; i < 6; i++) {
      Key seekKey = new Key(RFileTest.nf("", i), "cf1", "cq1");
      BlockIndexEntry bie = blockIndex.seekBlock(seekKey, cacheBlock);
     
      Assert.assertTrue(bie.getPrevKey().compareTo(seekKey) < 0);

      RelativeKey rk = new RelativeKey();
      rk.setPrevKey(bie.getPrevKey());
      rk.readFields(cacheBlock);
     
      Assert.assertTrue(rk.getKey().compareTo(seekKey) <= 0);
    }
    cacheBlock.close();
  }
View Full Code Here

      this.blockStore = blockStore;
    }
   
    private IndexBlock getIndexBlock(IndexEntry ie) throws IOException {
      IndexBlock iblock = new IndexBlock();
      ABlockReader in = blockStore.getMetaBlock(ie.getOffset(), ie.getCompressedSize(), ie.getRawSize());
      iblock.readFields(in, version);
      in.close();
     
      return iblock;
    }
View Full Code Here

    private AtomicBoolean interruptFlag;
   
    public Reader(BlockFileReader rdr) throws IOException {
      this.reader = rdr;
     
      ABlockReader mb = reader.getMetaBlock("RFile.index");
     
      int magic = mb.readInt();
      int ver = mb.readInt();
     
      if (magic != RINDEX_MAGIC)
        throw new IOException("Did not see expected magic number, saw " + magic);
      if (ver != RINDEX_VER_7 && ver != RINDEX_VER_6 && ver != RINDEX_VER_4 && ver != RINDEX_VER_3)
        throw new IOException("Did not see expected version, saw " + ver);
     
      int size = mb.readInt();
      lgReaders = new LocalityGroupReader[size];
     
      deepCopies = new LinkedList<Reader>();
     
      for (int i = 0; i < size; i++) {
        LocalityGroupMetadata lgm = new LocalityGroupMetadata(ver, rdr);
        lgm.readFields(mb);
        localityGroups.add(lgm);
       
        lgReaders[i] = new LocalityGroupReader(reader, lgm, ver);
      }
     
      mb.close();
     
      nonDefaultColumnFamilies = new HashSet<ByteSequence>();
      for (LocalityGroupMetadata lgm : localityGroups) {
        if (!lgm.isDefaultLG)
          nonDefaultColumnFamilies.addAll(lgm.columnFamilies.keySet());
View Full Code Here

    private AtomicBoolean interruptFlag;
   
    Reader(BlockFileReader rdr) throws IOException {
      this.reader = rdr;
     
      ABlockReader mb = reader.getMetaBlock("RFile.index");
     
      int magic = mb.readInt();
      int ver = mb.readInt();
     
      if (magic != RINDEX_MAGIC)
        throw new IOException("Did not see expected magic number, saw " + magic);
      if (ver != RINDEX_VER_6 && ver != RINDEX_VER_4 && ver != RINDEX_VER_3)
        throw new IOException("Did not see expected version, saw " + ver);
     
      int size = mb.readInt();
      lgReaders = new LocalityGroupReader[size];
     
      deepCopies = new LinkedList<Reader>();
     
      for (int i = 0; i < size; i++) {
        LocalityGroupMetadata lgm = new LocalityGroupMetadata(ver, rdr);
        lgm.readFields(mb);
        localityGroups.add(lgm);
       
        lgReaders[i] = new LocalityGroupReader(reader, lgm, ver);
      }
     
      mb.close();
     
      nonDefaultColumnFamilies = new HashSet<ByteSequence>();
      for (LocalityGroupMetadata lgm : localityGroups) {
        if (!lgm.isDefaultLG)
          nonDefaultColumnFamilies.addAll(lgm.columnFamilies.keySet());
View Full Code Here

      this.blockStore = blockStore;
    }
   
    private IndexBlock getIndexBlock(IndexEntry ie) throws IOException {
      IndexBlock iblock = new IndexBlock();
      ABlockReader in = blockStore.getMetaBlock(ie.getOffset(), ie.getCompressedSize(), ie.getRawSize());
      iblock.readFields(in, version);
      in.close();
     
      return iblock;
    }
View Full Code Here

    out.close();
    final byte[] data = baos.toByteArray();
   
    CacheEntry ce = new MyCacheEntry(data);

    ABlockReader cacheBlock = new CachableBlockFile.CachedBlockRead(ce, data);
    BlockIndex blockIndex = null;
   
    for (int i = 0; i < 129; i++)
      blockIndex = BlockIndex.getIndex(cacheBlock, new IndexEntry(prevKey, num, 0, 0, 0));
   
View Full Code Here

    out.close();
    final byte[] data = baos.toByteArray();
   
    CacheEntry ce = new MyCacheEntry(data);

    ABlockReader cacheBlock = new CachableBlockFile.CachedBlockRead(ce, data);
    BlockIndex blockIndex = null;
   
    for (int i = 0; i < 257; i++)
      blockIndex = BlockIndex.getIndex(cacheBlock, new IndexEntry(prevKey, num, 0, 0, 0));
   
View Full Code Here

      this.blockStore = blockStore;
    }
   
    private IndexBlock getIndexBlock(IndexEntry ie) throws IOException {
      IndexBlock iblock = new IndexBlock();
      ABlockReader in = blockStore.getMetaBlock(ie.getOffset(), ie.getCompressedSize(), ie.getRawSize());
      iblock.readFields(in, version);
      in.close();
     
      return iblock;
    }
View Full Code Here

    private AtomicBoolean interruptFlag;
   
    public Reader(BlockFileReader rdr) throws IOException {
      this.reader = rdr;
     
      ABlockReader mb = reader.getMetaBlock("RFile.index");
     
      int magic = mb.readInt();
      int ver = mb.readInt();
     
      if (magic != RINDEX_MAGIC)
        throw new IOException("Did not see expected magic number, saw " + magic);
      if (ver != RINDEX_VER_7 && ver != RINDEX_VER_6 && ver != RINDEX_VER_4 && ver != RINDEX_VER_3)
        throw new IOException("Did not see expected version, saw " + ver);
     
      int size = mb.readInt();
      lgReaders = new LocalityGroupReader[size];
     
      deepCopies = new LinkedList<Reader>();
     
      for (int i = 0; i < size; i++) {
        LocalityGroupMetadata lgm = new LocalityGroupMetadata(ver, rdr);
        lgm.readFields(mb);
        localityGroups.add(lgm);
       
        lgReaders[i] = new LocalityGroupReader(reader, lgm, ver);
      }
     
      mb.close();
     
      nonDefaultColumnFamilies = new HashSet<ByteSequence>();
      for (LocalityGroupMetadata lgm : localityGroups) {
        if (!lgm.isDefaultLG)
          nonDefaultColumnFamilies.addAll(lgm.columnFamilies.keySet());
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.file.blockfile.ABlockReader

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.