callbacks.pyx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from lakesuperior.model.base cimport Key, TripleKey
  2. cdef inline bint lookup_sk_cmp_fn(
  3. const TripleKey* spok, const Key k1, const Key k2
  4. ):
  5. """ Keyset lookup for S key. """
  6. return spok[0][0] == k1
  7. cdef inline bint lookup_pk_cmp_fn(
  8. const TripleKey* spok, const Key k1, const Key k2
  9. ):
  10. """ Keyset lookup for P key. """
  11. return spok[0][1] == k1
  12. cdef inline bint lookup_ok_cmp_fn(
  13. const TripleKey* spok, const Key k1, const Key k2
  14. ):
  15. """ Keyset lookup for O key. """
  16. return spok[0][2] == k1
  17. cdef inline bint lookup_skpk_cmp_fn(
  18. const TripleKey* spok, const Key k1, const Key k2
  19. ):
  20. """ Keyset lookup for S and P keys. """
  21. return spok[0][0] == k1 and spok[0][1] == k2
  22. cdef inline bint lookup_skok_cmp_fn(
  23. const TripleKey* spok, const Key k1, const Key k2
  24. ):
  25. """ Keyset lookup for S and O keys. """
  26. return spok[0][0] == k1 and spok[0][2] == k2
  27. cdef inline bint lookup_pkok_cmp_fn(
  28. const TripleKey* spok, const Key k1, const Key k2
  29. ):
  30. """ Keyset lookup for P and O keys. """
  31. return spok[0][1] == k1 and spok[0][2] == k2
  32. cdef inline bint lookup_none_cmp_fn(
  33. const TripleKey* spok, const Key k1, const Key k2
  34. ):
  35. """
  36. Dummy callback for queries with all parameters unbound.
  37. This function always returns ``True``
  38. """
  39. return True