ctubbsii closed pull request #769: fixes #767 correct allocation issue in 
native maps
URL: https://github.com/apache/accumulo/pull/769
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to