mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 22:59:58 -07:00
parser: fix gnericmap multi_insert_simple_average
This commit is contained in:
@@ -49,10 +49,11 @@
|
||||
- Added config print at the start of the program
|
||||
- Compressed `empty_address_data` struct to save space (should shave of between up to 50% of the `address_index_to_empty_address_data` database)
|
||||
- Doubled the number of `txid_to_tx_data` databases from 4096 to 8192
|
||||
- Added `--recompute_computed true` argument, to allow recomputation of computed datasets in case of a bug
|
||||
- ~Added `--recompute_computed true` argument, to allow recomputation of computed datasets in case of a bug~ Buggy for now
|
||||
- Fixed not saved arguments, not being processed properly
|
||||
- Fixed bug in `generic_map.multi_insert_simple_average`
|
||||
- Added defragmentation option `--first-defragment true` of databases to save space (which can save up to 50%)
|
||||
- Fixed bug in the computation of averages in `GenericMap`
|
||||
|
||||
## Server
|
||||
|
||||
|
||||
@@ -691,7 +691,7 @@ where
|
||||
let mut average = None;
|
||||
|
||||
keys.iter().for_each(|key| {
|
||||
let previous_average: f32 = average
|
||||
let mut previous_average: f32 = average
|
||||
.unwrap_or_else(|| {
|
||||
key.checked_sub(1)
|
||||
.and_then(|previous_average_key| self.get_or_import(&previous_average_key))
|
||||
@@ -699,6 +699,10 @@ where
|
||||
})
|
||||
.into();
|
||||
|
||||
if previous_average.is_nan() {
|
||||
previous_average = 0.0;
|
||||
}
|
||||
|
||||
let mut last_value = f32::lossy_from(source.get_or_import(key).unwrap_or_else(|| {
|
||||
dbg!(key);
|
||||
panic!()
|
||||
@@ -708,7 +712,13 @@ where
|
||||
last_value = 0.0;
|
||||
}
|
||||
|
||||
average.replace(((previous_average * (len - 1.0) + last_value) / len).into());
|
||||
let _average = (previous_average * (len - 1.0) + last_value) / len;
|
||||
|
||||
if _average.is_nan() || _average.is_infinite() {
|
||||
average.replace(0.0.into());
|
||||
} else {
|
||||
average.replace(_average.into());
|
||||
}
|
||||
|
||||
self.insert_computed(*key, average.unwrap());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user