Skip to content

Commit 3a4de79

Browse files
Fix addressing sparsed (#9382)
1 parent 0361036 commit 3a4de79

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

ydb/core/tx/columnshard/engines/changes/compaction/sparsed/logic.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ bool TSparsedMerger::TPlainChunkCursor::AddIndexTo(const ui32 index, TWriter& wr
134134

135135
bool TSparsedMerger::TSparsedChunkCursor::AddIndexTo(const ui32 index, TWriter& writer) {
136136
AFL_VERIFY(ChunkStartGlobalPosition <= index);
137-
AFL_VERIFY(index == NextGlobalPosition);
137+
AFL_VERIFY(index == NextGlobalPosition)("index", index)("next", NextGlobalPosition);
138138
writer.AddRealData(Chunk->GetColValue(), NextLocalPosition);
139139
return true;
140140
}
@@ -163,7 +163,9 @@ void TSparsedMerger::TCursor::InitArrays(const ui32 position) {
163163
PlainCursor = make_shared<TPlainChunkCursor>(CurrentOwnedArray->GetArray(), &*CurrentOwnedArray);
164164
SparsedCursor = nullptr;
165165
}
166+
AFL_VERIFY(CurrentOwnedArray->GetAddress().GetGlobalStartPosition() <= position);
166167
FinishGlobalPosition = CurrentOwnedArray->GetAddress().GetGlobalStartPosition() + CurrentOwnedArray->GetArray()->GetRecordsCount();
168+
AFL_VERIFY(position < FinishGlobalPosition);
167169
}
168170

169171
} // namespace NKikimr::NOlap::NCompaction

ydb/core/tx/columnshard/engines/changes/compaction/sparsed/logic.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,15 @@ class TSparsedMerger: public IColumnMerger {
5858

5959
void InitArrays(const ui32 position) {
6060
AFL_VERIFY(!ChunkAddress || ChunkFinishPosition <= position);
61-
ChunkAddress = CurrentChunkedArray->GetChunk(ChunkAddress, position);
61+
AFL_VERIFY(CurrentOwnedArray->GetAddress().GetGlobalStartPosition() <= position)("pos", position)(
62+
"global", CurrentOwnedArray->GetAddress().GetGlobalStartPosition());
63+
ChunkAddress = CurrentChunkedArray->GetChunk(ChunkAddress, position - CurrentOwnedArray->GetAddress().GetGlobalStartPosition());
6264
AFL_VERIFY(ChunkAddress);
6365
ChunkStartPosition = CurrentOwnedArray->GetAddress().GetGlobalStartPosition() + ChunkAddress->GetAddress().GetGlobalStartPosition();
6466
ChunkFinishPosition =
6567
CurrentOwnedArray->GetAddress().GetGlobalStartPosition() + ChunkAddress->GetAddress().GetGlobalFinishPosition();
68+
AFL_VERIFY(position < ChunkFinishPosition)("finish", ChunkFinishPosition)("pos", position);
69+
AFL_VERIFY(ChunkStartPosition <= position)("start", ChunkStartPosition)("pos", position);
6670
}
6771

6872
public:
@@ -76,14 +80,15 @@ class TSparsedMerger: public IColumnMerger {
7680
}
7781
bool AddIndexTo(const ui32 index, TWriter& writer);
7882
std::optional<ui32> MoveToSignificant(const ui32 currentGlobalPosition, const TColumnMergeContext& context) {
79-
AFL_VERIFY(ChunkStartPosition <= currentGlobalPosition);
83+
AFL_VERIFY(ChunkStartPosition <= currentGlobalPosition)("start", ChunkStartPosition)("pos", currentGlobalPosition)(
84+
"global_start", CurrentOwnedArray->GetAddress().GetGlobalStartPosition());
8085
ui32 currentIndex = currentGlobalPosition;
8186
while (true) {
8287
if (CurrentOwnedArray->GetAddress().GetGlobalFinishPosition() <= currentIndex) {
8388
return {};
8489
}
8590
if (ChunkFinishPosition <= currentIndex) {
86-
InitArrays(currentGlobalPosition);
91+
InitArrays(currentIndex);
8792
continue;
8893
}
8994
for (; currentIndex < ChunkFinishPosition; ++currentIndex) {
@@ -190,6 +195,7 @@ class TSparsedMerger: public IColumnMerger {
190195
if (FinishGlobalPosition == Array->GetRecordsCount()) {
191196
return FinishGlobalPosition;
192197
} else {
198+
currentPosition = FinishGlobalPosition;
193199
InitArrays(FinishGlobalPosition);
194200
}
195201
}

ydb/library/formats/arrow/accessor/abstract/accessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ std::shared_ptr<arrow::ChunkedArray> IChunkedArray::Slice(const ui32 offset, con
4545

4646
NKikimr::NArrow::NAccessor::IChunkedArray::TFullDataAddress IChunkedArray::GetChunk(
4747
const std::optional<TAddressChain>& chunkCurrent, const ui64 position) const {
48-
AFL_VERIFY(position < GetRecordsCount());
48+
AFL_VERIFY(position < GetRecordsCount())("pos", position)("records", GetRecordsCount())("current", chunkCurrent ? chunkCurrent->DebugString() : Default<TString>());
4949
std::optional<TCommonChunkAddress> address;
5050

5151
if (IsDataOwner()) {

ydb/library/formats/arrow/accessor/abstract/accessor.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,13 @@ class IChunkedArray {
104104
}
105105

106106
TString DebugString() const {
107-
return TStringBuilder() << "start=" << GlobalStartPosition << ";finish=" << GlobalFinishPosition
108-
<< ";addresses_count=" << Addresses.size() << ";";
107+
TStringBuilder sb;
108+
sb << "start=" << GlobalStartPosition << ";finish=" << GlobalFinishPosition
109+
<< ";addresses_count=" << Addresses.size() << ";";
110+
for (auto&& i : Addresses) {
111+
sb << "addresses=" << i.DebugString() << ";";
112+
}
113+
return sb;
109114
}
110115
};
111116

0 commit comments

Comments
 (0)