MCPcopy Create free account
hub / github.com/apache/impala / TestSwitchModeHelper

Method TestSwitchModeHelper

be/src/codegen/llvm-codegen-cache-test.cc:548–575  ·  view source on GitHub ↗

Helper function to test swithing modes. Helps to insert an entry with provided key and mode.

Source from the content-addressed store, hash-verified

546/// Helper function to test swithing modes. Helps to insert an entry with provided key
547/// and mode.
548void LlvmCodeGenCacheTest::TestSwitchModeHelper(TCodeGenCacheMode::type mode, string key,
549 int expect_entry_num = -1, int expect_engine_num = -1,
550 CodeGenObjectCache** engine_cache = nullptr) {
551 // Create a LlvmCodeGen containing a codegen function Echo.
552 scoped_ptr<LlvmCodeGen> codegen;
553 ASSERT_OK(LlvmCodeGen::CreateImpalaCodegen(fragment_state_, nullptr, "test", &codegen));
554 string module_id_echo;
555 codegen->engine_cache_ = CreateObjCache(false /*is_double*/, &module_id_echo);
556 ASSERT_TRUE(codegen->engine_cache_ != nullptr);
557 CheckObjCacheExists(codegen.get());
558
559 CodeGenCacheKey cache_key;
560 CodeGenCacheEntry entry;
561 CodeGenCacheKeyConstructor::construct(key, &cache_key);
562
563 // Store and lookup the entry by the key.
564 EXPECT_OK(codegen_cache_->Store(cache_key, codegen.get(), mode, opt_level_));
565 if (expect_entry_num != -1) {
566 CheckInUseMetrics(codegen_cache_.get(), expect_entry_num /*num_entry_in_use*/);
567 }
568 if (expect_engine_num != -1) {
569 CheckEngineCacheCount(codegen.get(), expect_engine_num);
570 }
571 EXPECT_OK(codegen_cache_->Lookup(cache_key, mode, &entry, &codegen_obj_cache_));
572 CheckResult(entry, module_id_echo);
573 if (engine_cache) *engine_cache = codegen->engine_cache();
574 codegen->Close();
575}
576
577// Test to switch among different modes.
578TEST_F(LlvmCodeGenCacheTest, SwitchMode) {

Callers

nothing calls this directly

Calls 5

engine_cacheMethod · 0.80
getMethod · 0.65
StoreMethod · 0.45
LookupMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected