You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/21 23:08:48 UTC

[GitHub] [arrow-rs] alamb commented on a diff in pull request #3116: Cleanup parquet tests

alamb commented on code in PR #3116:
URL: https://github.com/apache/arrow-rs/pull/3116#discussion_r1028595367


##########
parquet/src/file/writer.rs:
##########
@@ -1212,16 +1231,19 @@ mod tests {
         for (i, item) in data.iter().enumerate().take(reader.num_row_groups()) {
             let row_group_reader = reader.get_row_group(i).unwrap();
             let iter = row_group_reader.get_row_iter(None).unwrap();
-            let res = iter
-                .map(|elem| elem.get_int(0).unwrap())
-                .collect::<Vec<i32>>();
+            let res: Vec<_> = iter.map(&value).collect();
             assert_eq!(res, *item);
         }
         file_metadata
     }
 
-    fn assert_send<T: Send>(t: T) -> T {

Review Comment:
   is this check covered elsewhere ? 



##########
parquet/src/file/writer.rs:
##########
@@ -1245,58 +1267,17 @@ mod tests {
     }
 
     fn test_bytes_roundtrip(data: Vec<Vec<i32>>) {
-        let mut buffer = vec![];
-
-        let schema = Arc::new(
-            types::Type::group_type_builder("schema")
-                .with_fields(&mut vec![Arc::new(
-                    types::Type::primitive_type_builder("col1", Type::INT32)
-                        .with_repetition(Repetition::REQUIRED)
-                        .build()
-                        .unwrap(),
-                )])
-                .build()
-                .unwrap(),
-        );
-
-        let mut rows: i64 = 0;
-        {
-            let props = Arc::new(WriterProperties::builder().build());
-            let mut writer =
-                SerializedFileWriter::new(&mut buffer, schema, props).unwrap();
-
-            for subset in &data {
-                let mut row_group_writer = writer.next_row_group().unwrap();
-                if let Some(mut writer) = row_group_writer.next_column().unwrap() {
-                    rows += writer
-                        .typed::<Int32Type>()
-                        .write_batch(&subset[..], None, None)
-                        .unwrap() as i64;
-
-                    writer.close().unwrap();
-                }
-                row_group_writer.close().unwrap();
-            }
-            writer.close().unwrap();
-        }
-
-        let reading_cursor = Bytes::from(buffer);
-        let reader = SerializedFileReader::new(reading_cursor).unwrap();
+        test_roundtrip_i32::<Vec<u8>, Bytes>(Vec::with_capacity(1024), data);
+    }
 
-        assert_eq!(reader.num_row_groups(), data.len());
-        assert_eq!(
-            reader.metadata().file_metadata().num_rows(),
-            rows,
-            "row count in metadata not equal to number of rows written"
+    #[test]
+    fn test_boolean_roundtrip() {
+        let my_bool_values: Vec<_> = (0..2049).map(|idx| idx % 2 == 0).collect();

Review Comment:
   I double checked that `2049` is the same size as `parquet/tests/boolean_writer.rs`



##########
parquet/tests/boolean_writer.rs:
##########
@@ -1,89 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use parquet::data_type::BoolType;
-use parquet::file::properties::WriterProperties;
-use parquet::file::reader::FileReader;
-use parquet::file::serialized_reader::SerializedFileReader;
-use parquet::file::writer::SerializedFileWriter;
-use parquet::schema::parser::parse_message_type;
-use std::fs;
-use std::path::Path;
-use std::sync::{mpsc, Arc};
-use std::thread;
-use std::time::Duration;
-
-#[test]
-fn it_writes_data_without_hanging() {
-    let path = Path::new("it_writes_data_without_hanging.parquet");
-
-    let message_type = "
-  message BooleanType {
-    REQUIRED BOOLEAN DIM0;
-  }
-";
-    let schema = Arc::new(parse_message_type(message_type).expect("parse schema"));
-    let props = Arc::new(WriterProperties::builder().build());
-    let file = fs::File::create(path).expect("create file");
-    let mut writer =
-        SerializedFileWriter::new(file, schema, props).expect("create parquet writer");
-    for _group in 0..1 {
-        let mut row_group_writer = writer.next_row_group().expect("get row group writer");
-        let values: Vec<i64> = vec![0; 2049];
-        let my_bool_values: Vec<bool> = values
-            .iter()
-            .enumerate()
-            .map(|(count, _x)| count % 2 == 0)
-            .collect();
-        while let Some(mut col_writer) =
-            row_group_writer.next_column().expect("next column")
-        {
-            col_writer
-                .typed::<BoolType>()
-                .write_batch(&my_bool_values, None, None)
-                .expect("writing bool column");
-
-            col_writer.close().expect("close column");
-        }
-        let rg_md = row_group_writer.close().expect("close row group");
-        println!("total rows written: {}", rg_md.num_rows());
-    }
-    writer.close().expect("close writer");
-
-    let bytes = fs::read(path).expect("read file");
-    assert_eq!(&bytes[0..4], &[b'P', b'A', b'R', b'1']);
-
-    // Now that we have written our data and are happy with it, make
-    // sure we can read it back in < 5 seconds...

Review Comment:
   🤯  not sure what this was all about



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org