lgraph_result
Result interface for plugins and built-in procedures. The result of a plugin should be provided in this format in order for the Cypher engine and the graph visualizer to understand.
-
namespace lgraph
-
namespace cypher
-
namespace lgraph_api
-
class Record
- #include <lgraph_result.h>
You only initialize the class by Result instance. Record provide some insert method to insert data to the record. eg. Insert, InsertVertexByID, InsertEdgeByID.
Public Functions
-
void Insert(const std::string &fname, const FieldData &fv)
insert a value to result table. You can insert a value by insert function, and value type must be same as you defined earlier.
- 参数
fname – Field name you defined earlier.
fv – Field value.
-
void Insert(const std::string &fname, const int64_t vid, lgraph_api::Transaction *txn)
insert a value to result table. You can insert a value by insert function, and value type must be same as you defined earlier. You can get properties and label from the interface, this is different from InsertVertexByID.
- 参数
fname – title name you defined earlier.
vid – VertextId
txn – Transaction
-
void Insert(const std::string &fname, EdgeUid &euid, lgraph_api::Transaction *txn)
insert a value to result table. You can insert a value by insert function, and value type must be same as you defined earlier. You can get properties and label from the interface, this is different from InsertEdgeByID.
- 参数
fname – title name you defined earlier.
euid – EdgeUid
txn – Transaction
-
void InsertVertexByID(const std::string &fname, int64_t vid)
insert a value to result table. You can insert a value by insert function, and value type must be same as you defined earlier.
- 参数
fname – Field name you defined earlier.
vid – VertextId.
-
void InsertEdgeByID(const std::string &fname, const EdgeUid &uid)
insert a value to result table. You can insert a value by insert function, and value type must be same as you defined earlier.
- 参数
fname – title name you defined earlier.
uid – EdgeUid.
-
void Insert(const std::string &fname, const lgraph_api::VertexIterator &vit)
insert a value to result table. You can insert a value by insert function, and value type must be same as you defined earlier.
- 参数
fname – one of title name you defined earlier.
vit – VertexIterator.
-
void Insert(const std::string &fname, const lgraph_api::InEdgeIterator &ieit)
insert a value to result table. You can insert a value by insert function, and value type must be same as you defined earlier.
- 参数
fname – one of title name you defined earlier.
ieit – InEdgeIterator.
-
void Insert(const std::string &fname, const lgraph_api::OutEdgeIterator &oeit)
insert a value to result table. You can insert a value by insert function, and value type must be same as you defined earlier.
- 参数
fname – one of title name you defined earlier.
oeit – OutEdgeIterator.
-
void Insert(const std::string &fname, const std::vector<FieldData> &list)
Insert a value to result table. You can insert a value by insert function, and value type must be same as you defined earlier.
- 参数
fname – one of title name you defined earlier.
list – LIST OF FieldData.
-
void Insert(const std::string &fname, const std::map<std::string, FieldData> &map)
insert a value to result table. You can insert a value by insert function, and value type must be same as you defined earlier.
- 参数
fname – one of title name you defined earlier.
map – MAP OF <string, FieldData>
-
void Insert(const std::string &fname, const traversal::Path &path, lgraph_api::Transaction *txn)
insert value into result table. You can insert a value by the function, and value must be same as you defined earlier.
- 参数
fname – one of title name you defined earlier.
path – Path of traverse api.
txn – Trasaction
-
inline int64_t Size() const
Get the size of record. If record is empty, return 0, max size is not beyond the length of your defined param list
- 返回
Size of record.
-
inline bool HasKey(const std::string &key)
Check a key is exist or not. The key is the one of titile your defined earlier.
- 参数
key – The key.
- 返回
True if exsit, otherwise fasle.
Private Functions
-
explicit Record(const std::vector<std::pair<std::string, LGraphType>>&)
Private Members
-
std::unordered_map<std::string, std::shared_ptr<ResultElement>> record
-
std::unordered_map<std::string, LGraphType> header
-
int64_t length_
Friends
- friend class Result
-
void Insert(const std::string &fname, const FieldData &fv)
-
class Result
- #include <lgraph_result.h>
Result table, result instance provide [MutableRecord], [ResetHeader], [Dump] and [Load] method. Table also provide some method to view content of table. For example, [Header] and [Recordview].
It’s worth noting that you are best to define your header before using result table. eg. auto result = Result({title, LGraphType}…) If you do not define header and initialize by Result(), you will get a empty table without header, you just use the table after using [ResetHeader] method to set your header.
Public Functions
-
Result()
-
Result(const std::initializer_list<std::pair<std::string, LGraphType>>&)
-
explicit Result(const std::vector<std::pair<std::string, LGraphType>>&)
-
LGraphType GetType(std::string title)
Get type of title.
- 参数
title – One of titles in table.
- 返回
LGraphType.
-
void ResetHeader(const std::vector<std::pair<std::string, LGraphType>> &header)
Reset your header, the operation will clear the original data and header, please use the function carefully.
- 参数
header – List of <title, LGraphType>
-
void ResetHeader(const std::initializer_list<std::pair<std::string, LGraphType>> &header)
Reset your header, the operation will clear the original data and header, please use the function carefully.
- 参数
header – List of <title, LGraphType>
-
Record *MutableRecord()
Create a new record in the table and return the record. The record is the reference of record in the table, if you want to modify the record, you must assign return value to a reference variable.
- 返回
The reference of record.
-
const std::vector<std::pair<std::string, LGraphType>> &Header()
return header of the table.
- 返回
header.
-
int64_t Size() const
return size of the table.
- 返回
table size.
-
std::string Dump(bool is_standard = true)
Serialize the table.
- 参数
is_standard – (Optional) If true, the result will serialize to a standard result, the standard result can be Visualized in web. If false, result will serialize a json object — SDK result.
- 返回
Serialize result.
-
void Load(const std::string &json)
Deserialize data to result table. This will be clear original data and header, please use this function carefully.
- 参数
json – Json string to be deserialized.
Private Functions
Friends
- friend class lgraph::StateMachine
- friend class cypher::PluginAdapter
-
Result()
-
class Record