lmdb_triplestore.pxd 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. cimport lakesuperior.cy_include.collections as cc
  2. cimport lakesuperior.cy_include.cylmdb as lmdb
  3. cimport lakesuperior.cy_include.cytpl as tpl
  4. from lakesuperior.model.base cimport (
  5. KeyIdx, Key, DoubleKey, TripleKey, Buffer
  6. )
  7. from lakesuperior.model.graph.graph cimport SimpleGraph
  8. from lakesuperior.model.structures.keyset cimport Keyset
  9. from lakesuperior.store.base_lmdb_store cimport BaseLmdbStore
  10. cdef enum:
  11. IDX_OP_ADD = 1
  12. IDX_OP_REMOVE = -1
  13. cdef:
  14. unsigned char lookup_rank[3]
  15. unsigned char lookup_ordering[3][3]
  16. unsigned char lookup_ordering_2bound[3][3]
  17. unsigned int INT_KEY_MASK = (
  18. lmdb.MDB_DUPSORT | lmdb.MDB_DUPFIXED | lmdb.MDB_INTEGERKEY
  19. | lmdb.MDB_REVERSEKEY # TODO Check endianness.
  20. )
  21. unsigned int INT_DUP_MASK = (
  22. lmdb.MDB_DUPSORT | lmdb.MDB_DUPFIXED | lmdb.MDB_INTEGERDUP
  23. | lmdb.MDB_REVERSEDUP # TODO Check endianness.
  24. )
  25. cdef class LmdbTriplestore(BaseLmdbStore):
  26. cpdef dict stats(self)
  27. cpdef size_t _len(self, context=*) except -1
  28. cpdef add(self, triple, context=*, quoted=*)
  29. cpdef add_graph(self, graph)
  30. cpdef void _remove(self, tuple triple_pattern, context=*) except *
  31. cpdef void _remove_graph(self, object gr_uri) except *
  32. cpdef tuple all_namespaces(self)
  33. cpdef SimpleGraph graph_lookup(
  34. self, triple_pattern, context=*, uri=*, copy=*
  35. )
  36. cdef:
  37. void _add_graph(self, Buffer* pk_gr) except *
  38. void _index_triple(self, int op, TripleKey spok) except *
  39. Keyset triple_keys(self, tuple triple_pattern, context=*)
  40. void _all_term_keys(self, term_type, cc.HashSet** tkeys) except *
  41. void lookup_term(self, const Key tk, Buffer* data) except *
  42. Keyset _lookup(self, tuple triple_pattern)
  43. Keyset _lookup_1bound(self, unsigned char idx, term)
  44. Keyset _lookup_2bound(
  45. self, unsigned char idx1, term1, unsigned char idx2, term2)
  46. object from_key(self, const Key tk)
  47. tuple from_trp_key(self, const TripleKey spok)
  48. KeyIdx _to_key_idx(self, term)
  49. void all_contexts(self, KeyIdx** ctx, size_t* sz, triple=*) except *
  50. KeyIdx _append(
  51. self, Buffer *value,
  52. unsigned char *dblabel=*, lmdb.MDB_txn *txn=*,
  53. unsigned int flags=*)