graph.pxd 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. bint trp_contains(self, const BufferTriple* btrp)
  27. # Basic graph operations.
  28. void ip_union(self, Graph other) except *
  29. void ip_subtraction(self, Graph other) except *
  30. void ip_intersection(self, Graph other) except *
  31. void ip_xor(self, Graph other) except *
  32. Graph empty_copy(self)
  33. void _match_ptn_callback(
  34. self, pattern, Graph gr,
  35. lookup_callback_fn_t callback_fn, void* ctx=*
  36. ) except *
  37. cpdef union_(self, Graph other)
  38. cpdef subtraction(self, Graph other)
  39. cpdef intersection(self, Graph other)
  40. cpdef xor(self, Graph other)
  41. cpdef void set(self, tuple trp) except *