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

Function WriteMapBatch

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

Source from the content-addressed store, hash-verified

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