-
Notifications
You must be signed in to change notification settings - Fork 33
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
33 changed files
with
271 additions
and
358 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
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,41 @@ | ||
use itertools::Itertools; | ||
use std::ops::Deref; | ||
|
||
use crate::array::chunked::{ChunkedArray, ChunkedEncoding}; | ||
use crate::array::downcast::DowncastArrayBuiltin; | ||
use crate::array::{Array, ArrayRef}; | ||
use crate::compress::{CompressConfig, CompressCtx, Compressor, EncodingCompression}; | ||
use itertools::Itertools; | ||
use crate::error::VortexResult; | ||
|
||
impl EncodingCompression for ChunkedEncoding { | ||
fn compressor( | ||
&self, | ||
array: &dyn Array, | ||
_config: &CompressConfig, | ||
) -> Option<&'static Compressor> { | ||
if array.encoding().id() == &Self::ID { | ||
Some(&(chunked_compressor as Compressor)) | ||
} else { | ||
None | ||
} | ||
(array.encoding().id() == &Self::ID).then_some(&(chunked_compressor as Compressor)) | ||
} | ||
} | ||
|
||
fn chunked_compressor(array: &dyn Array, like: Option<&dyn Array>, ctx: CompressCtx) -> ArrayRef { | ||
fn chunked_compressor( | ||
array: &dyn Array, | ||
like: Option<&dyn Array>, | ||
ctx: CompressCtx, | ||
) -> VortexResult<ArrayRef> { | ||
let chunked_array = array.as_chunked(); | ||
let chunked_like = like.map(|like_array| like_array.as_chunked()); | ||
|
||
let compressed_chunks = chunked_like | ||
.map(|c_like| { | ||
chunked_array | ||
.chunks() | ||
.iter() | ||
.zip_eq(c_like.chunks()) | ||
.map(|(chunk, chunk_like)| ctx.compress(chunk.as_ref(), Some(chunk_like.as_ref()))) | ||
.collect() | ||
let compressed_chunks = chunked_array | ||
.chunks() | ||
.iter() | ||
.enumerate() | ||
.map(|(i, chunk)| { | ||
let like_chunk = chunked_like | ||
.and_then(|c_like| c_like.chunks().get(i)) | ||
.map(Deref::deref); | ||
ctx.compress(chunk.deref(), like_chunk) | ||
}) | ||
.unwrap_or_else(|| { | ||
chunked_array | ||
.chunks() | ||
.iter() | ||
.map(|chunk| ctx.compress(chunk.as_ref(), None)) | ||
.collect() | ||
}); | ||
.try_collect()?; | ||
|
||
ChunkedArray::new(compressed_chunks, array.dtype().clone()).boxed() | ||
Ok(ChunkedArray::new(compressed_chunks, array.dtype().clone()).boxed()) | ||
} |
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
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
Oops, something went wrong.