| 825 | } |
| 826 | |
| 827 | Status MakeDataView(const std::shared_ptr<Field>& out_field, |
| 828 | std::shared_ptr<ArrayData>* out) { |
| 829 | const auto& out_type = out_field->type(); |
| 830 | const auto out_layout = out_type->layout(); |
| 831 | |
| 832 | AdjustInputPointer(); |
| 833 | int64_t out_length = in_data_length; |
| 834 | int64_t out_offset = 0; |
| 835 | int64_t out_null_count; |
| 836 | |
| 837 | std::shared_ptr<ArrayData> dictionary; |
| 838 | if (out_type->id() == Type::DICTIONARY) { |
| 839 | ARROW_ASSIGN_OR_RAISE(dictionary, GetDictionaryView(*out_type)); |
| 840 | } |
| 841 | |
| 842 | // No type has a purely empty layout |
| 843 | DCHECK_GT(out_layout.buffers.size(), 0); |
| 844 | |
| 845 | std::vector<std::shared_ptr<Buffer>> out_buffers; |
| 846 | |
| 847 | // Process null bitmap |
| 848 | if (in_buffer_idx == 0 && out_layout.buffers[0].kind == DataTypeLayout::BITMAP) { |
| 849 | // Copy input null bitmap |
| 850 | RETURN_NOT_OK(CheckInputAvailable()); |
| 851 | const auto& in_data_item = in_data[in_layout_idx]; |
| 852 | if (!out_field->nullable() && in_data_item->GetNullCount() != 0) { |
| 853 | return InvalidView("nulls in input cannot be viewed as non-nullable"); |
| 854 | } |
| 855 | DCHECK_GT(in_data_item->buffers.size(), in_buffer_idx); |
| 856 | out_buffers.push_back(in_data_item->buffers[in_buffer_idx]); |
| 857 | out_length = in_data_item->length; |
| 858 | out_offset = in_data_item->offset; |
| 859 | out_null_count = in_data_item->null_count; |
| 860 | ++in_buffer_idx; |
| 861 | AdjustInputPointer(); |
| 862 | } else { |
| 863 | // No null bitmap in input, append no-nulls bitmap |
| 864 | out_buffers.push_back(nullptr); |
| 865 | if (out_type->id() == Type::NA) { |
| 866 | out_null_count = out_length; |
| 867 | } else { |
| 868 | out_null_count = 0; |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | // Process other buffers in output layout |
| 873 | for (size_t out_buffer_idx = 1; out_buffer_idx < out_layout.buffers.size(); |
| 874 | ++out_buffer_idx) { |
| 875 | const auto& out_spec = out_layout.buffers[out_buffer_idx]; |
| 876 | // If always-null buffer is expected, just construct it |
| 877 | if (out_spec.kind == DataTypeLayout::ALWAYS_NULL) { |
| 878 | out_buffers.push_back(nullptr); |
| 879 | continue; |
| 880 | } |
| 881 | |
| 882 | // If input buffer is null bitmap, try to ignore it |
| 883 | while (in_buffer_idx == 0) { |
| 884 | RETURN_NOT_OK(CheckInputAvailable()); |
no test coverage detected