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

Record Set JsonPath with numeric parts that are not array indices returned different results on client vs server side #651

Closed
honorcode opened this issue Apr 16, 2017 · 10 comments

Comments

@honorcode
Copy link

Using localhost (Mac osx) Deepstream.io 2.2.0, Java Client 2.0.8, no plugins

Upon setRecord(recId, "a.b.1", value) the end result of set shows the path created to be:
{ "a": { "b": { "1": value } } }

Problem: data-sync/getRecord returns this record which does not match and will fail gson.toJson(elem):
{ "a": { "b": [ null, value ] } }

Example Test:
setRecord runtime breakpoint below ->

In UtilJsonPath.java :: setIterateThrough @ line 52
private static JsonElement setIterateThrough(JsonElement element, String path, JsonElement value, boolean delete)
... breakpoint at line 92: updateValue(value, (JsonElement)parent, token, delete);
where runtime vars:
element = {"tickets":{"ticketTexts":{"1":{}}}}
value = "BDD TESTING"
token = "1"
path = "tickets.ticketTexts.1"
parent = "{"1":{}}"
delete = false

BUT upon setRecord completing the data-sync'd record and / or subsequent getRecord returns this:
{"tickets":{"ticketTexts":[null,"BDD TESTING"]}}

@honorcode honorcode changed the title Json Path BUG: setRecord and subsequent getRecord show diff results when setting json path value containing numeric fieldname Json Path BUG: SERDE conflict: setRecord and subsequent getRecord show diff results when setting json path value containing numeric fieldname Apr 16, 2017
@honorcode
Copy link
Author

Btw, much of our data is deeply nested json objs with numerous objects members having numeric fieldnames. These are automated transforms in another ETL application, not possible to refactor easily.

@honorcode
Copy link
Author

The numeric fieldnames also help significantly as the number of records scales due to memory usage for each fieldname's length for every obj. Smaller fieldnames = smaller objects = smaller data stores = less bandwidth.

@honorcode
Copy link
Author

We also don't want the added padding of nulls in sparse arrays of slotted values.

@redlock
Copy link
Contributor

redlock commented Apr 16, 2017

this is probably related to the issue #646 I have posted earlier. The fix is also posted. I hope they patch it soon

@honorcode
Copy link
Author

honorcode commented Apr 18, 2017

@WolframHempel @yasserf @AlexBHarley
FYI the website link for the Contributor License Agreement is broken, so I couldn't do a PR but below is my deepstream.io/master patch with my FIXes for the server-side issues #651 and #646.

@honorcode
Copy link
Author

honorcode commented Apr 18, 2017

honorcode_deepstream_io_patch_fix_json_path_numeric_obj_member_support.diff (ok - .diff file type not supported so I guess I'll include my two .js files (json-path.js and json-pathSpec.js) as .txt files below.

@honorcode
Copy link
Author

honorcode commented Apr 18, 2017

Summary:
JsonPath _tokenizer and setValue fncs now uses NEW algo to transform json path array items (e.g. arr[3]) into a single 'part' of jsonpath token parts
'arrayProp[#]' members transform to 'arrayProp=#' now instead of 'arrayProp.#' previously
see setValue fnc for special handling of array item parsing vs numeric obj member name e.g. 'object.1' parsing.
This allows for support of parsing and differentiating object member names that are numeric values from array index numeric values in the JsonPath.

json-path.txt
json-pathSpec.txt

@honorcode
Copy link
Author

@WolframHempel @yasserf @AlexBHarley
Opened related java-client issue found when testing:
deepstreamIO/deepstream.io-client-java#84

@honorcode honorcode changed the title Json Path BUG: SERDE conflict: setRecord and subsequent getRecord show diff results when setting json path value containing numeric fieldname Record Set JsonPath with numeric parts that are not array indices, returned different results on client vs server side Apr 18, 2017
@honorcode honorcode changed the title Record Set JsonPath with numeric parts that are not array indices, returned different results on client vs server side Record Set JsonPath with numeric parts that are not array indices returned different results on client vs server side Apr 18, 2017
@yasserf yasserf added the in qa label Jul 31, 2017
@mrby
Copy link
Contributor

mrby commented Aug 3, 2017

unsure of priority for this issue.
yasser suggested this could be a client_data vs. server_data issue.

script:

const deepstream = require('deepstream.io-client-js')

const client = deepstream('wss://154.dsh.cloud?apiKey=021c04c5-a631-409d-85d1-1fb71aaa1a17')

client.login({ type: 'open' }, (success, data) => {
  console.log(success, data)
})

const recordName = 'myNewRecord_a'

client.record.getRecord(recordName)

client.record.setData(recordName, 'a.b.1', 'value', (error) => {
  if(error) {
    console.log('error: ', error)
  }
})

setTimeout(() => {
  console.log('getting record:\n  ', client.record.getRecord(recordName).get())
}, 1500)

setTimeout(() => {
  client.close()
}, 2000)

result:
Screen Shot 2017-08-03 at 16.51.00.png

@mrby mrby self-assigned this Aug 4, 2017
@mrby mrby added the bug label Aug 4, 2017
@mrby mrby removed their assignment Aug 4, 2017
@mrby mrby added ready and removed in qa labels Aug 4, 2017
@yasserf yasserf added to reproduce and removed ready labels Oct 6, 2017
@yasserf
Copy link
Contributor

yasserf commented May 3, 2020

Closing in favour of #1046

@yasserf yasserf closed this as completed May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants