@@ -34,45 +34,42 @@ class ExpressionCacheKey {
3434 public:
3535 ExpressionCacheKey (SchemaPtr schema, std::shared_ptr<Configuration> configuration,
3636 ExpressionVector expression_vector, SelectionVector::Mode mode)
37- : schema_(schema), mode_(mode), uniquifier_ (0 ), configuration_(configuration) {
37+ : mode_(mode), uniqifier_ (0 ), configuration_(configuration) {
3838 static const int kSeedValue = 4 ;
3939 size_t result = kSeedValue ;
4040 for (auto & expr : expression_vector) {
41- std::string expr_as_string = expr->ToString ();
42- expressions_as_strings_ .push_back (expr_as_string );
43- arrow::internal::hash_combine (result, expr_as_string );
44- UpdateUniquifier (expr_as_string );
41+ std::string expr_cache_key_string = expr->ToCacheKeyString ();
42+ expressions_as_cache_key_strings_ .push_back (expr_cache_key_string );
43+ arrow::internal::hash_combine (result, expr_cache_key_string );
44+ UpdateUniqifier (expr_cache_key_string );
4545 }
4646 arrow::internal::hash_combine (result, static_cast <size_t >(mode));
4747 arrow::internal::hash_combine (result, configuration->Hash ());
48- arrow::internal::hash_combine (result, schema_->ToString ());
49- arrow::internal::hash_combine (result, uniquifier_);
48+ arrow::internal::hash_combine (result, uniqifier_);
5049 hash_code_ = result;
5150 }
5251
5352 ExpressionCacheKey (SchemaPtr schema, std::shared_ptr<Configuration> configuration,
5453 Expression& expression)
55- : schema_(schema),
56- mode_ (SelectionVector::MODE_NONE),
57- uniquifier_(0 ),
54+ :mode_(SelectionVector::MODE_NONE),
55+ uniqifier_ (0 ),
5856 configuration_(configuration) {
5957 static const int kSeedValue = 4 ;
6058 size_t result = kSeedValue ;
61- expressions_as_strings_ .push_back (expression.ToString ());
62- UpdateUniquifier (expression.ToString ());
63-
59+ expressions_as_cache_key_strings_ .push_back (expression.ToCacheKeyString ());
60+ UpdateUniqifier (expression.ToCacheKeyString ());
61+ arrow::internal::hash_combine (result,expression. ToCacheKeyString ());
6462 arrow::internal::hash_combine (result, configuration->Hash ());
65- arrow::internal::hash_combine (result, schema_->ToString ());
66- arrow::internal::hash_combine (result, uniquifier_);
63+ arrow::internal::hash_combine (result, uniqifier_);
6764 hash_code_ = result;
6865 }
6966
70- void UpdateUniquifier (const std::string& expr) {
71- if (uniquifier_ == 0 ) {
67+ void UpdateUniqifier (const std::string& expr) {
68+ if (uniqifier_ == 0 ) {
7269 // caching of expressions with re2 patterns causes lock contention. So, use
7370 // multiple instances to reduce contention.
7471 if (expr.find (" like(" ) != std::string::npos) {
75- uniquifier_ = std::hash<std::thread::id>()(std::this_thread::get_id ()) % 16 ;
72+ uniqifier_ = std::hash<std::thread::id>()(std::this_thread::get_id ()) % 16 ;
7673 }
7774 }
7875 }
@@ -84,9 +81,6 @@ class ExpressionCacheKey {
8481 return false ;
8582 }
8683
87- if (!(schema_->Equals (*other.schema_ , true ))) {
88- return false ;
89- }
9084
9185 if (configuration_ != other.configuration_ ) {
9286 return false ;
@@ -96,11 +90,11 @@ class ExpressionCacheKey {
9690 return false ;
9791 }
9892
99- if (expressions_as_strings_ != other.expressions_as_strings_ ) {
93+ if (expressions_as_cache_key_strings_ != other.expressions_as_cache_key_strings_ ) {
10094 return false ;
10195 }
10296
103- if (uniquifier_ != other.uniquifier_ ) {
97+ if (uniqifier_ != other.uniqifier_ ) {
10498 return false ;
10599 }
106100
@@ -111,10 +105,9 @@ class ExpressionCacheKey {
111105
112106 private:
113107 size_t hash_code_;
114- SchemaPtr schema_;
115- std::vector<std::string> expressions_as_strings_;
108+ std::vector<std::string> expressions_as_cache_key_strings_;
116109 SelectionVector::Mode mode_;
117- uint32_t uniquifier_ ;
110+ uint32_t uniqifier_ ;
118111 std::shared_ptr<Configuration> configuration_;
119112};
120113
0 commit comments