Files
doris/be/src/util/path_util.h
Mingyu Chen 05db6e9b55 [refactor](file-system)(step-2) remove env, file_utils and filesystem_utils (#18009)
Follow #17586.
This PR mainly changes:

Remove env/
Remove FileUtils/FilesystemUtils
Some methods are moved to LocalFileSystem
Remove olap/file_cache
Add s3 client cache for s3 file system
In my test, the time of open s3 file can be reduced significantly
Fix cold/hot separation bug for s3 fs.
This is the last PR of #17764.
After this, all IO operation should be in io/fs.

Except for tests in #17586, I also tested some case related to fs io:

clone
concurrency query on local/s3/hdfs
load error log create and clean
disk metrics
2023-03-29 09:00:52 +08:00

75 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.
//
// Utility methods for dealing with file paths.
#pragma once
#include <string>
#include <vector>
#include "io/fs/fs_utils.h"
namespace doris {
namespace path_util {
using doris::io::FilePathDesc;
// NOTE: The methods here are only related to path processing, do not involve
// any file and IO operations.
extern const std::string kTmpInfix;
// Join two path segments with the appropriate path separator, if necessary.
std::string join_path_segments(const std::string& a, const std::string& b);
// Join each path segment in a list with a common suffix segment.
std::vector<std::string> join_path_segments_v(const std::vector<std::string>& v,
const std::string& s);
FilePathDesc join_path_desc_segments(const FilePathDesc& path_desc, const std::string& b);
// Split a path into segments with the appropriate path separator.
std::vector<std::string> split_path(const std::string& path);
// Return the enclosing directory of path.
// This is like dirname(3) but for C++ strings.
// The following list of examples shows the strings returned by dirname() and basename():
// path dirname basename
// "/usr/lib" "/usr" "lib"
// "/usr/" "/" "usr"
// "usr" "." "usr"
// "/" "/" "/"
// "." "." "."
// ".." "." ".."
std::string dir_name(const std::string& path);
// Return the terminal component of a path.
// This is like basename(3) but for C++ strings.
std::string base_name(const std::string& path);
// It is used to replace std::filesystem::path::extension().
// If the filename contains a dot but does not consist solely of one or to two dots,
// returns the substring of file_name starting at the rightmost dot and ending at
// the path's end. Otherwise, returns an empty string.
// The dot is included in the return value so that it is possible to distinguish
// between no extension and an empty extension.
// NOTE: path can be either one file's full path or only file name
std::string file_extension(const std::string& path);
} // namespace path_util
} // namespace doris