-
-
Notifications
You must be signed in to change notification settings - Fork 75
chore: more java 21 idiomatic code #2143
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
Conversation
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
31ed06e
to
433252c
Compare
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.
Copilot reviewed 134 out of 134 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (5)
engine/src/main/java/com/arcadedb/index/TypeIndex.java:499
- Ensure that 'indexesOnBuckets' is of a type that supports getFirst() (e.g. LinkedList) as replacing get(0) may cause incompatibility if it remains an ArrayList.
return indexesOnBuckets.getFirst();
engine/src/main/java/com/arcadedb/engine/PageManagerFlushThread.java:52
- Ensure that the 'pages' list is of a type that supports getFirst(); otherwise, consider using pages.get(0) if pages is an ArrayList.
this.database = pages == null || pages.isEmpty() ? null : pages.getFirst().pageId.getDatabase();
engine/src/main/java/com/arcadedb/engine/LocalBucket.java:1719
- Verify that 'orderedRecordContentInPage' supports getLast(); if it is an ArrayList, this call will not compile. Consider using get(orderedRecordContentInPage.size()-1) if necessary.
final int[] lastRecord = orderedRecordContentInPage.getLast();
engine/src/main/java/com/arcadedb/database/TransactionContext.java:194
- Confirm that the 'transactions' list supports removeLast(); if it is an ArrayList, this will fail at runtime. Consider using an appropriate collection type (e.g. Deque or LinkedList).
return transactions.removeLast();
console/src/test/java/com/arcadedb/console/TerminalParser.java:91
- Verify that the 'words' collection’s implementation supports getLast(); if it is an ArrayList, use get(words.size() - 1).
wordCursor = words.getLast().length();
433252c
to
15b830b
Compare
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.
Pull Request Overview
This PR updates various parts of the codebase to use Java 21 idiomatic features for list handling and to standardize the usage of metadata property constants. It replaces index‐based list access (e.g. get(0), get(size()-1), add(0)) with the newer getFirst(), getLast(), and addFirst() methods, and also updates hard-coded metadata keys to use defined constants.
- Updated list element retrieval and insertion throughout the code.
- Replaced string literals for metadata keys with constants.
Reviewed Changes
Copilot reviewed 134 out of 134 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
engine/src/main/java/com/arcadedb/index/vector/HnswVectorIndex.java | Replaces index‐based insertion with addFirst() for improved clarity. |
engine/src/main/java/com/arcadedb/index/TypeIndex.java | Uses getFirst() to retrieve the initial index element. |
engine/src/main/java/com/arcadedb/index/MultiIndexCursor.java | Updates list accesses from get(0) to getFirst() for several lists. |
engine/src/main/java/com/arcadedb/graph/MutableEdgeSegment.java | Updates metadata key usage to reference RID_PROPERTY. |
engine/src/main/java/com/arcadedb/engine/PageManagerFlushThread.java | Replaces pages.get(0) with getFirst() for accessing the first page. |
engine/src/main/java/com/arcadedb/engine/LocalBucket.java | Replaces access to the last element using get(size()-1) with getLast(). |
engine/src/main/java/com/arcadedb/engine/Dictionary.java | Uses getFirst() instead of get(0) for dictionary key indexing. |
engine/src/main/java/com/arcadedb/database/RID.java | Updates list access for bucketId and integer checking with getFirst(). |
engine/src/main/java/com/arcadedb/database/MutableDocument.java | Replaces metadata keys with constant-based keys. |
engine/src/main/java/com/arcadedb/database/ImmutableDocument.java | Replaces metadata keys with constants. |
engine/src/main/java/com/arcadedb/database/DetachedDocument.java | Uses RID_PROPERTY constant instead of hard-coded '@Rid'. |
engine/src/main/java/com/arcadedb/database/DatabaseContext.java | Replaces list operations on transactions with getFirst(), getLast(), and removeLast(). |
engine/src/main/java/com/arcadedb/Profiler.java | Updates the method call for CPU load retrieval. |
engine/src/main/java/com/arcadedb/GlobalConfiguration.java | Uses Set.of() with a simplified array initializer syntax. |
e2e/src/test/java/com/arcadedb/e2e/RemoteDatabaseJavaApiTest.java | Modifies test annotations and minor formatting. |
e2e/src/test/java/com/arcadedb/e2e/JdbcQueriesTest.java | Uses the new string formatting style with .formatted(). |
console/src/test/java/com/arcadedb/console/ConsoleAsyncInsertTest.java | Uses constant-based keys and streamlined lambda expressions. |
console/src/test/java/com/arcadedb/console/TerminalParser.java | Updates list access to use getLast(). |
Comments suppressed due to low confidence (1)
engine/src/main/java/com/arcadedb/index/vector/HnswVectorIndex.java:560
- The list 'results' is instantiated as an ArrayList, which does not support the addFirst() method. Consider changing the declaration to a LinkedList (or a Deque) so that addFirst() is available, or revert to using results.add(0, ...) if appropriate.
results.addFirst(new SearchResult<>(loadVertexFromRID(pair.nodeId), pair.distance, maxValueDistanceComparator));
What does this PR do?
Propose more Jaba 21 idiomatic code
@rid
,@cat
and@type
Motivation
Clean up the code base
Checklist
mvn clean package
command