pitrou commented on code in PR #51286:
URL: https://github.com/apache/arrow/pull/51286#discussion_r4410558804


##########
cpp/src/arrow/csv/lexing_internal.h:
##########
@@ -61,6 +64,58 @@ decltype(auto) DispatchBool(Fn&& fn, Rest... rest)
   }
 }
 
+inline std::string_view GetDelimiter(const ParseOptions& options) {
+  if (!options.delimiter_string.empty()) {
+    return options.delimiter_string;
+  }
+  return {&options.delimiter, 1};
+}
+
+inline char GetDelimiterFirstByte(const ParseOptions& options) {
+  if (!options.delimiter_string.empty()) {
+    return options.delimiter_string.front();
+  }
+  return options.delimiter;
+}
+
+class StreamingDelimiterMatcher {
+ public:
+  explicit StreamingDelimiterMatcher(std::string_view delimiter) : 
delimiter_(delimiter) {
+    DCHECK(!delimiter_.empty());
+  }
+
+  bool Consume(char c) {
+    if (c == delimiter_[matched_]) {
+      matched_++;
+      if (matched_ == delimiter_.size()) {
+        matched_ = 0;
+        return true;
+      }
+      return false;
+    }
+
+    const std::string_view delimiter(delimiter_);
+    for (size_t length = matched_; length > 0; --length) {
+      if (c == delimiter[length - 1] &&
+          delimiter.substr(0, length - 1) ==
+              delimiter.substr(matched_ - (length - 1), length - 1)) {

Review Comment:
   Fair enough.



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