Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 88cafd2

Browse files
authored
Update Kuzu from branch master (#156)
Co-authored-by: mewim <14037726+mewim@users.noreply.github.com>
1 parent 3c8e067 commit 88cafd2

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

Sources/cxx-kuzu/kuzu/src/storage/table/column_chunk_data.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,11 @@ void ColumnChunkData::setToOnDisk(const ColumnChunkMetadata& otherMetadata) {
334334

335335
ColumnChunkMetadata ColumnChunkData::flushBuffer(PageAllocator& pageAllocator,
336336
const PageRange& entry, const ColumnChunkMetadata& otherMetadata) const {
337-
if (!otherMetadata.compMeta.isConstant() && getBufferSize(numValues) != 0) {
338-
return flushBufferFunction(buffer->getBuffer(), pageAllocator.getDataFH(), entry,
339-
otherMetadata);
337+
const auto bufferSizeToFlush = getBufferSize(numValues);
338+
if (!otherMetadata.compMeta.isConstant() && bufferSizeToFlush != 0) {
339+
KU_ASSERT(bufferSizeToFlush <= buffer->getBuffer().size_bytes());
340+
const auto bufferToFlush = buffer->getBuffer().subspan(0, bufferSizeToFlush);
341+
return flushBufferFunction(bufferToFlush, pageAllocator.getDataFH(), entry, otherMetadata);
340342
}
341343
KU_ASSERT(otherMetadata.getNumPages() == 0);
342344
return otherMetadata;

Sources/cxx-kuzu/kuzu/src/storage/table/compression_flush_buffer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ using namespace transaction;
1515
ColumnChunkMetadata uncompressedFlushBuffer(std::span<const uint8_t> buffer, FileHandle* dataFH,
1616
const PageRange& entry, const ColumnChunkMetadata& metadata) {
1717
KU_ASSERT(dataFH->getNumPages() >= entry.startPageIdx + entry.numPages);
18+
KU_ASSERT(buffer.size_bytes() <= entry.numPages * KUZU_PAGE_SIZE);
1819
dataFH->writePagesToFile(buffer.data(), buffer.size(), entry.startPageIdx);
1920
return ColumnChunkMetadata(entry.startPageIdx, entry.numPages, metadata.numValues,
2021
metadata.compMeta);

Sources/cxx-kuzu/kuzu/src/storage/table/string_column.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,14 @@ void StringColumn::scanSegment(const SegmentState& state, ColumnChunkData* resul
149149
auto* indexChunk = stringResultChunk->getIndexColumnChunk();
150150
indexColumn->scanSegment(getChildState(state, ChildStateIndex::INDEX), indexChunk,
151151
startOffsetInSegment, numValuesToScan);
152+
153+
const auto initialDictSize =
154+
stringResultChunk->getDictionaryChunk().getOffsetChunk()->getNumValues();
152155
if (numValuesToScan == state.metadata.numValues) {
153156
// Append the entire dictionary into the chunk
154157
// Since the resultChunk may be non-empty, each index needs to be incremented by the initial
155158
// size of the dictionary so that the indices line up with the values that will be scanned
156159
// into the dictionary chunk
157-
auto initialDictSize =
158-
stringResultChunk->getDictionaryChunk().getOffsetChunk()->getNumValues();
159160
for (row_idx_t i = 0; i < numValuesToScan; i++) {
160161
indexChunk->setValue<string_index_t>(
161162
indexChunk->getValue<string_index_t>(startOffsetInResult + i) + initialDictSize,
@@ -172,11 +173,10 @@ void StringColumn::scanSegment(const SegmentState& state, ColumnChunkData* resul
172173
auto index = indexChunk->getValue<string_index_t>(startOffsetInResult + i);
173174
auto element = indexMap.find(index);
174175
if (element == indexMap.end()) {
175-
indexMap.insert(
176-
std::make_pair(index, startOffsetInResult + offsetsToScan.size()));
177-
indexChunk->setValue<string_index_t>(startOffsetInResult + offsetsToScan.size(),
176+
indexMap.insert(std::make_pair(index, initialDictSize + offsetsToScan.size()));
177+
indexChunk->setValue<string_index_t>(initialDictSize + offsetsToScan.size(),
178178
startOffsetInResult + i);
179-
offsetsToScan.emplace_back(index, startOffsetInResult + offsetsToScan.size());
179+
offsetsToScan.emplace_back(index, initialDictSize + offsetsToScan.size());
180180
} else {
181181
indexChunk->setValue<string_index_t>(element->second, startOffsetInResult + i);
182182
}

0 commit comments

Comments
 (0)