graph.pxd 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. from lakesuperior.model.structures.keyset cimport Keyset
  7. # Lookup function that returns whether a triple contains a match pattern.
  8. ctypedef bint (*lookup_fn_t)(
  9. const BufferTriple *trp, const Buffer *t1, const Buffer *t2)
  10. ctypedef Buffer SPOBuffer[3]
  11. ctypedef Buffer *BufferPtr
  12. cdef:
  13. int term_cmp_fn(const void* key1, const void* key2)
  14. int trp_cmp_fn(const void* key1, const void* key2)
  15. bint graph_eq_fn(SimpleGraph g1, SimpleGraph g2)
  16. size_t trp_hash_fn(const void* key, int l, uint32_t seed)
  17. size_t hash_ptr_passthrough(const void* key, int l, uint32_t seed)
  18. cdef class SimpleGraph:
  19. cdef:
  20. cc.HashSet *_terms # Set of unique serialized terms.
  21. cc.HashSet *_triples # Set of unique triples.
  22. # Temp data pool. It gets managed with the object lifecycle via cymem.
  23. Pool pool
  24. cc.key_compare_ft term_cmp_fn
  25. cc.key_compare_ft trp_cmp_fn
  26. inline BufferTriple* store_triple(self, const BufferTriple* strp)
  27. inline void add_triple(self, BufferTriple *trp, bint add=*) except *
  28. int remove_triple(self, BufferTriple* trp_buf) except -1
  29. bint trp_contains(self, 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. cpdef union_(self, SimpleGraph other)
  37. cpdef subtraction(self, SimpleGraph other)
  38. cpdef intersection(self, SimpleGraph other)
  39. cpdef xor(self, SimpleGraph other)
  40. cpdef void set(self, tuple trp) except *
  41. cpdef void remove_triples(self, pattern) except *
  42. cdef class Imr(SimpleGraph):
  43. cdef:
  44. readonly str uri
  45. Imr empty_copy(self)
  46. cpdef as_rdflib(self)