Skip to content

Commit

Permalink
[GLUTEN-1632][CH]Daily Update Clickhouse Version (20241017) (#7567)
Browse files Browse the repository at this point in the history
* [GLUTEN-1632][CH]Daily Update Clickhouse Version (20241017)

* Fix  Build due to ClickHouse/ClickHouse#68146

* Fix Build due to rebasing failed with ClickHouse/ClickHouse#69179

---------

Co-authored-by: kyligence-git <[email protected]>
Co-authored-by: Chang Chen <[email protected]>
  • Loading branch information
3 people authored Oct 17, 2024
1 parent 2a2d5bd commit 9a19204
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 20 deletions.
4 changes: 2 additions & 2 deletions cpp-ch/clickhouse.version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CH_ORG=Kyligence
CH_BRANCH=rebase_ch/20241016
CH_COMMIT=c3a1c1b8457
CH_BRANCH=rebase_ch/20241017
CH_COMMIT=afe3026c6ce
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,21 @@ DB::MetadataStorageType MetadataStorageFromRocksDB::getType() const
return DB::MetadataStorageType::None;
}

bool MetadataStorageFromRocksDB::exists(const std::string & path) const
bool MetadataStorageFromRocksDB::existsFileOrDirectory(const std::string & path) const
{
return exist(getRocksDB(), path);
}

bool MetadataStorageFromRocksDB::isFile(const std::string & path) const
bool MetadataStorageFromRocksDB::existsFile(const std::string & path) const
{
auto data = getData(getRocksDB(), path);
return data != RocksDBCreateDirectoryOperation::DIR_DATA;
std::string data;
return tryGetData(getRocksDB(), path, &data) && data != RocksDBCreateDirectoryOperation::DIR_DATA;
}

bool MetadataStorageFromRocksDB::isDirectory(const std::string & path) const
bool MetadataStorageFromRocksDB::existsDirectory(const std::string & path) const
{
auto data = getData(getRocksDB(), path);
return data == RocksDBCreateDirectoryOperation::DIR_DATA;
std::string data;
return tryGetData(getRocksDB(), path, &data) && data == RocksDBCreateDirectoryOperation::DIR_DATA;
}

uint64_t MetadataStorageFromRocksDB::getFileSize(const std::string & path) const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class MetadataStorageFromRocksDB final : public DB::IMetadataStorage
DB::MetadataTransactionPtr createTransaction() override;
const std::string & getPath() const override;
DB::MetadataStorageType getType() const override;
bool exists(const std::string & path) const override;
bool isFile(const std::string & path) const override;
bool isDirectory(const std::string & path) const override;
bool existsFile(const std::string & path) const override;
bool existsDirectory(const std::string & path) const override;
bool existsFileOrDirectory(const std::string & path) const override;
uint64_t getFileSize(const std::string & path) const override;
Poco::Timestamp getLastModified(const std::string & path) const override;
bool supportsChmod() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <config.h>
#if USE_ROCKSDB
#include "MetadataStorageFromRocksDBTransactionOperations.h"

#include <ranges>

namespace DB
Expand All @@ -39,7 +40,12 @@ void throwRockDBErrorNotOk(const rocksdb::Status & status)
bool exist(rocksdb::DB & db, const std::string & path)
{
std::string data;
auto status = db.Get({}, path, &data);
return tryGetData(db, path, &data);
}

bool tryGetData(rocksdb::DB & db, const std::string & path, std::string * value)
{
auto status = db.Get({}, path, value);
if (status.IsNotFound())
return false;
throwRockDBErrorNotOk(status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace local_engine
{
void throwRockDBErrorNotOk(const rocksdb::Status & status);
bool exist(rocksdb::DB & db, const std::string & path);
bool tryGetData(rocksdb::DB & db, const std::string & path, std::string* value);
String getData(rocksdb::DB & db, const std::string & path);
std::vector<String> listKeys(rocksdb::DB & db, const std::string & path);

Expand Down
12 changes: 6 additions & 6 deletions cpp-ch/local-engine/Storages/MergeTree/MetaDataHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void restoreMetaData<ROCKSDB>(const SparkStorageMergeTreePtr & storage, const Me
for (const auto & part : mergeTreeTable.getPartNames())
{
auto part_path = table_path / part;
if (!metadata_storage->exists(part_path))
if (!metadata_storage->existsDirectory(part_path))
not_exists_part.emplace(part);
}

Expand All @@ -104,15 +104,15 @@ void restoreMetaData<ROCKSDB>(const SparkStorageMergeTreePtr & storage, const Me
auto s3 = data_disk->getObjectStorage();
auto transaction = metadata_storage->createTransaction();

if (!metadata_storage->exists(table_path))
if (!metadata_storage->existsDirectory(table_path))
transaction->createDirectoryRecursive(table_path.generic_string());

for (const auto & part : not_exists_part)
{
auto part_path = table_path / part;
auto metadata_file_path = part_path / METADATA_FILE_NAME;

if (metadata_storage->exists(part_path))
if (metadata_storage->existsDirectory(part_path))
return;
else
transaction->createDirectoryRecursive(part_path);
Expand Down Expand Up @@ -143,7 +143,7 @@ void restoreMetaData<LOCAL>(
for (const auto & part : mergeTreeTable.getPartNames())
{
auto part_path = table_path / part;
if (!metadata_disk->exists(part_path))
if (!metadata_disk->existsDirectory(part_path))
not_exists_part.emplace(part);
}

Expand All @@ -166,7 +166,7 @@ void restoreMetaData<LOCAL>(
not_exists_part.size());
auto s3 = data_disk->getObjectStorage();

if (!metadata_disk->exists(table_path))
if (!metadata_disk->existsDirectory(table_path))
metadata_disk->createDirectories(table_path.generic_string());

for (const auto & part : not_exists_part)
Expand All @@ -176,7 +176,7 @@ void restoreMetaData<LOCAL>(
auto part_path = table_path / part;
auto metadata_file_path = part_path / METADATA_FILE_NAME;

if (metadata_disk->exists(part_path))
if (metadata_disk->existsDirectory(part_path))
return;
else
metadata_disk->createDirectories(part_path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void SparkStorageMergeTree::prefetchMetaDataFile(std::unordered_set<std::string>
read_settings.remote_fs_method = RemoteFSReadMethod::read;
for (const auto & meta_path : meta_paths)
{
if (!disk->exists(meta_path))
if (!disk->existsDirectory(meta_path))
continue;

auto in = disk->readFile(meta_path, read_settings);
Expand Down

0 comments on commit 9a19204

Please sign in to comment.