feat: enable disabling MUB snapshot caching (#1203) (#1264)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
pull/24376/head
Raphael Taylor-Davies 2021-04-21 09:21:31 +01:00 committed by GitHub
parent 70a82cc038
commit 1cf3ab3978
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

@ -33,3 +33,8 @@ tracker = { path = "../tracker" }
[dev-dependencies] # In alphabetical order
test_helpers = { path = "../test_helpers" }
criterion = "0.3"
[features]
default = []
# Disables snapshot caching
nocache = []

View File

@ -140,6 +140,7 @@ impl Chunk {
}
/// Returns a queryable snapshot of this chunk
#[cfg(not(feature = "nocache"))]
pub fn snapshot(&self) -> Arc<ChunkSnapshot> {
let mut guard = self.snapshot.lock();
if let Some(snapshot) = &*guard {
@ -152,6 +153,12 @@ impl Chunk {
snapshot
}
/// Returns a queryable snapshot of this chunk
#[cfg(feature = "nocache")]
pub fn snapshot(&self) -> Arc<ChunkSnapshot> {
Arc::new(ChunkSnapshot::new(self))
}
/// returns true if there is no data in this chunk
pub fn is_empty(&self) -> bool {
self.tables.is_empty()

View File

@ -42,6 +42,11 @@ flate2 = "1.0.20"
tempfile = "3.1.0"
test_helpers = { path = "../test_helpers" }
[features]
default = []
# Enable features for benchmarking
bench = ["mutable_buffer/nocache"]
[[bench]]
name = "influxrpc"
harness = false