Skip to content

Conversation

@andrii0lomakin
Copy link
Collaborator

Summary

  • Automated PR to apply Qodana cleanup fixes to the codebase

Test plan

  • Review the automated fixes
  • Verify tests pass

🤖 Generated automatically by Qodana workflow

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @andrii0lomakin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request incorporates automated code cleanup fixes suggested by Qodana, primarily focusing on modernizing the codebase by adopting Java record types for various internal classes. It also includes adding missing @Override annotations and other minor code style and API usage improvements to enhance overall code quality and leverage newer Java language features.

Highlights

  • Java Record Types Adoption: Many internal data-carrying classes and nested classes have been refactored into Java record types, significantly reducing boilerplate code and improving conciseness. This includes SpinLockWrapper, PointerTracker, MemoryStatPrinter, PairIntegerObject, RawPairIntegerBoolean, EdgeKey, DatabaseURLConnection, and several others across various packages.
  • Enhanced Code Clarity with @OverRide: Numerous @Override annotations have been added to methods implementing interfaces or overriding superclass methods, improving code readability and maintainability by explicitly indicating overridden methods.
  • Modernized API Usage: Updates include replacing direct field access (.field) with accessor methods (.field()) for record components, removing redundant .toString() calls on Path objects, and simplifying generic type arguments in method calls, leveraging modern Java features and compiler improvements.
  • Interface Method Renaming: In the BaseIndexEngine interface, getId() and getName() methods have been renamed to id() and name() respectively, with corresponding updates in implementing classes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

Qodana for JVM

51 new problems were found

Inspection name Severity Problems
Unused import 🔶 Warning 15
@NotNull/@Nullable problems 🔶 Warning 8
Unused declaration 🔶 Warning 7
Method parameter always has the same value 🔶 Warning 3
Lambda can be replaced with method reference 🔶 Warning 2
Field can be made 'static' 🔶 Warning 1
Duplicated code fragment ◽️ Notice 8
Incorrect formatting ◽️ Notice 7

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request applies automated Qodana cleanup fixes, primarily converting simple data-holding classes to Java records. This is a great improvement for code conciseness and maintainability. The changes are mostly correct, but I've found a critical bug in one of the equals methods and several formatting issues in the newly created records. Please see the detailed comments.

@@ -31,10 +15,10 @@ public boolean equals(Object o) {

var oRawPair = (RawPairIntegerObject<?>) o;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

There is a critical bug in the equals method. It incorrectly casts the object o to RawPairIntegerObject instead of RawPairLongObject. This will cause a ClassCastException at runtime when comparing two RawPairLongObject instances. Please correct the cast.

Suggested change
var oRawPair = (RawPairIntegerObject<?>) o;
var oRawPair = (RawPairLongObject<?>) o;

Comment on lines +79 to +110
public void lock() {
throw new UnsupportedOperationException();
}

@Override
public void lockInterruptibly() {
throw new UnsupportedOperationException();
}
@Override
public void lockInterruptibly() {
throw new UnsupportedOperationException();
}

@Override
public boolean tryLock() {
throw new UnsupportedOperationException();
}
@Override
public boolean tryLock() {
throw new UnsupportedOperationException();
}

@Override
public boolean tryLock(long time, TimeUnit unit) {
throw new UnsupportedOperationException();
}
@Override
public boolean tryLock(long time, TimeUnit unit) {
throw new UnsupportedOperationException();
}

@Override
public void unlock() {
if (readLock) {
spinLock.releaseReadLock();
} else {
spinLock.releaseWriteLock();
@Override
public void unlock() {
if (readLock) {
spinLock.releaseReadLock();
} else {
spinLock.releaseWriteLock();
}
}
}

@Override
public Condition newCondition() {
throw new UnsupportedOperationException();
@Override
public Condition newCondition() {
throw new UnsupportedOperationException();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The methods within the SpinLockWrapper record are incorrectly indented. This affects readability and consistency with standard Java formatting conventions. Please remove the extra indentation.

public void lock() {
  throw new UnsupportedOperationException();
}

@Override
public void lockInterruptibly() {
  throw new UnsupportedOperationException();
}

@Override
public boolean tryLock() {
  throw new UnsupportedOperationException();
}

@Override
public boolean tryLock(long time, TimeUnit unit) {
  throw new UnsupportedOperationException();
}

@Override
public void unlock() {
  if (readLock) {
    spinLock.releaseReadLock();
  } else {
    spinLock.releaseWriteLock();
  }
}

@Override
public Condition newCondition() {
  throw new UnsupportedOperationException();
}

private static final class PointerTracker {

private final Exception allocation;
* Holder which contains if memory tracking is enabled stack trace for the first allocation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The Javadoc for the PointerTracker record has extra leading spaces, which affects formatting. Please remove the unnecessary indentation.

Suggested change
* Holder which contains if memory tracking is enabled stack trace for the first allocation.
* Holder which contains if memory tracking is enabled stack trace for the first allocation.

Comment on lines +514 to +523
public void run() {
final var accumulator = new EnumMap<Intention, ModifiableLong>(Intention.class);

for (final var consumptionMap : consumptionMaps) {
accumulateConsumptionStatistics(accumulator, consumptionMap);
}
for (final var consumptionMap : consumptionMaps) {
accumulateConsumptionStatistics(accumulator, consumptionMap);
}

final var memoryStat = printMemoryStatistics(accumulator);
LogManager.instance().info(this, memoryStat);
final var memoryStat = printMemoryStatistics(accumulator);
LogManager.instance().info(this, memoryStat);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The run method within the MemoryStatPrinter record is incorrectly indented. Please correct the formatting for better readability and consistency.

Suggested change
public void run() {
final var accumulator = new EnumMap<Intention, ModifiableLong>(Intention.class);
for (final var consumptionMap : consumptionMaps) {
accumulateConsumptionStatistics(accumulator, consumptionMap);
}
for (final var consumptionMap : consumptionMaps) {
accumulateConsumptionStatistics(accumulator, consumptionMap);
}
final var memoryStat = printMemoryStatistics(accumulator);
LogManager.instance().info(this, memoryStat);
final var memoryStat = printMemoryStatistics(accumulator);
LogManager.instance().info(this, memoryStat);
}
public void run() {
final var accumulator = new EnumMap<Intention, ModifiableLong>(Intention.class);
for (final var consumptionMap : consumptionMaps) {
accumulateConsumptionStatistics(accumulator, consumptionMap);
}
final var memoryStat = printMemoryStatistics(accumulator);
LogManager.instance().info(this, memoryStat);
}

Comment on lines +67 to +87
public boolean tryAdvance(Consumer<? super RawPair<RID, Change>> action) {
return spliterator.tryAdvance(
entry -> action.accept(new RawPair<>(entry.getKey(), entry.getValue())));
}

@Override
@Nullable
public Spliterator<RawPair<RID, Change>> trySplit() {
var split = spliterator.trySplit();
return split != null ? new TransformingSpliterator(split) : null;
}

@Override
public long estimateSize() {
return spliterator.estimateSize();
}

@Override
public int characteristics() {
return spliterator.characteristics();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The methods inside the TransformingSpliterator record are incorrectly indented. This should be fixed to improve code readability and adhere to standard Java formatting conventions.

public boolean tryAdvance(Consumer<? super RawPair<RID, Change>> action) {
  return spliterator.tryAdvance(
      entry -> action.accept(new RawPair<>(entry.getKey(), entry.getValue())));
}

@Override
@Nullable
public Spliterator<RawPair<RID, Change>> trySplit() {
  var split = spliterator.trySplit();
  return split != null ? new TransformingSpliterator(split) : null;
}

@Override
public long estimateSize() {
  return spliterator.estimateSize();
}

@Override
public int characteristics() {
  return spliterator.characteristics();
}

Comment on lines +274 to +296
public boolean tryAdvance(Consumer<? super ObjectIntPair<RID>> action) {
return delegate.tryAdvance(pair -> {
final var rid = new RecordId(pair.first().targetCollection(),
pair.first().targetPosition());
action.accept(new ObjectIntImmutablePair<>(rid, pair.second()));
});
}

@Nullable
@Override
public Spliterator<ObjectIntPair<RID>> trySplit() {
return new TransformingSpliterator(delegate.trySplit());
}
@Nullable
@Override
public Spliterator<ObjectIntPair<RID>> trySplit() {
return new TransformingSpliterator(delegate.trySplit());
}

@Override
public long estimateSize() {
return delegate.estimateSize();
}
@Override
public long estimateSize() {
return delegate.estimateSize();
}

@Override
public int characteristics() {
return delegate.characteristics();
@Override
public int characteristics() {
return delegate.characteristics();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The methods inside the TransformingSpliterator record are incorrectly indented. Please fix the formatting for consistency and readability.

public boolean tryAdvance(Consumer<? super ObjectIntPair<RID>> action) {
  return delegate.tryAdvance(pair -> {
    final var rid = new RecordId(pair.first().targetCollection(),
        pair.first().targetPosition());
    action.accept(new ObjectIntImmutablePair<>(rid, pair.second()));
  });
}

@Nullable
@Override
public Spliterator<ObjectIntPair<RID>> trySplit() {
  return new TransformingSpliterator(delegate.trySplit());
}

@Override
public long estimateSize() {
  return delegate.estimateSize();
}

@Override
public int characteristics() {
  return delegate.characteristics();
}

Comment on lines +286 to +288
public DatabaseSessionInternal getThreadDatabase() {
return context.cachedPool(database, username, password).acquire();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The getThreadDatabase method inside the TestScheduleDatabaseFactory record is incorrectly indented. Please correct the formatting.

Suggested change
public DatabaseSessionInternal getThreadDatabase() {
return context.cachedPool(database, username, password).acquire();
}
public DatabaseSessionInternal getThreadDatabase() {
return context.cachedPool(database, username, password).acquire();
}

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.

2 participants