@@ -398,7 +398,6 @@ impl<'a> MutableArrayData<'a> {
398
398
}
399
399
}
400
400
401
- /*
402
401
#[ cfg( test) ]
403
402
mod tests {
404
403
use std:: { convert:: TryFrom , sync:: Arc } ;
@@ -424,8 +423,7 @@ mod tests {
424
423
#[ test]
425
424
fn test_primitive ( ) {
426
425
let b = UInt8Array :: from ( vec ! [ Some ( 1 ) , Some ( 2 ) , Some ( 3 ) ] ) ;
427
- let b = b.data();
428
- let arrays = vec![b];
426
+ let arrays = vec ! [ b. data( ) ] ;
429
427
let mut a = MutableArrayData :: new ( arrays, false , 3 ) ;
430
428
a. extend ( 0 , 0 , 2 ) ;
431
429
let result = a. freeze ( ) ;
@@ -439,8 +437,7 @@ mod tests {
439
437
fn test_primitive_offset ( ) {
440
438
let b = UInt8Array :: from ( vec ! [ Some ( 1 ) , Some ( 2 ) , Some ( 3 ) ] ) ;
441
439
let b = b. slice ( 1 , 2 ) ;
442
- let b = b.data();
443
- let arrays = vec![b];
440
+ let arrays = vec ! [ b. data( ) ] ;
444
441
let mut a = MutableArrayData :: new ( arrays, false , 2 ) ;
445
442
a. extend ( 0 , 0 , 2 ) ;
446
443
let result = a. freeze ( ) ;
@@ -453,8 +450,8 @@ mod tests {
453
450
#[ test]
454
451
fn test_primitive_null_offset ( ) {
455
452
let b = UInt8Array :: from ( vec ! [ Some ( 1 ) , None , Some ( 3 ) ] ) ;
456
- let b = b.slice(1, 2).data() ;
457
- let arrays = vec![b];
453
+ let b = b. slice ( 1 , 2 ) ;
454
+ let arrays = vec ! [ b. data ( ) ] ;
458
455
let mut a = MutableArrayData :: new ( arrays, false , 2 ) ;
459
456
a. extend ( 0 , 0 , 2 ) ;
460
457
let result = a. freeze ( ) ;
@@ -466,8 +463,8 @@ mod tests {
466
463
#[ test]
467
464
fn test_primitive_null_offset_nulls ( ) {
468
465
let b = UInt8Array :: from ( vec ! [ Some ( 1 ) , Some ( 2 ) , Some ( 3 ) ] ) ;
469
- let b = b.slice(1, 2).data() ;
470
- let arrays = vec![b];
466
+ let b = b. slice ( 1 , 2 ) ;
467
+ let arrays = vec ! [ b. data ( ) ] ;
471
468
let mut a = MutableArrayData :: new ( arrays, true , 2 ) ;
472
469
a. extend ( 0 , 0 , 2 ) ;
473
470
a. extend_nulls ( 3 ) ;
@@ -489,8 +486,8 @@ mod tests {
489
486
builder. append ( true ) ?;
490
487
builder. values ( ) . append_slice ( & [ 6 , 7 , 8 ] ) ?;
491
488
builder. append ( true ) ?;
492
- let array = builder.finish().data() ;
493
- let arrays = vec![array];
489
+ let array = builder. finish ( ) ;
490
+ let arrays = vec ! [ array. data ( ) ] ;
494
491
495
492
let mut mutable = MutableArrayData :: new ( arrays, false , 0 ) ;
496
493
mutable. extend ( 0 , 0 , 1 ) ;
@@ -512,9 +509,8 @@ mod tests {
512
509
/// tests extending from a variable-sized (strings and binary) array w/ offset with nulls
513
510
#[ test]
514
511
fn test_variable_sized_nulls ( ) {
515
- let array =
516
- StringArray::from(vec![Some("a"), Some("bc"), None, Some("defh")]).data();
517
- let arrays = vec![array];
512
+ let array = StringArray :: from ( vec ! [ Some ( "a" ) , Some ( "bc" ) , None , Some ( "defh" ) ] ) ;
513
+ let arrays = vec ! [ array. data( ) ] ;
518
514
519
515
let mut mutable = MutableArrayData :: new ( arrays, false , 0 ) ;
520
516
@@ -531,11 +527,10 @@ mod tests {
531
527
/// with an offset and nulls
532
528
#[ test]
533
529
fn test_variable_sized_offsets ( ) {
534
- let array =
535
- StringArray::from(vec![Some("a"), Some("bc"), None, Some("defh")]).data();
530
+ let array = StringArray :: from ( vec ! [ Some ( "a" ) , Some ( "bc" ) , None , Some ( "defh" ) ] ) ;
536
531
let array = array. slice ( 1 , 3 ) ;
537
532
538
- let arrays = vec![& array];
533
+ let arrays = vec ! [ array. data ( ) ] ;
539
534
540
535
let mut mutable = MutableArrayData :: new ( arrays, false , 0 ) ;
541
536
@@ -550,11 +545,10 @@ mod tests {
550
545
551
546
#[ test]
552
547
fn test_string_offsets ( ) {
553
- let array =
554
- StringArray::from(vec![Some("a"), Some("bc"), None, Some("defh")]).data();
548
+ let array = StringArray :: from ( vec ! [ Some ( "a" ) , Some ( "bc" ) , None , Some ( "defh" ) ] ) ;
555
549
let array = array. slice ( 1 , 3 ) ;
556
550
557
- let arrays = vec![& array];
551
+ let arrays = vec ! [ array. data ( ) ] ;
558
552
559
553
let mut mutable = MutableArrayData :: new ( arrays, false , 0 ) ;
560
554
@@ -569,10 +563,10 @@ mod tests {
569
563
570
564
#[ test]
571
565
fn test_multiple_with_nulls ( ) {
572
- let array1 = StringArray::from(vec!["hello", "world"]).data() ;
573
- let array2 = StringArray::from(vec![Some("1"), None]).data() ;
566
+ let array1 = StringArray :: from ( vec ! [ "hello" , "world" ] ) ;
567
+ let array2 = StringArray :: from ( vec ! [ Some ( "1" ) , None ] ) ;
574
568
575
- let arrays = vec![array1, array2];
569
+ let arrays = vec ! [ array1. data ( ) , array2. data ( ) ] ;
576
570
577
571
let mut mutable = MutableArrayData :: new ( arrays, false , 5 ) ;
578
572
@@ -589,11 +583,10 @@ mod tests {
589
583
590
584
#[ test]
591
585
fn test_string_null_offset_nulls ( ) {
592
- let array =
593
- StringArray::from(vec![Some("a"), Some("bc"), None, Some("defh")]).data();
586
+ let array = StringArray :: from ( vec ! [ Some ( "a" ) , Some ( "bc" ) , None , Some ( "defh" ) ] ) ;
594
587
let array = array. slice ( 1 , 3 ) ;
595
588
596
- let arrays = vec![& array];
589
+ let arrays = vec ! [ array. data ( ) ] ;
597
590
598
591
let mut mutable = MutableArrayData :: new ( arrays, true , 0 ) ;
599
592
@@ -609,9 +602,8 @@ mod tests {
609
602
610
603
#[ test]
611
604
fn test_bool ( ) {
612
- let array =
613
- BooleanArray::from(vec![Some(false), Some(true), None, Some(false)]).data();
614
- let arrays = vec![array];
605
+ let array = BooleanArray :: from ( vec ! [ Some ( false ) , Some ( true ) , None , Some ( false ) ] ) ;
606
+ let arrays = vec ! [ array. data( ) ] ;
615
607
616
608
let mut mutable = MutableArrayData :: new ( arrays, false , 0 ) ;
617
609
@@ -626,9 +618,9 @@ mod tests {
626
618
627
619
#[ test]
628
620
fn test_null ( ) {
629
- let array1 = NullArray::new(10).data() ;
630
- let array2 = NullArray::new(5).data() ;
631
- let arrays = vec![array1, array2];
621
+ let array1 = NullArray :: new ( 10 ) ;
622
+ let array2 = NullArray :: new ( 5 ) ;
623
+ let arrays = vec ! [ array1. data ( ) , array2. data ( ) ] ;
632
624
633
625
let mut mutable = MutableArrayData :: new ( arrays, false , 0 ) ;
634
626
@@ -698,9 +690,8 @@ mod tests {
698
690
699
691
let array =
700
692
StructArray :: try_from ( vec ! [ ( "f1" , strings. clone( ) ) , ( "f2" , ints. clone( ) ) ] )
701
- .unwrap()
702
- .data();
703
- let arrays = vec![array];
693
+ . unwrap ( ) ;
694
+ let arrays = vec ! [ array. data( ) ] ;
704
695
let mut mutable = MutableArrayData :: new ( arrays, false , 0 ) ;
705
696
706
697
mutable. extend ( 0 , 1 , 3 ) ;
@@ -735,14 +726,13 @@ mod tests {
735
726
let array =
736
727
StructArray :: try_from ( vec ! [ ( "f1" , strings. clone( ) ) , ( "f2" , ints. clone( ) ) ] )
737
728
. unwrap ( )
738
- .slice(1, 3)
739
- .data();
740
- let arrays = vec![array.as_ref()];
729
+ . slice ( 1 , 3 ) ;
730
+ let arrays = vec ! [ array. data( ) ] ;
741
731
let mut mutable = MutableArrayData :: new ( arrays, false , 0 ) ;
742
732
743
733
mutable. extend ( 0 , 1 , 3 ) ;
744
734
let data = mutable. freeze ( ) ;
745
- let array = StructArray::from(Arc::new( data) );
735
+ let array = StructArray :: from ( data) ;
746
736
747
737
let expected_strings: ArrayRef =
748
738
Arc :: new ( StringArray :: from ( vec ! [ None , Some ( "mark" ) ] ) ) ;
@@ -774,9 +764,8 @@ mod tests {
774
764
775
765
let array =
776
766
StructArray :: try_from ( vec ! [ ( "f1" , strings. clone( ) ) , ( "f2" , ints. clone( ) ) ] )
777
- .unwrap()
778
- .data();
779
- let arrays = vec![array];
767
+ . unwrap ( ) ;
768
+ let arrays = vec ! [ array. data( ) ] ;
780
769
781
770
let mut mutable = MutableArrayData :: new ( arrays, false , 0 ) ;
782
771
@@ -812,9 +801,8 @@ mod tests {
812
801
813
802
let array =
814
803
StructArray :: try_from ( vec ! [ ( "f1" , strings. clone( ) ) , ( "f2" , ints. clone( ) ) ] )
815
- .unwrap()
816
- .data();
817
- let arrays = vec![array, array];
804
+ . unwrap ( ) ;
805
+ let arrays = vec ! [ array. data( ) , array. data( ) ] ;
818
806
let mut mutable = MutableArrayData :: new ( arrays, false , 0 ) ;
819
807
820
808
mutable. extend ( 0 , 1 , 3 ) ;
@@ -838,12 +826,11 @@ mod tests {
838
826
let array = FixedSizeBinaryArray :: try_from_iter (
839
827
vec ! [ vec![ 0 , 0 ] , vec![ 0 , 1 ] , vec![ 0 , 2 ] ] . into_iter ( ) ,
840
828
)
841
- .expect("Failed to create FixedSizeBinaryArray from iterable")
842
- .data();
829
+ . expect ( "Failed to create FixedSizeBinaryArray from iterable" ) ;
843
830
let array = array. slice ( 1 , 2 ) ;
844
831
// = [[0, 1], [0, 2]] due to the offset = 1
845
832
846
- let arrays = vec![& array];
833
+ let arrays = vec ! [ array. data ( ) ] ;
847
834
848
835
let mut mutable = MutableArrayData :: new ( arrays, false , 0 ) ;
849
836
@@ -869,7 +856,7 @@ mod tests {
869
856
builder. values ( ) . append_slice ( & [ 6 , 7 , 8 ] ) ?;
870
857
builder. values ( ) . append_slice ( & [ 9 , 10 , 11 ] ) ?;
871
858
builder. append ( true ) ?;
872
- let a = builder.finish().data() ;
859
+ let a = builder. finish ( ) ;
873
860
874
861
let a_builder = Int64Builder :: new ( 24 ) ;
875
862
let mut a_builder = ListBuilder :: < Int64Builder > :: new ( a_builder) ;
@@ -880,10 +867,10 @@ mod tests {
880
867
a_builder. append ( true ) ?;
881
868
let b = a_builder. finish ( ) ;
882
869
883
- let b = b.data();
884
870
let c = b. slice ( 1 , 2 ) ;
885
871
886
- let mut mutable = MutableArrayData::new(vec![a, b, &c], false, 1);
872
+ let mut mutable =
873
+ MutableArrayData :: new ( vec ! [ a. data( ) , b. data( ) , c. data( ) ] , false , 1 ) ;
887
874
mutable. extend ( 0 , 0 , a. len ( ) ) ;
888
875
mutable. extend ( 1 , 0 , b. len ( ) ) ;
889
876
mutable. extend ( 2 , 0 , c. len ( ) ) ;
@@ -1016,7 +1003,7 @@ mod tests {
1016
1003
builder. values ( ) . append_value ( "Arrow" ) ?;
1017
1004
builder. values ( ) . append_null ( ) ?;
1018
1005
builder. append ( true ) ?;
1019
- let a = builder.finish().data() ;
1006
+ let a = builder. finish ( ) ;
1020
1007
1021
1008
// [["alpha", "beta"], [None], ["gamma", "delta", None]]
1022
1009
let mut builder = ListBuilder :: new ( StringBuilder :: new ( 32 ) ) ;
@@ -1029,9 +1016,9 @@ mod tests {
1029
1016
builder. values ( ) . append_value ( "delta" ) ?;
1030
1017
builder. values ( ) . append_null ( ) ?;
1031
1018
builder. append ( true ) ?;
1032
- let b = builder.finish().data() ;
1019
+ let b = builder. finish ( ) ;
1033
1020
1034
- let mut mutable = MutableArrayData::new(vec![a, b], false, 10);
1021
+ let mut mutable = MutableArrayData :: new ( vec ! [ a. data ( ) , b. data ( ) ] , false , 10 ) ;
1035
1022
1036
1023
mutable. extend ( 0 , 0 , a. len ( ) ) ;
1037
1024
mutable. extend ( 1 , 0 , b. len ( ) ) ;
@@ -1082,8 +1069,7 @@ mod tests {
1082
1069
fn test_fixed_size_binary_append ( ) {
1083
1070
let a = vec ! [ Some ( vec![ 1 , 2 ] ) , Some ( vec![ 3 , 4 ] ) , Some ( vec![ 5 , 6 ] ) ] ;
1084
1071
let a = FixedSizeBinaryArray :: try_from_sparse_iter ( a. into_iter ( ) )
1085
- .expect("Failed to create FixedSizeBinaryArray from iterable")
1086
- .data();
1072
+ . expect ( "Failed to create FixedSizeBinaryArray from iterable" ) ;
1087
1073
1088
1074
let b = vec ! [
1089
1075
None ,
@@ -1094,10 +1080,9 @@ mod tests {
1094
1080
None ,
1095
1081
] ;
1096
1082
let b = FixedSizeBinaryArray :: try_from_sparse_iter ( b. into_iter ( ) )
1097
- .expect("Failed to create FixedSizeBinaryArray from iterable")
1098
- .data();
1083
+ . expect ( "Failed to create FixedSizeBinaryArray from iterable" ) ;
1099
1084
1100
- let mut mutable = MutableArrayData::new(vec![a, b], false, 10);
1085
+ let mut mutable = MutableArrayData :: new ( vec ! [ a. data ( ) , b. data ( ) ] , false , 10 ) ;
1101
1086
1102
1087
mutable. extend ( 0 , 0 , a. len ( ) ) ;
1103
1088
mutable. extend ( 1 , 0 , b. len ( ) ) ;
@@ -1127,9 +1112,8 @@ mod tests {
1127
1112
// b[4..4]
1128
1113
] ;
1129
1114
let expected = FixedSizeBinaryArray :: try_from_sparse_iter ( expected. into_iter ( ) )
1130
- .expect("Failed to create FixedSizeBinaryArray from iterable")
1131
- .data();
1132
- assert_eq!(&result, expected.as_ref());
1115
+ . expect ( "Failed to create FixedSizeBinaryArray from iterable" ) ;
1116
+ assert_eq ! ( & result, expected. data( ) ) ;
1133
1117
}
1134
1118
1135
1119
/*
@@ -1220,4 +1204,3 @@ mod tests {
1220
1204
}
1221
1205
*/
1222
1206
}
1223
- */
0 commit comments