public static Put mergePuts ( byte [ ] keyBytes , List < Put > putList ) { Put put = new Put ( keyBytes ) ; for ( Put putToMerge : putList ) { Map < byte [ ] , List < KeyValue > > familyMap = ( Map < byte [ ] , List < KeyValue > > ) GET_FAMILY_MAP_METHOD . invoke ( putToMerge ) ; for ( List < KeyValue > keyValueList : familyMap . values ( ) ) { for ( KeyValue keyValue : keyValueList ) { // don't use put.add(KeyValue) since it doesn't work with HBase 0.96 onwards put . add ( keyValue . getFamily ( ) , keyValue . getQualifier ( ) , keyValue . getTimestamp ( ) , keyValue . getValue ( ) ) ; } } } return put ; }
Given a list of puts create a new put with the values in each put merged together . It is expected that no puts have a value for the same fully qualified column . Return the new put .