Giter VIP home page Giter VIP logo

redisjson's Introduction

GitHub issues CircleCI macos Dockerhub Codecov

RedisJSON

Forum Discord

logo

Overview

RedisJSON is a Redis module that implements ECMA-404 The JSON Data Interchange Standard as a native data type. It allows storing, updating and fetching JSON values from Redis keys (documents).

Primary features

  • Full support of the JSON standard
  • JSONPath syntax for selecting elements inside documents
  • Documents are stored as binary data in a tree structure, allowing fast access to sub-elements
  • Typed atomic operations for all JSON values types
  • Secondary index support when combined with RediSearch

Quick start

docker run -p 6379:6379 --name redis-stack redis/redis-stack:latest

Documentation

Read the docs at https://redis.io/docs/latest/develop/data-types/json/

How do I Redis?

Learn for free at Redis University

Build faster with the Redis Launchpad

Try the Redis Cloud

Dive in developer tutorials

Join the Redis community

Work at Redis

Build

Make sure you have Rust installed: https://www.rust-lang.org/tools/install

Then, build as usual:

cargo build --release

When running the tests, you need to explicitly specify the test feature to disable use of the Redis memory allocator when testing:

cargo test

If you forget to do this, you'll see an error mentioning signal: 4, SIGILL: illegal instruction.

Run

Linux

redis-server --loadmodule ./target/release/librejson.so

Mac OS

redis-server --loadmodule ./target/release/librejson.dylib

Client libraries

Official clients

NRedisStack Jedis node-redis redis-py
Redis.OM Redis OM Spring redis-om-node redis-om

Community supported clients

Project Language License Author Stars Package Comment
Redisson Java Apache-2.0 Redisson Redisson-stars Maven
redis-modules-java Java Apache-2.0 Liming Deng @dengliming redis-modules-java-stars maven
ioredis-rejson Node.js MIT Felipe Schulz @schulzf ioredis-rejson-stars npm
go-rejson Go MIT Nitish Malhotra @nitishm go-rejson-stars
rejonson Go Apache-2.0 Daniel Krom @KromDaniel rejonson-stars
rueidis Go Apache-2.0 Rueian @rueian rueidis-stars
NReJSON .NET MIT/Apache-2.0 Tommy Hanks @tombatron NReJSON-stars nuget
phpredis-json PHP MIT Rafa Campoy @averias phpredis-json-stars composer
redislabs-rejson PHP MIT Mehmet Korkmaz @mkorkmaz redislabs-rejson-stars composer
rejson-rb Ruby MIT Pavan Vachhani @vachhanihpavan rejson-rb-stars rubygems
rustis Rust MIT Dahomey Technologies rustis-stars crate Documentation
coredis Python MIT Ali-Akber Saifee @alisaifee coredis-stars pypi Documentation

Acknowledgments

RedisJSON is developed with <3 at Redis Labs.

RedisJSON is made possible only because of the existence of this amazing open source project:

License

RedisJSON is licensed under the Redis Source Available License 2.0 (RSALv2) or the Server Side Public License v1 (SSPLv1).

redisjson's People

Contributors

alonre24 avatar chayim avatar dvirdukhan avatar dvirsky avatar elena-kolevska avatar emmanuelkeller avatar enjoy-binbin avatar ephraimfeldblum avatar filipecosta90 avatar gavrie avatar gkorland avatar iddm avatar itamarhaber avatar k-jo avatar liorkogan avatar mbusath avatar meiravgri avatar meirshpilraien avatar mnunberg avatar nafraf avatar nermiller avatar oshadmi avatar rafie avatar rrelledge avatar sazzad16 avatar slorello89 avatar swilly22 avatar tomerhekmati avatar yoav-steinberg avatar yusaku avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redisjson's Issues

Can't send rejson commands via libhiredis

I have libhiredis 0.13.3 installed on my local. All rejson commands send via redisCommand() results in error with message ERR JSON lexer error SPECIAL_EXPECTED at position 311

redis-server version is 4.0.2 with rejson module pre-loaded.

I see that libhiredis is not listed under supported Client libraries. Is there a C, C++ client library that supports rejson?

No way to escape/disambiguate search paths

  1. There's no way to escape literal dots in the search path
  2. There's no way to escape search keywords within the search path.

I'm unsure what the best solution here is. I'm tempted to add a new command which would have the 'correct' semantics, but this might be a bit overboard? on the other hand, there's absolutely no way to do the aforementioned things. This might not be a big problem now, but I can certainly see someone running into weird bugs in the future.

[Crash] JSON.GET using the same path

Redis server crashed when using the same path in rejson command.
To reproduce:

172.31.21.227:11107> JSON.SET obj . '{"name":"Leonard Cohen","lastSeen":1478476800,"loggedOut": true}'
OK
172.31.21.227:11107> json.get obj . name . 

Redis rejson , get multiple elements from array

i have json Array stored in redis with rejson.

Now for example only need 2 elements from the array how do i get it?

Am using node.js with iorejson client for node.

I would prefer not to encapsulate the entire code in a loop in order to get number of article desired.

as you see below i can only query one article at the time ".article[1]" or all by doing this ".article"

  var json =  p.get("stories", ".article[1]");
json.then(function(value) {
 console.log(value);
 // expected output: "Success!"
}).catch(function(rej) {
     //rejected
     console.log(rej);
   });

Problem concerning JSON.SET

Hello, I've installed redis-4.0-rc3 and rejson module, and the test passed at root:

YumingdeMacBook-Pro:rejson yumingzhai$ make test
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C ./test all
cc -I"/Users/yumingzhai/Downloads/rejson/test/../src" -I"/Users/yumingzhai/Downloads/rejson/test/../deps/jsonsl"  -I"/Users/yumingzhai/Downloads/rejson/test/../deps/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2  -std=gnu99 -D_GNU_SOURCE -mmacosx-version-min=10.6 -o test_object.out test_object.c /Users/yumingzhai/Downloads/rejson/test/../src/librejson.a /Users/yumingzhai/Downloads/rejson/test/../deps/RedisModuleSDK/rmutil/librmutil.a /Users/yumingzhai/Downloads/rejson/test/../deps/jsonsl/libjsonsl.a -lm 
cc -I"/Users/yumingzhai/Downloads/rejson/test/../src" -I"/Users/yumingzhai/Downloads/rejson/test/../deps/jsonsl"  -I"/Users/yumingzhai/Downloads/rejson/test/../deps/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2  -std=gnu99 -D_GNU_SOURCE -mmacosx-version-min=10.6 -o test_json_object.out test_json_object.c /Users/yumingzhai/Downloads/rejson/test/../src/librejson.a /Users/yumingzhai/Downloads/rejson/test/../deps/RedisModuleSDK/rmutil/librmutil.a /Users/yumingzhai/Downloads/rejson/test/../deps/jsonsl/libjsonsl.a -lm
cc -I"/Users/yumingzhai/Downloads/rejson/test/../src" -I"/Users/yumingzhai/Downloads/rejson/test/../deps/jsonsl"  -I"/Users/yumingzhai/Downloads/rejson/test/../deps/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2  -std=gnu99 -D_GNU_SOURCE -mmacosx-version-min=10.6 -o json_validator.out json_printer.c /Users/yumingzhai/Downloads/rejson/test/../src/librejson.a /Users/yumingzhai/Downloads/rejson/test/../deps/RedisModuleSDK/rmutil/librmutil.a /Users/yumingzhai/Downloads/rejson/test/../deps/jsonsl/libjsonsl.a -lm
./test_object.out
.......................................................................................................................................................................................................................

8 tests, 215 assertions, 0 failures

Finished in 0.00017183 seconds (real) 0.00012900 seconds (proc)

./test_json_object.out
............................................................................................................................

17 tests, 124 assertions, 0 failures

Finished in 0.00030962 seconds (real) 0.00022300 seconds (proc)

./test_json_validator.sh

Should PASS: ........................................
Should FAIL: .......................................................................

111 JSON files validated, 0 problems detected
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C pytest
python -m unittest discover
.........................
----------------------------------------------------------------------
Ran 25 tests in 3.095s

OK

But it failed in the repertory pytest:

YumingdeMacBook-Pro:pytest yumingzhai$ REDIS_PORT=6379 make
python -m unittest discover
Redis output: 83380:C 04 Jul 12:08:42.759 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
83380:C 04 Jul 12:08:42.760 # Redis version=3.9.103, bits=64, commit=00000000, modified=0, pid=83380, just started
83380:C 04 Jul 12:08:42.760 # Configuration loaded
83380:M 04 Jul 12:08:42.761 * Increased maximum number of open files to 10032 (it was originally set to 256).
83380:M 04 Jul 12:08:42.761 # Creating Server TCP listening socket *:6379: bind: Address already in use

[... many errors here...]


======================================================================
ERROR: testStrCommands (test.ReJSONTestCase)
Test JSON.STRAPPEND and JSON.STRLEN commands
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 581, in testStrCommands
    self.assertOk(r.execute_command('JSON.SET', 'test', '.', '"foo"'))
  File "/Users/yumingzhai/anaconda2/lib/python2.7/site-packages/redis/client.py", line 573, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/Users/yumingzhai/anaconda2/lib/python2.7/site-packages/redis/client.py", line 585, in parse_response
    response = connection.read_response()
  File "/Users/yumingzhai/anaconda2/lib/python2.7/site-packages/redis/connection.py", line 582, in read_response
    raise response
ResponseError: unknown command 'JSON.SET'

======================================================================
ERROR: testTypeCommand (test.ReJSONTestCase)
Test JSON.TYPE command
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 489, in testTypeCommand
    self.assertOk(r.execute_command('JSON.SET', 'test', '.', json.dumps(v)))
  File "/Users/yumingzhai/anaconda2/lib/python2.7/site-packages/redis/client.py", line 573, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/Users/yumingzhai/anaconda2/lib/python2.7/site-packages/redis/client.py", line 585, in parse_response
    response = connection.read_response()
  File "/Users/yumingzhai/anaconda2/lib/python2.7/site-packages/redis/connection.py", line 582, in read_response
    raise response
ResponseError: unknown command 'JSON.SET'

----------------------------------------------------------------------
Ran 25 tests in 0.359s

FAILED (errors=23)
make: *** [test] Error 1

Now I can load Rejson module with redis, and use Rejson commands in redis-cli:

YumingdeMacBook-Pro:src yumingzhai$ redis-server --loadmodule /Users/yumingzhai/Downloads/rejson/src/rejson.so
82846:C 04 Jul 11:52:40.465 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
82846:C 04 Jul 11:52:40.466 # Redis version=3.9.103, bits=64, commit=00000000, modified=0, pid=82846, just started
82846:C 04 Jul 11:52:40.466 # Configuration loaded
82846:M 04 Jul 11:52:40.467 * Increased maximum number of open files to 10032 (it was originally set to 256).
82846:M 04 Jul 11:52:40.467 # Creating Server TCP listening socket *:6379: bind: Address already in use

YumingdeMacBook-Pro:src yumingzhai$ redis-cli
127.0.0.1:6379> JSON.SET foo . 6
OK
127.0.0.1:6379> JSON.GET foo
"6"

But it doesn't work in these two cases with python:

YumingdeMacBook-Pro:src yumingzhai$ python
Python 2.7.12 |Anaconda custom (x86_64)| (default, Jul  2 2016, 17:43:17) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import redis
>>> import json
>>> data = {
...     'foo': 'bar'
... }
>>> 
>>> r = redis.StrictRedis()
>>> r.execute_command('JSON.SET', 'doc', '.', json.dumps(data))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/yumingzhai/anaconda2/lib/python2.7/site-packages/redis/client.py", line 573, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/Users/yumingzhai/anaconda2/lib/python2.7/site-packages/redis/client.py", line 585, in parse_response
    response = connection.read_response()
  File "/Users/yumingzhai/anaconda2/lib/python2.7/site-packages/redis/connection.py", line 582, in read_response
    raise response
redis.exceptions.ResponseError: unknown command 'JSON.SET'
YumingdeMacBook-Pro:rejson yumingzhai$ python 
Python 2.7.12 |Anaconda custom (x86_64)| (default, Jul  2 2016, 17:43:17) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> from rejson import Client, Path
>>> rj = Client(host='localhost', port=6379)
>>> obj={ 'foo': 'bar', 'ans':42}
>>> rj.jsonset('obj',Path.rootPath(),obj)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/yumingzhai/anaconda2/lib/python2.7/site-packages/rejson/client.py", line 142, in jsonset
    return self.execute_command('JSON.SET', *pieces)
  File "/Users/yumingzhai/anaconda2/lib/python2.7/site-packages/redis/client.py", line 573, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/Users/yumingzhai/anaconda2/lib/python2.7/site-packages/redis/client.py", line 585, in parse_response
    response = connection.read_response()
  File "/Users/yumingzhai/anaconda2/lib/python2.7/site-packages/redis/connection.py", line 582, in read_response
    raise response
redis.exceptions.ResponseError: unknown command 'JSON.SET'

I don't know where the problem comes from, could you help me with this issue? Thanks!

Compile warnings and failure to load module in arm7l environment

Build phase:

/home/pi/docker/armh-redis_server/lib/rejson/src/object.c: In function ‘Node_Print’:
/home/pi/docker/armh-redis_server/lib/rejson/src/object.c:507:13: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int64_t’ [-Wformat=]
printf("%ld", n->value.intval);
^
/home/pi/docker/armh-redis_server/lib/rejson/src/object.c: In function ‘Node_Serializer’:
/home/pi/docker/armh-redis_server/lib/rejson/src/object.c:598:57: warning: ‘curr_entries’ may be used uninitialized in this function [-Wmaybe-uninitialized]
_serializerPush(&stack, curr_entries[curr_index]);
^
cc -I"/home/pi/docker/armh-redis_server/lib/rejson/src" -I""/home/pi/docker/armh-redis_server/lib/rejson/src/../deps"/jsonsl" -I""/home/pi/docker/armh-redis_server/lib/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99 -D_GNU_SOURCE -c -o /home/pi/docker/armh-redis_server/lib/rejson/src/object_type.o /home/pi/docker/armh-redis_server/lib/rejson/src/object_type.c

Runtime:
Redis version=3.9.103, bits=32

1:M 13 May 00:07:06.920 # Module /usr/local/lib/rejson.so failed to load: /usr/local/lib/rejson.so: undefined symbol: __aeabi_uldivmod
1:M 13 May 00:07:06.920 # Can't load module from /usr/local/lib/rejson.so: server aborting

Is this related to Integer Sizes and typing differences between i386 64 and arm7l ?
Can you offer a fix?

STRAPPEND expects JSON string instead of string

Essentially, it requires the string to append to be "quoted" as if it has been serialized, which is unnecessary, since the key/path to append to should already be a string.

See the following comparisons:

127.0.0.1:6380[7]> JSON.SET hello . '"world"'
OK
127.0.0.1:6380[7]> JSON.GET hello .
"\"world\""
127.0.0.1:6380[7]> JSON.STRAPPEND hello . '"peace"'
(integer) 10
127.0.0.1:6380[7]> JSON.SET world . '{"foo":"bar"}'
OK
127.0.0.1:6380[7]> JSON.GET world .foo
"\"bar\""
127.0.0.1:6380[7]> JSON.STRAPPEND world .foo '"t"'
(integer) 4
127.0.0.1:6380[7]> JSON.STRAPPEND world .foo 't'
(error) ERR JSON lexer error SPECIAL_INCOMPLETE at position 1
127.0.0.1:6380[7]> JSON.SET blabh 'blah'
(error) ERR wrong number of arguments for 'JSON.SET' command
127.0.0.1:6380[7]> SET blabh 'blah'
OK
127.0.0.1:6380[7]> GET blabh 'blah'
(error) ERR wrong number of arguments for 'get' command
127.0.0.1:6380[7]> GET blabh
"blah"

JSON.SET lua table

Am I forced to use cjson before calling JSON.SET, or can I pass a Lua table directly?

If passing a table is not supported, would adding such a feature improve the speed of decoding by ReJSON?

Module rejson.so failed to load: dlopen(rejson.so, 6): image not found (MacOS)

Make looks to compile fine the extension but redis is unable to load it (redis 4.0.2).

imac:rejson damz$ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C ./src all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C "/Users/damz/Desktop/rejson/src/../deps"/jsonsl static
ar rcs libjsonsl.a jsonsl.o
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C "/Users/damz/Desktop/rejson/src/../deps"/RedisModuleSDK/rmutil all
make[2]: Nothing to be done for `all'.
ld -o rejson.so  /Users/damz/Desktop/rejson/src/json_object.o  /Users/damz/Desktop/rejson/src/json_path.o  /Users/damz/Desktop/rejson/src/json_type.o  /Users/damz/Desktop/rejson/src/object.o  /Users/damz/Desktop/rejson/src/object_type.o  /Users/damz/Desktop/rejson/src/path.o  /Users/damz/Desktop/rejson/src/rejson.o  /Users/damz/Desktop/rejson/src/rmstrndup.o "/Users/damz/Desktop/rejson/src/../deps"/jsonsl/jsonsl.o "/Users/damz/Desktop/rejson/src/../deps"/RedisModuleSDK/rmutil/librmutil.a -dylib -exported_symbol _RedisModule_OnLoad -macosx_version_min 10.6 -lc -lm
ar rcs librejson.a "/Users/damz/Desktop/rejson/src/../deps"/jsonsl/jsonsl.o "/Users/damz/Desktop/rejson/src/../deps"/RedisModuleSDK/rmutil/librmutil.a  /Users/damz/Desktop/rejson/src/json_object.o  /Users/damz/Desktop/rejson/src/json_path.o  /Users/damz/Desktop/rejson/src/json_type.o  /Users/damz/Desktop/rejson/src/object.o  /Users/damz/Desktop/rejson/src/object_type.o  /Users/damz/Desktop/rejson/src/path.o  /Users/damz/Desktop/rejson/src/rejson.o  /Users/damz/Desktop/rejson/src/rmstrndup.o
imac:rejson damz$ redis-server --loadmodule rejson.so
11946:C 25 Oct 12:33:13.216 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
11946:C 25 Oct 12:33:13.216 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=11946, just started
11946:C 25 Oct 12:33:13.216 # Configuration loaded
11946:M 25 Oct 12:33:13.217 * Increased maximum number of open files to 10032 (it was originally set to 256).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 4.0.2 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 11946
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

11946:M 25 Oct 12:33:13.218 # Server initialized
11946:M 25 Oct 12:33:13.218 # Module rejson.so failed to load: dlopen(rejson.so, 6): image not found
11946:M 25 Oct 12:33:13.218 # Can't load module from rejson.so: server aborting
imac:rejson damz$ 

incrementby not working as expected

The incrementby is not working as intended
Please see the following.
I am trying to update a property called total_connected_users by 1 and this property belongs to a object called company. ie. company.total_connected_users
However the command returns a number that is incremented everytime i call it.
However the property of the object never changes.

192.168.1.13:0>JSON.NUMINCRBY 'company' 'total_connected_users' 1
"113"

192.168.1.13:0>JSON.GET 'company' .
"{"total_connected_users":102,"total_sites":46,"domains":{"tubely.com":{"site_id":1,"site_name":"Tubely","site_description":"Tubely - Webchat"},"jhoos.com":{"site_id":2,"site_name":"Jhoos","site_description":"Jhoos - Meet Singles across the world"},"livehealthclub.com":{"site_id":3,"site_name":"Live Health Club","site_description":"LHC- health chat"},"astute.ws":{"site_id":4,"site_name":"Astute","site_description":"Astute Developer Chat"}}}"

Parse error

Hi, tried to feed rejson with this commands:

127.0.0.1:6379> json.set x . '{"crawling": {"1days": {"regionCode": "US", "timeWindow": null, "deltaStart": {"seconds": 3600, "days": 1}, "deltaEnd": {"days": 1}, "order": "viewCount", "minViews": 5000}, "7days": {"regionCode": "US", "timeWindow": null, "deltaStart": {"seconds": 3600, "days": 7}, "deltaEnd": {"days": 7}, "order": "viewCount", "minViews": 5000}}}'
OK
127.0.0.1:6379> json.get x .crawling.1days.regionCode
(error) ERR error parsing path

am i missing something here? is it a bug or a syntax issue?

Make Files do not support folder names with Spaces

When I attempted to build and run the make file, I got an error for a folder not existing. It seemed to cut off my path at a folder which had a space character in it.

I removed the space character and ran the make process again, and everything turned out fine.

Add option to auto-create a path

Is it possible to add an option to auto-create a JSON path in JSON.SET ?

It would be nice to set arbitrary values (e.g. counters for instrumentation) in a tree.

Right now there is no way to do this safely because creating the path using JSON can override existing values.

Example:

JSON.SET test .key1.key2 10 - this fails because .key1 does not exist
JSON.SET test .key1 {} - will create the key but if a .key1.key3 exists it will be destroyed

Truncating doubles

Hi,

The documentation mentions numbers are stored as 64-bit integers or doubles. When I set a key as an array containing a large double, at a certain point it gets truncated. Hopefully I am doing something wrong.

127.0.0.1:6379> json.set test . '[999999999.987654321]'
OK
127.0.0.1:6379> json.get test .
[999999999.98765433]

So far, so good.

127.0.0.1:6379> json.set test . '[1512060373.222988]'
OK
127.0.0.1:6379> json.get test .
[1.512060e+09]

Uh-oh. I thought maybe this is just a display issue, so I queried the key with redis-py, but I get a different value than was I originally set.

In [59]: reply = redis.execute_command('json.get', 'test', '.')
In [60]: print(reply)
[1.512060e+09]
In [61]: json.loads(reply)
Out[61]: [1512060000.0]

Am I simply misunderstanding how things work here, or is there an issue? For the vast majority of the numbers I am storing, there have been no issues with precision, but in this case it's a UNIX timestamp which seems like a reasonable value to store.

Thank you for all your effort!

Troy

ReJson first version

I understand current version is Beta quality (please correct, if that's not true).

What is the roadmap ahead? When do we expect first version, with production ready quality?

Reconsider changing license from AGPL to more liberal one

Hi,

Thanks for the much needed module. I m interested in using this for one of the client project, but the AGPL license is stopping us. Any specific reason for AGPL? Can you consider it changing to at least LGPL if not more liberal one (like MIT, Apache, BSD, ..)? Thanks

Mac Configuration Issues

I was able to clone the repository, install cmake via brew, run the bootstrap.sh file and had no errors when doing so. However, when I explored the lib directory, instead of getting a rejson.so file, the directory had a rejson.dylib. When I attempted run the loadmodule command, I errored out.

$ redis-server /usr/local/etc/redis.conf

*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 181
>>> 'loadmodule /Users/sampastoriza/rejson/lib/rejson.dylib'
Bad directive or wrong number of arguments

Any thoughts on what might be happening here? Is there another location for the rejson.so file? Thanks!

master-slave mode data inconsistency

run below command in master
and data inconsistency in slave

JSON.NUMINCRBY
JSON.ARRAPPEND
JSON.ARRINSERT
JSON.ARRTRIM
JSON.STRAPPEND
JSON.ARRPOP

but there are 2 commands data consistency in slave

JSON.SET
JSON.DEL

env

redis : redis-4.0-rc3
loaded module : both master and slave loaded rejson module
kernal : Linux version 4.8.13-100.fc23.x86_64 ([email protected]) (gcc version 5.3.1 20160406 (Red Hat 5.3.1-6) (GCC) )

Redis standalone mode and ReJSON module crashed

Hi! I tested Redis standalone mode and ReJSON module today (git clone both) and Redis crashed.
CPU: Intel® Core™ i5-6200U CPU @ 2.30GHz × 4, ubuntu 16.04 LTS 64 bit
Allocator: make MALLOC=jemalloc
make test: All tests passed without errors!
I tested memory pass twice (./redis-server --test-memory 4096) but it still crash when i try this command:

127.0.0.1:6379> JSON.SET num . 0
OK
127.0.0.1:6379> JSON.NUMINCRBY num . 1
"1"
127.0.0.1:6379> JSON.NUMINCRBY num . 1.5

=== REDIS BUG REPORT START: Cut & paste starting from here ===
4282:M 30 Mar 15:56:42.536 # Redis 999.999.999 crashed by signal: 11
4282:M 30 Mar 15:56:42.536 # Crashed running the instuction at: 0x7f8aa9ea8664
4282:M 30 Mar 15:56:42.536 # Accessing address: 0x1dcc84a15
4282:M 30 Mar 15:56:42.536 # Failed assertion: (:0)

------ STACK TRACE ------
EIP:
/zserver/rejson/rejson/lib/rejson.so(+0x6664)[0x7f8aa9ea8664]

Backtrace:
./redis-server *:6379(logStackTrace+0x45)[0x463fe5]
./redis-server *:6379(sigsegvHandler+0xb9)[0x4647a9]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f8aac0fb390]
/zserver/rejson/rejson/lib/rejson.so(+0x6664)[0x7f8aa9ea8664]
./redis-server *:6379(RedisModuleCommandDispatcher+0x4f)[0x48c40f]
./redis-server *:6379(call+0xa6)[0x4255d6]
./redis-server *:6379(processCommand+0x3a7)[0x425cd7]
./redis-server *:6379(processInputBuffer+0xfd)[0x4357fd]
./redis-server *:6379(aeProcessEvents+0x128)[0x41f548]
./redis-server *:6379(aeMain+0x2b)[0x41f8eb]
./redis-server *:6379(main+0x495)[0x41c6c5]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f8aabd41830]
./redis-server *:6379(_start+0x29)[0x41c8e9]

------ INFO OUTPUT ------

Server

redis_version:999.999.999
redis_git_sha1:94751543
redis_git_dirty:0
redis_build_id:58fc46a9a4c59ba6
redis_mode:standalone
os:Linux 4.4.0-70-generic x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:5.4.0
process_id:4282
run_id:b891b4865e95bb6bb63477f9c802e5265e4d5ecd
tcp_port:6379
uptime_in_seconds:123
uptime_in_days:0
hz:10
lru_clock:14469194
executable:/zserver/redis/redis/src/./redis-server
config_file:

Clients

connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

Memory

used_memory:890748
used_memory_human:869.87K
used_memory_rss:4501504
used_memory_rss_human:4.29M
used_memory_peak:890748
used_memory_peak_human:869.87K
used_memory_peak_perc:100.16%
used_memory_overhead:884874
used_memory_startup:835116
used_memory_dataset:5874
used_memory_dataset_perc:10.56%
total_system_memory:8248623104
total_system_memory_human:7.68G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:5.05
mem_allocator:libc
active_defrag_running:0
lazyfree_pending_objects:0

Persistence

loading:0
rdb_changes_since_last_save:1
rdb_bgsave_in_progress:0
rdb_last_save_time:1490864079
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:0
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:0

Stats

total_connections_received:1
total_commands_processed:11
instantaneous_ops_per_sec:0
total_net_input_bytes:465
total_net_output_bytes:1102793
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:4
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0

Replication

role:master
connected_slaves:0
master_replid:805e5c6e38edf6ba6453d7f23881ce3d80817bd7
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

CPU

used_cpu_sys:0.14
used_cpu_user:0.07
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

Commandstats

cmdstat_del:calls=1,usec=10,usec_per_call=10.00
cmdstat_command:calls=1,usec=1106,usec_per_call=1106.00

Cluster

cluster_enabled:0

Keyspace

db0:keys=2,expires=0,avg_ttl=0

------ CLIENT LIST OUTPUT ------
id=2 addr=127.0.0.1:50374 fd=6 name= age=96 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=json.numincrby

------ CURRENT CLIENT INFO ------
id=2 addr=127.0.0.1:50374 fd=6 name= age=96 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=json.numincrby
argv[0]: 'JSON.NUMINCRBY'
argv[1]: 'num'
argv[2]: '.'
argv[3]: '1.5'
4282:M 30 Mar 15:56:42.538 # key 'num' found in DB containing the following object:
4282:M 30 Mar 15:56:42.538 # Object type: 5
4282:M 30 Mar 15:56:42.538 # Object encoding: 0
4282:M 30 Mar 15:56:42.538 # Object refcount: 1

------ REGISTERS ------
4282:M 30 Mar 15:56:42.538 #
RAX:00000001dcc84a05 RBX:00000000018a6bc8
RCX:000000000180c918 RDX:00000001dcc84a05
RDI:00007fffab333940 RSI:000000000180c918
RBP:00007fffab333980 RSP:00007fffab333860
R8 :000000000180c910 R9 :3332366436333037
R10:000000000180c900 R11:00007f8aabeb5390
R12:0000000000000000 R13:0000000000000000
R14:00054beedf3356eb R15:000000000000000f
RIP:00007f8aa9ea8664 EFL:0000000000010206
CSGSFS:0000000000000033
4282:M 30 Mar 15:56:42.538 # (00007fffab33386f) -> 00000000018a5ae8
4282:M 30 Mar 15:56:42.538 # (00007fffab33386e) -> 00000000018a5cf8
4282:M 30 Mar 15:56:42.538 # (00007fffab33386d) -> 00000000018a59d8
4282:M 30 Mar 15:56:42.538 # (00007fffab33386c) -> 00000000018a6b7b
4282:M 30 Mar 15:56:42.538 # (00007fffab33386b) -> 00000000018a5a68
4282:M 30 Mar 15:56:42.538 # (00007fffab33386a) -> 3ff0000000000000
4282:M 30 Mar 15:56:42.538 # (00007fffab333869) -> 00000000018a6bab
4282:M 30 Mar 15:56:42.538 # (00007fffab333868) -> 00007fffab3338cf
4282:M 30 Mar 15:56:42.539 # (00007fffab333867) -> ffff800054ccc731
4282:M 30 Mar 15:56:42.539 # (00007fffab333866) -> 0000000000000000
4282:M 30 Mar 15:56:42.539 # (00007fffab333865) -> 00000006ac0e4b70
4282:M 30 Mar 15:56:42.539 # (00007fffab333864) -> 00007f8aac0e4b38
4282:M 30 Mar 15:56:42.539 # (00007fffab333863) -> 00007fffab333990
4282:M 30 Mar 15:56:42.539 # (00007fffab333862) -> 00000000018a5cc8
4282:M 30 Mar 15:56:42.539 # (00007fffab333861) -> 00000004ac0e4b70
4282:M 30 Mar 15:56:42.539 # (00007fffab333860) -> 00007f8aac0e4b38

------ FAST MEMORY TEST ------
4282:M 30 Mar 15:56:42.539 # Bio thread for job type #0 terminated
4282:M 30 Mar 15:56:42.539 # Bio thread for job type #1 terminated
4282:M 30 Mar 15:56:42.539 # Bio thread for job type #2 terminated
*** Preparing to test memory region 6f9000 (90112 bytes)
*** Preparing to test memory region 1800000 (831488 bytes)
*** Preparing to test memory region 7f8aaa0c9000 (8388608 bytes)
*** Preparing to test memory region 7f8aaa8ca000 (8388608 bytes)
*** Preparing to test memory region 7f8aab0cb000 (8388608 bytes)
*** Preparing to test memory region 7f8aac0e6000 (16384 bytes)
*** Preparing to test memory region 7f8aac303000 (16384 bytes)
*** Preparing to test memory region 7f8aac9c1000 (344064 bytes)
*** Preparing to test memory region 7f8aaca37000 (8192 bytes)
*** Preparing to test memory region 7f8aaca3b000 (4096 bytes)
.O.O.O.O.O.O.O.O.O.O
Fast memory test PASSED, however your memory can still be broken. Please run a memory test for several hours if possible.

------ DUMPING CODE AROUND EIP ------
Symbol: (null) (base: (nil))
Module: /zserver/rejson/rejson/lib/rejson.so (base 0x7f8aa9ea2000)
$ xxd -r -p /tmp/dump.hex /tmp/dump.bin
$ objdump --adjust-vma=(nil) -D -b binary -m i386:x86-64 /tmp/dump.bin

=== REDIS BUG REPORT END. Make sure to include from START to END. ===

   Please report the crash by opening an issue on github:

       http://github.com/antirez/redis/issues

Suspect RAM error? Use redis-server --test-memory to verify it.

Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> exit
[1]+ Segmentation fault (core dumped) ./redis-server --loadmodule /zserver/rejson/rejson/lib/rejson.so

ERR unknown command 'JSON.SET'

Installed both Redis and ReJson from source
Make install put redis-server and redis-cli in /usr/local/bin
copied the compiled rejson.so to /usr/local/lib
ran redis-server --loadmodule /usr/local/lib/rejson.so
it gave an error about missing redis-server so i added symbolic link in /usr/bin/redis-server

now when running redis-cli interactively trying out JSON.SET I get an error
looks like the module hasn't loaded ?
please help

Create a Docker Image

Please provide a docker image and a Make target to build and push it, follow (or copy) what we're doing in RediSearch. Also, please send me your docker hub user and I'll provide push access to the repo.

Thanks!

setting a key with expires

The redis node syntax goes this way
client.set(key, value, 'EX', 60 * 60 * 24, callback);

and when i attempt with the json method, i get a ERR wrong number of arguments for 'json.set' command

redis_client.json_set('company', 'total_sites', total_sites,'EX',10, function(e, obj) {
if (e) {
console.log("ERROR happened".red)
console.log(e);
} else {
console.log("Updated Total Sites".green);
}
}); //update site count in redis

[FR] Merge nested types

Consider

> JSON.SET j . '{"foo":"bar"}
OK
> JSON.SET j . '{"ans":42}'
OK
> JSON.GET j
"{\"ans\":42}"

That is SETs expected behavior, so the value at the path is replaced. However. When it comes to objects (and perhaps arrays too), it makes sense to support a merge operation, for example:

> JSON.SET j . '{"foo":"bar"}
OK
> JSON.MERGE j . '{"ans":42}'
OK
> JSON.GET j
"{\"foo\":\"bar\",\"ans\":42}"

Furthermore, this could be augmented with NX, XX for keys-level resolution and possibly other modifiers. Lastly, an MX modifier should be added to `JSON.SET` to expose the same merge functionality.

Building on PowerPC/ppc64le

I'm trying to test if rejson will work on an IBM PowerPC Server. Running make gives me the following message. I'm running this from the ppc64le redis docker image.

make -C ./src all
make[1]: Entering directory '/opt/rejson/src'
make -C "/opt/rejson/src/../deps"/jsonsl static
make[2]: Entering directory '/opt/rejson/deps/jsonsl'
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE -Wall -std=gnu89 -pedantic -O3  -I/opt/rejson/deps/jsonsl -DJSONSL_STATE_GENERIC    -c -o jsonsl.o jsonsl.c
ar rcs libjsonsl.a jsonsl.o
make[2]: Leaving directory '/opt/rejson/deps/jsonsl'
make -C "/opt/rejson/src/../deps"/RedisModuleSDK/rmutil all
make[2]: Entering directory '/opt/rejson/deps/RedisModuleSDK/rmutil'
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o util.o util.c
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o strings.o strings.c
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o sds.o sds.c
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o vector.o vector.c
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o heap.o heap.c
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o priority_queue.o priority_queue.c
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o alloc.o alloc.c
ar rcs librmutil.a util.o strings.o sds.o vector.o heap.o priority_queue.o alloc.o
make[2]: Leaving directory '/opt/rejson/deps/RedisModuleSDK/rmutil'
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o /opt/rejson/src/json_object.o /opt/rejson/src/json_object.c
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o /opt/rejson/src/json_path.o /opt/rejson/src/json_path.c
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o /opt/rejson/src/rejson.o /opt/rejson/src/rejson.c
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o /opt/rejson/src/rmstrndup.o /opt/rejson/src/rmstrndup.c
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o /opt/rejson/src/path.o /opt/rejson/src/path.c
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o /opt/rejson/src/object.o /opt/rejson/src/object.c
/opt/rejson/src/object.c: In function 'Node_Print':
/opt/rejson/src/object.c:506:13: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int64_t' [-Wformat=]
             printf("%lld", n->value.intval);
             ^
/opt/rejson/src/object.c: In function 'Node_Serializer':
/opt/rejson/src/object.c:597:57: warning: 'curr_entries' may be used uninitialized in this function [-Wmaybe-uninitialized]
                     _serializerPush(&stack, curr_entries[curr_index]);
                                                         ^
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o /opt/rejson/src/print_version.o /opt/rejson/src/print_version.c
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o /opt/rejson/src/object_type.o /opt/rejson/src/object_type.c
/opt/rejson/src/object_type.c: In function 'ObjectTypeRdbLoad':
/opt/rejson/src/object_type.c:42:17: warning: 'type' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 switch (type) {
                 ^
cc -I"/opt/rejson/src" -I""/opt/rejson/src/../deps"/jsonsl"  -I""/opt/rejson/src/../deps"/RedisModuleSDK/rmutil" -Wall -g -ggdb -O2 -fPIC -std=gnu99  -D_GNU_SOURCE   -c -o /opt/rejson/src/json_type.o /opt/rejson/src/json_type.c
ld -o rejson.so  /opt/rejson/src/json_object.o  /opt/rejson/src/json_path.o  /opt/rejson/src/rejson.o  /opt/rejson/src/rmstrndup.o  /opt/rejson/src/path.o  /opt/rejson/src/object.o  /opt/rejson/src/print_version.o  /opt/rejson/src/object_type.o  /opt/rejson/src/json_type.o "/opt/rejson/src/../deps"/jsonsl/jsonsl.o "/opt/rejson/src/../deps"/RedisModuleSDK/rmutil/librmutil.a -shared -Bsymbolic -Bsymbolic-functions -lc -lm
ar rcs librejson.a "/opt/rejson/src/../deps"/jsonsl/jsonsl.o "/opt/rejson/src/../deps"/RedisModuleSDK/rmutil/librmutil.a  /opt/rejson/src/json_object.o  /opt/rejson/src/json_path.o  /opt/rejson/src/rejson.o  /opt/rejson/src/rmstrndup.o  /opt/rejson/src/path.o  /opt/rejson/src/object.o  /opt/rejson/src/print_version.o  /opt/rejson/src/object_type.o  /opt/rejson/src/json_type.o
make[1]: Leaving directory '/opt/rejson/src'
root@cbc6f21b4e9e:/opt/rejson# make
make -C ./src all
make[1]: Entering directory '/opt/rejson/src'
make -C "/opt/rejson/src/../deps"/jsonsl static
make[2]: Entering directory '/opt/rejson/deps/jsonsl'
ar rcs libjsonsl.a jsonsl.o
make[2]: Leaving directory '/opt/rejson/deps/jsonsl'
make -C "/opt/rejson/src/../deps"/RedisModuleSDK/rmutil all
make[2]: Entering directory '/opt/rejson/deps/RedisModuleSDK/rmutil'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/opt/rejson/deps/RedisModuleSDK/rmutil'
ld -o rejson.so  /opt/rejson/src/path.o  /opt/rejson/src/json_object.o  /opt/rejson/src/json_path.o  /opt/rejson/src/rejson.o  /opt/rejson/src/rmstrndup.o  /opt/rejson/src/object.o  /opt/rejson/src/print_version.o  /opt/rejson/src/object_type.o  /opt/rejson/src/json_type.o "/opt/rejson/src/../deps"/jsonsl/jsonsl.o "/opt/rejson/src/../deps"/RedisModuleSDK/rmutil/librmutil.a -shared -Bsymbolic -Bsymbolic-functions -lc -lm
ar rcs librejson.a "/opt/rejson/src/../deps"/jsonsl/jsonsl.o "/opt/rejson/src/../deps"/RedisModuleSDK/rmutil/librmutil.a  /opt/rejson/src/path.o  /opt/rejson/src/json_object.o  /opt/rejson/src/json_path.o  /opt/rejson/src/rejson.o  /opt/rejson/src/rmstrndup.o  /opt/rejson/src/object.o  /opt/rejson/src/print_version.o  /opt/rejson/src/object_type.o  /opt/rejson/src/json_type.o
make[1]: Leaving directory '/opt/rejson/src'

Inconsistent database state

Hi,

I was using rejson for an application I'm working on and ran into an issue where calling json.get returns different child values based on how far up the parent chain I am. I'm not sure how to explain well so here's an album to show you what I'm talking about:

imgur

The issue is when I do json.get queues JAYD, connected_users is populated; however, when I do json.get queues JAYD.connected_users it returns an empty array. The correct behavior, I think, should have been that it returns an empty array since I called json.arrpop on the array.

Let me know if you need more information!

JSONPath for array search

Raising here, as didn't know from where to get better support on documentation.

As part of evaluating ReJson for our project, trying to understand JSON Search capability with Array.

Tried following commands to create an Array:

JSON.SET acc_requests . '[]'
JSON.ARRAPPEND acc_requests . '{ "seqId" : "1", "accountId" : "ACCT_001", "balance" : 1001.1 }'
JSON.ARRAPPEND acc_requests . '{ "seqId" : "2", "accountId" : "ACCT_002", "balance" : 2002.2 }'
JSON.GET acc_requests .

Now I want to search for JSON document containing seqId as "2"

Tried using following syntax as per JSONPath syntax:

JSON.GET acc_requests '[?(@.seqId == "2")]'

But getting following error:

(error) ERR Search path error at offset 2: square brackets can only contain integers, single- or double-quoted strings

What am I doing wrong here? How can I access JSON document with search criteria?

Also, how can I apply AND / OR condition while searching document in an array?
For example, Getting a document that contains "seqId" = "2" OR "balance" > 1001

JSON Path documentation here doesn't talk much about capabilities supported for now (or expected in future) and no examples too. Further clarity will be appreciated.

Thanks in advance!

key with dash not working

Hi - fantastic project, thanks for building it.

I found that if I set an object with a dash in the key, I cannot retrieve it.

127.0.0.1:6379> JSON.SET dash . '{"d-1" : "test"}'
OK
127.0.0.1:6379> JSON.GET dash
"{\"d-1\":\"test\"}"
127.0.0.1:6379> JSON.GET dash . "d-1"
(error) ERR Search path error at offset 2: an identifier can only contain letters, digits, dollar signs or underscores - use bracket notation for anything else
127.0.0.1:6379> JSON.GET dash . ["d-1"]
Invalid argument(s)
127.0.0.1:6379> JSON.GET dash .["d-1"]
Invalid argument(s)
127.0.0.1:6379> JSON.GET dash ["d-1"]
Invalid argument(s)
127.0.0.1:6379> JSON.GET dash ."d-1"
(error) ERR Search path error at offset 3: an identifier can only contain letters, digits, dollar signs or underscores - use bracket notation for anything else

Am I doing something wrong or is this bug?
Cheers

Question: Can you timeout stored values somehow?

Installation and compilation on Mac went without a hitch. It took me a while to figure out how to send commands from node_redis driver but I got that working too. So far, very pleased with this project.

Is there a way to timeout/expire or otherwise remove the value after certain amount of time?

JSON.SET foo . '"bar"' I would want this document to be purged after say 20 min.

[Crash] JSON.GET with empty key

Hi, I've found that empty path key crashes Redis server
I think this issue is related with #13

127.0.0.1:6379> JSON.SET foo . '{"bar":{"baz":42}}'
OK
127.0.0.1:6379> json.get foo .bar.
Could not connect to Redis at 127.0.0.1:6379: Connection refused

Crash report: redis_error.log

Publish docker image based on specific image

It would be nice if you would deploy new docker images as part of the CI process. Also including publishing images based on the alpine version of redis -> for easy production usage

rejson.so on ubuntu Ubuntu 16.04.3 LTS

After running make the rejson.so is generated fine
However on including it in redis.conf, redis server does not start

[....] Starting redis-server (via systemctl): redis-server.serviceJob for redis-server.service failed because the control process exited with error code. See "systemctl status redis-server.service" and "journalctl -xe" for details.
failed!

Build a include and expand feature into the ReJson module to fetch parts of large JSON documents

Overview:
The spec is for building the include feature into the ReJson module.

Purpose:
• This would reduce the amount of data transferred sent from redis.
• This would push more computation into redis.

Description:
• We have large documents in redis that we trim or expand certain attributes and send it out over the wire. For e.g.,
1. if you have a document in redis: key1: {'a':'1', 'b':'1', 'c':'1'}, if the user requests only for attribute 'a','c' for 'key1', the output from the module should be {'a':'1', 'c':'1'}.
• We use Redis for storing very large json documents, we need this feature for pulling subparts of the document and this would cut down the amount of data transferred. This would eliminate the need for having json parsing and composing on the service code.

Product Experience:

USE CASES:
1. This feature will be very useful for retrieving parts of large json document in one redis call.

Product Support
We would like to measure the time difference between json parsing and json composition.

Error in JSON.MGET documentation

In the docs it says the MGET command's syntax is like this:

JSON.MGET <key> [key ...] <path>

While in reality, <path> goes first:

JSON.MGET <path> <key> [key ...]

Bug report using rejson module

1:C 21 Feb 06:10:59.107 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 21 Feb 06:10:59.107 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 21 Feb 06:10:59.107 # Configuration loaded
1:M 21 Feb 06:10:59.107 * Running mode=standalone, port=6379.
1:M 21 Feb 06:10:59.107 # Server initialized
1:M 21 Feb 06:10:59.107 # JSON data type for Redis v1.0.1 [encver 0]
1:M 21 Feb 06:10:59.107 * Module 'ReJSON' loaded from /usr/lib/redis/modules/rejson.so
1:M 21 Feb 06:10:59.107 * Ready to accept connections

=== REDIS BUG REPORT START: Cut & paste starting from here ===
*** Error in `redis-server *:6379': free(): invalid pointer: 0x0000000000b704d4 ***
1:M 21 Feb 06:15:27.891 # Redis 4.0.1 crashed by signal: 11
1:M 21 Feb 06:15:27.891 # Crashed running the instuction at: 0x7f29e1682532
1:M 21 Feb 06:15:27.891 # Accessing address: (nil)
1:M 21 Feb 06:15:27.891 # Failed assertion: (:0)

------ STACK TRACE ------
EIP:
/lib/x86_64-linux-gnu/libc.so.6(abort+0x232)[0x7f29e1682532]

Backtrace:
redis-server *:6379(logStackTrace+0x29)[0x467a89]
redis-server *:6379(sigsegvHandler+0xa6)[0x468126]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xf890)[0x7f29e1a06890]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x232)[0x7f29e1682532]
/lib/x86_64-linux-gnu/libc.so.6(+0x731b4)[0x7f29e16bf1b4]
/lib/x86_64-linux-gnu/libc.so.6(+0x7898e)[0x7f29e16c498e]
/lib/x86_64-linux-gnu/libc.so.6(+0x79696)[0x7f29e16c5696]
/usr/lib/redis/modules/rejson.so(+0x6465)[0x7f29df7e8465]

------ INFO OUTPUT ------

Server

redis_version:4.0.1
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:ac6c9ffb15b04a74
redis_mode:standalone
os:Linux 4.9.60-linuxkit-aufs x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.9.2
process_id:1
run_id:80ed610f3db494ed197698d0960071111c1e4b71
tcp_port:6379
uptime_in_seconds:268
uptime_in_days:0
hz:10
lru_clock:9244287
executable:/data/redis-server
config_file:

Clients

connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

Memory

used_memory:1217928
used_memory_human:1.16M
used_memory_rss:4640768
used_memory_rss_human:4.43M
used_memory_peak:1217928
used_memory_peak_human:1.16M
used_memory_peak_perc:100.53%
used_memory_overhead:825590
used_memory_startup:765592
used_memory_dataset:392338
used_memory_dataset_perc:86.74%
total_system_memory:6246981632
total_system_memory_human:5.82G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:3.81
mem_allocator:jemalloc-4.0.3
active_defrag_running:0
lazyfree_pending_objects:0

Persistence

loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1519193459
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:0
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:0

Stats

total_connections_received:2
total_commands_processed:1062
instantaneous_ops_per_sec:73
total_net_input_bytes:165284
total_net_output_bytes:210320
instantaneous_input_kbps:10.91
instantaneous_output_kbps:12.67
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:618
keyspace_misses:208
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0

Replication

role:master
connected_slaves:0
master_replid:02d014ce08a9b63bdcd5878a45d17f59f3e8509b
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

CPU

used_cpu_sys:0.19
used_cpu_user:0.08
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

Commandstats

cmdstat_select:calls=3,usec=3,usec_per_call=1.00
cmdstat_info:calls=3,usec=106,usec_per_call=35.33

Cluster

cluster_enabled:0

Keyspace

db2:keys=208,expires=0,avg_ttl=0

------ CLIENT LIST OUTPUT ------
id=3 addr=172.17.0.1:39676 fd=8 name= age=41 idle=0 flags=N db=2 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=json.set

------ CURRENT CLIENT INFO ------
id=3 addr=172.17.0.1:39676 fd=8 name= age=41 idle=0 flags=N db=2 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=json.set
argv[0]: 'JSON.SET'
argv[1]: 'calendar:745fcaf2-3507-4843-8f5a-0d63495f419d'
argv[2]: '.'
argv[3]: '{"events":[{"start":"2018-02-01T09:30:00.000Z","end":"2018-02-01T10:00:00.000Z","resources":{"places":{"qty":12,"use":12},"adults":{"qty":10,"use":10},"children":{"qty":2,"use":2},"infants":{"qty":2}}},{"start":"2018-02-01T09:00:00.000Z","end":"2018-02-01T09:30:00.000Z","resources":{"places":{"qty":12,"use":12},"adults":{"qty":10,"use":10},"children":{"qty":2,"use":2},"infants":{"qty":2}}},{"start":"2018-02-01T10:00:00.000Z","end":"2018-02-01T10:30:00.000Z","resources":{"places":{"qty":12,"use":12},"adults":{"qty":10,"use":10},"children":{"qty":2,"use":2},"infants":{"qty":2}}}]}'

------ REGISTERS ------
1:M 21 Feb 06:15:27.892 #
RAX:0000000000000006 RBX:0000000000000054
RCX:00007f29e1681067 RDX:0000000000000006
RDI:0000000000000001 RSI:0000000000000001
RBP:00007ffdba2112a0 RSP:00007ffdba210f10
R8 :0000000000000000 R9 :00007ffdba210e60
R10:0000000000000008 R11:0000000000000202
R12:00007ffdba2110b0 R13:0000000000000007
R14:0000000000000054 R15:0000000000000007
RIP:00007f29e1682532 EFL:0000000000010246
CSGSFS:002b000000000033
1:M 21 Feb 06:15:27.892 # (00007ffdba210f1f) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f1e) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f1d) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f1c) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f1b) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f1a) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f19) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f18) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f17) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f16) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f15) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f14) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f13) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f12) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f11) -> 0000000000000000
1:M 21 Feb 06:15:27.892 # (00007ffdba210f10) -> 0000000000000020

------ FAST MEMORY TEST ------
1:M 21 Feb 06:15:27.892 # Bio thread for job type #0 terminated
1:M 21 Feb 06:15:27.892 # Bio thread for job type #1 terminated
1:M 21 Feb 06:15:27.893 # Bio thread for job type #2 terminated
*** Preparing to test memory region 752000 (94208 bytes)
*** Preparing to test memory region b47000 (266240 bytes)
*** Preparing to test memory region 7f29df9fe000 (8388608 bytes)
*** Preparing to test memory region 7f29e01ff000 (8388608 bytes)
*** Preparing to test memory region 7f29e0a00000 (12582912 bytes)
*** Preparing to test memory region 7f29e19f3000 (16384 bytes)
*** Preparing to test memory region 7f29e1c10000 (16384 bytes)
*** Preparing to test memory region 7f29e2330000 (24576 bytes)
*** Preparing to test memory region 7f29e2336000 (12288 bytes)
*** Preparing to test memory region 7f29e233b000 (4096 bytes)
.O.O.O.O.O.O.O.O.O.O
Fast memory test PASSED, however your memory can still be broken. Please run a memory test for several hours if possible.

------ DUMPING CODE AROUND EIP ------
Symbol: abort (base: 0x7f29e1682300)
Module: /lib/x86_64-linux-gnu/libc.so.6 (base 0x7f29e164c000)
$ xxd -r -p /tmp/dump.hex /tmp/dump.bin
$ objdump --adjust-vma=0x7f29e1682300 -D -b binary -m i386:x86-64 /tmp/dump.bin

1:M 21 Feb 06:15:27.955 # dump of function (hexdump of 690 bytes):
4881ec2801000064488b142510000000483b15010937007434be0100000031c0833dad443700007410f00fb135df0837000f8510020000eb0d0fb135d00837000f8501020000488915cb0837008b05cd0837008305ba0837000185c0744583f801747983f8020f849000000083f803900f841f01000083f8040f847201000083f8050f848701000083f8060f84a101000083f8070f8499010000660f1f440000f4ebfd31c0b9100000004889e7f348ab31d24889e6bf01000000c7055c0837000100000048c7042420000000e82fefffff8b054908370083f801758731ffc7053808370002000000e8930304008b052d08370083f8020f8570ffffff832d1108370001c7051308370000000000752f48c705fe07370000000000833db343370000740ff0ff0de60737000f8536010000eb0cff0dd80737000f8528010000bf06000000e8e8ebffff64488b142510000000483b15c00737007434be0100000031c0833d6c433700007410f00fb1359e0737000f850d010000eb0d0fb1358f0737000f85fe0000004889158a07370083057f07370001488d942480000000b91300000031c0c70572073700040000004889d7488db280000000f348ab48c706ffffffff4883ee084839d675f031d2bf06000000c784240801000000000000e8feedffff8b053807370083f8040f858efeffffc7052507370005000000e8b0c203008b051a07370083f8050f8579feffffbf06000000c7050207370006000000e80debffff8b05f706370083f8060f855ffefffff4bf7f000000c705de06370008000000e8693d0800488d3dc20637004881ec80000000e836e60b004881c480000000e9e0fdffff488d3da30637004881ec80000000e847e60b004881c480000000e9b9feffff488d3d840637004881ec80000000e8f8e50b004881c480000000e9e3feffff662e0f1f84000000000066904157
Function at 0x7f29e1681300 is sigprocmask
Function at 0x7f29e1681030 is gsignal
Function at 0x7f29e16812e0 is sigaction
Function at 0x7f29e16be7b0 is fcloseall
Function at 0x7f29e17062b0 is _exit

=== REDIS BUG REPORT END. Make sure to include from START to END. ===

   Please report the crash by opening an issue on github:

       http://github.com/antirez/redis/issues

Docker image does not persist RDB file in /data

When I use the docker image redislabs/rejson:latest the data does not persist between restarts of the docker container. See below docker-compose file.

Using this docker-compose, Redis launches with the rejson module loaded, but it does not persist the data to disk on container shutdown.

version: '3'
services:
  redis:
    container_name: redis
    image: redislabs/rejson:latest
    volumes:
      - ./volumes/redis:/data
    ports:
      - "6379:6379"

Everything works fine when I use the "redis" Docker image - I clearly see the message "Saving the final RDB snapshot before exiting" after I issue the "docker stop" command. The RDB file appears in ./volumes/redis director as I would expect.

Behavior is as expected when I start/stop the docker image using the following docker-compose file

version: '3'
services:
  redis:
    container_name: redis
    image: redis
    volumes:
      - ./volumes/redis:/data
    ports:
      - "6379:6379"

Please advise if there is something additional that needs to be done so the rejson docker image persists data on container shutdown.

AOF is not working when using LUA scripts with REJSON commands

used docker file https://github.com/idoko/docker-rejson to create the setup.

docker run -v ~/Work/test_rejson:/data --name rj redis-json:latest
docker exec -it rj redis-cli
127.0.0.1:6379> json.set my_var "." '{"a":1}'
OK
127.0.0.1:6379> EVAL "redis.call('json.set', KEYS[1],'.',ARGV[1])" 1 'my_var' '{"b":2}'
"{\"b\":2}"
(nil)
127.0.0.1:6379> json.get my_var
"{\"b\":2}"

now after that i stop the container

docker stop rj

run it again

docker start rj

and now :

docker exec -it rj redis-cli
127.0.0.1:6379> json.get my_var
"{\"a\":1}"

which mean the AOF is not working when using lua scripts.
for me its critical issue since i'm looking for the persistence offered by AOF + I need the Atomic ability to get/set the data given by LUA script.

any idea how to solve the issue? any workaround?

unicode support in rejson

I'm trying to store a json with some chinese character in redis with rejson like this:

127.0.0.1:6379> JSON.SET test . '{"key":"测试"}'
OK
127.0.0.1:6379> JSON.GET test .key
"\u00e6\u00b5\u008b\u00e8\u00af\u0095"
127.0.0.1:6379> SET test2 "测试"
OK
127.0.0.1:6379> GET test2 
测试
127.0.0.1:6379> 

As you can see the value "测试" convert to "\u00e6\u00b5\u008b\u00e8\u00af\u0095" when using JSON.GET... It looks like rejson didn't support unicode yet...

Float Point Precision

AFAIK, float point in redis is stored as 64 bit ieee float, but when I try to retrieve a float point value stored in a JSON field, it seems to lose precision, or is automatically rounded:

127.0.0.1:6380[7]> json.set world . 1.33333333
OK
127.0.0.1:6380[7]> json.get world .
"1.33333"
127.0.0.1:6380[7]> set hello 1.33333333
OK
127.0.0.1:6380[7]> get hello
"1.33333333"

Is this expected behavior?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.