code: public ResourceSpec merge(ResourceSpec other) {
  		ResourceSpec target = new ResourceSpec(
  				Math.max(this.cpuCores, other.cpuCores),
  				this.heapMemoryInMB + other.heapMemoryInMB,
  				this.directMemoryInMB + other.directMemoryInMB,
  				this.nativeMemoryInMB + other.nativeMemoryInMB,
  				this.stateSizeInMB + other.stateSizeInMB);
  		target.extendedResources.putAll(extendedResources);
  		for (Resource resource : other.extendedResources.values()) {
  			target.extendedResources.merge(resource.getName(), resource, (v1, v2) -> v1.merge(v2));
  		}
  		return target;
  	}
docs: Used by system internally to merge the other resources of chained operators
  when generating the job graph or merge the resource consumed by state backend.
  
  @param other Reference to resource to merge in.
  @return The new resource with merged values.