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

Examples of org.apache.accumulo.core.file.blockfile.impl.CachableBlockFile.BlockRead


   
    public Reader(CachableBlockFile.Reader cache, FSDataInputStream fin, long fileLength, Configuration conf) throws IOException {
      this.in = fin;
      this.conf = conf;
     
      BlockRead cachedMetaIndex = cache.getCachedMetaBlock(META_NAME);
      BlockRead cachedDataIndex = cache.getCachedMetaBlock(DataIndex.BLOCK_NAME);
     
      if (cachedMetaIndex == null || cachedDataIndex == null) {
        // move the cursor to the beginning of the tail, containing: offset to the
        // meta block index, version and magic
        fin.seek(fileLength - Magic.size() - Version.size() - Long.SIZE / Byte.SIZE);
        long offsetIndexMeta = fin.readLong();
        version = new Version(fin);
        Magic.readAndVerify(fin);
       
        if (!version.compatibleWith(BCFile.API_VERSION)) {
          throw new RuntimeException("Incompatible BCFile fileBCFileVersion.");
        }
       
        // read meta index
        fin.seek(offsetIndexMeta);
        metaIndex = new MetaIndex(fin);
        if (cachedMetaIndex == null) {
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          DataOutputStream dos = new DataOutputStream(baos);
          metaIndex.write(dos);
          dos.close();
          cache.cacheMetaBlock(META_NAME, baos.toByteArray());
        }
       
        // read data:BCFile.index, the data block index
        if (cachedDataIndex == null) {
          BlockReader blockR = getMetaBlock(DataIndex.BLOCK_NAME);
          cachedDataIndex = cache.cacheMetaBlock(DataIndex.BLOCK_NAME, blockR);
        }
       
        dataIndex = new DataIndex(cachedDataIndex);
        cachedDataIndex.close();
       
      } else {
        // Logger.getLogger(Reader.class).debug("Read bcfile !METADATA from cache");
        version = null;
        metaIndex = new MetaIndex(cachedMetaIndex);
View Full Code Here


   
    public Reader(CachableBlockFile.Reader cache, FSDataInputStream fin, long fileLength, Configuration conf) throws IOException {
      this.in = fin;
      this.conf = conf;
     
      BlockRead cachedMetaIndex = cache.getCachedMetaBlock(META_NAME);
      BlockRead cachedDataIndex = cache.getCachedMetaBlock(DataIndex.BLOCK_NAME);
     
      if (cachedMetaIndex == null || cachedDataIndex == null) {
        // move the cursor to the beginning of the tail, containing: offset to the
        // meta block index, version and magic
        fin.seek(fileLength - Magic.size() - Version.size() - Long.SIZE / Byte.SIZE);
View Full Code Here

    public Reader(CachableBlockFile.Reader cache, FSDataInputStream fin, long fileLength, Configuration conf, AccumuloConfiguration accumuloConfiguration) throws IOException {
      this.in = fin;
      this.conf = conf;

      BlockRead cachedMetaIndex = cache.getCachedMetaBlock(META_NAME);
      BlockRead cachedDataIndex = cache.getCachedMetaBlock(DataIndex.BLOCK_NAME);
      BlockRead cachedCryptoParams = cache.getCachedMetaBlock(CRYPTO_BLOCK_NAME);

      if (cachedMetaIndex == null || cachedDataIndex == null || cachedCryptoParams == null) {
        // move the cursor to the beginning of the tail, containing: offset to the
        // meta block index, version and magic
        // Move the cursor to grab the version and the magic first
View Full Code Here

    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());
View Full Code Here

   
    public Reader(CachableBlockFile.Reader cache, FSDataInputStream fin, long fileLength, Configuration conf) throws IOException {
      this.in = fin;
      this.conf = conf;
     
      BlockRead cachedMetaIndex = cache.getCachedMetaBlock(META_NAME);
      BlockRead cachedDataIndex = cache.getCachedMetaBlock(DataIndex.BLOCK_NAME);
     
      if (cachedMetaIndex == null || cachedDataIndex == null) {
        // move the cursor to the beginning of the tail, containing: offset to the
        // meta block index, version and magic
        fin.seek(fileLength - Magic.size() - Version.size() - Long.SIZE / Byte.SIZE);
View Full Code Here

   
    public Reader(CachableBlockFile.Reader cache, FSDataInputStream fin, long fileLength, Configuration conf) throws IOException {
      this.in = fin;
      this.conf = conf;
     
      BlockRead cachedMetaIndex = cache.getCachedMetaBlock(META_NAME);
      BlockRead cachedDataIndex = cache.getCachedMetaBlock(DataIndex.BLOCK_NAME);
     
      if (cachedMetaIndex == null || cachedDataIndex == null) {
        // move the cursor to the beginning of the tail, containing: offset to the
        // meta block index, version and magic
        fin.seek(fileLength - Magic.size() - Version.size() - Long.SIZE / Byte.SIZE);
        long offsetIndexMeta = fin.readLong();
        version = new Version(fin);
        Magic.readAndVerify(fin);
       
        if (!version.compatibleWith(BCFile.API_VERSION)) {
          throw new RuntimeException("Incompatible BCFile fileBCFileVersion.");
        }
       
        // read meta index
        fin.seek(offsetIndexMeta);
        metaIndex = new MetaIndex(fin);
        if (cachedMetaIndex == null) {
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          DataOutputStream dos = new DataOutputStream(baos);
          metaIndex.write(dos);
          dos.close();
          cache.cacheMetaBlock(META_NAME, baos.toByteArray());
        }
       
        // read data:BCFile.index, the data block index
        if (cachedDataIndex == null) {
          BlockReader blockR = getMetaBlock(DataIndex.BLOCK_NAME);
          cachedDataIndex = cache.cacheMetaBlock(DataIndex.BLOCK_NAME, blockR);
        }
       
        dataIndex = new DataIndex(cachedDataIndex);
        cachedDataIndex.close();
       
      } else {
        // Logger.getLogger(Reader.class).debug("Read bcfile !METADATA from cache");
        version = null;
        metaIndex = new MetaIndex(cachedMetaIndex);
View Full Code Here

    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());
View Full Code Here

    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());
View Full Code Here

    public Reader(CachableBlockFile.Reader cache, FSDataInputStream fin, long fileLength, Configuration conf, AccumuloConfiguration accumuloConfiguration) throws IOException {
      this.in = fin;
      this.conf = conf;

      BlockRead cachedMetaIndex = cache.getCachedMetaBlock(META_NAME);
      BlockRead cachedDataIndex = cache.getCachedMetaBlock(DataIndex.BLOCK_NAME);
      BlockRead cachedCryptoParams = cache.getCachedMetaBlock(CRYPTO_BLOCK_NAME);

      if (cachedMetaIndex == null || cachedDataIndex == null || cachedCryptoParams == null) {
        // move the cursor to the beginning of the tail, containing: offset to the
        // meta block index, version and magic
        // Move the cursor to grab the version and the magic first
View Full Code Here

    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());
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.file.blockfile.impl.CachableBlockFile.BlockRead

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.