Skip to content

Commit

Permalink
regression testing and add more large scale tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkinben committed Oct 21, 2021
1 parent 1e1539b commit c1b5899
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 250 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
.bundle
bin/
test.c
test.rb
tinydb
mydb.db
8 changes: 4 additions & 4 deletions btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const uint32_t LEAF_NODE_VALUE_OFFSET = LEAF_NODE_KEY_OFFSET + LEAF_NODE_KEY_SIZ
const uint32_t LEAF_NODE_CELL_SIZE = LEAF_NODE_KEY_SIZE + LEAF_NODE_VALUE_SIZE;
const uint32_t LEAF_NODE_SPACE_FOR_CELLS = PAGE_SIZE - LEAF_NODE_HEADER_SIZE;
// we can set it with 3 for debugging
// const uint32_t LEAF_NODE_MAX_CELLS = LEAF_NODE_SPACE_FOR_CELLS / LEAF_NODE_CELL_SIZE;
const uint32_t LEAF_NODE_MAX_CELLS = 3;
const uint32_t LEAF_NODE_MAX_CELLS = LEAF_NODE_SPACE_FOR_CELLS / LEAF_NODE_CELL_SIZE;
// const uint32_t LEAF_NODE_MAX_CELLS = 3;

// leaf node 已有 n = LEAF_NODE_MAX_CELLS 个 key
// 插入新 key 值时, 需要分裂
Expand Down Expand Up @@ -96,9 +96,9 @@ const uint32_t INTERNAL_NODE_CHILD_SIZE = sizeof(uint32_t);
const uint32_t INTERNAL_NODE_CELL_SIZE = INTERNAL_NODE_CHILD_SIZE + INTERNAL_NODE_KEY_SIZE;

const uint32_t INTERNAL_NODE_SPACE_FOR_CELLS = PAGE_SIZE - INTERNAL_NODE_HEADER_SIZE;
// const uint32_t INTERNAL_NODE_MAX_CELLS = INTERNAL_NODE_SPACE_FOR_CELLS / INTERNAL_NODE_CELL_SIZE - 1;
const uint32_t INTERNAL_NODE_MAX_CELLS = INTERNAL_NODE_SPACE_FOR_CELLS / INTERNAL_NODE_CELL_SIZE - 1;
// set a small value for debugging/testing
const uint32_t INTERNAL_NODE_MAX_CELLS = 3;
// const uint32_t INTERNAL_NODE_MAX_CELLS = 3;

// 函数声明
uint32_t *leaf_node_num_cells(void *);
Expand Down
4 changes: 2 additions & 2 deletions debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void print_constants()
printf(" - key size: %d\n", LEAF_NODE_KEY_SIZE);
printf(" - row size: %d\n", LEAF_NODE_VALUE_SIZE);
printf(" + spaces for cells: %d\n", LEAF_NODE_SPACE_FOR_CELLS);
printf(" + max cells: %d\n", LEAF_NODE_MAX_CELLS);
// printf(" + max cells: %d\n", LEAF_NODE_MAX_CELLS);

printf("internal node:\n");
printf(" + header size: %d\n", INTERNAL_NODE_HEADER_SIZE);
Expand All @@ -31,7 +31,7 @@ void print_constants()
printf(" - child: %d\n", INTERNAL_NODE_CHILD_SIZE);
printf(" - key: %d\n", INTERNAL_NODE_KEY_SIZE);
printf(" + spaces for cells: %d\n", INTERNAL_NODE_SPACE_FOR_CELLS);
printf(" + max cells: %d\n", INTERNAL_NODE_MAX_CELLS);
// printf(" + max cells: %d\n", INTERNAL_NODE_MAX_CELLS);
}

void indent(int32_t level)
Expand Down
Loading

0 comments on commit c1b5899

Please sign in to comment.