Skip to content

remove B+ Tree implementation #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 26, 2024
Merged

remove B+ Tree implementation #10

merged 4 commits into from
Sep 26, 2024

Conversation

walmir-silva
Copy link
Contributor

remove B+ Tree implementation due to logical errors](595db62)

…romotion, and key-based access

- **Adjusted `BPlusTreeInternalNode::insert()` Method:**
  - Corrected the insertion logic to maintain proper alignment between `keys` and `children` arrays.
  - Ensured that when a child node splits, the promoted key is inserted into the current node's `keys`, and the new child node is correctly placed in the `children` array.

- **Modified `split()` Methods in Nodes:**
  - Updated `BPlusTreeInternalNode::split()` to correctly calculate the middle index and properly split `keys` and `children` arrays.
  - Promoted the appropriate key to the parent node during splits.
  - Ensured that each internal node maintains the B+ Tree properties after splitting.
  - Adjusted `BPlusTreeLeafNode::split()` to handle small orders and maintain the linked list of leaf nodes.

- **Updated Tree Size Management:**
  - Incremented the `size` property in the `BPlusTree` class during insertions to accurately reflect the number of elements.
  - Fixed issues where the `size` was not updated, causing `OutOfRangeException` errors.

- **Revised `set` and `get` Methods:**
  - Changed `set` and `get` methods to operate on keys rather than indices, aligning with the key-based nature of B+ Trees.
  - Updated `set` to traverse the tree and update the value associated with a given key.
  - Modified `get` to retrieve the value based on the key, throwing an exception if the key is not found.

- **Fixed Test Cases:**
  - Adjusted `testVisualTreeStructure` to insert enough keys to cause node splitting, ensuring both internal and leaf nodes are present.
  - Updated `testGetOrder` by correcting the `order` property assignment in the `BPlusTree` class, matching expected values in tests.
  - Renamed and modified `testSetAndGetByIndex` to `testSetAndGetByKey`, reflecting the changes in method functionality.

- **Improved Code Consistency and Documentation:**
  - Removed redundant property declarations and assignments in the `BPlusTree` constructor.
  - Ensured consistent use of the `order` property throughout the class.
  - Added comments and documentation to clarify method purposes and enhance readability.
  - Ensured alignment between method implementations and their intended use cases.

**Summary:**

These corrections address critical issues in the B+ Tree implementation related to node splitting, key promotion, and data access by keys. By refining the logic in node insertion and splitting methods, the tree now correctly maintains its balanced structure and properties, even with small orders. The `size` property accurately tracks the number of elements, preventing out-of-range errors. The `set` and `get` methods now intuitively operate on keys, improving usability. Tests have been updated to reflect these changes, ensuring the reliability and correctness of the implementation.
- Restructured methods in `BPlusTree`, `BPlusTreeInternalNode`, and `BPlusTreeLeafNode` classes to enhance code clarity and organization.
- Removed redundant code and simplified logical conditions for better performance.
- Standardized variable and method naming conventions for consistency throughout the codebase.
- Updated tests in `BPlusTreeTest.php` to reflect the changes made to the classes and ensure functional integrity.
- Prepared the code for future enhancements and extensions in the B+ Tree implementation.
- Added `BPlusTreeSearcherTest.php` (untracked file) for additional testing of search functionality.'
The current implementation of the B+ Tree contains critical logical issues, particularly in tree balancing and search operations. All related classes and tests have been removed to prevent further issues. The algorithm will be rewritten in the future with a more robust approach. Removed files include:
@walmir-silva walmir-silva merged commit 4e6bed8 into main Sep 26, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant