表 B 树写入器: 负责容量计算、自底向上建树、cell 编码与页号分配。
BTreeWriter
01 Syntax
Microsoft.VisualBasic.Data.IO.ManagedSqlite.Writer.Internal.BTreeWriter
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| GetInlineSize | 1 | 计算 payload 之中内联保存在 cell 内部的字节数(与读取侧 ParseCellInternal 严格对称)。 |
| GetLeafCellSize | 1 | 计算叶 cell 在页内所占的字节数(含可能的 4 字节溢出页指针) |
| BuildTree | 1 | 自底向上把有序记录构建为表 B 树。 |
| AssignPages | 1 | 按 pre-order(父页先于子页)分配页号, 保证父页可以引用已确定的子页号。 |
| BuildLeafCell | 1 | 构建叶 cell 字节: varint(P) + varint(rowid) + 内联 payload [+ 4 字节溢出页指针] |
| BuildInteriorCell | 1 | 构建内部 cell 字节: 4 字节左子页号 + varint(key) |
03 Properties
| Name | Overloads | Summary |
|---|---|---|
| UsableSize | 1 | 可用页大小 U = PageSize - ReservedSpace |
04 Fields
05 Members
GetInlineSize(
Int64)计算 payload 之中内联保存在 cell 内部的字节数(与读取侧 ParseCellInternal 严格对称)。
GetLeafCellSize(LeafEntry)
计算叶 cell 在页内所占的字节数(含可能的 4 字节溢出页指针)
BuildTree(
List(Of LeafEntry))自底向上把有序记录构建为表 B 树。
AssignPages(BTreeNode,
Int64)按 pre-order(父页先于子页)分配页号, 保证父页可以引用已确定的子页号。
BuildLeafCell(LeafEntry,
Func(Of Byte(), Int32, Int64))构建叶 cell 字节: varint(P) + varint(rowid) + 内联 payload [+ 4 字节溢出页指针]
Parameters
| Name | Type | Description |
|---|---|---|
allocateOverflow | LeafEntry | 溢出页分配回调, 参数为(完整记录体, 内联字节数), 返回首个溢出页号。 |
BuildInteriorCell(
Int64, Int64)构建内部 cell 字节: 4 字节左子页号 + varint(key)
UsableSize
可用页大小 U = PageSize - ReservedSpace
_x
table leaf 页在无溢出时可以内联的最大 payload(X = U - 35)
_m
溢出时保证内联的最小 payload(M = ((U-12)*32/255)-23)