MCPcopy Index your code
hub / github.com/apache/orc / fillStringValues

Function fillStringValues

tools/src/CSVFileImport.cc:74–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74void 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
109void fillDoubleValues(const std::vector<std::string>& data, orc::ColumnVectorBatch* batch,
110 uint64_t numValues, uint64_t colIndex) {

Callers 1

mainFunction · 0.85

Calls 4

extractColumnFunction · 0.85
sizeMethod · 0.65
dataMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected