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

Function MakeRunEndEncoded

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

Source from the content-addressed store, hash-verified

641} // namespace
642
643Status MakeRunEndEncoded(std::shared_ptr<RecordBatch>* out) {
644 const int64_t logical_length = 10000;
645 const int64_t slice_offset = 2000;
646 random::RandomArrayGenerator rand(/*seed =*/1);
647 std::vector<std::shared_ptr<Array>> all_arrays;
648 std::vector<std::shared_ptr<Field>> all_fields;
649 for (const bool sliced : {false, true}) {
650 const int64_t generate_length =
651 sliced ? logical_length + 2 * slice_offset : logical_length;
652
653 std::vector<std::shared_ptr<Array>> arrays = {
654 rand.RunEndEncoded(int32(), generate_length, 0.5),
655 rand.RunEndEncoded(int32(), generate_length, 0),
656 rand.RunEndEncoded(utf8(), generate_length, 0.5),
657 rand.RunEndEncoded(list(int32()), generate_length, 0.5),
658 };
659 std::vector<std::shared_ptr<Field>> fields = {
660 field("ree_int32", run_end_encoded(int32(), int32())),
661 field("ree_int32_not_null", run_end_encoded(int32(), int32()), false),
662 field("ree_string", run_end_encoded(int32(), utf8())),
663 field("ree_list", run_end_encoded(int32(), list(int32()))),
664 };
665
666 if (sliced) {
667 for (auto& array : arrays) {
668 ARROW_RETURN_NOT_OK(
669 AddArtificialOffsetInChildArray(array->data().get(), slice_offset));
670 array = array->Slice(slice_offset, logical_length);
671 }
672 for (auto& item : fields) {
673 item = field(item->name() + "_sliced", item->type(), item->nullable(),
674 item->metadata());
675 }
676 }
677
678 all_arrays.insert(all_arrays.end(), arrays.begin(), arrays.end());
679 all_fields.insert(all_fields.end(), fields.begin(), fields.end());
680 }
681 *out = RecordBatch::Make(schema(all_fields), logical_length, all_arrays);
682 return Status::OK();
683}
684
685Status MakeUnion(std::shared_ptr<RecordBatch>* out) {
686 // Define schema

Callers 1

BatchesFunction · 0.85

Calls 15

listFunction · 0.85
run_end_encodedFunction · 0.85
RunEndEncodedMethod · 0.80
nullableMethod · 0.80
schemaFunction · 0.70
fieldFunction · 0.50
MakeFunction · 0.50
OKFunction · 0.50
getMethod · 0.45
dataMethod · 0.45
SliceMethod · 0.45

Tested by

no test coverage detected