Header
ZAP叶的头存储在zap_leaf_header结构中。描述如下: lhr_block_type: 始终为ZBT_LEAF(参见表14) lhr_next: 块链表的下一个叶块id lhr_prefix and lhr_prefix_len: hash值的高lhr_prefixlen位等于lhr_prefix的ZAP存储在这个叶(或叶链表)中。Lhr_prefixlen可以等于或者小于zt_shift(小于的情况下表示多个hash桶的冲突链表引用相同的叶)。
lhr_prefixlen can be equal to or less than zt_shift (the number of bits used to
index into the pointer table) in which case multiple pointer table buckets
reference the same leaf. lhr_magic: 叶魔数 0x2AB1EAF (zap-leaf) lhr_nfree: 这个叶中空闲chunk数。 lhr_nentries: 这个叶中存的ZAP条目 lhr_freelist:空闲chunk链表头,zap_leaf_chunk数组下标 Leaf Hash
下面的8KB是zap叶的hash表。Hash表中的条目指向zap_leaf_entry类型的chunk。ZAP属性条目名称的Hash值的lhr_prefix_len后面的12个位 [c1]
用于这个hash表的索引。hash表中的每一个桶包含16位整数,作为zap_leaf_chunk数组的下标。
5.2.4 zap_leaf_chunk
每一个叶包含一个chunk数组,有三种类型的chunk:zap_leaf_entry,zap_leaf_array,zap_leaf_free。每个属性由一些chunk组成,其中有一个zap_leaf_entry以及几个zap_leaf_array。下图展示这些chunk的安排。各种chunk类型的细节在后面描述。
图18 zap叶结构
Zap_leaf_entry:叶hash表指向这个类型的chunk。结构中包含了指向zap_leaf_array的指针,属性的名称和值存放在zap_leaf_array中。 le_type: ZAP_LEAF_ENTRY == 252 le_int_size: Size of integers in bytes for this entry.该条目的整数字节数。 le_next: hash冲突链表中的下一个zap_leaf_chunk。链表的最后条目的le_next为0xffff。 le_name_chunk:包含名称的前21个字符的zap_leaf_array类型的chunk标识。 le_name_length: 属性名称的长度,包括’\0’ le_value_chunk: 包含属性值的前21字节的第一个zap_leaf_array 类型chunk标识。 le_value_length: 属性值的长度(le_int_size) le_cd: 冲突识别(CD) le_hash: 属性名的64位hash值。 zap_leaf_array: zap_leaf_array类型的chunk存储ZAP属性的名称或者值。这些chunk能够组合起来提供一个对长名称和大值的支持。Zap_leaf_array由zap_leaf_entry中的指针指向。 la_type: ZAP_LEAF_ARRAY == 251 la_array: 21字节数组包含名称或者值。整数类型的值始终按大尾格式存储,不论处理器为何种字节序。 la_next: 16位整数的zap_leaf_chunk数组下标,指向该属性的下一个zap_leaf_array类型chunk,链表的最后元素该值为0xffff(CHAIN_END)。 zap_leaf_free:未使用的chunk放在空闲chunk链表中。空闲链表的头放在叶头中。 lf_type: ZAP_LEAF_FREE == 253 lf_next:16位整数,指向下一个空闲chunk。