parse timestamp values in seconds
| 218 | |
| 219 | // parse timestamp values in seconds |
| 220 | void fillTimestampValues(const std::vector<std::string>& data, orc::ColumnVectorBatch* batch, |
| 221 | uint64_t numValues, uint64_t colIndex) { |
| 222 | struct tm timeStruct; |
| 223 | orc::TimestampVectorBatch* tsBatch = dynamic_cast<orc::TimestampVectorBatch*>(batch); |
| 224 | bool hasNull = false; |
| 225 | for (uint64_t i = 0; i < numValues; ++i) { |
| 226 | std::string col = extractColumn(data[i], colIndex); |
| 227 | if (col.empty()) { |
| 228 | batch->notNull[i] = 0; |
| 229 | hasNull = true; |
| 230 | } else { |
| 231 | memset(&timeStruct, 0, sizeof(timeStruct)); |
| 232 | char* left = strptime(col.c_str(), "%Y-%m-%d %H:%M:%S", &timeStruct); |
| 233 | if (left == nullptr) { |
| 234 | batch->notNull[i] = 0; |
| 235 | } else { |
| 236 | batch->notNull[i] = 1; |
| 237 | tsBatch->data[i] = timegm(&timeStruct); |
| 238 | char* tail; |
| 239 | double d = strtod(left, &tail); |
| 240 | if (tail != left) { |
| 241 | tsBatch->nanoseconds[i] = static_cast<long>(d * 1000000000.0); |
| 242 | } else { |
| 243 | tsBatch->nanoseconds[i] = 0; |
| 244 | } |
| 245 | } |
| 246 | } |
| 247 | } |
| 248 | tsBatch->hasNulls = hasNull; |
| 249 | tsBatch->numElements = numValues; |
| 250 | } |
| 251 | |
| 252 | void usage() { |
| 253 | std::cout << "Usage: csv-import [-h] [--help]\n" |
no test coverage detected