arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-779: [C++] Check for old metadata and raise exception if found
Date Mon, 10 Apr 2017 21:35:25 GMT
Repository: arrow
Updated Branches:
  refs/heads/master c2f28cd07 -> 06d92bbab


ARROW-779: [C++] Check for old metadata and raise exception if found

Author: Wes McKinney <wes.mckinney@twosigma.com>

Closes #507 from wesm/ARROW-779 and squashes the following commits:

dad42f7 [Wes McKinney] Check for old metadata and raise exception if found


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/06d92bba
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/06d92bba
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/06d92bba

Branch: refs/heads/master
Commit: 06d92bbab426d8b343d238e3e61166353da11877
Parents: c2f28cd
Author: Wes McKinney <wes.mckinney@twosigma.com>
Authored: Mon Apr 10 17:35:18 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Mon Apr 10 17:35:18 2017 -0400

----------------------------------------------------------------------
 cpp/src/arrow/ipc/metadata.cc | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/06d92bba/cpp/src/arrow/ipc/metadata.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/metadata.cc b/cpp/src/arrow/ipc/metadata.cc
index 84f8883..ee21156 100644
--- a/cpp/src/arrow/ipc/metadata.cc
+++ b/cpp/src/arrow/ipc/metadata.cc
@@ -50,7 +50,11 @@ using VectorLayoutOffset = flatbuffers::Offset<arrow::flatbuf::VectorLayout>;
 using Offset = flatbuffers::Offset<void>;
 using FBString = flatbuffers::Offset<flatbuffers::String>;
 
-static constexpr flatbuf::MetadataVersion kMetadataVersion = flatbuf::MetadataVersion_V3;
+static constexpr flatbuf::MetadataVersion kCurrentMetadataVersion =
+    flatbuf::MetadataVersion_V3;
+
+static constexpr flatbuf::MetadataVersion kMinMetadataVersion =
+    flatbuf::MetadataVersion_V3;
 
 static Status IntFromFlatbuffer(
     const flatbuf::Int* int_data, std::shared_ptr<DataType>* out) {
@@ -605,8 +609,8 @@ static Status WriteFlatbufferBuilder(FBB& fbb, std::shared_ptr<Buffer>*
out) {
 
 static Status WriteFBMessage(FBB& fbb, flatbuf::MessageHeader header_type,
     flatbuffers::Offset<void> header, int64_t body_length, std::shared_ptr<Buffer>*
out) {
-  auto message =
-      flatbuf::CreateMessage(fbb, kMetadataVersion, header_type, header, body_length);
+  auto message = flatbuf::CreateMessage(
+      fbb, kCurrentMetadataVersion, header_type, header, body_length);
   fbb.Finish(message);
   return WriteFlatbufferBuilder(fbb, out);
 }
@@ -738,7 +742,7 @@ Status WriteFileFooter(const Schema& schema, const std::vector<FileBlock>&
dicti
   auto fb_record_batches = FileBlocksToFlatbuffer(fbb, record_batches);
 
   auto footer = flatbuf::CreateFooter(
-      fbb, kMetadataVersion, fb_schema, fb_dictionaries, fb_record_batches);
+      fbb, kCurrentMetadataVersion, fb_schema, fb_dictionaries, fb_record_batches);
 
   fbb.Finish(footer);
 
@@ -814,7 +818,11 @@ class Message::MessageImpl {
   Status Open() {
     message_ = flatbuf::GetMessage(buffer_->data() + offset_);
 
-    // TODO(wesm): verify the message
+    // Check that the metadata version is supported
+    if (message_->version() < kMinMetadataVersion) {
+      return Status::Invalid("Old metadata version not supported");
+    }
+
     return Status::OK();
   }
 


Mime
View raw message