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
  5. from lakesuperior.model.graph.triple cimport BufferTriple
  6. # Lookup function that returns whether a triple contains a match pattern.
  7. # Return True if the triple exists, False otherwise.
  8. ctypedef bint (*lookup_fn_t)(
  9. const BufferTriple *trp, const Buffer *t1, const Buffer *t2)
  10. # Callback for an iterator.
  11. ctypedef void (*lookup_callback_fn_t)(
  12. SimpleGraph gr, const BufferTriple* trp, void* ctx
  13. )
  14. ctypedef Buffer SPOBuffer[3]
  15. ctypedef Buffer *BufferPtr
  16. cdef class SimpleGraph:
  17. cdef:
  18. cc.HashSet *_terms # Set of unique serialized terms.
  19. cc.HashSet *_triples # Set of unique triples.
  20. # Temp data pool. It gets managed with the object lifecycle via cymem.
  21. Pool pool
  22. cc.key_compare_ft term_cmp_fn
  23. cc.key_compare_ft trp_cmp_fn
  24. BufferTriple* store_triple(self, const BufferTriple* strp)
  25. void add_triple(
  26. self, const BufferTriple *trp, bint copy=*
  27. ) 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, SimpleGraph other) except *
  32. void ip_subtraction(self, SimpleGraph other) except *
  33. void ip_intersection(self, SimpleGraph other) except *
  34. void ip_xor(self, SimpleGraph other) except *
  35. SimpleGraph empty_copy(self)
  36. void _match_ptn_callback(
  37. self, pattern, SimpleGraph gr,
  38. lookup_callback_fn_t callback_fn, void* ctx=*
  39. ) except *
  40. cpdef union_(self, SimpleGraph other)
  41. cpdef subtraction(self, SimpleGraph other)
  42. cpdef intersection(self, SimpleGraph other)
  43. cpdef xor(self, SimpleGraph other)
  44. cpdef void set(self, tuple trp) except *
  45. cdef class Imr(SimpleGraph):
  46. cdef:
  47. readonly str id
  48. Imr empty_copy(self)
  49. cpdef as_rdflib(self)