Skip to content

Commit a10e885

Browse files
authored
refactor(query): remove lru cache meter (#16260)
* refactor(query): remove useless meter * refactor(query): merge cache and cache_manager * refactor(query): remove meter * refactor(query): remove meter * refactor(query): remove meter * refactor(query): remove meter
1 parent 77248da commit a10e885

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+615
-864
lines changed

Cargo.lock

Lines changed: 5 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ members = [
4848
"src/query/sql",
4949
"src/query/storages/common/blocks",
5050
"src/query/storages/common/cache",
51-
"src/query/storages/common/cache_manager",
5251
"src/query/storages/common/index",
5352
"src/query/storages/common/io",
5453
"src/query/storages/common/pruner",
@@ -195,7 +194,6 @@ databend-query = { path = "src/query/service" }
195194
databend-sqllogictests = { path = "tests/sqllogictests" }
196195
databend-storages-common-blocks = { path = "src/query/storages/common/blocks" }
197196
databend-storages-common-cache = { path = "src/query/storages/common/cache" }
198-
databend-storages-common-cache-manager = { path = "src/query/storages/common/cache_manager" }
199197
databend-storages-common-index = { path = "src/query/storages/common/index" }
200198
databend-storages-common-io = { path = "src/query/storages/common/io" }
201199
databend-storages-common-pruner = { path = "src/query/storages/common/pruner" }

src/common/cache/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ doctest = false
1111
test = true
1212

1313
[dependencies]
14-
bytes = { workspace = true }
1514
hashbrown = { workspace = true }
1615
hashlink = "0.8"
1716

src/common/cache/src/cache.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ pub mod lru;
1717
use std::borrow::Borrow;
1818
use std::hash::Hash;
1919

20-
use crate::Meter;
20+
use crate::mem_sized::MemSized;
2121

2222
/// A trait for a cache.
23-
pub trait Cache<K: Eq + Hash, V, M: Meter<K, V>> {
23+
pub trait Cache<K: Eq + Hash + MemSized, V: MemSized> {
2424
/// Returns a reference to the value corresponding to the given key in the cache, if
2525
/// any.
2626
fn get<Q>(&mut self, k: &Q) -> Option<&V>
@@ -44,7 +44,7 @@ pub trait Cache<K: Eq + Hash, V, M: Meter<K, V>> {
4444

4545
/// Inserts a key-value pair into the cache. If the key already existed, the old value is
4646
/// returned.
47-
fn put(&mut self, k: K, v: V) -> Option<V>;
47+
fn insert(&mut self, k: K, v: V) -> Option<V>;
4848

4949
/// Removes the given key from the cache and returns its corresponding value.
5050
fn pop<Q>(&mut self, k: &Q) -> Option<V>
@@ -67,17 +67,13 @@ pub trait Cache<K: Eq + Hash, V, M: Meter<K, V>> {
6767
/// Returns `true` if the cache contains no key-value pairs.
6868
fn is_empty(&self) -> bool;
6969

70-
/// Returns the maximum size of the key-value pairs the cache can hold, as measured by the
71-
/// `Meter` used by the cache.
72-
fn capacity(&self) -> u64;
70+
/// Returns the maximum bytes size of the key-value pairs the cache can hold.
71+
fn bytes_capacity(&self) -> u64;
7372

74-
/// Sets the size of the key-value pairs the cache can hold, as measured by the `Meter` used by
75-
/// the cache.
76-
fn set_capacity(&mut self, cap: u64);
73+
fn items_capacity(&self) -> u64;
7774

78-
/// Returns the size of all the key-value pairs in the cache, as measured by the `Meter` used
79-
/// by the cache.
80-
fn size(&self) -> u64;
75+
/// Returns the bytes size of all the key-value pairs in the cache.
76+
fn bytes_size(&self) -> u64;
8177

8278
/// Removes all key-value pairs from the cache.
8379
fn clear(&mut self);

0 commit comments

Comments
 (0)