### Install SmolDB Dependencies (Shell) Source: https://github.com/kshivendu/smoldb/blob/dev/DEVELOPMENT.md Installs the required packages for SmolDB, specifically protobuf-compiler and libprotobuf-dev, which are necessary for gRPC API functionality. This command should be run on a Debian-based Linux system. ```shell sudo apt update && sudo apt upgrade -y sudo apt install -y protobuf-compiler libprotobuf-dev ``` -------------------------------- ### Run SmolDB with Docker Source: https://github.com/kshivendu/smoldb/blob/dev/README.md This snippet shows how to pull and run the SmolDB Docker image. It exposes port 9000 and mounts a local 'storage' directory for persistence. Ensure Docker is installed and running. ```bash docker pull ghcr.io/kshivendu/smoldb:dev docker run -p 9000:9000 -v $(pwd)/storage:/storage ghcr.io/kshivendu/smoldb:dev ``` -------------------------------- ### Compile and Run SmolDB Locally Source: https://github.com/kshivendu/smoldb/blob/dev/README.md This command compiles and runs the SmolDB project locally using Cargo, the Rust package manager. This requires Rust and Cargo to be installed on your system. ```bash cargo run -r ``` -------------------------------- ### Retrieve All Points from a Collection Source: https://github.com/kshivendu/smoldb/blob/dev/README.md This cURL command fetches all points from the 'test' collection using the GET HTTP method. The response includes a 'result' object containing a list of 'points' and the 'time' taken for the operation. The endpoint is 'http://localhost:9000/collections/test/points'. ```bash curl -X GET http://localhost:9000/collections/test/points ``` -------------------------------- ### Get Collection Cluster Info in SmolDB Source: https://github.com/kshivendu/smoldb/blob/dev/README.md This cURL command retrieves the cluster information for the 'test' collection. It uses the GET HTTP method and returns details such as peer ID, shard count, local shards status, and remote shards. The endpoint is 'http://localhost:9000/collections/test/cluster'. ```bash curl -X GET http://localhost:9000/collections/test/cluster ``` -------------------------------- ### Retrieve a Specific Point from a Collection Source: https://github.com/kshivendu/smoldb/blob/dev/README.md This cURL command retrieves a specific point by its ID (e.g., ID 0) from the 'test' collection. It uses the GET HTTP method and targets the endpoint 'http://localhost:9000/collections/test/points/0'. ```bash curl -X GET http://localhost:9000/collections/test/points/0 ``` -------------------------------- ### Run Smolbench Benchmarks (Shell) Source: https://github.com/kshivendu/smoldb/blob/dev/DEVELOPMENT.md Commands to execute the smolbench tool for performance testing. Includes basic execution, running with specific parameters for upserts and searches, and running upsert and search operations concurrently in separate terminals. ```shell cargo run -p smolbench # upserts cargo run -p smolbench -- -n 100k --uri http://localhost:9001 -b 1k ``` ```shell # terminal 1 (upsert): cargo run -p smolbench -- --skip-read -n 100M --delay 1000 -b 100 # terminal 2 (search): watch -n1 'cargo run -p smolbench -- --skip-write -n 100M --delay 1000 -b 100' ``` -------------------------------- ### List and Run Cargo Benches (Shell) Source: https://github.com/kshivendu/smoldb/blob/dev/DEVELOPMENT.md Commands for managing and running benchmarks using Cargo. This includes listing all available benchmarks, running all benchmarks, running benchmarks within a specific group (e.g., 'upserts'), and listing all benches. ```shell cargo bench -- --list # List benches cargo bench # Run all benches cargo bench upserts # Run all benches in upserts group ``` -------------------------------- ### Interact with SmolDB gRPC API (Shell) Source: https://github.com/kshivendu/smoldb/blob/dev/DEVELOPMENT.md Demonstrates how to interact with the internal gRPC API of SmolDB using grpcurl. It specifies the plaintext transport, import path for proto files, the proto file itself, and the address and service/method to call. ```shell grpcurl -plaintext -import-path src/api/grpc/proto/ -proto smoldb.proto 0.0.0.0:5000 smoldb.Service/RootApi ``` -------------------------------- ### Serve Criterion Reports Locally (Python) Source: https://github.com/kshivendu/smoldb/blob/dev/DEVELOPMENT.md Serves the benchmark reports generated by Criterion using Python's built-in HTTP server. This allows easy access to the reports via a web browser. The reports are typically located in the `target/criterion/report/` directory. ```shell python -m http.server . ``` -------------------------------- ### Create a Collection in SmolDB Source: https://github.com/kshivendu/smoldb/blob/dev/README.md This cURL command demonstrates how to create a new collection named 'test' in SmolDB. It uses the PUT HTTP method and requires a JSON payload for parameters. The collection is created at the 'http://localhost:9000/collections/test'. ```bash curl -X PUT http://localhost:9000/collections/test \ -H "Content-Type: application/json" \ -d '{ "params": "..." }' ``` -------------------------------- ### Points API Source: https://github.com/kshivendu/smoldb/blob/dev/README.md Endpoints for adding, retrieving, and managing points within collections. ```APIDOC ## PUT /collections/{collection_name}/points ### Description Adds multiple points to a specified collection. ### Method PUT ### Endpoint /collections/{collection_name}/points ### Parameters #### Path Parameters - **collection_name** (string) - Required - The name of the collection to add points to. #### Request Body - **points** (array) - Required - An array of point objects to add. - **id** (integer) - Required - The unique identifier for the point. - **payload** (object) - Optional - Additional data associated with the point. ### Request Example ```json { "points": [ { "id": 0, "payload": { "msg": "hello world" } }, { "id": 10, "payload": { "msg": "foo bar" } }, { "id": 123, "payload": { "msg": "bar baz" } } ] } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation of points addition. #### Response Example ```json { "message": "Points added successfully." } ``` ``` ```APIDOC ## GET /collections/{collection_name}/points ### Description Retrieves all points from a specified collection. ### Method GET ### Endpoint /collections/{collection_name}/points ### Parameters #### Path Parameters - **collection_name** (string) - Required - The name of the collection to retrieve points from. ### Response #### Success Response (200) - **result** (object) - **points** (array) - An array of point objects. - **id** (integer) - The unique identifier for the point. - **payload** (object) - Additional data associated with the point. - **time** (number) - The time taken to process the request. #### Response Example ```json { "result": { "points": [ { "id": 0, "payload": { "msg": "hello world" } }, { "id": 10, "payload": { "msg": "foo bar" } } ] }, "time": 0.000211024 } ``` ``` ```APIDOC ## GET /collections/{collection_name}/points/{point_id} ### Description Retrieves a specific point from a collection by its ID. ### Method GET ### Endpoint /collections/{collection_name}/points/{point_id} ### Parameters #### Path Parameters - **collection_name** (string) - Required - The name of the collection. - **point_id** (integer) - Required - The ID of the point to retrieve. ### Response #### Success Response (200) - **result** (object) - **point** (object) - **id** (integer) - The unique identifier for the point. - **payload** (object) - Additional data associated with the point. - **time** (number) - The time taken to process the request. #### Response Example ```json { "result": { "point": { "id": 0, "payload": { "msg": "hello world" } } }, "time": 0.000150000 } ``` ``` -------------------------------- ### Generate Flamegraph for Benchmarks (Shell) Source: https://github.com/kshivendu/smoldb/blob/dev/DEVELOPMENT.md Generates a flame graph for a specific benchmark group ('upsert' in this case) using the `cargo-flamegraph` tool. The output is saved as a scalable vector graphics (SVG) file, useful for performance profiling. ```shell cargo flamegraph --bench upsert -o flamegraph.svg -- --bench ``` -------------------------------- ### Collection Management API Source: https://github.com/kshivendu/smoldb/blob/dev/README.md Endpoints for managing collections within SmolDB, such as creating new collections. ```APIDOC ## PUT /collections/{name} ### Description Creates a new collection with the specified name. ### Method PUT ### Endpoint /collections/{name} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the collection to create. #### Request Body - **params** (object) - Required - Parameters for collection creation (details depend on implementation). ### Request Example ```json { "params": "..." } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation of collection creation. #### Response Example ```json { "message": "Collection 'test' created successfully." } ``` ``` -------------------------------- ### Cluster Info API Source: https://github.com/kshivendu/smoldb/blob/dev/README.md Endpoints for retrieving cluster information for a collection. ```APIDOC ## GET /collections/{collection_name}/cluster ### Description Retrieves the cluster information for a specified collection. ### Method GET ### Endpoint /collections/{collection_name}/cluster ### Parameters #### Path Parameters - **collection_name** (string) - Required - The name of the collection. ### Response #### Success Response (200) - **peer_id** (integer) - The ID of the current peer. - **shard_count** (integer) - The total number of shards in the collection. - **local_shards** (array) - Information about shards managed by the local peer. - **shard_id** (integer) - The ID of the shard. - **point_count** (integer) - The number of points in the shard. - **state** (string) - The current state of the shard (e.g., "Active"). - **remote_shards** (array) - Information about shards managed by remote peers. #### Response Example ```json { "peer_id": 0, "shard_count": 2, "local_shards": [ { "shard_id": 1, "point_count": 1, "state": "Active" }, { "shard_id": 0, "point_count": 2, "state": "Active" } ], "remote_shards": [] } ``` ``` -------------------------------- ### Add Points to a Collection in SmolDB Source: https://github.com/kshivendu/smoldb/blob/dev/README.md This cURL command adds points to the 'test' collection. It uses the PUT HTTP method and expects a JSON array of points, each with an 'id' and an optional 'payload'. The endpoint is 'http://localhost:9000/collections/test/points'. ```bash curl -X PUT http://localhost:9000/collections/test/points \ -H "Content-Type: application/json" \ -d '{ "points": [ { "id": 0, "payload": { "msg": "hello world" } }, { "id": 10, "payload": { "msg": "foo bar" } }, { "id": 123, "payload": { "msg": "bar baz" } } ]' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.