Skip to content

feature: Move ULID-related classes to util package#95

Merged
xerial merged 2 commits intomainfrom
feature-20250525-234102
May 26, 2025
Merged

feature: Move ULID-related classes to util package#95
xerial merged 2 commits intomainfrom
feature-20250525-234102

Conversation

@xerial
Copy link
Copy Markdown
Member

@xerial xerial commented May 26, 2025

Description

Moved ULID related classes from their original location to the util package to improve organization and maintainability.

Related Issue/Task

No related issues or tasks.

Checklist

  • This pull request focuses on a single task.
  • The change does not contain security credentials.

@amazon-q-developer
Copy link
Copy Markdown
Contributor

⏳ I'm reviewing this pull request for security vulnerabilities and code quality issues. I'll provide an update when I'm done

@github-actions github-actions Bot added the feature New feature label May 26, 2025
Copy link
Copy Markdown
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.

Hello @xerial, 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!

Summary of Changes

Hello team, gemini-code-assist here to provide a summary of this pull request. The primary goal of this PR, as indicated by the title and description, is to improve code organization by relocating ULID-related classes and their corresponding test files. These files have been moved from a dedicated ulid package within wvlet.ai.core to the more general util package within the same module.

Highlights

  • Code Relocation: The core change involves moving several files (CrockfordBase32.scala, PrefixedULID.scala, ULID.scala) and their test counterparts (CrockfordBase32Test.scala, PrefixedULIDTest.scala, ULIDTest.scala) from the wvlet.ai.core.ulid package to wvlet.ai.core.util.
  • Package and Import Updates: All affected files have had their package declarations updated to reflect the new location (wvlet.ai.core.util). Corresponding import statements in the test files have also been adjusted.
  • Access Modifier Adjustment: In ULID.scala, the package-private access modifiers for MinTime and MaxTime have been updated from private[ulid] to private[util] to maintain the intended scope within the new package.

Changelog

Click here to see the changelog
  • ai-core/src/main/scala/wvlet/ai/core/util/CrockfordBase32.scala
    • Changed package declaration from wvlet.ai.core.ulid to wvlet.ai.core.util (line 14).
  • ai-core/src/main/scala/wvlet/ai/core/util/PrefixedULID.scala
    • Changed package declaration from wvlet.ai.core.ulid to wvlet.ai.core.util (line 14).
  • ai-core/src/main/scala/wvlet/ai/core/util/ULID.scala
    • Changed package declaration from wvlet.ai.core.ulid to wvlet.ai.core.util (line 14).
    • Updated package-private access modifiers for MinTime and MaxTime from private[ulid] to private[util] (lines 101, 102).
  • ai-core/src/test/scala/wvlet/ai/core/util/CrockfordBase32Test.scala
    • Changed package declaration from wvlet.ai.core.ulid to wvlet.ai.core.util (line 14).
    • Updated import statement for CrockfordBase32 (line 16).
  • ai-core/src/test/scala/wvlet/ai/core/util/PrefixedULIDTest.scala
    • Changed package declaration from wvlet.ai.core.ulid to wvlet.ai.core.util (line 14).
    • Updated import statement for PrefixedULID and ULID (line 16).
  • ai-core/src/test/scala/wvlet/ai/core/util/ULIDTest.scala
    • Changed package declaration from wvlet.ai.core.ulid to wvlet.ai.core.util (line 14).
    • Updated import statement for CrockfordBase32 and ULID (line 16).
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.


Packages shift and change,
Code finds a new home, arranged,
Utilities wait.

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.

Comment thread ai-core/src/main/scala/wvlet/ai/core/util/ULID.scala
@amazon-q-developer
Copy link
Copy Markdown
Contributor

✅ I finished the code review, and left comments with the issues I found. I will now generate code fix suggestions.

Copy link
Copy Markdown
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 effectively moves ULID-related classes from their original wvlet.ai.core.ulid package to the more general wvlet.ai.core.util package. This is a good refactoring step that improves code organization and potentially maintainability by grouping utility classes together.

The changes are mostly straightforward package and import updates, which have been executed correctly across all relevant source and test files. The visibility modifier for MinTime and MaxTime in ULID.scala has also been appropriately updated to private[util].

Overall, the changes are clean and achieve the stated goal. I have one suggestion regarding a removed comment that would enhance the clarity of the code.

Summary of Findings

  • Code Clarity: A clarifying comment explaining the 48-bit nature of the ULID timestamp in the MaxTime calculation was removed. Restoring it would improve code maintainability.
  • Refactoring: The primary goal of moving ULID classes to the util package was successfully achieved, improving code organization.

Merge Readiness

The pull request is well-structured and achieves its refactoring goal. There is one medium-severity suggestion regarding a removed comment in ULID.scala that would improve code clarity. I recommend addressing this point before merging.

As a language model, I am not authorized to approve pull requests. Please ensure this change is reviewed and approved by a repository maintainer.

private[ulid] val MinTime = 0L
private[ulid] val MaxTime = (~0L) >>> (64 - 48) // Timestamp uses 48-bit range
private[util] val MinTime = 0L
private[util] val MaxTime = (~0L) >>> (64 - 48)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The comment // Timestamp uses 48-bit range was removed from this line. This comment was quite helpful for understanding the calculation (~0L) >>> (64 - 48), as it clarifies that the ULID timestamp is 48 bits long.

Could we consider re-adding this comment, or a similar one, to maintain clarity on why these specific numbers are used in the MaxTime calculation? This would aid future maintainers in understanding this constant's derivation.

  private[util] val MaxTime = (~0L) >>> (64 - 48) // Timestamp uses 48-bit range

@xerial xerial enabled auto-merge (squash) May 26, 2025 06:56
@xerial xerial merged commit 7f89ad6 into main May 26, 2025
10 checks passed
@xerial xerial deleted the feature-20250525-234102 branch May 26, 2025 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant