-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conversation
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.
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 likejava:type
andproto:type
. - Multibase Binary Support: Adds
mf:multibaseBinary
as a subtype ofenola: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 newfrom(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
.
- Added a dependency on
- 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 mutablebytes
andhashCode
fields. - Added JavaDoc to clarify usage and relationship to
com.google.protobuf.ByteString
.
- Added
- java/dev/enola/common/io/resource/ReadableResource.java
- Added a
TODO
comment to consider adding atoDataURI()
method, similar toDataResource
.
- Added a
- java/dev/enola/model/xsd/Datatypes.java
- Added a
TODO
comment to includebase64Binary
andhexBinary
datatypes, referencingbinary.ttl
for their patterns.
- Added a
- models/enola.dev/binary.ttl
- Created a new file defining
enola:binary
and related subtypes likexsd:base64Binary
,xsd:hexBinary
,enola:UUID
, andmf:multibaseBinary
. - Defined IRI templates and patterns for
xsd:base64Binary
andmf:multibaseBinary
.
- Created a new file defining
- models/enola.dev/enola.ttl
- Added
enola:subDatatypeOf
property to define sub-datatype relationships.
- Added
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
-
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. ↩
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 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 forByteSeq
could be expanded to clearly differentiate it fromcom.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 renamingtoBytes()
tocopyIntoNewByteArray()
andtoUUID()
toasUUID()
for better consistency with existing naming conventions likeasString()
. - 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() ? |
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.
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.
// 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()? |
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.
Consider renaming toUUID()
to asUUID()
for consistency with the existing asString()
method, which provides a more fluent and readable API.
// TODO Rename toUUID() to asUUID() for consistency with asString()? | |
// TODO Rename toUUID() to asUUID() for consistency with asString()? | |
public UUID asUUID() { |
See also multiformats/multibase#133.