Skip to content

Commit

Permalink
demo module level imports granularity (#485)
Browse files Browse the repository at this point in the history
if we're already using a nightly toolchain, this & `group_imports` =>
only a single way for imports to be ordered
  • Loading branch information
AdamGS authored Jul 19, 2024
1 parent ade9cc1 commit 40ea250
Show file tree
Hide file tree
Showing 57 changed files with 100 additions and 173 deletions.
3 changes: 1 addition & 2 deletions bench-vortex/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ use vortex_buffer::Buffer;
use vortex_dtype::DType;
use vortex_error::{vortex_err, VortexResult};
use vortex_ipc::chunked_reader::ChunkedArrayReader;
use vortex_ipc::io::ObjectStoreExt;
use vortex_ipc::io::{TokioAdapter, VortexReadAt, VortexWrite};
use vortex_ipc::io::{ObjectStoreExt, TokioAdapter, VortexReadAt, VortexWrite};
use vortex_ipc::writer::ArrayWriter;
use vortex_ipc::MessageReader;
use vortex_sampling_compressor::SamplingCompressor;
Expand Down
3 changes: 1 addition & 2 deletions encodings/alp/src/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use vortex::{Array, IntoArray};
use vortex_error::VortexResult;
use vortex_scalar::Scalar;

use crate::ALPFloat;
use crate::{match_each_alp_float_ptype, ALPArray};
use crate::{match_each_alp_float_ptype, ALPArray, ALPFloat};

impl ArrayCompute for ALPArray {
fn scalar_at(&self) -> Option<&dyn ScalarAtFn> {
Expand Down
24 changes: 9 additions & 15 deletions encodings/byte_bool/src/compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@ use std::sync::Arc;

use arrow_buffer::BooleanBuffer;
use num_traits::AsPrimitive;
use vortex::compute::unary::fill_forward::FillForwardFn;
use vortex::compute::unary::scalar_at::ScalarAtFn;
use vortex::compute::{ArrayCompute, CompareFn, SliceFn, TakeFn};
use vortex::validity::Validity;
use vortex::Array;
use vortex::{
compute::{unary::fill_forward::FillForwardFn, unary::scalar_at::ScalarAtFn},
encoding::ArrayEncodingRef,
stats::StatsSet,
validity::ArrayValidity,
ArrayDType, ArrayData, IntoArray,
};
use vortex::{IntoArrayVariant, ToArrayData};
use vortex::encoding::ArrayEncodingRef;
use vortex::stats::StatsSet;
use vortex::validity::{ArrayValidity, Validity};
use vortex::{Array, ArrayDType, ArrayData, IntoArray, IntoArrayVariant, ToArrayData};
use vortex_dtype::{match_each_integer_ptype, Nullability};
use vortex_error::{vortex_bail, VortexResult};
use vortex_expr::Operator;
Expand Down Expand Up @@ -186,11 +182,9 @@ impl FillForwardFn for ByteBoolArray {

#[cfg(test)]
mod tests {
use vortex::{
compute::unary::scalar_at::scalar_at,
compute::{compare, slice},
AsArray as _,
};
use vortex::compute::unary::scalar_at::scalar_at;
use vortex::compute::{compare, slice};
use vortex::AsArray as _;

use super::*;

Expand Down
9 changes: 3 additions & 6 deletions encodings/byte_bool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ use std::mem::ManuallyDrop;
use arrow_buffer::BooleanBuffer;
use serde::{Deserialize, Serialize};
use vortex::array::bool::BoolArray;
use vortex::validity::{ArrayValidity, LogicalValidity, Validity, ValidityMetadata};
use vortex::variants::{ArrayVariants, BoolArrayTrait};
use vortex::{
impl_encoding,
validity::{ArrayValidity, LogicalValidity, Validity, ValidityMetadata},
visitor::{AcceptArrayVisitor, ArrayVisitor},
};
use vortex::{Canonical, IntoCanonical};
use vortex::visitor::{AcceptArrayVisitor, ArrayVisitor};
use vortex::{impl_encoding, Canonical, IntoCanonical};
use vortex_buffer::Buffer;

mod compute;
Expand Down
6 changes: 2 additions & 4 deletions encodings/byte_bool/src/stats.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use vortex::{
stats::{ArrayStatisticsCompute, Stat, StatsSet},
AsArray, IntoArrayVariant,
};
use vortex::stats::{ArrayStatisticsCompute, Stat, StatsSet};
use vortex::{AsArray, IntoArrayVariant};
use vortex_error::VortexResult;

use super::ByteBoolArray;
Expand Down
3 changes: 1 addition & 2 deletions encodings/datetime-parts/src/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use vortex::array::datetime::temporal::TemporalMetadata;
use vortex::array::datetime::{TemporalArray, TimeUnit};
use vortex::array::primitive::PrimitiveArray;
use vortex::compute::unary::scalar_at::{scalar_at, ScalarAtFn};
use vortex::compute::ArrayCompute;
use vortex::compute::{slice, take, SliceFn, TakeFn};
use vortex::compute::{slice, take, ArrayCompute, SliceFn, TakeFn};
use vortex::validity::ArrayValidity;
use vortex::{Array, ArrayDType, IntoArray, IntoArrayVariant};
use vortex_dtype::DType;
Expand Down
3 changes: 1 addition & 2 deletions encodings/dict/src/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use vortex::array::primitive::PrimitiveArray;
use vortex::array::varbin::VarBinArray;
use vortex::validity::Validity;
use vortex::{ArrayDType, IntoArray};
use vortex_dtype::{match_each_native_ptype, DType};
use vortex_dtype::{NativePType, ToBytes};
use vortex_dtype::{match_each_native_ptype, DType, NativePType, ToBytes};

#[derive(Debug)]
struct Value<T>(T);
Expand Down
6 changes: 2 additions & 4 deletions encodings/fastlanes/src/bitpacking/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use vortex::array::primitive::PrimitiveArray;
use vortex::array::sparse::{Sparse, SparseArray};
use vortex::stats::ArrayStatistics;
use vortex::validity::Validity;
use vortex::IntoArrayVariant;
use vortex::{Array, ArrayDType, ArrayDef, IntoArray};
use vortex::{Array, ArrayDType, ArrayDef, IntoArray, IntoArrayVariant};
use vortex_dtype::{
match_each_integer_ptype, match_each_unsigned_integer_ptype, NativePType, PType,
};
Expand Down Expand Up @@ -307,8 +306,7 @@ pub fn count_exceptions(bit_width: usize, bit_width_freq: &[usize]) -> usize {

#[cfg(test)]
mod test {
use vortex::IntoArrayVariant;
use vortex::ToArray;
use vortex::{IntoArrayVariant, ToArray};
use vortex_scalar::PrimitiveScalar;

use super::*;
Expand Down
3 changes: 1 addition & 2 deletions encodings/fastlanes/src/bitpacking/compute/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use vortex::compute::unary::scalar_at::{scalar_at, ScalarAtFn};
use vortex::compute::ArrayCompute;
use vortex::compute::{SearchSortedFn, SliceFn, TakeFn};
use vortex::compute::{ArrayCompute, SearchSortedFn, SliceFn, TakeFn};
use vortex::ArrayDType;
use vortex_error::{vortex_err, VortexResult};
use vortex_scalar::Scalar;
Expand Down
3 changes: 1 addition & 2 deletions encodings/fastlanes/src/delta/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use vortex::array::primitive::PrimitiveArray;
use vortex::compute::unary::fill_forward::fill_forward;
use vortex::validity::Validity;
use vortex::IntoArrayVariant;
use vortex_dtype::NativePType;
use vortex_dtype::{match_each_unsigned_integer_ptype, Nullability};
use vortex_dtype::{match_each_unsigned_integer_ptype, NativePType, Nullability};
use vortex_error::VortexResult;

use crate::DeltaArray;
Expand Down
3 changes: 1 addition & 2 deletions encodings/fastlanes/src/delta/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
pub use compress::*;
use serde::{Deserialize, Serialize};
use vortex::stats::ArrayStatisticsCompute;
use vortex::validity::ValidityMetadata;
use vortex::validity::{ArrayValidity, LogicalValidity, Validity};
use vortex::validity::{ArrayValidity, LogicalValidity, Validity, ValidityMetadata};
use vortex::variants::{ArrayVariants, PrimitiveArrayTrait};
use vortex::visitor::{AcceptArrayVisitor, ArrayVisitor};
use vortex::{impl_encoding, ArrayDType, Canonical, IntoCanonical};
Expand Down
6 changes: 2 additions & 4 deletions encodings/roaring/src/boolean/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use arrow_buffer::BooleanBuffer;
use arrow_buffer::Buffer as ArrowBuffer;
use arrow_buffer::{BooleanBuffer, Buffer as ArrowBuffer};
pub use compress::*;
use croaring::{Bitmap, Portable};
use serde::{Deserialize, Serialize};
Expand All @@ -10,8 +9,7 @@ use vortex::variants::{ArrayVariants, BoolArrayTrait};
use vortex::visitor::{AcceptArrayVisitor, ArrayVisitor};
use vortex::{impl_encoding, ArrayDType, Canonical, IntoCanonical};
use vortex_buffer::Buffer;
use vortex_dtype::Nullability::NonNullable;
use vortex_dtype::Nullability::Nullable;
use vortex_dtype::Nullability::{NonNullable, Nullable};
use vortex_error::{vortex_bail, vortex_err};

mod compress;
Expand Down
3 changes: 1 addition & 2 deletions encodings/runend/src/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use vortex::array::primitive::PrimitiveArray;
use vortex::stats::{ArrayStatistics, Stat};
use vortex::validity::Validity;
use vortex::ArrayDType;
use vortex_dtype::Nullability;
use vortex_dtype::{match_each_integer_ptype, match_each_native_ptype, NativePType};
use vortex_dtype::{match_each_integer_ptype, match_each_native_ptype, NativePType, Nullability};
use vortex_error::VortexResult;

pub fn runend_encode(array: &PrimitiveArray) -> (PrimitiveArray, PrimitiveArray) {
Expand Down
3 changes: 1 addition & 2 deletions encodings/runend/src/compute.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use vortex::array::primitive::PrimitiveArray;
use vortex::compute::unary::scalar_at::{scalar_at, ScalarAtFn};
use vortex::compute::ArrayCompute;
use vortex::compute::{slice, take, SliceFn, TakeFn};
use vortex::compute::{slice, take, ArrayCompute, SliceFn, TakeFn};
use vortex::{Array, IntoArray, IntoArrayVariant};
use vortex_dtype::match_each_integer_ptype;
use vortex_error::VortexResult;
Expand Down
4 changes: 1 addition & 3 deletions pyvortex/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ use vortex::array::varbin::{VarBin, VarBinArray, VarBinEncoding};
use vortex::array::varbinview::{VarBinView, VarBinViewArray, VarBinViewEncoding};
use vortex::compute::take;
use vortex::encoding::EncodingRef;
use vortex::ToArray;
use vortex::{Array, ArrayDType, ArrayData, IntoArray};
use vortex::{ArrayDef, IntoArrayData};
use vortex::{Array, ArrayDType, ArrayData, ArrayDef, IntoArray, IntoArrayData, ToArray};
use vortex_alp::{ALPArray, ALPEncoding, ALP};
use vortex_dict::{Dict, DictArray, DictEncoding};
use vortex_fastlanes::{
Expand Down
3 changes: 2 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ format_macro_matchers = true
format_macro_bodies = true
group_imports = "StdExternalCrate"
unstable_features = true
use_field_init_shorthand = true
use_field_init_shorthand = true
imports_granularity = "Module"
3 changes: 1 addition & 2 deletions vortex-array/benches/filter_indices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use rand::{thread_rng, Rng};
use vortex::IntoArray;
use vortex_dtype::field::FieldPath;
use vortex_error::VortexError;
use vortex_expr::FieldPathOperations;
use vortex_expr::{lit, Conjunction, Disjunction};
use vortex_expr::{lit, Conjunction, Disjunction, FieldPathOperations};

fn filter_indices(c: &mut Criterion) {
let mut group = c.benchmark_group("filter_indices");
Expand Down
3 changes: 2 additions & 1 deletion vortex-array/src/array/bool/compute/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ mod tests {

use super::*;
use crate::compute::slice;
use crate::compute::unary::scalar_at::scalar_at;
use crate::validity::ArrayValidity;
use crate::{compute::unary::scalar_at::scalar_at, AsArray};
use crate::AsArray;

#[test]
fn test_slice() {
Expand Down
4 changes: 1 addition & 3 deletions vortex-array/src/array/bool/compute/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ use vortex_error::VortexResult;

use crate::array::bool::BoolArray;
use crate::compute::TakeFn;
use crate::Array;
use crate::IntoArray;
use crate::{AsArray, IntoArrayVariant};
use crate::{Array, AsArray, IntoArray, IntoArrayVariant};

impl TakeFn for BoolArray {
fn take(&self, indices: &Array) -> VortexResult<Array> {
Expand Down
3 changes: 1 addition & 2 deletions vortex-array/src/array/bool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use itertools::Itertools;
use serde::{Deserialize, Serialize};
use vortex_buffer::Buffer;

use crate::validity::{ArrayValidity, ValidityMetadata};
use crate::validity::{LogicalValidity, Validity};
use crate::validity::{ArrayValidity, LogicalValidity, Validity, ValidityMetadata};
use crate::variants::{ArrayVariants, BoolArrayTrait};
use crate::visitor::{AcceptArrayVisitor, ArrayVisitor};
use crate::{impl_encoding, Canonical, IntoCanonical};
Expand Down
3 changes: 1 addition & 2 deletions vortex-array/src/array/chunked/compute/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use crate::compute::unary::scalar_at::scalar_at;
use crate::compute::unary::scalar_subtract::subtract_scalar;
use crate::compute::{search_sorted, slice, take, SearchSortedSide, TakeFn};
use crate::stats::ArrayStatistics;
use crate::ArrayDType;
use crate::{Array, IntoArray, ToArray};
use crate::{Array, ArrayDType, IntoArray, ToArray};

impl TakeFn for ChunkedArray {
fn take(&self, indices: &Array) -> VortexResult<Array> {
Expand Down
3 changes: 1 addition & 2 deletions vortex-array/src/array/chunked/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ impl SubtractScalarFn for ChunkedArray {

#[cfg(test)]
mod test {
use vortex_dtype::{DType, Nullability};
use vortex_dtype::{NativePType, PType};
use vortex_dtype::{DType, NativePType, Nullability, PType};

use crate::array::chunked::ChunkedArray;
use crate::compute::slice;
Expand Down
3 changes: 1 addition & 2 deletions vortex-array/src/array/chunked/stats.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use vortex_error::VortexResult;

use crate::array::chunked::ChunkedArray;
use crate::stats::ArrayStatistics;
use crate::stats::{ArrayStatisticsCompute, Stat, StatsSet};
use crate::stats::{ArrayStatistics, ArrayStatisticsCompute, Stat, StatsSet};

impl ArrayStatisticsCompute for ChunkedArray {
fn compute_statistics(&self, stat: Stat) -> VortexResult<StatsSet> {
Expand Down
3 changes: 1 addition & 2 deletions vortex-array/src/array/constant/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use crate::array::constant::ConstantArray;
use crate::array::primitive::PrimitiveArray;
use crate::array::varbin::VarBinArray;
use crate::validity::Validity;
use crate::ArrayDType;
use crate::{Canonical, IntoCanonical};
use crate::{ArrayDType, Canonical, IntoCanonical};

impl IntoCanonical for ConstantArray {
fn into_canonical(self) -> VortexResult<Canonical> {
Expand Down
5 changes: 3 additions & 2 deletions vortex-array/src/array/constant/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use vortex_scalar::Scalar;

use crate::array::constant::ConstantArray;
use crate::compute::unary::scalar_at::ScalarAtFn;
use crate::compute::{ArrayCompute, SliceFn, TakeFn};
use crate::compute::{SearchResult, SearchSortedFn, SearchSortedSide};
use crate::compute::{
ArrayCompute, SearchResult, SearchSortedFn, SearchSortedSide, SliceFn, TakeFn,
};
use crate::{Array, IntoArray};

impl ArrayCompute for ConstantArray {
Expand Down
3 changes: 1 addition & 2 deletions vortex-array/src/array/extension/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use vortex_scalar::Scalar;
use crate::array::extension::ExtensionArray;
use crate::compute::unary::cast::CastFn;
use crate::compute::unary::scalar_at::{scalar_at, ScalarAtFn};
use crate::compute::ArrayCompute;
use crate::compute::{slice, take, SliceFn, TakeFn};
use crate::compute::{slice, take, ArrayCompute, SliceFn, TakeFn};
use crate::{Array, IntoArray};

impl ArrayCompute for ExtensionArray {
Expand Down
6 changes: 2 additions & 4 deletions vortex-array/src/array/null/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use vortex_scalar::Scalar;

use crate::array::null::NullArray;
use crate::compute::unary::scalar_at::ScalarAtFn;
use crate::compute::ArrayCompute;
use crate::compute::{SliceFn, TakeFn};
use crate::compute::{ArrayCompute, SliceFn, TakeFn};
use crate::{Array, IntoArray, IntoArrayVariant};

impl ArrayCompute for NullArray {
Expand Down Expand Up @@ -57,9 +56,8 @@ mod test {
use vortex_dtype::DType;

use crate::array::null::NullArray;
use crate::compute::slice;
use crate::compute::take;
use crate::compute::unary::scalar_at::scalar_at;
use crate::compute::{slice, take};
use crate::validity::{ArrayValidity, LogicalValidity};
use crate::IntoArray;

Expand Down
6 changes: 2 additions & 4 deletions vortex-array/src/array/primitive/compute/cast.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use vortex_dtype::{match_each_native_ptype, DType};
use vortex_dtype::{NativePType, PType};
use vortex_dtype::{match_each_native_ptype, DType, NativePType, PType};
use vortex_error::{vortex_err, VortexResult};

use crate::array::primitive::PrimitiveArray;
use crate::compute::unary::cast::CastFn;
use crate::validity::Validity;
use crate::IntoArray;
use crate::{Array, ArrayDType};
use crate::{Array, ArrayDType, IntoArray};

impl CastFn for PrimitiveArray {
fn cast(&self, dtype: &DType) -> VortexResult<Array> {
Expand Down
4 changes: 1 addition & 3 deletions vortex-array/src/array/primitive/compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use crate::compute::unary::cast::CastFn;
use crate::compute::unary::fill_forward::FillForwardFn;
use crate::compute::unary::scalar_at::ScalarAtFn;
use crate::compute::unary::scalar_subtract::SubtractScalarFn;
use crate::compute::FilterIndicesFn;
use crate::compute::SearchSortedFn;
use crate::compute::{ArrayCompute, CompareFn, SliceFn, TakeFn};
use crate::compute::{ArrayCompute, CompareFn, FilterIndicesFn, SearchSortedFn, SliceFn, TakeFn};

mod cast;
mod compare;
Expand Down
3 changes: 1 addition & 2 deletions vortex-array/src/array/primitive/compute/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use vortex_error::VortexResult;

use crate::array::primitive::PrimitiveArray;
use crate::compute::SliceFn;
use crate::Array;
use crate::IntoArray;
use crate::{Array, IntoArray};

impl SliceFn for PrimitiveArray {
fn slice(&self, start: usize, stop: usize) -> VortexResult<Array> {
Expand Down
3 changes: 1 addition & 2 deletions vortex-array/src/array/primitive/compute/subtract_scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use itertools::Itertools;
use num_traits::WrappingSub;
use vortex_dtype::{match_each_float_ptype, match_each_integer_ptype, NativePType};
use vortex_error::{vortex_bail, vortex_err, VortexError, VortexResult};
use vortex_scalar::PrimitiveScalar;
use vortex_scalar::Scalar;
use vortex_scalar::{PrimitiveScalar, Scalar};

use crate::array::constant::ConstantArray;
use crate::array::primitive::PrimitiveArray;
Expand Down
6 changes: 2 additions & 4 deletions vortex-array/src/array/primitive/compute/take.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use num_traits::PrimInt;
use vortex_dtype::NativePType;
use vortex_dtype::{match_each_integer_ptype, match_each_native_ptype};
use vortex_dtype::{match_each_integer_ptype, match_each_native_ptype, NativePType};
use vortex_error::VortexResult;

use crate::array::primitive::PrimitiveArray;
use crate::compute::TakeFn;
use crate::Array;
use crate::{IntoArray, IntoArrayVariant};
use crate::{Array, IntoArray, IntoArrayVariant};

impl TakeFn for PrimitiveArray {
fn take(&self, indices: &Array) -> VortexResult<Array> {
Expand Down
Loading

0 comments on commit 40ea250

Please sign in to comment.