-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use flatbuffers::{FlatBufferBuilder, WIPOffset}; | ||
use itertools::Itertools; | ||
use vortex_flatbuffers::WriteFlatBuffer; | ||
|
||
use crate::stats::{Stat, Statistics}; | ||
|
||
impl WriteFlatBuffer for &dyn Statistics { | ||
type Target<'t> = crate::flatbuffers::ArrayStats<'t>; | ||
|
||
fn write_flatbuffer<'fb>( | ||
&self, | ||
fbb: &mut FlatBufferBuilder<'fb>, | ||
) -> WIPOffset<Self::Target<'fb>> { | ||
let trailing_zero_freq = self | ||
.get_as::<Vec<u64>>(Stat::TrailingZeroFreq) | ||
.ok() | ||
.map(|v| v.iter().copied().collect_vec()) | ||
.map(|v| fbb.create_vector(v.as_slice())); | ||
|
||
let bit_width_freq = self | ||
.get_as::<Vec<u64>>(Stat::BitWidthFreq) | ||
.ok() | ||
.map(|v| v.iter().copied().collect_vec()) | ||
.map(|v| fbb.create_vector(v.as_slice())); | ||
|
||
let min = self | ||
.get(Stat::Min) | ||
.map(|min| min.value().write_flatbuffer(fbb)); | ||
|
||
let max = self | ||
.get(Stat::Max) | ||
.map(|max| max.value().write_flatbuffer(fbb)); | ||
|
||
let stat_args = &crate::flatbuffers::ArrayStatsArgs { | ||
min, | ||
max, | ||
is_sorted: self.get_as::<bool>(Stat::IsSorted).ok(), | ||
is_strict_sorted: self.get_as::<bool>(Stat::IsStrictSorted).ok(), | ||
is_constant: self.get_as::<bool>(Stat::IsConstant).ok(), | ||
run_count: self.get_as::<u64>(Stat::RunCount).ok(), | ||
true_count: self.get_as::<u64>(Stat::TrueCount).ok(), | ||
null_count: self.get_as::<u64>(Stat::NullCount).ok(), | ||
bit_width_freq, | ||
trailing_zero_freq, | ||
}; | ||
|
||
crate::flatbuffers::ArrayStats::create(fbb, stat_args) | ||
} | ||
} |
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
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