Changeset View
Changeset View
Standalone View
Standalone View
swh/perfecthash/hash.h
- This file was added.
#include <cmph.h> | |||||
#include <cmph_types.h> | |||||
#define SHARD_OFFSET_HEADER 512 | |||||
#define SHARD_KEY_LEN 32 | |||||
typedef struct { | |||||
size_t objects_count; | |||||
size_t objects_position; | |||||
size_t objects_size; | |||||
size_t index_position; | |||||
size_t index_size; | |||||
size_t hash_position; | |||||
} shard_header_t; | |||||
typedef struct { | |||||
char key[SHARD_KEY_LEN]; | |||||
size_t object_offset; | |||||
} shard_index_t; | |||||
typedef struct { | |||||
cmph_io_adapter_t *source; | |||||
cmph_config_t *config; | |||||
cmph_t *hash; | |||||
char *addr; | |||||
char *path; | |||||
shard_index_t *index; | |||||
size_t index_offset; | |||||
size_t file_size; | |||||
shard_header_t header; | |||||
size_t object_offset; | |||||
} shard_t; | |||||
shard_t *shard_init(const char *path); | |||||
int shard_destroy(shard_t *shard); | |||||
int shard_create(shard_t *shard, size_t objects_count); | |||||
int shard_object_write(shard_t *shard, const char *key, const char *object, | |||||
size_t object_size); | |||||
int shard_save(shard_t *shard); | |||||
int shard_load(shard_t *shard); | |||||
int shard_lookup(shard_t *shard, const char *key, char **object, | |||||
size_t *object_size); |