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;
20pub(crate) mod product;
21mod scalar_add;
22mod scalar_mul;
23pub(crate) mod sum;
24mod vector_add;
25mod vector_dim;
26mod vector_div;
27mod vector_kth_elem;
28mod vector_mul;
29mod vector_norm;
30mod vector_sub;
31mod vector_subvector;
32
33use std::sync::Arc;
34
35use crate::function_registry::FunctionRegistry;
36
37pub(crate) struct VectorFunction;
38
39impl VectorFunction {
40    pub fn register(registry: &FunctionRegistry) {
41        // conversion
42        registry.register(Arc::new(convert::ParseVectorFunction));
43        registry.register(Arc::new(convert::VectorToStringFunction));
44
45        // distance
46        registry.register(Arc::new(distance::CosDistanceFunction));
47        registry.register(Arc::new(distance::DotProductFunction));
48        registry.register(Arc::new(distance::L2SqDistanceFunction));
49
50        // scalar calculation
51        registry.register(Arc::new(scalar_add::ScalarAddFunction));
52        registry.register(Arc::new(scalar_mul::ScalarMulFunction));
53
54        // vector calculation
55        registry.register(Arc::new(vector_add::VectorAddFunction));
56        registry.register(Arc::new(vector_sub::VectorSubFunction));
57        registry.register(Arc::new(vector_mul::VectorMulFunction));
58        registry.register(Arc::new(vector_div::VectorDivFunction));
59        registry.register(Arc::new(vector_norm::VectorNormFunction));
60        registry.register(Arc::new(vector_dim::VectorDimFunction));
61        registry.register(Arc::new(vector_kth_elem::VectorKthElemFunction));
62        registry.register(Arc::new(vector_subvector::VectorSubvectorFunction));
63        registry.register(Arc::new(elem_sum::ElemSumFunction));
64        registry.register(Arc::new(elem_product::ElemProductFunction));
65    }
66}