// Copyright (C) 2019-2020 Zilliz. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software distributed under the License // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // or implied. See the License for the specific language governing permissions and limitations under the License #pragma once #include "Types.h" namespace milvus { class VectorTrait {}; class FloatVector : public VectorTrait { public: using embedded_type = float; static constexpr auto metric_type = DataType::VECTOR_FLOAT; }; class BinaryVector : public VectorTrait { public: using embedded_type = uint8_t; static constexpr auto metric_type = DataType::VECTOR_BINARY; }; template inline constexpr int64_t element_sizeof(int64_t dim) { static_assert(std::is_base_of_v); if constexpr (std::is_same_v) { return dim * sizeof(float); } else { return dim / 8; } } template constexpr bool IsVector = std::is_base_of_v; template constexpr bool IsScalar = std::is_fundamental_v; template struct EmbeddedTypeImpl; template struct EmbeddedTypeImpl>> { using type = T; }; template struct EmbeddedTypeImpl>> { using type = std::conditional_t, float, uint8_t>; }; template using EmbeddedType = typename EmbeddedTypeImpl::type; } // namespace milvus