triviumdb 0.3.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.
Files changed (45) hide show
  1. triviumdb-0.3.0/.github/workflows/ci.yml +38 -0
  2. triviumdb-0.3.0/.github/workflows/release.yml +139 -0
  3. triviumdb-0.3.0/.gitignore +45 -0
  4. triviumdb-0.3.0/Cargo.lock +1153 -0
  5. triviumdb-0.3.0/Cargo.toml +53 -0
  6. triviumdb-0.3.0/LICENSE +201 -0
  7. triviumdb-0.3.0/PKG-INFO +270 -0
  8. triviumdb-0.3.0/README.md +252 -0
  9. triviumdb-0.3.0/benches/benchmark.rs +119 -0
  10. triviumdb-0.3.0/build.rs +6 -0
  11. triviumdb-0.3.0/docs/api-reference.md +650 -0
  12. triviumdb-0.3.0/docs/best-practices.md +423 -0
  13. triviumdb-0.3.0/docs/features.md +318 -0
  14. triviumdb-0.3.0/package.json +38 -0
  15. triviumdb-0.3.0/pyproject.toml +26 -0
  16. triviumdb-0.3.0/scripts/test_arena.py +125 -0
  17. triviumdb-0.3.0/scripts/test_custom_id.py +61 -0
  18. triviumdb-0.3.0/scripts/test_python.py +84 -0
  19. triviumdb-0.3.0/scripts/test_query.py +81 -0
  20. triviumdb-0.3.0/src/database.rs +701 -0
  21. triviumdb-0.3.0/src/error.rs +21 -0
  22. triviumdb-0.3.0/src/filter.rs +94 -0
  23. triviumdb-0.3.0/src/graph/mod.rs +1 -0
  24. triviumdb-0.3.0/src/graph/traversal.rs +58 -0
  25. triviumdb-0.3.0/src/index/brute_force.rs +42 -0
  26. triviumdb-0.3.0/src/index/hnsw.rs +91 -0
  27. triviumdb-0.3.0/src/index/mod.rs +3 -0
  28. triviumdb-0.3.0/src/lib.rs +23 -0
  29. triviumdb-0.3.0/src/main.rs +57 -0
  30. triviumdb-0.3.0/src/node.rs +33 -0
  31. triviumdb-0.3.0/src/nodejs.rs +485 -0
  32. triviumdb-0.3.0/src/python.rs +739 -0
  33. triviumdb-0.3.0/src/query/ast.rs +87 -0
  34. triviumdb-0.3.0/src/query/executor.rs +279 -0
  35. triviumdb-0.3.0/src/query/lexer.rs +218 -0
  36. triviumdb-0.3.0/src/query/mod.rs +4 -0
  37. triviumdb-0.3.0/src/query/parser.rs +253 -0
  38. triviumdb-0.3.0/src/storage/compaction.rs +92 -0
  39. triviumdb-0.3.0/src/storage/file_format.rs +208 -0
  40. triviumdb-0.3.0/src/storage/memtable.rs +278 -0
  41. triviumdb-0.3.0/src/storage/mod.rs +4 -0
  42. triviumdb-0.3.0/src/storage/wal.rs +229 -0
  43. triviumdb-0.3.0/src/vector.rs +90 -0
  44. triviumdb-0.3.0/triviumdb.d.ts +223 -0
  45. triviumdb-0.3.0/uv.lock +8 -0
@@ -0,0 +1,38 @@
1
+ name: Benchmark & CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+
11
+ jobs:
12
+ test_and_bench:
13
+ name: Run Tests and Benchmarks
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - name: Checkout code
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Install Rust
21
+ uses: dtolnay/rust-toolchain@stable
22
+ with:
23
+ toolchain: stable
24
+
25
+ - name: Cache dependencies
26
+ uses: Swatinem/rust-cache@v2
27
+
28
+ - name: Run Tests
29
+ run: cargo test --all-features
30
+
31
+ - name: Run Benchmarks (Performance Regression Check)
32
+ run: cargo bench --workspace
33
+
34
+ - name: Upload Benchmark Results (Criterion)
35
+ uses: actions/upload-artifact@v4
36
+ with:
37
+ name: benchmark-results
38
+ path: target/criterion/
@@ -0,0 +1,139 @@
1
+ name: Publish to PyPI
2
+
3
+ # 触发条件:当推送形如 vX.Y.Z 的 tag 时触发
4
+ on:
5
+ push:
6
+ tags:
7
+ - 'v[0-9]+.[0-9]+.[0-9]+*'
8
+
9
+ jobs:
10
+ # 第一阶段:编译各个平台的二进制 Wheels
11
+ build-wheels:
12
+ name: Build wheels on ${{ matrix.os }}
13
+ runs-on: ${{ matrix.os }}
14
+ strategy:
15
+ matrix:
16
+ # 矩阵构建:覆盖 Windows, Ubuntu(Linux), Mac
17
+ os: [ubuntu-latest, windows-latest, macos-latest]
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Setup Python 3.10
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: '3.10'
25
+
26
+ - name: Build wheels
27
+ uses: PyO3/maturin-action@v1
28
+ env:
29
+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
30
+ with:
31
+ # 我们只需要 python 的 feature
32
+ # (sdist 参数负责连源码一起打包,我们只让 linux 机子去打 1 份源码包就好)
33
+ command: build
34
+ args: --release --features python -o dist ${{ matrix.os == 'ubuntu-latest' && '--sdist' || '' }}
35
+ # 开启 zig 将支持更好的 Linux 下的交叉编译兼容性
36
+ rust-toolchain: stable
37
+
38
+ # 把编译好的所有轮子暂时上传保存到当前流水线任务的缓存中
39
+ - name: Upload wheels
40
+ uses: actions/upload-artifact@v4
41
+ with:
42
+ name: wheels-${{ matrix.os }}
43
+ path: dist
44
+
45
+ # 第二阶段:下载刚刚所有机器编好的包,统合后发往 PyPI
46
+ release:
47
+ name: Release to PyPI
48
+ runs-on: ubuntu-latest
49
+ needs: build-wheels
50
+ steps:
51
+ - name: Download all wheels
52
+ uses: actions/download-artifact@v4
53
+ with:
54
+ path: dist
55
+ pattern: wheels-*
56
+ merge-multiple: true
57
+
58
+ # 使用 pypa 官方 Action 发包
59
+ - name: Publish to PyPI
60
+ uses: pypa/gh-action-pypi-publish@release/v1
61
+ with:
62
+ password: ${{ secrets.PYPI_API_TOKEN }}
63
+
64
+ # 第三阶段:准备 npm 跨平台包并分发
65
+ build-node:
66
+ name: Build Node addon on ${{ matrix.os }}
67
+ runs-on: ${{ matrix.os }}
68
+ strategy:
69
+ matrix:
70
+ os: [ubuntu-latest, windows-latest, macos-latest]
71
+ steps:
72
+ - uses: actions/checkout@v4
73
+
74
+ - name: Setup Node.js
75
+ uses: actions/setup-node@v4
76
+ with:
77
+ node-version: 20
78
+
79
+ - name: Install dependencies
80
+ run: npm install
81
+
82
+ - name: Build node module
83
+ # 使用 napi-rs 自带的 CLI 构建各平台原生包
84
+ run: npx napi build --platform --release --features nodejs
85
+
86
+ # 将编出的 .node 暂存
87
+ - name: Upload node binding
88
+ uses: actions/upload-artifact@v4
89
+ with:
90
+ name: node-${{ matrix.os }}
91
+ path: "*.node"
92
+
93
+ release-npm:
94
+ name: Release to NPM
95
+ runs-on: ubuntu-latest
96
+ needs: build-node
97
+ steps:
98
+ - uses: actions/checkout@v4
99
+
100
+ - name: Setup Node
101
+ uses: actions/setup-node@v4
102
+ with:
103
+ node-version: 20
104
+ registry-url: 'https://registry.npmjs.org'
105
+
106
+ # 把三个系统编好的 .node 全部下回当前目录
107
+ - name: Download all bindings
108
+ uses: actions/download-artifact@v4
109
+ with:
110
+ path: .
111
+ pattern: node-*
112
+ merge-multiple: true
113
+
114
+ # 在发包前编写一个万能入口文件 index.js 自动加载对应平台的二进制
115
+ - name: Generate JS Loader
116
+ run: |
117
+ cat << 'EOF' > index.js
118
+ const { platform, arch } = process;
119
+ let nativeBinding = null;
120
+ try {
121
+ if (platform === 'win32') { nativeBinding = require('./triviumdb.win32-x64-msvc.node'); }
122
+ else if (platform === 'darwin' && arch === 'arm64') { nativeBinding = require('./triviumdb.darwin-arm64.node'); }
123
+ else if (platform === 'darwin') { nativeBinding = require('./triviumdb.darwin-x64.node'); }
124
+ else if (platform === 'linux' && arch === 'arm64') { nativeBinding = require('./triviumdb.linux-arm64-gnu.node'); }
125
+ else { nativeBinding = require('./triviumdb.linux-x64-gnu.node'); }
126
+ } catch (e) {
127
+ console.error(`TriviumDB failed to load native binding for ${platform} ${arch}`, e);
128
+ throw e;
129
+ }
130
+ module.exports = nativeBinding;
131
+ EOF
132
+
133
+ - name: Publish to NPM
134
+ # NODE_AUTH_TOKEN 环境变量会被 registry-url 自动读取以使用 npm token
135
+ run: |
136
+ npm install
137
+ npm publish
138
+ env:
139
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,45 @@
1
+ # ══════ Rust ══════
2
+ /target/
3
+ **/*.rs.bk
4
+ Cargo.lock
5
+
6
+ # ══════ Python ══════
7
+ .venv/
8
+ __pycache__/
9
+ *.pyc
10
+ *.pyo
11
+ *.egg-info/
12
+ dist/
13
+ *.so
14
+ *.pyd
15
+ *.dll
16
+
17
+ # ══════ TriviumDB 运行产物 ══════
18
+ *.tdb
19
+ *.tdb.wal
20
+
21
+ # ══════ Node.js & napi-rs ══════
22
+ node_modules/
23
+ npm-debug.log
24
+ *.node
25
+ index.d.ts
26
+ index.js
27
+ yarn-error.log
28
+ test.js
29
+ package-lock.json
30
+
31
+ # ══════ IDE / 编辑器 ══════
32
+ .idea/
33
+ .vscode/
34
+ *.swp
35
+ *.swo
36
+ *~
37
+
38
+ # ══════ 构建日志 / 临时文件 ══════
39
+ *.log
40
+ *.tmp
41
+
42
+ # ══════ 系统文件 ══════
43
+ .DS_Store
44
+ Thumbs.db
45
+ desktop.ini