| 72 | } |
| 73 | |
| 74 | void fillStringValues(const std::vector<std::string>& data, orc::ColumnVectorBatch* batch, |
| 75 | uint64_t numValues, uint64_t colIndex, orc::DataBuffer<char>& buffer) { |
| 76 | uint64_t offset = 0; |
| 77 | orc::StringVectorBatch* stringBatch = dynamic_cast<orc::StringVectorBatch*>(batch); |
| 78 | bool hasNull = false; |
| 79 | for (uint64_t i = 0; i < numValues; ++i) { |
| 80 | std::string col = extractColumn(data[i], colIndex); |
| 81 | if (col.empty()) { |
| 82 | batch->notNull[i] = 0; |
| 83 | hasNull = true; |
| 84 | } else { |
| 85 | batch->notNull[i] = 1; |
| 86 | char* oldBufferAddress = buffer.data(); |
| 87 | // Resize the buffer in case buffer does not have remaining space to store the next string. |
| 88 | while (buffer.size() - offset < col.size()) { |
| 89 | buffer.resize(buffer.size() * 2); |
| 90 | } |
| 91 | char* newBufferAddress = buffer.data(); |
| 92 | // Refill stringBatch->data with the new addresses, if buffer's address has changed. |
| 93 | if (newBufferAddress != oldBufferAddress) { |
| 94 | for (uint64_t refillIndex = 0; refillIndex < i; ++refillIndex) { |
| 95 | stringBatch->data[refillIndex] = |
| 96 | stringBatch->data[refillIndex] - oldBufferAddress + newBufferAddress; |
| 97 | } |
| 98 | } |
| 99 | memcpy(buffer.data() + offset, col.c_str(), col.size()); |
| 100 | stringBatch->data[i] = buffer.data() + offset; |
| 101 | stringBatch->length[i] = static_cast<int64_t>(col.size()); |
| 102 | offset += col.size(); |
| 103 | } |
| 104 | } |
| 105 | stringBatch->hasNulls = hasNull; |
| 106 | stringBatch->numElements = numValues; |
| 107 | } |
| 108 | |
| 109 | void fillDoubleValues(const std::vector<std::string>& data, orc::ColumnVectorBatch* batch, |
| 110 | uint64_t numValues, uint64_t colIndex) { |
no test coverage detected