lgraph_types

namespace lgraph_api

Typedefs

typedef std::vector<std::pair<std::string, std::string>> EdgeConstraints

Edge constraints type define.

Enums

enum class AccessLevel

Access level a user or role has on a graph. NONE: no permission. READ: read-only, no write access. WRITE: can read and write vertex and edge, but cannot change meta data such as schema or access. FULL: full access, can modify schema, grant access to other users, or even delete this graph.

Values:

enumerator NONE
enumerator READ
enumerator WRITE
enumerator FULL
enum class FieldAccessLevel

Values:

enumerator NONE
enumerator READ
enumerator WRITE
enum FieldType

Field and value types.

Values:

enumerator NUL
enumerator BOOL
enumerator INT8
enumerator INT16
enumerator INT32
enumerator INT64
enumerator FLOAT
enumerator DOUBLE
enumerator DATE
enumerator DATETIME
enumerator STRING
enumerator BLOB
enum class LGraphType : uint16_t

a type of value used in result entry and parameter in procedure or plugin signature

Param INTEGER

Param FLOAT

Param DOUBLE

Param BOOLEAN

Param STRING

Param MAP

<string, FieldData>

Param NODE

VertexIterator, VertexId

Param RELATIONSHIP

InEdgeIterator || OutEdgeIterator, EdgeUid

Param PATH

lgraph_api::Path

Param LIST

<string, FieldData>

Param ANY

like Object in Java, its procedure author’s responsibility to check the underlying concrete type whether valid in runtime.

Values:

enumerator NUL
enumerator INTEGER
enumerator FLOAT
enumerator DOUBLE
enumerator BOOLEAN
enumerator STRING
enumerator NODE
enumerator RELATIONSHIP
enumerator PATH
enumerator LIST
enumerator MAP
enumerator ANY
enum PluginCodeType

Type of code given when loading a new plugin.

Values:

enumerator PY
enumerator SO
enumerator CPP
enumerator ZIP

Functions

static inline std::string to_string(const AccessLevel &v)
static inline std::string to_string(const FieldAccessLevel &v)
inline const std::string to_string(FieldType v)

Get the name of the given FieldType.

Throws

std::runtime_error – when an unrecognizable FieldType is given.

Parameters

v – A FieldType.

Returns

Name of the given FieldType.

inline auto LGraphTypeIsField(LGraphType type) -> bool
inline auto LGraphTypeIsGraphElement(LGraphType type) -> bool
inline auto LGraphTypeIsCollection(LGraphType type) -> bool
inline auto LGraphTypeIsAny(LGraphType type) -> bool
inline const std::string to_string(LGraphType type)
inline std::string PluginCodeTypeStr(PluginCodeType code_type)

Get the name of plugin code types.

struct EdgeOptions : public LabelOptions
#include <lgraph_types.h>

Edge label options, contain fields only edge have.

Public Functions

EdgeOptions() = default
inline explicit EdgeOptions(const EdgeConstraints &edge_constraints)
inline virtual std::string to_string() const
inline virtual void clear()

Public Members

EdgeConstraints edge_constraints
std::string temporal_field
struct EdgeUid
#include <lgraph_types.h>

Public Functions

inline EdgeUid()
inline EdgeUid(int64_t s, int64_t d, uint16_t l, int64_t t, int64_t e)
inline void Reverse()

Reverses side of this edge.

inline bool operator==(const EdgeUid &rhs) const
inline std::string ToString() const

Get string representation of this object.

Public Members

int64_t src

source vertex id

int64_t dst

destination vertex id

uint16_t lid

label id

int64_t tid

timestamp

int64_t eid

additional edge id to distinguish edges with the same tid

Public Static Functions

static inline EdgeUid AnyEdge()
struct InEdgeSortOrder
#include <lgraph_types.h>

Comparator for EdgeUid of in-coming edges.

Public Functions

inline bool operator()(const EdgeUid &lhs, const EdgeUid &rhs) const
struct OutEdgeSortOrder
#include <lgraph_types.h>

Comparator for EdgeUid of out-going edges.

Public Functions

inline bool operator()(const EdgeUid &lhs, const EdgeUid &rhs) const
struct FieldData
#include <lgraph_types.h>

A class that represents variant type.

Public Functions

inline FieldData()
inline explicit FieldData(bool b)
inline explicit FieldData(int8_t integer)
inline explicit FieldData(int16_t integer)
inline explicit FieldData(int32_t integer)
inline explicit FieldData(int64_t integer)
inline explicit FieldData(float real)
inline explicit FieldData(double real)
inline explicit FieldData(const Date &d)
inline explicit FieldData(const DateTime &d)
inline explicit FieldData(const std::string &buf)
inline explicit FieldData(std::string &&str)
inline explicit FieldData(const char *buf)
inline explicit FieldData(const char *buf, size_t s)
inline ~FieldData()
inline FieldData(const FieldData &rhs)
inline FieldData(FieldData &&rhs)
inline FieldData &operator=(const FieldData &rhs)
inline FieldData &operator=(FieldData &&rhs)
inline int64_t integer() const

Access the FieldData as int64. Valid only when the FieldData is of INT8, INT16, INT32, or INT64 types.

Throws

std::bad_cast – Thrown when the FieldData is not of int types.

Returns

An int64_t.

inline double real() const

Access the FieldData as a double. The FieldData must be of FLOAT or DOUBLE types.

Throws

std::bad_cast – Thrown if the FieldData is not of FLOAT or DOUBLE types.

Returns

A double.

inline const std::string &string() const

Access the FieldData as std::string. Valid only for STRING and BLOB. BLOB data is returned as-is, since std::string can also hold byte array.

Throws

std::bad_cast – Thrown when a bad cast error condition occurs.

Returns

A reference to a const std::string.

inline bool AsBool() const
inline int8_t AsInt8() const
inline int16_t AsInt16() const
inline int32_t AsInt32() const
inline int64_t AsInt64() const
inline float AsFloat() const
inline double AsDouble() const
inline inline ::lgraph_api::Date AsDate () const
inline inline ::lgraph_api::DateTime AsDateTime () const
inline std::string AsString() const
inline std::string AsBlob() const
inline std::string AsBase64Blob() const
inline std::string ToString(const std::string &null_value = "NUL") const

Get string representation of this FieldData.

inline bool operator==(const FieldData &rhs) const
inline bool operator!=(const FieldData &rhs) const
inline bool operator>(const FieldData &rhs) const
inline bool operator>=(const FieldData &rhs) const
inline bool operator<(const FieldData &rhs) const
inline bool operator<=(const FieldData &rhs) const
inline FieldType GetType() const
inline bool is_null() const
inline bool is_buf() const
inline bool is_empty_buf() const
inline bool IsNull() const

Query if this object is null.

inline bool IsBool() const

Query if this object is bool.

inline bool IsBlob() const

Query if this object is BLOB.

inline bool IsString() const

Query if this object is string.

inline bool IsInt8() const

Query if this object is INT8.

inline bool IsInt16() const

Query if this object is INT16.

inline bool IsInt32() const

Query if this object is INT32.

inline bool IsInt64() const

Query if this object is INT64.

inline bool IsInteger() const

Is this a INT8, INT16, INT32 or INT64?

inline bool IsFloat() const

Query if this object is float.

inline bool IsDouble() const

Query if this object is double.

inline bool IsReal() const

Is this a FLOAT or DOUBLE?

inline bool IsDate() const

Query if this object is date.

inline bool IsDateTime() const

Query if this object is date time.

Public Members

FieldType type
bool boolean
int8_t int8
int16_t int16
int32_t int32
int64_t int64
float sp
double dp
std::string *buf
union lgraph_api::FieldData::[anonymous] data

Public Static Functions

static inline FieldData Bool(bool b)
static inline FieldData Int8(int8_t i)
static inline FieldData Int16(int16_t i)
static inline FieldData Int32(int32_t i)
static inline FieldData Int64(int64_t i)
static inline FieldData Float(float d)
static inline FieldData Double(double d)
static inline FieldData Date(const std::string &str)
static inline FieldData Date(const ::lgraph_api::Date &d)
static inline FieldData DateTime(const std::string &str)
static inline FieldData DateTime(const ::lgraph_api::DateTime &d)
static inline FieldData String(const std::string &str)
static inline FieldData String(std::string &&str)
static inline FieldData String(const char *str)
static inline FieldData String(const char *p, size_t s)
static inline FieldData Blob(const std::string &str)
static inline FieldData Blob(std::string &&str)
static inline FieldData Blob(const std::vector<uint8_t> &str)

Constructs a Blob from vector of uint8_t, treated as byte array.

static inline FieldData BlobFromBase64(const std::string &base64_encoded)

Constructs a BLOB from Base64 encoded string.

Private Static Functions

static inline bool IsBufType(FieldType t)

Query if ‘t’ is BLOB or STRING.

static inline bool IsInteger(FieldType t)

Query if ‘t’ is INT8, 16, 32, or 64.

static inline bool IsReal(FieldType t)

Query if ‘t’ is FLLOAT or DOUBLE.

struct FieldSpec
#include <lgraph_types.h>

Specification for a field.

Public Functions

inline FieldSpec()
inline FieldSpec(const std::string &n, FieldType t, bool nu)

Constructor.

Parameters
  • n – Field name

  • t – Field type

  • nu – True if field is optional

inline FieldSpec(std::string &&n, FieldType t, bool nu)
inline bool operator==(const FieldSpec &rhs) const
inline std::string ToString() const

Get the string representation of the FieldSpec.

Public Members

std::string name

name of the field

FieldType type

type of that field

bool optional

is this field optional?

struct IndexSpec
#include <lgraph_types.h>

An index specifier.

Public Members

std::string label

label name

std::string field

field name

bool unique

is this a unique index?

struct LabelOptions
#include <lgraph_types.h>

Label options, base class, define some common fields and methods.

Subclassed by EdgeOptions, VertexOptions

Public Functions

virtual std::string to_string() const = 0
virtual void clear() = 0
inline virtual ~LabelOptions()

Public Members

bool detach_property = false
struct Parameter
#include <lgraph_types.h>

The parameter of procedure/plugin.

Public Members

std::string name
int index

name of the parameter

LGraphType type

index of the parameter list in which the parameter stay

struct RoleInfo
#include <lgraph_types.h>

Information about the role.

Public Members

std::string desc

description

std::map<std::string, AccessLevel> graph_access

access levels on different graphs

bool disabled = false

is this role disabled?

struct SigSpec
#include <lgraph_types.h>

Public Members

std::vector<Parameter> input_list
std::vector<Parameter> result_list

input parameter list

struct UserInfo
#include <lgraph_types.h>

Information about the user.

Public Members

std::string desc

description of the user

std::set<std::string> roles

roles of this user

bool disabled = false

is this user disabled?

size_t memory_limit

memory limit for this user

struct VertexOptions : public LabelOptions
#include <lgraph_types.h>

Vertex label options, contain fields only vertex have.

Public Functions

VertexOptions() = default
inline explicit VertexOptions(const std::string &primary_field)
inline virtual std::string to_string() const
inline virtual void clear()

Public Members

std::string primary_field