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

Add a default mapping for java.util.UUID #71

Closed
nvamelichev opened this issue May 17, 2024 · 1 comment
Closed

Add a default mapping for java.util.UUID #71

nvamelichev opened this issue May 17, 2024 · 1 comment
Assignees
Labels
feature New feature or request

Comments

@nvamelichev
Copy link
Collaborator

nvamelichev commented May 17, 2024

In the next YOJ minor version (2.3.0), we should introduce new FieldValueType.UUID which corresponds to a java.util.UUID value and is stored as a single column of type UTF8 (modern mapping)/STRING (legacy mapping) in YDB.
In InMemory database it will be stored as a String, to make UUID sorting consistent with YDB (Java's java.util.UUID has the weirdest compareTo() implementation possible, -100/10 don't recommend.)

This is safe because there is no existing default mapping for UUID: it currently might get detected as FieldValueType.COMPOSITE but we have no access through Java reflection because it is in the jdk.base module. Any current mapping for UUID is therefore custom, e.g. (@Column(flatten=false) for JSON mapping, or a custom value type via e.g. @StringColumn or FieldValueType.registerStringValueType()).

Existing @StringColumn and FieldValueType.registerStringValueType() conversions will just continue to work (they might be a bit more inefficient than the direct mapping, but the cost is generally negligible).

This can also be extended to support other UUID implementations in the future, e.g., newer UUID versions which Java's java.util.UUID does not generate.

@nvamelichev nvamelichev added the feature New feature or request label May 17, 2024
@nvamelichev nvamelichev self-assigned this May 17, 2024
nvamelichev added a commit that referenced this issue May 30, 2024
Note that this makes backward incompatible method signature changes in `FieldValue.Tuple`
(which should **not** have been used in application code, anyway, but...)
nvamelichev added a commit that referenced this issue Jun 1, 2024
Note that this makes backward incompatible method signature changes in `FieldValue.Tuple`
(which should **not** have been used in application code, anyway, but...)
@nvamelichev
Copy link
Collaborator Author

nvamelichev commented Jun 3, 2024

Fixed by PR #73. Available in release 2.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant