@Override
    public FieldValue applyTo(FieldValue oldValue) {
        if (oldValue instanceof TensorFieldValue) {
            Tensor oldTensor = ((TensorFieldValue)oldValue).getTensor().orElseThrow(
                    () -> new IllegalArgumentException("No existing tensor to apply update on"));
            if (tensor.getTensor().isPresent()) {
                DoubleBinaryOperator modifier;
                switch (operation) {
                    case REPLACE:  modifier = (left, right) -> right; break;
                    case ADD:      modifier = (left, right) -> left + right; break;
                    case MULTIPLY: modifier = (left, right) -> left * right; break;
                    default:
                        throw new UnsupportedOperationException("Unknown operation: " + operation);
                }
                if (createNonExistingCells && hasMappedSubtype(oldTensor.type())) {
                    var subspaces = findSubspacesNotInInput(oldTensor, tensor.getTensor().get());
                    if (!subspaces.isEmpty()) {
                        oldTensor = insertSubspaces(oldTensor, subspaces, getDefaultCellValue());
                    }
                }
                Tensor modified = oldTensor.modify(modifier, tensor.getTensor().get().cells());
                return new TensorFieldValue(modified);
            }
        } else {
            throw new IllegalStateException("Cannot use tensor modify update on non-tensor datatype "+oldValue.getClass().getName());
        }
        return oldValue;
    }
Converts the given tensor type to a type that is compatible for being used in this update (has only mapped dimensions).
document/src/main/java/com/yahoo/document/update/TensorModifyUpdate.java