Mercurial > hg > cc > cirrus_work
comparison lib/python/cc/lmh/db.pyx @ 264:7886d7de5eed
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 | 015a4b49ec1f |
comparison
equal
deleted
inserted
replaced
263:f457d7eb8cbe | 264:7886d7de5eed |
---|---|
1 # distutils: sources = [cdb_min/cdb.c, cdb_min/error.c, cdb_min/open_read.c, cdb_min/seek_cur.c, cdb_min/open_trunc.c, cdb_min/seek_set.c, cdb_min/byte_copy.c, cdb_min/byte_diff.c, cdb_min/error_str.c, cdb_min/uint32_unpack.c, cdb_min/cdb_hash.c] | 1 # distutils: extra_objects = cdb/libcdb.a |
2 # extra_objects = cdb_min/libcdb.a | 2 # distutils: include_dirs = cdb |
3 # distutils: include_dirs = cdb_min | |
4 | 3 |
5 cimport cdb | 4 cimport cdb |
6 | 5 |
7 cdef class CCdb: | 6 cdef class CCdb: |
8 def __cinit__(self): | 7 def __cinit__(self): |
9 self._c_cdb = cdb.cdb_new() | 8 self._c_cdb = cdb.cdb_new() |
9 | |
10 cdef void findstart(self): | |
11 cdb.cdb_findstart(self._c_cdb) | |
10 | 12 |
11 cdef int find(self, bytes p): | 13 cdef int find(self, bytes p): |
12 return cdb.cdb_find(self._c_cdb, p, len(p)) | 14 return cdb.cdb_find(self._c_cdb, p, len(p)) |
13 | 15 |
14 cdef char[::1] init(self, int fno): | 16 cdef char[::1] init(self, int fno): |
15 cdb.cdb_init(self._c_cdb,fno) | 17 cdb.cdb_init(self._c_cdb,fno) |
16 cdef char[::1] _mview = <char[:cdb.cdb_msize():1]>(cdb.cdb_mmap()) | 18 cdef char[::1] _mview = <char[:cdb.cdb_msize():1]>(cdb.cdb_mmap()) |
17 return _mview | 19 return _mview |
20 | |
21 cdef cdb.uint32 pos(self): | |
22 return cdb.cdb_pos() | |
23 | |
24 cdef int len(self): | |
25 return cdb.cdb_len() |