Write it into two Parquet files
| 76 | ARROW_ASSIGN_OR_RAISE(auto table, CreateTable()); |
| 77 | // Write it into two Parquet files |
| 78 | ARROW_ASSIGN_OR_RAISE(auto output, |
| 79 | filesystem->OpenOutputStream(base_path + "/data1.parquet")); |
| 80 | ARROW_RETURN_NOT_OK(parquet::arrow::WriteTable( |
| 81 | *table->Slice(0, 5), arrow::default_memory_pool(), output, /*chunk_size=*/2048)); |
| 82 | ARROW_ASSIGN_OR_RAISE(output, |
| 83 | filesystem->OpenOutputStream(base_path + "/data2.parquet")); |
| 84 | ARROW_RETURN_NOT_OK(parquet::arrow::WriteTable( |
| 85 | *table->Slice(5), arrow::default_memory_pool(), output, /*chunk_size=*/2048)); |
| 86 | return base_path; |
| 87 | } |
| 88 | // (Doc section: Reading Datasets) |
| 89 | |
| 90 | // (Doc section: Reading different file formats) |
| 91 | // Set up a dataset by writing two Feather files. |
| 92 | arrow::Result<std::string> CreateExampleFeatherDataset( |
| 93 | const std::shared_ptr<fs::FileSystem>& filesystem, const std::string& root_path) { |
| 94 | auto base_path = root_path + "/feather_dataset"; |
| 95 | ARROW_RETURN_NOT_OK(filesystem->CreateDir(base_path)); |
| 96 | // Create an Arrow Table |
| 97 | ARROW_ASSIGN_OR_RAISE(auto table, CreateTable()); |
| 98 | // Write it into two Feather files |
| 99 | ARROW_ASSIGN_OR_RAISE(auto output, |
| 100 | filesystem->OpenOutputStream(base_path + "/data1.feather")); |
| 101 | ARROW_ASSIGN_OR_RAISE(auto writer, |
| 102 | arrow::ipc::MakeFileWriter(output.get(), table->schema())); |
| 103 | ARROW_RETURN_NOT_OK(writer->WriteTable(*table->Slice(0, 5))); |
| 104 | ARROW_RETURN_NOT_OK(writer->Close()); |
| 105 | ARROW_ASSIGN_OR_RAISE(output, |
| 106 | filesystem->OpenOutputStream(base_path + "/data2.feather")); |
| 107 | ARROW_ASSIGN_OR_RAISE(writer, |
| 108 | arrow::ipc::MakeFileWriter(output.get(), table->schema())); |
| 109 | ARROW_RETURN_NOT_OK(writer->WriteTable(*table->Slice(5))); |
| 110 | ARROW_RETURN_NOT_OK(writer->Close()); |
| 111 | return base_path; |
| 112 | } |
| 113 | // (Doc section: Reading different file formats) |
| 114 | |
| 115 | // (Doc section: Reading and writing partitioned data) |
| 116 | // Set up a dataset by writing files with partitioning |
| 117 | arrow::Result<std::string> CreateExampleParquetHivePartitionedDataset( |
| 118 | const std::shared_ptr<fs::FileSystem>& filesystem, const std::string& root_path) { |
| 119 | auto base_path = root_path + "/parquet_dataset"; |
| 120 | ARROW_RETURN_NOT_OK(filesystem->CreateDir(base_path)); |
| 121 | // Create an Arrow Table |
| 122 | auto schema = arrow::schema( |
| 123 | {arrow::field("a", arrow::int64()), arrow::field("b", arrow::int64()), |
| 124 | arrow::field("c", arrow::int64()), arrow::field("part", arrow::utf8())}); |
| 125 | std::vector<std::shared_ptr<arrow::Array>> arrays(4); |
| 126 | arrow::NumericBuilder<arrow::Int64Type> builder; |
| 127 | ARROW_RETURN_NOT_OK(builder.AppendValues({0, 1, 2, 3, 4, 5, 6, 7, 8, 9})); |
| 128 | ARROW_RETURN_NOT_OK(builder.Finish(&arrays[0])); |
| 129 | builder.Reset(); |
| 130 | ARROW_RETURN_NOT_OK(builder.AppendValues({9, 8, 7, 6, 5, 4, 3, 2, 1, 0})); |
| 131 | ARROW_RETURN_NOT_OK(builder.Finish(&arrays[1])); |
| 132 | builder.Reset(); |
| 133 | ARROW_RETURN_NOT_OK(builder.AppendValues({1, 2, 1, 2, 1, 2, 1, 2, 1, 2})); |
| 134 | ARROW_RETURN_NOT_OK(builder.Finish(&arrays[2])); |
| 135 | arrow::StringBuilder string_builder; |
no test coverage detected