common_function/scalars/
vector.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15mod convert;
16mod distance;
17mod elem_product;
18mod elem_sum;
19pub mod impl_conv;
20mod scalar_add;
21mod scalar_mul;
22mod vector_add;
23mod vector_dim;
24mod vector_div;
25mod vector_kth_elem;
26mod vector_mul;
27mod vector_norm;
28mod vector_sub;
29mod vector_subvector;
30
31use crate::function_registry::FunctionRegistry;
32pub(crate) struct VectorFunction;
33
34impl VectorFunction {
35    pub fn register(registry: &FunctionRegistry) {
36        // conversion
37        registry.register_scalar(convert::ParseVectorFunction);
38        registry.register_scalar(convert::VectorToStringFunction);
39
40        // distance
41        registry.register_scalar(distance::CosDistanceFunction);
42        registry.register_scalar(distance::DotProductFunction);
43        registry.register_scalar(distance::L2SqDistanceFunction);
44
45        // scalar calculation
46        registry.register_scalar(scalar_add::ScalarAddFunction);
47        registry.register_scalar(scalar_mul::ScalarMulFunction);
48
49        // vector calculation
50        registry.register_scalar(vector_add::VectorAddFunction);
51        registry.register_scalar(vector_sub::VectorSubFunction);
52        registry.register_scalar(vector_mul::VectorMulFunction);
53        registry.register_scalar(vector_div::VectorDivFunction);
54        registry.register_scalar(vector_norm::VectorNormFunction);
55        registry.register_scalar(vector_dim::VectorDimFunction);
56        registry.register_scalar(vector_kth_elem::VectorKthElemFunction);
57        registry.register_scalar(vector_subvector::VectorSubvectorFunction);
58        registry.register_scalar(elem_sum::ElemSumFunction);
59        registry.register_scalar(elem_product::ElemProductFunction);
60    }
61}