accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [accumulo] branch 1.9 updated: fixes #767 correct allocation issue in native maps (#769)
Date Thu, 15 Nov 2018 23:35:49 GMT
This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch 1.9
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/1.9 by this push:
     new df1061b  fixes #767 correct allocation issue in native maps (#769)
df1061b is described below

commit df1061b79cd3be716567e3ecbc595126036d517f
Author: Keith Turner <kturner@apache.org>
AuthorDate: Thu Nov 15 18:35:45 2018 -0500

    fixes #767 correct allocation issue in native maps (#769)
    
    This fixes a bug that was found when building the native maps against
    Fedora 29.  The cause of the bug was that an empty C++ map seemed to
    allocate a small amount of memory, which was a new behavior.  This new
    behavior violated an assumption made by the custom alloctor used by the
    native map code.  The code was restructured to avoid this issue.
---
 server/native/src/main/c++/nativeMap/NativeMap.h | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/server/native/src/main/c++/nativeMap/NativeMap.h b/server/native/src/main/c++/nativeMap/NativeMap.h
index bc44a98..5934e2e 100644
--- a/server/native/src/main/c++/nativeMap/NativeMap.h
+++ b/server/native/src/main/c++/nativeMap/NativeMap.h
@@ -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){


Mime
View raw message