-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstryke_binding.cpp
123 lines (92 loc) · 4.94 KB
/
stryke_binding.cpp
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "stryke/core.hpp"
#include "stryke/dispatch.hpp"
#include "stryke/sequential.hpp"
#include "stryke/options.hpp"
#include "stryke/reader.hpp"
#include "stryke/thread.hpp"
#include "stryke_binding.hpp"
#include <Python.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <array>
#include <iostream>
#include <string>
namespace py = pybind11;
void init_custom(py::module &);
PYBIND11_MODULE(stryke, m) {
using namespace stryke; // for convenience
py::class_<WriterOptions>(m, "WriterOptions")
.def(py::init<>())
.def("disable_lock_file", &WriterOptions::disable_lock_file, py::arg("disable_lock_file") = true)
.def("enable_suffix_timestamp", &WriterOptions::enable_suffix_timestamp, py::arg("enable_suffix_timestamp") = true)
.def("set_batch_size", &WriterOptions::set_batch_size)
.def("set_batch_max", &WriterOptions::set_batch_max)
.def("set_stripe_size", &WriterOptions::set_stripe_size)
.def("set_cron", &WriterOptions::set_cron);
// ==============================================================
// Binding for WriterTemplate
// ==============================================================
auto m_simple = m.def_submodule("simple");
// Example
declare_writer_impl<TimestampNumber, Long, Long, Long>(m_simple, "ForTest");
// Basic type
declare_writer_impl<Short>(m_simple, "Short1");
declare_writer_impl<Int>(m_simple, "Int1");
declare_writer_impl<Long>(m_simple, "Long1");
declare_writer_impl<Double>(m_simple, "Double1");
declare_writer_impl<Boolean>(m_simple, "Boolean1");
declare_writer_impl<Date>(m_simple, "Date1");
declare_writer_impl<DateNumber>(m_simple, "DateN1");
declare_writer_impl<Timestamp>(m_simple, "Timestamp1");
declare_writer_impl<TimestampNumber>(m_simple, "TimestampN1");
// Reader
declare_reader<Short>(m_simple, "Short1");
declare_reader<Int>(m_simple, "Int1");
declare_reader<Long>(m_simple, "Long1");
declare_reader<Double>(m_simple, "Double1");
declare_reader<Boolean>(m_simple, "Boolean1");
declare_reader<Date>(m_simple, "Date1");
declare_reader<DateNumber>(m_simple, "DateN1");
declare_reader<Timestamp>(m_simple, "Timestamp1");
declare_reader<TimestampNumber>(m_simple, "TimestampN1");
// ==============================================================
// Binding for WriterDispatch
// ==============================================================
auto m_dispatch = m.def_submodule("dispatch");
// Example
declare_writer_dispatch<FolderEncode<TimestampNumber, Long>, Long, Long>(m_dispatch, "ForTestWithFolder");
declare_writer_dispatch<FolderEncode<>, TimestampNumber, Long, Long, Long>(m_dispatch, "ForTestWithoutFolder");
// ==============================================================
// Binding for WriterSequential
// ==============================================================
auto m_sequential = m.def_submodule("sequential");
// Example
declare_writer_sequential<TimestampNumber, FolderEncode<Long>, Long, Long>(m_sequential, "ForTestWithFolder");
declare_writer_sequential<TimestampNumber, FolderEncode<>, Long, Long>(m_sequential, "ForTestWithoutFolder");
// ==============================================================
// Binding for WriterThread
// ==============================================================
auto m_thread = m.def_submodule("thread");
// Example
declare_writer_thread<OrcWriterSequentialDuplicate, TimestampNumber, FolderEncode<Long>, Long, Long>(m_thread, "ForTestWithFolder");
declare_writer_thread<OrcWriterSequentialDuplicate, TimestampNumber, FolderEncode<>, Long, Long, Long>(m_thread, "ForTestWithoutFolder");
// ==============================================================
// Binding for Miscellaneous
// ==============================================================
// ==============================================================
// Binding for Miscellaneous WriterThreadDispatchDuplicate
// ==============================================================
auto m_dispatch_miscellaneous = m_dispatch.def_submodule("miscellaneous");
// Example
declare_writer_dispatch_duplicate<TimestampNumber, FolderEncode<Long>, Long, Long>(m_dispatch_miscellaneous, "ForTestWithFolder");
declare_writer_dispatch_duplicate<TimestampNumber, FolderEncode<>, Long, Long>(m_dispatch_miscellaneous, "ForTestWithoutFolder");
// ==============================================================
// Binding for Miscellaneous WriterThreadSequentialDuplicate
// ==============================================================
auto m_sequential_miscellaneous = m_sequential.def_submodule("miscellaneous");
// Example
declare_writer_sequential_duplicate<TimestampNumber, FolderEncode<Long>, Long, Long>(m_sequential_miscellaneous, "ForTestWithFolder");
declare_writer_sequential_duplicate<TimestampNumber, FolderEncode<>, Long, Long>(m_sequential_miscellaneous, "ForTestWithoutFolder");
auto m_custom = m.def_submodule("custom");
init_custom(m_custom);
}