forked from gaolk/graph-database-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathExprFunctions.hpp
73 lines (64 loc) · 2.23 KB
/
ExprFunctions.hpp
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
/******************************************************************************
* Copyright (c) 2015-2016, TigerGraph Inc.
* All rights reserved.
* Project: TigerGraph Query Language
* udf.hpp: a library of user defined functions used in queries.
*
* - This library should only define functions that will be used in
* TigerGraph Query scripts. Other logics, such as structs and helper
* functions that will not be directly called in the GQuery scripts,
* must be put into "ExprUtil.hpp" under the same directory where
* this file is located.
*
* - Supported type of return value and parameters
* - int
* - float
* - double
* - bool
* - string (don't use std::string)
* - accumulators
*
* - Function names are case sensitive, unique, and can't be conflict with
* built-in math functions and reserve keywords.
*
* - Please don't remove necessary codes in this file
*
* - A backup of this file can be retrieved at
* <tigergraph_root_path>/dev_<backup_time>/gdk/gsql/src/QueryUdf/ExprFunctions.hpp
* after upgrading the system.
*
******************************************************************************/
#ifndef EXPRFUNCTIONS_HPP_
#define EXPRFUNCTIONS_HPP_
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <gle/engine/cpplib/headers.hpp>
/** XXX Warning!! Put self-defined struct in ExprUtil.hpp **
* No user defined struct, helper functions (that will not be directly called
* in the GQuery scripts) etc. are allowed in this file. This file only
* contains user-defined expression function's signature and body.
* Please put user defined structs, helper functions etc. in ExprUtil.hpp
*/
#include "ExprUtil.hpp"
namespace UDIMPL {
typedef std::string string; //XXX DON'T REMOVE
/****** BIULT-IN FUNCTIONS **************/
/****** XXX DON'T REMOVE ****************/
inline int str_to_int (string str) {
return atoi(str.c_str());
}
inline int float_to_int (float val) {
return (int) val;
}
inline string to_string (double val) {
char result[200];
sprintf(result, "%g", val);
return string(result);
}
inline int64_t uid_to_vid(VERTEX val){
return val;
}
}
/****************************************/
#endif /* EXPRFUNCTIONS_HPP_ */