orc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject orc git commit: ORC-356: Fix C09Adaper.cc (as Adaptor.cc)
Date Tue, 01 May 2018 22:08:42 GMT
Repository: orc
Updated Branches:
  refs/heads/master 45b9c5082 -> 6eccd4721


ORC-356: Fix C09Adaper.cc (as Adaptor.cc)

Fixes #261

Signed-off-by: Owen O'Malley <omalley@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/orc/repo
Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/6eccd472
Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/6eccd472
Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/6eccd472

Branch: refs/heads/master
Commit: 6eccd472122252499d8757634adaaa89be00a051
Parents: 45b9c50
Author: rip-nsk <rip.nsk@gmail.com>
Authored: Tue May 1 10:32:04 2018 -0700
Committer: Owen O'Malley <omalley@apache.org>
Committed: Tue May 1 15:08:12 2018 -0700

----------------------------------------------------------------------
 c++/src/Adaptor.cc       | 43 +++++++++++++++++++++++++++++++++++++++++++
 c++/src/Adaptor.hh.in    |  5 +++++
 c++/src/C09Adapter.cc    | 28 ----------------------------
 c++/src/CMakeLists.txt   | 10 ++++++++++
 c++/test/TestTimezone.cc |  5 ++---
 5 files changed, 60 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/orc/blob/6eccd472/c++/src/Adaptor.cc
----------------------------------------------------------------------
diff --git a/c++/src/Adaptor.cc b/c++/src/Adaptor.cc
new file mode 100644
index 0000000..9c0a74c
--- /dev/null
+++ b/c++/src/Adaptor.cc
@@ -0,0 +1,43 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include "Adaptor.hh"
+#include <sstream>
+#include <iomanip>
+
+#ifndef HAS_STOLL
+namespace std {
+  int64_t std::stoll(std::string str) {
+    int64_t val = 0;
+    stringstream ss;
+    ss << str;
+    ss >> val;
+    return val;
+  }
+}
+#endif
+
+#ifndef HAS_STRPTIME
+char* strptime(const char* s, const char* f, struct tm* tm) {
+  std::istringstream input(s);
+  input.imbue(std::locale(setlocale(LC_ALL, nullptr)));
+  input >> std::get_time(tm, f);
+  if (input.fail()) return nullptr;
+  return (char*)(s + input.tellg());
+}
+#endif

http://git-wip-us.apache.org/repos/asf/orc/blob/6eccd472/c++/src/Adaptor.hh.in
----------------------------------------------------------------------
diff --git a/c++/src/Adaptor.hh.in b/c++/src/Adaptor.hh.in
index 5d9ea15..5fefa3f 100644
--- a/c++/src/Adaptor.hh.in
+++ b/c++/src/Adaptor.hh.in
@@ -21,6 +21,7 @@
 
 #cmakedefine INT64_IS_LL
 #cmakedefine HAS_PREAD
+#cmakedefine HAS_STRPTIME
 #cmakedefine HAS_STOLL
 #cmakedefine HAS_DIAGNOSTIC_PUSH
 #cmakedefine HAS_PRE_1970
@@ -40,6 +41,10 @@
   }
 #endif
 
+#ifndef HAS_STRPTIME
+  char* strptime(const char* buf, const char* format, struct tm* tm);
+#endif
+
 #ifndef HAS_PREAD
   ssize_t pread(int fd, void *buf, size_t count, off_t offset);
 #endif

http://git-wip-us.apache.org/repos/asf/orc/blob/6eccd472/c++/src/C09Adapter.cc
----------------------------------------------------------------------
diff --git a/c++/src/C09Adapter.cc b/c++/src/C09Adapter.cc
deleted file mode 100644
index 8afc752..0000000
--- a/c++/src/C09Adapter.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "orc/C09Adapter.hh"
-#include <sstream>
-
-int64_t std::stoll(std::string str) {
-  int64_t val = 0;
-  stringstream ss ;
-  ss << str ;
-  ss >> val ;
-  return val;
-}

http://git-wip-us.apache.org/repos/asf/orc/blob/6eccd472/c++/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt
index 8254574..695a0ae 100644
--- a/c++/src/CMakeLists.txt
+++ b/c++/src/CMakeLists.txt
@@ -26,6 +26,15 @@ CHECK_CXX_SOURCE_COMPILES("
 )
 
 CHECK_CXX_SOURCE_COMPILES("
+    #include<time.h>
+    int main(int,char*[]){
+      struct tm time2020;
+      return !strptime(\"2020-02-02 12:34:56\", \"%Y-%m-%d %H:%M:%S\", &time2020);
+    }"
+  HAS_STRPTIME
+)
+
+CHECK_CXX_SOURCE_COMPILES("
     #include<string>
     int main(int,char* argv[]){
       return static_cast<int>(std::stoll(argv[0]));
@@ -156,6 +165,7 @@ set(SOURCE_FILES
   io/InputStream.cc
   io/OutputStream.cc
   wrap/orc-proto-wrapper.cc
+  Adaptor.cc
   ByteRLE.cc
   ColumnPrinter.cc
   ColumnReader.cc

http://git-wip-us.apache.org/repos/asf/orc/blob/6eccd472/c++/test/TestTimezone.cc
----------------------------------------------------------------------
diff --git a/c++/test/TestTimezone.cc b/c++/test/TestTimezone.cc
index 88415cc..f690786 100644
--- a/c++/test/TestTimezone.cc
+++ b/c++/test/TestTimezone.cc
@@ -21,7 +21,6 @@
 #include "wrap/gtest-wrapper.h"
 
 #include <iostream>
-#include <unistd.h>
 #include <vector>
 
 namespace orc {
@@ -123,7 +122,7 @@ namespace orc {
   const std::string& getZoneFromRule(FutureRule *rule,
                                      const std::string& date) {
     tm timeStruct;
-    if (strptime(date.c_str(), "%F %H:%M:%S", &timeStruct) == nullptr) {
+    if (strptime(date.c_str(), "%Y-%m-%d %H:%M:%S", &timeStruct) == nullptr) {
       throw TimezoneError("bad time " + date);
     }
     return rule->getVariant(timegm(&timeStruct)).name;
@@ -319,7 +318,7 @@ namespace orc {
   const std::string& getVariantFromZone(const Timezone& zone,
                                         const std::string& date) {
     tm timeStruct;
-    if (strptime(date.c_str(), "%F %H:%M:%S", &timeStruct) == nullptr) {
+    if (strptime(date.c_str(), "%Y-%m-%d %H:%M:%S", &timeStruct) == nullptr) {
       throw TimezoneError("bad time " + date);
     }
     return zone.getVariant(timegm(&timeStruct)).name;


Mime
View raw message