graph.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef _LSUP_GRAPH_H
  2. #define _LSUP_GRAPH_H
  3. #include "structures/keyset.h"
  4. #include "structures/index.h"
  5. #include "model/rdf/triple.h"
  6. typedef enum LSUP_store_type {
  7. LSUP_STORE_MEM,
  8. LSUP_STORE_MDB
  9. } LSUP_store_type;
  10. typedef struct LSUP_Graph {
  11. LSUP_store_type store_type;
  12. LSUP_Keyset *keys;
  13. const LSUP_Term *uri;
  14. LSUP_Index *idx;
  15. } LSUP_Graph;
  16. typedef void (*lookup_callback_fn_t)(
  17. LSUP_Graph gr, const LSUP_TripleKey* spok_p, void* ctx
  18. );
  19. int
  20. LSUP_graph_init(
  21. LSUP_Graph *gr, size_t capacity, const LSUP_Term *uri,
  22. LSUP_store_type store_type);
  23. LSUP_Graph *
  24. LSUP_graph_new(
  25. size_t capacity, const LSUP_Term *uri,
  26. LSUP_store_type store_type);
  27. bool
  28. LSUP_graph_contains(const LSUP_Graph *gr, const LSUP_Triple *t);
  29. /**
  30. * Add triples to a graph.
  31. */
  32. int
  33. LSUP_graph_add(LSUP_Graph *gr, LSUP_Triple data[], size_t data_size);
  34. void
  35. LSUP_graph_free(LSUP_Graph *gr);
  36. /** Extern inline functions. */
  37. inline size_t
  38. LSUP_graph_capacity(LSUP_Graph *gr) { return gr->keys->capacity; }
  39. inline size_t
  40. LSUP_graph_size(LSUP_Graph *gr) { return gr->keys->free_i; }
  41. #endif