bkietz commented on code in PR #39067:
URL: https://github.com/apache/arrow/pull/39067#discussion_r1506239410


##########
cpp/examples/arrow/filesystem_definition_example.cc:
##########
@@ -0,0 +1,150 @@
+// 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 <arrow/filesystem/filesystem.h>
+#include <arrow/io/memory.h>
+#include <arrow/result.h>
+#include <arrow/util/uri.h>
+
+// Demonstrate registering a user-defined Arrow FileSystem outside
+// of the Arrow source tree.
+
+using arrow::Result;
+using arrow::Status;
+namespace io = arrow::io;
+namespace fs = arrow::fs;
+
+class ExampleFileSystem : public fs::FileSystem {
+ public:
+  explicit ExampleFileSystem(const io::IOContext& io_context)
+      : fs::FileSystem{io_context} {}
+
+  // This is a mock filesystem whose root directory contains a single file.
+  // All operations which would mutate will simply raise an error.
+  static constexpr std::string_view kPath = "example_file";
+  static constexpr std::string_view kContents = "hello world";
+  static fs::FileInfo info() {
+    fs::FileInfo info;
+    info.set_path(std::string{kPath});
+    info.set_type(fs::FileType::File);
+    info.set_size(kContents.size());
+    return info;
+  }
+
+  static Status DoesntExist(std::string_view path) {
+    return Status::IOError("Path does not exist '", path, "'");
+  }
+
+  static Status NoMutation() {
+    return Status::IOError("operations which would mutate are not permitted");

Review Comment:
   Simply because this example filesystem is read-only, so mutating it seemed 
more like an IO error than something which would be implemented later



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to