Skip to content

Commit 3dbd915

Browse files
Ignacio Van Droogenbroeckclaude
andcommitted
docs: Update quick example to use columnar format
Replace row-based MessagePack example with columnar format to match the arc README and showcase the recommended 2.66x faster format. Changes: - Use columnar data structure with arrays instead of row-based batch - Show multiple records in one example (3 records) - Include more realistic fields (region, datacenter, multiple metrics) - Add response handling with status check - Update performance note to 2.42M RPS Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2390f90 commit 3dbd915

1 file changed

Lines changed: 30 additions & 9 deletions

File tree

docs/intro.md

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,44 @@ Arc is designed for applications that need:
3131
```python
3232
import msgpack
3333
import requests
34+
from datetime import datetime
3435

35-
# Write data
36+
# COLUMNAR FORMAT (RECOMMENDED - 2.66x faster than row format)
37+
# All data organized as columns (arrays), not rows
3638
data = {
37-
"batch": [{
38-
"m": "cpu", # measurement
39-
"t": 1697472000000, # timestamp (ms)
40-
"h": "server01", # host
41-
"fields": {"usage": 45.2}
42-
}]
39+
"m": "cpu", # measurement name
40+
"columns": { # columnar data structure
41+
"time": [
42+
int(datetime.now().timestamp() * 1000),
43+
int(datetime.now().timestamp() * 1000) + 1000,
44+
int(datetime.now().timestamp() * 1000) + 2000
45+
],
46+
"host": ["server01", "server02", "server03"],
47+
"region": ["us-east", "us-west", "eu-central"],
48+
"datacenter": ["aws", "gcp", "azure"],
49+
"usage_idle": [95.0, 85.0, 92.0],
50+
"usage_user": [3.2, 10.5, 5.8],
51+
"usage_system": [1.8, 4.5, 2.2]
52+
}
4353
}
4454

45-
requests.post(
55+
# Send columnar data (2.42M RPS throughput)
56+
response = requests.post(
4657
"http://localhost:8000/write/v2/msgpack",
47-
headers={"Authorization": "Bearer YOUR_TOKEN"},
58+
headers={
59+
"Authorization": "Bearer YOUR_TOKEN",
60+
"Content-Type": "application/msgpack",
61+
"x-arc-database": "default" # Optional: specify database
62+
},
4863
data=msgpack.packb(data)
4964
)
5065

66+
# Check response (returns 204 No Content on success)
67+
if response.status_code == 204:
68+
print(f"Successfully wrote {len(data['columns']['time'])} records!")
69+
else:
70+
print(f"Error {response.status_code}: {response.text}")
71+
5172
# Query data
5273
response = requests.post(
5374
"http://localhost:8000/query",

0 commit comments

Comments
 (0)