graph.pxd 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. from libc.stdint cimport uint32_t, uint64_t
  2. from cymem.cymem cimport Pool
  3. from lakesuperior.cy_include cimport 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. inline BufferTriple* store_triple(self, const BufferTriple* strp)
  25. inline void add_triple(self, const BufferTriple *trp, bint add=*) except *
  26. int remove_triple(self, const BufferTriple* trp_buf) except -1
  27. bint trp_contains(self, const BufferTriple* btrp)
  28. # Basic graph operations.
  29. void ip_union(self, SimpleGraph other) except *
  30. void ip_subtraction(self, SimpleGraph other) except *
  31. void ip_intersection(self, SimpleGraph other) except *
  32. void ip_xor(self, SimpleGraph other) except *
  33. SimpleGraph empty_copy(self)
  34. void _match_ptn_callback(
  35. self, pattern, SimpleGraph gr,
  36. lookup_callback_fn_t callback_fn, void* ctx=*
  37. ) except *
  38. cpdef union_(self, SimpleGraph other)
  39. cpdef subtraction(self, SimpleGraph other)
  40. cpdef intersection(self, SimpleGraph other)
  41. cpdef xor(self, SimpleGraph other)
  42. cpdef void set(self, tuple trp) except *
  43. cdef class Imr(SimpleGraph):
  44. cdef:
  45. readonly str id
  46. Imr empty_copy(self)
  47. cpdef as_rdflib(self)