Search in sources :

Example 1 with StripeRange

use of org.apache.hadoop.hdfs.util.StripedBlockUtil.StripeRange in project hadoop by apache.

the class DFSStripedInputStream method resetCurStripeBuffer.

void resetCurStripeBuffer() {
    if (curStripeBuf == null) {
        curStripeBuf = BUFFER_POOL.getBuffer(useDirectBuffer(), cellSize * dataBlkNum);
    }
    curStripeBuf.clear();
    curStripeRange = new StripeRange(0, 0);
}
Also used : StripeRange(org.apache.hadoop.hdfs.util.StripedBlockUtil.StripeRange)

Example 2 with StripeRange

use of org.apache.hadoop.hdfs.util.StripedBlockUtil.StripeRange in project hadoop by apache.

the class DFSStripedInputStream method readOneStripe.

/**
   * Read a new stripe covering the current position, and store the data in the
   * {@link #curStripeBuf}.
   */
private void readOneStripe(CorruptedBlocks corruptedBlocks) throws IOException {
    resetCurStripeBuffer();
    // compute stripe range based on pos
    final long offsetInBlockGroup = getOffsetInBlockGroup();
    final long stripeLen = cellSize * dataBlkNum;
    final int stripeIndex = (int) (offsetInBlockGroup / stripeLen);
    final int stripeBufOffset = (int) (offsetInBlockGroup % stripeLen);
    final int stripeLimit = (int) Math.min(currentLocatedBlock.getBlockSize() - (stripeIndex * stripeLen), stripeLen);
    StripeRange stripeRange = new StripeRange(offsetInBlockGroup, stripeLimit - stripeBufOffset);
    LocatedStripedBlock blockGroup = (LocatedStripedBlock) currentLocatedBlock;
    AlignedStripe[] stripes = StripedBlockUtil.divideOneStripe(ecPolicy, cellSize, blockGroup, offsetInBlockGroup, offsetInBlockGroup + stripeRange.getLength() - 1, curStripeBuf);
    final LocatedBlock[] blks = StripedBlockUtil.parseStripedBlockGroup(blockGroup, cellSize, dataBlkNum, parityBlkNum);
    // read the whole stripe
    for (AlignedStripe stripe : stripes) {
        // Parse group to get chosen DN location
        StripeReader sreader = new StatefulStripeReader(stripe, ecPolicy, blks, blockReaders, corruptedBlocks, decoder, this);
        sreader.readStripe();
    }
    curStripeBuf.position(stripeBufOffset);
    curStripeBuf.limit(stripeLimit);
    curStripeRange = stripeRange;
}
Also used : LocatedStripedBlock(org.apache.hadoop.hdfs.protocol.LocatedStripedBlock) StripeRange(org.apache.hadoop.hdfs.util.StripedBlockUtil.StripeRange) AlignedStripe(org.apache.hadoop.hdfs.util.StripedBlockUtil.AlignedStripe) LocatedBlock(org.apache.hadoop.hdfs.protocol.LocatedBlock)

Aggregations

StripeRange (org.apache.hadoop.hdfs.util.StripedBlockUtil.StripeRange)2 LocatedBlock (org.apache.hadoop.hdfs.protocol.LocatedBlock)1 LocatedStripedBlock (org.apache.hadoop.hdfs.protocol.LocatedStripedBlock)1 AlignedStripe (org.apache.hadoop.hdfs.util.StripedBlockUtil.AlignedStripe)1