Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me implement gather method in this question. I hope you do not repost the solution from the previous answer in Chegg because they

Please help me implement gather method in this question. I hope you do not repost the solution from the previous answer in Chegg because they are not complete and does not implement the gather method.

Thank you very much. I really appreciate your help.

Question:

image text in transcribedimage text in transcribed

image text in transcribedThis is all necessary method for this question:

image text in transcribedimage text in transcribed

Language: C++ Autocomplete Ready O ? 1. NullableArray Gather You are given a templated class NullableArray which is used to represent a 1D array of data whose values can possibly be null. Null values are represented using a least-significant bit (LSB) ordered bitmap where a set bit (1) represents a valid value and an unset bit (0) represents a null value. NullableArray has two members: data which is a vector of type T to hold the values, and nulls which is a vector of type uint8_t to hold the bitmap. 1 > #include 47 template 48 class NullableArray { 49 public: 50 std::vector data; 51 std::vector nulls; 52 53 // Implement the gather method here 54 }; 55 56 57 58 > template ... The problem you are asked to solve is to implement a gather method for the NullableArray class. This method is expected to take a vector of type uint32_t to use as the gather map and returns a new NullableArray of the same type as the calling NullableArray, In the input NullableArray and Gather Map: The data vector's values are undefined when the NullableArray value is null based on the null bitmap The null bitmap's additional bits are undefined when not corresponding to values in the data vector Values in the gather map will never be larger than the size of the input NullableArray In the output NullableArray: The data vector's values should be set to o wherever the output values are null The null bitmap is required to be the minimum size necessary to indicate the corresponding null values The null bitmap is required to have any additional bits not corresponding to values in the data vector be unset (0) For example: Given an input NullableArray and Gather Map: data: {1, 2, 3, 4} nulls: {11} //00001011 gather_map: {, 2, , 3, 1} The expected output NullableArray would be: data: (1, 0, 1, 4, 2} nulls: (29) 1/00011101 template void print_nullable_array(const NullableArray& input) { std::cout (EOF)); std::pair, std::vector> input-pair = read_input_data[int32_t>(input_data); const NullableArray my_nullable_array = std::move(input_pair.first); const std::vector gather_map = std::move (input_pair.second); auto output_array = my_nullable_array.gather(gather_map]); std::cout(output_array); return @; v template std::pair, std::vector> read input_data(const std::string& input_string) { std::pair, std::vector cuint32_t>> output; output.first.data = std::move(read_vector(input_string)); std::string::size_type data_end - input_string.find("}"); auto split_string = input_string.substr(data_end + 2); output.first.nulls = std::move(read_vectorsuint8_t> (split_string)); std::string: :size_type nulls_end = input_string.find("}", data_end + 2); split_string = input_string.substr(nulls_end + 2); output. second = std::move (read_vector(split_string)); return output; } +

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago