summaryrefslogtreecommitdiff
path: root/src/runtime/c/sg/sg.h
blob: 8e543a97c1bb497cf6d2454631a970b3dee4c7d2 (plain)
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
#ifndef SG_SG_H_
#define SG_SG_H_

typedef long long int SgId;

#include <gu/exn.h>
#include <pgf/pgf.h>

typedef struct SgSG SgSG;

SgSG*
sg_open(const char *filename, GuExn* err);

void
sg_close(SgSG *sg, GuExn* err);

void
sg_begin_trans(SgSG* sg, GuExn* err);

void
sg_commit(SgSG* sg, GuExn* err);

void
sg_rollback(SgSG* sg, GuExn* err);


SgId
sg_insert_expr(SgSG *sg, PgfExpr expr, int wrFlag, GuExn* err);

PgfExpr
sg_get_expr(SgSG *sg, SgId key, GuPool* out_pool, GuExn* err);

typedef struct SgQueryExprResult SgQueryExprResult;

SgQueryExprResult*
sg_query_expr(SgSG *sg, PgfExpr expr, GuPool* pool, GuExn* err);

PgfExpr
sg_query_next(SgSG *sg, SgQueryExprResult* ctxt, SgId* pKey, GuPool* pool, GuExn* err);

void
sg_query_close(SgSG* sg, SgQueryExprResult* ctxt, GuExn* err);

void
sg_update_fts_index(SgSG* sg, PgfPGF* pgf, GuExn* err);

GuSeq*
sg_query_linearization(SgSG *sg, GuString tok, GuPool* pool, GuExn* err);


typedef PgfExpr SgTriple[3];

SgId
sg_insert_triple(SgSG *sg, SgTriple triple, GuExn* err);

int
sg_get_triple(SgSG *sg, SgId key, SgTriple triple,
                 GuPool* out_pool, GuExn* err);

typedef struct SgTripleResult SgTripleResult;

SgTripleResult*
sg_query_triple(SgSG *sg, SgTriple triple, GuExn* err);

int
sg_triple_result_fetch(SgTripleResult* tres, SgId* pKey, SgTriple triple,
                       GuPool* out_pool, GuExn* err);

void
sg_triple_result_get_query(SgTripleResult* tres, SgTriple triple);

void
sg_triple_result_close(SgTripleResult* tres, GuExn* err);

typedef struct SgQueryResult SgQueryResult;

SgQueryResult*
sg_query(SgSG *sg, size_t n_triples, SgTriple* triples, GuExn* err);

size_t
sg_query_result_columns(SgQueryResult* qres);

int
sg_query_result_fetch_columns(SgQueryResult* qres, PgfExpr* res,
                              GuPool* out_pool, GuExn* err);

PgfExpr
sg_query_result_fetch_expr(SgQueryResult* qres, PgfExpr expr,
                           GuPool* out_pool, GuExn* err);

void
sg_query_result_close(SgQueryResult* qres, GuExn* err);

#endif