Commit fa8d350 1 parent bca2f3a commit fa8d350 Copy full SHA for fa8d350
File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,26 @@ impl Row {
57
57
self . fields . len ( )
58
58
}
59
59
60
+ /// Move columns data out of the row. Useful to avoid internal data cloning.
61
+ ///
62
+ /// # Example
63
+ ///
64
+ /// ```no_run
65
+ /// use std::fs::File;
66
+ /// use parquet::record::Row;
67
+ /// use parquet::file::reader::{FileReader, SerializedFileReader};
68
+ ///
69
+ /// let file = File::open("/path/to/file").unwrap();
70
+ /// let reader = SerializedFileReader::new(file).unwrap();
71
+ /// let row: Row = reader.get_row_iter(None).unwrap().next().unwrap().unwrap();
72
+ /// let columns = row.into_columns();
73
+ /// println!("row columns: {:?}", columns);
74
+ ///
75
+ /// ```
76
+ pub fn into_columns ( self ) -> Vec < ( String , Field ) > {
77
+ self . fields
78
+ }
79
+
60
80
/// Get an iterator to go through all columns in the row.
61
81
///
62
82
/// # Example
Original file line number Diff line number Diff line change @@ -1280,6 +1280,21 @@ mod tests {
1280
1280
) ;
1281
1281
}
1282
1282
1283
+ #[ test]
1284
+ fn test_into_columns_in_row ( ) {
1285
+ let r = row ! [
1286
+ ( "a" . to_string( ) , Field :: Str ( "My string" . to_owned( ) ) ) ,
1287
+ ( "b" . to_string( ) , Field :: Int ( 1 ) )
1288
+ ] ;
1289
+ assert_eq ! (
1290
+ r. into_columns( ) ,
1291
+ vec![
1292
+ ( "a" . to_string( ) , Field :: Str ( "My string" . to_owned( ) ) ) ,
1293
+ ( "b" . to_string( ) , Field :: Int ( 1 ) ) ,
1294
+ ]
1295
+ ) ;
1296
+ }
1297
+
1283
1298
#[ test]
1284
1299
fn test_file_reader_rows_projection_map ( ) {
1285
1300
let schema = "
You can’t perform that action at this time.
0 commit comments