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

Function fillDateValues

tools/src/CSVFileImport.cc:194–217  ·  view source on GitHub ↗

parse date string from format YYYY-mm-dd

Source from the content-addressed store, hash-verified

192
193// parse date string from format YYYY-mm-dd
194void fillDateValues(const std::vector<std::string>& data, orc::ColumnVectorBatch* batch,
195 uint64_t numValues, uint64_t colIndex) {
196 orc::LongVectorBatch* longBatch = dynamic_cast<orc::LongVectorBatch*>(batch);
197 bool hasNull = false;
198 for (uint64_t i = 0; i < numValues; ++i) {
199 std::string col = extractColumn(data[i], colIndex);
200 if (col.empty()) {
201 batch->notNull[i] = 0;
202 hasNull = true;
203 } else {
204 batch->notNull[i] = 1;
205 struct tm tm;
206 memset(&tm, 0, sizeof(struct tm));
207 strptime(col.c_str(), "%Y-%m-%d", &tm);
208 time_t t = mktime(&tm);
209 time_t t1970 = 0;
210 double seconds = difftime(t, t1970);
211 int64_t days = static_cast<int64_t>(seconds / (60 * 60 * 24));
212 longBatch->data[i] = days;
213 }
214 }
215 longBatch->hasNulls = hasNull;
216 longBatch->numElements = numValues;
217}
218
219// parse timestamp values in seconds
220void fillTimestampValues(const std::vector<std::string>& data, orc::ColumnVectorBatch* batch,

Callers 1

mainFunction · 0.85

Calls 2

extractColumnFunction · 0.85
strptimeFunction · 0.85

Tested by

no test coverage detected