1
0
mirror of https://github.com/fumiama/fumidb.git synced 2026-06-05 16:50:33 +08:00
Files
fumidb/include/types/int16.h
源文雨 bd6ce1d778 int16
2022-05-03 01:29:08 +08:00

35 lines
1.2 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef _TYPE_INT16_H_
#define _TYPE_INT16_H_
#include <stdint.h>
#include "../types.h"
#define INT16_INDEX_SZ ( 8*3 + 256*8 )
#define INT16_BITMAP_SZ ( 65536/8 )
#define INT16_CHAIN_SZ ( (256+1)*8 )
// len(buf) >= INT16_INDEX_SZ+10 + INT16_BITMAP_SZ+8*2 = 10290
// &buf[0] ~ &buf[2081] is index, index = buf+10
// &buf[2082] ~ &buf[6185] is the first page of bitmap, ptr = buf+2090
// &buf[6186] ~ &buf[10289] is the second page of bitmap, ptr = buf+6194
// 返回index = buf+10
void* create_int16_index(int fd, void* buf);
// len(buf) >= INT16_INDEX_SZ+10 + INT16_BITMAP_SZ+8*2 = 10290
// &buf[0] ~ &buf[2081] is index, index = buf+10
// &buf[2082] ~ &buf[6185] is the first page of bitmap, ptr = buf+2090
// &buf[6186] ~ &buf[10289] is the second page of bitmap, ptr = buf+6194
// 返回index = buf+10
void* load_int16_index(int fd, uint64_t ptr, void* buf);
int remove_int16_index(int fd, void* index);
uint64_t count_int16_items(int fd, void* index);
int insert_int16_item(int fd, void* index, key_t k, uint64_t ptr);
uint64_t find_item_by_int16_key(int fd, void* index, key_t k);
uint64_t remove_item_by_int16_key(int fd, void* index, key_t k);
#endif