diff options
author | vitalyisaev <vitalyisaev@yandex-team.com> | 2023-06-29 10:00:50 +0300 |
---|---|---|
committer | vitalyisaev <vitalyisaev@yandex-team.com> | 2023-06-29 10:00:50 +0300 |
commit | 6ffe9e53658409f212834330e13564e4952558f6 (patch) | |
tree | 85b1e00183517648b228aafa7c8fb07f5276f419 /contrib/libs/clang14/lib/Serialization/InMemoryModuleCache.cpp | |
parent | 726057070f9c5a91fc10fde0d5024913d10f1ab9 (diff) | |
download | ydb-6ffe9e53658409f212834330e13564e4952558f6.tar.gz |
YQ Connector: support managed ClickHouse
Со стороны dqrun можно обратиться к инстансу коннектора, который работает на streaming стенде, и извлечь данные из облачного CH.
Diffstat (limited to 'contrib/libs/clang14/lib/Serialization/InMemoryModuleCache.cpp')
-rw-r--r-- | contrib/libs/clang14/lib/Serialization/InMemoryModuleCache.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/contrib/libs/clang14/lib/Serialization/InMemoryModuleCache.cpp b/contrib/libs/clang14/lib/Serialization/InMemoryModuleCache.cpp new file mode 100644 index 00000000000..d35fa2a807f --- /dev/null +++ b/contrib/libs/clang14/lib/Serialization/InMemoryModuleCache.cpp @@ -0,0 +1,80 @@ +//===- InMemoryModuleCache.cpp - Cache for loaded memory buffers ----------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang/Serialization/InMemoryModuleCache.h" +#include "llvm/Support/MemoryBuffer.h" + +using namespace clang; + +InMemoryModuleCache::State +InMemoryModuleCache::getPCMState(llvm::StringRef Filename) const { + auto I = PCMs.find(Filename); + if (I == PCMs.end()) + return Unknown; + if (I->second.IsFinal) + return Final; + return I->second.Buffer ? Tentative : ToBuild; +} + +llvm::MemoryBuffer & +InMemoryModuleCache::addPCM(llvm::StringRef Filename, + std::unique_ptr<llvm::MemoryBuffer> Buffer) { + auto Insertion = PCMs.insert(std::make_pair(Filename, std::move(Buffer))); + assert(Insertion.second && "Already has a PCM"); + return *Insertion.first->second.Buffer; +} + +llvm::MemoryBuffer & +InMemoryModuleCache::addBuiltPCM(llvm::StringRef Filename, + std::unique_ptr<llvm::MemoryBuffer> Buffer) { + auto &PCM = PCMs[Filename]; + assert(!PCM.IsFinal && "Trying to override finalized PCM?"); + assert(!PCM.Buffer && "Trying to override tentative PCM?"); + PCM.Buffer = std::move(Buffer); + PCM.IsFinal = true; + return *PCM.Buffer; +} + +llvm::MemoryBuffer * +InMemoryModuleCache::lookupPCM(llvm::StringRef Filename) const { + auto I = PCMs.find(Filename); + if (I == PCMs.end()) + return nullptr; + return I->second.Buffer.get(); +} + +bool InMemoryModuleCache::isPCMFinal(llvm::StringRef Filename) const { + return getPCMState(Filename) == Final; +} + +bool InMemoryModuleCache::shouldBuildPCM(llvm::StringRef Filename) const { + return getPCMState(Filename) == ToBuild; +} + +bool InMemoryModuleCache::tryToDropPCM(llvm::StringRef Filename) { + auto I = PCMs.find(Filename); + assert(I != PCMs.end() && "PCM to remove is unknown..."); + + auto &PCM = I->second; + assert(PCM.Buffer && "PCM to remove is scheduled to be built..."); + + if (PCM.IsFinal) + return true; + + PCM.Buffer.reset(); + return false; +} + +void InMemoryModuleCache::finalizePCM(llvm::StringRef Filename) { + auto I = PCMs.find(Filename); + assert(I != PCMs.end() && "PCM to finalize is unknown..."); + + auto &PCM = I->second; + assert(PCM.Buffer && "Trying to finalize a dropped PCM..."); + PCM.IsFinal = true; +} |