You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-12-17 01:02:23 +03:00
Modify write to correctly set length on new object creation.
This commit is contained in:
@@ -319,15 +319,15 @@ int IOCoordinator::_write(const char *filename, const uint8_t *data, off_t offse
|
|||||||
// there is no overlapping data, or data goes beyond end of last object
|
// there is no overlapping data, or data goes beyond end of last object
|
||||||
while (dataRemaining > 0)
|
while (dataRemaining > 0)
|
||||||
{
|
{
|
||||||
metadataObject newObject = metadata.addMetadataObject(filename,0);
|
off_t newObjectOffset = metadata.getMetadataNewObjectOffset();
|
||||||
// count is 0 so first write is beyond current end of file.
|
// count is 0 so first write is beyond current end of file.
|
||||||
// offset is > than newObject.offset so we need to adjust offset for object
|
// offset is > than newObject.offset so we need to adjust offset for object
|
||||||
// unless offset is beyond newObject.offset + objectSize then we need to write null data to this object
|
// unless offset is beyond newObject.offset + objectSize then we need to write null data to this object
|
||||||
if (count == 0 && (uint64_t) offset > newObject.offset)
|
if (count == 0 && offset > newObjectOffset)
|
||||||
{
|
{
|
||||||
//this is starting beyond last object in metadata
|
//this is starting beyond last object in metadata
|
||||||
//figure out if the offset is in this object
|
//figure out if the offset is in this object
|
||||||
objectOffset = offset - newObject.offset;
|
objectOffset = offset - newObjectOffset;
|
||||||
writeLength = min((objectSize - objectOffset),dataRemaining);
|
writeLength = min((objectSize - objectOffset),dataRemaining);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -341,8 +341,8 @@ int IOCoordinator::_write(const char *filename, const uint8_t *data, off_t offse
|
|||||||
// objectOffset is 0 unless the write starts beyond the end of data
|
// objectOffset is 0 unless the write starts beyond the end of data
|
||||||
// in that case need to add the null data to cachespace
|
// in that case need to add the null data to cachespace
|
||||||
cache->makeSpace(writeLength + objectOffset);
|
cache->makeSpace(writeLength + objectOffset);
|
||||||
if ((writeLength + objectOffset) > newObject.length)
|
|
||||||
metadata.updateEntryLength(newObject.offset, (writeLength + objectOffset));
|
metadataObject newObject = metadata.addMetadataObject(filename,(writeLength + objectOffset));
|
||||||
|
|
||||||
// send to replicator
|
// send to replicator
|
||||||
err = replicator->newObject(newObject.key.c_str(),&data[count],objectOffset,writeLength);
|
err = replicator->newObject(newObject.key.c_str(),&data[count],objectOffset,writeLength);
|
||||||
|
|||||||
@@ -445,6 +445,18 @@ void MetadataFile::updateEntryLength(off_t offset, size_t newLength)
|
|||||||
updateObj->length = newLength;
|
updateObj->length = newLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
off_t MetadataFile::getMetadataNewObjectOffset()
|
||||||
|
{
|
||||||
|
off_t newObjectOffset = 0;
|
||||||
|
if (!mObjects.empty())
|
||||||
|
{
|
||||||
|
std::set<metadataObject>::reverse_iterator iLastObject = mObjects.rbegin();
|
||||||
|
newObjectOffset = iLastObject->offset + iLastObject->length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newObjectOffset;
|
||||||
|
}
|
||||||
|
|
||||||
metadataObject::metadataObject()
|
metadataObject::metadataObject()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ class MetadataFile
|
|||||||
// breaks a key into its consitituent fields
|
// breaks a key into its consitituent fields
|
||||||
static void breakout(const std::string &key, std::vector<std::string> &out);
|
static void breakout(const std::string &key, std::vector<std::string> &out);
|
||||||
|
|
||||||
|
off_t getMetadataNewObjectOffset();
|
||||||
// this will be a singleton, which stores the config used
|
// this will be a singleton, which stores the config used
|
||||||
// by all MetadataFile instances so we don't have to keep bothering Config.
|
// by all MetadataFile instances so we don't have to keep bothering Config.
|
||||||
// members are public b/c i don't want to write accessors right now. Also who cares.
|
// members are public b/c i don't want to write accessors right now. Also who cares.
|
||||||
|
|||||||
Reference in New Issue
Block a user