@@ -62,27 +62,27 @@ Status WriteTable(std::shared_ptr<::arrow::Array> data,
6262 return WriteTableInner (*writer, data);
6363}
6464
65- Status ReadTable (std::optional<std:: shared_ptr<::arrow::Array>>* out,
65+ Status ReadTable (std::shared_ptr<::arrow::Array>& out,
6666 const ReaderOptions& reader_options) {
6767 ICEBERG_ASSIGN_OR_RAISE (
6868 auto reader, ReaderFactoryRegistry::Open (FileFormatType::kParquet , reader_options));
6969 ICEBERG_ASSIGN_OR_RAISE (auto read_data, reader->Next ());
7070
7171 if (!read_data.has_value ()) {
72- * out = std:: nullopt ;
72+ out = nullptr ;
7373 return {};
7474 }
7575 auto arrow_c_array = read_data.value ();
7676
7777 ArrowSchema arrow_schema;
7878 ICEBERG_RETURN_UNEXPECTED (ToArrowSchema (*reader_options.projection , &arrow_schema));
79- ICEBERG_ARROW_ASSIGN_OR_RETURN (* out,
79+ ICEBERG_ARROW_ASSIGN_OR_RETURN (out,
8080 ::arrow::ImportArray (&arrow_c_array, &arrow_schema));
8181 return {};
8282}
8383
8484void DoRoundtrip (std::shared_ptr<::arrow::Array> data, std::shared_ptr<Schema> schema,
85- std::shared_ptr<::arrow::Array>* out) {
85+ std::shared_ptr<::arrow::Array>& out) {
8686 std::shared_ptr<FileIO> file_io = arrow::ArrowFileSystemFileIO::MakeMockFileIO ();
8787 const std::string basePath = " base.parquet" ;
8888
@@ -93,15 +93,13 @@ void DoRoundtrip(std::shared_ptr<::arrow::Array> data, std::shared_ptr<Schema> s
9393 auto writer = std::move (writer_data.value ());
9494 ASSERT_THAT (WriteTableInner (*writer, data), IsOk ());
9595
96- std::optional<std::shared_ptr<::arrow::Array>> out_array;
97- ASSERT_THAT (ReadTable (&out_array, {.path = basePath,
98- .length = writer->length (),
99- .io = file_io,
100- .projection = schema}),
96+ ASSERT_THAT (ReadTable (out, {.path = basePath,
97+ .length = writer->length (),
98+ .io = file_io,
99+ .projection = schema}),
101100 IsOk ());
102101
103- ASSERT_TRUE (out_array.has_value ()) << " Reader.Next() returned no data" ;
104- *out = std::move (out_array.value ());
102+ ASSERT_TRUE (out != nullptr ) << " Reader.Next() returned no data" ;
105103}
106104
107105} // namespace
@@ -334,7 +332,7 @@ TEST_F(ParquetReadWrite, SimpleStructRoundTrip) {
334332 .ValueOrDie();
335333
336334 std::shared_ptr<::arrow::Array> out;
337- DoRoundtrip (array, schema, & out);
335+ DoRoundtrip (array, schema, out);
338336
339337 ASSERT_TRUE (out->Equals (*array));
340338}
@@ -362,7 +360,7 @@ TEST_F(ParquetReadWrite, SimpleTypeRoundTrip) {
362360 .ValueOrDie();
363361
364362 std::shared_ptr<::arrow::Array> out;
365- DoRoundtrip (array, schema, & out);
363+ DoRoundtrip (array, schema, out);
366364
367365 ASSERT_TRUE (out->Equals (*array));
368366}
0 commit comments