You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by om...@apache.org on 2018/05/01 18:04:02 UTC
orc git commit: ORC-353. Change C++ CSV reader to handle formatted
timestamps.
Repository: orc
Updated Branches:
refs/heads/master 65330dd77 -> a03ddd188
ORC-353. Change C++ CSV reader to handle formatted timestamps.
Fixes #258
Signed-off-by: Owen O'Malley <om...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/orc/repo
Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/a03ddd18
Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/a03ddd18
Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/a03ddd18
Branch: refs/heads/master
Commit: a03ddd1887f989ad12f25431e0fc7260e1e002da
Parents: 65330dd
Author: Owen O'Malley <om...@apache.org>
Authored: Fri Apr 27 15:07:05 2018 -0700
Committer: Owen O'Malley <om...@apache.org>
Committed: Tue May 1 11:03:42 2018 -0700
----------------------------------------------------------------------
tools/src/CSVFileImport.cc | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/orc/blob/a03ddd18/tools/src/CSVFileImport.cc
----------------------------------------------------------------------
diff --git a/tools/src/CSVFileImport.cc b/tools/src/CSVFileImport.cc
index 2901636..a08a655 100644
--- a/tools/src/CSVFileImport.cc
+++ b/tools/src/CSVFileImport.cc
@@ -234,7 +234,7 @@ void fillTimestampValues(const std::vector<std::string>& data,
orc::ColumnVectorBatch* batch,
uint64_t numValues,
uint64_t colIndex) {
- const orc::Timezone& localTZ = orc::getLocalTimezone();
+ struct tm timeStruct;
orc::TimestampVectorBatch* tsBatch =
dynamic_cast<orc::TimestampVectorBatch*>(batch);
bool hasNull = false;
@@ -244,10 +244,21 @@ void fillTimestampValues(const std::vector<std::string>& data,
batch->notNull[i] = 0;
hasNull = true;
} else {
- batch->notNull[i] = 1;
- // data is in local timezone
- tsBatch->data[i] = localTZ.convertToUTC(atoll(col.c_str()));
- tsBatch->nanoseconds[i] = 0;
+ memset(&timeStruct, 0, sizeof(timeStruct));
+ char *left=strptime(col.c_str(), "%Y-%m-%d %H:%M:%S", &timeStruct);
+ if (left == nullptr) {
+ batch->notNull[i] = 0;
+ } else {
+ batch->notNull[i] = 1;
+ tsBatch->data[i] = timegm(&timeStruct);
+ char *tail;
+ double d = strtod(left, &tail);
+ if (tail != left) {
+ tsBatch->nanoseconds[i] = static_cast<long>(d * 1000000000.0);
+ } else {
+ tsBatch->nanoseconds[i] = 0;
+ }
+ }
}
}
tsBatch->hasNulls = hasNull;