Skip to content

Commit

Permalink
Add to_hz_ranges in store
Browse files Browse the repository at this point in the history
  • Loading branch information
fxpineau committed Mar 28, 2023
1 parent 31633de commit e4825fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/storage/u64idx/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,17 @@ impl InternalMoc {
InternalMoc::TimeSpace(_) => Err(String::from("Get ranges not possible for Time-Space MOCs")),
}
}

pub(crate) fn get_hz_ranges(&self) -> Result<Vec<Range<f64>>, String> {
match self {
InternalMoc::Frequency(moc) => Ok(
moc.into_range_moc_iter()
.map(|Range { start, end }| Frequency::<u64>::hash2freq(start)..Frequency::<u64>::hash2freq(end))
.collect()
),
_ => Err(String::from("Get Hz ranges only available for F-MOCs")),
}
}


pub(crate) fn to_ascii<W>(&self, fold: Option<usize>, writer: W) -> Result<(), String>
Expand Down
4 changes: 4 additions & 0 deletions src/storage/u64idx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ impl U64MocStore {
pub fn to_ranges(&self, index: usize) -> Result<Vec<Range<u64>>, String> {
store::exec_on_one_readonly_moc(index, InternalMoc::get_ranges)
}

pub fn to_hz_ranges(&self, index: usize) -> Result<Vec<Range<f64>>, String> {
store::exec_on_one_readonly_moc(index, InternalMoc::get_hz_ranges)
}

///////////////////////
// LOAD EXISTING MOC //
Expand Down

0 comments on commit e4825fd

Please sign in to comment.