liyafan82 commented on a change in pull request #7544: URL: https://github.com/apache/arrow/pull/7544#discussion_r448167615
########## File path: cpp/src/arrow/ipc/read_write_test.cc ########## @@ -1228,6 +1228,152 @@ TEST_P(TestFileFormat, RoundTrip) { TestZeroLengthRoundTrip(*GetParam(), options); } +Status MakeDictionaryBatch(std::shared_ptr<RecordBatch>* out) { + const int64_t length = 6; + + std::vector<bool> is_valid = {true, true, false, true, true, true}; + + auto dict_ty = utf8(); + + auto dict = ArrayFromJSON(dict_ty, "[\"foo\", \"bar\", \"baz\"]"); + + auto f0_type = arrow::dictionary(arrow::int32(), dict_ty); + auto f1_type = arrow::dictionary(arrow::int8(), dict_ty); + + std::shared_ptr<Array> indices0, indices1; + std::vector<int32_t> indices0_values = {1, 2, -1, 0, 2, 0}; + std::vector<int8_t> indices1_values = {0, 0, 2, 2, 1, 1}; + + ArrayFromVector<Int32Type, int32_t>(is_valid, indices0_values, &indices0); + ArrayFromVector<Int8Type, int8_t>(is_valid, indices1_values, &indices1); + + auto a0 = std::make_shared<DictionaryArray>(f0_type, indices0, dict); + auto a1 = std::make_shared<DictionaryArray>(f1_type, indices1, dict); + + // construct batch + auto schema = ::arrow::schema({field("dict1", f0_type), field("dict2", f1_type)}); + + *out = RecordBatch::Make(schema, length, {a0, a1}); + return Status::OK(); +} + +// A record batch writer implementation that supports manually specifying dictionaries. +class TestRecordBatchWriter : public RecordBatchWriter { Review comment: You are right. This is not a RecordBatchWriter, as it performs both read and write. I have renamed it to DictionaryBatchHelper, and make it no longer inherit from RecordBatchWriter. ---------------------------------------------------------------- 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: us...@infra.apache.org