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 2020/07/12 16:22:02 UTC

[GitHub] [arrow] wesm commented on a change in pull request #7718: PARQUET-1882: Buffered Reads should allow for 0 length

wesm commented on a change in pull request #7718:
URL: https://github.com/apache/arrow/pull/7718#discussion_r453335961



##########
File path: cpp/src/parquet/file_serialize_test.cc
##########
@@ -398,6 +400,48 @@ TEST(TestBufferedRowGroupWriter, MultiPageDisabledDictionary) {
   }
 }
 
+TEST(Roundtrip, AllNulls) {
+  auto primitiveNode =
+      PrimitiveNode::Make("nulls", Repetition::OPTIONAL, nullptr, Type::INT32);
+  schema::NodeVector columns({primitiveNode});
+
+  auto rootNode = GroupNode::Make("root", Repetition::REQUIRED, columns, nullptr);
+
+  auto sink = CreateOutputStream();
+
+  auto fileWriter =
+      ParquetFileWriter::Open(sink, std::static_pointer_cast<GroupNode>(rootNode));
+  auto rowGroupWriter = fileWriter->AppendRowGroup();
+  auto columnWriter = static_cast<Int32Writer*>(rowGroupWriter->NextColumn());
+
+  int32_t values[3];
+  int16_t defLevels[] = {0, 0, 0};
+
+  columnWriter->WriteBatch(3, defLevels, nullptr, values);
+
+  columnWriter->Close();
+  rowGroupWriter->Close();
+  fileWriter->Close();
+
+  ReaderProperties props = default_reader_properties();
+  props.enable_buffered_stream();
+  PARQUET_ASSIGN_OR_THROW(auto buffer, sink->Finish());
+
+  auto source = std::make_shared<::arrow::io::BufferReader>(buffer);
+  auto file_reader = ParquetFileReader::Open(source);
+
+  auto fileReader = ParquetFileReader::Open(source, props);
+  auto rowGroupReader = fileReader->RowGroup(0);
+  auto columnReader = std::static_pointer_cast<Int32Reader>(rowGroupReader->Column(0));
+
+  int64_t valuesRead;
+  defLevels[0] = -1;
+  defLevels[1] = -1;
+  defLevels[2] = -1;
+  columnReader->ReadBatch(3, defLevels, nullptr, values, &valuesRead);
+  EXPECT_THAT(defLevels, ElementsAre(0, 0, 0));

Review comment:
       Should de-camel-case this test




----------------------------------------------------------------
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.

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