graph.pxd 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. from libc.stdint cimport uint32_t, uint64_t
  2. from cymem.cymem cimport Pool
  3. cimport lakesuperior.cy_include.collections as cc
  4. from lakesuperior.model.base cimport Buffer, TripleKey
  5. from lakesuperior.model.graph.triple cimport BufferTriple
  6. from lakesuperior.model.structures.keyset cimport Keyset
  7. # Lookup function that returns whether a triple contains a match pattern.
  8. # Return True if the triple exists, False otherwise.
  9. ctypedef bint (*lookup_fn_t)(
  10. const BufferTriple *trp, const Buffer *t1, const Buffer *t2)
  11. # Callback for an iterator.
  12. ctypedef void (*lookup_callback_fn_t)(
  13. Graph gr, const BufferTriple* trp, void* ctx
  14. )
  15. ctypedef Buffer SPOBuffer[3]
  16. ctypedef Buffer *BufferPtr
  17. cdef class Graph:
  18. cdef:
  19. cc.HashSet *_terms # Set of unique serialized terms.
  20. cc.HashSet *_triples # Set of unique triples.
  21. # Temp data pool. It gets managed with the object lifecycle via cymem.
  22. Pool pool
  23. Keyset keys
  24. cc.key_compare_ft term_cmp_fn
  25. cc.key_compare_ft trp_cmp_fn
  26. void add(self, TripleKey* spok_p) except *
  27. void remove(self, TripleKey* spok_p) except *
  28. int remove_triple(self, const BufferTriple* trp_buf) except -1
  29. bint trp_contains(self, const BufferTriple* btrp)
  30. # Basic graph operations.
  31. void ip_union(self, Graph other) except *
  32. void ip_subtraction(self, Graph other) except *
  33. void ip_intersection(self, Graph other) except *
  34. void ip_xor(self, Graph other) except *
  35. Graph empty_copy(self)
  36. void _match_ptn_callback(
  37. self, pattern, Graph gr,
  38. lookup_callback_fn_t callback_fn, void* ctx=*
  39. ) except *
  40. cpdef union_(self, Graph other)
  41. cpdef subtraction(self, Graph other)
  42. cpdef intersection(self, Graph other)
  43. cpdef xor(self, Graph other)
  44. cpdef void set(self, tuple trp) except *
  45. cdef class Imr(Graph):
  46. cdef:
  47. readonly str id
  48. Imr empty_copy(self)
  49. cpdef as_rdflib(self)