Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
bobhan1 committed Jan 6, 2025
1 parent d5a02e0 commit 65042b2
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 1 deletion.
5 changes: 5 additions & 0 deletions be/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,11 @@ if (BUILD_META_TOOL)
add_subdirectory(${SRC_DIR}/tools)
endif()

option(BUILD_MY_TOOL "Build my tool" ON)
if (BUILD_MY_TOOL)
add_subdirectory(${SRC_DIR}/my-tools)
endif()

option(BUILD_INDEX_TOOL "Build index tool" OFF)
if (BUILD_INDEX_TOOL)
add_subdirectory(${SRC_DIR}/index-tools)
Expand Down
38 changes: 38 additions & 0 deletions be/src/my-tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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.

# where to put generated libraries
set(LIBRARY_OUTPUT_PATH "${BUILD_DIR}/src/my-tools")

# where to put generated binaries
set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/src/my-tools")

add_executable(my_tool
my_tool.cpp
)

# pch_reuse(my_tool)

# This permits libraries loaded by dlopen to link to the symbols in the program.
set_target_properties(my_tool PROPERTIES ENABLE_EXPORTS 1)

target_link_libraries(my_tool
${DORIS_LINK_LIBS}
)

install(DIRECTORY DESTINATION ${OUTPUT_DIR}/lib/)
install(TARGETS my_tool DESTINATION ${OUTPUT_DIR}/lib/)
56 changes: 56 additions & 0 deletions be/src/my-tools/my_tool.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// 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 <fmt/format.h>

#include "common/status.h"
#include "olap/olap_meta.h"

DEFINE_string(operation, "", "valid operation: show");
DEFINE_string(root_path, "", "root path");

std::string get_usage(const std::string& progname) {
std::stringstream ss;
ss << progname << " is the Doris inverted index file tool.\n";
ss << "Usage:\n";
ss << "./my_tool";
return ss.str();
}

int main(int argc, char** argv) {
using namespace doris;

std::string usage = get_usage(argv[0]);
gflags::SetUsageMessage(usage);
google::ParseCommandLineFlags(&argc, &argv, true);

if (FLAGS_operation == "show") {
std::string root_path {FLAGS_root_path};
std::cout << fmt::format("get root_path={}", root_path);
OlapMeta meta {root_path};
std::cout << fmt::format("begin to init OlapMeta, root_path={}", root_path);
Status res = meta.init();
if (!res.ok()) {
RETURN_NOT_OK_STATUS_WITH_WARN(
Status::IOError("open rocksdb failed, path={}", root_path),
"init OlapMeta failed");
}
std::cout << fmt::format("successfully open RocksDB, path={}", meta.get_root_path());
}
gflags::ShutDownCommandLineFlags();
return 0;
}
2 changes: 1 addition & 1 deletion be/src/tools/meta_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ using doris::segment_v2::ColumnIteratorOptions;
using doris::segment_v2::PageFooterPB;
using doris::io::FileReaderSPtr;

const std::string HEADER_PREFIX = "tabletmeta_";
// const std::string HEADER_PREFIX = "tabletmeta_";

DEFINE_string(root_path, "", "storage root path");
DEFINE_string(operation, "get_meta",
Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ BUILD_FE=0
BUILD_BE=0
BUILD_BROKER=0
BUILD_META_TOOL='OFF'
BUILD_MY_TOOL='ON'
BUILD_INDEX_TOOL='OFF'
BUILD_SPARK_DPP=0
BUILD_BE_JAVA_EXTENSIONS=0
Expand Down Expand Up @@ -535,6 +536,7 @@ if [[ "${BUILD_BE}" -eq 1 ]]; then
-DWITH_MYSQL="${WITH_MYSQL}" \
-DUSE_LIBCPP="${USE_LIBCPP}" \
-DBUILD_META_TOOL="${BUILD_META_TOOL}" \
-DBUILD_MY_TOOL="${BUILD_MY_TOOL}" \
-DBUILD_INDEX_TOOL="${BUILD_INDEX_TOOL}" \
-DSTRIP_DEBUG_INFO="${STRIP_DEBUG_INFO}" \
-DUSE_DWARF="${USE_DWARF}" \
Expand Down

0 comments on commit 65042b2

Please sign in to comment.