Record the given block at the given offset in this piece.

@param block  The ByteBuffer containing the block data.
@param offset The block offset in this piece.
185921
public void record(ByteBuffer block, int offset) {
    if (this.data == null) {
      // TODO: remove cast to int when large ByteBuffer support is
      // implemented in Java.
      this.data = ByteBuffer.allocate((int) this.length);
    }

    int pos = block.position();
    this.data.position(offset);
    this.data.put(block);
    block.position(pos);
  }
1012773
private void writeBytesSlow(final byte[] bytes, int off, int len)
    {
        while (len > 0)
        {
            final Block block = current;
            final int amount = Math.min(len, block.remaining());
            System.arraycopy(bytes, off, block.data, block.limit, amount);
            block.limit += amount;
            off += amount;
            len -= amount;
            if (block.remaining() == 0)
            {
                if (index == blocks.size() - 1)
                {
                    allocateNewBlock();
                }
                index++;
                current = blocks.get(index);
            }
        }

    }
782503
@Override
  public void write(byte []buffer, int offset, int length)
  {
    write(buffer, offset, length, true);
  }
393667
public static void writeBytes(byte b[], int offset, byte[] value) {
    System.arraycopy(value, 0, b, offset, value.length);
  }
619101
protected Block visitBlock(Block block) {
        if (block == null) {
            return null;
        }

        Statement stmt = (Statement)block.accept(this);

        if (stmt instanceof Block) {
            return (Block)stmt;
        }
        else if (stmt != null) {
            return new Block(stmt);
        }
        else {
            return new Block(block.getSourceInfo());
        }
    }
1274864
@Override // FSDatasetInterface
  public void finalizeBlock(int namespaceId, Block b) throws IOException {
    finalizeBlockInternal(namespaceId, b, true);
  }
1213160
public void addBlock(Block block)
    {
        try {
            this.stack.getFirst().add(block);
        } catch (NoSuchElementException e) {
            throw new IllegalStateException("All container blocks are closed, too many calls to endBlockList().");
        }
    }
1156083
public synchronized void write(int blockNumber, int blockOffset, int value) 
			throws IOException {
		long pointer = getBlockOffset(blockNumber) + blockOffset;
		if(mapped == true) {
			MappedByteBuffer map = NikeFS2FileAccessMonitor.instance().requestMap(this);
			map.position((int)pointer);
			map.put((byte)(value - 128));
		} else {
			rafile.seek(pointer);
			rafile.write(value);
		}
	}
250932
protected final void copyBitcoinHeaderTo(final Block block) {
        block.nonce = nonce;
        block.prevBlockHash = prevBlockHash;
        block.merkleRoot = getMerkleRoot();
        block.version = version;
        block.time = time;
        block.difficultyTarget = difficultyTarget;
        block.transactions = null;
        block.hash = getHash();
    }
64814
void setBlock(final int index, final Block b) {
    blockList[index2BlockId(index)] = b.getBlockId();
    blockList[index2BlockLen(index)] = b.getNumBytes();
    blockList[index2BlockGenStamp(index)] = b.getGenerationStamp();
  }
862440
public int copyTo(byte []buffer, int rowOffset, int blobTail)
  {
    byte []blockBuffer = _block.getBuffer();

    System.arraycopy(blockBuffer, _rowOffset, buffer, rowOffset, _length);

    return _row.copyBlobs(blockBuffer, _rowOffset, buffer, rowOffset,
                          blobTail);
  }
105033
void storeBlock(BlockId blockId, ByteBuffer block) throws IOException {
        synchronized (m_accessLock) {
            if (m_blockPathMap.containsKey(blockId)) {
                throw new IllegalArgumentException("Request to store block that is already stored: "
                                                    + blockId.toString());
            }

            int origPosition = block.position();
            block.position(0);
            Path blockPath = makeBlockPath(blockId);
            try (SeekableByteChannel channel = Files.newByteChannel(blockPath, OPEN_OPTIONS, PERMISSIONS)) {
                channel.write(block);
            }
            finally {
                block.position(origPosition);
            }

            m_blockPathMap.put(blockId, blockPath);
        }
    }
1101567
synchronized void addBlock(Block block) {
    if (!isInitialized()) {
      return;
    }
    
    BlockScanInfo info = blockMap.get(block);
    if ( info != null ) {
      LOG.warn("Adding an already existing block " + block);
      delBlockInfo(info);
    }
    
    info = new BlockScanInfo(block);    
    info.lastScanTime = getNewBlockScanTime();
    
    addBlockInfo(info);
    adjustThrottler();
  }
1239971
public void setChannelPosition(long dataOffset, boolean startWithPartialChunk)
      throws IOException {
    long channelSize = blockDataWriter.getChannelSize();
    if (channelSize < dataOffset) {
      String msg = "Trying to change block file offset of block "
          + block
          + "file "
          + ((blockDataFile.getFile() != null) ? blockDataFile.getFile()
              : "unknown") + " to " + dataOffset
          + " but actual size of file is " + blockDataWriter.getChannelSize();
      throw new IOException(msg);
    }
    if (dataOffset > channelSize) {
      throw new IOException("Set position over the end of the data file.");
    }
    
    if (startWithPartialChunk && channelSize != dataOffset + checksumSize) {
      DFSClient.LOG.warn("Inline Checksum Block " + block + " channel size "
          + channelSize + " but packet needs to start from " + dataOffset);
    }
    
    // This flush should be a no-op since we always flush at the end of
    // writePacket() and hence the buffer should be empty.
    // However we do this just to be extra careful so that the
    // channel.position() doesn't mess up things with respect to the
    // buffered dataOut stream.
    blockDataWriter.flush();
    blockDataWriter.position(dataOffset);
  }
904313
@Override
	protected void readDataBlock(byte[] data, int offset, int len, int blockHandle) throws DataStoreException
    {
    	byte[] dirtyBlock = dirtyBlockTable.get(blockHandle);
    	if (dirtyBlock != null)
    	{
    		// Copy data from memory-cached dirty block
    		System.arraycopy(dirtyBlock, 0, data, offset, len);
    	}
    	else
    	{
    		try
    		{
    			long dataOffset = (long)blockHandle*blockSize;
    			
	    		// Make sure we do not conflict with another async operation
	    		synchronized (dataRandomAccessFile)
				{
			        dataRandomAccessFile.seek(dataOffset);
			        if (dataRandomAccessFile.read(data,offset,len) != len)
			            throw new DataStoreException("Cannot read "+len+" bytes from store file");
				}
    		}
    		catch (DataStoreException e)
    		{
    		    throw e;
    		}
            catch (IOException e)
            {
                throw new DataStoreException("Could not read data block "+blockHandle,e);
            }
    	}
    }
1014800
void assignToBlock(BlockId blk) {
		internalLock.writeLock().lock();
		try {
			flush();
			this.blk = blk;
			contents.read(blk);
			pins = 0;
			lastLsn = LogSeqNum.readFromPage(contents, LAST_LSN_OFFSET);
		} finally {
			internalLock.writeLock().unlock();
		}
	}
307347
private void record(byte[] b, int off, int len) throws IOException {
        if(this.shouldDigest) {
            assert this.digest != null: "Digest is null.";
            this.digest.update(b, off, len);
        }
        tailRecord(b, off, len);
    }