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

FMWK-443 Add configuration flag writeSortedMaps #745

Merged
merged 8 commits into from
May 28, 2024

Conversation

agrgr
Copy link

@agrgr agrgr commented May 26, 2024

No description provided.

@agrgr agrgr requested review from roimenashe and reugn May 26, 2024 13:05
@@ -157,7 +159,12 @@ private void convertToAerospikeWriteData(Object source, AerospikeWriteData data)

private Map<String, Object> convertProperties(TypeInformation<?> type, AerospikePersistentEntity<?> entity,
ConvertingPropertyAccessor<?> accessor, boolean isCustomType) {
Map<String, Object> target = new TreeMap<>();
Map<String, Object> target;
if (!settings.isWriteTreeMaps()) {
Copy link
Member

Choose a reason for hiding this comment

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

simpler to check isWriteTreeMaps and set target as TreeMap, otherwise use HashMap (follow the condition, no need for !

@@ -234,7 +241,14 @@ protected Map<Object, Object> convertMap(final Map<Object, Object> source, final
Assert.notNull(source, "Given map must not be null!");
Assert.notNull(type, "Given type must not be null!");

return source.entrySet().stream().collect(TreeMap::new, (m, e) -> {
Supplier<Map<Object, Object>> mapSupplier;
if (!settings.isWriteTreeMaps()) {
Copy link
Member

Choose a reason for hiding this comment

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

Same here:

simpler to check isWriteTreeMaps and set target as TreeMap, otherwise use HashMap (follow the condition, no need for !

@agrgr agrgr marked this pull request as ready for review May 26, 2024 15:49
@@ -37,4 +37,6 @@ public class AerospikeDataSettings {
// Define how @Id fields (primary keys) and Map keys are stored: false - always as String,
// true - preserve original type if supported
boolean keepOriginalKeyTypes = false;
// Define how Maps are written: true - as TreeMaps (default), false - as HashMaps
boolean writeTreeMaps = true;
Copy link
Member

Choose a reason for hiding this comment

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

Consider renaming to useSortedMap.

Comment on lines 162 to 167
Map<String, Object> target;
if (settings.isWriteTreeMaps()) {
target = new TreeMap<>();
} else {
target = new HashMap<>();
}
Copy link
Member

Choose a reason for hiding this comment

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

Consider using the ternary operator.

Comment on lines 244 to 249
Supplier<Map<Object, Object>> mapSupplier;
if (settings.isWriteTreeMaps()) {
mapSupplier = TreeMap::new;
} else {
mapSupplier = HashMap::new;
}
Copy link
Member

Choose a reason for hiding this comment

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

Consider using the ternary operator.

@reugn reugn changed the title FMWK-443 Add configuration flag writeTreeMaps FMWK-443 Add configuration flag writeSortedMaps May 28, 2024
@agrgr agrgr merged commit bce7b11 into main May 28, 2024
7 checks passed
@agrgr agrgr deleted the FMWK-443-flag-writeTreeMaps branch May 28, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants