| 1058 | void TearDown() { io::MemoryMapFixture::TearDown(); } |
| 1059 | |
| 1060 | Status WriteToMmap(int recursion_level, bool override_level, int32_t* metadata_length, |
| 1061 | int64_t* body_length, std::shared_ptr<RecordBatch>* batch, |
| 1062 | std::shared_ptr<Schema>* schema) { |
| 1063 | const int batch_length = 5; |
| 1064 | auto type = int32(); |
| 1065 | std::shared_ptr<Array> array; |
| 1066 | const bool include_nulls = true; |
| 1067 | RETURN_NOT_OK(MakeRandomInt32Array(1000, include_nulls, pool_, &array)); |
| 1068 | for (int i = 0; i < recursion_level; ++i) { |
| 1069 | type = list(type); |
| 1070 | RETURN_NOT_OK( |
| 1071 | MakeRandomListArray(array, batch_length, include_nulls, pool_, &array)); |
| 1072 | } |
| 1073 | |
| 1074 | auto f0 = field("f0", type); |
| 1075 | |
| 1076 | *schema = ::arrow::schema({f0}); |
| 1077 | |
| 1078 | *batch = RecordBatch::Make(*schema, batch_length, {array}); |
| 1079 | |
| 1080 | std::stringstream ss; |
| 1081 | ss << "test-write-past-max-recursion-" << g_file_number++; |
| 1082 | const int memory_map_size = 1 << 20; |
| 1083 | ARROW_ASSIGN_OR_RAISE( |
| 1084 | mmap_, io::MemoryMapFixture::InitMemoryMap(memory_map_size, TempFile(ss.str()))); |
| 1085 | |
| 1086 | auto options = IpcWriteOptions::Defaults(); |
| 1087 | if (override_level) { |
| 1088 | options.max_recursion_depth = recursion_level + 1; |
| 1089 | } |
| 1090 | return WriteRecordBatch(**batch, 0, mmap_.get(), metadata_length, body_length, |
| 1091 | options); |
| 1092 | } |
| 1093 | |
| 1094 | protected: |
| 1095 | std::shared_ptr<io::MemoryMappedFile> mmap_; |
nothing calls this directly
no test coverage detected