mirror of
https://github.com/fumiama/fumidb.git
synced 2026-06-09 20:50:38 +08:00
finish int32 int64
This commit is contained in:
@@ -4,6 +4,10 @@
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef uint8_t
|
||||
typedef unsigned char uint8_t;
|
||||
#endif
|
||||
|
||||
typedef uint8_t type_t;
|
||||
typedef uint64_t key_t;
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
#include <stdint.h>
|
||||
#include "../types.h"
|
||||
|
||||
#define INT32_BUCKET_SZ (256)
|
||||
#define INT32_INDEX_SZ ((INT32_BUCKET_SZ+1)*(PAGESZ+8))
|
||||
#define INT32_BUCKET_SZ (256ull)
|
||||
#define INT32_BUCKET_MAX_ITEM_SZ (340ull)
|
||||
#define INT32_INDEX_SZ ((INT32_BUCKET_SZ+2)*(PAGESZ+8))
|
||||
#define INT32_DIGEST_FACTOR (11454191981ull)
|
||||
|
||||
// len(buf) >= INT32_INDEX_SZ = (PAGESZ+8)*(256+1) = 4104*257 = 1054728 (1M)
|
||||
// 256个哈希桶, 多出来一个是机动空间, 用于加载溢出桶
|
||||
// len(buf) >= INT32_INDEX_SZ = (PAGESZ+8)*(256+2) = 4104*258
|
||||
// 256个哈希桶, 多出来2个是机动空间, 用于加载溢出桶
|
||||
void* create_int32_index(int fd, void* buf);
|
||||
|
||||
void* load_int32_index(int fd, uint64_t ptr, void* buf);
|
||||
|
||||
28
include/types/int64.h
Normal file
28
include/types/int64.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef _TYPE_INT64_H_
|
||||
#define _TYPE_INT64_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../types.h"
|
||||
|
||||
#define INT64_BUCKET_SZ (1024ull)
|
||||
#define INT64_BUCKET_MAX_ITEM_SZ (255ull)
|
||||
#define INT64_INDEX_SZ ((INT64_BUCKET_SZ+2)*(PAGESZ+8))
|
||||
#define INT64_DIGEST_FACTOR (18446744073709551557ull)
|
||||
|
||||
// len(buf) >= INT64_INDEX_SZ
|
||||
// 1024个哈希桶, 多出来2个是机动空间, 用于加载溢出桶
|
||||
void* create_int64_index(int fd, void* buf);
|
||||
|
||||
void* load_int64_index(int fd, uint64_t ptr, void* buf);
|
||||
|
||||
int remove_int64_index(int fd, void* index);
|
||||
|
||||
uint64_t count_int64_items(int fd, void* index);
|
||||
|
||||
int insert_int64_item(int fd, void* index, key_t k, uint64_t ptr);
|
||||
|
||||
uint64_t find_item_by_int64_key(int fd, void* index, key_t k);
|
||||
|
||||
uint64_t remove_item_by_int64_key(int fd, void* index, key_t k);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user