You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by md...@apache.org on 2018/05/30 00:39:24 UTC
orc git commit: ORC-368: [C++] Reader must return default version
0.11 instead of error for missing version values
Repository: orc
Updated Branches:
refs/heads/master b1e77d483 -> 187a618c3
ORC-368: [C++] Reader must return default version 0.11 instead of error for missing version values
Fixes #274
Signed-off-by: Deepak Majeti <md...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/orc/repo
Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/187a618c
Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/187a618c
Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/187a618c
Branch: refs/heads/master
Commit: 187a618c315d8666d270f7642ba18bc059f8b1c5
Parents: b1e77d4
Author: zherui cao <zh...@hpe.com>
Authored: Fri May 25 11:30:22 2018 -0400
Committer: Deepak Majeti <md...@apache.org>
Committed: Tue May 29 20:38:59 2018 -0400
----------------------------------------------------------------------
c++/include/orc/Common.hh | 3 +++
c++/src/Common.cc | 10 ++++++++++
c++/src/Reader.cc | 2 +-
c++/src/Writer.cc | 2 +-
examples/orc_no_format.orc | Bin 0 -> 745 bytes
tools/test/TestFileMetadata.cc | 32 ++++++++++++++++++++++++++++++++
6 files changed, 47 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/orc/blob/187a618c/c++/include/orc/Common.hh
----------------------------------------------------------------------
diff --git a/c++/include/orc/Common.hh b/c++/include/orc/Common.hh
index b23d019..9bfa82d 100644
--- a/c++/include/orc/Common.hh
+++ b/c++/include/orc/Common.hh
@@ -32,6 +32,9 @@ namespace orc {
uint32_t majorVersion;
uint32_t minorVersion;
public:
+ static const FileVersion& v_0_11();
+ static const FileVersion& v_0_12();
+
FileVersion(uint32_t major, uint32_t minor) :
majorVersion(major), minorVersion(minor) {
}
http://git-wip-us.apache.org/repos/asf/orc/blob/187a618c/c++/src/Common.cc
----------------------------------------------------------------------
diff --git a/c++/src/Common.cc b/c++/src/Common.cc
index 0542188..0a5256e 100644
--- a/c++/src/Common.cc
+++ b/c++/src/Common.cc
@@ -109,4 +109,14 @@ namespace orc {
ss << getMajor() << '.' << getMinor();
return ss.str();
}
+
+ const FileVersion& FileVersion::v_0_11(){
+ static FileVersion version(0,11);
+ return version;
+ }
+
+ const FileVersion& FileVersion::v_0_12(){
+ static FileVersion version(0,12);
+ return version;
+ }
}
http://git-wip-us.apache.org/repos/asf/orc/blob/187a618c/c++/src/Reader.cc
----------------------------------------------------------------------
diff --git a/c++/src/Reader.cc b/c++/src/Reader.cc
index 6db8008..776f4d8 100644
--- a/c++/src/Reader.cc
+++ b/c++/src/Reader.cc
@@ -406,7 +406,7 @@ namespace orc {
FileVersion ReaderImpl::getFormatVersion() const {
if (contents->postscript->version_size() != 2) {
- throw std::logic_error("Unrecognized file version.");
+ return FileVersion::v_0_11();
}
return FileVersion(
contents->postscript->version(0),
http://git-wip-us.apache.org/repos/asf/orc/blob/187a618c/c++/src/Writer.cc
----------------------------------------------------------------------
diff --git a/c++/src/Writer.cc b/c++/src/Writer.cc
index 016ce35..16c2af4 100644
--- a/c++/src/Writer.cc
+++ b/c++/src/Writer.cc
@@ -40,7 +40,7 @@ namespace orc {
bool enableIndex;
WriterOptionsPrivate() :
- fileVersion(0, 11) { // default to Hive_0_11
+ fileVersion(FileVersion::v_0_11()) { // default to Hive_0_11
stripeSize = 64 * 1024 * 1024; // 64M
compressionBlockSize = 64 * 1024; // 64K
rowIndexStride = 10000;
http://git-wip-us.apache.org/repos/asf/orc/blob/187a618c/examples/orc_no_format.orc
----------------------------------------------------------------------
diff --git a/examples/orc_no_format.orc b/examples/orc_no_format.orc
new file mode 100644
index 0000000..3efb93a
Binary files /dev/null and b/examples/orc_no_format.orc differ
http://git-wip-us.apache.org/repos/asf/orc/blob/187a618c/tools/test/TestFileMetadata.cc
----------------------------------------------------------------------
diff --git a/tools/test/TestFileMetadata.cc b/tools/test/TestFileMetadata.cc
index ec962e5..45d6d5b 100644
--- a/tools/test/TestFileMetadata.cc
+++ b/tools/test/TestFileMetadata.cc
@@ -205,3 +205,35 @@ TEST (TestFileMetadata, testJson) {
EXPECT_EQ("", error);
}
+
+
+TEST (TestFileMetadata, testNoFormat) {
+ const std::string pgm = findProgram("tools/src/orc-metadata");
+ const std::string file = findExample("orc_no_format.orc");
+ const std::string expected =
+ "{ \"name\": \"" + file + "\",\n"
+ " \"type\": \"struct<_col0:array<string>,_col1:map<int,string>,_col2:struct<name:string,score:int>>\",\n"
+ " \"rows\": 5,\n"
+ " \"stripe count\": 1,\n"
+ " \"format\": \"0.11\", \"writer version\": \"original\",\n"
+ " \"compression\": \"zlib\", \"compression block\": 262144,\n"
+ " \"file length\": 745,\n"
+ " \"content\": 525, \"stripe stats\": 0, \"footer\": 210, \"postscript\": 9,\n"
+ " \"row index stride\": 10000,\n"
+ " \"user metadata\": {\n"
+ " },\n"
+ " \"stripes\": [\n"
+ " { \"stripe\": 0, \"rows\": 5,\n"
+ " \"offset\": 3, \"length\": 522,\n"
+ " \"index\": 224, \"data\": 187, \"footer\": 111\n"
+ " }\n"
+ " ]\n"
+ "}\n";
+
+ std::string output;
+ std::string error;
+ std::cout << expected;
+ EXPECT_EQ(0, runProgram({pgm, file}, output, error));
+ EXPECT_EQ(expected, output);
+ EXPECT_EQ("", error);
+}