-
Notifications
You must be signed in to change notification settings - Fork 288
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
Development
: Remove atlas dependency on jgrapht and apfloat
#9342
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe changes involve the removal of two dependencies from the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant UnionFind
participant Element
Client->>UnionFind: Initialize with elements
UnionFind->>Element: Set each element as its own parent
Client->>UnionFind: Add Element
UnionFind->>Element: Ensure no duplicates
Client->>UnionFind: Find Element
UnionFind->>Element: Retrieve representative
Client->>UnionFind: Union Elements
UnionFind->>Element: Merge sets
Client->>UnionFind: Check inSameSet
UnionFind->>Element: Verify membership
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Files selected for processing (4)
- build.gradle (0 hunks)
- src/main/java/de/tum/cit/aet/artemis/atlas/service/learningpath/LearningPathNgxService.java (1 hunks)
- src/main/java/de/tum/cit/aet/artemis/atlas/service/util/UnionFind.java (1 hunks)
- src/test/java/de/tum/cit/aet/artemis/UnionFindTest.java (1 hunks)
Files not reviewed due to no reviewable changes (1)
- build.gradle
Additional context used
Path-based instructions (3)
src/main/java/de/tum/cit/aet/artemis/atlas/service/learningpath/LearningPathNgxService.java (1)
Pattern
src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_importssrc/main/java/de/tum/cit/aet/artemis/atlas/service/util/UnionFind.java (1)
Pattern
src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_importssrc/test/java/de/tum/cit/aet/artemis/UnionFindTest.java (1)
Pattern
src/test/java/**/*.java
: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true
Additional comments not posted (15)
src/test/java/de/tum/cit/aet/artemis/UnionFindTest.java (7)
24-27
: LGTM!The test is well-written, follows the naming convention, and uses specific assertions to verify the initial state of the
UnionFind
instance.
30-34
: LGTM!The test is well-written, follows the naming convention, and uses specific assertions to verify the behavior of adding a new element to the
UnionFind
instance.
37-40
: LGTM!The test is well-written, follows the naming convention, and uses specific assertions to verify the behavior of finding the representative of individual elements.
43-47
: LGTM!The test is well-written, follows the naming convention, and uses specific assertions to verify the behavior of merging sets using the
union
method.
50-54
: LGTM!The test is well-written, follows the naming convention, and uses specific assertions to verify the behavior of checking if elements belong to the same set using the
inSameSet
method.
57-61
: LGTM!The test is well-written, follows the naming convention, and uses specific assertions to verify the behavior of counting the number of sets after performing multiple unions.
64-68
: LGTM!The test is well-written, follows the naming convention, and uses specific assertions to verify the behavior of checking the size of the
UnionFind
instance before and after adding an element.src/main/java/de/tum/cit/aet/artemis/atlas/service/util/UnionFind.java (7)
16-22
: LGTM!The constructor correctly initializes the
UnionFind
data structure with the provided elements, setting each element as its own parent with a rank of 0 and updating thecount
variable accordingly.
29-36
: LGTM!The
addElement
method correctly handles the addition of a new element to theUnionFind
data structure, ensuring that duplicates are not added and updating the necessary data structures and variables.
44-68
: LGTM!The
find
method correctly implements the find operation with path compression, efficiently retrieving the representative element of the set containing the given element. The method also properly handles the case when the input element is not found in the data structure.
76-101
: LGTM!The
union
method correctly implements the union operation with union by rank, efficiently merging the sets containing the given elements. The method properly handles the case when either of the input elements is not found in the data structure and updates thecount
variable to reflect the merging of sets.
110-112
: LGTM!The
inSameSet
method correctly checks if the two given elements belong to the same set by comparing their representative elements (roots) obtained using thefind
method.
119-121
: LGTM!The
numberOfSets
method correctly returns the current number of disjoint sets by returning the value of thecount
variable.
128-130
: LGTM!The
size
method correctly returns the total number of elements in theUnionFind
data structure by returning the size of theparentMap
.src/main/java/de/tum/cit/aet/artemis/atlas/service/learningpath/LearningPathNgxService.java (1)
26-26
: Verify correctness of the custom UnionFind implementation.The import statement change aligns with the PR objective to remove the dependency on the
jgrapht
library. However, please ensure that the customUnionFind
implementation located in thede.tum.cit.aet.artemis.atlas.service.util
package has been thoroughly tested for correctness and provides equivalent behavior to the previous implementation fromjgrapht
.To verify the correctness of the custom
UnionFind
implementation, you can run the following script:The script performs the following verifications:
- Checks if both the
UnionFind
class and its corresponding test classUnionFindTest
exist in the codebase.- Searches for usage of core methods specific to the
UnionFind
class (union
,find
,connected
) to ensure that the custom implementation provides the same functionality.- Checks if the
UnionFindTest
class contains multiple test methods annotated with@Test
to verify the correctness of theUnionFind
implementation.Please review the test results and ensure that the custom
UnionFind
implementation is thoroughly tested and provides the same behavior as the previous implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM - nice that we get rid of some dependencies
40feab5
Development
: Remove jgrapht and apfloat dependencyDevelopment
: Remove atlas dependency on jgrapht and apfloat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice data structure. Code looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested on ts5, works as expected, nothing seems to be broken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on TS5, working as described
Checklist
General
Server
Motivation and Context
jgrapht relies on apfloat which may cause serious security issues.
Description
In this PR we add our own implementation of a generic UnionFind datastructure that utilizes path compression and accounts for the rank of the nodes to achieve an amotized runtime O($\alpha$ (n)) and O(n) space complexity.
Steps for Testing
Prerequisites:
1 Instructor
Course with learning paths enabled
Competencies that contain relations of the type "Matching"
navigate to the learning paths tab of the instructor view
view a students learning path
Testserver States
Note
These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.
Review Progress
Performance Review
Code Review
Manual Tests
Test Coverage
Summary by CodeRabbit
New Features
UnionFind
class for efficient management of disjoint sets.UnionFind
functionality.Bug Fixes
Refactor
UnionFind
implementation.