Removed cdb code.
This commit is contained in:
parent
e32d398467
commit
7f4a877e93
|
@ -1,9 +0,0 @@
|
|||
bin_PROGRAMS = cmph_cdb
|
||||
lib_LTLIBRARIES = libcmph_cdb.la
|
||||
include_HEADERS = cdb.h
|
||||
libcmph_cdb_la_SOURCES = cdb.h
|
||||
|
||||
libcmph_cdb_la_LDFLAGS = -version-info 0:0:0
|
||||
|
||||
cmph_cdb_SOURCES = main.c
|
||||
cmph_LDADD = libcmph_cdb.la
|
|
@ -1,39 +0,0 @@
|
|||
#include "cmph.h"
|
||||
#include "cmph_cdb.h"
|
||||
|
||||
int cdb_init(struct cdb *cdbp, int fd) { }
|
||||
FILE* file = fdopen(fd, "r");
|
||||
if (file == NULL) return -1;
|
||||
cmph_t *mphf = cmph_load(file);
|
||||
if (mphf == NULL) return -1;
|
||||
cdbp->mphf = mphf;
|
||||
}
|
||||
|
||||
int cdb_free(cdb *cdbp) {
|
||||
cmph_destroy(cdbp->mphf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cdb_find(cdb* cdbp, const void *key, cmph_uint32 keylen) {
|
||||
cmph_uint32 index = cmph_search(cdbp->mphf, key, keylen);
|
||||
char *key_read;
|
||||
cmph_uint32 keylen_read;
|
||||
int c = cmph_disk_array_key(cdbp->disk_array, index, &key_read, &keylen_read);
|
||||
if (c < 0) return -1;
|
||||
if (keylen != keylen_read) return 0;
|
||||
if (strncmp(key, key_read, keylen) != 0) return 0;
|
||||
cmph_uint64 vpos;;
|
||||
cmph_uint32 vlen;
|
||||
int c = cmph_disk_array_value_meta(cdbp->disk_array, index, &vpos, &vlen);
|
||||
cdbp->index = index;
|
||||
cdbp->vpos = vpos;
|
||||
cdbp->vlen = vlen;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cdb_read(cdbp *cdb, char* val, cmph_uint32 vlen, cmph_uint64 vpos) {
|
||||
int c = cmph_disk_array_value(cdb, index, val);
|
||||
if (c < 0) return -1;
|
||||
assert(c == vlen);
|
||||
return vlen;
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
#ifndef __CMPH_CDB_H__
|
||||
#define __CMPH_CDB_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef struct __cdb_t cdb;
|
||||
typedef struct __cdb_make_t cdb_make;
|
||||
|
||||
int cdb_init(cdb *cdbp, int fd);
|
||||
void cdb_free(cdb *cdbp);
|
||||
int cdb_read(const cdb *cdbp, void *buf, cmph_uint32 len, cmph_uint32 pos);
|
||||
int cdb_find(const cdb *cdbp, const void *key, cmph_uint32 keylen);
|
||||
int cdb_read(const cdb *cdbp, void *buf, cmph_uint32 len, cmph_uint32 pos);
|
||||
|
||||
int cdb_make_start(cdb_make *cdbmp, int fd);
|
||||
int cdb_make_add(cdb_make *cdbmp, const void *key, cmph_uint32 keylen, const void *val, cmph_uint32 vallen);
|
||||
int cdb_make_finish(cdb_make *cdbmp);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,31 +0,0 @@
|
|||
#include "cmph_cdb.h"
|
||||
|
||||
int cdb_make_start(cdb_make* cdbmp, int fd) {
|
||||
cdbmp->config = cmph_config_new(key_source);
|
||||
cdbmp->tmpfd = fd;
|
||||
}
|
||||
|
||||
int cdb_make_add(cdb_make* cdbmp, const void* key, cmph_uint32 klen, const void *val, cmph_uint32 vlen) {
|
||||
/* Uses cdb format as documented at http://cr.yp.to/cdb/cdbmake.html. A 32 bits integer takes at most 11 bytes when represented as a string. Adding the plus sign, the comma, the colon and the zero terminator, a total of 25 bytes is required. We use 50. */
|
||||
char preamble[50];
|
||||
cmph_uint64 c = snprintf(preamble, 25, "+%u,%u:", klen, vlen);
|
||||
c += write(cdbmp->fd, preamble);
|
||||
c += write(cdbmp->fd, key);
|
||||
c += write(cdbmp->fd, ",");
|
||||
c += write(cdbmp->fd, value);
|
||||
c += write(cdbmp->fd, "\n");
|
||||
if (c != strlen(preamble) + strlen(key) + strlen(value) + 2) return -1;
|
||||
}
|
||||
|
||||
int cdb_make_finish(cdb_make *cdbmp) {
|
||||
cmph_io_adapter_t *key_source = cmph_io_cdb_adapter(cdbmp->fd, cdbmp->nkeys);
|
||||
if (!key_source) return -1;
|
||||
cmph_config_t *config = cmph_config_new(key_source);
|
||||
if (!config) return -1;
|
||||
cmph_t* mphf = cmph_new(config);
|
||||
if (!mphf) return -1;
|
||||
FILE *f = fdopen(cdbmp->fd);
|
||||
if (!f) return -1;
|
||||
int c = cmph_dump(mphf, f);
|
||||
if (c < 0) return -1;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#ifndef __CMPH_CDB_STRUCTS_H__
|
||||
#define __CMPH_CDB_STRUCTS_H__
|
||||
|
||||
struct __cmph_cdb_t
|
||||
{
|
||||
cmph_t *mph;
|
||||
cmph_uint32 *idx;
|
||||
FILE* data;
|
||||
cmph_uint64 mmap_data_len;
|
||||
void* mmap_data;
|
||||
};
|
||||
|
||||
struct __cmph_cdb_make_t {
|
||||
cmph_config_t* config;
|
||||
|
||||
|
||||
#endif
|
|
@ -5,6 +5,15 @@ LICENSE="LGPL-2"
|
|||
SLOT="0"
|
||||
KEYWORDS="~x86"
|
||||
IUSE=""
|
||||
DEPEND="gcc libtool libc"
|
||||
RDEPEND="libc"
|
||||
|
||||
S=${WORKDIR}/${P}
|
||||
|
||||
src_compile() {
|
||||
econf || die "econf failed"
|
||||
emake || die "emake failed"
|
||||
}
|
||||
|
||||
src_install() {
|
||||
emake DESTDIR=${D} install || die
|
||||
|
|
Loading…
Reference in New Issue