code: @Override
    public int write(String path, Pointer buf, @size_t long size, @off_t long offset,
                     FuseFileInfo fi) {
      if (size > Integer.MAX_VALUE) {
        LOG.error("Cannot write more than Integer.MAX_VALUE");
        return ErrorCodes.EIO();
      }
      LOG.trace("write({}, {}, {})", path, size, offset);
      final int sz = (int) size;
      final long fd = fi.fh.get();
      OpenFileEntry oe = mOpenFiles.getFirstByField(ID_INDEX, fd);
      if (oe == null) {
        LOG.error("Cannot find fd for {} in table", path);
        return -ErrorCodes.EBADFD();
      }
  
      if (oe.getOut() == null) {
        LOG.error("{} already exists in Alluxio and cannot be overwritten."
            + " Please delete this file first.", path);
        return -ErrorCodes.EEXIST();
      }
  
      if (offset < oe.getWriteOffset()) {
        // no op
        return sz;
      }
  
      try {
        final byte[] dest = new byte[sz];
        buf.get(0, dest, 0, sz);
        oe.getOut().write(dest);
        oe.setWriteOffset(offset + size);
      } catch (IOException e) {
        LOG.error("IOException while writing to {}.", path, e);
        return -ErrorCodes.EIO();
      }
  
      return sz;
    }
docs: Writes a buffer to an open Alluxio file. Random write is not supported, so the offset argument
  is ignored. Also, due to an issue in OSXFUSE that may write the same content at a offset
  multiple times, the write also checks that the subsequent write of the same offset is ignored.
  
  @param buf The buffer with source data
  @param size How much data to write from the buffer. The maximum accepted size for writes is
  {@link Integer#MAX_VALUE}. Note that current FUSE implementation will anyway call write
  with at most 128K writes
  @param offset The offset where to write in the file (IGNORED)
  @param fi FileInfo data structure kept by FUSE
  @return number of bytes written on success, a negative value on error