rida-format 2.0.0__tar.gz → 2.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rida_format-2.0.0 → rida_format-2.0.2}/CHANGELOG.md +14 -0
- {rida_format-2.0.0/src/rida_format.egg-info → rida_format-2.0.2}/PKG-INFO +262 -56
- {rida_format-2.0.0 → rida_format-2.0.2}/RIDA-README.md +260 -53
- {rida_format-2.0.0 → rida_format-2.0.2}/pyproject.toml +2 -7
- {rida_format-2.0.0 → rida_format-2.0.2}/src/rida/__init__.py +9 -10
- {rida_format-2.0.0 → rida_format-2.0.2}/src/rida/_encryption.py +5 -5
- {rida_format-2.0.0 → rida_format-2.0.2/src/rida_format.egg-info}/PKG-INFO +262 -56
- {rida_format-2.0.0 → rida_format-2.0.2}/src/rida_format.egg-info/requires.txt +0 -2
- {rida_format-2.0.0 → rida_format-2.0.2}/LICENSE +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/MANIFEST.in +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/RIDA-FORMAT.md +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/docs/rida-metadata.html +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/setup.cfg +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/src/rida/__main__.py +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/src/rida_format.egg-info/SOURCES.txt +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/src/rida_format.egg-info/dependency_links.txt +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/src/rida_format.egg-info/entry_points.txt +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/src/rida_format.egg-info/top_level.txt +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/tests/fixture_spec.py +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/tests/fixtures/golden-source-dictionary.json +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/tests/fixtures/golden-source-sequential.json +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/tests/fixtures/golden-v1-dictionary-denseData.rida +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/tests/fixtures/golden-v1-dictionary-denseIndex.rida +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/tests/fixtures/golden-v1-dictionary-sparseData.rida +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/tests/fixtures/golden-v1-dictionary-sparseIndex.rida +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/tests/fixtures/golden-v1-sequential-denseData.rida +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/tests/fixtures/golden-v1-sequential-denseIndex.rida +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/tests/fixtures/golden-v1-sequential-sparseData.rida +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/tests/fixtures/golden-v1-sequential-sparseIndex.rida +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/tests/make_fixtures.py +0 -0
- {rida_format-2.0.0 → rida_format-2.0.2}/tests/test_rida.py +0 -0
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.2 — Encryption included in the default install
|
|
4
|
+
|
|
5
|
+
- Made cryptography a required dependency so pip install rida-format includes encryption support.
|
|
6
|
+
- Removed the separate encryption extra from install instructions.
|
|
7
|
+
- The RIDA data format and encryption algorithm are unchanged.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 2.0.1 — Encrypted delivery and application examples
|
|
11
|
+
|
|
12
|
+
- Added direct encrypted CDN delivery guidance and server-only key handling.
|
|
13
|
+
- Added detailed product catalogue and multilingual help-centre examples.
|
|
14
|
+
- Clarified whole-field reads, nested values, map lookup, and multi-field requests.
|
|
15
|
+
- Updated documentation and package numbering; the data format is unchanged.
|
|
16
|
+
|
|
3
17
|
All notable changes to the RIDA library and container format.
|
|
4
18
|
|
|
5
19
|
## 2.0.0 — Aligned release numbering
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rida-format
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: Range Indexed Data Access (RIDA) static data format and library
|
|
5
5
|
Author: Syed Ali Hamza Chishty
|
|
6
6
|
Maintainer-email: Qasra Foundation <admin@qasra.org>
|
|
@@ -19,11 +19,10 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
19
19
|
Requires-Python: >=3.10
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
License-File: LICENSE
|
|
22
|
-
|
|
23
|
-
Requires-Dist: cryptography>=42.0; extra == "encryption"
|
|
22
|
+
Requires-Dist: cryptography>=42.0
|
|
24
23
|
Dynamic: license-file
|
|
25
24
|
|
|
26
|
-
# RIDA Python library — 2.0.
|
|
25
|
+
# RIDA Python library — 2.0.2
|
|
27
26
|
|
|
28
27
|
RIDA means **Range Indexed Data Access**. It is an installable Python library
|
|
29
28
|
and terminal tool that builds a RIDA dataset from a collection of JSON records.
|
|
@@ -42,7 +41,7 @@ reader, so opening a dataset costs **no request at all** and every lookup costs
|
|
|
42
41
|
exactly **one** — the range of bytes holding that value.
|
|
43
42
|
|
|
44
43
|
The map is what lets a reader ask for a record by a name a person recognises, as
|
|
45
|
-
`
|
|
44
|
+
`apparel/jackets/5`, rather than by its number. A dataset whose record names are
|
|
46
45
|
already unique has no map, and needs none.
|
|
47
46
|
|
|
48
47
|
Every stored value is its own deflate stream, so a reader fetches one range and
|
|
@@ -64,7 +63,7 @@ case, and any JSON collection of the same shape behaves the same way.
|
|
|
64
63
|
From this project folder:
|
|
65
64
|
|
|
66
65
|
```sh
|
|
67
|
-
|
|
66
|
+
pip install .
|
|
68
67
|
```
|
|
69
68
|
|
|
70
69
|
After that, the `rida` command is available in the same Python environment.
|
|
@@ -74,7 +73,7 @@ account, or server process is required.
|
|
|
74
73
|
Install the published package with:
|
|
75
74
|
|
|
76
75
|
```sh
|
|
77
|
-
|
|
76
|
+
pip install rida-format
|
|
78
77
|
```
|
|
79
78
|
|
|
80
79
|
The PyPI package name is `rida-format`. After installation, the terminal
|
|
@@ -115,20 +114,12 @@ individual `.py` file: they use `import rida`, `rida ...`, or `python -m rida`.
|
|
|
115
114
|
## Requirements and downloads
|
|
116
115
|
|
|
117
116
|
- Python **3.10 or newer** and `pip` are required.
|
|
118
|
-
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
-
|
|
122
|
-
`
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
```sh
|
|
126
|
-
python3 -m pip install "rida-format[encryption]"
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
Everything else — building unencrypted files, local reads, remote reads,
|
|
130
|
-
verification — works without it. `rida.encryption_available()` reports
|
|
131
|
-
whether it is importable in the current environment.
|
|
117
|
+
- A single `pip install rida-format` installs RIDA and its `cryptography`
|
|
118
|
+
dependency. Building and reading encrypted datasets is included; there is
|
|
119
|
+
no separate encryption install or extra to choose.
|
|
120
|
+
- JSON, compression, hashing, and HTTP reads use Python's standard modules.
|
|
121
|
+
`rida.encryption_available()` reports whether the installed encryption
|
|
122
|
+
dependency can be imported in the current environment.
|
|
132
123
|
- The `rida` command has its own progress display for loading, scanning, value
|
|
133
124
|
writing, catalog compression, and final file writing. It does not require
|
|
134
125
|
`tqdm`.
|
|
@@ -204,7 +195,7 @@ before a build starts.
|
|
|
204
195
|
|
|
205
196
|
#### When several groups should be one file
|
|
206
197
|
|
|
207
|
-
A folder holding several groups — `
|
|
198
|
+
A folder holding several groups — `apparel/`, `electronics/`, `furniture/`, say — may hold
|
|
208
199
|
one dataset that was split across folders, or several separate ones. RIDA
|
|
209
200
|
settles it by comparing a sample of each group's field names, and prints what it
|
|
210
201
|
found:
|
|
@@ -214,13 +205,13 @@ JSON groups found: 3
|
|
|
214
205
|
Distinct fields across all groups: 34
|
|
215
206
|
Fields shared by every group: 28
|
|
216
207
|
|
|
217
|
-
group
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
208
|
+
group records fields not shared
|
|
209
|
+
-------------------------------------------------------------
|
|
210
|
+
apparel 300 34 6
|
|
211
|
+
electronics 300 28 0
|
|
212
|
+
furniture 300 34 6
|
|
222
213
|
|
|
223
|
-
field 'f28': not in
|
|
214
|
+
field 'f28': not in electronics
|
|
224
215
|
```
|
|
225
216
|
|
|
226
217
|
It then lays out the three ways to build, each with a size:
|
|
@@ -229,11 +220,11 @@ It then lays out the three ways to build, each with a size:
|
|
|
229
220
|
Three ways to build this folder (900 records in all)
|
|
230
221
|
|
|
231
222
|
1) one file for each group, each keeping its own schema
|
|
232
|
-
group
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
in all
|
|
223
|
+
group records fields data catalog
|
|
224
|
+
apparel 300 34 135.7 KB 33.1 KB
|
|
225
|
+
electronics 300 28 111.3 KB 27.7 KB
|
|
226
|
+
furniture 300 34 135.7 KB 33.1 KB
|
|
227
|
+
in all 900 382.7 KB 93.9 KB
|
|
237
228
|
|
|
238
229
|
2) one file, on the fields every group shares
|
|
239
230
|
only the 28 fields every group has; the rest are not stored
|
|
@@ -278,13 +269,13 @@ HTTP byte ranges and does not care who serves it.
|
|
|
278
269
|
|
|
279
270
|
#### Record IDs
|
|
280
271
|
|
|
281
|
-
|
|
272
|
+
Different product categories may each number their records from `1`. Three folders holding `1.json` therefore
|
|
282
273
|
produce three records called `1`, and no file name can tell them apart:
|
|
283
274
|
|
|
284
275
|
```text
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
276
|
+
apparel/jackets/pages/1.json -> "1"
|
|
277
|
+
electronics/phones/pages/1.json -> "1"
|
|
278
|
+
furniture/chairs/pages/1.json -> "1"
|
|
288
279
|
```
|
|
289
280
|
|
|
290
281
|
RIDA identifies a record by where it sits rather than what it is called. Each
|
|
@@ -292,9 +283,9 @@ folder's children are numbered from 1 in sorted order, so an ID has one number
|
|
|
292
283
|
per level:
|
|
293
284
|
|
|
294
285
|
```text
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
286
|
+
apparel/jackets/pages/1.json -> 1/1/1/1
|
|
287
|
+
electronics/phones/pages/1.json -> 2/1/1/1
|
|
288
|
+
furniture/chairs/pages/1.json -> 3/1/1/1
|
|
298
289
|
```
|
|
299
290
|
|
|
300
291
|
Positions cannot repeat. The same ID can never be produced twice, at any depth,
|
|
@@ -311,9 +302,9 @@ data and index:
|
|
|
311
302
|
"version": 1,
|
|
312
303
|
"records": 479552,
|
|
313
304
|
"paths": {
|
|
314
|
-
"1": "
|
|
315
|
-
"1/1": "
|
|
316
|
-
"1/1/1": "
|
|
305
|
+
"1": "apparel",
|
|
306
|
+
"1/1": "jackets",
|
|
307
|
+
"1/1/1": "pages"
|
|
317
308
|
},
|
|
318
309
|
"fields": {
|
|
319
310
|
"1": "english",
|
|
@@ -328,15 +319,15 @@ reader can find a record by the name a person knows:
|
|
|
328
319
|
|
|
329
320
|
```python
|
|
330
321
|
data.get("1/1/1/5", "english") # by number
|
|
331
|
-
data.get("
|
|
322
|
+
data.get("apparel/jackets/5", "english") # by name, using the map
|
|
332
323
|
|
|
333
|
-
data.resolve("
|
|
324
|
+
data.resolve("apparel", "jackets") # -> "1/1"
|
|
334
325
|
data.records_under("1/1") # -> ["1/1/1/1", "1/1/1/2", ...]
|
|
335
326
|
data.folders() # -> every numbered prefix and its name
|
|
336
327
|
```
|
|
337
328
|
|
|
338
|
-
The name form does not need the `
|
|
339
|
-
`1/1/1/5`. Naming only a folder, `
|
|
329
|
+
The name form does not need the `pages` level: `apparel/jackets/5` finds
|
|
330
|
+
`1/1/1/5`. Naming only a folder, `apparel/jackets`, gives that folder's first
|
|
340
331
|
record.
|
|
341
332
|
|
|
342
333
|
The map is optional. A file whose IDs are already its record names reads without
|
|
@@ -346,7 +337,7 @@ one, and a reader that cannot find a map simply expects numbers.
|
|
|
346
337
|
|
|
347
338
|
`--id-scheme named` keeps the old behaviour: the file name is the ID, and repeats
|
|
348
339
|
are numbered `1-2`, `1-3`. No map is written. Use it when the names are already
|
|
349
|
-
meaningful and unique, such as `
|
|
340
|
+
meaningful and unique, such as `jackets_1.json` and `phones_1.json`.
|
|
350
341
|
|
|
351
342
|
| | `numbered` (default) | `named` |
|
|
352
343
|
| --- | --- | --- |
|
|
@@ -423,7 +414,7 @@ beside the data file; the number form does not:
|
|
|
423
414
|
|
|
424
415
|
```sh
|
|
425
416
|
rida get old.rida 1/1/1/5 english --key "$(cat oldKey.rida)"
|
|
426
|
-
rida get old.rida
|
|
417
|
+
rida get old.rida apparel/jackets/5 english --key "$(cat oldKey.rida)"
|
|
427
418
|
```
|
|
428
419
|
|
|
429
420
|
To see what a numbered dataset holds, ask it for the folder names:
|
|
@@ -480,7 +471,7 @@ rida verify UsersData.rida
|
|
|
480
471
|
|
|
481
472
|
## Where RIDA can read data
|
|
482
473
|
|
|
483
|
-
RIDA 0.
|
|
474
|
+
RIDA 2.0.2 can read a data file from the local computer or from a direct
|
|
484
475
|
HTTP/HTTPS file URL. For remote reads, RIDA sends ordinary HTTP byte-range
|
|
485
476
|
requests; it does not use a cloud-provider SDK. This makes it compatible with
|
|
486
477
|
object storage that returns the requested bytes as HTTP `206 Partial Content`
|
|
@@ -612,7 +603,7 @@ A data file that is served from a CDN is public. Encrypting it means a scraper
|
|
|
612
603
|
that downloads the file gets bytes it cannot read.
|
|
613
604
|
|
|
614
605
|
```sh
|
|
615
|
-
#
|
|
606
|
+
# Encryption support is included in pip install rida-format
|
|
616
607
|
rida build ./my-data ItemsData.rida --encrypt
|
|
617
608
|
```
|
|
618
609
|
|
|
@@ -669,10 +660,78 @@ protect you from a reader who already has the key: the key has to reach your
|
|
|
669
660
|
client somehow, and a client that holds a key can be studied. Looking after the
|
|
670
661
|
key is the publisher's job, exactly like a password.
|
|
671
662
|
|
|
672
|
-
For access control tied to a user account, keep the key on
|
|
673
|
-
|
|
663
|
+
For access control tied to a user account on every read, keep the key on your
|
|
664
|
+
server, check permission there, and return decrypted content rather than the key. `rida.encryption_available()` tells you whether the encryption
|
|
674
665
|
dependency is present before you promise encryption to a caller.
|
|
675
666
|
|
|
667
|
+
### Encrypted data directly from your CDN
|
|
668
|
+
|
|
669
|
+
You can host an encrypted RIDA data file at a public CDN URL while keeping its
|
|
670
|
+
contents unreadable without the decryption key. The reader uses its index to
|
|
671
|
+
find the requested value, downloads that encrypted byte range, and decrypts it
|
|
672
|
+
where the reader runs. You do not need to download the whole dataset first.
|
|
673
|
+
|
|
674
|
+
```text
|
|
675
|
+
Reader with a key → CDN byte-range request → encrypted value → local decryption
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
For example, a page record can contain separate `english`, `hindi`, `urdu`, and
|
|
679
|
+
`spanish` fields. Requesting page 2's `spanish` field downloads the stored bytes
|
|
680
|
+
for that field, including encryption overhead. If Spanish contains a complete
|
|
681
|
+
object with a title, paragraphs, and steps, you receive that complete object.
|
|
682
|
+
A larger value needs a larger range: RIDA does not make every response a fixed
|
|
683
|
+
number of bytes. HTTP headers and network overhead are additional to the value.
|
|
684
|
+
|
|
685
|
+
#### Option 1: give the authorized reader the key
|
|
686
|
+
|
|
687
|
+
Your application can authorize a user and provide the key to a compatible
|
|
688
|
+
reader. Subsequent reads can go directly to the CDN, with decryption on the
|
|
689
|
+
user's device. Keep the index and map with the reader so it can find the correct
|
|
690
|
+
record and field without guessing paths.
|
|
691
|
+
|
|
692
|
+
If your Worker or backend would otherwise exist only to validate a token on
|
|
693
|
+
**every data request**, this arrangement can avoid that proxy's execution and
|
|
694
|
+
extra network hop for those reads. RIDA itself adds no encryption subscription
|
|
695
|
+
fee. Storage, CDN delivery, your authorization service, and other hosting
|
|
696
|
+
services can still have charges; this is not a promise that every CDN security
|
|
697
|
+
feature or paid plan becomes unnecessary.
|
|
698
|
+
|
|
699
|
+
The trade-off is that a user who holds the key can copy it and read the values
|
|
700
|
+
encrypted with it. A public URL lets anyone download ciphertext; encryption
|
|
701
|
+
protects the contents, not access to that URL. The index and map can also reveal
|
|
702
|
+
record names, field names, and dataset structure.
|
|
703
|
+
|
|
704
|
+
Expiring a session or token does **not** revoke a copied key. To exclude that
|
|
705
|
+
key from future data, use a new key and newly encrypted data. Previously
|
|
706
|
+
downloaded data remains readable with its original key. Choose this approach
|
|
707
|
+
when your application accepts these limits.
|
|
708
|
+
|
|
709
|
+
#### Option 2: keep the key on your Next.js server
|
|
710
|
+
|
|
711
|
+
Store the key in a server-only environment variable such as `RIDA_KEY`. Never
|
|
712
|
+
use a `NEXT_PUBLIC_` variable for it, import it into client code, or return the
|
|
713
|
+
key in an API response. Keep the key file out of public assets as well.
|
|
714
|
+
|
|
715
|
+
```text
|
|
716
|
+
User → your server checks access → CDN encrypted range
|
|
717
|
+
→ server decrypts → permitted content returned to the user
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
Your server checks the user's permission, fetches the requested encrypted range,
|
|
721
|
+
decrypts it, and returns the permitted content. The key stays on the server,
|
|
722
|
+
but reads now pass through your backend and its running costs remain. Keeping a
|
|
723
|
+
key in an environment variable does not by itself give a browser direct reads:
|
|
724
|
+
the browser needs the key to decrypt locally, or the server must decrypt for it.
|
|
725
|
+
|
|
726
|
+
Use this option when each read needs an account permission check. Encryption
|
|
727
|
+
and per-request authorization solve different problems; choose where decryption
|
|
728
|
+
happens according to the access rules your application needs.
|
|
729
|
+
|
|
730
|
+
The Python reader can perform these reads in a Python application or backend.
|
|
731
|
+
A browser or mobile app needs a compatible reader for its own platform. A
|
|
732
|
+
Next.js server can use the Node.js `rida-format` package for server-side reads;
|
|
733
|
+
the Python package is not browser JavaScript.
|
|
734
|
+
|
|
676
735
|
## Use from Python
|
|
677
736
|
|
|
678
737
|
```python
|
|
@@ -715,7 +774,7 @@ map beside the data file turns a name into one:
|
|
|
715
774
|
```python
|
|
716
775
|
with rida.RidaFile("old.rida", key=open("oldKey.rida").read().strip()) as data:
|
|
717
776
|
# By name, the way a person would say it.
|
|
718
|
-
print(data.get("
|
|
777
|
+
print(data.get("apparel/jackets/5", "english"))
|
|
719
778
|
|
|
720
779
|
# By number, which needs no map and works from a bare index.
|
|
721
780
|
print(data.get("1/1/1/5", "english"))
|
|
@@ -725,7 +784,7 @@ with rida.RidaFile("old.rida", key=open("oldKey.rida").read().strip()) as data:
|
|
|
725
784
|
print(prefix, name)
|
|
726
785
|
|
|
727
786
|
# Everything under one book.
|
|
728
|
-
for record_id in data.records_under(data.resolve("
|
|
787
|
+
for record_id in data.records_under(data.resolve("apparel", "jackets")):
|
|
729
788
|
print(record_id, data.get(record_id, "english"))
|
|
730
789
|
```
|
|
731
790
|
|
|
@@ -773,9 +832,156 @@ build; the suite checks that this version still reads it and still reproduces it
|
|
|
773
832
|
catalog and data bytes. Regenerate it with `tests/make_fixtures.py` whenever the
|
|
774
833
|
layout changes.
|
|
775
834
|
|
|
835
|
+
## Detailed application examples
|
|
836
|
+
|
|
837
|
+
These examples use numbered record IDs and the generated map. Build each example folder as its own dataset. The IDs shown apply only to these exact folder trees; adding or rearranging records can change numbered positions.
|
|
838
|
+
|
|
839
|
+
### One product. Only the description your customer needs.
|
|
840
|
+
|
|
841
|
+
Your product catalogue can contain thousands of records. Each product may have a price, specifications, images, stock information, and descriptions in several languages.
|
|
842
|
+
|
|
843
|
+
```text
|
|
844
|
+
catalogue/
|
|
845
|
+
└── products/
|
|
846
|
+
└── 2812.json
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
Example record:
|
|
850
|
+
|
|
851
|
+
```json
|
|
852
|
+
{
|
|
853
|
+
"name": "Travel Backpack",
|
|
854
|
+
"price": 49,
|
|
855
|
+
"stock": 120,
|
|
856
|
+
"specifications": {
|
|
857
|
+
"capacity": "30 litres",
|
|
858
|
+
"weight": "900 grams"
|
|
859
|
+
},
|
|
860
|
+
"english": {
|
|
861
|
+
"title": "Ready for everyday travel",
|
|
862
|
+
"description": "A lightweight backpack with a padded laptop compartment."
|
|
863
|
+
},
|
|
864
|
+
"hindi": {
|
|
865
|
+
"title": "Roz ke safar ke liye",
|
|
866
|
+
"description": "Halka backpack, laptop ke liye alag padded jagah ke saath.",
|
|
867
|
+
"care": [
|
|
868
|
+
"Haath se saaf karein",
|
|
869
|
+
"Chhaon mein sukhayein"
|
|
870
|
+
]
|
|
871
|
+
},
|
|
872
|
+
"images": [
|
|
873
|
+
"front.webp",
|
|
874
|
+
"back.webp"
|
|
875
|
+
]
|
|
876
|
+
}
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
Build the example:
|
|
880
|
+
|
|
881
|
+
```sh
|
|
882
|
+
rida build ./catalogue ./CatalogueData.rida --records-dir .
|
|
883
|
+
```
|
|
884
|
+
|
|
885
|
+
#### Your customer chooses Hindi
|
|
886
|
+
|
|
887
|
+
Request the hindi field. The reader uses the map to resolve the record and the index to find its byte range. The response contains the complete Hindi value: its title, description, and care instructions. Price, stock, specifications, English content, and image URLs are not selected.
|
|
888
|
+
|
|
889
|
+
```python
|
|
890
|
+
import rida
|
|
891
|
+
|
|
892
|
+
with rida.RidaFile("CatalogueData.rida") as data:
|
|
893
|
+
prefix = data.resolve("products")
|
|
894
|
+
if not prefix:
|
|
895
|
+
raise ValueError("Folder not found in the map")
|
|
896
|
+
record_ids = data.records_under(prefix)
|
|
897
|
+
# This exact example: 2812.json is the only record.
|
|
898
|
+
record_id = record_ids[0]
|
|
899
|
+
print(data.get(record_id, "hindi"))
|
|
900
|
+
print(data.get_many(record_id, ["price", "hindi"]))
|
|
901
|
+
```
|
|
902
|
+
|
|
903
|
+
Need the price too? Request price and hindi together with a multi-field read. Nearby ranges can be combined; the number of HTTP requests depends on their positions in the data file.
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
### A complete help page. In the selected language.
|
|
907
|
+
|
|
908
|
+
A help centre can organise complete multilingual instructions inside deeply nested folders. Each language can contain a heading, introduction, steps, and troubleshooting.
|
|
909
|
+
|
|
910
|
+
```text
|
|
911
|
+
help-centre/
|
|
912
|
+
└── guides/
|
|
913
|
+
└── account/
|
|
914
|
+
└── recovery/
|
|
915
|
+
└── pages/
|
|
916
|
+
├── 1.json
|
|
917
|
+
├── 2.json
|
|
918
|
+
└── 3812.json
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
Example record:
|
|
922
|
+
|
|
923
|
+
```json
|
|
924
|
+
{
|
|
925
|
+
"title": "Recover your account",
|
|
926
|
+
"category": "Account access",
|
|
927
|
+
"english": {
|
|
928
|
+
"heading": "Reset your password",
|
|
929
|
+
"steps": [
|
|
930
|
+
"Open account recovery",
|
|
931
|
+
"Enter your email",
|
|
932
|
+
"Follow the reset link"
|
|
933
|
+
]
|
|
934
|
+
},
|
|
935
|
+
"spanish": {
|
|
936
|
+
"heading": "Restablece tu contraseña",
|
|
937
|
+
"introduction": "Sigue estos pasos para recuperar el acceso a tu cuenta.",
|
|
938
|
+
"steps": [
|
|
939
|
+
"Abre la página de recuperación",
|
|
940
|
+
"Introduce tu correo electrónico",
|
|
941
|
+
"Sigue el enlace para restablecer la contraseña"
|
|
942
|
+
],
|
|
943
|
+
"troubleshooting": {
|
|
944
|
+
"email_missing": "Revisa la carpeta de correo no deseado.",
|
|
945
|
+
"link_expired": "Solicita un nuevo enlace."
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
Build the example:
|
|
952
|
+
|
|
953
|
+
```sh
|
|
954
|
+
rida build ./help-centre ./HelpData.rida --records-dir .
|
|
955
|
+
```
|
|
956
|
+
|
|
957
|
+
#### Your user needs Spanish instructions
|
|
958
|
+
|
|
959
|
+
Request the spanish field to receive the complete Spanish object, including its nested troubleshooting content. English instructions are not selected. Use the generated map to find the folder prefix rather than guessing a numbered path.
|
|
960
|
+
|
|
961
|
+
```python
|
|
962
|
+
import rida
|
|
963
|
+
|
|
964
|
+
with rida.RidaFile("HelpData.rida") as data:
|
|
965
|
+
prefix = data.resolve("guides", "account", "recovery", "pages")
|
|
966
|
+
if not prefix:
|
|
967
|
+
raise ValueError("Folder not found in the map")
|
|
968
|
+
record_ids = data.records_under(prefix)
|
|
969
|
+
# This exact example: 3812.json follows 1.json and 2.json.
|
|
970
|
+
record_id = record_ids[2]
|
|
971
|
+
print(data.get(record_id, "spanish"))
|
|
972
|
+
print(data.get_many(record_id, ["title", "category", "spanish"]))
|
|
973
|
+
```
|
|
974
|
+
|
|
975
|
+
Need page metadata too? Request title, category, and spanish together. RIDA selects stored fields, not individual properties inside them. If troubleshooting needs independent reads, store it in a separate top-level field.
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
A field can contain a complete object or array, not just a short sentence. A long value needs a larger byte range. An encrypted build returns the same selected values after decryption with the key. Encryption and HTTP headers add overhead; responses are not a fixed few bytes. Merged ranges can also include small gaps between selected values.
|
|
979
|
+
|
|
980
|
+
The filenames are source names, not guaranteed numbered record IDs. The map describes folder prefixes; records_under / recordsUnder lists their record IDs. Keep the chosen ID in your application when selecting a record. For a large catalogue, use your own product identifier field or mapping to associate business IDs with numbered record IDs.
|
|
981
|
+
|
|
776
982
|
## Current scope
|
|
777
983
|
|
|
778
|
-
RIDA 0.
|
|
984
|
+
RIDA 2.0.2 implements primary lookup — `record ID + field name → value` — plus
|
|
779
985
|
multi-field reads (`get_many`, `get_record`), numbered folder IDs with a map that
|
|
780
986
|
turns a name into one, a data-file integrity check, and optional AES-256-GCM
|
|
781
987
|
encryption of every stored value. Optional exact-match,
|