Skip to content

Commit 0ed745f

Browse files
committed
Add back parent pointer
1 parent b7f2ca3 commit 0ed745f

3 files changed

Lines changed: 7 additions & 32 deletions

File tree

_parts/part12.md

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -257,33 +257,6 @@ Executed.
257257
db >
258258
```
259259

260-
Whew! One bug after another, but we're making progress. Now that we've got the sibling pointer, I don't think we actually need a parent pointer. I added it preemptively, but we never actually used it.
261-
262-
```diff
263-
const uint32_t NODE_TYPE_OFFSET = 0;
264-
const uint32_t IS_ROOT_SIZE = sizeof(uint8_t);
265-
const uint32_t IS_ROOT_OFFSET = NODE_TYPE_SIZE;
266-
-const uint32_t PARENT_POINTER_SIZE = sizeof(uint32_t);
267-
-const uint32_t PARENT_POINTER_OFFSET = IS_ROOT_OFFSET + IS_ROOT_SIZE;
268-
const uint8_t COMMON_NODE_HEADER_SIZE =
269-
- NODE_TYPE_SIZE + IS_ROOT_SIZE + PARENT_POINTER_SIZE;
270-
+ NODE_TYPE_SIZE + IS_ROOT_SIZE;
271-
```
272-
273-
```diff
274-
expect(result).to eq([
275-
"db > Constants:",
276-
"ROW_SIZE: 293",
277-
- "COMMON_NODE_HEADER_SIZE: 6",
278-
- "LEAF_NODE_HEADER_SIZE: 14",
279-
+ "COMMON_NODE_HEADER_SIZE: 2",
280-
+ "LEAF_NODE_HEADER_SIZE: 10",
281-
"LEAF_NODE_CELL_SIZE: 297",
282-
- "LEAF_NODE_SPACE_FOR_CELLS: 4082",
283-
+ "LEAF_NODE_SPACE_FOR_CELLS: 4086",
284-
"LEAF_NODE_MAX_CELLS: 13",
285-
"db > ",
286-
])
287-
```
260+
Whew! One bug after another, but we're making progress.
288261

289262
Until next time.

db.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ const uint32_t NODE_TYPE_SIZE = sizeof(uint8_t);
102102
const uint32_t NODE_TYPE_OFFSET = 0;
103103
const uint32_t IS_ROOT_SIZE = sizeof(uint8_t);
104104
const uint32_t IS_ROOT_OFFSET = NODE_TYPE_SIZE;
105+
const uint32_t PARENT_POINTER_SIZE = sizeof(uint32_t);
106+
const uint32_t PARENT_POINTER_OFFSET = IS_ROOT_OFFSET + IS_ROOT_SIZE;
105107
const uint8_t COMMON_NODE_HEADER_SIZE =
106-
NODE_TYPE_SIZE + IS_ROOT_SIZE;
108+
NODE_TYPE_SIZE + IS_ROOT_SIZE + PARENT_POINTER_SIZE;
107109

108110
/*
109111
* Internal Node Header Layout

spec/main_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ def run_script(commands)
198198
expect(result).to eq([
199199
"db > Constants:",
200200
"ROW_SIZE: 293",
201-
"COMMON_NODE_HEADER_SIZE: 2",
202-
"LEAF_NODE_HEADER_SIZE: 10",
201+
"COMMON_NODE_HEADER_SIZE: 6",
202+
"LEAF_NODE_HEADER_SIZE: 14",
203203
"LEAF_NODE_CELL_SIZE: 297",
204-
"LEAF_NODE_SPACE_FOR_CELLS: 4086",
204+
"LEAF_NODE_SPACE_FOR_CELLS: 4082",
205205
"LEAF_NODE_MAX_CELLS: 13",
206206
"db > ",
207207
])

0 commit comments

Comments
 (0)