Skip to content

Commit 598b5ee

Browse files
incapsulate sharding logic into special class and remove declaration … (#3964)
1 parent 51118c5 commit 598b5ee

17 files changed

+278
-228
lines changed

ydb/core/kqp/ut/olap/kqp_olap_ut.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
14241424
auto sender = runtime->AllocateEdgeActor();
14251425

14261426
InitRoot(server, sender);
1427-
Tests::NCommon::TLoggerInit(runtime).Initialize();
1427+
// Tests::NCommon::TLoggerInit(runtime).Initialize();
14281428

14291429
ui32 numShards = NSan::PlainOrUnderSanitizer(1000, 10);
14301430
ui32 numIterations = NSan::PlainOrUnderSanitizer(50, 10);
@@ -1554,7 +1554,7 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
15541554
auto sender = runtime->AllocateEdgeActor();
15551555

15561556
InitRoot(server, sender);
1557-
Tests::NCommon::TLoggerInit(runtime).Initialize();
1557+
// Tests::NCommon::TLoggerInit(runtime).Initialize();
15581558

15591559
ui32 numShards = NSan::PlainOrUnderSanitizer(100, 10);
15601560
ui32 numIterations = NSan::PlainOrUnderSanitizer(100, 10);

ydb/core/tx/data_events/columnshard_splitter.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,22 @@ NKikimr::NEvWrite::IShardsSplitter::TYdbConclusionStatus TColumnShardShardsSplit
4545
}
4646
}
4747

48-
return SplitImpl(batch, sharding);
49-
}
50-
51-
NKikimr::NEvWrite::IShardsSplitter::TYdbConclusionStatus TColumnShardShardsSplitter::SplitImpl(const std::shared_ptr<arrow::RecordBatch>& batch, const NKikimrSchemeOp::TColumnTableSharding& descSharding) {
52-
Y_ABORT_UNLESS(batch);
53-
54-
const std::vector<ui64> tabletIds(descSharding.GetColumnShards().begin(), descSharding.GetColumnShards().end());
55-
auto shardingConclusion = NSharding::TShardingBase::BuildShardingOperator(descSharding);
48+
NSchemeShard::TOlapSchema olapSchema;
49+
olapSchema.ParseFromLocalDB(scheme);
50+
auto shardingConclusion = NSharding::TShardingBase::BuildFromProto(olapSchema, sharding);
5651
if (shardingConclusion.IsFail()) {
5752
return TYdbConclusionStatus::Fail(Ydb::StatusIds::SCHEME_ERROR, shardingConclusion.GetErrorMessage());
5853
}
5954
AFL_VERIFY(!!shardingConclusion.GetResult());
60-
auto sharding = shardingConclusion.DetachResult();
61-
auto split = sharding->SplitByShards(batch, tabletIds, NColumnShard::TLimits::GetMaxBlobSize() * 0.875);
55+
return SplitImpl(batch, shardingConclusion.DetachResult());
56+
}
57+
58+
NKikimr::NEvWrite::IShardsSplitter::TYdbConclusionStatus TColumnShardShardsSplitter::SplitImpl(const std::shared_ptr<arrow::RecordBatch>& batch,
59+
const std::shared_ptr<NSharding::TShardingBase>& sharding)
60+
{
61+
Y_ABORT_UNLESS(batch);
62+
63+
auto split = sharding->SplitByShards(batch, NColumnShard::TLimits::GetMaxBlobSize() * 0.875);
6264
if (split.IsFail()) {
6365
return TYdbConclusionStatus::Fail(Ydb::StatusIds::SCHEME_ERROR, split.GetErrorMessage());
6466
}

ydb/core/tx/data_events/columnshard_splitter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class TColumnShardShardsSplitter : public IShardsSplitter {
4545
TYdbConclusionStatus DoSplitData(const NSchemeCache::TSchemeCacheNavigate::TEntry& schemeEntry, const IEvWriteDataAccessor& data) override;
4646

4747
private:
48-
TYdbConclusionStatus SplitImpl(const std::shared_ptr<arrow::RecordBatch>& batch, const NKikimrSchemeOp::TColumnTableSharding& descSharding);
48+
TYdbConclusionStatus SplitImpl(const std::shared_ptr<arrow::RecordBatch>& batch, const std::shared_ptr<NSharding::TShardingBase>& sharding);
4949

5050
std::shared_ptr<arrow::Schema> ExtractArrowSchema(const NKikimrSchemeOp::TColumnTableSchema& schema);
5151
};

ydb/core/tx/schemeshard/olap/operations/alter_table.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,8 @@ class TAlterColumnTable: public TSubOperation {
538538
}
539539

540540
TOlapStoreInfo::TPtr storeInfo;
541-
if (tableInfo->OlapStorePathId) {
542-
auto& storePathId = *tableInfo->OlapStorePathId;
541+
if (!tableInfo->IsStandalone()) {
542+
const auto storePathId = tableInfo->GetOlapStorePathIdVerified();
543543
TPath storePath = TPath::Init(storePathId, context.SS);
544544
{
545545
TPath::TChecker checks = storePath.Check();
@@ -593,7 +593,7 @@ class TAlterColumnTable: public TSubOperation {
593593
context.SS->PersistLastTxId(db, path.Base());
594594

595595
if (storeInfo) {
596-
auto& storePathId = *tableInfo->OlapStorePathId;
596+
const auto storePathId = tableInfo->GetOlapStorePathIdVerified();
597597
TPath storePath = TPath::Init(storePathId, context.SS);
598598

599599
Y_ABORT_UNLESS(storeInfo->ColumnTables.contains(path->PathId));

0 commit comments

Comments
 (0)