Skip to content

Commit

Permalink
reuse get_calculated_value (#1472)
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz authored Aug 24, 2022
1 parent 2151978 commit 82209c5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion fastfield_codecs/src/linearinterpol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn diff(val1: u64, val2: u64) -> f64 {
}

#[inline]
fn get_calculated_value(first_val: u64, pos: u64, slope: f32) -> u64 {
pub fn get_calculated_value(first_val: u64, pos: u64, slope: f32) -> u64 {
if slope < 0.0 {
first_val - (pos as f32 * -slope) as u64
} else {
Expand Down
7 changes: 1 addition & 6 deletions fastfield_codecs/src/multilinearinterpol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use common::{BinarySerializable, CountingWriter, DeserializeFrom};
use ownedbytes::OwnedBytes;
use tantivy_bitpacker::{compute_num_bits, BitPacker, BitUnpacker};

use crate::linearinterpol::get_slope;
use crate::linearinterpol::{get_calculated_value, get_slope};
use crate::{FastFieldCodecReader, FastFieldCodecSerializer, FastFieldDataAccess, FastFieldStats};

const CHUNK_SIZE: u64 = 512;
Expand Down Expand Up @@ -355,11 +355,6 @@ fn distance<T: Sub<Output = T> + Ord>(x: T, y: T) -> T {
}
}

#[inline]
fn get_calculated_value(first_val: u64, pos: u64, slope: f32) -> u64 {
(first_val as i64 + (pos as f32 * slope) as i64) as u64
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 82209c5

Please sign in to comment.