We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4b7139a commit acd2faaCopy full SHA for acd2faa
graph/src/util/cache_weight.rs
@@ -55,7 +55,7 @@ impl CacheWeight for String {
55
56
impl CacheWeight for BigDecimal {
57
fn indirect_weight(&self) -> usize {
58
- (self.digits() as f32).log2() as usize
+ ((self.digits() as f32 * std::f32::consts::LOG2_10) / 8.0).ceil() as usize
59
}
60
61
@@ -96,3 +96,12 @@ impl CacheWeight for graphql_parser::query::Value {
96
97
98
99
+
100
+#[test]
101
+fn big_decimal_cache_weight() {
102
+ use std::str::FromStr;
103
104
+ // 22.4548 has 18 bits as binary, so 3 bytes.
105
+ let n = BigDecimal::from_str("22.454800000000").unwrap();
106
+ assert_eq!(n.indirect_weight(), 3);
107
+}
0 commit comments