Skip to content

Commit

Permalink
refactor(query): remove useless meter (#16202)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhang2014 authored Aug 7, 2024
1 parent a9cabcd commit 125b431
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 82 deletions.
10 changes: 0 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions src/common/cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@ edition = { workspace = true }
doctest = false
test = true

[features]
heapsize = ["heapsize_"]

[dependencies]
bytes = { workspace = true }
hashbrown = { workspace = true }
hashlink = "0.8"

[target.'cfg(not(target_os = "macos"))'.dependencies]
heapsize_ = { package = "heapsize", version = "0.4.2", optional = true }

[dev-dependencies]

[lints]
Expand Down
7 changes: 1 addition & 6 deletions src/common/cache/src/cache/lru.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,12 @@
//! ```
//!
//! The cache can also be limited by an arbitrary metric calculated from its key-value pairs, see
//! [`LruCache::with_meter`][with_meter] for more information. If the `heapsize` feature is enabled,
//! this crate provides one such alternate metric—`HeapSize`. Custom metrics can be written by
//! [`LruCache::with_meter`][with_meter] for more information. Custom metrics can be written by
//! implementing the [`Meter`][meter] trait.
//!
//! [with_meter]: struct.LruCache.html#method.with_meter
//! [meter]: trait.Meter.html
#[cfg(feature = "heapsize")]
#[cfg(not(target_os = "macos"))]
extern crate heapsize_;

use std::borrow::Borrow;
use std::fmt;
use std::hash::BuildHasher;
Expand Down
6 changes: 0 additions & 6 deletions src/common/cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

#![feature(write_all_vectored)]
#![allow(clippy::uninlined_format_args)]
#[cfg(feature = "heapsize")]
#[cfg(not(target_os = "macos"))]
extern crate heapsize_;

mod cache;
mod meter;
Expand All @@ -29,7 +26,4 @@ pub use meter::count_meter::Count;
pub use meter::count_meter::CountableMeter;
pub use meter::count_meter::CountableMeterWithMeasure;
pub use meter::file_meter::FileSize;
#[cfg(feature = "heapsize")]
#[cfg(not(target_os = "macos"))]
pub use meter::heap_meter::HeapSize;
pub use meter::Meter;
3 changes: 0 additions & 3 deletions src/common/cache/src/meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
pub mod bytes_meter;
pub mod count_meter;
pub mod file_meter;
#[cfg(feature = "heapsize")]
#[cfg(not(target_os = "macos"))]
pub mod heap_meter;

use std::borrow::Borrow;

Expand Down
35 changes: 0 additions & 35 deletions src/common/cache/src/meter/heap_meter.rs

This file was deleted.

16 changes: 0 additions & 16 deletions src/common/cache/tests/it/cache/lru.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,3 @@ fn test_metered_cache_oversize() {
assert!(!cache.contains("foo1"));
assert!(!cache.contains("foo2"));
}

#[cfg(feature = "heapsize")]
#[cfg(not(target_os = "macos"))]
#[test]
fn test_heapsize_cache() {
use databend_common_cache::HeapSize;

let mut cache = LruCache::<&str, (u8, u8, u8), _, _>::with_meter(8, HeapSize);
cache.put("foo1", (1, 2, 3));
cache.put("foo2", (4, 5, 6));
cache.put("foo3", (7, 8, 9));
assert!(!cache.contains("foo1"));
cache.put("foo2", (10, 11, 12));
cache.put("foo4", (13, 14, 15));
assert!(!cache.contains("foo3"));
}

0 comments on commit 125b431

Please sign in to comment.