@Override
    public FieldValue applyTo(FieldValue oldValue) {
        if ( ! (oldValue instanceof TensorFieldValue)) {
            throw new IllegalStateException("Cannot use tensor add update on non-tensor datatype " + oldValue.getClass().getName());
        }
        if ( ! ((TensorFieldValue) oldValue).getTensor().isPresent()) {
            throw new IllegalArgumentException("No existing tensor to apply update to");
        }
        if ( ! tensor.getTensor().isPresent()) {
            return oldValue;
        }

        Tensor old = ((TensorFieldValue) oldValue).getTensor().get();
        Tensor update = tensor.getTensor().get();
        Tensor result = old.merge(update, (left, right) -> right);  // note this might be slow for large mixed tensor updates
        return new TensorFieldValue(result);
    }
An update used to add cells to a sparse or mixed tensor (has at least one mapped dimension).
document/src/main/java/com/yahoo/document/update/TensorAddUpdate.java