Skip to content

Commit 9e4dbfa

Browse files
committed
Revert "Speed up SIMPLE scanner (ydb-platform#12164)"
This reverts commit 6fc18f8.
1 parent 8bb4246 commit 9e4dbfa

36 files changed

+904
-633
lines changed

ydb/core/formats/arrow/accessor/plain/accessor.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ class TChunkAccessor {
4343
return (ui64)ChunkedArray->num_chunks();
4444
}
4545
ui64 GetChunkLength(const ui32 idx) const {
46-
return (ui64)ChunkedArray->chunks()[idx]->length();
46+
return (ui64)ChunkedArray->chunk(idx)->length();
4747
}
4848
void OnArray(const ui32 idx, const ui32 startPosition) const {
49-
*Result = IChunkedArray::TLocalDataAddress(ChunkedArray->chunk(idx), startPosition, idx);
49+
const auto& arr = ChunkedArray->chunk(idx);
50+
*Result = IChunkedArray::TLocalDataAddress(arr, startPosition, idx);
5051
}
5152
};
5253

ydb/core/tx/columnshard/columnshard_impl.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,8 +1424,11 @@ class TTxAskPortionChunks: public TTransactionBase<TColumnShard> {
14241424
for (auto&& i : PortionsByPath) {
14251425
AFL_INFO(NKikimrServices::TX_COLUMNSHARD)("event", "TTxAskPortionChunks::Execute")("size", i.second.size())("path_id", i.first);
14261426
for (auto&& p : i.second) {
1427-
if (!p->GetSchema(Self->GetIndexAs<NOlap::TColumnEngineForLogs>().GetVersionedIndex())->GetIndexesCount()) {
1428-
continue;
1427+
{
1428+
auto rowset = db.Table<NColumnShard::Schema::IndexColumnsV2>().Prefix(p->GetPathId(), p->GetPortionId()).Select();
1429+
if (!rowset.IsReady()) {
1430+
reask = true;
1431+
}
14291432
}
14301433
{
14311434
auto rowset = db.Table<NColumnShard::Schema::IndexIndexes>().Prefix(p->GetPathId(), p->GetPortionId()).Select();
@@ -1453,8 +1456,8 @@ class TTxAskPortionChunks: public TTransactionBase<TColumnShard> {
14531456
NOlap::TColumnChunkLoadContextV2 info(rowset);
14541457
constructor.SetRecords(std::move(info));
14551458
}
1456-
std::vector<NOlap::TIndexChunkLoadContext> indexes;
1457-
if (p->GetSchema(Self->GetIndexAs<NOlap::TColumnEngineForLogs>().GetVersionedIndex())->GetIndexesCount()) {
1459+
{
1460+
std::vector<NOlap::TIndexChunkLoadContext> indexes;
14581461
auto rowset = db.Table<NColumnShard::Schema::IndexIndexes>().Prefix(p->GetPathId(), p->GetPortionId()).Select();
14591462
if (!rowset.IsReady()) {
14601463
return false;
@@ -1465,8 +1468,8 @@ class TTxAskPortionChunks: public TTransactionBase<TColumnShard> {
14651468
return false;
14661469
}
14671470
}
1471+
constructor.SetIndexes(std::move(indexes));
14681472
}
1469-
constructor.SetIndexes(std::move(indexes));
14701473
FetchedAccessors.emplace_back(std::move(constructor));
14711474
i.second.pop_back();
14721475
}

ydb/core/tx/columnshard/data_accessor/request.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,10 @@ class TPathFetchingState {
141141
AFL_VERIFY(Portions.emplace(portion->GetPortionId(), portion).second);
142142
}
143143

144-
void AddAccessor(
145-
const TPortionDataAccessor& accessor, const std::optional<std::set<ui32>>& columnIds, const std::optional<std::set<ui32>>& indexIds) {
144+
void AddAccessor(const TPortionDataAccessor& accessor) {
146145
AFL_VERIFY(Stage == EFetchStage::Fetching);
147146
AFL_VERIFY(Portions.erase(accessor.GetPortionInfo().GetPortionId()));
148-
AFL_VERIFY(PortionAccessors.emplace(accessor.GetPortionInfo().GetPortionId(), accessor.Extract(columnIds, indexIds)).second);
147+
AFL_VERIFY(PortionAccessors.emplace(accessor.GetPortionInfo().GetPortionId(), accessor).second);
149148
if (Portions.empty()) {
150149
AFL_VERIFY(Stage == EFetchStage::Fetching);
151150
Stage = EFetchStage::Fetched;
@@ -173,8 +172,8 @@ class TDataAccessorsRequest: public NColumnShard::TMonitoringObjectsCounter<TDat
173172
THashMap<ui64, TPathFetchingState> PathIdStatus;
174173
THashSet<ui64> PathIds;
175174
TDataAccessorsResult AccessorsByPathId;
176-
YDB_READONLY_DEF(std::optional<std::set<ui32>>, ColumnIds);
177-
std::optional<std::set<ui32>> IndexIds;
175+
std::optional<std::vector<ui32>> ColumnIds;
176+
std::optional<std::vector<ui32>> IndexIds;
178177

179178
TAtomicCounter PreparingCount = 0;
180179
TAtomicCounter FetchingCount = 0;
@@ -194,11 +193,6 @@ class TDataAccessorsRequest: public NColumnShard::TMonitoringObjectsCounter<TDat
194193
}
195194

196195
public:
197-
void SetColumnIds(const std::set<ui32>& columnIds) {
198-
AFL_VERIFY(!ColumnIds);
199-
ColumnIds = columnIds;
200-
}
201-
202196
TString DebugString() const {
203197
TStringBuilder sb;
204198
sb << "request_id=" << RequestId << ";";
@@ -293,7 +287,7 @@ class TDataAccessorsRequest: public NColumnShard::TMonitoringObjectsCounter<TDat
293287
{
294288
auto itStatus = PathIdStatus.find(pathId);
295289
AFL_VERIFY(itStatus != PathIdStatus.end());
296-
itStatus->second.AddAccessor(accessor, ColumnIds, IndexIds);
290+
itStatus->second.AddAccessor(accessor);
297291
if (itStatus->second.IsFinished()) {
298292
AFL_VERIFY(FetchingCount.Dec() >= 0);
299293
ReadyCount.Inc();

ydb/core/tx/columnshard/engines/portions/data_accessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ TConclusion<std::shared_ptr<NArrow::TGeneralContainer>> TPortionDataAccessor::TP
779779
std::vector<std::shared_ptr<NArrow::NAccessor::IChunkedArray>> columns;
780780
std::vector<std::shared_ptr<arrow::Field>> fields;
781781
for (auto&& i : Columns) {
782-
// NActors::TLogContextGuard lGuard = NActors::TLogContextBuilder::Build()("column", i.GetField()->ToString())("column_id", i.GetColumnId());
782+
NActors::TLogContextGuard lGuard = NActors::TLogContextBuilder::Build()("column", i.GetField()->ToString())("id", i.GetColumnId());
783783
if (sequentialColumnIds.contains(i.GetColumnId())) {
784784
columns.emplace_back(i.AssembleForSeqAccess());
785785
} else {

ydb/core/tx/columnshard/engines/portions/data_accessor.h

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -45,61 +45,6 @@ class TPortionDataAccessor {
4545
(Indexes ? (Indexes->size() * sizeof(TIndexChunk)) : 0);
4646
}
4747

48-
class TExtractContext {
49-
private:
50-
YDB_ACCESSOR_DEF(std::optional<std::set<ui32>>, ColumnIds);
51-
YDB_ACCESSOR_DEF(std::optional<std::set<ui32>>, IndexIds);
52-
53-
public:
54-
TExtractContext() = default;
55-
};
56-
57-
TPortionDataAccessor Extract(const std::optional<std::set<ui32>>& columnIds, const std::optional<std::set<ui32>>& indexIds) const {
58-
return Extract(TExtractContext().SetColumnIds(columnIds).SetIndexIds(indexIds));
59-
}
60-
61-
TPortionDataAccessor Extract(const TExtractContext& context) const {
62-
AFL_VERIFY(Records);
63-
std::vector<TColumnRecord> extractedRecords;
64-
if (context.GetColumnIds()) {
65-
auto itRec = Records->begin();
66-
auto itExt = context.GetColumnIds()->begin();
67-
while (itRec != Records->end() && itExt != context.GetColumnIds()->end()) {
68-
if (itRec->GetEntityId() == *itExt) {
69-
extractedRecords.emplace_back(*itRec);
70-
++itRec;
71-
} else if (itRec->GetEntityId() < *itExt) {
72-
++itRec;
73-
} else {
74-
++itExt;
75-
}
76-
}
77-
} else {
78-
extractedRecords = *Records;
79-
}
80-
81-
AFL_VERIFY(Indexes);
82-
std::vector<TIndexChunk> extractedIndexes;
83-
if (context.GetIndexIds()) {
84-
auto itIdx = Indexes->begin();
85-
auto itExt = context.GetIndexIds()->begin();
86-
while (itIdx != Indexes->end() && itExt != context.GetIndexIds()->end()) {
87-
if (itIdx->GetEntityId() == *itExt) {
88-
extractedIndexes.emplace_back(*itIdx);
89-
++itIdx;
90-
} else if (itIdx->GetEntityId() < *itExt) {
91-
++itIdx;
92-
} else {
93-
++itExt;
94-
}
95-
}
96-
} else {
97-
extractedIndexes = *Indexes;
98-
}
99-
100-
return TPortionDataAccessor(PortionInfo, std::move(extractedRecords), std::move(extractedIndexes), false);
101-
}
102-
10348
const std::vector<TColumnRecord>& TestGetRecords() const {
10449
AFL_VERIFY(Records);
10550
return std::move(*Records);

ydb/core/tx/columnshard/engines/reader/actor/actor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ TColumnShardScan::TColumnShardScan(const TActorId& columnShardActorId, const TAc
7373
}
7474

7575
void TColumnShardScan::Bootstrap(const TActorContext& ctx) {
76-
// TLogContextGuard gLogging(NActors::TLogContextBuilder::Build(NKikimrServices::TX_COLUMNSHARD_SCAN) ("SelfId", SelfId())(
77-
// "TabletId", TabletId)("ScanId", ScanId)("TxId", TxId)("ScanGen", ScanGen));
76+
TLogContextGuard gLogging(NActors::TLogContextBuilder::Build(NKikimrServices::TX_COLUMNSHARD_SCAN) ("SelfId", SelfId())(
77+
"TabletId", TabletId)("ScanId", ScanId)("TxId", TxId)("ScanGen", ScanGen));
7878
auto g = Stats->MakeGuard("bootstrap");
7979
ScanActorId = ctx.SelfID;
8080

ydb/core/tx/columnshard/engines/reader/common_reader/iterator/fetched_data.cpp

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)