Skip to content

ColumnString avoid memory copy #197

Description

@1261385937
void ColumnString::Append(std::string_view str) {
    if (blocks_.size() == 0 || blocks_.back().GetAvailble() < str.length())
    {
        blocks_.emplace_back(std::max(DEFAULT_BLOCK_SIZE, str.size()));
    }

    items_.emplace_back(blocks_.back().AppendUnsafe(str));
}

Always cpoy the str into the Block, this is not necessary. We can move the data into std::queue<std::string> if the str is not useful any more.
I remeber a previous version use the std::vector<std::string> to hold the str, but also use the cpoy. The code like :

void ColumnString::Append(const std::string& str) {
       data_.push_back(str)
}

some advantage that i missed ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions