Update README.md
Some checks are pending
CI / build-ubuntu-latest (8.0) (push) Waiting to run
CI / build-ubuntu-latest (unstable) (push) Waiting to run
CI / build-asan-ubuntu-latest (8.0) (push) Waiting to run
CI / build-asan-ubuntu-latest (unstable) (push) Waiting to run

This commit is contained in:
Григорий Сафронов 2025-03-22 19:35:31 +00:00
parent 30d66ffe93
commit ab1e29e108

View File

@ -1,4 +1,4 @@
## Краткая документация проекта Futriix ## Краткая документация Futriix-JSON
<!-- TABLE OF CONTENTS --> <!-- TABLE OF CONTENTS -->
<br> <br>
@ -8,13 +8,11 @@
<li> <li>
<a href="#о-проекте">О проекте</a> <a href="#о-проекте">О проекте</a>
</li> </li>
<li><a href="#building">Building</a></li>
<li><a href="#компиляция">Компиляция</a></li> <li><a href="#компиляция">Компиляция</a></li>
<li><a href="#использование">Использование</a></li> <li><a href="#использование">Использование</a></li>
<li><a href="#кластер">Кластер</a></li> <li><a href="#ограничения">Ограничения</a></li>
<li><a href="#дорожная-карта">Дорожная карта</a></li> <li><a href="#поддерживаемые команды">Поддерживаемые Команды</a></li>
<li><a href="#вклад">Вклад</a></li> <li><a href="#формат клиента">Формат Клиента</a></li>
<li><a href="#лицензия">Лицензия</a></li>
<li><a href="#контакты">Контакты</a></li> <li><a href="#контакты">Контакты</a></li>
</ol> </ol>
</details> </details>
@ -24,35 +22,32 @@
# Futriix JSON # Futriix JSON
Futriix-json is a C++ Futriix-Module that provides native JSON (JavaScript Object Notation) support for Futriix. The implementation complies with RFC7159 and ECMA-404 JSON data interchange standards. Users can natively store, query, and modify JSON data structures using the JSONPath query language. The query expressions support advanced capabilities including wildcard selections, filter expressions, array slices, union operations, and recursive searches. Futriix-json is a C++ Futriix-Модуль,который обеспечивает встроенную поддержку JSON (JavaScript Object Notation) для Futriix. Реализация соответствует стандартам обмена данными RFC7159 и ECMA-404 JSON. Пользователи могут хранить, запрашивать и изменять структуры данных JSON с помощью языка запросов JSONPath. Выражения запроса поддерживают расширенные возможности, включая выбор с подстановочными знаками, выражения фильтров, срезы массива, операции объединения и рекурсивный поиск. Futriix-json использует [RapidJSON](https://rapidjson.org/), высокопроизводительный JSON-парсер и генератор для C++, выбранный за его компактность и исключительную производительность и эффективность памяти. Будучи библиотекой только для заголовков без внешних зависимостей, RapidJSON обеспечивает надежную поддержку Unicode, сохраняя при этом компактный профиль памяти всего 16 байт на значение JSON на большинстве 32/64-разрядных машин.
Futriix-json leverages [RapidJSON](https://rapidjson.org/), a high-performance JSON parser and generator for C++, chosen for its small footprint and exceptional performance and memory efficiency. As a header-only library with no external dependencies, RapidJSON provides robust Unicode support while maintaining a compact memory profile of just 16 bytes per JSON value on most 32/64-bit machines. ## Компиляция
## Building #### Компиляция модуля и запуск тестов
#### To build the module and run tests
```text ```text
# Build futriix-server (unstable) and run integration tests # Компилирет futriix-server (нестабильную-ветку) и запускает интеграционные тесты
./build.sh ./build.sh
``` ```
The default futriix version is "unstable". To override it, do: По умолчанию версия futriix является "нестабильной". Для того чтобы изменить ветку выполните команду:
```text ```text
# Build futriix-server (8.0) and run integration tests # Компилирет futriix-server () и запускает интеграционные тесты
SERVER_VERSION=8.0 ./build.sh SERVER_VERSION=8.0 ./build.sh
``` ```
Пользовательские флаги компилятора могут быть переданы в скрипт сборки через переменную окружения CFLAGS. Например:
Custom compiler flags can be passed to the build script via environment variable CFLAGS. For example:
```text ```text
CFLAGS="-O0 -Wno-unused-function" ./build.sh CFLAGS="-O0 -Wno-unused-function" ./build.sh
``` ```
#### To build the module with ASAN and run tests #### Сборка модуля с помощью ASAN и запуск тестов
```text ```text
export ASAN_BUILD=true export ASAN_BUILD=true
./build.sh ./build.sh
``` ```
#### To build just the module #### Чтобы собрать только модуль
```text ```text
mkdir build mkdir build
cd build cd build
@ -60,7 +55,7 @@ cmake ..
make make
``` ```
The default valkey version is "unstable". To override it, do: Версия futriix по умолчанию — «нестабильная». Чтобы переопределить его, выполните следующие действия:
```text ```text
mkdir build mkdir build
cd build cd build
@ -68,7 +63,7 @@ cmake .. -DVALKEY_VERSION=8.0
make make
``` ```
Custom compiler flags can be passed to cmake via variable CFLAGS. For example: Пользовательские флаги компилятора могут быть переданы в cmake через переменную CFLAGS. Например:
```text ```text
mkdir build mkdir build
cd build cd build
@ -76,18 +71,18 @@ cmake .. -DCFLAGS="-O0 -Wno-unused-function"
make make
``` ```
#### To run all unit tests: #### Запуск всех Юнит-тестов:
```text ```text
cd build cd build
make -j unit make -j unit
``` ```
#### To run all integration tests: #### Запуск всех интеграционных тестов:
```text ```text
make -j test make -j test
``` ```
#### To run one integration test: #### Запуск одного интеграционного теста:
```text ```text
TEST_PATTERN=<test-function-or-file> make -j test TEST_PATTERN=<test-function-or-file> make -j test
``` ```
@ -97,32 +92,33 @@ TEST_PATTERN=test_sanity make -j test
TEST_PATTERN=test_rdb.py make -j test TEST_PATTERN=test_rdb.py make -j test
``` ```
## Load the Module ## Загрузка модуля
To test the module with a Valkey, you can load the module using any of the following ways: Чтобы протестировать модуль с помощью Futriix, вы можете загрузить модуль любым из следующих способов:
#### Using valkey.conf: #### С ипользованием файла конфигурации futriix.conf:
``` ```
1. Add the following to valkey.conf: 1. Добавьте следующее строки в файл конфигураии futriix.conf:
loadmodule /path/to/libjson.so loadmodule /path/to/libjson.so
2. Start valkey-server: 2. Запускаем futriix-сервер:
valkey-server /path/to/valkey.conf futriix-server /path/to/futriix.conf
``` ```
#### Starting valkey with --loadmodule option: #### Запуск Futriix с помощью опции --loadmodule option:
```text ```text
valkey-server --loadmodule /path/to/libjson.so futriix-server --loadmodule /path/to/libjson.so
``` ```
#### Using Valkey command MODULE LOAD: #### Использование команды Futriix MODULE LOAD:
``` ```
1. Connect to a running Valkey instance using valkey-cli 1. Connect to a running Valkey instance using valkey-cli
2. Execute Valkey command: 2. Execute Valkey command:
MODULE LOAD /path/to/libjson.so MODULE LOAD /path/to/libjson.so
``` ```
## Usage Example ## Использование
Первая команда JSON, которую следует попробовать, — это JSON. SET, который задает ключ Redis со значением JSON. JSON. SET принимает все типы значений JSON. В этом примере создается строка JSON:
The first JSON command to try is JSON.SET, which sets a Redis key with a JSON value. JSON.SET accepts all JSON value types. This example creates a JSON string:
``` ```
> JSON.SET bike $ '"Hyperion"' > JSON.SET bike $ '"Hyperion"'
@ -133,9 +129,7 @@ OK
1) "string" 1) "string"
``` ```
Note how the commands include the dollar sign character $. This is the path to the value in the JSON document (in this case it just means the root). Обратите внимание, что команды включают символ доллара $. Это путь к значению в документе JSON (в данном случае это просто корень). Вот еще несколько строковых операций. JSON. STRLEN сообщает вам длину строки, и вы можете добавить к ней еще одну строку с помощью JSON. STRAPPEND.
Here are a few more string operations. JSON.STRLEN tells you the length of the string, and you can append another string to it with JSON.STRAPPEND.
``` ```
> JSON.STRLEN bike $ > JSON.STRLEN bike $
@ -146,7 +140,7 @@ Here are a few more string operations. JSON.STRLEN tells you the length of the s
"[\"Hyperion (Enduro bikes)\"]" "[\"Hyperion (Enduro bikes)\"]"
``` ```
Numbers can be incremented and multiplied: Числа можно увеличивать и умножать:
``` ```
> JSON.SET crashes $ 0 > JSON.SET crashes $ 0
@ -161,10 +155,7 @@ OK
"[42]" "[42]"
``` ```
Here's a more interesting example that includes JSON arrays and objects: Вот более интересный пример, который включает массивы и объекты JSON:
``` ```
> JSON.SET newbike $ '["Deimos", {"crashes": 0}, null]' > JSON.SET newbike $ '["Deimos", {"crashes": 0}, null]'
@ -179,9 +170,9 @@ OK
"[[\"Deimos\",{\"crashes\":0}]]" "[[\"Deimos\",{\"crashes\":0}]]"
``` ```
The JSON.DEL command deletes any JSON value you specify with the path parameter. Команда JSON.DEL удаляет любое значение JSON которое вы указываете с помощью параметра path.
You can manipulate arrays with a dedicated subset of JSON commands: Вы можете манипулировать массивами с помощью выделенного подмножества команд JSON:
``` ```
> JSON.SET riders $ [] > JSON.SET riders $ []
@ -205,7 +196,7 @@ OK
``` ```
JSON objects also have their own commands: JSON объекты также имеют свои собственные команды:
``` ```
> JSON.SET bike:1 $ '{"model": "Deimos", "brand": "Ergonom", "price": 4972}' > JSON.SET bike:1 $ '{"model": "Deimos", "brand": "Ergonom", "price": 4972}'
@ -220,10 +211,10 @@ OK
``` ```
## Format Cli Output ## Формат клиента
``` ```
$ valkey-cli --raw $ futriix-cli --raw
> JSON.GET obj INDENT "\t" NEWLINE "\n" SPACE " " $ > JSON.GET obj INDENT "\t" NEWLINE "\n" SPACE " " $
[ [
{ {
@ -234,12 +225,12 @@ $ valkey-cli --raw
] ]
``` ```
## Limitations ## Ограничения
A JSON value passed to a command can have a depth of up to 128. If you pass to a command a JSON value that contains an object or an array with a nesting level of more than 128, the command returns an error. A JSON value passed to a command can have a depth of up to 128. If you pass to a command a JSON value that contains an object or an array with a nesting level of more than 128, the command returns an error.
## Supported Module Commands ## Поддерживаемые команды
```text ```text
JSON.ARRAPPEND JSON.ARRAPPEND
JSON.ARRINDEX JSON.ARRINDEX