forked from apache/arrow-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into scalar-experiments
- Loading branch information
Showing
54 changed files
with
1,339 additions
and
1,034 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ jobs: | |
container: | ||
image: ${{ matrix.arch }}/rust | ||
env: | ||
RUSTDOCFLAGS: "-Dwarnings" | ||
RUSTDOCFLAGS: "-Dwarnings --enable-index-page -Zunstable-options" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
|
@@ -56,3 +56,42 @@ jobs: | |
rust-version: ${{ matrix.rust }} | ||
- name: Run cargo doc | ||
run: cargo doc --document-private-items --no-deps --workspace --all-features | ||
- name: Fix file permissions | ||
shell: sh | ||
run: | | ||
chmod -c -R +rX "target/doc" | | ||
while read line; do | ||
echo "::warning title=Invalid file permissions automatically fixed::$line" | ||
done | ||
- name: Upload artifacts | ||
uses: actions/upload-pages-artifact@v1 | ||
with: | ||
name: crate-docs | ||
path: target/doc | ||
|
||
deploy: | ||
# Only deploy if a push to master | ||
if: github.ref_name == 'master' && github.event_name == 'push' | ||
needs: docs | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Download crate docs | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: crate-docs | ||
path: website/build | ||
- name: Prepare website | ||
run: | | ||
tar -xf website/build/artifact.tar -C website/build | ||
rm website/build/artifact.tar | ||
cp .asf.yaml ./website/build/.asf.yaml | ||
- name: Deploy to gh-pages | ||
uses: peaceiris/[email protected] | ||
if: github.event_name == 'push' && github.ref_name == 'master' | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: website/build | ||
publish_branch: asf-site |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,7 @@ exclude = [ | |
] | ||
|
||
[workspace.package] | ||
version = "41.0.0" | ||
version = "42.0.0" | ||
homepage = "https://github.com/apache/arrow-rs" | ||
repository = "https://github.com/apache/arrow-rs" | ||
authors = ["Apache Arrow <[email protected]>"] | ||
|
@@ -76,18 +76,18 @@ edition = "2021" | |
rust-version = "1.62" | ||
|
||
[workspace.dependencies] | ||
arrow = { version = "41.0.0", path = "./arrow", default-features = false } | ||
arrow-arith = { version = "41.0.0", path = "./arrow-arith" } | ||
arrow-array = { version = "41.0.0", path = "./arrow-array" } | ||
arrow-buffer = { version = "41.0.0", path = "./arrow-buffer" } | ||
arrow-cast = { version = "41.0.0", path = "./arrow-cast" } | ||
arrow-csv = { version = "41.0.0", path = "./arrow-csv" } | ||
arrow-data = { version = "41.0.0", path = "./arrow-data" } | ||
arrow-ipc = { version = "41.0.0", path = "./arrow-ipc" } | ||
arrow-json = { version = "41.0.0", path = "./arrow-json" } | ||
arrow-ord = { version = "41.0.0", path = "./arrow-ord" } | ||
arrow-row = { version = "41.0.0", path = "./arrow-row" } | ||
arrow-schema = { version = "41.0.0", path = "./arrow-schema" } | ||
arrow-select = { version = "41.0.0", path = "./arrow-select" } | ||
arrow-string = { version = "41.0.0", path = "./arrow-string" } | ||
parquet = { version = "41.0.0", path = "./parquet", default-features = false } | ||
arrow = { version = "42.0.0", path = "./arrow", default-features = false } | ||
arrow-arith = { version = "42.0.0", path = "./arrow-arith" } | ||
arrow-array = { version = "42.0.0", path = "./arrow-array" } | ||
arrow-buffer = { version = "42.0.0", path = "./arrow-buffer" } | ||
arrow-cast = { version = "42.0.0", path = "./arrow-cast" } | ||
arrow-csv = { version = "42.0.0", path = "./arrow-csv" } | ||
arrow-data = { version = "42.0.0", path = "./arrow-data" } | ||
arrow-ipc = { version = "42.0.0", path = "./arrow-ipc" } | ||
arrow-json = { version = "42.0.0", path = "./arrow-json" } | ||
arrow-ord = { version = "42.0.0", path = "./arrow-ord" } | ||
arrow-row = { version = "42.0.0", path = "./arrow-row" } | ||
arrow-schema = { version = "42.0.0", path = "./arrow-schema" } | ||
arrow-select = { version = "42.0.0", path = "./arrow-select" } | ||
arrow-string = { version = "42.0.0", path = "./arrow-string" } | ||
parquet = { version = "42.0.0", path = "./parquet", default-features = false } |
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 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 |
---|---|---|
@@ -0,0 +1,184 @@ | ||
// 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. | ||
|
||
use crate::builder::ArrayBuilder; | ||
use crate::{ArrayRef, NullArray}; | ||
use arrow_data::ArrayData; | ||
use arrow_schema::DataType; | ||
use std::any::Any; | ||
use std::sync::Arc; | ||
|
||
/// Builder for [`NullArray`] | ||
/// | ||
/// # Example | ||
/// | ||
/// Create a `NullArray` from a `NullBuilder` | ||
/// | ||
/// ``` | ||
/// | ||
/// # use arrow_array::{Array, NullArray, builder::NullBuilder}; | ||
/// | ||
/// let mut b = NullBuilder::new(); | ||
/// b.append_empty_value(); | ||
/// b.append_null(); | ||
/// b.append_nulls(3); | ||
/// b.append_empty_values(3); | ||
/// let arr = b.finish(); | ||
/// | ||
/// assert_eq!(8, arr.len()); | ||
/// assert_eq!(8, arr.null_count()); | ||
/// ``` | ||
#[derive(Debug)] | ||
pub struct NullBuilder { | ||
len: usize, | ||
} | ||
|
||
impl Default for NullBuilder { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
impl NullBuilder { | ||
/// Creates a new null builder | ||
pub fn new() -> Self { | ||
Self { len: 0 } | ||
} | ||
|
||
/// Creates a new null builder with space for `capacity` elements without re-allocating | ||
pub fn with_capacity(capacity: usize) -> Self { | ||
Self { len: capacity } | ||
} | ||
|
||
/// Returns the capacity of this builder measured in slots of type `T` | ||
pub fn capacity(&self) -> usize { | ||
self.len | ||
} | ||
|
||
/// Appends a null slot into the builder | ||
#[inline] | ||
pub fn append_null(&mut self) { | ||
self.len += 1; | ||
} | ||
|
||
/// Appends `n` `null`s into the builder. | ||
#[inline] | ||
pub fn append_nulls(&mut self, n: usize) { | ||
self.len += n; | ||
} | ||
|
||
/// Appends a null slot into the builder | ||
#[inline] | ||
pub fn append_empty_value(&mut self) { | ||
self.append_null(); | ||
} | ||
|
||
/// Appends `n` `null`s into the builder. | ||
#[inline] | ||
pub fn append_empty_values(&mut self, n: usize) { | ||
self.append_nulls(n); | ||
} | ||
|
||
/// Builds the [NullArray] and reset this builder. | ||
pub fn finish(&mut self) -> NullArray { | ||
let len = self.len(); | ||
let builder = ArrayData::new_null(&DataType::Null, len).into_builder(); | ||
|
||
let array_data = unsafe { builder.build_unchecked() }; | ||
NullArray::from(array_data) | ||
} | ||
|
||
/// Builds the [NullArray] without resetting the builder. | ||
pub fn finish_cloned(&self) -> NullArray { | ||
let len = self.len(); | ||
let builder = ArrayData::new_null(&DataType::Null, len).into_builder(); | ||
|
||
let array_data = unsafe { builder.build_unchecked() }; | ||
NullArray::from(array_data) | ||
} | ||
} | ||
|
||
impl ArrayBuilder for NullBuilder { | ||
/// Returns the builder as a non-mutable `Any` reference. | ||
fn as_any(&self) -> &dyn Any { | ||
self | ||
} | ||
|
||
/// Returns the builder as a mutable `Any` reference. | ||
fn as_any_mut(&mut self) -> &mut dyn Any { | ||
self | ||
} | ||
|
||
/// Returns the boxed builder as a box of `Any`. | ||
fn into_box_any(self: Box<Self>) -> Box<dyn Any> { | ||
self | ||
} | ||
|
||
/// Returns the number of array slots in the builder | ||
fn len(&self) -> usize { | ||
self.len | ||
} | ||
|
||
/// Returns whether the number of array slots is zero | ||
fn is_empty(&self) -> bool { | ||
self.len() == 0 | ||
} | ||
|
||
/// Builds the array and reset this builder. | ||
fn finish(&mut self) -> ArrayRef { | ||
Arc::new(self.finish()) | ||
} | ||
|
||
/// Builds the array without resetting the builder. | ||
fn finish_cloned(&self) -> ArrayRef { | ||
Arc::new(self.finish_cloned()) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use crate::Array; | ||
|
||
#[test] | ||
fn test_null_array_builder() { | ||
let mut builder = NullArray::builder(10); | ||
builder.append_null(); | ||
builder.append_nulls(4); | ||
builder.append_empty_value(); | ||
builder.append_empty_values(4); | ||
|
||
let arr = builder.finish(); | ||
assert_eq!(20, arr.len()); | ||
assert_eq!(0, arr.offset()); | ||
assert_eq!(20, arr.null_count()); | ||
} | ||
|
||
#[test] | ||
fn test_null_array_builder_finish_cloned() { | ||
let mut builder = NullArray::builder(16); | ||
builder.append_null(); | ||
builder.append_empty_value(); | ||
builder.append_empty_values(3); | ||
let mut array = builder.finish_cloned(); | ||
assert_eq!(21, array.null_count()); | ||
|
||
builder.append_empty_values(5); | ||
array = builder.finish(); | ||
assert_eq!(26, array.null_count()); | ||
} | ||
} |
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.