iridium-db 0.4.0

A high-performance vector-graph hybrid storage and indexing engine
use super::blob::{
    BlobGetResult, BlobPrefixDeleteResult, BlobPutOptions, BlobPutResult, BlobReadOptions,
};
use super::types::{Result, StorageHandle};
#[cfg(feature = "rhodium-backend")]
use rhodium::core::storage::blob::CompiledPlanCacheDescriptor;

pub fn put_blob(handle: &mut StorageHandle, blob_id: &str, bytes: &[u8]) -> Result<()> {
    handle.blob_store.put_blob(blob_id, bytes)
}

pub fn put_blob_with_options(
    handle: &mut StorageHandle,
    blob_id: &str,
    bytes: &[u8],
    options: BlobPutOptions,
) -> Result<BlobPutResult> {
    handle
        .blob_store
        .put_blob_with_options(blob_id, bytes, options)
}

pub fn get_blob(handle: &StorageHandle, blob_id: &str) -> Result<Option<Vec<u8>>> {
    handle.blob_store.get_blob(blob_id)
}

pub fn get_blob_with_options(
    handle: &StorageHandle,
    blob_id: &str,
    options: BlobReadOptions,
) -> Result<Option<BlobGetResult>> {
    handle.blob_store.get_blob_with_options(blob_id, options)
}

#[cfg(feature = "rhodium-backend")]
pub fn put_compiled_plan_with_options(
    handle: &mut StorageHandle,
    descriptor: &CompiledPlanCacheDescriptor,
    bytes: &[u8],
    options: BlobPutOptions,
) -> Result<BlobPutResult> {
    handle
        .blob_store
        .put_compiled_plan_with_options(descriptor, bytes, options)
}

#[cfg(feature = "rhodium-backend")]
pub fn get_compiled_plan_with_options(
    handle: &StorageHandle,
    descriptor: &CompiledPlanCacheDescriptor,
    options: BlobReadOptions,
) -> Result<Option<BlobGetResult>> {
    handle
        .blob_store
        .get_compiled_plan_with_options(descriptor, options)
}

pub fn has_blob(handle: &StorageHandle, blob_id: &str) -> Result<bool> {
    handle.blob_store.has_blob(blob_id)
}

pub fn delete_blob(handle: &mut StorageHandle, blob_id: &str) -> Result<()> {
    handle.blob_store.delete_blob(blob_id)
}

pub fn has_blobs(handle: &StorageHandle, blob_ids: &[String]) -> Result<Vec<bool>> {
    handle.blob_store.has_blobs(blob_ids)
}

pub fn delete_blobs(handle: &mut StorageHandle, blob_ids: &[String]) -> Result<usize> {
    handle.blob_store.delete_blobs(blob_ids)
}

pub fn list_blob_prefix(
    handle: &StorageHandle,
    namespace: &str,
    prefix: &str,
    limit: usize,
) -> Result<Vec<String>> {
    handle.blob_store.list_prefix(namespace, prefix, limit)
}

pub fn delete_blob_prefix(
    handle: &mut StorageHandle,
    namespace: &str,
    prefix: &str,
    batch_limit: usize,
) -> Result<BlobPrefixDeleteResult> {
    handle
        .blob_store
        .delete_prefix(namespace, prefix, batch_limit)
}