Sets the offset in the block to which the the next write will write data
to.
967074
public void setChannelPosition(long dataOffset, long ckOffset)
      throws IOException {
    long channelSize = blockDataWriter.getChannelSize();
    if (channelSize < dataOffset) {
      String fileName;
      if (datanode.data instanceof FSDataset) {
        FSDataset fsDataset = (FSDataset) datanode.data;
        fileName = fsDataset.getDatanodeBlockInfo(namespaceId, block)
            .getBlockDataFile().getTmpFile(namespaceId, block).toString();
      } else {
        fileName = "unknown";
      }
      String msg = "Trying to change block file offset of block " + block
          + " file " + fileName + " 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 (dataOffset % bytesPerChecksum != 0 && channelSize != dataOffset) {
      DFSClient.LOG.warn("Non-inline Checksum Block " + block
          + " channel size " + channelSize + " but data starts from "
          + dataOffset);
    }
    blockDataWriter.position(dataOffset);

    setChecksumOffset(ckOffset);
  }
1115610
private function write_block()
    {
        if ($this->block_count > 0) {
            $this->encoder->write_long($this->block_count);
            $to_write = strval($this->buffer);
            $this->encoder->write_long(strlen($to_write));

            if (DataIO::is_valid_codec(
                $this->metadata[DataIO::METADATA_CODEC_ATTR])
            )
                $this->write($to_write);
            else
                throw new DataIOException(
                    sprintf('codec %s is not supported',
                        $this->metadata[DataIO::METADATA_CODEC_ATTR]));

            $this->write($this->sync_marker);
            $this->buffer->truncate();
            $this->block_count = 0;
        }
    }
426309
public void write(int b) throws IOException {
    if (chunk.length - 1 == pos) {
      flush();
    }
    chunk[(int) pos++] = (byte) b;
  }
340472
@Override
	protected void writeFirstBlock() throws DataStoreException
    {
    	try
    	{
	    	allocationTableRandomAccessFile.seek(AT_HEADER_FIRSTBLOCK_OFFSET);
	        allocationTableRandomAccessFile.writeInt(firstBlock);
    	}
    	catch (IOException e)
    	{
    		throw new DataStoreException("Cannot write to allocation table file : "+allocationTableFile.getAbsolutePath(),e);
    	}
    }
364818
def write(self, offset, value):
		
		if(not self.mode & 0b10):
			raise ReadOnlyError("Device is Read-Only")
		if(offset >= self.size):
			raise AddressError("Offset({}) not in address space({})".format(offset, self.size))
		self.repr_[offset].setvalue(value)
676579
def set_block(self, x,y,z, id, data=0):
        """"""
        offset = y + z*128 + x*128*16
        self.blocksList[offset] = id
        if (offset % 2 == 1):
            # offset is odd
            index = (offset-1)//2
            b = self.dataList[index]
            self.dataList[index] = (b & 240) + (data & 15) # modify lower bits, leaving higher bits in place
        else:
            # offset is even
            index = offset//2
            b = self.dataList[index]
            self.dataList[index] = (b & 15) + (data << 4 & 240)
393667
public static void writeBytes(byte b[], int offset, byte[] value) {
    System.arraycopy(value, 0, b, offset, value.length);
  }
747555
private void copyToOffset(int offset) {
    final int minCapacity = 2 * (offset + nbrruns);
    if (valueslength.length < minCapacity) {
      // expensive case where we need to reallocate
      int newCapacity = valueslength.length;
      while (newCapacity < minCapacity) {
        newCapacity = (newCapacity == 0) ? DEFAULT_INIT_SIZE
            : newCapacity < 64 ? newCapacity * 2
                : newCapacity < 1024 ? newCapacity * 3 / 2 : newCapacity * 5 / 4;
      }
      short[] newvalueslength = new short[newCapacity];
      copyValuesLength(this.valueslength, 0, newvalueslength, offset, nbrruns);
      this.valueslength = newvalueslength;
    } else {
      // efficient case where we just copy
      copyValuesLength(this.valueslength, 0, this.valueslength, offset, nbrruns);
    }
  }
1127650
public synchronized void write(int blockNumber, int blockOffset, byte[] buffer) 
			throws IOException {
		write(blockNumber, blockOffset, buffer, 0, buffer.length);
	}
322624
@Override
	protected void writeDataBlock(byte[] data, int offset, int len, int blockHandle) throws DataStoreException
    {
    	byte[] blockData = new byte[blockSize];
    	System.arraycopy(data, offset, blockData, 0, len);
    	
    	dirtyBlockTable.markDirty(blockHandle, blockData);    	
    	journal.writeDataBlock(blockHandle, (long)blockHandle*blockSize, blockData);
    }
44451
public boolean write(byte []buffer, int offset, int length)
  {
    if (length == 0) {
      return true; // throw new IllegalStateException();
    }
    
    int count = length / BLOCK_SIZE + 1;
    
    if (_tailAddress <= _index + length + PAD + 2 * count) {
      return false;
    }

    _crc.update(buffer, offset, length);
    
    byte []headerBuffer = _headerBuffer;
    
    while (length > 0) {
      int sublen = Math.min(length, BLOCK_SIZE);
      
      BitsUtil.writeInt16(headerBuffer, 0, sublen);
      
      writeImpl(headerBuffer, 0, 2);
      writeImpl(buffer, offset, sublen);
      
      length -= sublen;
      offset += sublen;
    }
    
    return true;
  }
124145
public void seek(int offset) throws IOException {
    if (!(offset >= bufferOffset && offset < bufferOffset + maxBufferSize)) {
      writeBuffer();
      newBuffer(offset);
      aFile.seek(offset);
    }
    position = offset;
  }
589900
def write(self, chunk, offset):
        
        return lib.zfile_write(self._as_parameter_, chunk, offset)
1328289
void moveBlock()
    {
        int offset = _bufferOffset + _pos - _keepSizeBefore;
        // we need one additional byte, since movePos moves on 1 byte.
        if (offset > 0)
        {
            offset--;
        }

        int numBytes = _bufferOffset + _streamPos - offset;

        // check negative offset ????
        System.arraycopy(_bufferBase, offset, _bufferBase, 0, numBytes);
        _bufferOffset -= offset;
    }
994863
public void write(DataOutput out) throws IOException {
    out.writeLong(blockId);
    out.writeLong(blockGenStamp);
    super.write(out);
  }
657513
public function offsetSet($offset, $value): void
    {
        self::validateOffset($offset);
        $this->data[$offset] = $value;
    }
333100
private void writeByte(int b)
    {
        int offset = myOffset;
        if (--offset < 0) {
            offset = growBuffer(offset);
        }
        // Using narrowing primitive conversion from int to byte
        myBuffer[offset] = (byte) b;
        myOffset = offset;
    }