84 if (msg.dataArrays.size() == 1) {
85 auto dataArray = msg.dataArrays.begin()->second;
86 if (dataArray.data.item.idx() == 0) {
88 for (
auto i = 0; i < avroArray.values.size(); ++i) {
89 values[i] = avroArray.values[i];
92 else if (dataArray.data.item.idx() == 1) {
94 for (
auto i = 0; i < avroArray.values.size(); ++i) {
95 values[i] = avroArray.values[i];
98 else if (dataArray.data.item.idx() == 2) {
100 for (
auto i = 0; i < avroArray.values.size(); ++i) {
101 values[i] = avroArray.values[i];
104 else if (dataArray.data.item.idx() == 3) {
106 for (
auto i = 0; i < avroArray.values.size(); ++i) {
107 values[i] = avroArray.values[i];
110 else if (dataArray.data.item.idx() == 4) {
112 for (
auto i = 0; i < avroArray.values.size(); ++i) {
113 values[i] = avroArray.values[i];
124 else if (dataArray.data.item.idx() == 6) {
125 std::string& avroValues = dataArray.data.item.get_bytes();
126 for (
auto i = 0; i < avroValues.size(); ++i) {
127 values[i] = avroValues[i];
132 throw std::range_error(
"These handlers can only work with a single DataArray in GetDataArraysResponse");
137 for (
const auto& receivedKeyValue : msg.dataSubarrays) {
138 std::string receivedKey = receivedKeyValue.first;
139 auto iterator = dataSubarrays.find(receivedKey);
140 if (iterator == dataSubarrays.end()) {
141 throw std::invalid_argument(
"The data sub array has not been registered.");
144 auto dataArray = receivedKeyValue.second;
145 size_t dataArrayValueCount = iterator->second.counts[0];
146 for (
int dimIndex = 1; dimIndex < iterator->second.counts.size(); ++dimIndex) {
147 dataArrayValueCount *= iterator->second.counts[dimIndex];
149 auto currentStarts = iterator->second.starts;
151 size_t subarrayOffset = 0;
152 while (subarrayOffset < dataArrayValueCount) {
154 size_t arrayOffset = currentStarts.back();
155 for (int64_t dimIndex = iterator->second.counts.size() - 2; dimIndex >= 0; --dimIndex) {
156 size_t multiplier = iterator->second.counts[dimIndex + 1];
157 for (
size_t dimIndex2 = dimIndex + 2; dimIndex2 < iterator->second.counts.size(); ++dimIndex2) {
158 multiplier *= iterator->second.counts[dimIndex2];
160 arrayOffset += currentStarts[dimIndex] * multiplier;
164 if (dataArray.data.item.idx() == 0) {
166 for (
auto i = 0; i < iterator->second.counts.back(); ++i) {
167 values[i + arrayOffset] = avroArray.values[i + subarrayOffset];
170 else if (dataArray.data.item.idx() == 1) {
172 for (
auto i = 0; i < iterator->second.counts.back(); ++i) {
173 values[i + arrayOffset] = avroArray.values[i + subarrayOffset];
176 else if (dataArray.data.item.idx() == 2) {
178 for (
auto i = 0; i < iterator->second.counts.back(); ++i) {
179 values[i + arrayOffset] = avroArray.values[i + subarrayOffset];
182 else if (dataArray.data.item.idx() == 3) {
184 for (
auto i = 0; i < iterator->second.counts.back(); ++i) {
185 values[i + arrayOffset] = avroArray.values[i + subarrayOffset];
188 else if (dataArray.data.item.idx() == 4) {
190 for (
auto i = 0; i < iterator->second.counts.back(); ++i) {
191 values[i + arrayOffset] = avroArray.values[i + subarrayOffset];
202 else if (dataArray.data.item.idx() == 6) {
203 std::string& avroValues = dataArray.data.item.get_bytes();
204 for (
auto i = 0; i < iterator->second.counts.back(); ++i) {
205 values[i + arrayOffset] = avroValues[i + subarrayOffset];
210 for (int64_t dimIndex = iterator->second.counts.size() - 2; dimIndex >= 0; --dimIndex) {
211 if (currentStarts[dimIndex] + 1 < iterator->second.starts[dimIndex] + iterator->second.counts[dimIndex]) {
212 ++currentStarts[dimIndex];
216 currentStarts[dimIndex] = iterator->second.starts[dimIndex];
220 subarrayOffset += iterator->second.counts.back();