rasterizeddb_core 0.0.8

A schemaless, high-performance database written in Rust, designed for speed and scalability.
Documentation
use ahash::RandomState;
use moka::sync::Cache;
use once_cell::sync::Lazy;

pub(crate) const SERVER_PORT: u16 = 8080;
pub(crate) const HEADER_SIZE: u16 = 30;
pub(crate) const CHUNK_SIZE: u32 = 4194304; //4MB

pub const EMPTY_BUFFER: [u8; 8] = [0, 0, 0, 0, 0, 0, 0, 0];

pub(crate) static POSITIONS_CACHE: Lazy<Cache<u64, Vec<(u64, u32)>, RandomState>> =
    Lazy::new(|| {
        let cache = Cache::builder()
            .max_capacity(u64::MAX)
            .build_with_hasher(ahash::RandomState::new());

        return cache;
    });

/// # Rasterized DB (Alpha)
/// ## A new schemaless high-performance database written in Rust from scratch.
///
/// #### Features:
/// `enable_index_caching` to enable query caching
///
/// #### Create a static TABLE
/// ```rust
/// //Local File Storage Database
/// let io_sync = LocalStorageProvider::new(
///     "Some\\Folder",
///     "database.db"
/// );
/// //In-Memory Database
/// let io_sync = MemoryStorageProvider::new();
///
/// let mut table = Table::init(io_sync, false, false).unwrap();
/// ```
///
/// #### Create columns, rows and insert them
/// ```rust
/// let c1 = Column::new(10).unwrap();
/// let c2 = Column::new(-10).unwrap();
/// let str = 'A'.to_string().repeat(100);
/// let c3 = Column::new(str).unwrap();
/// 
/// let mut columns_buffer: Vec<u8> = Vec::with_capacity(
///     c1.len() +
///     c2.len() +
///     c3.len()
/// );
/// 
/// columns_buffer.append(&mut c1.content.to_vec());
/// columns_buffer.append(&mut c2.content.to_vec());
/// columns_buffer.append(&mut c3.content.to_vec());
/// 
/// let insert_row = InsertOrUpdateRow {
///    columns_data: columns_buffer.clone()
/// };
/// 
/// table.insert_row(insert_row).await;
/// //OR unsafe
/// table.insert_row_unsync(insert_row).await;
/// ```
/// #### Build in-memory file indexes
/// ```rust
/// table.rebuild_in_memory_indexes();
/// ```
///
/// #### Retrieve a row
/// ```rust
/// //Rasterized Query Language (Alpha)
/// let query_evaluation = parse_rql(&format!(r#"
///     BEGIN
///     SELECT FROM NAME_DOESNT_MATTER_FOR_NOW
///     WHERE COL(1) = -10
///     LIMIT 2
///     END
/// "#)).unwrap();
///
/// let rows = table.execute_query(query_evaluation.parser_result).await?;
/// ```
/// #### Update a row
/// ```rust
/// let update_row = InsertOrUpdateRow {
///     columns_data: columns_buffer_update // Same as insert_row
/// };
///
/// table.update_row_by_id(3, update_row).await;
/// ```
///
/// #### Delete a row
/// ```rust
/// // Invalidates cache automatically
/// table.delete_row_by_id(10).unwrap();
/// ```
///
/// #### Table Maintanance
/// ```rust
/// // Vacuum the table
/// table.vacuum_table().await;
///
/// // Must rebuild in-memory file indexes after vacuum
/// table.rebuild_in_memory_indexes();
/// ```
pub mod core;

pub(crate) mod instructions;
pub mod memory_pool;
pub mod rql;
pub mod simds;