Skip to content

Commit 08037f5

Browse files
committed
Rename parquet shard cache funcs
Signed-off-by: SungJin1212 <tjdwls1201@gmail.com>
1 parent 51b5c1d commit 08037f5

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

pkg/querier/parquet_queryable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func NewParquetQueryable(
134134
return nil, err
135135
}
136136

137-
cache, err := parquetutil.NewCache[parquet_storage.ParquetShard](&config.ParquetShardCache, "parquet-shards", extprom.WrapRegistererWith(prometheus.Labels{"component": "querier"}, reg))
137+
cache, err := parquetutil.NewParquetShardCache[parquet_storage.ParquetShard](&config.ParquetShardCache, "parquet-shards", extprom.WrapRegistererWith(prometheus.Labels{"component": "querier"}, reg))
138138
if err != nil {
139139
return nil, err
140140
}

pkg/util/parquetutil/cache.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type cacheEntry[T any] struct {
5252
expiresAt time.Time
5353
}
5454

55-
type Cache[T any] struct {
55+
type ParquetShardCache[T any] struct {
5656
cache *lru.Cache[string, *cacheEntry[T]]
5757
name string
5858
metrics *cacheMetrics
@@ -72,7 +72,7 @@ func (cfg *CacheConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)
7272
cfg.MaintenanceInterval = defaultMaintenanceInterval
7373
}
7474

75-
func NewCache[T any](cfg *CacheConfig, name string, reg prometheus.Registerer) (CacheInterface[T], error) {
75+
func NewParquetShardCache[T any](cfg *CacheConfig, name string, reg prometheus.Registerer) (CacheInterface[T], error) {
7676
if cfg.ParquetShardCacheSize <= 0 {
7777
return &noopCache[T]{}, nil
7878
}
@@ -85,7 +85,7 @@ func NewCache[T any](cfg *CacheConfig, name string, reg prometheus.Registerer) (
8585
return nil, err
8686
}
8787

88-
c := &Cache[T]{
88+
c := &ParquetShardCache[T]{
8989
cache: cache,
9090
name: name,
9191
metrics: metrics,
@@ -100,7 +100,7 @@ func NewCache[T any](cfg *CacheConfig, name string, reg prometheus.Registerer) (
100100
return c, nil
101101
}
102102

103-
func (c *Cache[T]) maintenanceLoop(interval time.Duration) {
103+
func (c *ParquetShardCache[T]) maintenanceLoop(interval time.Duration) {
104104
ticker := time.NewTicker(interval)
105105
defer ticker.Stop()
106106

@@ -123,7 +123,7 @@ func (c *Cache[T]) maintenanceLoop(interval time.Duration) {
123123
}
124124
}
125125

126-
func (c *Cache[T]) Get(path string) (r T) {
126+
func (c *ParquetShardCache[T]) Get(path string) (r T) {
127127
if entry, ok := c.cache.Get(path); ok {
128128
isExpired := !entry.expiresAt.IsZero() && time.Now().After(entry.expiresAt)
129129

@@ -140,7 +140,7 @@ func (c *Cache[T]) Get(path string) (r T) {
140140
return
141141
}
142142

143-
func (c *Cache[T]) Set(path string, reader T) {
143+
func (c *ParquetShardCache[T]) Set(path string, reader T) {
144144
if !c.cache.Contains(path) {
145145
c.metrics.size.WithLabelValues(c.name).Inc()
146146
}
@@ -158,7 +158,7 @@ func (c *Cache[T]) Set(path string, reader T) {
158158
c.cache.Add(path, entry)
159159
}
160160

161-
func (c *Cache[T]) Close() {
161+
func (c *ParquetShardCache[T]) Close() {
162162
close(c.stopCh)
163163
}
164164

pkg/util/parquetutil/cache_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func Test_Cache_LRUEviction(t *testing.T) {
1717
ParquetShardCacheTTL: 0,
1818
MaintenanceInterval: time.Minute,
1919
}
20-
cache, err := NewCache[string](cfg, "test", reg)
20+
cache, err := NewParquetShardCache[string](cfg, "test", reg)
2121
require.NoError(t, err)
2222
defer cache.Close()
2323

@@ -59,7 +59,7 @@ func Test_Cache_TTLEvictionByGet(t *testing.T) {
5959
MaintenanceInterval: time.Minute,
6060
}
6161

62-
cache, err := NewCache[string](cfg, "test", reg)
62+
cache, err := NewParquetShardCache[string](cfg, "test", reg)
6363
require.NoError(t, err)
6464
defer cache.Close()
6565

@@ -98,7 +98,7 @@ func Test_Cache_TTLEvictionByLoop(t *testing.T) {
9898
MaintenanceInterval: 100 * time.Millisecond,
9999
}
100100

101-
cache, err := NewCache[string](cfg, "test", reg)
101+
cache, err := NewParquetShardCache[string](cfg, "test", reg)
102102
require.NoError(t, err)
103103
defer cache.Close()
104104

@@ -110,7 +110,7 @@ func Test_Cache_TTLEvictionByLoop(t *testing.T) {
110110
// sleep longer than TTL
111111
time.Sleep(150 * time.Millisecond)
112112

113-
if c, ok := cache.(*Cache[string]); ok {
113+
if c, ok := cache.(*ParquetShardCache[string]); ok {
114114
// should delete by maintenance loop
115115
_, ok := c.cache.Peek("key1")
116116
require.False(t, ok)

0 commit comments

Comments
 (0)