Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split out arrow-ord (#2594) #3299

Merged
merged 5 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 21 additions & 13 deletions .github/workflows/arrow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@ on:
- master
pull_request:
paths:
- arrow/**
- .github/**
- arrow-array/**
- arrow-buffer/**
- arrow-cast/**
- arrow-csv/**
- arrow-data/**
- arrow-schema/**
- arrow-select/**
- arrow-integration-test/**
- arrow-ipc/**
- arrow-csv/**
- arrow-json/**
- .github/**
- arrow-ord/**
- arrow-schema/**
- arrow-select/**
- arrow-string/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to add this in #3295

- arrow/**

jobs:

Expand All @@ -58,8 +60,8 @@ jobs:
run: cargo test -p arrow-data --all-features
- name: Test arrow-schema with all features
run: cargo test -p arrow-schema --all-features
- name: Test arrow-array with all features
run: cargo test -p arrow-array --all-features
- name: Test arrow-array with all features except SIMD
run: cargo test -p arrow-array
- name: Test arrow-select with all features
run: cargo test -p arrow-select --all-features
- name: Test arrow-cast with all features
Expand All @@ -72,6 +74,8 @@ jobs:
run: cargo test -p arrow-json --all-features
- name: Test arrow-string with all features
run: cargo test -p arrow-string --all-features
- name: Test arrow-ord with all features except SIMD
run: cargo test -p arrow-ord --features dyn_cmp_dict
- name: Test arrow-integration-test with all features
run: cargo test -p arrow-integration-test --all-features
- name: Test arrow with default features
Expand Down Expand Up @@ -129,10 +133,12 @@ jobs:
uses: ./.github/actions/setup-builder
with:
rust-version: nightly
- name: Run tests --features "simd"
run: cargo test -p arrow --features "simd"
- name: Check compilation --features "simd"
run: cargo check -p arrow --features simd
- name: Test arrow-array with SIMD
run: cargo test -p arrow-array --features simd
- name: Test arrow-ord with SIMD
run: cargo test -p arrow-ord --features simd
- name: Test arrow with SIMD
run: cargo test -p arrow --features simd
- name: Check compilation --features simd --all-targets
run: cargo check -p arrow --features simd --all-targets

Expand Down Expand Up @@ -174,8 +180,8 @@ jobs:
run: cargo clippy -p arrow-data --all-targets --all-features -- -D warnings
- name: Clippy arrow-schema with all features
run: cargo clippy -p arrow-schema --all-targets --all-features -- -D warnings
- name: Clippy arrow-array with all features
run: cargo clippy -p arrow-array --all-targets --all-features -- -D warnings
- name: Clippy arrow-array with all features except SIMD
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created rust-lang/cargo#11467 to track making this less error prone

run: cargo clippy -p arrow-array --all-targets -- -D warnings
- name: Clippy arrow-select with all features
run: cargo clippy -p arrow-select --all-targets --all-features -- -D warnings
- name: Clippy arrow-cast with all features
Expand All @@ -188,5 +194,7 @@ jobs:
run: cargo clippy -p arrow-json --all-targets --all-features -- -D warnings
- name: Clippy arrow-string with all features
run: cargo clippy -p arrow-string --all-targets --all-features -- -D warnings
- name: Clippy arrow-ord with all features except SIMD
run: cargo clippy -p arrow-ord --all-targets --features dyn_cmp_dict -- -D warnings
- name: Clippy arrow
run: cargo clippy -p arrow --features=prettyprint,csv,ipc,test_utils,ffi,ipc_compression,dyn_cmp_dict,dyn_arith_dict,chrono-tz --all-targets -- -D warnings
1 change: 0 additions & 1 deletion .github/workflows/arrow_flight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ on:
- arrow-ipc/**
- arrow-schema/**
- arrow-select/**
- arrow-string/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arrow-flight doesn't depend on this crate and so this can be removed

- .github/**

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ on:
- arrow-integration-test/**
- arrow-integration-testing/**
- arrow-ipc/**
- arrow-ord/**
- arrow-json/**
- arrow-pyarrow-integration-testing/**
- arrow-schema/**
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/parquet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ on:
- arrow-ipc/**
- arrow-csv/**
- arrow-json/**
- arrow-string/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parquet doesn't actually depend on any of these kernels, and so this can be removed

- parquet/**
- .github/**

Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ members = [
"arrow-integration-testing",
"arrow-ipc",
"arrow-json",
"arrow-ord",
"arrow-schema",
"arrow-select",
"arrow-string",
Expand Down
4 changes: 4 additions & 0 deletions arrow-array/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ chrono-tz = { version = "0.8", optional = true }
num = { version = "0.4", default-features = false, features = ["std"] }
half = { version = "2.1", default-features = false, features = ["num-traits"] }
hashbrown = { version = "0.13", default-features = false }
packed_simd = { version = "0.3", default-features = false, optional = true, package = "packed_simd_2" }

[features]
simd = ["packed_simd"]

[dev-dependencies]
rand = { version = "0.8", default-features = false, features = ["std", "std_rng"] }
Expand Down
3 changes: 3 additions & 0 deletions arrow-array/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ pub use record_batch::{RecordBatch, RecordBatchOptions, RecordBatchReader};
mod arithmetic;
pub use arithmetic::ArrowNativeTypeOp;

mod numeric;
pub use numeric::*;

pub mod builder;
pub mod cast;
mod delta;
Expand Down
16 changes: 9 additions & 7 deletions arrow/src/datatypes/numeric.rs → arrow-array/src/numeric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
// specific language governing permissions and limitations
// under the License.

use super::*;
use crate::types::*;
use crate::ArrowPrimitiveType;
#[cfg(feature = "simd")]
use packed_simd::*;
#[cfg(feature = "simd")]
Expand Down Expand Up @@ -106,9 +107,11 @@ where
/// Writes a SIMD result back to a slice
fn write(simd_result: Self::Simd, slice: &mut [Self::Native]);

/// Performs a SIMD unary operation
fn unary_op<F: Fn(Self::Simd) -> Self::Simd>(a: Self::Simd, op: F) -> Self::Simd;
}

/// A subtype of primitive type that represents numeric values.
#[cfg(not(feature = "simd"))]
pub trait ArrowNumericType: ArrowPrimitiveType {}

Expand Down Expand Up @@ -468,7 +471,7 @@ impl ArrowNumericType for Decimal256Type {}

#[cfg(feature = "simd")]
impl ArrowNumericType for Decimal256Type {
type Simd = i256;
type Simd = arrow_buffer::i256;
type SimdMask = bool;

fn lanes() -> usize {
Expand Down Expand Up @@ -555,11 +558,14 @@ impl ArrowNumericType for Decimal256Type {
}
}

/// A subtype of primitive type that represents numeric float values
#[cfg(feature = "simd")]
pub trait ArrowFloatNumericType: ArrowNumericType {
/// SIMD version of pow
fn pow(base: Self::Simd, raise: Self::Simd) -> Self::Simd;
}

/// A subtype of primitive type that represents numeric float values
#[cfg(not(feature = "simd"))]
pub trait ArrowFloatNumericType: ArrowNumericType {}

Expand All @@ -583,11 +589,7 @@ make_float_numeric_type!(Float64Type, f64x8);

#[cfg(all(test, feature = "simd"))]
mod tests {
use crate::datatypes::{
ArrowNumericType, Float32Type, Float64Type, Int32Type, Int64Type, Int8Type,
IntervalMonthDayNanoType, UInt16Type,
};
use packed_simd::*;
use super::*;
use FromCast;

/// calculate the expected mask by iterating over all bits
Expand Down
53 changes: 53 additions & 0 deletions arrow-ord/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

[package]
name = "arrow-ord"
version = "28.0.0"
description = "Ordering kernels for arrow arrays"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would "comparison kernels" be a more accurate description?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are sort kernels in there, so it is kind of kernels that relate to the ordering of elements? Maybe? I don't really feel strongly, was just trying to justify why it is arrow-ord and not arrow-cmp or something 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine 👍

homepage = "https://github.com/apache/arrow-rs"
repository = "https://github.com/apache/arrow-rs"
authors = ["Apache Arrow <dev@arrow.apache.org>"]
license = "Apache-2.0"
keywords = ["arrow"]
include = [
"benches/*.rs",
"src/**/*.rs",
"Cargo.toml",
]
edition = "2021"
rust-version = "1.62"

[lib]
name = "arrow_ord"
path = "src/lib.rs"
bench = false

[dependencies]
arrow-array = { version = "28.0.0", path = "../arrow-array" }
arrow-buffer = { version = "28.0.0", path = "../arrow-buffer" }
arrow-data = { version = "28.0.0", path = "../arrow-data" }
arrow-schema = { version = "28.0.0", path = "../arrow-schema" }
arrow-select = { version = "28.0.0", path = "../arrow-select" }
num = { version = "0.4", default-features = false, features = ["std"] }

[dev-dependencies]
rand = { version = "0.8", default-features = false, features = ["std", "std_rng"] }

[features]
dyn_cmp_dict = []
simd = ["arrow-array/simd"]