Files
doris/be/src/util/debug_util.cpp
DeadlineFen a05dbd3f81 [chore](compile) Improves PCH cache hit ratio (#19469)
Supplement the documentation of be-clion-dev, avoid the problem of undefined DORIS_JAVA_HOME and inability to find jni.h when using clion development without directly compiling through build.sh
Complete the classification of header files in pch.h and introduce some header files that are not frequently modified in doris.
Separate the declaration and definition in common/config.h. If you need to modify the default configuration now, please modify it in common/config.cpp.
gen_cpp/version.h is regenerated every time it is recompiled, which may cause PCH to fail, so now you need to get the version information indirectly rather than directly.
2023-05-10 12:49:01 +08:00

105 lines
2.9 KiB
C++

// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include "util/debug_util.h"
#include <gen_cpp/PlanNodes_types.h>
#include <stdint.h>
#include <iomanip>
#include <map>
#include <sstream> // IWYU pragma: keep
#include <utility>
#include "common/version_internal.h"
namespace doris {
std::string print_plan_node_type(const TPlanNodeType::type& type) {
std::map<int, const char*>::const_iterator i;
i = _TPlanNodeType_VALUES_TO_NAMES.find(type);
if (i != _TPlanNodeType_VALUES_TO_NAMES.end()) {
return i->second;
}
return "Invalid plan node type";
}
std::string get_build_version(bool compact) {
std::stringstream ss;
ss << version::doris_build_version()
#if defined(__x86_64__) || defined(_M_X64)
#ifdef __AVX2__
<< "(AVX2)"
#else
<< "(SSE4.2)"
#endif
#elif defined(__aarch64__)
<< "(AArch64)"
#endif
#ifdef NDEBUG
<< " RELEASE"
#else
<< " DEBUG"
#if defined(ADDRESS_SANITIZER)
<< " with ASAN"
#elif defined(LEAK_SANITIZER)
<< " with LSAN"
#elif defined(THREAD_SANITIZER)
<< " with TSAN"
#elif defined(UNDEFINED_BEHAVIOR_SANITIZER)
<< " with UBSAN"
#elif defined(MEMORY_SANITIZER)
<< " with MSAN"
#elif defined(BLACKLIST_SANITIZER)
<< " with BLSAN"
#endif
#endif
<< " (build " << version::doris_build_hash() << ")";
if (!compact) {
ss << std::endl
<< "Built on " << version::doris_build_time() << " by " << version::doris_build_info();
}
return ss.str();
}
std::string get_short_version() {
static std::string short_version(std::string(version::doris_build_version()) + "-" +
version::doris_build_short_hash());
return short_version;
}
std::string get_version_string(bool compact) {
std::stringstream ss;
ss << " version " << get_build_version(compact);
return ss.str();
}
std::string hexdump(const char* buf, int len) {
std::stringstream ss;
ss << std::hex << std::uppercase;
for (int i = 0; i < len; ++i) {
ss << std::setfill('0') << std::setw(2) << ((uint16_t)buf[i] & 0xff);
}
return ss.str();
}
} // namespace doris