Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
fix clang
  • Loading branch information
hououou committed Mar 20, 2024
1 parent 1c18f92 commit 42f0763
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 248 deletions.
4 changes: 2 additions & 2 deletions src/include/storage/store/column.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ class Column {
const ColumnChunkMetadata& metadata, const offset_to_row_idx_t& insertInfo);
bool isMaxOffsetOutOfPagesCapacity(
const ColumnChunkMetadata& metadata, common::offset_t maxOffset);
virtual bool checkUpdateInPlace(const ColumnChunkMetadata& metadata, const ChunkCollection& localChunks,
const offset_to_row_idx_t& writeInfo);
virtual bool checkUpdateInPlace(const ColumnChunkMetadata& metadata,
const ChunkCollection& localChunks, const offset_to_row_idx_t& writeInfo);
virtual bool canCommitInPlace(transaction::Transaction* transaction,
common::node_group_idx_t nodeGroupIdx, const ChunkCollection& localInsertChunks,
const offset_to_row_idx_t& insertInfo, const ChunkCollection& localUpdateChunks,
Expand Down
23 changes: 3 additions & 20 deletions src/include/storage/store/var_list_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ struct VarListInfo {
std::unique_ptr<ChunkCollection> sizeInsertChunkCollection,
std::unique_ptr<ChunkCollection> offsetUpdateChunkCollection,
std::unique_ptr<ChunkCollection> offsetInsertChunkCollection)
: totalListNum{totalListNum},
dataInsertUpdateChunkCollection{std::move(dataInsertUpdateChunkCollection)},
: totalListNum{totalListNum}, dataInsertUpdateChunkCollection{std::move(
dataInsertUpdateChunkCollection)},
sizeUpdateChunkCollection{std::move(sizeUpdateChunkCollection)},
sizeInsertChunkCollection{std::move(sizeInsertChunkCollection)},
offsetUpdateChunkCollection{std::move(offsetUpdateChunkCollection)},
Expand Down Expand Up @@ -99,23 +99,6 @@ class VarListColumn : public Column {
void scanFiltered(transaction::Transaction* transaction, common::node_group_idx_t nodeGroupIdx,
common::ValueVector* offsetVector, const ListOffsetSizeInfo& listOffsetInfoInStorage);

void commitOffsetLocalChunkOutOfPlace(transaction::Transaction* transaction, common::node_group_idx_t nodeGroupIdx,
bool isNewNodeGroup, const ChunkCollection& localInsertChunks,
const offset_to_row_idx_t& insertInfo, const ChunkCollection& localUpdateChunks,
const offset_to_row_idx_t& updateInfo, const offset_set_t& deleteInfo);

VarListInfo getVarListInfoForPrepareCommit(transaction::Transaction* transaction,common::node_group_idx_t nodeGroupIdx, const ChunkCollection& localInsertChunks,
const offset_to_row_idx_t& insertInfo, const ChunkCollection& localUpdateChunks,
const offset_to_row_idx_t& updateInfo);

void dataLocalChunkInPlaceCommit(common::node_group_idx_t nodeGroupIdx,
const ChunkCollection& localChunks);
void dataLocalChunkOutPlaceCommit(transaction::Transaction* transaction,
common::node_group_idx_t nodeGroupIdx, const ChunkCollection& localChunks);
bool canDataInPlaceCommit(transaction::Transaction* transaction,
common::node_group_idx_t nodeGroupIdx, const ChunkCollection& localChunks,
const common::offset_t totalListNum);

void checkpointInMemory() final;
void rollbackInMemory() final;

Expand All @@ -133,7 +116,7 @@ class VarListColumn : public Column {
common::node_group_idx_t nodeGroupIdx, const ChunkCollection& localInsertChunks,
const offset_to_row_idx_t& insertInfo, const ChunkCollection& localUpdateChunks,
const offset_to_row_idx_t& updateInfo, const offset_set_t& deleteInfo) override;
void prepareCommitForChunk(transaction::Transaction* transaction,
void prepareCommitForChunk(transaction::Transaction* transaction,
common::node_group_idx_t nodeGroupIdx, const std::vector<common::offset_t>& dstOffsets,
ColumnChunk* chunk, common::offset_t startSrcOffset) override;

Expand Down
7 changes: 5 additions & 2 deletions src/storage/store/column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,9 @@ void Column::commitColumnChunkOutOfPlace(Transaction* transaction, node_group_id
auto chunkMeta = getMetadata(nodeGroupIdx, transaction->getType());
// TODO(Guodong): Should consider caching the scanned column chunk to avoid redundant
// scans in the same transaction.
auto columnChunk = getEmptyChunkForCommit(chunkMeta.numValues + dstOffsets.size());
auto columnChunk =
getEmptyChunkForCommit(4 * std::bit_ceil(chunkMeta.numValues + dstOffsets.size()));
auto a = columnChunk->getCapacity();
scan(transaction, nodeGroupIdx, columnChunk.get());
for (auto i = 0u; i < dstOffsets.size(); i++) {
columnChunk->write(chunk, srcOffset + i, dstOffsets[i], 1 /* numValues */);
Expand All @@ -807,7 +809,8 @@ void Column::applyLocalChunkToColumnChunk(const ChunkCollection& localChunks,
for (auto& [offsetInDstChunk, rowIdx] : updateInfo) {
auto [chunkIdx, offsetInLocalChunk] =
LocalChunkedGroupCollection::getChunkIdxAndOffsetInChunk(rowIdx);
KU_ASSERT(localChunks[chunkIdx]->getDataType().getLogicalTypeID()==columnChunk->getDataType().getLogicalTypeID());
KU_ASSERT(localChunks[chunkIdx]->getDataType().getLogicalTypeID() ==
columnChunk->getDataType().getLogicalTypeID());
columnChunk->write(
localChunks[chunkIdx], offsetInLocalChunk, offsetInDstChunk, 1 /* numValues */);
}
Expand Down
5 changes: 5 additions & 0 deletions src/storage/store/column_chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@ bool ColumnChunk::numValuesSanityCheck() const {

bool ColumnChunk::sanityCheck() {
if (nullChunk) {
auto a = nullChunk->sanityCheck();
auto b = numValuesSanityCheck();
if (a != b) {
KU_UNREACHABLE;
}
return nullChunk->sanityCheck() && numValuesSanityCheck();
}
return numValues <= capacity;
Expand Down
2 changes: 1 addition & 1 deletion src/storage/store/string_column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ bool StringColumn::canCommitInPlace(Transaction* transaction, node_group_idx_t n
auto strChunk = ku_dynamic_cast<ColumnChunk*, StringColumnChunk*>(chunk);
auto length = std::min((uint64_t)dstOffsets.size(), strChunk->getNumValues());
for (auto i = 0u; i < length; i++) {
if (strChunk->getNullChunk()->isNull(i)) { //TODO(Jiamin): i should be i + srcOffset?
if (strChunk->getNullChunk()->isNull(i)) { // TODO(Jiamin): i should be i + srcOffset?
continue;
}
strLenToAdd += strChunk->getStringLength(i + srcOffset);
Expand Down
Loading

0 comments on commit 42f0763

Please sign in to comment.