rida-format 0.1.0__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-0.1.0/LICENSE +43 -0
- rida_format-0.1.0/MANIFEST.in +9 -0
- rida_format-0.1.0/PKG-INFO +218 -0
- rida_format-0.1.0/RIDA-DESIGN-0.1.md +223 -0
- rida_format-0.1.0/RIDA-README.md +197 -0
- rida_format-0.1.0/pyproject.toml +37 -0
- rida_format-0.1.0/setup.cfg +4 -0
- rida_format-0.1.0/src/rida/__init__.py +870 -0
- rida_format-0.1.0/src/rida/__main__.py +7 -0
- rida_format-0.1.0/src/rida_format.egg-info/PKG-INFO +218 -0
- rida_format-0.1.0/src/rida_format.egg-info/SOURCES.txt +12 -0
- rida_format-0.1.0/src/rida_format.egg-info/dependency_links.txt +1 -0
- rida_format-0.1.0/src/rida_format.egg-info/entry_points.txt +2 -0
- rida_format-0.1.0/src/rida_format.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
RIDA PROPRIETARY LICENSE
|
|
2
|
+
Version 1.0
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2026 Syed Ali Hamza Chishty. All rights reserved.
|
|
5
|
+
|
|
6
|
+
This license applies to the RIDA software library and its source code
|
|
7
|
+
(“RIDA”). It does not apply to data files created with RIDA.
|
|
8
|
+
|
|
9
|
+
1. Permission to use and modify
|
|
10
|
+
|
|
11
|
+
You may download, install, run, inspect, and modify RIDA for your own use.
|
|
12
|
+
You may use RIDA, including a modified version, as a component of software
|
|
13
|
+
applications that you create.
|
|
14
|
+
|
|
15
|
+
2. Applications and commercial use
|
|
16
|
+
|
|
17
|
+
You may distribute and sell applications that include RIDA, including a
|
|
18
|
+
modified version of RIDA, as an integrated component. You may not offer RIDA
|
|
19
|
+
as a separately installable or downloadable library, package, or standalone
|
|
20
|
+
software product as part of that distribution.
|
|
21
|
+
|
|
22
|
+
Every application that includes RIDA must display this notice in an About,
|
|
23
|
+
Licenses, or Third-Party Notices section:
|
|
24
|
+
|
|
25
|
+
“Uses RIDA (Range Indexed Data Access).
|
|
26
|
+
Copyright (c) 2026 Syed Ali Hamza Chishty.
|
|
27
|
+
Used under the RIDA Proprietary License.”
|
|
28
|
+
|
|
29
|
+
3. Standalone redistribution and resale
|
|
30
|
+
|
|
31
|
+
You may not sell, sublicense, publish, or otherwise distribute RIDA or a
|
|
32
|
+
modified version of RIDA as a standalone library, package, or software
|
|
33
|
+
product. You may not claim that you own or authored the original RIDA code.
|
|
34
|
+
|
|
35
|
+
4. Ownership
|
|
36
|
+
|
|
37
|
+
Syed Ali Hamza Chishty retains ownership of RIDA. This license grants only
|
|
38
|
+
the permissions stated above; it does not transfer ownership of RIDA.
|
|
39
|
+
|
|
40
|
+
5. Warranty
|
|
41
|
+
|
|
42
|
+
RIDA is provided “AS IS”, without warranties or conditions of any kind,
|
|
43
|
+
express or implied, to the extent permitted by applicable law.
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rida-format
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Range Indexed Data Access (RIDA) static data format and library
|
|
5
|
+
Author: Syed Ali Hamza Chishty
|
|
6
|
+
Maintainer-email: Qasra Foundation <admin@qasra.org>
|
|
7
|
+
License-Expression: LicenseRef-Proprietary
|
|
8
|
+
Keywords: rida,json,r2,range-requests,static-data
|
|
9
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# RIDA Python library — 0.1
|
|
23
|
+
|
|
24
|
+
RIDA means **Range Indexed Data Access**. It is an installable Python library
|
|
25
|
+
and terminal tool that builds one `.rida` file from a collection of JSON
|
|
26
|
+
records. The file contains:
|
|
27
|
+
|
|
28
|
+
- a fixed RIDA header;
|
|
29
|
+
- small, readable UTF-8 metadata at the start of the file;
|
|
30
|
+
- a compressed dense or sparse address catalog; and
|
|
31
|
+
- UTF-8 JSON values stored in a data region.
|
|
32
|
+
|
|
33
|
+
The reader loads the catalog once and then reads only the requested field bytes.
|
|
34
|
+
It works locally and over an HTTP server that supports byte-range requests.
|
|
35
|
+
|
|
36
|
+
## Install locally
|
|
37
|
+
|
|
38
|
+
From this project folder:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
python3 -m pip install .
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
After that, the `rida` command is available in the same Python environment.
|
|
45
|
+
The library uses only Python's standard library at runtime: no database, cloud
|
|
46
|
+
account, or server process is required.
|
|
47
|
+
|
|
48
|
+
After the package is published, another person can install it with:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
python3 -m pip install rida-format
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The public package name is provisionally `rida`; publishing to PyPI will
|
|
55
|
+
happen only after the RIDA file format is frozen. The command and Python import
|
|
56
|
+
name are both simply `rida`.
|
|
57
|
+
|
|
58
|
+
### Library project files
|
|
59
|
+
|
|
60
|
+
Keep the source project in one folder, for example `rida/`:
|
|
61
|
+
|
|
62
|
+
```text
|
|
63
|
+
rida/
|
|
64
|
+
├── pyproject.toml package name and install command
|
|
65
|
+
├── MANIFEST.in files included in the public source archive
|
|
66
|
+
├── RIDA-README.md usage instructions
|
|
67
|
+
├── RIDA-DESIGN-0.1.md RIDA format design
|
|
68
|
+
├── rida-metadata.html optional browser metadata opener
|
|
69
|
+
└── src/
|
|
70
|
+
└── rida/
|
|
71
|
+
├── __init__.py RIDA builder and reader library
|
|
72
|
+
└── __main__.py enables: python -m rida
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`src/rida/` is internal library code. After installation, Python copies it into
|
|
76
|
+
its own `site-packages/rida/` location. A developer never needs to run an
|
|
77
|
+
individual `.py` file: they use `import rida`, `rida ...`, or `python -m rida`.
|
|
78
|
+
|
|
79
|
+
## Requirements and downloads
|
|
80
|
+
|
|
81
|
+
- Python **3.10 or newer** and `pip` are required.
|
|
82
|
+
- RIDA has **zero third-party runtime dependencies**. It uses only Python's
|
|
83
|
+
built-in `json`, `lzma`, `hashlib`, `urllib`, and related standard modules.
|
|
84
|
+
- The `rida` command has its own progress display for loading, scanning, value
|
|
85
|
+
writing, catalog compression, and final file writing. It does not require
|
|
86
|
+
`tqdm`.
|
|
87
|
+
- It does not install or require AWS SDK, Cloudflare SDK, SQLite, Node.js,
|
|
88
|
+
Rust, a database server, or a Worker.
|
|
89
|
+
- When installing this source project, `pip` may temporarily download
|
|
90
|
+
`setuptools` (version 68 or newer) to build the package. It is an install
|
|
91
|
+
tool, not a RIDA runtime dependency.
|
|
92
|
+
- Official Python installers for macOS and Windows include the required `lzma`
|
|
93
|
+
support. On an unusually minimal Linux Python build, install the operating
|
|
94
|
+
system's `python3-lzma` package before using RIDA.
|
|
95
|
+
|
|
96
|
+
## Build
|
|
97
|
+
|
|
98
|
+
Scan first. It reports the field density and recommends dense or sparse mode:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
rida scan users.json
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Build a RIDA file. The command asks for confirmation unless `--yes` is supplied:
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
rida build users.json users.rida \
|
|
108
|
+
--title "Users dataset" \
|
|
109
|
+
--description "Public sample data" \
|
|
110
|
+
--reader-url "https://example.com/rida-explorer" \
|
|
111
|
+
--yes
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
During a build, the terminal shows RIDA's own progress, for example:
|
|
115
|
+
|
|
116
|
+
```text
|
|
117
|
+
Reading JSON bytes: 217,221,288/217,221,288 (100%)
|
|
118
|
+
Parsing JSON: 1/1 (100%)
|
|
119
|
+
Scanning field names: 39,098/39,098 (100%)
|
|
120
|
+
Measuring values: 39,098/39,098 (100%)
|
|
121
|
+
Writing value data: 39,098/39,098 (100%)
|
|
122
|
+
Compressing catalog: 1/1 (100%)
|
|
123
|
+
Writing RIDA file: 217,221,288/217,221,288 (100%)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
For a folder of JSON record files, loading progress counts record files. For
|
|
127
|
+
one large JSON file, it counts source bytes while reading, then shows a
|
|
128
|
+
separate parsing stage. RIDA 0.1 still keeps a single JSON source in memory
|
|
129
|
+
while parsing; the planned streaming importer is for very large single files.
|
|
130
|
+
|
|
131
|
+
Input can be:
|
|
132
|
+
|
|
133
|
+
- an object that maps IDs to JSON record objects;
|
|
134
|
+
- an array of JSON record objects, with `--id-key`; or
|
|
135
|
+
- a folder containing individual JSON record files. Filenames become IDs.
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
rida build records/ records.rida --yes
|
|
139
|
+
rida build users-array.json users.rida --id-key id --yes
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Use `--mode dense` or `--mode sparse` to override the recommendation. The builder does not overwrite an existing output file.
|
|
143
|
+
|
|
144
|
+
## Read locally
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
rida inspect users.rida
|
|
148
|
+
rida get users.rida ali city
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Read from R2 or another public HTTP URL
|
|
152
|
+
|
|
153
|
+
After uploading the `.rida` file to an HTTP byte-range server:
|
|
154
|
+
|
|
155
|
+
```sh
|
|
156
|
+
rida remote-get https://data.example.com/users.rida ali city
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The remote reader first fetches the 128-byte header and catalog, then fetches only the requested field range. For browser readers, configure CORS to allow `GET`, `HEAD`, and the `Range` request header, and expose `Content-Range`, `Content-Length`, and `ETag`.
|
|
160
|
+
|
|
161
|
+
One `RemoteRidaFile` object keeps that catalog in RAM, so later `.get()` calls on
|
|
162
|
+
the same object fetch only the requested value range. The `rida remote-get`
|
|
163
|
+
terminal command creates a new object each time, so persistent on-disk catalog
|
|
164
|
+
cache is a later RIDA Reader feature.
|
|
165
|
+
|
|
166
|
+
## Metadata opener page
|
|
167
|
+
|
|
168
|
+
Open `rida-metadata.html` in a browser and choose any `.rida` file. It reads only the embedded header and metadata on the local computer, then displays the title, record count, index mode, and RIDA Explorer download URL. It never uploads the file.
|
|
169
|
+
|
|
170
|
+
## Use from Python
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
import rida
|
|
174
|
+
|
|
175
|
+
# Scan first if you want to show the publisher the recommendation.
|
|
176
|
+
report = rida.scan("users.json")
|
|
177
|
+
print(report.recommended_mode) # "dense" or "sparse"
|
|
178
|
+
|
|
179
|
+
# Build once. The source JSON stays unchanged.
|
|
180
|
+
rida.build(
|
|
181
|
+
"users.json",
|
|
182
|
+
"users.rida",
|
|
183
|
+
title="Users dataset",
|
|
184
|
+
reader_url="https://example.com/rida",
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
# Read only one stored value from a local RIDA file.
|
|
188
|
+
with rida.RidaFile("users.rida") as data:
|
|
189
|
+
print(data.get("ali", "city"))
|
|
190
|
+
|
|
191
|
+
# The same primary lookup works against an R2/public URL with Range support.
|
|
192
|
+
remote = rida.RemoteRidaFile("https://data.example.com/users.rida")
|
|
193
|
+
print(remote.get("fatima", "languages"))
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
A desktop app or another Python program can show the same stages in its own
|
|
197
|
+
interface by passing a callback:
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
def progress(stage, completed, total):
|
|
201
|
+
print(f"{stage}: {completed}/{total}")
|
|
202
|
+
|
|
203
|
+
rida.build("users.json", "users.rida", progress=progress)
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Current scope
|
|
207
|
+
|
|
208
|
+
RIDA 0.1 implements primary lookup: `record ID + field name → value`.
|
|
209
|
+
|
|
210
|
+
The approved design for optional exact-match, numeric-range, and Unicode full-text indexes is in [RIDA-DESIGN-0.1.md](RIDA-DESIGN-0.1.md). Those search-index blocks are the next format layer; they are not claimed as implemented by this library yet.
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
RIDA is distributed under the RIDA Proprietary License in the `LICENSE` file.
|
|
215
|
+
You may download and modify RIDA, and use it in free or paid applications.
|
|
216
|
+
You may not sell or redistribute RIDA as a standalone package or library.
|
|
217
|
+
Applications that include RIDA must show the attribution notice specified in
|
|
218
|
+
the license.
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# RIDA — Range Indexed Data Access — format design 0.1
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
RIDA is a single-file, read-first data format for large structured datasets. It supports direct byte-range reads from ordinary object storage such as R2, without requiring a database server or worker for each lookup.
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
dataset.rida
|
|
9
|
+
├── RIDA header and catalog
|
|
10
|
+
├── UTF-8 data values
|
|
11
|
+
├── primary ID index
|
|
12
|
+
├── optional search indexes
|
|
13
|
+
└── footer and integrity data
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The format is intended to feel like an embedded, static database for readers. It is not a replacement for a writable SQL database in version 1.
|
|
17
|
+
|
|
18
|
+
## RIDA 0.1 currently supports
|
|
19
|
+
|
|
20
|
+
- fetch one field by record ID without downloading the full dataset;
|
|
21
|
+
- support sequential numeric and arbitrary Unicode string record IDs;
|
|
22
|
+
- support records with shared, partly shared, or highly variable fields;
|
|
23
|
+
- keep all text as UTF-8;
|
|
24
|
+
- work from local files or HTTP byte-range storage;
|
|
25
|
+
- store 64-bit data offsets, allowing files larger than 4 GB; and
|
|
26
|
+
- cache the catalog in memory while a reader object remains open.
|
|
27
|
+
|
|
28
|
+
The 0.1 library does not yet implement permanent disk caching or optional
|
|
29
|
+
exact-match, numeric-range, and full-text search indexes. Those remain planned
|
|
30
|
+
features.
|
|
31
|
+
|
|
32
|
+
## RIDA 0.1 does not include
|
|
33
|
+
|
|
34
|
+
- in-place writes to an R2 object;
|
|
35
|
+
- SQL syntax;
|
|
36
|
+
- transactions, locking, joins, or multi-user editing; or
|
|
37
|
+
- automatic full-text indexing of every field.
|
|
38
|
+
|
|
39
|
+
Datasets are immutable versions. A data change produces a new `.rida` object and a new version identifier. This keeps CDN caching and range addressing reliable.
|
|
40
|
+
|
|
41
|
+
## Record model
|
|
42
|
+
|
|
43
|
+
RIDA stores a collection of records:
|
|
44
|
+
|
|
45
|
+
```text
|
|
46
|
+
record ID → object containing fields and values
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Example:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"ali": { "name": "Ali", "city": "Mumbai" },
|
|
54
|
+
"fatima": { "name": "Fatima", "age": 24, "languages": ["ur", "en"] }
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Every record needs a unique ID. It can come from a top-level key, an `id` field in an array, or a filename when importing a folder of JSON records.
|
|
59
|
+
|
|
60
|
+
## Dense and sparse index modes
|
|
61
|
+
|
|
62
|
+
The builder scans data first and displays a report before building.
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
Records: 50,000
|
|
66
|
+
Unique fields: 24
|
|
67
|
+
Average fields per record: 22
|
|
68
|
+
Field density: 91.7%
|
|
69
|
+
Recommended mode: dense
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
or:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
Records: 50,000
|
|
76
|
+
Unique fields: 10,247
|
|
77
|
+
Average fields per record: 12
|
|
78
|
+
Field density: 0.12%
|
|
79
|
+
Recommended mode: sparse
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Dense mode
|
|
83
|
+
|
|
84
|
+
Use when most records share a small field schema. Field names are stored once in a field dictionary and assigned small field IDs. Each record has a fixed ordered row of locations. Missing fields use an empty location.
|
|
85
|
+
|
|
86
|
+
This gives direct field lookup with minimal per-record work.
|
|
87
|
+
|
|
88
|
+
### Sparse mode
|
|
89
|
+
|
|
90
|
+
Use when the union of fields is large but each record uses only a few fields. Field names are still stored once and receive IDs, but each record stores only the field IDs and locations that exist in that record. Missing fields take no storage.
|
|
91
|
+
|
|
92
|
+
This avoids making thousands of empty field slots for every record.
|
|
93
|
+
|
|
94
|
+
The builder supports:
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
--mode auto choose and report the recommendation
|
|
98
|
+
--mode dense force dense mode
|
|
99
|
+
--mode sparse force sparse mode
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Interactive use asks for confirmation after showing the scan report.
|
|
103
|
+
|
|
104
|
+
## Internal ID dictionaries
|
|
105
|
+
|
|
106
|
+
RIDA turns long names into compact numbers internally:
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
Record IDs:
|
|
110
|
+
1 = ali
|
|
111
|
+
2 = fatima
|
|
112
|
+
|
|
113
|
+
Field IDs:
|
|
114
|
+
1 = name
|
|
115
|
+
2 = city
|
|
116
|
+
3 = age
|
|
117
|
+
4 = languages
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The strings are stored once. Record rows and index blocks use compact integer IDs. Sequential numeric record IDs such as `1, 2, 3...` do not need a separate ID dictionary.
|
|
121
|
+
|
|
122
|
+
## Unicode rules
|
|
123
|
+
|
|
124
|
+
- All text, field names, record IDs, and JSON string values use valid UTF-8.
|
|
125
|
+
- Original Unicode code points are preserved in stored values.
|
|
126
|
+
- Exact ID and exact-value lookup compare the original Unicode code points.
|
|
127
|
+
- Search indexes use a separately stored normalized search key. The default profile is Unicode NFC plus Unicode case folding.
|
|
128
|
+
- Arabic, Urdu, Hindi, and other language-specific search changes such as removing diacritics are opt-in search profiles. RIDA must never silently alter the original displayed text.
|
|
129
|
+
|
|
130
|
+
This allows a reader to show the original Arabic or Urdu exactly while still offering useful normalized searching when a publisher chooses it.
|
|
131
|
+
|
|
132
|
+
## Optional search indexes
|
|
133
|
+
|
|
134
|
+
Direct ID-and-field lookup is always available. Search indexes are opt-in per field because indexing every field can create a large file.
|
|
135
|
+
|
|
136
|
+
### Exact index
|
|
137
|
+
|
|
138
|
+
For short repeated values:
|
|
139
|
+
|
|
140
|
+
```text
|
|
141
|
+
city = Mumbai → [record IDs]
|
|
142
|
+
status = approved → [record IDs]
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Numeric range index
|
|
146
|
+
|
|
147
|
+
For numbers and dates:
|
|
148
|
+
|
|
149
|
+
```text
|
|
150
|
+
price between 100 and 500
|
|
151
|
+
score greater than 90
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Use a sorted tree of value-to-record-ID blocks.
|
|
155
|
+
|
|
156
|
+
### Full-text index
|
|
157
|
+
|
|
158
|
+
For selected text fields:
|
|
159
|
+
|
|
160
|
+
```text
|
|
161
|
+
search urdu3 for a word or phrase
|
|
162
|
+
search title for a word
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Use an inverted index: normalized token to a compressed list of record IDs. Full-text search requires the publisher to select fields and a Unicode search profile.
|
|
166
|
+
|
|
167
|
+
## Reader API shape
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
const data = await RIDA.open("https://storage.example.com/dataset.rida");
|
|
171
|
+
|
|
172
|
+
await data.get("ali", "city");
|
|
173
|
+
await data.getRecord("fatima");
|
|
174
|
+
await data.find("city", "Mumbai");
|
|
175
|
+
await data.range("price", { min: 100, max: 500 });
|
|
176
|
+
await data.search("urdu3", "علم");
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
`get` reads only the selected data range after the required catalog is cached. `find`, `range`, and `search` fetch only the relevant optional index blocks and then the selected records or fields.
|
|
180
|
+
|
|
181
|
+
## RIDA 1 file layout
|
|
182
|
+
|
|
183
|
+
RIDA 1 uses this layout:
|
|
184
|
+
|
|
185
|
+
1. a fixed 128-byte header beginning with the eight-byte `RIDA0001` marker;
|
|
186
|
+
2. readable UTF-8 JSON metadata;
|
|
187
|
+
3. one LZMA-compressed address catalog beginning with `RDACAT01`; and
|
|
188
|
+
4. a data region containing compact UTF-8 JSON values in record/field order.
|
|
189
|
+
|
|
190
|
+
The header stores 64-bit data offsets/length and SHA-256 digests for the
|
|
191
|
+
catalog and data region. The catalog stores the field dictionary, optional
|
|
192
|
+
record-ID dictionary, 64-bit row boundaries, and dense or sparse field
|
|
193
|
+
locations. Values themselves are not compressed, so a reader can fetch their
|
|
194
|
+
exact byte ranges directly.
|
|
195
|
+
|
|
196
|
+
The fixed header lets a RIDA reader find the catalog with a small first byte-range read. The catalog tells the reader which later ranges to request.
|
|
197
|
+
|
|
198
|
+
## Build flow
|
|
199
|
+
|
|
200
|
+
```text
|
|
201
|
+
Input JSON or folder
|
|
202
|
+
↓
|
|
203
|
+
Validate UTF-8 and record IDs
|
|
204
|
+
↓
|
|
205
|
+
Scan fields, density, value types, and selected search fields
|
|
206
|
+
↓
|
|
207
|
+
Show report and dense/sparse recommendation
|
|
208
|
+
↓
|
|
209
|
+
User confirms build settings
|
|
210
|
+
↓
|
|
211
|
+
Build one immutable dataset.rida file
|
|
212
|
+
↓
|
|
213
|
+
Upload to R2, S3, CDN, or any byte-range server
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Product path
|
|
217
|
+
|
|
218
|
+
1. Freeze RIDA 0.1 core read format: header, catalog, data region, primary lookup, dense/sparse modes, and Unicode rules.
|
|
219
|
+
2. Build a RIDA CLI that converts JSON or folders to `.rida`.
|
|
220
|
+
3. Build a JavaScript/TypeScript reader SDK.
|
|
221
|
+
4. Add exact-match and numeric-range indexes.
|
|
222
|
+
5. Add configurable Unicode full-text search.
|
|
223
|
+
6. Add mobile readers after the format and test suite are stable.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# RIDA Python library — 0.1
|
|
2
|
+
|
|
3
|
+
RIDA means **Range Indexed Data Access**. It is an installable Python library
|
|
4
|
+
and terminal tool that builds one `.rida` file from a collection of JSON
|
|
5
|
+
records. The file contains:
|
|
6
|
+
|
|
7
|
+
- a fixed RIDA header;
|
|
8
|
+
- small, readable UTF-8 metadata at the start of the file;
|
|
9
|
+
- a compressed dense or sparse address catalog; and
|
|
10
|
+
- UTF-8 JSON values stored in a data region.
|
|
11
|
+
|
|
12
|
+
The reader loads the catalog once and then reads only the requested field bytes.
|
|
13
|
+
It works locally and over an HTTP server that supports byte-range requests.
|
|
14
|
+
|
|
15
|
+
## Install locally
|
|
16
|
+
|
|
17
|
+
From this project folder:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
python3 -m pip install .
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
After that, the `rida` command is available in the same Python environment.
|
|
24
|
+
The library uses only Python's standard library at runtime: no database, cloud
|
|
25
|
+
account, or server process is required.
|
|
26
|
+
|
|
27
|
+
After the package is published, another person can install it with:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
python3 -m pip install rida-format
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The public package name is provisionally `rida`; publishing to PyPI will
|
|
34
|
+
happen only after the RIDA file format is frozen. The command and Python import
|
|
35
|
+
name are both simply `rida`.
|
|
36
|
+
|
|
37
|
+
### Library project files
|
|
38
|
+
|
|
39
|
+
Keep the source project in one folder, for example `rida/`:
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
rida/
|
|
43
|
+
├── pyproject.toml package name and install command
|
|
44
|
+
├── MANIFEST.in files included in the public source archive
|
|
45
|
+
├── RIDA-README.md usage instructions
|
|
46
|
+
├── RIDA-DESIGN-0.1.md RIDA format design
|
|
47
|
+
├── rida-metadata.html optional browser metadata opener
|
|
48
|
+
└── src/
|
|
49
|
+
└── rida/
|
|
50
|
+
├── __init__.py RIDA builder and reader library
|
|
51
|
+
└── __main__.py enables: python -m rida
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`src/rida/` is internal library code. After installation, Python copies it into
|
|
55
|
+
its own `site-packages/rida/` location. A developer never needs to run an
|
|
56
|
+
individual `.py` file: they use `import rida`, `rida ...`, or `python -m rida`.
|
|
57
|
+
|
|
58
|
+
## Requirements and downloads
|
|
59
|
+
|
|
60
|
+
- Python **3.10 or newer** and `pip` are required.
|
|
61
|
+
- RIDA has **zero third-party runtime dependencies**. It uses only Python's
|
|
62
|
+
built-in `json`, `lzma`, `hashlib`, `urllib`, and related standard modules.
|
|
63
|
+
- The `rida` command has its own progress display for loading, scanning, value
|
|
64
|
+
writing, catalog compression, and final file writing. It does not require
|
|
65
|
+
`tqdm`.
|
|
66
|
+
- It does not install or require AWS SDK, Cloudflare SDK, SQLite, Node.js,
|
|
67
|
+
Rust, a database server, or a Worker.
|
|
68
|
+
- When installing this source project, `pip` may temporarily download
|
|
69
|
+
`setuptools` (version 68 or newer) to build the package. It is an install
|
|
70
|
+
tool, not a RIDA runtime dependency.
|
|
71
|
+
- Official Python installers for macOS and Windows include the required `lzma`
|
|
72
|
+
support. On an unusually minimal Linux Python build, install the operating
|
|
73
|
+
system's `python3-lzma` package before using RIDA.
|
|
74
|
+
|
|
75
|
+
## Build
|
|
76
|
+
|
|
77
|
+
Scan first. It reports the field density and recommends dense or sparse mode:
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
rida scan users.json
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Build a RIDA file. The command asks for confirmation unless `--yes` is supplied:
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
rida build users.json users.rida \
|
|
87
|
+
--title "Users dataset" \
|
|
88
|
+
--description "Public sample data" \
|
|
89
|
+
--reader-url "https://example.com/rida-explorer" \
|
|
90
|
+
--yes
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
During a build, the terminal shows RIDA's own progress, for example:
|
|
94
|
+
|
|
95
|
+
```text
|
|
96
|
+
Reading JSON bytes: 217,221,288/217,221,288 (100%)
|
|
97
|
+
Parsing JSON: 1/1 (100%)
|
|
98
|
+
Scanning field names: 39,098/39,098 (100%)
|
|
99
|
+
Measuring values: 39,098/39,098 (100%)
|
|
100
|
+
Writing value data: 39,098/39,098 (100%)
|
|
101
|
+
Compressing catalog: 1/1 (100%)
|
|
102
|
+
Writing RIDA file: 217,221,288/217,221,288 (100%)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
For a folder of JSON record files, loading progress counts record files. For
|
|
106
|
+
one large JSON file, it counts source bytes while reading, then shows a
|
|
107
|
+
separate parsing stage. RIDA 0.1 still keeps a single JSON source in memory
|
|
108
|
+
while parsing; the planned streaming importer is for very large single files.
|
|
109
|
+
|
|
110
|
+
Input can be:
|
|
111
|
+
|
|
112
|
+
- an object that maps IDs to JSON record objects;
|
|
113
|
+
- an array of JSON record objects, with `--id-key`; or
|
|
114
|
+
- a folder containing individual JSON record files. Filenames become IDs.
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
rida build records/ records.rida --yes
|
|
118
|
+
rida build users-array.json users.rida --id-key id --yes
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Use `--mode dense` or `--mode sparse` to override the recommendation. The builder does not overwrite an existing output file.
|
|
122
|
+
|
|
123
|
+
## Read locally
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
rida inspect users.rida
|
|
127
|
+
rida get users.rida ali city
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Read from R2 or another public HTTP URL
|
|
131
|
+
|
|
132
|
+
After uploading the `.rida` file to an HTTP byte-range server:
|
|
133
|
+
|
|
134
|
+
```sh
|
|
135
|
+
rida remote-get https://data.example.com/users.rida ali city
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The remote reader first fetches the 128-byte header and catalog, then fetches only the requested field range. For browser readers, configure CORS to allow `GET`, `HEAD`, and the `Range` request header, and expose `Content-Range`, `Content-Length`, and `ETag`.
|
|
139
|
+
|
|
140
|
+
One `RemoteRidaFile` object keeps that catalog in RAM, so later `.get()` calls on
|
|
141
|
+
the same object fetch only the requested value range. The `rida remote-get`
|
|
142
|
+
terminal command creates a new object each time, so persistent on-disk catalog
|
|
143
|
+
cache is a later RIDA Reader feature.
|
|
144
|
+
|
|
145
|
+
## Metadata opener page
|
|
146
|
+
|
|
147
|
+
Open `rida-metadata.html` in a browser and choose any `.rida` file. It reads only the embedded header and metadata on the local computer, then displays the title, record count, index mode, and RIDA Explorer download URL. It never uploads the file.
|
|
148
|
+
|
|
149
|
+
## Use from Python
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
import rida
|
|
153
|
+
|
|
154
|
+
# Scan first if you want to show the publisher the recommendation.
|
|
155
|
+
report = rida.scan("users.json")
|
|
156
|
+
print(report.recommended_mode) # "dense" or "sparse"
|
|
157
|
+
|
|
158
|
+
# Build once. The source JSON stays unchanged.
|
|
159
|
+
rida.build(
|
|
160
|
+
"users.json",
|
|
161
|
+
"users.rida",
|
|
162
|
+
title="Users dataset",
|
|
163
|
+
reader_url="https://example.com/rida",
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
# Read only one stored value from a local RIDA file.
|
|
167
|
+
with rida.RidaFile("users.rida") as data:
|
|
168
|
+
print(data.get("ali", "city"))
|
|
169
|
+
|
|
170
|
+
# The same primary lookup works against an R2/public URL with Range support.
|
|
171
|
+
remote = rida.RemoteRidaFile("https://data.example.com/users.rida")
|
|
172
|
+
print(remote.get("fatima", "languages"))
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
A desktop app or another Python program can show the same stages in its own
|
|
176
|
+
interface by passing a callback:
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
def progress(stage, completed, total):
|
|
180
|
+
print(f"{stage}: {completed}/{total}")
|
|
181
|
+
|
|
182
|
+
rida.build("users.json", "users.rida", progress=progress)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Current scope
|
|
186
|
+
|
|
187
|
+
RIDA 0.1 implements primary lookup: `record ID + field name → value`.
|
|
188
|
+
|
|
189
|
+
The approved design for optional exact-match, numeric-range, and Unicode full-text indexes is in [RIDA-DESIGN-0.1.md](RIDA-DESIGN-0.1.md). Those search-index blocks are the next format layer; they are not claimed as implemented by this library yet.
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
RIDA is distributed under the RIDA Proprietary License in the `LICENSE` file.
|
|
194
|
+
You may download and modify RIDA, and use it in free or paid applications.
|
|
195
|
+
You may not sell or redistribute RIDA as a standalone package or library.
|
|
196
|
+
Applications that include RIDA must show the attribution notice specified in
|
|
197
|
+
the license.
|