callbacks.pyx 1.4 KB

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