-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from instaclustr/fix_ci
Fix CI
- Loading branch information
Showing
5 changed files
with
91 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,68 @@ | ||
pub mod optimizer; | ||
// Lucas - Once the project is far enough along I strongly reccomend reenabling dead code checks | ||
#![allow(dead_code)] | ||
|
||
use median::Filter; | ||
use log::debug; | ||
use types::metric_tag::MetricTag; | ||
use crate::types; | ||
|
||
impl MetricTag { | ||
#[allow(clippy::wrong_self_convention)] | ||
fn from_float(&self, x: f64) -> i64 { | ||
match self { | ||
MetricTag::Other => { | ||
0 | ||
} | ||
MetricTag::NotFloat | MetricTag::QuasiRandom => { | ||
x as i64 | ||
} | ||
MetricTag::Percent(y) => { | ||
to_multiply_and_truncate(x, *y) | ||
} | ||
MetricTag::Duration(y) => { | ||
to_multiply_and_truncate(x, *y) | ||
} | ||
MetricTag::Bytes(y) => { | ||
(x as i64) / (*y as i64) | ||
} | ||
} | ||
} | ||
} | ||
|
||
/// Converts a float via multiplication and truncation | ||
fn to_multiply_and_truncate(number: f64, mul: i32) -> i64 { | ||
(number * mul as f64) as i64 | ||
} | ||
|
||
fn to_median_filter(data: &Vec<f64>) -> Vec<i64> { | ||
let mut filtered = Vec::with_capacity(data.len()); | ||
// 10minutes of data | ||
let mut filter = Filter::new(50); | ||
for point in data { | ||
let point_int = MetricTag::QuasiRandom.from_float(*point); | ||
let median = filter.consume(point_int); | ||
filtered.push(median) | ||
} | ||
filtered | ||
} | ||
|
||
|
||
pub fn process_data(wav_data: &Vec<f64>, tag: &MetricTag) -> Vec<i64> { | ||
let mut _bitdepth = 64; | ||
let mut _dc_component: i64 = 0; | ||
let mut _fractional = true; | ||
|
||
debug!("Tag: {:?}", tag); | ||
let data = match tag { | ||
MetricTag::Other => Vec::new(), | ||
MetricTag::QuasiRandom => to_median_filter(wav_data), | ||
_ => { | ||
wav_data | ||
.iter() | ||
.map(|x| tag.from_float(*x)) | ||
.collect() | ||
} | ||
}; | ||
_fractional = false; | ||
data | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters