-
Notifications
You must be signed in to change notification settings - Fork 32
FMWK-79 Support native Aerospike Key types (false by default) #660
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
Conversation
… with a flag (false by default)
# Conflicts: # src/main/java/org/springframework/data/aerospike/config/AerospikeDataSettings.java
…r store as it is if the type is natively supported
@@ -15,10 +16,31 @@ public static KeyAssert assertThat(Key key) { | |||
} | |||
|
|||
@SuppressWarnings("UnusedReturnValue") | |||
public KeyAssert consistsOf(String namespace, String setName, Object userKey) { | |||
public KeyAssert consistsOf(AerospikeDataSettings aerospikeDataSettings, String namespace, String setName, | |||
Object expectedUserKey) { | |||
Assertions.assertThat(actual.namespace).isEqualTo(namespace); |
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.
Replace this assertj
(shouldn't be used in production code) call with something like:
if (!actual.namespace.equals(namespace)) {
throw new IllegalArgumentException("Inconsistent namespace name");
}
@@ -15,10 +16,31 @@ public static KeyAssert assertThat(Key key) { | |||
} | |||
|
|||
@SuppressWarnings("UnusedReturnValue") | |||
public KeyAssert consistsOf(String namespace, String setName, Object userKey) { | |||
public KeyAssert consistsOf(AerospikeDataSettings aerospikeDataSettings, String namespace, String setName, | |||
Object expectedUserKey) { | |||
Assertions.assertThat(actual.namespace).isEqualTo(namespace); | |||
Assertions.assertThat(actual.setName).isEqualTo(setName); |
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.
Same as above
} else { | ||
// String type is used for unsupported Aerospike key types and previously for all key types in older | ||
// versions of Spring Data Aerospike | ||
Assertions.assertThat(checkIfActualUserKeyTypeIsString()).isTrue(); |
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.
Use
/*org.springframework.util.*/Assert.isTrue(checkIfActualUserKeyTypeIsString(), "Key type is not string");
instead.
return Optional.of(new Key(data.getNamespace(), setName, id)); | ||
|
||
// Store record key as it is (if Aerospike supports it natively and configured) | ||
if (aerospikeDataSettings.isKeepOriginalKeyTypes() && |
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.
Take the &&
operator to the new line
String setName; | ||
if (data.getSetName() != null) { | ||
setName = data.getSetName(); | ||
} else { | ||
setName = entity.getSetName(); | ||
} |
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.
nit: can be simplified with
String setName = Optional.ofNullable(data.getSetName()).orElse(entity.getSetName());
return new Key(namespace, set, (byte[]) userKey); | ||
} | ||
// Could not construct a key of native supported Aerospike record key type | ||
return null; |
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.
Why not supporting Double/Float?
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.
Aerospike Record Key doesn't support Double/Float
@@ -32,6 +32,10 @@ public class AerospikeDataSettings { | |||
int indexCacheRefreshFrequencySeconds = 3600; | |||
@Builder.Default | |||
long queryMaxRecords = 10_000L; | |||
// When true, stores key types (record keys and map keys) as original type if supported. False means always store |
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.
Define how @Id
fields (primary keys) and Map keys are stored: false - always as String, true - preserve original type if supported
Used this in the documentation, we can have the same comment here. What do you think?
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.
I like it
…figuration, first part
…rt to be a list instead of string
This PR is still a draft, investigating whether we should support (and test) the following types:
short (primitive)
Short (primitive wrapper)
byte
char