Crates.io | PebbleVault |
lib.rs | PebbleVault |
version | 0.6.1 |
source | src |
created_at | 2024-06-25 19:25:17.994421 |
updated_at | 2024-10-23 02:03:22.503086 |
description | A high performance data storage solution written in rust |
homepage | |
repository | |
max_upload_size | |
id | 1283738 |
size | 162,479 |
[!IMPORTANT] PebbleVault is still in early development and is not meant to be used in any production environments yet.
Welcome to PebbleVault, the spatial database that rocks your world! 🚀 PebbleVault is a high-performance spatial database written in Rust, designed for managing 3D spatial data with efficiency and safety in mind.
The VaultManager is the central component of PebbleVault, orchestrating all spatial operations.
Key features:
Represents individual objects within the spatial database.
Key attributes:
Represents a spatial region in the game world.
Key attributes:
Manages persistent storage of spatial data using SQLite.
Key features:
// Create a new VaultManager with custom data type
let mut vault_manager: VaultManager<CustomData> = VaultManager::new("path/to/database.db")?;
// Create or load a region
let region_id = vault_manager.create_or_load_region([0.0, 0.0, 0.0], 100.0)?;
// Add an object to a region with custom data
let object_uuid = Uuid::new_v4();
let custom_data = CustomData { /* ... */ };
vault_manager.add_object(region_id, object_uuid, "player", 10.0, 20.0, 30.0, Arc::new(custom_data))?;
// Query objects in a region
let objects = vault_manager.query_region(region_id, -50.0, -50.0, -50.0, 50.0, 50.0, 50.0)?;
// Transfer a player between regions
let player_uuid = Uuid::new_v4();
let from_region_id = Uuid::new_v4();
let to_region_id = Uuid::new_v4();
vault_manager.transfer_player(player_uuid, from_region_id, to_region_id)?;
// Remove an object
vault_manager.remove_object(object_uuid)?;
// Update an object
let updated_object = SpatialObject { /* ... */ };
vault_manager.update_object(&updated_object)?;
// Save all data to persistent storage
vault_manager.persist_to_disk()?;
use pebblevault::{VaultManager, SpatialObject, CustomData};
use uuid::Uuid;
use std::sync::Arc;
fn main() -> Result<(), String> {
// Create a new VaultManager with custom data type
let mut vault_manager: VaultManager<CustomData> = VaultManager::new("spatial_db.db")?;
// Create a new region
let region_id = vault_manager.create_or_load_region([0.0, 0.0, 0.0], 500.0)?;
// Add some objects to our collection
let object1_uuid = Uuid::new_v4();
let custom_data1 = CustomData { name: "Player One".to_string(), level: 1 };
vault_manager.add_object(region_id, object1_uuid, "player", 10.0, 20.0, 30.0, Arc::new(custom_data1))?;
let object2_uuid = Uuid::new_v4();
let custom_data2 = CustomData { name: "Town Hall".to_string(), level: 5 };
vault_manager.add_object(region_id, object2_uuid, "building", -15.0, 25.0, -5.0, Arc::new(custom_data2))?;
// Find objects in a specific area
let found_objects = vault_manager.query_region(region_id, -20.0, 0.0, -10.0, 20.0, 30.0, 40.0)?;
println!("Found {} objects in the area!", found_objects.len());
// Transfer a player to a new region
let new_region_id = vault_manager.create_or_load_region([100.0, 100.0, 100.0], 500.0)?;
vault_manager.transfer_player(object1_uuid, region_id, new_region_id)?;
println!("Transferred player to new region!");
// Remove an object
vault_manager.remove_object(object2_uuid)?;
println!("Removed building from the region!");
// Save our spatial data collection
vault_manager.persist_to_disk()?;
println!("Our spatial data is safely stored!");
Ok(())
}
PebbleVault includes comprehensive load testing modules to ensure optimal performance under various conditions. The load_test.rs
file provides two main load testing functions:
run_load_test
: A detailed load test with predefined custom data.run_arbitrary_data_load_test
: A load test using arbitrary struct data to demonstrate flexibility.Here's how to run the load tests:
use pebblevault::load_test::{run_load_test, run_arbitrary_data_load_test};
fn main() -> Result<(), String> {
// Run the standard load test
let db_path = "load_test.db";
let num_objects = 100_000;
let num_regions = 10;
let num_operations = 5;
let mut vault_manager = VaultManager::new(db_path)?;
run_load_test(&mut vault_manager, num_objects, num_regions, num_operations)?;
println!("Standard load test completed successfully!");
// Run the arbitrary data load test
run_arbitrary_data_load_test(50_000, 5)?;
println!("Arbitrary data load test completed successfully!");
Ok(())
}
These load tests will:
The load tests help verify the system's performance, persistence capabilities, and ability to handle large datasets with various data types. Feel free to adjust the parameters to suit your testing needs!
We welcome contributions to make PebbleVault even better! If you have ideas for improvements or new features, please check out our contributing guide and join our community of spatial data enthusiasts.
PebbleVault is licensed under the Apache 2.0 License. Explore the spatial universe with confidence! 🌠