graph.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef _LSUP_GRAPH_H
  2. #define _LSUP_GRAPH_H
  3. #include "keyset.h"
  4. #include "index.h"
  5. #include "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. 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, char *uri_str,
  22. LSUP_store_type store_type);
  23. LSUP_Graph *
  24. LSUP_graph_new(size_t capacity, char *uri_str, LSUP_store_type store_type);
  25. bool
  26. LSUP_graph_contains(const LSUP_Graph *gr, const LSUP_Triple *t);
  27. /**
  28. * Add triples to a graph.
  29. */
  30. int
  31. LSUP_graph_add(LSUP_Graph *gr, LSUP_Triple data[], size_t data_size);
  32. void
  33. LSUP_graph_free(LSUP_Graph *gr);
  34. /** Extern inline functions. */
  35. inline size_t
  36. LSUP_graph_capacity(LSUP_Graph *gr) { return gr->keys->capacity; }
  37. inline size_t
  38. LSUP_graph_size(LSUP_Graph *gr) { return gr->keys->free_i; }
  39. #endif