-
Notifications
You must be signed in to change notification settings - Fork 14
Implement AerospikeGeneration annotation #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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/main/java/com/aerospike/mapper/annotations/AerospikeGeneration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.aerospike.mapper.annotations; | ||
|
||
import com.aerospike.client.policy.GenerationPolicy; | ||
import com.aerospike.client.policy.WritePolicy; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* 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 @AerospikeGeneration, the returned record's generation field will be mapped into the @AerospikeGeneration field. | ||
* When writing the record, if the @AerospikeGeneration field is non-zero, the generation will be set in the | ||
* {@link WritePolicy#generation} field and the {@link WritePolicy#generationPolicy} will be set to | ||
* {@link GenerationPolicy#EXPECT_GEN_EQUAL}. | ||
* <p/> | ||
* Example usage: | ||
* <pre> | ||
* @AerospikeRecord(namespace = "test", set = "account") | ||
* public class Account { | ||
* @AerospikeKey | ||
* private int id; | ||
* @AerospikeBin | ||
* private String name; | ||
* @AerospikeGeneration | ||
* private int generation; | ||
* } | ||
* </pre> | ||
* | ||
* @author timfaulkes | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD, ElementType.METHOD}) | ||
public @interface AerospikeGeneration { | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
498 changes: 329 additions & 169 deletions
498
src/main/java/com/aerospike/mapper/tools/ClassCacheEntry.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If for some reason, the class's write policy is set to GenerationPolicy.EXPECT_GEN_GT will we be overriding it?
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.
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!