Skip to content

Implemented @AerospikeGeneration (Issue #181) #182

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tim-aero
Copy link
Contributor

  • Added new annotation which can only on a field or property of type Integer or int
  • Only one such field can exist per class
  • On read, mapped the generation value back to the field
  • On write, if the field is set > 0, set the writePolicy.generation to this value and writePolicy.generationPolicy to EXPECT_GEN_EQUAL
  • Added appropriate configuration file
  • Added code config: .withFieldNamed("generation").asGenerationField()
  • Created unit tests for validation
  • Updated the AeroMapperBaseTest class to honor test.host if set as a system property instead of the default localhost:3000

- Added new annotation which can only on a field or property of type
Integer or int
- Only one such field can exist per class
- On read, mapped the generation value back to the field
- On write, if the field is set > 0, set the writePolicy.generation to
this value and writePolicy.generationPolicy to EXPECT_GEN_EQUAL
- Added appropriate configuration file
- Added code config: `.withFieldNamed("generation").asGenerationField()`
- Created unit tests for validation
- Updated the AeroMapperBaseTest class to honor `test.host` if set as a
system property instead of the default `localhost:3000`
@tim-aero tim-aero requested a review from roimenashe June 10, 2025 03:32
* Mark a field or property to be used for optimistic concurrency control using Aerospike's generation field.
* <p/>
* The field or property must be of Integer or int type. When reading an object which has a field marked
* with @Version, the returned record's generation field will be mapped into the @Version field.

Choose a reason for hiding this comment

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

@AerospikeGeneration instead of @Version

Integer versionValue = entry.getGenerationValue(object);
if (versionValue != null && versionValue > 0) {
writePolicy.generation = versionValue;
writePolicy.generationPolicy = GenerationPolicy.EXPECT_GEN_EQUAL;

Choose a reason for hiding this comment

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

If for some reason, the class's write policy is set to GenerationPolicy.EXPECT_GEN_GT will we be overriding it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I have never found any reason to use EXPECT_GEN_GT, it makes no sense as generations wrap around.

Good catches on those couple of trailing references to version instead of generation!

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