Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 1092 #1144

Merged
merged 1 commit into from
Jan 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/storage/storage_structure/in_mem_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace storage {

InMemFile::InMemFile(
string filePath, uint16_t numBytesForElement, bool hasNullMask, uint64_t numPages)
: filePath{move(filePath)}, numBytesForElement{numBytesForElement}, hasNullMask{hasNullMask} {
: filePath{std::move(filePath)}, numBytesForElement{numBytesForElement}, hasNullMask{
hasNullMask} {
numElementsInAPage = PageUtils::getNumElementsInAPage(numBytesForElement, hasNullMask);
for (auto i = 0u; i < numPages; i++) {
addANewPage();
Expand Down Expand Up @@ -94,6 +95,7 @@ template<DataTypeID DT>
void InMemOverflowFile::copyVarSizedValuesToPages(ku_list_t& resultKUList,
const Literal& listLiteral, PageByteCursor& overflowCursor, uint64_t numBytesOfListElement) {
assert(DT == STRING || DT == LIST);
auto overflowPageIdx = overflowCursor.pageIdx;
auto overflowPageOffset = overflowCursor.offsetInPage;
// Reserve space for ku_list or ku_string objects.
overflowCursor.offsetInPage += (resultKUList.size * numBytesOfListElement);
Expand All @@ -105,7 +107,7 @@ void InMemOverflowFile::copyVarSizedValuesToPages(ku_list_t& resultKUList,
}
shared_lock lck(lock);
for (auto i = 0u; i < listLiteral.listVal.size(); i++) {
pages[overflowCursor.pageIdx]->write(overflowPageOffset + (i * numBytesOfListElement),
pages[overflowPageIdx]->write(overflowPageOffset + (i * numBytesOfListElement),
overflowPageOffset + (i * numBytesOfListElement), (uint8_t*)&kuStrings[i],
numBytesOfListElement);
}
Expand All @@ -117,7 +119,7 @@ void InMemOverflowFile::copyVarSizedValuesToPages(ku_list_t& resultKUList,
}
shared_lock lck(lock);
for (auto i = 0u; i < listLiteral.listVal.size(); i++) {
pages[overflowCursor.pageIdx]->write(overflowPageOffset + (i * numBytesOfListElement),
pages[overflowPageIdx]->write(overflowPageOffset + (i * numBytesOfListElement),
overflowPageOffset + (i * numBytesOfListElement), (uint8_t*)&kuLists[i],
numBytesOfListElement);
}
Expand All @@ -127,10 +129,9 @@ void InMemOverflowFile::copyVarSizedValuesToPages(ku_list_t& resultKUList,
}

ku_list_t InMemOverflowFile::copyList(const Literal& listLiteral, PageByteCursor& overflowCursor) {
assert(listLiteral.dataType.typeID == LIST && !listLiteral.listVal.empty());
assert(listLiteral.dataType.typeID == LIST);
ku_list_t resultKUList;
auto childDataTypeID = listLiteral.listVal[0].dataType.typeID;
auto numBytesOfListElement = Types::getDataTypeSize(childDataTypeID);
auto numBytesOfListElement = Types::getDataTypeSize(*listLiteral.dataType.childType);
resultKUList.size = listLiteral.listVal.size();
// Allocate a new page if necessary.
if (overflowCursor.offsetInPage + (resultKUList.size * numBytesOfListElement) >=
Expand All @@ -141,7 +142,7 @@ ku_list_t InMemOverflowFile::copyList(const Literal& listLiteral, PageByteCursor
}
TypeUtils::encodeOverflowPtr(
resultKUList.overflowPtr, overflowCursor.pageIdx, overflowCursor.offsetInPage);
switch (childDataTypeID) {
switch (listLiteral.dataType.childType->typeID) {
case INT64:
case DOUBLE:
case BOOL:
Expand Down