-
Notifications
You must be signed in to change notification settings - Fork 59
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
Lua cjson library #558
Comments
Hi @ivan-kripakov-m10 , thanks for your interest in JedisMock! Yeah I was waiting for somebody to come and complain about missing
I did not immerse deeply into the problem but it looks wrong to me. Isn't it something we could avoid, as in the end what we get back into Redis is just a combination of Have a closer look at how |
Got it! It appears that the Redis cjson library is not available as a Lua file: https://github.com/redis/redis/blob/fdeb97629ef8964a5d9040328ee63734884ac874/deps/lua/src/lua_cjson.c#L1346 In Redis, the cjson library is implemented using a similar approach to the one I described above. UPD: I will try to figure out how to link this C source to JedisMock Lua Runtime Context. |
Do I get this right that as |
I'm not entirely sure.
|
In other words, does LuaJ expose API to link the C source files to LuaJ Runtime Context?
And also there is another option: find some Lua json library and (possibly) modify it (if it will be incompatible with So, generally, I see 5* options:
5th option seems to be impossible if you take a look at
From my perspective, this essentially narrows it down to two main options:
Since you suggested linking a Lua library in your comment, I can look into some libraries and come back with a list:) |
Thanks for the thorough analysis, @ivan-kripakov-m10 ! I remember that I came to this problem when we implemented Lua support, so I decided to wait for someone who needs one of these libraries in the first place, so that we could properly prioritize the support of one of them. As individual libraries from this list ( So let's focus on Ideally, it would be the best if we had a pure Lua implementation -- this would have required the least amount of work. If it's incompatible with Redis implementation in some details, we coud've fixed it, but in general JSON parsing should be more or less the same everywhere. Or maybe we could find a Java implementation or quickly write one ourselves. All this requires research, thank you for your willingness to do this. |
Hi @ivan-kripakov-m10 , thanks for the investigation. My thoughts so far:
|
Hi @inponomarev! I also prefer the Java-based approach since I understand it better :) |
Thank you @ivan-kripakov-m10 for the PR, expect the new Maven release soon. |
thanks, @inponomarev! |
Fixed in v1.1.8 |
hi!
There are some pre-imported libraries available in the Redis Lua runtime context that are not available in the Jedis mock Lua runtime context (source)
As I understand, the Lua context is configured here:
And in this method implementation:
So, only external libs are unsupported at the moment.
I'm ready to add them, but I want to discuss the approach first
I would like to present the one I've found for cjson as an example:
org.luaj.vm2.lib.TwoArgFunction
:While this approach can work, it would require to map all possible
org.luaj.vm2.LuaValue
inheritors to Java types, which seems to me a little bit complicated, but possible and good enough.Are there any other approaches I should consider?
The text was updated successfully, but these errors were encountered: