Skip to content

Commit 29cdbad

Browse files
committed
Merge remote-tracking branch 'oss/main' into unshred-variant
2 parents 62b6299 + ef51f11 commit 29cdbad

File tree

35 files changed

+430
-261
lines changed

35 files changed

+430
-261
lines changed

arrow-arith/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
html_logo_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_white-bg.svg",
2222
html_favicon_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_transparent-bg.svg"
2323
)]
24-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
24+
#![cfg_attr(docsrs, feature(doc_cfg))]
2525
#![warn(missing_docs)]
2626
pub mod aggregate;
2727
#[doc(hidden)] // Kernels to be removed in a future release

arrow-array/src/builder/fixed_size_binary_dictionary_builder.rs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,28 @@ where
252252
}
253253
}
254254

255+
/// Append a value multiple times to the array.
256+
/// This is the same as [`Self::append`] but allows to append the same value multiple times without doing multiple lookups.
257+
///
258+
/// Returns an error if the new index would overflow the key type.
259+
pub fn append_n(
260+
&mut self,
261+
value: impl AsRef<[u8]>,
262+
count: usize,
263+
) -> Result<K::Native, ArrowError> {
264+
if self.byte_width != value.as_ref().len() as i32 {
265+
Err(ArrowError::InvalidArgumentError(format!(
266+
"Invalid input length passed to FixedSizeBinaryBuilder. Expected {} got {}",
267+
self.byte_width,
268+
value.as_ref().len()
269+
)))
270+
} else {
271+
let key = self.get_or_insert_key(value)?;
272+
self.keys_builder.append_value_n(key, count);
273+
Ok(key)
274+
}
275+
}
276+
255277
/// Appends a null slot into the builder
256278
#[inline]
257279
pub fn append_null(&mut self) {
@@ -401,6 +423,39 @@ mod tests {
401423
assert_eq!(ava.value(1), values[1].as_bytes());
402424
}
403425

426+
#[test]
427+
fn test_fixed_size_dictionary_builder_append_n() {
428+
let values = ["abc", "def"];
429+
let mut b = FixedSizeBinaryDictionaryBuilder::<Int8Type>::new(3);
430+
assert_eq!(b.append_n(values[0], 2).unwrap(), 0);
431+
assert_eq!(b.append_n(values[1], 3).unwrap(), 1);
432+
assert_eq!(b.append_n(values[0], 2).unwrap(), 0);
433+
let array = b.finish();
434+
435+
assert_eq!(
436+
array.keys(),
437+
&Int8Array::from(vec![
438+
Some(0),
439+
Some(0),
440+
Some(1),
441+
Some(1),
442+
Some(1),
443+
Some(0),
444+
Some(0),
445+
]),
446+
);
447+
448+
// Values are polymorphic and so require a downcast.
449+
let ava = array
450+
.values()
451+
.as_any()
452+
.downcast_ref::<FixedSizeBinaryArray>()
453+
.unwrap();
454+
455+
assert_eq!(ava.value(0), values[0].as_bytes());
456+
assert_eq!(ava.value(1), values[1].as_bytes());
457+
}
458+
404459
#[test]
405460
fn test_fixed_size_dictionary_builder_wrong_size() {
406461
let mut b = FixedSizeBinaryDictionaryBuilder::<Int8Type>::new(3);
@@ -414,6 +469,11 @@ mod tests {
414469
err,
415470
"Invalid argument error: Invalid input length passed to FixedSizeBinaryBuilder. Expected 3 got 0"
416471
);
472+
let err = b.append_n("a", 3).unwrap_err().to_string();
473+
assert_eq!(
474+
err,
475+
"Invalid argument error: Invalid input length passed to FixedSizeBinaryBuilder. Expected 3 got 1"
476+
);
417477
}
418478

419479
#[test]

arrow-array/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
html_logo_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_white-bg.svg",
226226
html_favicon_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_transparent-bg.svg"
227227
)]
228-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
228+
#![cfg_attr(docsrs, feature(doc_cfg))]
229229
#![deny(rustdoc::broken_intra_doc_links)]
230230
#![warn(missing_docs)]
231231

arrow-avro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@
222222
html_logo_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_white-bg.svg",
223223
html_favicon_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_transparent-bg.svg"
224224
)]
225-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
225+
#![cfg_attr(docsrs, feature(doc_cfg))]
226226
#![warn(missing_docs)]
227227
#![allow(unused)] // Temporary
228228

arrow-buffer/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
html_logo_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_white-bg.svg",
2222
html_favicon_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_transparent-bg.svg"
2323
)]
24-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
24+
#![cfg_attr(docsrs, feature(doc_cfg))]
2525
#![warn(missing_docs)]
2626

2727
pub mod alloc;

arrow-cast/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
html_logo_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_white-bg.svg",
2222
html_favicon_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_transparent-bg.svg"
2323
)]
24-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
24+
#![cfg_attr(docsrs, feature(doc_cfg))]
2525
#![warn(missing_docs)]
2626
pub mod cast;
2727
pub use cast::*;

arrow-csv/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
html_logo_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_white-bg.svg",
2222
html_favicon_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_transparent-bg.svg"
2323
)]
24-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
24+
#![cfg_attr(docsrs, feature(doc_cfg))]
2525
#![warn(missing_docs)]
2626

2727
pub mod reader;

arrow-data/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
html_logo_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_white-bg.svg",
2424
html_favicon_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_transparent-bg.svg"
2525
)]
26-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
26+
#![cfg_attr(docsrs, feature(doc_cfg))]
2727
#![warn(missing_docs)]
2828
mod data;
2929
pub use data::*;

arrow-flight/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
html_logo_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_white-bg.svg",
4242
html_favicon_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_transparent-bg.svg"
4343
)]
44-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
44+
#![cfg_attr(docsrs, feature(doc_cfg))]
4545
#![allow(rustdoc::invalid_html_tags)]
4646
#![warn(missing_docs)]
4747
// The unused_crate_dependencies lint does not work well for crates defining additional examples/bin targets

arrow-integration-test/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
html_logo_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_white-bg.svg",
2626
html_favicon_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_transparent-bg.svg"
2727
)]
28-
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
28+
#![cfg_attr(docsrs, feature(doc_cfg))]
2929
#![warn(missing_docs)]
3030
use arrow_buffer::{IntervalDayTime, IntervalMonthDayNano, ScalarBuffer};
3131
use hex::decode;

0 commit comments

Comments
 (0)