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

Function MakeDictionaryFlat

cpp/src/arrow/ipc/test_common.cc:806–839  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

804}
805
806Status MakeDictionaryFlat(std::shared_ptr<RecordBatch>* out) {
807 const int64_t length = 6;
808
809 std::vector<bool> is_valid = {true, true, false, true, true, true};
810
811 auto dict_ty = utf8();
812 auto dict1 = ArrayFromJSON(dict_ty, "[\"foo\", \"bar\", \"baz\"]");
813 auto dict2 = ArrayFromJSON(dict_ty, "[\"foo\", \"bar\", \"baz\", \"qux\"]");
814
815 auto f0_type = arrow::dictionary(arrow::int32(), dict_ty);
816 auto f1_type = arrow::dictionary(arrow::int8(), dict_ty);
817 auto f2_type = arrow::dictionary(arrow::int32(), dict_ty);
818
819 std::shared_ptr<Array> indices0, indices1, indices2;
820 std::vector<int32_t> indices0_values = {1, 2, -1, 0, 2, 0};
821 std::vector<int8_t> indices1_values = {0, 0, 2, 2, 1, 1};
822 std::vector<int32_t> indices2_values = {3, 0, 2, 1, 0, 2};
823
824 ArrayFromVector<Int32Type, int32_t>(is_valid, indices0_values, &indices0);
825 ArrayFromVector<Int8Type, int8_t>(is_valid, indices1_values, &indices1);
826 ArrayFromVector<Int32Type, int32_t>(is_valid, indices2_values, &indices2);
827
828 auto a0 = std::make_shared<DictionaryArray>(f0_type, indices0, dict1);
829 auto a1 = std::make_shared<DictionaryArray>(f1_type, indices1, dict1);
830 auto a2 = std::make_shared<DictionaryArray>(f2_type, indices2, dict2);
831
832 // construct batch
833 auto schema = ::arrow::schema(
834 {field("dict1", f0_type), field("dict2", f1_type), field("dict3", f2_type)});
835
836 std::vector<std::shared_ptr<Array>> arrays = {a0, a1, a2};
837 *out = RecordBatch::Make(schema, length, arrays);
838 return Status::OK();
839}
840
841Status MakeNestedDictionary(std::shared_ptr<RecordBatch>* out) {
842 const int64_t length = 7;

Callers 2

TESTFunction · 0.85
TEST_PFunction · 0.85

Calls 6

ArrayFromJSONFunction · 0.85
schemaFunction · 0.70
dictionaryFunction · 0.50
fieldFunction · 0.50
MakeFunction · 0.50
OKFunction · 0.50

Tested by

no test coverage detected