-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathExtension.h
More file actions
81 lines (56 loc) · 2.19 KB
/
Extension.h
File metadata and controls
81 lines (56 loc) · 2.19 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* SPDX-License-Identifier: Apache-2.0 */
#pragma once
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "substrait/function/Function.h"
namespace io::substrait {
struct TypeVariant {
std::string name;
std::string uri;
};
using TypeVariantPtr = std::shared_ptr<TypeVariant>;
using FunctionImplMap =
std::unordered_map<std::string, std::vector<FunctionImplementationPtr>>;
using TypeVariantMap = std::unordered_map<std::string, TypeVariantPtr>;
class Extension {
public:
/// Deserialize default substrait extension by given basePath
/// @throws exception if file not found
static std::shared_ptr<Extension> load(const std::string& basePath);
/// Deserialize substrait extension by given basePath and extensionFiles.
static std::shared_ptr<Extension> load(
const std::string& basePath,
const std::vector<std::string>& extensionFiles);
/// Deserialize substrait extension by given extensionFiles.
static std::shared_ptr<Extension> load(
const std::vector<std::string>& extensionFiles);
/// Add a scalar function implementation.
void addScalarFunctionImpl(const FunctionImplementationPtr& functionImpl);
/// Add an aggregate function implementation.
void addAggregateFunctionImpl(const FunctionImplementationPtr& functionImpl);
/// Add a window function implementation.
void addWindowFunctionImpl(const FunctionImplementationPtr& functionImpl);
/// Add a type variant.
void addTypeVariant(const TypeVariantPtr& typeVariant);
/// Lookup type variant by given type name.
/// @return matched type variant
TypeVariantPtr lookupType(const std::string& typeName) const;
const FunctionImplMap& scalaFunctionImplMap() const {
return scalarFunctionImplMap_;
}
const FunctionImplMap& windowFunctionImplMap() const {
return windowFunctionImplMap_;
}
const FunctionImplMap& aggregateFunctionImplMap() const {
return aggregateFunctionImplMap_;
}
private:
FunctionImplMap scalarFunctionImplMap_;
FunctionImplMap aggregateFunctionImplMap_;
FunctionImplMap windowFunctionImplMap_;
TypeVariantMap typeVariantMap_;
};
using ExtensionPtr = std::shared_ptr<const Extension>;
} // namespace io::substrait