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

fixes #767 correct allocation issue in native maps #769

Merged
merged 1 commit into from Nov 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions server/native/src/main/c++/nativeMap/NativeMap.h
Expand Up @@ -130,21 +130,23 @@ struct NativeMap : public NativeMapData {
}

ColumnMap *startUpdate(const char *r){

Field row(lba, r);
return startUpdate(row);
}

ColumnMap *startUpdate(Field &row){
//cout << "Starting update "<<row.toString()<<endl;

pair<RowMap::iterator, bool> insertResult = rowmap.insert(pair<Field, ColumnMap>(row, ColumnMap(std::less<SubKey>(), BlockAllocator<std::pair<SubKey, Field> >(lba))));

if(!insertResult.second)
// This method is structured to avoid allocating the column map in the case
// where it already exists in the map. This is done so the row key memory can
// be easily deallocated.
RowMap::iterator lbi = rowmap.lower_bound(row);
if(lbi == rowmap.end() || row < lbi->first) {
RowMap::iterator iter = rowmap.insert(lbi, pair<Field, ColumnMap>(row, ColumnMap(std::less<SubKey>(), BlockAllocator<std::pair<SubKey, Field> >(lba))));
return &(iter->second);
} else {
// Return row memory because an insert was not done.
row.clear(lba);

return &(insertResult.first->second);

return &(lbi->second);
}
}

void update(ColumnMap *cm, JNIEnv *env, jbyteArray cf, jbyteArray cq, jbyteArray cv, jlong ts, jboolean del, jbyteArray val, jint mutationCount){
Expand Down