Skip to content

Commit

Permalink
Merge branch 'main' into issue-107
Browse files Browse the repository at this point in the history
  • Loading branch information
cjrolo authored Sep 18, 2024
2 parents 56a20d5 + c25cdd2 commit 11ffa07
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 21 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ jobs:
# * clippy --all-targets causes clippy to run against tests and examples which it doesnt do by default.
run: cargo hack --feature-powerset clippy --all-targets --locked ${{ matrix.cargo_flags }} -- -D warnings
- name: Ensure that tests pass
run: cargo test ${{ matrix.cargo_flags }} --all-features --all-targets -- --nocapture
run: |
cargo test --doc ${{ matrix.cargo_flags }} --all-features -- --show-output --nocapture
cargo test ${{ matrix.cargo_flags }} --all-features --all-targets -- --nocapture
- name: Ensure that tests did not create or modify any files that arent .gitignore'd
run: |
if [ -n "$(git status --porcelain)" ]; then
Expand Down
132 changes: 132 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official email address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[INSERT CONTACT METHOD].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
11 changes: 11 additions & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# FFT-compression Maintainers

## Maintainers

| Maintainer | GitHub ID | Affiliation |
|------------------|-------------------------------------------------|-------------------------------------------------------|
| Carlos Rolo | [cjrolo](https://github.com/cjrolo) | [Instaclustr](https://www.github.com/instaclustr/) |
| Lucas Kent | [rukai](https://github.com/rukai) | [Instaclustr](https://www.github.com/instaclustr/) |
| Bohdan Siryk | [worryg0d](https://github.com/worryg0d) | [Instaclustr](https://www.github.com/instaclustr/) |
| Danylo Savchenko | [testisnullus](https://github.com/testisnullus) | [Instaclustr](https://www.github.com/instaclustr/) |
| Conor | [conorbros](https://github.com/conorbros) | [Instaclustr](https://www.github.com/instaclustr/) |
39 changes: 28 additions & 11 deletions brro-compressor/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ impl CompressorFrame {
// We need enough samples to do decent compression, minimum is 128 (2^7)
let data_sample = COMPRESSION_SPEED[compression_speed] as usize;
// Eligible compressors for use
let compressor_list = [
Compressor::Constant,
Compressor::FFT,
Compressor::Polynomial,
];
let compressor_list = [Compressor::FFT, Compressor::Polynomial];
// Do a statistical analysis of the data, let's see if we can pick a compressor out of this.
let stats = DataStats::new(data);
// Checking the statistical analysis and chose, if possible, a compressor
Expand All @@ -106,6 +102,7 @@ impl CompressorFrame {
compressor,
)
})
.filter(|(result, _)| result.error <= max_error as f64)
.min_by_key(|x| x.0.compressed_data.len())
.unwrap();
self.compressor = *chosen_compressor;
Expand All @@ -116,19 +113,39 @@ impl CompressorFrame {
.compressed_data;
} else {
// Run all the eligible compressors and choose smallest
let (smallest_result, chosen_compressor) = compressor_list
let compressor_results: Vec<_> = compressor_list
.iter()
.map(|compressor| {
(
compressor.get_compress_bounded_results(data, max_error as f64),
compressor,
*compressor,
)
})
.min_by_key(|x| x.0.compressed_data.len())
.unwrap();
.collect();

self.data = smallest_result.compressed_data;
self.compressor = *chosen_compressor;
#[allow(
clippy::neg_cmp_op_on_partial_ord,
reason = "we need to exactly negate `result.error < max_error`, we can't apply de morgans to the expression due to NaN values"
)]
let best_compressor = if compressor_results
.iter()
.all(|(result, _)| !(result.error <= max_error as f64))
{
// To ensure we always have at least one result,
// if all results are above the max error just pick the smallest.
compressor_results
.into_iter()
.min_by_key(|x| x.0.compressed_data.len())
} else {
compressor_results
.into_iter()
.filter(|(result, _)| result.error <= max_error as f64)
.min_by_key(|x| x.0.compressed_data.len())
};

let (result, compressor) = best_compressor.unwrap();
self.data = result.compressed_data;
self.compressor = compressor;
}
debug!("Auto Compressor Selection: {:?}", self.compressor);
}
Expand Down
2 changes: 1 addition & 1 deletion prometheus-remote/src/lib_vsri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub struct Vsri {
impl Vsri {
/// Creates the index, it doesn't create the file in the disk
/// flush needs to be called for that
pub fn new(filename: &String) -> Self {
pub fn new(filename: &str) -> Self {
debug!("[INDEX] Creating new index!");
let segments: Vec<[i32; 4]> = Vec::new();
Vsri {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.80"
channel = "1.81"
components = [ "rustfmt", "clippy" ]
18 changes: 11 additions & 7 deletions vsri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,22 @@ pub fn start_day_ts(dt: DateTime<Utc>) -> i64 {
/// # Examples
/// Creating a new index, metric is of expected time 0, but for sure location of X is 0
/// ```no_run
/// let vsri = Vsri::new("metric_name", 0, 0);
/// # use vsri::Vsri;
/// let vsri = Vsri::new("metric_name");
/// vsri.flush();
/// ```
/// Updating an index, adding point at time 5sec
/// ```no_run
/// let vsri = Vsri::load("metric_name").unwrap().update_for_point(5);
///
/// # use vsri::Vsri;
/// let mut vsri = Vsri::load("metric_name").unwrap();
/// vsri.update_for_point(5).unwrap();
/// vsri.flush();
/// ```
/// Fetch a sample location from the index given a timestamp
/// ```no_run
/// let vsri = Vsri::load("metric_name").unwrap();
/// vsri.get_sample_location("metric_name", 5);
/// # use vsri::Vsri;
/// let vsri = Vsri::get_sample_location("metric_name", 5);
/// ```
/// Index Structure
Expand All @@ -106,7 +110,7 @@ pub struct Vsri {
impl Vsri {
/// Creates the index, it doesn't create the file in the disk
/// flush needs to be called for that
pub fn new(filename: &String) -> Self {
pub fn new(filename: &str) -> Self {
debug!("[INDEX] Creating new index!");
Vsri {
index_file: filename.to_string(),
Expand All @@ -118,8 +122,8 @@ impl Vsri {

/// Given a filename and a time location, returns the sample location in the
/// data file. Or None in case it doesn't exist.
pub fn get_sample_location(filename: String, y: i32) -> Option<i32> {
let vsri = match Vsri::load(&filename) {
pub fn get_sample_location(filename: &str, y: i32) -> Option<i32> {
let vsri = match Vsri::load(filename) {
Ok(vsri) => vsri,
Err(_err) => return None,
};
Expand Down

0 comments on commit 11ffa07

Please sign in to comment.