Skip to content

Commit

Permalink
use from_slice(&[T]) instead of from_slice(Vec<T>) to prevent future …
Browse files Browse the repository at this point in the history
…merge conflicts
  • Loading branch information
Igosuki committed Feb 2, 2022
1 parent 469731b commit 5ad5f7c
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion datafusion/benches/data_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fn create_record_batch(
schema,
vec![
Arc::new(Utf8Array::<i32>::from_slice(keys)),
Arc::new(Float32Array::from_slice(vec![i as f32; batch_size])),
Arc::new(Float32Array::from_slice(&[i as f32; batch_size])),
Arc::new(Float64Array::from(values)),
Arc::new(UInt64Array::from(integer_values_wide)),
Arc::new(UInt64Array::from_slice(integer_values_narrow)),
Expand Down
8 changes: 4 additions & 4 deletions datafusion/src/datasource/file_format/parquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn summarize_min_max(
if let Some(max_value) = &mut max_values[i] {
if let Some(v) = stats.max_value {
match max_value.update_batch(&[Arc::new(
arrow::array::$ARRAY_TYPE::from_slice(vec![v]),
arrow::array::$ARRAY_TYPE::from_slice(&[v]),
)]) {
Ok(_) => {}
Err(_) => {
Expand All @@ -153,7 +153,7 @@ fn summarize_min_max(
if let Some(min_value) = &mut min_values[i] {
if let Some(v) = stats.min_value {
match min_value.update_batch(&[Arc::new(
arrow::array::$ARRAY_TYPE::from_slice(vec![v]),
arrow::array::$ARRAY_TYPE::from_slice(&[v]),
)]) {
Ok(_) => {}
Err(_) => {
Expand All @@ -180,7 +180,7 @@ fn summarize_min_max(
if let Some(max_value) = &mut max_values[i] {
if let Some(v) = stats.max_value {
match max_value
.update_batch(&[Arc::new(BooleanArray::from_slice(vec![v]))])
.update_batch(&[Arc::new(BooleanArray::from_slice(&[v]))])
{
Ok(_) => {}
Err(_) => {
Expand All @@ -192,7 +192,7 @@ fn summarize_min_max(
if let Some(min_value) = &mut min_values[i] {
if let Some(v) = stats.min_value {
match min_value
.update_batch(&[Arc::new(BooleanArray::from_slice(vec![v]))])
.update_batch(&[Arc::new(BooleanArray::from_slice(&[v]))])
{
Ok(_) => {}
Err(_) => {
Expand Down
4 changes: 2 additions & 2 deletions datafusion/src/execution/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3681,8 +3681,8 @@ mod tests {
};

// create mock record batch
let ids = Arc::new(Int32Array::from_slice(vec![i as i32]));
let names = Arc::new(Utf8Array::<i32>::from_slice(vec!["test"]));
let ids = Arc::new(Int32Array::from_slice(&[i as i32]));
let names = Arc::new(Utf8Array::<i32>::from_slice(&["test"]));
let schema_ref = schema.as_ref();
let parquet_schema = to_parquet_schema(schema_ref).unwrap();
let iter = vec![Ok(Chunk::new(vec![ids as ArrayRef, names as ArrayRef]))];
Expand Down
2 changes: 1 addition & 1 deletion datafusion/src/physical_plan/expressions/array_agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ mod tests {

#[test]
fn array_agg_i32() -> Result<()> {
let a: ArrayRef = Arc::new(Int32Array::from_slice(vec![1, 2, 3, 4, 5]));
let a: ArrayRef = Arc::new(Int32Array::from_slice(&[1, 2, 3, 4, 5]));

let list = ScalarValue::List(
Some(Box::new(vec![
Expand Down
4 changes: 2 additions & 2 deletions datafusion/src/physical_plan/expressions/correlation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@ mod tests {

#[test]
fn correlation_f64_6() -> Result<()> {
let a = Arc::new(Float64Array::from_slice(vec![
let a = Arc::new(Float64Array::from_slice(&[
1_f64, 2_f64, 3_f64, 1.1_f64, 2.2_f64, 3.3_f64,
]));
let b = Arc::new(Float64Array::from_slice(vec![
let b = Arc::new(Float64Array::from_slice(&[
4_f64, 5_f64, 6_f64, 4.4_f64, 5.5_f64, 6.6_f64,
]));

Expand Down
4 changes: 2 additions & 2 deletions datafusion/src/physical_plan/expressions/covariance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,10 @@ mod tests {

#[test]
fn covariance_f64_6() -> Result<()> {
let a = Arc::new(Float64Array::from_slice(vec![
let a = Arc::new(Float64Array::from_slice(&[
1_f64, 2_f64, 3_f64, 1.1_f64, 2.2_f64, 3.3_f64,
]));
let b = Arc::new(Float64Array::from_slice(vec![
let b = Arc::new(Float64Array::from_slice(&[
4_f64, 5_f64, 6_f64, 4.4_f64, 5.5_f64, 6.6_f64,
]));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ mod tests {

#[test]
fn distinct_array_agg_i32() -> Result<()> {
let col: ArrayRef = Arc::new(Int32Array::from_slice(vec![1, 2, 7, 4, 5, 2]));
let col: ArrayRef = Arc::new(Int32Array::from_slice(&[1, 2, 7, 4, 5, 2]));

let out = ScalarValue::List(
Some(Box::new(vec![
Expand Down
16 changes: 8 additions & 8 deletions datafusion/src/physical_plan/expressions/stddev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ mod tests {

#[test]
fn stddev_f64_1() -> Result<()> {
let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![1_f64, 2_f64]));
let a: ArrayRef = Arc::new(Float64Array::from_slice(&[1_f64, 2_f64]));
generic_test_op!(
a,
DataType::Float64,
Expand All @@ -272,7 +272,7 @@ mod tests {

#[test]
fn stddev_f64_2() -> Result<()> {
let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![1.1_f64, 2_f64, 3_f64]));
let a: ArrayRef = Arc::new(Float64Array::from_slice(&[1.1_f64, 2_f64, 3_f64]));
generic_test_op!(
a,
DataType::Float64,
Expand All @@ -284,7 +284,7 @@ mod tests {

#[test]
fn stddev_f64_3() -> Result<()> {
let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![
let a: ArrayRef = Arc::new(Float64Array::from_slice(&[
1_f64, 2_f64, 3_f64, 4_f64, 5_f64,
]));
generic_test_op!(
Expand All @@ -298,7 +298,7 @@ mod tests {

#[test]
fn stddev_f64_4() -> Result<()> {
let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![1.1_f64, 2_f64, 3_f64]));
let a: ArrayRef = Arc::new(Float64Array::from_slice(&[1.1_f64, 2_f64, 3_f64]));
generic_test_op!(
a,
DataType::Float64,
Expand All @@ -310,7 +310,7 @@ mod tests {

#[test]
fn stddev_i32() -> Result<()> {
let a: ArrayRef = Arc::new(Int32Array::from_slice(vec![1, 2, 3, 4, 5]));
let a: ArrayRef = Arc::new(Int32Array::from_slice(&[1, 2, 3, 4, 5]));
generic_test_op!(
a,
DataType::Int32,
Expand All @@ -322,7 +322,7 @@ mod tests {

#[test]
fn stddev_u32() -> Result<()> {
let a: ArrayRef = Arc::new(UInt32Array::from_slice(vec![
let a: ArrayRef = Arc::new(UInt32Array::from_slice(&[
1_u32, 2_u32, 3_u32, 4_u32, 5_u32,
]));
generic_test_op!(
Expand All @@ -336,7 +336,7 @@ mod tests {

#[test]
fn stddev_f32() -> Result<()> {
let a: ArrayRef = Arc::new(Float32Array::from_slice(vec![
let a: ArrayRef = Arc::new(Float32Array::from_slice(&[
1_f32, 2_f32, 3_f32, 4_f32, 5_f32,
]));
generic_test_op!(
Expand All @@ -361,7 +361,7 @@ mod tests {

#[test]
fn test_stddev_1_input() -> Result<()> {
let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![1_f64]));
let a: ArrayRef = Arc::new(Float64Array::from_slice(&[1_f64]));
let schema = Schema::new(vec![Field::new("a", DataType::Float64, false)]);
let batch = RecordBatch::try_new(Arc::new(schema.clone()), vec![a])?;

Expand Down
16 changes: 8 additions & 8 deletions datafusion/src/physical_plan/expressions/variance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ mod tests {

#[test]
fn variance_f64_1() -> Result<()> {
let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![1_f64, 2_f64]));
let a: ArrayRef = Arc::new(Float64Array::from_slice(&[1_f64, 2_f64]));
generic_test_op!(
a,
DataType::Float64,
Expand All @@ -357,7 +357,7 @@ mod tests {

#[test]
fn variance_f64_2() -> Result<()> {
let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![
let a: ArrayRef = Arc::new(Float64Array::from_slice(&[
1_f64, 2_f64, 3_f64, 4_f64, 5_f64,
]));
generic_test_op!(
Expand All @@ -371,7 +371,7 @@ mod tests {

#[test]
fn variance_f64_3() -> Result<()> {
let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![
let a: ArrayRef = Arc::new(Float64Array::from_slice(&[
1_f64, 2_f64, 3_f64, 4_f64, 5_f64,
]));
generic_test_op!(
Expand All @@ -385,7 +385,7 @@ mod tests {

#[test]
fn variance_f64_4() -> Result<()> {
let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![1.1_f64, 2_f64, 3_f64]));
let a: ArrayRef = Arc::new(Float64Array::from_slice(&[1.1_f64, 2_f64, 3_f64]));
generic_test_op!(
a,
DataType::Float64,
Expand All @@ -397,7 +397,7 @@ mod tests {

#[test]
fn variance_i32() -> Result<()> {
let a: ArrayRef = Arc::new(Int32Array::from_slice(vec![1, 2, 3, 4, 5]));
let a: ArrayRef = Arc::new(Int32Array::from_slice(&[1, 2, 3, 4, 5]));
generic_test_op!(
a,
DataType::Int32,
Expand All @@ -409,7 +409,7 @@ mod tests {

#[test]
fn variance_u32() -> Result<()> {
let a: ArrayRef = Arc::new(UInt32Array::from_slice(vec![
let a: ArrayRef = Arc::new(UInt32Array::from_slice(&[
1_u32, 2_u32, 3_u32, 4_u32, 5_u32,
]));
generic_test_op!(
Expand All @@ -424,7 +424,7 @@ mod tests {
#[test]
fn variance_f32() -> Result<()> {
let a: ArrayRef =
Float32Vec::from_slice(vec![1_f32, 2_f32, 3_f32, 4_f32, 5_f32]).as_arc();
Float32Vec::from_slice(&[1_f32, 2_f32, 3_f32, 4_f32, 5_f32]).as_arc();
generic_test_op!(
a,
DataType::Float32,
Expand All @@ -447,7 +447,7 @@ mod tests {

#[test]
fn test_variance_1_input() -> Result<()> {
let a: ArrayRef = Arc::new(Float64Array::from_slice(vec![1_f64]));
let a: ArrayRef = Arc::new(Float64Array::from_slice(&[1_f64]));
let schema = Schema::new(vec![Field::new("a", DataType::Float64, false)]);
let batch = RecordBatch::try_new(Arc::new(schema.clone()), vec![a])?;

Expand Down
12 changes: 6 additions & 6 deletions datafusion/src/physical_plan/regex_expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ mod tests {
]);

let patterns = Utf8Array::<i32>::from_slice(&vec![r"x.*-(\d*)-.*"; 4]);
let flags = Utf8Array::<i32>::from_slice(vec!["i"; 4]);
let flags = Utf8Array::<i32>::from_slice(&["i"; 4]);

let result = regexp_matches(&array, &patterns, Some(&flags))?;

Expand All @@ -317,9 +317,9 @@ mod tests {

#[test]
fn test_case_sensitive_regexp_match() {
let values = StringArray::from_slice(vec!["abc"; 5]);
let values = StringArray::from_slice(&["abc"; 5]);
let patterns =
StringArray::from_slice(vec!["^(a)", "^(A)", "(b|d)", "(B|D)", "^(b|c)"]);
StringArray::from_slice(&["^(a)", "^(A)", "(b|d)", "(B|D)", "^(b|c)"]);
let expected = vec![
Some(vec![Some("a")]),
None,
Expand All @@ -337,10 +337,10 @@ mod tests {

#[test]
fn test_case_insensitive_regexp_match() {
let values = StringArray::from_slice(vec!["abc"; 5]);
let values = StringArray::from_slice(&["abc"; 5]);
let patterns =
StringArray::from_slice(vec!["^(a)", "^(A)", "(b|d)", "(B|D)", "^(b|c)"]);
let flags = StringArray::from_slice(vec!["i"; 5]);
StringArray::from_slice(&["^(a)", "^(A)", "(b|d)", "(B|D)", "^(b|c)"]);
let flags = StringArray::from_slice(&["i"; 5]);

let expected = vec![
Some(vec![Some("a")]),
Expand Down
2 changes: 1 addition & 1 deletion datafusion/src/physical_plan/repartition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ mod tests {
let runtime = Arc::new(RuntimeEnv::default());
let batch = RecordBatch::try_from_iter(vec![(
"a",
Arc::new(StringArray::from_slice(vec!["foo"])) as ArrayRef,
Arc::new(StringArray::from_slice(&["foo"])) as ArrayRef,
)])
.unwrap();
let partitioning = Partitioning::Hash(
Expand Down
12 changes: 6 additions & 6 deletions datafusion/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2631,7 +2631,7 @@ mod tests {
// Convert to length-2 array
let array = scalar.to_array_of_size(2);
let expected_vals = vec![
(field_a.clone(), Int32Vec::from_slice(vec![23, 23]).as_arc()),
(field_a.clone(), Int32Vec::from_slice(&[23, 23]).as_arc()),
(
field_b.clone(),
Arc::new(BooleanArray::from_slice(&vec![false, false])) as ArrayRef,
Expand All @@ -2645,8 +2645,8 @@ mod tests {
Arc::new(StructArray::from_data(
DataType::Struct(vec![field_e.clone(), field_f.clone()]),
vec![
Int16Vec::from_slice(vec![2, 2]).as_arc(),
Int64Vec::from_slice(vec![3, 3]).as_arc(),
Int16Vec::from_slice(&[2, 2]).as_arc(),
Int64Vec::from_slice(&[3, 3]).as_arc(),
],
None,
)) as ArrayRef,
Expand Down Expand Up @@ -2722,7 +2722,7 @@ mod tests {
let array: ArrayRef = ScalarValue::iter_to_array(scalars).unwrap();

let expected = Arc::new(struct_array_from(vec![
(field_a, Int32Vec::from_slice(vec![23, 7, -1000]).as_arc()),
(field_a, Int32Vec::from_slice(&[23, 7, -1000]).as_arc()),
(
field_b,
Arc::new(BooleanArray::from_slice(&vec![false, true, true])) as ArrayRef,
Expand All @@ -2737,8 +2737,8 @@ mod tests {
Arc::new(StructArray::from_data(
DataType::Struct(vec![field_e, field_f]),
vec![
Int16Vec::from_slice(vec![2, 4, 6]).as_arc(),
Int64Vec::from_slice(vec![3, 5, 7]).as_arc(),
Int16Vec::from_slice(&[2, 4, 6]).as_arc(),
Int64Vec::from_slice(&[3, 5, 7]).as_arc(),
],
None,
)) as ArrayRef,
Expand Down
4 changes: 2 additions & 2 deletions datafusion/tests/dataframe_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ fn create_test_table() -> Result<Arc<dyn DataFrame>> {
let batch = RecordBatch::try_new(
schema.clone(),
vec![
Arc::new(Utf8Array::<i32>::from_slice(vec![
Arc::new(Utf8Array::<i32>::from_slice(&[
"abcDEF",
"abc123",
"CBAdef",
"123AbcDef",
])),
Arc::new(Int32Array::from_slice(vec![1, 10, 10, 100])),
Arc::new(Int32Array::from_slice(&[1, 10, 10, 100])),
],
)?;

Expand Down

0 comments on commit 5ad5f7c

Please sign in to comment.