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

ByteArray class for primary keys with byte[] #17

Merged
merged 3 commits into from
Feb 14, 2024
Merged

Conversation

lavrukov
Copy link
Contributor

@lavrukov lavrukov commented Feb 1, 2024

Byte arrays in primary keys support.

We can't do it with simple byte[], because records default comparator and equals uses compare adresses, not real data. Special class for this looks better, than magic over byte[]

@lavrukov lavrukov changed the title ByteArray class for primary keys with byte[] WIP: ByteArray class for primary keys with byte[] Feb 1, 2024
Copy link
Collaborator

@nvamelichev nvamelichev left a comment

Choose a reason for hiding this comment

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

Overall very good!

I request some minor improvements

  • Add another (convenience) copy constructor to ByteArray, it will make the test so much nicer:
var copy = ByteArray.copy(ba); // copies ByteArray's bytes :-)
var copy2 = ba.copy(); // same as ByteArray.copy(ba), just alternative syntax
  • Add tests for ByteArray-keyed entities to ListingTest and TableQueryBuilderTest (to test Table.list() and Table.query() DSL explicitly)

Other than that, I think the PR is great!

} else if (value.isByteArray()) {
checkArgument(fieldValueType == FieldValueType.BYTE_ARRAY,
ByteArrayFieldExpected::new,
p -> format("Specified a boolean value for non-boolean field \"%s\"", p));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo: "boolean value", "non-boolean field" instead of "ByteArray value", "non-ByteArray field"

@nvamelichev nvamelichev changed the title WIP: ByteArray class for primary keys with byte[] ByteArray class for primary keys with byte[] Feb 2, 2024
Copy link
Collaborator

@nvamelichev nvamelichev left a comment

Choose a reason for hiding this comment

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

Merging! 🎉

@nvamelichev nvamelichev merged commit 5f9c58d into main Feb 14, 2024
1 check passed
@nvamelichev nvamelichev deleted the byte-array-pk-keys branch February 14, 2024 19:46
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