hdb->bnum 设置成实际key条目数的0.4到4倍 这样可以减少btree的搜索 这个搜索是在文件里面的搜索 搜索性能很低下 保证大部分的数据在hash后不会冲突
hdb->apow power of record alignment 默认值是4也就是16(2^4)位对齐
hdb->fpow 根据删除和插入的实际情况去设置 默认是10就是最大free block pool的大小是1024个 如果多于这个数目 就会做一次free block pool整理 这个整理是要耗时间的 所以可以根据删除插入的比例估计下在运行中这个值是多大 而设置
hdb->opts `opts' specifies options by bitwise-or: `HDBTLARGE' specifies that the size of the database
can be larger than 2GB by using 64-bit bucket array, `HDBTDEFLATE' specifies that each record
is compressed with Deflate encoding, `HDBTBZIP' specifies that each record is compressed with
BZIP2 encoding, `HDBTTCBS' specifies that each record is compressed with TCBS encoding.
If successful, the return value is true, else, it is false.
hdb->rcnum record cache number可以说是读缓存中record的条目 默认这个值是0 也就是关闭读缓存的 当然这个值越大读的效率越好 实际值可以根据实际可以使用的内存 来作合理的分配
hdb->xmsiz the size of the extra mapped memory of a hash database object 最小要保证hdb的头信息能够完全被map到内存中 如果太小 tc会做合理的调整 默认是64M可以合理的调节这个hdb->xmsiz和hdb->rcnum
hdb->dfunit unit step number of auto defragmentation默认值是0 也就是从来不做defragmentation
要指出的是每次读取record和record body的时候 都会判断读取边界 如果整块数据刚好映射在hdp->map中那么 读取只是一次memcpy操作 所以这个时候 如果存储数据的条目不是很多 比如100M以内 那么rcnum可以设置为0 xmsiz设置为数据库文件的最大大小或者接近
同样向数据库文件写数据的时候也会判断数据buf的边界 如果在hdb->map内的就做一次memcpy否这调用pwrite写入文件