aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/vespa/document/datatype/tensor_data_type.h
blob: 93f5fc50629e2ffccf10ef1fee21536134bb8134 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "primitivedatatype.h"
#include <vespa/eval/eval/value_type.h>

namespace document {

/*
 * This class describes a tensor type.
 */
class TensorDataType final : public PrimitiveDataType {
    vespalib::eval::ValueType _tensorType;
public:
    TensorDataType(vespalib::eval::ValueType tensorType);
    TensorDataType(const TensorDataType &);  //TODO try to avoid
    TensorDataType & operator=(const TensorDataType &) = delete;
    ~TensorDataType();

    bool isTensor() const noexcept override { return true; }
    virtual const TensorDataType* cast_tensor() const noexcept override { return this; }
    bool equals(const DataType& other) const noexcept override;
    std::unique_ptr<FieldValue> createFieldValue() const override;
    void print(std::ostream&, bool verbose, const std::string& indent) const override;
    static std::unique_ptr<const TensorDataType> fromSpec(const vespalib::string &spec);
    const vespalib::eval::ValueType &getTensorType() const { return _tensorType; }
    bool isAssignableType(const vespalib::eval::ValueType &tensorType) const;
    static bool isAssignableType(const vespalib::eval::ValueType &fieldTensorType, const vespalib::eval::ValueType &tensorType);
};

}