Volksdata 1.0b12
RDF library and triple store
Loading...
Searching...
No Matches
data_set.h
Go to the documentation of this file.
1#ifndef VOLK_DATA_SET_H
2#define VOLK_DATA_SET_H
3
4#include "volksdata/graph.h"
5
6
19
26typedef struct data_set_t {
31
32
43
44
55
57#define VOLK_data_set_new_from_store(...) VOLK_data_set_new_from_store_txn (\
58 NULL, __VA_ARGS__)
59
60
69
70
78void
80
81
91inline VOLK_rc
92VOLK_data_set_add (VOLK_DataSet *ds, const VOLK_Graph *gr)
93{
94 if (VOLK_graph_store (gr)->id != ds->store->id) return VOLK_VALUE_ERR;
95
96 return VOLK_term_set_add (
97 ds->gr, VOLK_term_copy (VOLK_graph_uri (gr)), NULL);
98}
99
100
110inline VOLK_rc
111VOLK_data_set_remove (VOLK_DataSet *ds, const VOLK_Graph *gr)
112{ return VOLK_term_set_remove (ds->gr, (VOLK_Term *) VOLK_graph_uri (gr)); }
113
114
121size_t
123
124
131inline bool
132VOLK_data_set_contains (VOLK_DataSet *ds, const VOLK_Graph *gr)
133{
134 if (VOLK_graph_store (gr)->id != ds->store->id) return false;
135
136 return VOLK_term_set_get (
137 ds->gr, VOLK_term_hash (VOLK_graph_uri (gr))) != NULL;
138}
139
141
142#endif // VOLK_DATASET_H
VOLK_rc VOLK_data_set_remove(VOLK_DataSet *ds, const VOLK_Graph *gr)
Remove graphs from the data set.
Definition data_set.h:111
size_t VOLK_data_set_size(VOLK_DataSet *ds)
Number of triples in a data set.
Definition data_set.c:85
VOLK_rc VOLK_data_set_add(VOLK_DataSet *ds, const VOLK_Graph *gr)
Add graphs to the data set.
Definition data_set.h:92
VOLK_DataSet * VOLK_data_set_new_copy(VOLK_DataSet *ds)
Duplicate a data set.
Definition data_set.c:56
bool VOLK_data_set_contains(VOLK_DataSet *ds, const VOLK_Graph *gr)
Check if a graph is in a data set.
Definition data_set.h:132
VOLK_DataSet * VOLK_data_set_new_from_store_txn(void *txn, VOLK_Store *store)
Create a data set populated with a whole store.
Definition data_set.c:18
VOLK_DataSet * VOLK_data_set_new(VOLK_Store *store)
Create an empty data set.
Definition data_set.c:5
void VOLK_data_set_free(VOLK_DataSet *ds)
Free a data set handle.
Definition data_set.c:77
#define VOLK_VALUE_ERR
An invalid input value was provided.
Definition core.h:167
int VOLK_rc
Return code.
Definition core.h:117
struct hashmap VOLK_TermSet
a set of unique terms.
Definition term.h:123
VOLK_rc VOLK_term_set_remove(VOLK_TermSet *ts, VOLK_Term *term)
Remove a specific term from a term set.
Definition term.c:617
const VOLK_Term * VOLK_term_set_get(VOLK_TermSet *ts, VOLK_Key key)
Get a term from a term set.
Definition term.c:586
VOLK_Key VOLK_term_hash(const VOLK_Term *term)
Hash a buffer.
Definition term.c:376
VOLK_rc VOLK_term_set_add(VOLK_TermSet *ts, VOLK_Term *term, VOLK_Term **ins)
Add term to a term set.
Definition term.c:561
VOLK_Term * VOLK_term_copy(const VOLK_Term *src)
Copy a term.
Definition term.c:174
VOLK_Store * VOLK_graph_store(const VOLK_Graph *gr)
Underlying graph store handle.
Definition graph.c:285
const VOLK_Term * VOLK_graph_uri(const VOLK_Graph *gr)
Read-only graph URI.
Definition graph.c:281
RDF Dataset type.
Definition data_set.h:26
VOLK_TermSet * gr
Graphs in the data set.
Definition data_set.h:29
VOLK_Store * store
Definition data_set.h:27
Store structure.
Definition store.h:59
char * id
Definition store.h:61
RDF term.
Definition term.h:61