Skip to content

Commit 13c8f21

Browse files
tae898Copilot
andcommitted
docs: add JVM API documentation and update references in existing docs
Co-authored-by: Copilot <copilot@github.com>
1 parent 2797e65 commit 13c8f21

10 files changed

Lines changed: 137 additions & 21 deletions

File tree

bindings/python/docs/api/jvm.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# JVM API
2+
3+
Helpers for locating the bundled runtime and configuring the JVM before the first
4+
database or server is created.
5+
6+
!!! warning "Configure once per process"
7+
JVM options are locked after the JVM starts. Call `start_jvm(...)` before the
8+
first `create_database(...)`, `open_database(...)`, or `create_server(...)`.
9+
10+
## Overview
11+
12+
The `arcadedb_embedded.jvm` module provides three public entry points:
13+
14+
- `start_jvm(...)` to configure and start the bundled JVM explicitly
15+
- `shutdown_jvm()` to shut down a JVM started in the current process
16+
- runtime location helpers for jars and the bundled JRE library
17+
18+
## start_jvm
19+
20+
```python
21+
from arcadedb_embedded.jvm import start_jvm
22+
23+
start_jvm(
24+
heap_size="8g",
25+
jvm_args="-XX:MaxDirectMemorySize=8g",
26+
common_pool_parallelism=8,
27+
)
28+
```
29+
30+
**Parameters:**
31+
32+
- `heap_size` (`Optional[str]`): Maximum JVM heap, for example `"4g"` or `"4096m"`
33+
- `disable_xml_limits` (`bool`): If `True`, relaxes JDK XML entity limits for large XML imports
34+
- `jvm_args` (`Optional[Iterable[str] | str]`): Additional JVM flags as a string or iterable
35+
- `common_pool_parallelism` (`Optional[int]`): Explicit cap for `ForkJoinPool.common.parallelism`
36+
37+
**Raises:**
38+
39+
- `ArcadeDBError`: If the JVM is already started with a different configuration, the bundled runtime is missing, or JPype cannot start the JVM
40+
41+
**Notes:**
42+
43+
- The bundled JRE is always used; no external Java installation is required
44+
- The module injects required defaults such as `jdk.incubator.vector`, UTF-8 file encoding, and required `--add-opens` flags if they are not already provided
45+
- `ARCADEDB_JVM_ARGS` remains supported as an environment fallback, but in-code configuration is preferred
46+
47+
## shutdown_jvm
48+
49+
```python
50+
from arcadedb_embedded.jvm import shutdown_jvm
51+
52+
shutdown_jvm()
53+
```
54+
55+
Shuts down the JVM if it is running in the current process.
56+
57+
!!! note
58+
Most application code does not need to call this directly. Normal database and
59+
server usage should focus on proper object cleanup; use this helper mainly in
60+
test harnesses or short-lived tooling.
61+
62+
## get_jar_path
63+
64+
```python
65+
from arcadedb_embedded.jvm import get_jar_path
66+
67+
jar_dir = get_jar_path()
68+
```
69+
70+
Returns the directory containing the bundled ArcadeDB JAR files.
71+
72+
## get_bundled_jre_lib_path
73+
74+
```python
75+
from arcadedb_embedded.jvm import get_bundled_jre_lib_path
76+
77+
jvm_lib = get_bundled_jre_lib_path()
78+
```
79+
80+
Returns the platform-specific JVM library path inside the bundled runtime:
81+
82+
- Linux: `lib/server/libjvm.so`
83+
- macOS: `lib/server/libjvm.dylib`
84+
- Windows: `bin/server/jvm.dll`
85+
86+
Raises `ArcadeDBError` if the bundled runtime is missing or incomplete.
87+
88+
## Recommended Pattern
89+
90+
```python
91+
from arcadedb_embedded.jvm import start_jvm
92+
import arcadedb_embedded as arcadedb
93+
94+
start_jvm(heap_size="8g", jvm_args="-XX:MaxDirectMemorySize=8g")
95+
96+
with arcadedb.create_database("./db") as db:
97+
row = db.query("sql", "SELECT 1 AS ok").one()
98+
assert row.get("ok") == 1
99+
```

bindings/python/docs/api/record-wrappers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ when you explicitly need the wrapper object in hand.
2828

2929
```python
3030
import arcadedb_embedded as arcadedb
31-
from arcadedb_embedded.graph import Document, Vertex, Edge
31+
from arcadedb_embedded import Document, Vertex, Edge
3232

3333
with arcadedb.create_database("./mydb") as db:
3434
db.command("sql", "CREATE DOCUMENT TYPE Note")
@@ -186,7 +186,7 @@ with db.transaction():
186186
Static method to wrap Java objects as Python wrappers. Automatically detects type.
187187

188188
```python
189-
from arcadedb_embedded.graph import Document
189+
from arcadedb_embedded import Document
190190

191191
# Wrap Java object and automatically detect type
192192
wrapped = Document.wrap(java_object)

bindings/python/docs/development/build-architecture.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ This simple class tells setuptools "this package has binary content" which:
8080

8181
- Triggers platform-specific wheel naming
8282
- Makes uv pip download the correct wheel for each platform
83-
- Enables platform tags like `macosx_11_0_arm64`, `manylinux_2_17_x86_64`, etc.
83+
- Enables platform tags like `macosx_11_0_arm64`, `manylinux_2_34_x86_64`, etc.
8484

8585
**Without setup.py**: All platforms → `arcadedb_embedded-X.Y.Z-py3-none-any.whl` (wrong!)
8686

87-
**With setup.py**: Each platform → `arcadedb_embedded-X.Y.Z-py3-none-<platform>.whl` (correct!)
87+
**With setup.py**: Each platform → `arcadedb_embedded-X.Y.Z-cp<pyver>-cp<pyver>-<platform>.whl` (correct!)
8888

8989
See `bindings/python/setup.py` for the complete implementation.
9090

bindings/python/docs/development/troubleshooting.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,12 @@ Configure JVM memory in Python **before the first database or server is created*
146146
147147
```python
148148
import arcadedb_embedded as arcadedb
149+
from arcadedb_embedded.jvm import start_jvm
149150

150151
# Default: 4GB heap (no changes needed)
151152

152153
# Production: 8GB heap with matching initial size
153-
arcadedb.start_jvm(heap_size="8g", jvm_args="-Xms8g")
154+
start_jvm(heap_size="8g", jvm_args="-Xms8g")
154155
```
155156
156157
**Common JVM Options:**
@@ -170,7 +171,9 @@ For applications using vector indexes, control memory usage:
170171
171172
```python
172173
# Conservative: bounded caches for large vector datasets
173-
arcadedb.start_jvm(
174+
from arcadedb_embedded.jvm import start_jvm
175+
176+
start_jvm(
174177
heap_size="8g",
175178
jvm_args=(
176179
"-Xms8g -XX:MaxDirectMemorySize=8g "
@@ -214,13 +217,15 @@ Rule of thumb: Plan for 1.5-2× your heap size in actual RAM
214217
215218
```python
216219
# Small datasets (<1M records, <100K vectors)
217-
arcadedb.start_jvm(heap_size="2g", jvm_args="-Xms2g")
220+
from arcadedb_embedded.jvm import start_jvm
221+
222+
start_jvm(heap_size="2g", jvm_args="-Xms2g")
218223

219224
# Medium datasets (1M-10M records, 100K-1M vectors)
220-
arcadedb.start_jvm(heap_size="8g", jvm_args="-Xms8g -XX:MaxDirectMemorySize=8g")
225+
start_jvm(heap_size="8g", jvm_args="-Xms8g -XX:MaxDirectMemorySize=8g")
221226

222227
# Large datasets (10M+ records, 1M+ vectors) with bounded caches
223-
arcadedb.start_jvm(
228+
start_jvm(
224229
heap_size="16g",
225230
jvm_args=(
226231
"-Xms16g -XX:MaxDirectMemorySize=16g "
@@ -231,7 +236,7 @@ arcadedb.start_jvm(
231236
)
232237

233238
# High-dimensional vectors (e.g., 1536-dim embeddings)
234-
arcadedb.start_jvm(
239+
start_jvm(
235240
heap_size="8g",
236241
jvm_args=(
237242
"-Xms8g -XX:MaxDirectMemorySize=8g "
@@ -262,13 +267,16 @@ arcadedb.start_jvm(
262267
263268
1. **Increase Heap (preferred)**:
264269
```python
265-
import arcadedb_embedded as arcadedb
266-
arcadedb.start_jvm(heap_size="8g", jvm_args="-Xms8g")
270+
from arcadedb_embedded.jvm import start_jvm
271+
272+
start_jvm(heap_size="8g", jvm_args="-Xms8g")
267273
```
268274
269275
2. **Bound Vector Caches** (for vector workloads):
270276
```python
271-
arcadedb.start_jvm(
277+
from arcadedb_embedded.jvm import start_jvm
278+
279+
start_jvm(
272280
heap_size="8g",
273281
jvm_args=(
274282
"-Xms8g "

bindings/python/docs/examples/05_csv_import_graph.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,9 @@ Prefer configuring heap inside the script before it creates the first database:
457457

458458
```python
459459
import arcadedb_embedded as arcadedb
460+
from arcadedb_embedded.jvm import start_jvm
460461

461-
arcadedb.start_jvm(heap_size="8g", jvm_args="-Xms8g")
462+
start_jvm(heap_size="8g", jvm_args="-Xms8g")
462463
```
463464

464465
**Memory Planning:**

bindings/python/docs/getting-started/distributions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ with arcadedb.create_database("./test") as db:
145145
uv pip automatically selects the correct platform-specific wheel:
146146

147147
```bash
148-
# On Linux x64, installs: arcadedb_embedded-X.Y.Z-py3-none-manylinux_2_17_x86_64.whl
149-
# On macOS ARM64, installs: arcadedb_embedded-X.Y.Z-py3-none-macosx_11_0_arm64.whl
150-
# On Windows x86_64, installs: arcadedb_embedded-X.Y.Z-py3-none-win_amd64.whl
148+
# On Linux x64 for Python 3.12, installs: arcadedb_embedded-X.Y.Z-cp312-cp312-manylinux_2_34_x86_64.whl
149+
# On macOS ARM64 for Python 3.12, installs: arcadedb_embedded-X.Y.Z-cp312-cp312-macosx_11_0_arm64.whl
150+
# On Windows x86_64 for Python 3.12, installs: arcadedb_embedded-X.Y.Z-cp312-cp312-win_amd64.whl
151151
# etc.
152152
```
153153

bindings/python/docs/getting-started/installation.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ Built wheels will be in `dist/`:
8787

8888
```text
8989
dist/
90-
└── arcadedb_embedded-X.Y.Z-py3-none-<platform>.whl
90+
└── arcadedb_embedded-X.Y.Z-cp<pyver>-cp<pyver>-<platform>.whl
91+
```
92+
93+
For example, a Linux x86_64 build on Python 3.12 now looks like:
94+
95+
```text
96+
arcadedb_embedded-X.Y.Z-cp312-cp312-manylinux_2_34_x86_64.whl
9197
```
9298

9399
Install locally:

bindings/python/docs/guide/core/database.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,10 @@ with open_with_retry("./mydb") as db:
485485
```python
486486
# JVM starts on first database creation
487487
import arcadedb_embedded as arcadedb
488+
from arcadedb_embedded.jvm import start_jvm
488489

489490
# Optional: configure JVM before first database or server
490-
arcadedb.start_jvm(heap_size="8g")
491+
start_jvm(heap_size="8g")
491492

492493
# JVM runs for entire Python process
493494
with arcadedb.create_database("./db1") as db1:

bindings/python/docs/guide/operations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ ArcadeDB has **three distinct types of logs** stored in **two different location
108108
**Verbosity**: Controlled by Java system properties:
109109

110110
```python
111-
import arcadedb_embedded as arcadedb
111+
from arcadedb_embedded.jvm import start_jvm
112112

113113
# Set before the first database or server is created
114-
arcadedb.start_jvm(jvm_args="-Djava.util.logging.level=DEBUG -Darcadedb.log.level=FINE")
114+
start_jvm(jvm_args="-Djava.util.logging.level=DEBUG -Darcadedb.log.level=FINE")
115115
```
116116

117117
## Database Files (Embedded Mode)

bindings/python/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ nav:
179179
- API Reference:
180180
- Database: api/database.md
181181
- GraphBatch: api/graph_batch.md
182+
- JVM: api/jvm.md
182183
- Record Wrappers: api/record-wrappers.md
183184
- Results: api/results.md
184185
- Server: api/server.md

0 commit comments

Comments
 (0)