This is an automated email from the ASF dual-hosted git repository. wesm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/arrow.git
commit fa2273b30c7a94ba8da56a010421c9fd0f759cd4 Author: Pindikura Ravindra <[email protected]> AuthorDate: Sun Sep 23 16:47:27 2018 +0530 [Gandiva] add debug msgs to print expressions --- cpp/src/gandiva/filter.cc | 9 ++++++--- cpp/src/gandiva/filter_cache_key.h | 13 +++++++++++++ cpp/src/gandiva/projector.cc | 6 ++++++ cpp/src/gandiva/projector_cache_key.h | 25 +++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/cpp/src/gandiva/filter.cc b/cpp/src/gandiva/filter.cc index cbcd40f..df624f2 100644 --- a/cpp/src/gandiva/filter.cc +++ b/cpp/src/gandiva/filter.cc @@ -48,10 +48,11 @@ Status Filter::Make(SchemaPtr schema, ConditionPtr condition, GANDIVA_RETURN_FAILURE_IF_FALSE(configuration != nullptr, Status::Invalid("configuration cannot be null")); static Cache<FilterCacheKey, std::shared_ptr<Filter>> cache; - FilterCacheKey cacheKey(schema, configuration, *(condition.get())); - std::shared_ptr<Filter> cachedFilter = cache.GetModule(cacheKey); + FilterCacheKey cache_key(schema, configuration, *(condition.get())); + std::shared_ptr<Filter> cachedFilter = cache.GetModule(cache_key); if (cachedFilter != nullptr) { *filter = cachedFilter; + std::cout << "llvm filter module cache hit : " << cache_key.ToString() << std::endl; return Status::OK(); } // Build LLVM generator, and generate code for the specified expression @@ -70,7 +71,9 @@ Status Filter::Make(SchemaPtr schema, ConditionPtr condition, // Instantiate the filter with the completely built llvm generator *filter = std::make_shared<Filter>(std::move(llvm_gen), schema, configuration); - cache.PutModule(cacheKey, *filter); + cache.PutModule(cache_key, *filter); + std::cout << "llvm filter module cache insert : " << cache_key.ToString() << std::endl; + return Status::OK(); } diff --git a/cpp/src/gandiva/filter_cache_key.h b/cpp/src/gandiva/filter_cache_key.h index 8cd3369..825f0ee 100644 --- a/cpp/src/gandiva/filter_cache_key.h +++ b/cpp/src/gandiva/filter_cache_key.h @@ -63,6 +63,19 @@ class FilterCacheKey { SchemaPtr schema() const { return schema_; } + std::string ToString() const { + std::stringstream ss; + ss << "Schema ["; + + // remove newlines from schema + auto schema_str = schema_->ToString(); + std::replace(schema_str.begin(), schema_str.end(), '\n', ','); + ss << schema_str << "] "; + + ss << "Condition: [" << expression_as_string_ << "]"; + return ss.str(); + } + private: const SchemaPtr schema_; const std::shared_ptr<Configuration> configuration_; diff --git a/cpp/src/gandiva/projector.cc b/cpp/src/gandiva/projector.cc index d1f35d7..8279a4f 100644 --- a/cpp/src/gandiva/projector.cc +++ b/cpp/src/gandiva/projector.cc @@ -59,8 +59,11 @@ Status Projector::Make(SchemaPtr schema, const ExpressionVector& exprs, std::shared_ptr<Projector> cached_projector = cache.GetModule(cache_key); if (cached_projector != nullptr) { *projector = cached_projector; + std::cout << "llvm projector module cache hit : " << cache_key.ToString() + << std::endl; return Status::OK(); } + // Build LLVM generator, and generate code for the specified expressions std::unique_ptr<LLVMGenerator> llvm_gen; Status status = LLVMGenerator::Make(configuration, &llvm_gen); @@ -88,6 +91,9 @@ Status Projector::Make(SchemaPtr schema, const ExpressionVector& exprs, *projector = std::shared_ptr<Projector>( new Projector(std::move(llvm_gen), schema, output_fields, configuration)); cache.PutModule(cache_key, *projector); + std::cout << "llvm projector module cache insert : " << cache_key.ToString() + << std::endl; + return Status::OK(); } diff --git a/cpp/src/gandiva/projector_cache_key.h b/cpp/src/gandiva/projector_cache_key.h index 962745b..1d73c33 100644 --- a/cpp/src/gandiva/projector_cache_key.h +++ b/cpp/src/gandiva/projector_cache_key.h @@ -21,6 +21,7 @@ #include <memory> #include <string> #include <vector> +#include <algorithm> #include "gandiva/arrow.h" #include "gandiva/projector.h" @@ -65,6 +66,30 @@ class ProjectorCacheKey { SchemaPtr schema() const { return schema_; } + std::string ToString() const { + std::stringstream ss; + ss << "Schema ["; + + // remove newlines from schema + auto schema_str = schema_->ToString(); + std::replace(schema_str.begin(), schema_str.end(), '\n', ','); + ss << schema_str << "] "; + + ss << "Expressions: ["; + bool first = true; + for (auto &expr : expressions_as_strings_) { + if (first) { + first = false; + } else { + ss << ", "; + } + + ss << expr; + } + ss << "]"; + return ss.str(); + } + private: const SchemaPtr schema_; const std::shared_ptr<Configuration> configuration_;
