view lib/python/cc/lmh/db.pyx @ 264:7886d7de5eed default tip

use cdb library directly, sequestration of cdb handle complete and working, nndb counts two loops now, one with and one without counting successes
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Fri, 31 Jan 2025 13:31:02 +0000
parents 41ed24203e14
children
line wrap: on
line source

# distutils: extra_objects = cdb/libcdb.a
# distutils: include_dirs = cdb

cimport cdb

cdef class CCdb:
  def __cinit__(self):
    self._c_cdb = cdb.cdb_new()

  cdef void findstart(self):
    cdb.cdb_findstart(self._c_cdb)

  cdef int find(self, bytes p):
    return cdb.cdb_find(self._c_cdb, p, len(p))

  cdef char[::1] init(self, int fno):
    cdb.cdb_init(self._c_cdb,fno)
    cdef char[::1] _mview = <char[:cdb.cdb_msize():1]>(cdb.cdb_mmap())
    return _mview

  cdef cdb.uint32 pos(self):
    return cdb.cdb_pos()

  cdef int len(self):
    return cdb.cdb_len()