You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "JackDrogon (via GitHub)" <gi...@apache.org> on 2025/07/28 13:56:10 UTC

[PR] feat(bindings/cpp): enhance Metadata API with comprehensive feature a… [opendal]

JackDrogon opened a new pull request, #6445:
URL: https://github.com/apache/opendal/pull/6445

   Enhance Metadata API with comprehensive feature alignment
   
   - Align C++ Metadata struct with Rust implementation for full feature parity
   - Add missing fields: content_encoding, version, is_current, is_deleted
   - Implement comprehensive accessor methods with detailed documentation
   - Add extensive BDD-style test suite with 20 test cases covering:
     * File and directory metadata behavior
     * HTTP headers and optional fields handling
     * Versioning information and deletion status
     * API consistency and object lifecycle
     * Timestamp behavior and edge cases
     * Error handling and robustness testing
   - Update FFI layer with OptionalBool type for proper type mapping
   - Enhance type conversion between Rust and C++ representations
   - Maintain backward compatibility while extending functionality
   


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(bindings/cpp): enhance Metadata API with comprehensive feature a… [opendal]

Posted by "JackDrogon (via GitHub)" <gi...@apache.org>.
JackDrogon commented on PR #6445:
URL: https://github.com/apache/opendal/pull/6445#issuecomment-3127364048

   @Xuanwo @deadlinefen 


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(bindings/cpp): enhance Metadata API with comprehensive feature a… [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #6445:
URL: https://github.com/apache/opendal/pull/6445#discussion_r2239458832


##########
bindings/cpp/include/data_structure.hpp:
##########
@@ -39,17 +39,143 @@ enum class EntryMode : int {
 /**
  * @struct Metadata
  * @brief The metadata of a file or directory
+ *
+ * Metadata contains all the information related to a specific path.
+ * Depending on the context of the requests, the metadata for the same path may
+ * vary. For example, two versions of the same path might have different content
+ * lengths. Keep in mind that metadata is always tied to the given context and
+ * is not a global state.
  */
 class Metadata {
  public:
+  // Basic file information
   EntryMode type;
   std::uint64_t content_length;
-  std::optional<std::string> cache_control;
-  std::optional<std::string> content_disposition;
-  std::optional<std::string> content_md5;
-  std::optional<std::string> content_type;
-  std::optional<std::string> etag;
-  std::optional<std::chrono::system_clock::time_point> last_modified;
+
+  // HTTP-style headers
+  std::optional<std::string>
+      cache_control;  ///< Cache-Control header as defined by RFC 7234
+  std::optional<std::string>
+      content_disposition;  ///< Content-Disposition header as defined by RFC
+                            ///< 6266
+  std::optional<std::string>
+      content_md5;  ///< Content-MD5 hash (deprecated but widely used)
+  std::optional<std::string>
+      content_type;  ///< Content-Type header as defined by RFC 9110
+  std::optional<std::string>
+      content_encoding;  ///< Content-Encoding header as defined by RFC 7231
+  std::optional<std::string> etag;  ///< ETag header as defined by RFC 7232
+  std::optional<std::chrono::system_clock::time_point>
+      last_modified;  ///< Last-Modified timestamp
+
+  // Versioning information
+  std::optional<std::string>
+      version;                     ///< Version identifier (e.g., S3 version ID)
+  std::optional<bool> is_current;  ///< Whether this is the current version
+  bool is_deleted;  ///< Whether this entry has been marked as deleted
+
+  // Default constructor
+  Metadata() : content_length(0), is_deleted(false) {}

Review Comment:
   `type` must be set during constructor.



-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(bindings/cpp): enhance Metadata API with comprehensive feature a… [opendal]

Posted by "JackDrogon (via GitHub)" <gi...@apache.org>.
JackDrogon commented on code in PR #6445:
URL: https://github.com/apache/opendal/pull/6445#discussion_r2239600605


##########
bindings/cpp/include/data_structure.hpp:
##########
@@ -39,17 +39,143 @@ enum class EntryMode : int {
 /**
  * @struct Metadata
  * @brief The metadata of a file or directory
+ *
+ * Metadata contains all the information related to a specific path.
+ * Depending on the context of the requests, the metadata for the same path may
+ * vary. For example, two versions of the same path might have different content
+ * lengths. Keep in mind that metadata is always tied to the given context and
+ * is not a global state.
  */
 class Metadata {
  public:
+  // Basic file information
   EntryMode type;
   std::uint64_t content_length;
-  std::optional<std::string> cache_control;
-  std::optional<std::string> content_disposition;
-  std::optional<std::string> content_md5;
-  std::optional<std::string> content_type;
-  std::optional<std::string> etag;
-  std::optional<std::chrono::system_clock::time_point> last_modified;
+
+  // HTTP-style headers
+  std::optional<std::string>
+      cache_control;  ///< Cache-Control header as defined by RFC 7234
+  std::optional<std::string>
+      content_disposition;  ///< Content-Disposition header as defined by RFC
+                            ///< 6266
+  std::optional<std::string>
+      content_md5;  ///< Content-MD5 hash (deprecated but widely used)
+  std::optional<std::string>
+      content_type;  ///< Content-Type header as defined by RFC 9110
+  std::optional<std::string>
+      content_encoding;  ///< Content-Encoding header as defined by RFC 7231
+  std::optional<std::string> etag;  ///< ETag header as defined by RFC 7232
+  std::optional<std::chrono::system_clock::time_point>
+      last_modified;  ///< Last-Modified timestamp
+
+  // Versioning information
+  std::optional<std::string>
+      version;                     ///< Version identifier (e.g., S3 version ID)
+  std::optional<bool> is_current;  ///< Whether this is the current version
+  bool is_deleted;  ///< Whether this entry has been marked as deleted
+
+  // Default constructor
+  Metadata() : content_length(0), is_deleted(false) {}

Review Comment:
   had used cpp11 default init style to refactor it



-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(bindings/cpp): enhance Metadata API with comprehensive feature a… [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #6445:
URL: https://github.com/apache/opendal/pull/6445


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org