ArianaVillegas commented on code in PR #12625:
URL: https://github.com/apache/arrow/pull/12625#discussion_r852464078


##########
cpp/src/arrow/filesystem/filesystem.h:
##########
@@ -122,18 +122,30 @@ ARROW_EXPORT std::ostream& operator<<(std::ostream& os, 
const FileInfo&);
 
 /// \brief File selector for filesystem APIs
 struct ARROW_EXPORT FileSelector {
-  /// The directory in which to select files.
-  /// If the path exists but doesn't point to a directory, this should be an 
error.
+  /// The path or glob in which to select files.
   std::string base_dir;
+  // Selector type of file selector
+  SelectorType type;
   /// The behavior if `base_dir` isn't found in the filesystem.  If false,
   /// an error is returned.  If true, an empty selection is returned.
   bool allow_not_found;
-  /// Whether to recurse into subdirectories.
-  bool recursive;
   /// The maximum number of subdirectories to recurse into.
   int32_t max_recursion;
 
-  FileSelector() : allow_not_found(false), recursive(false), 
max_recursion(INT32_MAX) {}
+  FileSelector()
+      : type(SelectorType::Directory), allow_not_found(false), 
max_recursion(0) {}
+
+  FileSelector(std::string base_dir, SelectorType type)
+      : base_dir(base_dir), type(type), allow_not_found(false), 
max_recursion(0) {}
+
+  bool recursive() const { return (type == SelectorType::Directory && 
max_recursion); }

Review Comment:
   I have a few questions, right now, we're not using that convention, but we 
could use it. Right now we are working only with '*' , but we can change it to 
'\*\*'. If we use '**' convention, do we want users to be able to specify the 
`max_recursion` or we assume we always have the maximum recursion? 
   
   If we keep only '*' and max_recursion, recursive function would be like 
this: 
   ```
   bool recursive() const { return ((type == SelectorType::Directory || (type 
== SelectorType::Glob && base_dir.back() == '*')) 
                                    && max_recursion); }
   ```



-- 
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