public static CounterMap parseCounters ( byte [ ] prefix , Map < byte [ ] , byte [ ] > keyValues ) { CounterMap counterValues = new CounterMap ( ) ; byte [ ] counterPrefix = Bytes . add ( prefix , Constants . SEP_BYTES ) ; for ( Map . Entry < byte [ ] , byte [ ] > entry : keyValues . entrySet ( ) ) { byte [ ] key = entry . getKey ( ) ; if ( Bytes . startsWith ( key , counterPrefix ) && key . length > counterPrefix . length ) { // qualifier should be in the format: g!countergroup!counterkey byte [ ] [ ] qualifierFields = ByteUtil . split ( Bytes . tail ( key , key . length - counterPrefix . length ) , Constants . SEP_BYTES ) ; if ( qualifierFields . length != 2 ) { throw new IllegalArgumentException ( "Malformed column qualifier for counter value: " + Bytes . toStringBinary ( key ) ) ; } Counter c = new Counter ( Bytes . toString ( qualifierFields [ 0 ] ) , Bytes . toString ( qualifierFields [ 1 ] ) , Bytes . toLong ( entry . getValue ( ) ) ) ; counterValues . add ( c ) ; } } return counterValues ; }
Converts encoded key values back into counter objects .