-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
RESP response encodes all field values as strings, JSON retains types of fields #719
Comments
Here's another oddity... if you quote a number in Here is
Here's TILE38
|
....obviously there is some coercion happing behind the scenes.
|
Tile38 fields were originally designed to only store floating points. At that time RESPv2 wasn't available and the proper way to store floating points was to use a Bulk string ($). I avoided Simple strings (+) because I wanted to future-proof the option of fields holding arbritary types such as strings or bytes, and simple string only support short single line strings. The Integer type (:) was a worse option because it's only suppose to integers and some clients didn't like it when floating points or strings were used. So for the best compatibility at that time and the future was the Bulk string. Since I can't control what client the user chooses, any change at this point to the RESP types may break compatibility.
Yes, now that Tile38 also supports strings there needs to be detection of the field type at runtime to correctly decode and encode for JSON. But the original functionality of representing floating point fields needs to be maintained to keep compatibility. |
I figured as much. Would you be open to RESP2 output type PR or should I just switch to JSON output? I'm using tile38 in high scale environment so i am a bit concerned about performance hit using JSON as output. I actually didn't notice this problem at first because I actually started off development using the json output but encountered a problem where storing a json object in a field in quoted form returned it unquoted during GET which made the C# deserializer explode. |
BTW
|
I would consider a PR for RESP2, but it'll probably be a big undertaking. I'm skeptical that it'll provide much of a performance gain. Though, I'd be happy to be surprised. I think the redis folks are on RESP3 now. I believe that using the JSON protocol and specifically GeoJSON "feature" types with the "properties" member is the way to go because it has the broadest compatibility. But I can understand the need to squeeze every ounce of performance out of Tile38. The JSON protocol shouldn't be much slower that RESP and I'm curious of the gains you are seeing on your side by only using RESP. Regarding the C# example using the StackExchange.Redis client. I haven't encountered that style of command before; where the command includes anything but an array of bulk strings. Is that a RESP2 feature? |
I'll give json a chance to see if it works out. I have to process 7.128e10*4 records per day at least so scale is a bit of a concern. I'll also take a look into RESP2 and see what is needed for a PR. As for stackexchange.Redis it follows full protocol and even does pipelining, batching, and a whole lot of other things. I'll pull the code apart when I get a chance. |
I also have to use FSET because I had to split into multiple commands due payload length causing errors. |
I decided to just treat all fields coming or going to tile38 as strings and let the server do what it wants with them. It does make where clauses a bit funky but it works. I'll close the issue for now. |
Describe the bug
The RESP response output of a tile38 server outputs all field values as string types whereas the JSON output properly returns the fields in the types they were sent to the server in. This is a pretty significant behavior difference between the protocols that should at least be notated somewhere.
To Reproduce
Following the example from here: https://tile38.com/topics/filter-expressions
The following response is created using a TELNET client.
If you switch to JSON output, the following is received
As you can see the
fields
arrays retain proper encoding of the type (and even put the JSON field as a object!).Expected behavior
The RESP response should alter the first byte to indicate number vs string.
See: https://redis.io/docs/reference/protocol-spec/#:~:text=Redis%20generally%20uses%20RESP%20as,the%20arguments%20for%20the%20command.
Logs
Not Applicable
Operating System (please complete the following information):
Additional context
I'm not entirely sure how to fix this without a breaking change.
Best i can think of is adding another OUTPUT type of
RESP2
or something?The text was updated successfully, but these errors were encountered: