-
Notifications
You must be signed in to change notification settings - Fork 698
Delete unsupported special column DELETE_FLAG #7068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ namespace NKikimr::NOlap { | |
enum class ENormalizerSequentialId : ui32 { | ||
Granules = 1, | ||
Chunks, | ||
DeleteUnsupportedSpecialColumns, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. добавление должно идти последовательно. это SequentialId There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Но у нас же падение в следующем нормализаторе. |
||
PortionsCleaner, | ||
TablesCleaner, | ||
// PortionsMetadata | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#include "normalizer.h" | ||
|
||
#include <ydb/core/tx/columnshard/columnshard_private_events.h> | ||
|
||
namespace NKikimr::NOlap { | ||
|
||
namespace { | ||
|
||
constexpr ui32 ColumnIdxToDelete = (ui32)IIndexInfo::ESpecialColumn::DELETE_FLAG; | ||
|
||
|
||
using namespace NColumnShard; | ||
|
||
struct TKey { | ||
ui32 Index; | ||
ui64 Granule; | ||
ui32 ColumnIdx; | ||
ui64 PlanStep; | ||
ui64 TxId; | ||
ui64 Portion; | ||
ui32 Chunk; | ||
}; | ||
|
||
using TKeyBatch = std::vector<TKey>; | ||
|
||
std::optional<std::vector<TKeyBatch>> KeysToDelete(NTabletFlatExecutor::TTransactionContext& txc, size_t maxBatchSize) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const size_t |
||
NIceDb::TNiceDb db(txc.DB); | ||
if (!Schema::Precharge<Schema::IndexColumns>(db, txc.DB.GetScheme())) { | ||
return std::nullopt; | ||
} | ||
std::vector<TKeyBatch> result; | ||
TKeyBatch currentBatch; | ||
auto rowset = db.Table<Schema::IndexColumns>().Select< | ||
Schema::IndexColumns::Index, | ||
Schema::IndexColumns::Granule, | ||
Schema::IndexColumns::ColumnIdx, | ||
Schema::IndexColumns::PlanStep, | ||
Schema::IndexColumns::TxId, | ||
Schema::IndexColumns::Portion, | ||
Schema::IndexColumns::Chunk | ||
>(); | ||
if (!rowset.IsReady()) { | ||
return std::nullopt; | ||
} | ||
while (!rowset.EndOfSet()) { | ||
if (rowset.GetValue<Schema::IndexColumns::ColumnIdx>() == ColumnIdxToDelete) { | ||
auto key = TKey { | ||
.Index = rowset.GetValue<Schema::IndexColumns::Index>(), | ||
.Granule = rowset.GetValue<Schema::IndexColumns::Granule>(), | ||
.ColumnIdx = rowset.GetValue<Schema::IndexColumns::ColumnIdx>(), | ||
.PlanStep = rowset.GetValue<Schema::IndexColumns::PlanStep>(), | ||
.Portion = rowset.GetValue<Schema::IndexColumns::Portion>(), | ||
.Chunk = rowset.GetValue<Schema::IndexColumns::Chunk>() | ||
}; | ||
currentBatch.emplace_back(std::move(key)); | ||
if (currentBatch.size() == maxBatchSize) { | ||
TKeyBatch newBatch; | ||
currentBatch.swap(newBatch); | ||
result.emplace_back(std::move(newBatch)); | ||
} | ||
} | ||
if (!rowset.Next()) { | ||
return std::nullopt; | ||
} | ||
} | ||
if (!currentBatch.empty()) { | ||
result.emplace_back(std::move(currentBatch)); | ||
} | ||
return result; | ||
} | ||
|
||
class TChanges : public INormalizerChanges { | ||
public: | ||
TChanges(TKeyBatch&& keys) | ||
: Keys(keys) | ||
{} | ||
bool ApplyOnExecute(NTabletFlatExecutor::TTransactionContext& txc, const TNormalizationController& /* normController */) const override { | ||
using namespace NColumnShard; | ||
NIceDb::TNiceDb db(txc.DB); | ||
for(const auto& k: Keys) { | ||
db.Table<Schema::IndexColumns>().Key( | ||
k.Index, | ||
k.Granule, | ||
k.ColumnIdx, | ||
k.PlanStep, | ||
k.TxId, | ||
k.Portion, | ||
k.Chunk | ||
).Delete(); | ||
|
||
} | ||
return true; | ||
} | ||
|
||
ui64 GetSize() const override { | ||
return 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. а это точно правильно? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. поправил |
||
} | ||
private: | ||
const TKeyBatch Keys; | ||
}; | ||
|
||
} //namespace | ||
|
||
TConclusion<std::vector<INormalizerTask::TPtr>> TDeleteUnsupportedSpecialColumnsNormalier::DoInit(const TNormalizationController& /*controller*/, NTabletFlatExecutor::TTransactionContext& txc) { | ||
using namespace NColumnShard; | ||
NIceDb::TNiceDb db(txc.DB); | ||
const size_t MaxBatchSize = 10000; | ||
auto keysToDelete = KeysToDelete(txc, MaxBatchSize); | ||
if (!keysToDelete) { | ||
return TConclusionStatus::Fail("Not ready"); | ||
} | ||
|
||
std::vector<INormalizerTask::TPtr> result; | ||
for (auto&& batch: *keysToDelete) { | ||
AFL_VERIFY(!batch.empty()); | ||
result.emplace_back(std::make_shared<TTrivialNormalizerTask>( | ||
std::make_shared<TChanges>(std::move(std::move(batch))) | ||
)); | ||
} | ||
return result; | ||
} | ||
|
||
} //namespace NKikimr::NOlap |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <ydb/core/tx/columnshard/normalizer/abstract/abstract.h> | ||
#include <ydb/core/tx/columnshard/columnshard_schema.h> | ||
|
||
|
||
namespace NKikimr::NOlap { | ||
|
||
class TDeleteUnsupportedSpecialColumnsNormalier: public TNormalizationController::INormalizerComponent { | ||
using TThisClass = TDeleteUnsupportedSpecialColumnsNormalier; | ||
static constexpr auto TypeId = ENormalizerSequentialId::DeleteUnsupportedSpecialColumns; | ||
static inline auto Registrator = INormalizerComponent::TFactory::TRegistrator<TThisClass>(TypeId); | ||
public: | ||
TDeleteUnsupportedSpecialColumnsNormalier(const TNormalizationController::TInitContext&) | ||
{} | ||
|
||
virtual ENormalizerSequentialId GetType() const override { | ||
return TypeId; | ||
} | ||
|
||
virtual TConclusion<std::vector<INormalizerTask::TPtr>> DoInit(const TNormalizationController& controller, NTabletFlatExecutor::TTransactionContext& txc) override; | ||
}; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
LIBRARY() | ||
|
||
SRCS( | ||
GLOBAL normalizer.cpp | ||
) | ||
|
||
PEERDIR( | ||
ydb/core/tx/columnshard/normalizer/abstract | ||
) | ||
|
||
END() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
здесь я бы не добавлял. может не упасть там где надо
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В каком случае?