use of org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.FieldDescriptor 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;
}
use of org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.FieldDescriptor in project hbase by apache.
the class DynamicMessage method hasOneof.
@Override
public boolean hasOneof(OneofDescriptor oneof) {
verifyOneofContainingType(oneof);
FieldDescriptor field = oneofCases[oneof.getIndex()];
if (field == null) {
return false;
}
return true;
}
use of org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.FieldDescriptor in project hbase by apache.
the class ExtensionRegistry method add.
private void add(final ExtensionInfo extension, final Extension.ExtensionType extensionType) {
if (!extension.descriptor.isExtension()) {
throw new IllegalArgumentException("ExtensionRegistry.add() was given a FieldDescriptor for a regular " + "(non-extension) field.");
}
Map<String, ExtensionInfo> extensionsByName;
Map<DescriptorIntPair, ExtensionInfo> extensionsByNumber;
switch(extensionType) {
case IMMUTABLE:
extensionsByName = immutableExtensionsByName;
extensionsByNumber = immutableExtensionsByNumber;
break;
case MUTABLE:
extensionsByName = mutableExtensionsByName;
extensionsByNumber = mutableExtensionsByNumber;
break;
default:
// Ignore the unknown supported type.
return;
}
extensionsByName.put(extension.descriptor.getFullName(), extension);
extensionsByNumber.put(new DescriptorIntPair(extension.descriptor.getContainingType(), extension.descriptor.getNumber()), extension);
final FieldDescriptor field = extension.descriptor;
if (field.getContainingType().getOptions().getMessageSetWireFormat() && field.getType() == FieldDescriptor.Type.MESSAGE && field.isOptional() && field.getExtensionScope() == field.getMessageType()) {
// This is an extension of a MessageSet type defined within the extension
// type's own scope. For backwards-compatibility, allow it to be looked
// up by type name.
extensionsByName.put(field.getMessageType().getFullName(), extension);
}
}
Aggregations