Volksdata 1.0b10
RDF library
Loading...
Searching...
No Matches
dataset.h
Go to the documentation of this file.
1#ifndef VOLK_DATASET_H
2#define VOLK_DATASET_H
3
4#include "volksdata/graph.h"
5
6
19
26typedef struct dataset_t {
31
32
43
44
55
57#define VOLK_dataset_new_from_store(...) VOLK_dataset_new_from_store_txn (\
58 NULL, __VA_ARGS__)
59
60
68void
70
71
81inline VOLK_rc
82VOLK_dataset_add (VOLK_Dataset *ds, const VOLK_Graph *gr)
83{
84 if (VOLK_graph_store (gr)->id != ds->store->id) return VOLK_VALUE_ERR;
85
86 return VOLK_term_set_add (
87 ds->gr, VOLK_term_copy (VOLK_graph_uri (gr)), NULL);
88}
89
90
100inline VOLK_rc
101VOLK_dataset_remove (VOLK_Dataset *ds, const VOLK_Graph *gr)
102{ return VOLK_term_set_remove (ds->gr, (VOLK_Term *) VOLK_graph_uri (gr)); }
103
104
111size_t
113
114
121inline bool
122VOLK_dataset_contains (VOLK_Dataset *ds, const VOLK_Graph *gr)
123{
124 if (VOLK_graph_store (gr)->id != ds->store->id) return false;
125
126 return VOLK_term_set_get (
127 ds->gr, VOLK_term_hash (VOLK_graph_uri (gr))) != NULL;
128}
129
131
132#endif // VOLK_DATASET_H
VOLK_Dataset * VOLK_dataset_new(VOLK_Store *store)
Create an empty dataset.
Definition dataset.c:5
bool VOLK_dataset_contains(VOLK_Dataset *ds, const VOLK_Graph *gr)
Check if a graph is in a dataset.
Definition dataset.h:122
VOLK_Dataset * VOLK_dataset_new_from_store_txn(void *txn, VOLK_Store *store)
Create a dataset populated with a whole store.
Definition dataset.c:18
void VOLK_dataset_free(VOLK_Dataset *ds)
Free a dataset handle.
Definition dataset.c:56
size_t VOLK_dataset_size(VOLK_Dataset *ds)
Number of triples in a dataset.
Definition dataset.c:64
VOLK_rc VOLK_dataset_remove(VOLK_Dataset *ds, const VOLK_Graph *gr)
Remove graphs from the dataset.
Definition dataset.h:101
VOLK_rc VOLK_dataset_add(VOLK_Dataset *ds, const VOLK_Graph *gr)
Add graphs to the dataset.
Definition dataset.h:82
#define VOLK_VALUE_ERR
An invalid input value was provided.
Definition core.h:141
int VOLK_rc
Return code.
Definition core.h:91
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:282
const VOLK_Term * VOLK_graph_uri(const VOLK_Graph *gr)
Read-only graph URI.
Definition graph.c:278
RDF Dataset type.
Definition dataset.h:26
VOLK_Store * store
Definition dataset.h:27
VOLK_TermSet * gr
Graphs in the dataset.
Definition dataset.h:29
Store structure.
Definition store.h:59
char * id
Definition store.h:61
RDF term.
Definition term.h:61