Skip to content

Commit

Permalink
Split out arrow-row (apache#2594)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Dec 20, 2022
1 parent c344433 commit 2997b40
Show file tree
Hide file tree
Showing 12 changed files with 2,264 additions and 35 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -29,6 +29,7 @@ members = [
"arrow-ipc",
"arrow-json",
"arrow-ord",
"arrow-row",
"arrow-schema",
"arrow-select",
"arrow-string",
Expand Down
19 changes: 19 additions & 0 deletions arrow-array/src/lib.rs
Expand Up @@ -183,6 +183,25 @@ pub mod timezone;
mod trusted_len;
pub mod types;

/// Options that define how sort kernels should behave
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct SortOptions {
/// Whether to sort in descending order
pub descending: bool,
/// Whether to sort nulls first
pub nulls_first: bool,
}

impl Default for SortOptions {
fn default() -> Self {
Self {
descending: false,
// default to nulls first to match spark's behavior
nulls_first: true,
}
}
}

#[cfg(test)]
mod tests {
use crate::builder::*;
Expand Down
21 changes: 2 additions & 19 deletions arrow-ord/src/sort.rs
Expand Up @@ -27,6 +27,8 @@ use arrow_schema::{ArrowError, DataType, IntervalUnit, TimeUnit};
use arrow_select::take::take;
use std::cmp::Ordering;

pub use arrow_array::SortOptions;

/// Sort the `ArrayRef` using `SortOptions`.
///
/// Performs a sort on values and indices. Nulls are ordered according
Expand Down Expand Up @@ -366,25 +368,6 @@ pub fn sort_to_indices(
})
}

/// Options that define how sort kernels should behave
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct SortOptions {
/// Whether to sort in descending order
pub descending: bool,
/// Whether to sort nulls first
pub nulls_first: bool,
}

impl Default for SortOptions {
fn default() -> Self {
Self {
descending: false,
// default to nulls first to match spark's behavior
nulls_first: true,
}
}
}

/// Sort boolean values
///
/// when a limit is present, the sort is pair-comparison based as k-select might be more efficient,
Expand Down
61 changes: 61 additions & 0 deletions arrow-row/Cargo.toml
@@ -0,0 +1,61 @@
# 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-row"
version = "29.0.0"
description = "Arrow row format"
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_row"
path = "src/lib.rs"
bench = false

[target.'cfg(target_arch = "wasm32")'.dependencies]
ahash = { version = "0.8", default-features = false, features = ["compile-time-rng"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
ahash = { version = "0.8", default-features = false, features = ["runtime-rng"] }

[dependencies]
arrow-array = { version = "29.0.0", path = "../arrow-array" }
arrow-buffer = { version = "29.0.0", path = "../arrow-buffer" }
arrow-data = { version = "29.0.0", path = "../arrow-data" }
arrow-schema = { version = "29.0.0", path = "../arrow-schema" }

half = { version = "2.1", default-features = false }
hashbrown = { version = "0.13", default-features = false }

[dev-dependencies]
arrow-cast = { version = "29.0.0", path = "../arrow-cast" }
arrow-ord = { version = "29.0.0", path = "../arrow-ord" }
rand = { version = "0.8", default-features = false, features = ["std", "std_rng"] }

[features]

7 changes: 3 additions & 4 deletions arrow/src/row/dictionary.rs → arrow-row/src/dictionary.rs
Expand Up @@ -15,10 +15,9 @@
// specific language governing permissions and limitations
// under the License.

use crate::compute::SortOptions;
use crate::row::fixed::{FixedLengthEncoding, FromSlice};
use crate::row::interner::{Interned, OrderPreservingInterner};
use crate::row::{null_sentinel, Rows};
use crate::fixed::{FixedLengthEncoding, FromSlice};
use crate::interner::{Interned, OrderPreservingInterner};
use crate::{null_sentinel, Rows};
use arrow_array::builder::*;
use arrow_array::cast::*;
use arrow_array::types::*;
Expand Down
6 changes: 2 additions & 4 deletions arrow/src/row/fixed.rs → arrow-row/src/fixed.rs
Expand Up @@ -16,11 +16,9 @@
// under the License.

use crate::array::PrimitiveArray;
use crate::compute::SortOptions;
use crate::datatypes::ArrowPrimitiveType;
use crate::row::{null_sentinel, Rows};
use crate::{null_sentinel, Rows};
use arrow_array::builder::BufferBuilder;
use arrow_array::{BooleanArray, FixedSizeBinaryArray};
use arrow_array::{ArrowPrimitiveType, BooleanArray, FixedSizeBinaryArray, SortOptions};
use arrow_buffer::{bit_util, i256, ArrowNativeType, Buffer, MutableBuffer};
use arrow_data::{ArrayData, ArrayDataBuilder};
use arrow_schema::DataType;
Expand Down
File renamed without changes.

0 comments on commit 2997b40

Please sign in to comment.