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-data into a separate crate #2746

Merged
merged 3 commits into from Sep 22, 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
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -18,6 +18,7 @@
[workspace]
members = [
"arrow",
"arrow-data",
"arrow-schema",
"arrow-buffer",
"arrow-flight",
Expand Down
56 changes: 56 additions & 0 deletions arrow-data/Cargo.toml
@@ -0,0 +1,56 @@
# 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-data"
version = "23.0.0"
description = "Array data abstractions for Apache Arrow"
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_data"
path = "src/lib.rs"
bench = false

[features]
# force_validate runs full data validation for all arrays that are created
# this is not enabled by default as it is too computationally expensive
# but is run as part of our CI checks
force_validate = []

[dependencies]

arrow-buffer = { version = "23.0.0", path = "../arrow-buffer" }
arrow-schema = { version = "23.0.0", path = "../arrow-schema" }

num = { version = "0.4", default-features = false, features = ["std"] }
half = { version = "2.0", default-features = false }

[dev-dependencies]

[build-dependencies]
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use crate::util::bit_chunk_iterator::{UnalignedBitChunk, UnalignedBitChunkIterator};
use arrow_buffer::bit_chunk_iterator::{UnalignedBitChunk, UnalignedBitChunkIterator};
use std::result::Result;

/// Iterator of contiguous ranges of set bits within a provided packed bitmask
Expand Down
4 changes: 2 additions & 2 deletions arrow/src/util/bit_mask.rs → arrow-data/src/bit_mask.rs
Expand Up @@ -17,8 +17,8 @@

//! Utils for working with packed bit masks

use crate::util::bit_chunk_iterator::BitChunks;
use crate::util::bit_util::{ceil, get_bit, set_bit};
use arrow_buffer::bit_chunk_iterator::BitChunks;
use arrow_buffer::bit_util::{ceil, get_bit, set_bit};

/// Sets all bits on `write_data` in the range `[offset_write..offset_write+len]` to be equal to the
/// bits in `data` in the range `[offset_read..offset_read+len]`
Expand Down
16 changes: 10 additions & 6 deletions arrow/src/bitmap.rs → arrow-data/src/bitmap.rs
Expand Up @@ -17,8 +17,8 @@

//! Defines [Bitmap] for tracking validity bitmaps

use crate::error::{ArrowError, Result};
use crate::util::bit_util;
use arrow_buffer::bit_util;
use arrow_schema::ArrowError;
use std::mem;

use arrow_buffer::buffer::{buffer_bin_and, buffer_bin_or, Buffer};
Expand Down Expand Up @@ -56,6 +56,10 @@ impl Bitmap {
unsafe { bit_util::get_bit_raw(self.bits.as_ptr(), i) }
}

pub fn buffer(&self) -> &Buffer {
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 intend to deprecate buffer_ref in a follow up PR

&self.bits
}

pub fn buffer_ref(&self) -> &Buffer {
&self.bits
}
Expand All @@ -76,9 +80,9 @@ impl Bitmap {
}

impl<'a, 'b> BitAnd<&'b Bitmap> for &'a Bitmap {
type Output = Result<Bitmap>;
type Output = Result<Bitmap, ArrowError>;

fn bitand(self, rhs: &'b Bitmap) -> Result<Bitmap> {
fn bitand(self, rhs: &'b Bitmap) -> Result<Bitmap, ArrowError> {
if self.bits.len() != rhs.bits.len() {
return Err(ArrowError::ComputeError(
"Buffers must be the same size to apply Bitwise AND.".to_string(),
Expand All @@ -95,9 +99,9 @@ impl<'a, 'b> BitAnd<&'b Bitmap> for &'a Bitmap {
}

impl<'a, 'b> BitOr<&'b Bitmap> for &'a Bitmap {
type Output = Result<Bitmap>;
type Output = Result<Bitmap, ArrowError>;

fn bitor(self, rhs: &'b Bitmap) -> Result<Bitmap> {
fn bitor(self, rhs: &'b Bitmap) -> Result<Bitmap, ArrowError> {
if self.bits.len() != rhs.bits.len() {
return Err(ArrowError::ComputeError(
"Buffers must be the same size to apply Bitwise OR.".to_string(),
Expand Down