Skip to content
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

Initial binary.ttl incl. mf:multibaseBinary #1149

Merged
merged 3 commits into from
Mar 1, 2025

Conversation

vorburger
Copy link
Member

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.

Hello @vorburger, 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

This pull request introduces an initial definition for enola:binary as a datatype, along with mf:multibaseBinary and other related subtypes, in the Enola data model. It also adds a dependency on error_prone_annotations and includes several improvements and clarifications to the ByteSeq class.

Highlights

  • New Datatype Definition: Introduces enola:binary as a datatype with associated properties like java:type and proto:type.
  • Multibase Binary Support: Adds mf:multibaseBinary as a subtype of enola:binary, including an IRI template and pattern based on the multibase specification.
  • ByteSeq Enhancements: Improves the ByteSeq class with additional methods and documentation, including a new from(String, Charset) method and various TODOs for future enhancements.
  • Sub-Datatype Property: Adds enola:subDatatypeOf as a property to define relationships between datatypes.

Changelog

Click here to see the changelog
  • java/dev/enola/common/BUILD
    • Added a dependency on @enola_maven//:com_google_errorprone_error_prone_annotations.
  • java/dev/enola/common/ByteSeq.java
    • Added @Immutable annotation.
    • Added from(String, Charset) method.
    • Added isEmpty() method.
    • Added several TODOs for future enhancements like toBase64(), substring(), asInputStream(), etc.
    • Added @SuppressWarnings("Immutable") to suppress warnings related to mutable bytes and hashCode fields.
    • Added JavaDoc to clarify usage and relationship to com.google.protobuf.ByteString.
  • java/dev/enola/common/io/resource/ReadableResource.java
    • Added a TODO comment to consider adding a toDataURI() method, similar to DataResource.
  • java/dev/enola/model/xsd/Datatypes.java
    • Added a TODO comment to include base64Binary and hexBinary datatypes, referencing binary.ttl for their patterns.
  • models/enola.dev/binary.ttl
    • Created a new file defining enola:binary and related subtypes like xsd:base64Binary, xsd:hexBinary, enola:UUID, and mf:multibaseBinary.
    • Defined IRI templates and patterns for xsd:base64Binary and mf:multibaseBinary.
  • models/enola.dev/enola.ttl
    • Added enola:subDatatypeOf property to define sub-datatype relationships.
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.


Did you know?

The term 'multiformats' refers to a set of protocols that aim to create future-proof and interoperable systems by using self-describing formats. Multibase is one of the multiformats projects.

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.

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 introduces a new ByteSeq class for handling immutable byte sequences, along with related utilities and definitions for binary datatypes in the Enola project. The changes look good overall, with careful attention to immutability and efficiency. However, there are a few areas where improvements can be made to enhance clarity, consistency, and maintainability.

Summary of Findings

  • Clarity of ByteSeq purpose: The Javadoc for ByteSeq could be expanded to clearly differentiate it from com.google.common.io.ByteSource and explain the specific use cases it's designed for within the Enola project.
  • Consistency in naming conventions: In ByteSeq, consider renaming toBytes() to copyIntoNewByteArray() and toUUID() to asUUID() for better consistency with existing naming conventions like asString().
  • Missing test coverage: The TODO comment in Datatypes.java indicates a lack of test coverage for the INT RegExp. Adding a test case would improve the reliability of the datatype validation.

Merge Readiness

The pull request is in good shape overall, but addressing the comments related to clarity, consistency, and test coverage would further improve the quality and maintainability of the code. I recommend addressing these points before merging. I am unable to directly approve this pull request, and users should have others review and approve this code before merging.

private transient int hashCode;

private ByteSeq(byte[] bytes) {
this.bytes = bytes;
}

// TODO Rename toBytes() to copyIntoNewByteArray() ?
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Consider renaming toBytes() to copyIntoNewByteArray() to more clearly indicate that a new byte array is created and returned, avoiding potential confusion about whether the internal byte array is being directly exposed.

Suggested change
// TODO Rename toBytes() to copyIntoNewByteArray() ?
// TODO Rename toBytes() to copyIntoNewByteArray() ?
public byte[] copyIntoNewByteArray() {

@@ -139,6 +173,7 @@ public ByteString toByteString() {
return ByteString.copyFrom(bytes);
}
*/
// TODO Rename toUUID() to asUUID() for consistency with asString()?
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Consider renaming toUUID() to asUUID() for consistency with the existing asString() method, which provides a more fluent and readable API.

Suggested change
// TODO Rename toUUID() to asUUID() for consistency with asString()?
// TODO Rename toUUID() to asUUID() for consistency with asString()?
public UUID asUUID() {

@vorburger vorburger merged commit 3bad4c8 into enola-dev:main Mar 1, 2025
9 checks passed
@vorburger vorburger deleted the binary1 branch March 1, 2025 18:00
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