pub struct LiquidCacheLocalBuilder { /* private fields */ }Expand description
Builder for in-process liquid cache session context
This allows you to use liquid cache within the same process, instead of using the client-server architecture as in the default mode.
§Example
use liquid_cache_local::{
storage::cache_policies::LiquidPolicy,
LiquidCacheLocalBuilder,
};
use datafusion::prelude::{SessionConfig, SessionContext};
use tempfile::TempDir;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let temp_dir = TempDir::new().unwrap();
let (ctx, _) = LiquidCacheLocalBuilder::new()
.with_max_cache_bytes(1024 * 1024 * 1024) // 1GB
.with_cache_dir(temp_dir.path().to_path_buf())
.with_cache_policy(Box::new(LiquidPolicy::new()))
.build(SessionConfig::new())?;
// Register the test parquet file
ctx.register_parquet("hits", "../../examples/nano_hits.parquet", Default::default())
.await?;
ctx.sql("SELECT COUNT(*) FROM hits").await?.show().await?;
Ok(())
}Implementations§
Source§impl LiquidCacheLocalBuilder
impl LiquidCacheLocalBuilder
Sourcepub fn with_batch_size(self, batch_size: usize) -> Self
pub fn with_batch_size(self, batch_size: usize) -> Self
Set batch size
Sourcepub fn with_max_cache_bytes(self, max_cache_bytes: usize) -> Self
pub fn with_max_cache_bytes(self, max_cache_bytes: usize) -> Self
Set maximum cache size in bytes
Sourcepub fn with_cache_dir(self, cache_dir: PathBuf) -> Self
pub fn with_cache_dir(self, cache_dir: PathBuf) -> Self
Set cache directory
Sourcepub fn with_squeeze_policy(self, squeeze_policy: Box<dyn SqueezePolicy>) -> Self
pub fn with_squeeze_policy(self, squeeze_policy: Box<dyn SqueezePolicy>) -> Self
Set squeeze policy
Sourcepub fn with_cache_policy(self, cache_policy: Box<dyn CachePolicy>) -> Self
pub fn with_cache_policy(self, cache_policy: Box<dyn CachePolicy>) -> Self
Set cache strategy
Sourcepub fn with_io_mode(self, io_mode: IoMode) -> Self
pub fn with_io_mode(self, io_mode: IoMode) -> Self
Set IO mode
Sourcepub fn build(
self,
config: SessionConfig,
) -> Result<(SessionContext, LiquidCacheRef)>
pub fn build( self, config: SessionConfig, ) -> Result<(SessionContext, LiquidCacheRef)>
Build a SessionContext with liquid cache configured Returns the SessionContext and the liquid cache reference
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LiquidCacheLocalBuilder
impl !RefUnwindSafe for LiquidCacheLocalBuilder
impl Send for LiquidCacheLocalBuilder
impl Sync for LiquidCacheLocalBuilder
impl Unpin for LiquidCacheLocalBuilder
impl !UnwindSafe for LiquidCacheLocalBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request