Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
unw9527 committed Sep 28, 2024
1 parent cd984b0 commit a9c460c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/include/storage/page/b_plus_tree_internal_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ namespace bustub {

#define B_PLUS_TREE_INTERNAL_PAGE_TYPE BPlusTreeInternalPage<KeyType, ValueType, KeyComparator>
#define INTERNAL_PAGE_HEADER_SIZE 12
#define INTERNAL_PAGE_SIZE ((BUSTUB_PAGE_SIZE - INTERNAL_PAGE_HEADER_SIZE) / ((int)(sizeof(KeyType) + sizeof(ValueType)))) // NOLINT
#define INTERNAL_PAGE_SIZE \
((BUSTUB_PAGE_SIZE - INTERNAL_PAGE_HEADER_SIZE) / ((int)(sizeof(KeyType) + sizeof(ValueType)))) // NOLINT

/**
* Store `n` indexed keys and `n + 1` child pointers (page_id) within internal page.
* Pointer PAGE_ID(i) points to a subtree in which all keys K satisfy:
* K(i) <= K < K(i+1).
* NOTE: Since the number of keys does not equal to number of child pointers,
* the first key always remains invalid. That is to say, any search / lookup
* the first key in key_array_ always remains invalid. That is to say, any search / lookup
* should ignore the first key.
*
* Internal page format (keys are stored in increasing order):
Expand Down Expand Up @@ -105,7 +106,7 @@ class BPlusTreeInternalPage : public BPlusTreePage {
}

private:
// Flexible array members for page data.
// Array members for page data.
KeyType key_array_[INTERNAL_PAGE_SIZE];
ValueType value_array_[INTERNAL_PAGE_SIZE];
// (Fall 2024) Feel free to add more fields and helper functions below if needed
Expand Down
2 changes: 1 addition & 1 deletion src/include/storage/page/b_plus_tree_leaf_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class BPlusTreeLeafPage : public BPlusTreePage {

private:
page_id_t next_page_id_;
// Flexible array members for page data.
// Array members for page data.
KeyType key_array_[LEAF_PAGE_SIZE];
ValueType value_array_[LEAF_PAGE_SIZE];
// (Fall 2024) Feel free to add more fields and helper functions below if needed
Expand Down
4 changes: 3 additions & 1 deletion src/include/storage/page/b_plus_tree_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class BPlusTreePage {

auto GetSize() const -> int;
void SetSize(int size);
void IncreaseSize(int amount);
void ChangeSizeBy(int amount);

auto GetMaxSize() const -> int;
void SetMaxSize(int max_size);
Expand All @@ -59,7 +59,9 @@ class BPlusTreePage {
private:
// Member variables, attributes that both internal and leaf page share
IndexPageType page_type_ __attribute__((__unused__));
// Number of key & value pairs in a page
int size_ __attribute__((__unused__));
// Max number of key & value pairs in a page
int max_size_ __attribute__((__unused__));
};

Expand Down
3 changes: 2 additions & 1 deletion src/storage/page/b_plus_tree_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void BPlusTreePage::SetPageType(IndexPageType page_type) {}
*/
auto BPlusTreePage::GetSize() const -> int { return 0; }
void BPlusTreePage::SetSize(int size) {}
void BPlusTreePage::IncreaseSize(int amount) {}
void BPlusTreePage::ChangeSizeBy(int amount) {}

/*
* Helper methods to get/set max size (capacity) of the page
Expand All @@ -37,6 +37,7 @@ void BPlusTreePage::SetMaxSize(int size) {}
/*
* Helper method to get min page size
* Generally, min page size == max page size / 2
* But whether you will take ceil() or floor() depends on your implementation
*/
auto BPlusTreePage::GetMinSize() const -> int { return 0; }

Expand Down

0 comments on commit a9c460c

Please sign in to comment.