-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
41 lines (30 loc) · 901 Bytes
/
main.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
#include "Swordfish.h"
#include <memory>
using std::shared_ptr;
using std::make_shared;
using oltp::DB;
using oltp::Connection;
using oltp::RawTableBuffer;
using oltp::RawTableBufferGenerator;
using oltp::RawTupleBufferReader;
using oltp::RawTupleBufferWriter;
using oltp::RawTableBufferWriter;
int main()
{
DolphinDBLib::initializeRuntime();
oltp::DBOption option;
shared_ptr<DB> db = make_shared<DB>("test_db", option);
Connection conn(*db);
//call user define function
conn.execute(R"(
def sum5(a, b, c, d, f){
return a + b + c + d + f;
}
)");
ConstantSP result = conn.execute("sum5([1,2,3], [10,10,10], 5, 0, 10)");
std::cout <<result->getString() << std::endl;
//call built-in function
result = conn.execute("sum3(1 2 3)");
std::cout <<result->getString() << std::endl;
DolphinDBLib::finalizeRuntime();
}