MCPcopy Create free account
hub / github.com/apache/arrow / WriteToMmap

Method WriteToMmap

cpp/src/arrow/ipc/read_write_test.cc:1056–1088  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 11

MakeRandomInt32ArrayFunction · 0.85
listFunction · 0.85
MakeRandomListArrayFunction · 0.85
strMethod · 0.80
schemaFunction · 0.70
ARROW_ASSIGN_OR_RAISEFunction · 0.70
WriteRecordBatchFunction · 0.70
fieldFunction · 0.50
MakeFunction · 0.50
DefaultsFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected