Repository navigation
Expand file tree
/
Copy pathCacheStats.java
More file actions
132 lines (121 loc) · 3.59 KB
/
Copy pathCacheStats.java
File metadata and controls
132 lines (121 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/**
*
* Copyright (C) TidesDB
*
* Original Author: Alex Gaetano Padula
*
* Licensed under the Mozilla Public License, v. 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.mozilla.org/en-US/MPL/2.0/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tidesdb;
/**
* Statistics about the block cache in a {@link TidesDB} instance. Created by
* the native library and returned from {@link TidesDB#getCacheStats()}.
*/
public class CacheStats {
private final boolean enabled;
private final long totalEntries;
private final long totalBytes;
private final long hits;
private final long misses;
private final double hitRate;
private final long numPartitions;
/**
* Creates a new {@code CacheStats} instance. Typically called by the JNI
* bridge rather than application code.
*
* @param enabled whether the cache is enabled
* @param totalEntries the total number of cache entries
* @param totalBytes the total bytes used by the cache
* @param hits the number of cache hits
* @param misses the number of cache misses
* @param hitRate the cache hit rate (0.0 to 1.0)
* @param numPartitions the number of cache partitions
*/
public CacheStats(boolean enabled, long totalEntries, long totalBytes, long hits, long misses, double hitRate, long numPartitions) {
this.enabled = enabled;
this.totalEntries = totalEntries;
this.totalBytes = totalBytes;
this.hits = hits;
this.misses = misses;
this.hitRate = hitRate;
this.numPartitions = numPartitions;
}
/**
* Returns whether the block cache is enabled.
*
* @return {@code true} if the cache is enabled
*/
public boolean isEnabled() {
return enabled;
}
/**
* Returns the total number of entries currently in the cache.
*
* @return the total entry count
*/
public long getTotalEntries() {
return totalEntries;
}
/**
* Returns the total bytes used by the cache.
*
* @return the total bytes
*/
public long getTotalBytes() {
return totalBytes;
}
/**
* Returns the cumulative number of cache hits.
*
* @return the cache hit count
*/
public long getHits() {
return hits;
}
/**
* Returns the cumulative number of cache misses.
*
* @return the cache miss count
*/
public long getMisses() {
return misses;
}
/**
* Returns the cache hit rate.
*
* @return the hit rate, typically in the range 0.0 to 1.0
*/
public double getHitRate() {
return hitRate;
}
/**
* Returns the number of cache partitions.
*
* @return the partition count
*/
public long getNumPartitions() {
return numPartitions;
}
@Override
public String toString() {
return "CacheStats{" +
"enabled=" + enabled +
", totalEntries=" + totalEntries +
", totalBytes=" + totalBytes +
", hits=" + hits +
", misses=" + misses +
", hitRate=" + hitRate +
", numPartitions=" + numPartitions +
'}';
}
}