Search in sources :

Example 1 with EnumLite

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.Internal.EnumLite in project hbase by apache.

the class AbstractMessage method hashFields.

/** Get a hash code for given fields and values, using the given seed. */
@SuppressWarnings("unchecked")
protected static int hashFields(int hash, Map<FieldDescriptor, Object> map) {
    for (Map.Entry<FieldDescriptor, Object> entry : map.entrySet()) {
        FieldDescriptor field = entry.getKey();
        Object value = entry.getValue();
        hash = (37 * hash) + field.getNumber();
        if (field.isMapField()) {
            hash = (53 * hash) + hashMapField(value);
        } else if (field.getType() != FieldDescriptor.Type.ENUM) {
            hash = (53 * hash) + value.hashCode();
        } else if (field.isRepeated()) {
            List<? extends EnumLite> list = (List<? extends EnumLite>) value;
            hash = (53 * hash) + Internal.hashEnumList(list);
        } else {
            hash = (53 * hash) + Internal.hashEnum((EnumLite) value);
        }
    }
    return hash;
}
Also used : EnumLite(org.apache.hadoop.hbase.shaded.com.google.protobuf.Internal.EnumLite) List(java.util.List) Map(java.util.Map) HashMap(java.util.HashMap) FieldDescriptor(org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.FieldDescriptor)

Aggregations

HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 FieldDescriptor (org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.FieldDescriptor)1 EnumLite (org.apache.hadoop.hbase.shaded.com.google.protobuf.Internal.EnumLite)1