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

Function WriteMapBatch

cpp/src/arrow/adapters/orc/util.cc:768–810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

766}
767
768Status WriteMapBatch(const Array& array, int64_t orc_offset,
769 liborc::ColumnVectorBatch* column_vector_batch) {
770 const MapArray& map_array(checked_cast<const MapArray&>(array));
771 auto batch = checked_cast<liborc::MapVectorBatch*>(column_vector_batch);
772 liborc::ColumnVectorBatch* key_batch = (batch->keys).get();
773 liborc::ColumnVectorBatch* element_batch = (batch->elements).get();
774 std::shared_ptr<Array> key_array = map_array.keys();
775 std::shared_ptr<Array> element_array = map_array.items();
776 int64_t arrow_length = array.length();
777 int64_t running_arrow_offset = 0, running_orc_offset = orc_offset;
778 if (orc_offset == 0) {
779 batch->offsets[0] = 0;
780 }
781 if (array.null_count()) {
782 batch->hasNulls = true;
783 }
784 for (; running_arrow_offset < arrow_length;
785 running_orc_offset++, running_arrow_offset++) {
786 if (array.IsNull(running_arrow_offset)) {
787 batch->notNull[running_orc_offset] = false;
788 batch->offsets[running_orc_offset + 1] = batch->offsets[running_orc_offset];
789 } else {
790 batch->notNull[running_orc_offset] = true;
791 batch->offsets[running_orc_offset + 1] =
792 batch->offsets[running_orc_offset] +
793 map_array.value_offset(running_arrow_offset + 1) -
794 map_array.value_offset(running_arrow_offset);
795 int64_t subarray_arrow_offset = map_array.value_offset(running_arrow_offset),
796 subarray_orc_offset = batch->offsets[running_orc_offset],
797 new_subarray_orc_offset = batch->offsets[running_orc_offset + 1],
798 subarray_orc_length = new_subarray_orc_offset - subarray_orc_offset;
799 key_batch->resize(new_subarray_orc_offset);
800 element_batch->resize(new_subarray_orc_offset);
801 RETURN_NOT_OK(
802 WriteBatch(*(key_array->Slice(subarray_arrow_offset, subarray_orc_length)),
803 subarray_orc_offset, key_batch));
804 RETURN_NOT_OK(
805 WriteBatch(*(element_array->Slice(subarray_arrow_offset, subarray_orc_length)),
806 subarray_orc_offset, element_batch));
807 }
808 }
809 return Status::OK();
810}
811
812template <typename UnionArrayType>
813Status WriteUnionBatch(const Array& array, int64_t orc_offset,

Callers 1

WriteBatchFunction · 0.85

Calls 10

resizeMethod · 0.80
WriteBatchFunction · 0.70
OKFunction · 0.50
getMethod · 0.45
keysMethod · 0.45
lengthMethod · 0.45
null_countMethod · 0.45
IsNullMethod · 0.45
value_offsetMethod · 0.45
SliceMethod · 0.45

Tested by

no test coverage detected