-
Notifications
You must be signed in to change notification settings - Fork 16
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
Implement $eq support for sub document #98
Conversation
sub_doc_equals field in table changed to
# Conflicts: # src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/FindOperation.java # src/main/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/matcher/FilterableResolver.java # src/main/java/io/stargate/sgv2/jsonapi/service/shredding/model/DocValueHasher.java # src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/FindOperationTest.java # src/test/java/io/stargate/sgv2/jsonapi/service/shredding/model/DocValueHasherTest.java
src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/FindOperation.java
Outdated
Show resolved
Hide resolved
src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/FindOperation.java
Outdated
Show resolved
Hide resolved
src/main/java/io/stargate/sgv2/jsonapi/service/shredding/model/DocValueHasher.java
Outdated
Show resolved
Hide resolved
@@ -93,6 +93,28 @@ public void setUp() { | |||
.post(CollectionResource.BASE_PATH, keyspaceId.asInternal(), collectionName) | |||
.then() | |||
.statusCode(200); | |||
|
|||
json = |
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.
Ok, my changes will conflict here (sorry!)
assertThat(hash).isNotNull(); | ||
Map<String, Object> values = new LinkedHashMap<>(); | ||
values.put("a1", new BigDecimal(5)); | ||
Map<String, Object> innerValues = new LinkedHashMap<>(); |
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.
One idea: would be good to verify that innerValues
hash is also identical to equivalent sub-tree (ObjectNode of document
at JsonPointer.compile("/b1")
.
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.
Not sure how to do this the hash method calls in recursive.
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.
You can just get JsonNode
out of document (document.get("b1")
), calculate it separately.
And calculate similarly for innerValues
.
.../java/io/stargate/sgv2/jsonapi/api/model/command/deserializers/FilterClauseDeserializer.java
Show resolved
Hide resolved
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.
Looks good: added some suggestions and one question on exception.
sub_doc_equals field in table changed to Rebased to main # Conflicts: # src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindIntegrationTest.java
sub_doc_equals field in table changed to Rebased to main # Conflicts: # src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindIntegrationTest.java
… sub_doc_eq # Conflicts: # src/main/java/io/stargate/sgv2/jsonapi/service/shredding/model/DocValueHasher.java # src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindIntegrationTest.java
Not sure why it shows the changes from merged code when i did a rebase |
@@ -412,24 +557,101 @@ public void findWithSizeOperatorNoMatch() { | |||
.post(CollectionResource.BASE_PATH, keyspaceId.asInternal(), collectionName) | |||
.then() | |||
.statusCode(200) | |||
.body("data.count", is(0)); | |||
.body("data.count", is(1)) | |||
.body("data.docs[0]", jsonEquals(expected)); |
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.
Great that this works! Small question though: what about key order? If I swap key order by changing { "c": "v1", "d": false }
to { "d": false, "c": "v1" }
would I still get a result?
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.
@vkarpov15 The key order has to be same to return result. Do we need to make it work for any order?
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.
@maheshrajamani As far as I know, MongoDB retains and checks field order so filter must match that too. From that I think the suggestion is that maybe there should be negative test to ensure different ordering does NOT match the row?
Another minor point: jsonEquals()
probably does order-insensitive comparison (at least Jackson JsonNode
is order-insensitive and most JSON packages are similarly). I think this is fine for most tests but good to keep in mind for small number where we do want to check that order is retained. I think it's fine here too since the focus is not on ensuring storage of doc, retaining.
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.
@tatu-at-datastax is right, key order matters for filtering. If you swap key order and change { "c": "v1", "d": false }
to { "d": false, "c": "v1" }
you should not get a result in this test. Would be nice to add a test case for checking key order just in case.
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.
Will add a test case for this
Fix for #96