Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ FEDORA=33
PYTHON=3.6
LLVM=11
CLANG_TOOLS=8
RUST=nightly-2020-04-22
RUST=nightly-2020-11-14
GO=1.12
NODE=14
MAVEN=3.5.4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
strategy:
fail-fast: false
matrix:
rust: [nightly-2020-04-22]
rust: [nightly-2020-11-14]
env:
RUST: ${{ matrix.rust }}
steps:
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
strategy:
fail-fast: false
matrix:
rust: [nightly-2020-04-22]
rust: [nightly-2020-11-14]
steps:
- name: Install Rust
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -134,7 +134,7 @@ jobs:
strategy:
fail-fast: false
matrix:
rust: [nightly-2020-04-22]
rust: [nightly-2020-11-14]
steps:
- name: Install Rust
uses: actions-rs/toolchain@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
strategy:
fail-fast: false
matrix:
rust: [nightly-2020-04-22]
rust: [nightly-2020-11-14]
env:
RUST: ${{ matrix.rust }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/debian-10-rust.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ RUN wget -q -O - https://github.com/google/flatbuffers/archive/v${flatbuffers}.t
cd / && \
rm -rf flatbuffers-${flatbuffers}

ARG rust=nightly-2020-04-22
ARG rust=nightly-2020-11-14

# freeze the version for deterministic builds
RUN rustup default ${rust} && \
Expand Down
4 changes: 3 additions & 1 deletion ci/scripts/rust_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ pushd ${source_dir}

rustup default ${rust}
rustup component add rustfmt --toolchain ${rust}-x86_64-unknown-linux-gnu
cargo install cargo-tarpaulin
# 2020-11-15: There is a cargo-tarpaulin regression in 0.17.0
# see https://github.com/xd009642/tarpaulin/issues/618
cargo install --version 0.16.0 cargo-tarpaulin

cargo tarpaulin --out Xml

Expand Down
3 changes: 1 addition & 2 deletions rust/arrow/benches/array_from_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ fn struct_array_from_vec(
let ints: ArrayRef = Arc::new(Int32Array::from(ints.clone()));

criterion::black_box(
StructArray::try_from(vec![(field1.clone(), strings), (field2.clone(), ints)])
.unwrap(),
StructArray::try_from(vec![(field1, strings), (field2, ints)]).unwrap(),
);
}

Expand Down
3 changes: 3 additions & 0 deletions rust/arrow/benches/equal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
// specific language governing permissions and limitations
// under the License.

// Allowed because we use `arr == arr` in benchmarks
#![allow(clippy::eq_op)]

#[macro_use]
extern crate criterion;
use criterion::Criterion;
Expand Down
15 changes: 3 additions & 12 deletions rust/arrow/benches/filter_kernels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,9 @@ fn bench_filter_context_f32(data_array: &Float32Array, filter_context: &FilterCo

fn add_benchmark(c: &mut Criterion) {
let size = 65536;
let filter_array = create_bool_array(size, |i| match i % 2 {
0 => true,
_ => false,
});
let sparse_filter_array = create_bool_array(size, |i| match i % 8000 {
0 => true,
_ => false,
});
let dense_filter_array = create_bool_array(size, |i| match i % 8000 {
0 => false,
_ => true,
});
let filter_array = create_bool_array(size, |i| matches!(i % 2, 0));
let sparse_filter_array = create_bool_array(size, |i| matches!(i % 8000, 0));
let dense_filter_array = create_bool_array(size, |i| !matches!(i % 8000, 0));

let filter_context = FilterContext::new(&filter_array).unwrap();
let sparse_filter_context = FilterContext::new(&sparse_filter_array).unwrap();
Expand Down
3 changes: 2 additions & 1 deletion rust/arrow/examples/dynamic_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ fn main() -> Result<()> {
let batch =
RecordBatch::try_new(Arc::new(schema), vec![Arc::new(id), Arc::new(nested)])?;

Ok(process(&batch))
process(&batch);
Ok(())
}

/// Create a new batch by performing a projection of id, nested.c
Expand Down
6 changes: 2 additions & 4 deletions rust/arrow/src/array/array_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,8 @@ mod tests {
// from Iterator<Option<&str>>
let array2: StringArray = data.clone().into_iter().collect();
// from Iterator<Option<String>>
let array3: StringArray = data
.into_iter()
.map(|x| x.map(|s| format!("{}", s)))
.collect();
let array3: StringArray =
data.into_iter().map(|x| x.map(|s| s.to_string())).collect();

assert_eq!(array1, array2);
assert_eq!(array2, array3);
Expand Down
2 changes: 1 addition & 1 deletion rust/arrow/src/array/array_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ mod tests {
Err(ArrowError::InvalidArgumentError(e)) => {
assert!(e.starts_with("Array of field \"f2\" has length 4, but previous elements have length 3."));
}
_ => assert!(false, "This test got an unexpected error type"),
_ => panic!("This test got an unexpected error type"),
};
}

Expand Down
5 changes: 3 additions & 2 deletions rust/arrow/src/array/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ pub trait BufferBuilderTrait<T: ArrowPrimitiveType> {
///
/// assert!(builder.capacity() >= 20);
/// ```
fn reserve(&mut self, n: usize) -> ();
fn reserve(&mut self, n: usize);

/// Appends a value of type `T` into the builder,
/// growing the internal buffer as needed.
Expand Down Expand Up @@ -370,7 +370,8 @@ impl<T: ArrowPrimitiveType> BufferBuilderTrait<T> for BufferBuilder<T> {
}
Ok(())
} else {
Ok(self.write_bytes(slice.to_byte_slice(), array_slots))
self.write_bytes(slice.to_byte_slice(), array_slots);
Ok(())
}
}

Expand Down
2 changes: 1 addition & 1 deletion rust/arrow/src/array/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl ArrayData {
#[inline]
pub(super) fn buffer<T: ArrowNativeType>(&self, buffer: usize) -> &[T] {
let values = unsafe { self.buffers[buffer].data().align_to::<T>() };
if values.0.len() != 0 || values.2.len() != 0 {
if !values.0.is_empty() || !values.2.is_empty() {
panic!("The buffer is not byte-aligned with its interpretation")
};
assert_ne!(self.data_type, DataType::Boolean);
Expand Down
2 changes: 1 addition & 1 deletion rust/arrow/src/array/equal/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn lengths_equal<T: OffsetSizeTrait>(lhs: &[T], rhs: &[T]) -> bool {
// invariant from `base_equal`
debug_assert_eq!(lhs.len(), rhs.len());

if lhs.len() == 0 {
if lhs.is_empty() {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion rust/arrow/src/array/equal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ mod tests {
false,
),
(base.clone(), base.clone(), true),
(base.clone(), not_base.clone(), false),
(base, not_base, false),
]
}

Expand Down
5 changes: 1 addition & 4 deletions rust/arrow/src/array/equal_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ impl JsonEqual for StructArray {
return false;
}

let all_object = json.iter().all(|v| match v {
Object(_) | JNull => true,
_ => false,
});
let all_object = json.iter().all(|v| matches!(v, Object(_) | JNull));

if !all_object {
return false;
Expand Down
3 changes: 1 addition & 2 deletions rust/arrow/src/array/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ mod tests {
let array = array.as_any().downcast_ref::<Int32Array>().unwrap();

// to and from iter, with a +1
let result: Int32Array =
array.iter().map(|e| e.and_then(|e| Some(e + 1))).collect();
let result: Int32Array = array.iter().map(|e| e.map(|e| e + 1)).collect();

let expected = Int32Array::from(vec![Some(1), None, Some(3), None, Some(5)]);
assert_eq!(result, expected);
Expand Down
2 changes: 1 addition & 1 deletion rust/arrow/src/compute/kernels/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ where
let remainder = data_chunks.remainder();

let bit_chunks = buffer.bit_chunks(array.offset(), array.len());
&data_chunks
data_chunks
.zip(bit_chunks.iter())
.for_each(|(chunk, mask)| {
chunk.iter().enumerate().for_each(|(i, value)| {
Expand Down
24 changes: 11 additions & 13 deletions rust/arrow/src/compute/kernels/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,9 @@ pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool {
(Time32(_), Time64(_)) => true,
(Time64(TimeUnit::Microsecond), Time64(TimeUnit::Nanosecond)) => true,
(Time64(TimeUnit::Nanosecond), Time64(TimeUnit::Microsecond)) => true,
(Time64(_), Time32(to_unit)) => match to_unit {
TimeUnit::Second => true,
TimeUnit::Millisecond => true,
_ => false,
},
(Time64(_), Time32(to_unit)) => {
matches!(to_unit, TimeUnit::Second | TimeUnit::Millisecond)
}
(Timestamp(_, _), Int64) => true,
(Int64, Timestamp(_, _)) => true,
(Timestamp(_, _), Timestamp(_, _)) => true,
Expand Down Expand Up @@ -2857,10 +2855,10 @@ mod tests {
// Construct a list array from the above two
let list_data_type =
DataType::List(Box::new(Field::new("item", DataType::Int32, true)));
let list_data = ArrayData::builder(list_data_type.clone())
let list_data = ArrayData::builder(list_data_type)
.len(3)
.add_buffer(value_offsets.clone())
.add_child_data(value_data.clone())
.add_buffer(value_offsets)
.add_child_data(value_data)
.build();
ListArray::from(list_data)
}
Expand All @@ -2879,10 +2877,10 @@ mod tests {
// Construct a list array from the above two
let list_data_type =
DataType::LargeList(Box::new(Field::new("item", DataType::Int32, true)));
let list_data = ArrayData::builder(list_data_type.clone())
let list_data = ArrayData::builder(list_data_type)
.len(3)
.add_buffer(value_offsets.clone())
.add_child_data(value_data.clone())
.add_buffer(value_offsets)
.add_child_data(value_data)
.build();
LargeListArray::from(list_data)
}
Expand All @@ -2903,7 +2901,7 @@ mod tests {
);
let list_data = ArrayData::builder(list_data_type)
.len(5)
.add_child_data(value_data.clone())
.add_child_data(value_data)
.build();
FixedSizeListArray::from(list_data)
}
Expand Down Expand Up @@ -2973,7 +2971,7 @@ mod tests {
Timestamp(TimeUnit::Second, Some(tz_name.clone())),
Timestamp(TimeUnit::Millisecond, Some(tz_name.clone())),
Timestamp(TimeUnit::Microsecond, Some(tz_name.clone())),
Timestamp(TimeUnit::Nanosecond, Some(tz_name.clone())),
Timestamp(TimeUnit::Nanosecond, Some(tz_name)),
Date32(DateUnit::Day),
Date64(DateUnit::Day),
Date32(DateUnit::Millisecond),
Expand Down
52 changes: 22 additions & 30 deletions rust/arrow/src/compute/kernels/length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,36 +102,30 @@ mod tests {

#[test]
fn test_string() -> Result<()> {
cases()
.into_iter()
.map(|(input, len, expected)| {
let array = StringArray::from(input);
let result = length(&array)?;
assert_eq!(len, result.len());
let result = result.as_any().downcast_ref::<Int32Array>().unwrap();
expected.iter().enumerate().for_each(|(i, value)| {
assert_eq!(*value, result.value(i));
});
Ok(())
})
.collect::<Result<()>>()
cases().into_iter().try_for_each(|(input, len, expected)| {
let array = StringArray::from(input);
let result = length(&array)?;
assert_eq!(len, result.len());
let result = result.as_any().downcast_ref::<Int32Array>().unwrap();
expected.iter().enumerate().for_each(|(i, value)| {
assert_eq!(*value, result.value(i));
});
Ok(())
})
}

#[test]
fn test_large_string() -> Result<()> {
cases()
.into_iter()
.map(|(input, len, expected)| {
let array = LargeStringArray::from(input);
let result = length(&array)?;
assert_eq!(len, result.len());
let result = result.as_any().downcast_ref::<Int64Array>().unwrap();
expected.iter().enumerate().for_each(|(i, value)| {
assert_eq!(*value as i64, result.value(i));
});
Ok(())
})
.collect::<Result<()>>()
cases().into_iter().try_for_each(|(input, len, expected)| {
let array = LargeStringArray::from(input);
let result = length(&array)?;
assert_eq!(len, result.len());
let result = result.as_any().downcast_ref::<Int64Array>().unwrap();
expected.iter().enumerate().for_each(|(i, value)| {
assert_eq!(*value as i64, result.value(i));
});
Ok(())
})
}

fn null_cases() -> Vec<(Vec<Option<&'static str>>, usize, Vec<Option<i32>>)> {
Expand All @@ -146,7 +140,7 @@ mod tests {
fn null_string() -> Result<()> {
null_cases()
.into_iter()
.map(|(input, len, expected)| {
.try_for_each(|(input, len, expected)| {
let array = StringArray::from(input);
let result = length(&array)?;
assert_eq!(len, result.len());
Expand All @@ -156,14 +150,13 @@ mod tests {
assert_eq!(expected.data(), result.data());
Ok(())
})
.collect::<Result<()>>()
}

#[test]
fn null_large_string() -> Result<()> {
null_cases()
.into_iter()
.map(|(input, len, expected)| {
.try_for_each(|(input, len, expected)| {
let array = LargeStringArray::from(input);
let result = length(&array)?;
assert_eq!(len, result.len());
Expand All @@ -178,7 +171,6 @@ mod tests {
assert_eq!(expected.data(), result.data());
Ok(())
})
.collect::<Result<()>>()
}

/// Tests that length is not valid for u64.
Expand Down
2 changes: 1 addition & 1 deletion rust/arrow/src/compute/kernels/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ pub fn lexsort(columns: &[SortColumn]) -> Result<Vec<ArrayRef>> {
/// Sort elements lexicographically from a list of `ArrayRef` into an unsigned integer
/// (`UInt32Array`) of indices.
pub fn lexsort_to_indices(columns: &[SortColumn]) -> Result<UInt32Array> {
if columns.len() == 0 {
if columns.is_empty() {
return Err(ArrowError::InvalidArgumentError(
"Sort requires at least one column".to_string(),
));
Expand Down
2 changes: 1 addition & 1 deletion rust/arrow/src/compute/kernels/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ mod tests {
// Construct a list array from the above two
let list_data_type =
DataType::List(Box::new(Field::new("item", DataType::Int32, false)));
let list_data = ArrayData::builder(list_data_type.clone())
let list_data = ArrayData::builder(list_data_type)
.len(3)
.add_buffer(value_offsets)
.add_child_data(value_data)
Expand Down
4 changes: 2 additions & 2 deletions rust/arrow/src/compute/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ mod tests {
.add_buffer(value_offsets)
.add_child_data(value_data)
.build();
let array = Arc::new(GenericListArray::<S>::from(list_data)) as ArrayRef;
array

Arc::new(GenericListArray::<S>::from(list_data))
}

#[test]
Expand Down
Loading