text stringlengths 1 24.5M |
|---|
#pragma once
#include <type_traits>
#include <utility>
#include <variant>
#include "common/serde/Serde.h"
#include "common/utils/Nameof.hpp"
namespace hf3fs::serde {
template <class T>
class VisitOut {
public:
auto tableBegin(); // begin a table.
void tableEnd(); // end a table.
... |
#pragma once
#include <fmt/core.h>
#include <folly/IPAddressV4.h>
#include <folly/SocketAddress.h>
#include <folly/hash/Hash.h>
#include <scn/scn.h>
#include "common/utils/MagicEnum.hpp"
#include "common/utils/Result.h"
namespace hf3fs::net {
constexpr const char *kUnixDomainSocketPrefix[] = {nullptr, "/tmp/domain_... |
/*
__ _ _ __ __ _ _ __ __ _ _ __ ___ ___
/ _` | '__/ _` | '_ \ / _` | '__/ __|/ _ \ Argument Parser for Modern C++
| (_| | | | (_| | |_) | (_| | | \__ \ __/ http://github.com/p-ranav/argparse
\__,_|_| \__, | .__/ \__,_|_| |___/\___|
|___/|_|
Licensed under the MIT License <http://opensource.org/l... |
#pragma once
#include <folly/concurrency/AtomicSharedPtr.h>
#include <mutex>
#include <set>
#include <vector>
namespace hf3fs {
struct AvailSlots {
AvailSlots(int c)
: cap(c) {}
std::optional<int> alloc() {
std::lock_guard lock(mutex);
if (!free.empty()) {
auto idx = *free.begin();
free.... |
#pragma once
#include <atomic>
namespace hf3fs {
// Wrapper of atomic value, support copy.
template <class T>
class AtomicValue {
public:
AtomicValue() = default;
explicit AtomicValue(T value)
: value_(value) {}
AtomicValue(const AtomicValue &o)
: value_(o.value()) {}
T value(std::memory_order ... |
#include "BackgroundRunner.h"
#include <folly/experimental/coro/BlockingWait.h>
#include <folly/experimental/coro/Sleep.h>
#include <folly/logging/xlog.h>
#include "UtcTime.h"
namespace hf3fs {
BackgroundRunner::BackgroundRunner(folly::Executor::KeepAlive<> executor) {
XLOGF_IF(FATAL, !executor, "empty executor!")... |
#pragma once
#include <folly/Executor.h>
#include <variant>
#include "CPUExecutorGroup.h"
#include "Coroutine.h"
#include "CountDownLatch.h"
#include "Duration.h"
namespace hf3fs {
class BackgroundRunner {
public:
explicit BackgroundRunner(folly::Executor::KeepAlive<> executor);
explicit BackgroundRunner(CPUExe... |
#include "BoostFileSystemWrappers.h"
namespace hf3fs {
namespace {
template <typename Func, typename R = std::invoke_result_t<Func, boost::system::error_code &>>
Result<std::conditional_t<std::is_void_v<R>, Void, R>> callBoostFsFunc(Func &&func, std::string_view desc) {
boost::system::error_code ec;
if constexpr (... |
#pragma once
#include "Path.h"
#include "Result.h"
namespace hf3fs {
Result<bool> boostFilesystemExists(const Path &path);
Result<bool> boostFilesystemIsDir(const Path &path);
Result<boost::filesystem::directory_iterator> boostFilesystemDirIter(const Path &path);
Result<bool> boostFilesystemCreateDir(const Path &p... |
#pragma once
#include <folly/MPMCQueue.h>
#include <folly/ProducerConsumerQueue.h>
#include <folly/Utility.h>
#include <folly/experimental/coro/Task.h>
#include <folly/fibers/Semaphore.h>
namespace hf3fs {
template <typename T>
class BoundedQueue {
public:
explicit BoundedQueue(uint32_t capacity)
: queue_(c... |
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#include "coding.h"
namespace hf3fs {
void PutFixed32(std::string *dst, uint32_t value) {
char buf[... |
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
//
// Endian-neutral encoding:
// * Fixed-length numbers are encoded with least-significant byte first
/... |
#pragma once
#include <folly/experimental/coro/Baton.h>
#include <folly/experimental/coro/BlockingWait.h>
#include <limits>
#include <memory>
#include <mutex>
#include <tuple>
#include <utility>
#include "common/utils/Coroutine.h"
#include "common/utils/Shards.h"
namespace hf3fs {
template <std::size_t N = 256>
cla... |
#pragma once
#include <folly/experimental/coro/Baton.h>
#include <folly/logging/xlog.h>
#include <functional>
#include <queue>
#include <unordered_map>
#include <utility>
#include "common/utils/ConfigBase.h"
#include "common/utils/Coroutine.h"
#include "common/utils/Shards.h"
namespace hf3fs {
class ConcurrencyLimi... |
#include "common/utils/ConfigBase.h"
#include <boost/filesystem.hpp>
#include <fmt/format.h>
#include <folly/init/Init.h>
#include <folly/logging/xlog.h>
#include <gflags/gflags.h>
#include <iostream>
#include "common/utils/FileUtils.h"
#include "common/utils/VersionInfo.h"
DEFINE_string(cfg, "", "Path to .toml conf... |
#pragma once
#include <atomic>
#include <fmt/format.h>
#include <folly/Likely.h>
#include <folly/ThreadLocal.h>
#include <folly/concurrency/AtomicSharedPtr.h>
#include <functional>
#include <iomanip>
#include <map>
#include <memory>
#include <mutex>
#include <optional>
#include <set>
#include <span>
#include <sstream>... |
#pragma once
#include <folly/logging/xlog.h>
#include "common/utils/NameWrapper.h"
namespace hf3fs {
template <NameWrapper Name>
struct ConstructLog {
ConstructLog() { XLOGF(INFO, "Construct {}", std::string_view{Name}); }
~ConstructLog() { XLOGF(INFO, "Destruct {}", std::string_view{Name}); }
};
} // namespa... |
#pragma once
#include <cstdint>
#include <limits>
#include <type_traits>
namespace hf3fs {
template <typename To, typename From>
inline constexpr bool isSafeConvertTo(From from) noexcept {
static_assert(std::is_integral_v<From> && std::is_integral_v<To>);
static_assert(sizeof(From) <= sizeof(uint64_t) && sizeof(T... |
#pragma once
#include <folly/experimental/coro/SharedMutex.h>
#include "common/utils/Coroutine.h"
namespace hf3fs {
namespace detail {
template <typename Guard, typename T>
class CoLockGuard {
public:
CoLockGuard(Guard &&guard, T &obj)
: guard_(std::move(guard)),
obj_(obj) {}
T *operator->() { re... |
#pragma once
#include <common/utils/Result.h>
#include <folly/Unit.h>
#include <folly/experimental/coro/Task.h>
#include <folly/experimental/coro/WithCancellation.h>
#include <type_traits>
namespace hf3fs {
template <typename T>
using CoTask = folly::coro::Task<T>;
template <typename T>
using CoTryTask = CoTask<std:... |
#pragma once
#include <folly/Random.h>
#include <folly/executors/CPUThreadPoolExecutor.h>
#include <folly/experimental/coro/Collect.h>
#include <folly/experimental/coro/Sleep.h>
#include "common/utils/BoundedQueue.h"
#include "common/utils/CPUExecutorGroup.h"
#include "common/utils/ConfigBase.h"
#include "common/util... |
#pragma once
#include <atomic>
#include <folly/experimental/coro/Baton.h>
#include "common/utils/Coroutine.h"
namespace hf3fs {
template <typename BatonType = folly::coro::Baton>
class CountDownLatch {
public:
explicit CountDownLatch(int64_t count = 0)
: count_(count) {}
void countDown(int64_t n = 1) {
... |
#include "CPUExecutorGroup.h"
#include <folly/executors/task_queue/UnboundedBlockingQueue.h>
#include <folly/logging/xlog.h>
#include "common/utils/SimpleSemaphore.h"
#include "common/utils/StringUtils.h"
#include "common/utils/WorkStealingBlockingQueue.h"
namespace hf3fs {
namespace {
using Task = folly::CPUThread... |
#pragma once
#include <folly/executors/CPUThreadPoolExecutor.h>
#include "common/utils/ConfigBase.h"
#include "common/utils/ConstructLog.h"
namespace hf3fs {
class CPUExecutorGroup {
public:
enum class ExecutorStrategy {
SHARED_QUEUE, // fallback to CPUThreadPoolExecutor
SHARED_NOTHING,
WORK_STEALING... |
#pragma once
#include <chrono>
#include <folly/experimental/coro/Sleep.h>
#include "common/kv/ITransaction.h"
#include "common/utils/Coroutine.h"
#include "common/utils/Result.h"
#include "common/utils/Status.h"
#include "common/utils/UtcTime.h"
#include "fdb/FDBTransaction.h"
namespace hf3fs {
struct CoroSleeper {
... |
#pragma once
#include <folly/fibers/Baton.h>
#include <memory>
namespace hf3fs {
class DestructionGuard : public std::enable_shared_from_this<DestructionGuard> {
public:
folly::fibers::Baton destructed;
static std::shared_ptr<DestructionGuard> create() {
struct X : DestructionGuard {};
auto ptr = std::m... |
#pragma once
#include <cstring>
#include <exception>
#include <folly/Likely.h>
#include <folly/logging/xlog.h>
#include <memory>
#include <stdexcept>
namespace hf3fs {
template <class Allocator>
class DownwardBytes {
public:
DownwardBytes() = default;
DownwardBytes(const DownwardBytes &o)
: offset_(o.offs... |
#include "common/utils/Duration.h"
#include <folly/String.h>
#include <scn/tuple_return.h>
#include <unordered_map>
namespace hf3fs {
namespace {
constexpr std::chrono::nanoseconds kUnitNanoSec = std::chrono::nanoseconds(1);
constexpr std::chrono::nanoseconds kUnitMicroSec = std::chrono::microseconds(1);
constexpr s... |
#pragma once
#include <chrono>
#include <cstdint>
#include <string>
#include <string_view>
#include "common/utils/Result.h"
namespace hf3fs {
class Duration : public std::chrono::nanoseconds {
public:
using is_serde_copyable = void;
explicit constexpr Duration(std::chrono::nanoseconds duration = {})
: s... |
#include "common/utils/DynamicCoroutinesPool.h"
#include <folly/experimental/coro/BlockingWait.h>
#include <folly/experimental/coro/Invoke.h>
#include "common/monitor/Recorder.h"
namespace hf3fs {
namespace {
monitor::ValueRecorder currentCoroutinesNum{"common.coroutines_num.current", std::nullopt, false};
} // n... |
#pragma once
#include <folly/executors/CPUThreadPoolExecutor.h>
#include <folly/experimental/coro/Baton.h>
#include "common/monitor/Recorder.h"
#include "common/utils/BoundedQueue.h"
#include "common/utils/CPUExecutorGroup.h"
#include "common/utils/ConfigBase.h"
#include "common/utils/Coroutine.h"
namespace hf3fs {
... |
#include "common/utils/ExecutorStatsReporter.h"
#include <folly/executors/IOThreadPoolExecutor.h>
#include "common/utils/CPUExecutorGroup.h"
namespace hf3fs {
namespace {
monitor::CountRecorder threadCountRecorder{"thread_pool_group.thread_count"};
monitor::CountRecorder idleThreadCountRecorder{"thread_pool_group.i... |
#pragma once
#include "common/monitor/Recorder.h"
namespace hf3fs {
template <class T>
class ExecutorStatsReporter {
public:
ExecutorStatsReporter(const T &executor);
void report();
private:
const T &executor_;
monitor::Recorder::TagRef<monitor::CountRecorder> threadCountRecorder_;
monitor::Recorder::T... |
#pragma once
#include <algorithm>
#include <chrono>
#include "common/utils/UtcTime.h"
namespace hf3fs {
class ExponentialBackoffRetry {
public:
ExponentialBackoffRetry(std::chrono::milliseconds initWaitTime,
std::chrono::milliseconds maxWaitTime,
std::chrono::m... |
#pragma once
#include <shared_mutex>
namespace hf3fs {
#ifndef PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
#error "only support GNU pthread rwlock!"
#endif
class FairSharedMutex : public std::shared_mutex {
public:
FairSharedMutex() {
*reinterpret_cast<pthread_rwlock_t *>(native_handle()) = PTHREAD_RWL... |
#pragma once
#include <atomic>
#include <cassert>
#include <folly/Likely.h>
#include <folly/Preprocessor.h>
#include <folly/Random.h>
#include <folly/io/async/Request.h>
#include <memory>
#include <optional>
// Set fault injection parameter in current code scope and automatically restore after leaving the scope.
// P... |
#pragma once
#include <exception>
#include <unistd.h>
#include <utility>
#include "common/utils/Coroutine.h"
namespace hf3fs {
class FdWrapper {
public:
static constexpr int kInvalidFd = -1;
explicit FdWrapper(int fd = kInvalidFd)
: fd_(fd) {}
FdWrapper(const FdWrapper &) = delete;
FdWrapper(FdWrapp... |
#include "FileUtils.h"
#include <fstream>
namespace hf3fs {
Result<std::string> loadFile(const Path &path) {
try {
std::ifstream file(path);
if (!file) {
return makeError(StatusCode::kIOError, fmt::format("Error opening file: {}", path));
}
std::string output((std::istreambuf_iterator<char>(fi... |
#pragma once
#include <string>
#include "common/utils/Path.h"
#include "common/utils/Result.h"
namespace hf3fs {
Result<std::string> loadFile(const Path &path);
Result<Void> storeToFile(const Path &path, const std::string &content);
} // namespace hf3fs
|
#pragma once
namespace hf3fs {
inline void HandleException() {
//
}
} // namespace hf3fs
|
#pragma once
#include <algorithm>
#include <array>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <fmt/core.h>
#include <folly/Likely.h>
#include <folly/Random.h>
#include <folly/Utility.h>
#include <folly/lang/Bits.h>
#include <folly/logging/xlog.h>
#include <memory>
#include <optional>
#include <ra... |
#pragma once
#include <folly/Hash.h>
namespace hf3fs {
using int128_t = __int128;
using uint128_t = unsigned __int128;
} // namespace hf3fs
template <>
struct std::hash<hf3fs::uint128_t> {
constexpr size_t operator()(hf3fs::uint128_t const &i) const noexcept {
auto const hi = static_cast<uint64_t>(i >> 64);... |
/* linenoise.c -- guerrilla line editing library against the idea that a
* line editing lib needs to be 20,000 lines of C code.
*
* You can find the latest source code at:
*
* http://github.com/antirez/linenoise
*
* Does a number of crazy assumptions that happen to be true in 99.9999% of
* the 2010 UNIX compu... |
/* linenoise.h -- VERSION 1.0
*
* Guerrilla line editing library against the idea that a line editing lib
* needs to be 20,000 lines of C code.
*
* See linenoise.c for more information.
*
* ------------------------------------------------------------------------
*
* Copyright (c) 2010-2023, Salvatore Sanfilipp... |
#pragma once
#include <folly/concurrency/AtomicSharedPtr.h>
#include <folly/experimental/coro/Mutex.h>
#include <folly/hash/Hash.h>
#include <folly/logging/xlog.h>
#include <memory>
#include <mutex>
#include <shared_mutex>
#include "common/utils/Coroutine.h"
#include "common/utils/FairSharedMutex.h"
#include "common/... |
#pragma once
#include <fmt/format.h>
#include <folly/logging/xlog.h>
#include "Coroutine.h"
namespace hf3fs::_detail {
template <typename T>
struct CastResult {
using type = Result<T>;
};
template <typename T>
struct CastResult<Result<T>> {
using type = Result<T>;
};
template <>
struct CastResult<void> {
usi... |
#pragma once
#include <list>
#include "common/utils/RobinHood.h"
namespace hf3fs {
template <class K, class V>
class LruCache {
public:
using key_type = K;
using mapped_type = V;
using value_type = std::pair<key_type, mapped_type>;
using list_type = std::list<value_type>;
using size_type = typename list_... |
// __ __ _ ______ _____
// | \/ | (_) | ____| / ____|_ _
// | \ / | __ _ __ _ _ ___ | |__ _ __ _ _ _ __ ___ | | _| |_ _| |_
// | |\/| |/ _` |/ _` | |/ __| | __| | '_ \| | | | '_ ` _ \ | | |_ _|_ _|
// | | | |... |
#pragma once
#include <atomic>
#include <folly/Likely.h>
#include <memory>
#include <vector>
#include "common/utils/Status.h"
namespace hf3fs {
template <typename T>
class MPSCQueue {
public:
explicit MPSCQueue(uint64_t capacity)
: capacity_(capacity),
items_(std::make_unique<std::unique_ptr<T>[]>(... |
//-----------------------------------------------------------------------------
// MurmurHash3 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
// Note - The x86 and x64 versions do _not_ produce the same results, as the
// algorithms are ... |
//-----------------------------------------------------------------------------
// MurmurHash3 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
#ifndef _MURMURHASH3_H_
#define _MURMURHASH3_H_
//--------------------------------------------... |
// _ _ __ _____
// | \ | | / _| / ____|_ _
// | \| | __ _ _ __ ___ ___ ___ | |_ | | _| |_ _| |_
// | . ` |/ _` | '_ ` _ \ / _ \/ _ \| _| | | |_ _|_ _|
// | |\ | (_| | | | | | | __/ (_) | | | |____|_| |_|
// |_| \_|\__,_|_| |_| |_|\___|\... |
#pragma once
#include <algorithm>
#include <string_view>
namespace hf3fs {
template <size_t N>
struct NameWrapper {
constexpr NameWrapper(const char (&str)[N]) { std::copy_n(str, N, string); }
constexpr operator std::string_view() const { return {string, N - 1}; }
char string[N];
};
} // namespace hf3fs
|
#pragma once
#include <folly/Likely.h>
#include <memory>
#include <mutex>
#include <new>
#include <type_traits>
#include <vector>
#include "common/utils/Size.h"
namespace hf3fs {
template <class T, size_t NumTLSCachedItem = 64, size_t NumGlobalCachedItem = 64 * 64>
class ObjectPool {
using Storage = std::aligned_... |
#pragma once
#include <fmt/format.h>
#include <optional>
namespace hf3fs {
template <typename T>
inline std::optional<std::decay_t<T>> makeOptional(const T *ptr) {
if (ptr) return std::make_optional<T>(*ptr);
return std::nullopt;
}
template <typename T>
auto optionalMap(const std::optional<T> &src, auto &&transf... |
#include "Path.h"
#include "common/utils/RobinHood.h"
size_t std::hash<hf3fs::Path>::operator()(const hf3fs::Path &path) const {
std::string_view sv = path.string();
return robin_hood::hash_bytes(sv.data(), sv.size());
}
|
#pragma once
#include <boost/filesystem.hpp>
#include <filesystem>
#include <fmt/format.h>
namespace hf3fs {
using Path = boost::filesystem::path;
} // namespace hf3fs
template <>
struct std::hash<hf3fs::Path> {
size_t operator()(const hf3fs::Path &path) const;
};
FMT_BEGIN_NAMESPACE
template <>
struct format... |
#pragma once
#include <folly/CancellationToken.h>
#include <folly/Random.h>
#include <folly/executors/CPUThreadPoolExecutor.h>
#include <folly/experimental/coro/Collect.h>
#include <folly/experimental/coro/Sleep.h>
#include <folly/logging/xlog.h>
#include "common/app/ApplicationBase.h"
#include "common/utils/CPUExecu... |
#pragma once
#include <folly/MPMCQueue.h>
#include <folly/ProducerConsumerQueue.h>
#include <folly/Utility.h>
#include <folly/concurrency/PriorityUnboundedQueueSet.h>
#include <folly/experimental/coro/Task.h>
#include <folly/fibers/Semaphore.h>
#include <optional>
#include "common/utils/Semaphore.h"
namespace hf3fs ... |
#pragma once
#include <cassert>
#include <folly/Random.h>
#include <span>
#include <vector>
namespace hf3fs {
struct RandomUtils {
template <typename T>
static T randomSelect(const std::vector<T> &vec) {
assert(!vec.empty());
return vec[folly::Random::rand64(vec.size())];
}
};
} // namespace hf3fs |
/*
* rapidcsv.h
*
* URL: https://github.com/d99kris/rapidcsv
* Version: 8.69
*
* Copyright (C) 2017-2022 Kristofer Berggren
* All rights reserved.
*
* rapidcsv is distributed under the BSD 3-Clause license, see LICENSE for details.
*
*/
#pragma once
#include <algorithm>
#include <cassert>
#include <c... |
#include "common/utils/ReentrantLockManager.h"
#include <chrono>
#include <utility>
#include "common/monitor/Recorder.h"
namespace hf3fs {
namespace {
monitor::LatencyRecorder readLockLatency("common_read_lock_latency");
monitor::LatencyRecorder writeLockLatency("common_write_lock_latency");
monitor::LatencyRecorder... |
#pragma once
#include <condition_variable>
#include <folly/Hash.h>
#include <map>
#include <memory>
#include <mutex>
#include <shared_mutex>
#include <vector>
#include "common/utils/RobinHood.h"
namespace hf3fs {
class ReentrantLockManager {
enum class LockType { NONE, READ, WRITE };
public:
void init(uint32_... |
#pragma once
#include <cstddef>
#include <tuple>
#include <type_traits>
#include <utility>
#include "common/utils/TypeTraits.h"
namespace hf3fs::refl {
template <size_t N = 64>
struct Rank : Rank<N - 1> {};
template <>
struct Rank<0> {};
template <class Tuple, class T>
struct Append;
template <class... Ts, class T... |
#include "RenderConfig.h"
#include "common/utils/StringUtils.h"
#include "common/utils/SysResource.h"
namespace hf3fs {
Result<flat::ReleaseVersion> parseReleaseVersion(const String &str, const flat::ReleaseVersion &actual) {
{
auto [r, tagDate] = scn::scan_tuple<uint32_t>(str, "{}");
if (r && r.range().em... |
#pragma once
#include "common/app/AppInfo.h"
namespace hf3fs {
Result<String> renderConfig(const String &configTemplate,
const flat::AppInfo *app,
const std::map<String, String> *envs = nullptr);
Result<flat::ReleaseVersion> parseReleaseVersion(const String &str... |
#pragma once
#include <folly/io/async/Request.h>
namespace hf3fs {
class RequestInfo : public folly::RequestData {
public:
static constexpr const char *kTokenName = "hf3fs::RequestInfo";
static folly::RequestToken const &token() {
static folly::RequestToken const token(kTokenName);
return token;
}
s... |
#pragma once
#include <cassert>
#include <folly/Expected.h>
#include <folly/logging/xlog.h>
#include "common/utils/Status.h"
#define RETURN_ERROR(result) return hf3fs::makeError(std::move(result.error()))
#define MAKE_ERROR_F(code, ...) hf3fs::makeError((code), fmt::format(__VA_ARGS__))
#define CO_RETURN_ON_ERROR_... |
// ______ _____ ______ _________
// ______________ ___ /_ ___(_)_______ ___ /_ ______ ______ ______ /
// __ ___/_ __ \__ __ \__ / __ __ \ __ __ \_ __ \_ __ \_ __ /
// _ / / /_/ /_ /_/ /_ / _ / / / _ / / // /_/ // /_/ // /_/ /... |
#pragma once
#include <folly/hash/Hash.h>
#include "RobinHood.h"
namespace hf3fs {
struct StringHash {
using is_transparent = void; // enable heterogeneous overloads
[[nodiscard]] auto operator()(std::string_view str) const noexcept -> uint64_t {
return robin_hood::hash<std::string_view>{}(str);
}
};
te... |
#pragma once
#include <functional>
#include <type_traits>
namespace hf3fs {
template <typename P, typename T>
concept UnaryPredicate = std::is_same_v<bool, std::invoke_result_t<P, const T &>>;
// Selector is an alias of `std::function<bool(const T &)>`.
// Declare it as a new class so we can override its logical ope... |
#pragma once
#include <folly/experimental/symbolizer/Symbolizer.h>
#include <folly/fibers/Semaphore.h>
#include <folly/logging/xlog.h>
namespace hf3fs {
/* Semaphore with changeable effective capacity and fixed max capacity */
class Semaphore : public folly::NonCopyableNonMovable {
public:
Semaphore(size_t usable... |
#pragma once
#include <folly/logging/xlog.h>
#include "Semaphore.h"
namespace hf3fs {
class SemaphoreGuard : public folly::NonCopyableNonMovable {
public:
SemaphoreGuard(Semaphore &semaphore)
: semaphore_(semaphore),
acquired_(false) {}
~SemaphoreGuard() {
if (acquired_) semaphore_.signal();
... |
#pragma once
#include <cassert>
#include <fmt/format.h>
#include <string_view>
#include <type_traits>
#include <utility>
#include "common/utils/Conversion.h"
#include "common/utils/Result.h"
#include "common/utils/String.h"
namespace hf3fs {
namespace detail {
template <typename T, typename... Ts>
constexpr inline s... |
#pragma once
#include <array>
#include <folly/hash/Hash.h>
#include <mutex>
#include "RobinHoodUtils.h"
namespace hf3fs {
template <class T, std::size_t N>
class Shards {
public:
auto position(auto &&...args) { return folly::hash::hash_combine_generic(RobinHoodHasher{}, args...) % N; }
auto withLockAt(auto &&... |
#pragma once
#include <cstddef>
#include <vector>
namespace hf3fs {
template <typename T>
class SimpleRingBuffer {
public:
explicit SimpleRingBuffer(size_t capacity)
: cap_(capacity),
head_(0),
tail_(0) {
buffer_.resize(capacity * sizeof(T));
}
template <typename U>
requires(std::... |
#include "SimpleSemaphore.h"
#include <folly/logging/xlog.h>
namespace hf3fs {
struct SimpleSemaphore::Waiter {
Waiter *next = nullptr;
Waiter *prev = nullptr;
std::condition_variable cv;
bool done = false;
static Waiter *add(Waiter *head, Waiter *waiter) {
if (!head) {
waiter->next = waiter;
... |
#pragma once
#include <chrono>
#include <condition_variable>
#include <cstdint>
#include <mutex>
namespace hf3fs {
class SimpleSemaphore {
public:
struct Options {};
SimpleSemaphore(Options opts);
bool post();
void wait();
bool try_wait();
bool try_wait_for(std::chrono::milliseconds time);
private:
... |
#include "common/utils/Size.h"
#include <scn/scan/scan.h>
#include <scn/tuple_return.h>
namespace hf3fs {
namespace {
const std::unordered_map<std::string_view, uint64_t> kUnitMap = {
{Size::kLabelB, Size::kUnitB},
{Size::kLabelKB, Size::kUnitKB},
{Size::kLabelMB, Size::kUnitMB},
{Size::kLabelGB, Siz... |
#pragma once
#include <fmt/core.h>
#include <limits>
#include <string>
#include <string_view>
#include "common/utils/Result.h"
namespace hf3fs {
class Size {
public:
static constexpr uint64_t kUnitB = 1ul << 0;
static constexpr uint64_t kUnitKB = 1ul << 10;
static constexpr uint64_t kUnitMB = 1ul << 20;
st... |
#pragma once
#include <any>
#include <common/utils/StatusCode.h>
#include <common/utils/String.h>
#include <cstdint>
#include <fmt/format.h>
#include <memory>
#include <string_view>
#include "folly/Portability.h"
namespace hf3fs {
#if !FOLLY_X64 && !FOLLY_AARCH64
#error "The platform must be 64bit!"
#endif
static_a... |
#include "StatusCode.h"
#include <asm-generic/errno-base.h>
#include <asm-generic/errno.h>
#include <cerrno>
namespace hf3fs::StatusCode {
std::string_view toString(status_code_t code) {
switch (code) {
#define RAW_STATUS(name, ...) \
case k##name: \
return #name;
#define STATUS(ns, name, ...) ... |
#pragma once
#include <cstdint>
#include <string_view>
namespace hf3fs {
// NOTE: `StatusCode` is used as the namespace name so here we use `status_code_t` as the type name.
using status_code_t = uint16_t;
#define RAW_STATUS(name, value) \
namespace StatusCode { \
inlin... |
#include "StatusCodeConversion.h"
namespace hf3fs {
Status StatusCodeConversion::convertToStorageClientCode(Status status) {
switch (status.code()) {
case StatusCode::kInvalidArg:
return status.convert(StorageClientCode::kInvalidArg);
case RPCCode::kTimeout:
return status.convert(StorageClientCo... |
#pragma once
#include "common/utils/Result.h"
#include "common/utils/Status.h"
#include "common/utils/StatusCodeDetails.h"
namespace hf3fs {
class StatusCodeConversion {
public:
static Status convertToStorageClientCode(Status status);
template <typename T>
static Result<T> convertToStorageClientCode(const Re... |
#ifndef RAW_STATUS
#define RAW_STATUS(...)
#endif
#ifndef STATUS
#define STATUS(...)
#endif
#define COMMON_STATUS(...) RAW_STATUS(__VA_ARGS__)
#define TRANSACTION_STATUS(...) STATUS(Transaction, __VA_ARGS__)
#define RPC_STATUS(...) STATUS(RPC, __VA_ARGS__)
#define META_STATUS(...) STATUS(Meta, __VA_ARGS__)
#define ST... |
#pragma once
#include <algorithm>
#include <ranges>
#include <string>
#include <utility>
namespace hf3fs {
using String = std::string;
} // namespace hf3fs
|
#include "StringUtils.h"
namespace hf3fs {
String getPrefixEnd(String prefix) {
int32_t i = prefix.size();
for (; i > 0; --i) {
if (prefix[i - 1] != '\xff') {
++prefix[i - 1];
break;
}
prefix[i - 1] = '\0';
}
if (i == 0) {
// all \xff
return {};
}
return prefix;
}
String fr... |
#pragma once
#include <boost/algorithm/hex.hpp>
#include <boost/algorithm/string.hpp>
#include <fmt/format.h>
#include <span>
#include "Result.h"
#include "String.h"
#include "common/utils/MagicEnum.hpp"
namespace hf3fs {
template <typename T>
requires(std::is_enum_v<T>) inline String toString(T t) { return String(m... |
// take from
// https://github.com/ClickHouse/ClickHouse/blob/766a3a0e111fa075879d7a8e15e749b42f7c748a/base/base/strong_typedef.h
#pragma once
#include <fmt/core.h>
#include <fmt/format.h>
#include <folly/dynamic.h>
#include <functional>
#include <optional>
#include <type_traits>
#include <utility>
#include "common/u... |
#include "suicide.h"
#include <signal.h>
#include <unistd.h>
namespace hf3fs {
Result<Void> suicide(bool graceful) {
if (::kill(getpid(), graceful ? SIGTERM : SIGKILL) != 0) {
return MAKE_ERROR_F(StatusCode::kUnknown,
"send {} to self failed. errno={}. msg={}",
gr... |
#pragma once
#include "Result.h"
namespace hf3fs {
Result<Void> suicide(bool graceful);
}
|
#include "common/utils/SysResource.h"
#include <dirent.h>
#include <filesystem>
#include <folly/logging/xlog.h>
#include <fstream>
#include <sys/sysmacros.h>
#include <unistd.h>
#include "common/serde/Serde.h"
#include "common/utils/Result.h"
#include "scn/scan/scan.h"
namespace hf3fs {
namespace {
struct Device {
... |
#pragma once
#include <map>
#include <string>
#include <sys/resource.h>
#include "common/serde/Serde.h"
#include "common/utils/Result.h"
namespace hf3fs {
struct SysResource {
static Result<std::string> hostname(bool physicalMachineName = true);
static uint32_t pid();
static Result<Void> increaseProcessFDLi... |
#include "SysvShm.h"
namespace hf3fs {
SysvShm::SysvShm() = default;
SysvShm::~SysvShm() {
if (auto r = detach(); r.hasError()) {
XLOGF(WARN, "Error when destruct a shm: {}", r.error());
}
if (auto r = remove(); r.hasError()) {
XLOGF(WARN, "Error when destruct a shm: {}", r.error());
}
}
Result<std::... |
#pragma once
#include <span>
#include <sys/shm.h>
#include "common/utils/Path.h"
#include "common/utils/Result.h"
namespace hf3fs {
class SysvShm {
public:
~SysvShm();
static Result<std::shared_ptr<SysvShm>> create(const Path &path, size_t size, int flags);
std::span<uint8_t> getBuf() const;
Result<shmid_d... |
#pragma once
#include <type_traits>
namespace hf3fs::thief {
namespace detail {
template <typename Tag>
struct Bridge {
#if defined(__GNUC__) && !defined(__clang__)
// Silence unnecessary warning
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-template-friend"
#endif
friend consteval auto ADL(Bri... |
#define TOML_IMPLEMENTATION
#include "common/utils/Toml.hpp"
|
#define TOML_HEADER_ONLY 0
//----------------------------------------------------------------------------------------------------------------------
//
// toml++ v3.3.0
// https://github.com/marzer/tomlplusplus
// SPDX-License-Identifier: MIT
//
//-------------------------------------------------------------------------... |
#pragma once
#include <cstring>
#include <folly/io/async/Request.h>
#include <memory>
#include <mutex>
#include "String.h"
#include "TracingEvent.h"
#include "UtcTime.h"
#define SCOPE_SET_TRACING_POINTS(points) hf3fs::tracing::ScopeGuard FB_ANONYMOUS_VARIABLE(guard)(points)
#define TRACING_ADD_SCOPE_EVENT(...) hf3f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.