#ifndef _LSUP_GRAPH_H #define _LSUP_GRAPH_H #include "keyset.h" #include "index.h" #include "triple.h" typedef enum LSUP_store_type { LSUP_STORE_MEM, LSUP_STORE_MDB } LSUP_store_type; typedef struct LSUP_Graph { LSUP_store_type store_type; LSUP_Keyset *keys; LSUP_Term *uri; LSUP_Index *idx; } LSUP_Graph; typedef void (*lookup_callback_fn_t)( LSUP_Graph gr, const LSUP_TripleKey* spok_p, void* ctx ); int LSUP_graph_init( LSUP_Graph *gr, size_t capacity, char *uri_str, LSUP_store_type store_type); LSUP_Graph * LSUP_graph_new(size_t capacity, char *uri_str, LSUP_store_type store_type); bool LSUP_graph_contains(const LSUP_Graph *gr, const LSUP_Triple *t); /** * Add triples to a graph. */ int LSUP_graph_add(LSUP_Graph *gr, LSUP_Triple data[], size_t data_size); /** * Set-theoretical union (gr1 ∪ gr2). * * The resulting Keyset is initialized beforehand and is not compacted. */ int LSUP_graph_join(LSUP_Graph *gr1, LSUP_Graph *gr2, LSUP_Graph *res); /** * Set-theoretical complement (gr1 \ gr2). * * The resulting Keyset is initialized beforehand and is not compacted. */ int LSUP_graph_subtract(LSUP_Graph *gr1, LSUP_Graph *gr2, LSUP_Graph *res); /** * Set-theoretical intersection (gr1 ∩ gr2). * * The resulting Keyset is initialized beforehand and is not compacted. */ int LSUP_graph_intersect(LSUP_Graph *gr1, LSUP_Graph *gr2, LSUP_Graph *res); /** * Disjunctive union (XOR) (gr1 ⊕ gr2). * * The resulting Keyset is initialized beforehand and is not compacted. */ int LSUP_graph_xor(LSUP_Graph *gr1, LSUP_Graph *gr2, LSUP_Graph *res); void LSUP_graph_free(LSUP_Graph *gr); /** Extern inline functions. */ inline size_t LSUP_graph_capacity(LSUP_Graph *gr) { return gr->keys->capacity; } inline size_t LSUP_graph_size(LSUP_Graph *gr) { return gr->keys->free_i; } #endif