kou commented on code in PR #49070:
URL: https://github.com/apache/arrow/pull/49070#discussion_r2745181877


##########
cpp/src/arrow/csv/converter.h:
##########
@@ -57,6 +57,7 @@ class ARROW_EXPORT Converter {
   const ConvertOptions& options_;
   MemoryPool* pool_;
   std::shared_ptr<DataType> type_;
+  std::shared_ptr<void> trie_cache_;  // Opaque pointer to TrieCache

Review Comment:
   `TrieCache`'s destructor is still called with this, right?



##########
cpp/src/arrow/csv/converter.cc:
##########
@@ -105,31 +105,45 @@ Status PresizeBuilder(const BlockParser& parser, 
BuilderType* builder) {
   }
 }
 
+/////////////////////////////////////////////////////////////////////////
+// Shared Tries cache to avoid rebuilding them for each decoder instance
+
+struct TrieCache {
+  Trie null_trie;
+  Trie true_trie;
+  Trie false_trie;
+
+  static Result<std::shared_ptr<TrieCache>> Make(const ConvertOptions& 
options) {
+    auto cache = std::make_shared<TrieCache>();
+    RETURN_NOT_OK(InitializeTrie(options.null_values, &cache->null_trie));
+    RETURN_NOT_OK(InitializeTrie(options.true_values, &cache->true_trie));
+    RETURN_NOT_OK(InitializeTrie(options.false_values, &cache->false_trie));
+    return cache;
+  }
+};
+
 /////////////////////////////////////////////////////////////////////////
 // Per-type value decoders
 
 struct ValueDecoder {
   explicit ValueDecoder(const std::shared_ptr<DataType>& type,
-                        const ConvertOptions& options)
-      : type_(type), options_(options) {}
+                        const ConvertOptions& options, const TrieCache* 
trie_cache)
+      : type_(type), options_(options), trie_cache_(*trie_cache) {}

Review Comment:
   How about using `trie_cache_` as a pointer not a reference?



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