Java Code Examples for com.google.protobuf.Descriptors.FieldDescriptor#getIndex()
The following examples show how to use
com.google.protobuf.Descriptors.FieldDescriptor#getIndex() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProtoWriteSupport.java From parquet-mr with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") MessageWriter(Descriptor descriptor, GroupType schema) { List<FieldDescriptor> fields = descriptor.getFields(); fieldWriters = (FieldWriter[]) Array.newInstance(FieldWriter.class, fields.size()); for (FieldDescriptor fieldDescriptor: fields) { String name = fieldDescriptor.getName(); Type type = schema.getType(name); FieldWriter writer = createWriter(fieldDescriptor, type); if(writeSpecsCompliant && fieldDescriptor.isRepeated() && !fieldDescriptor.isMapField()) { writer = new ArrayWriter(writer); } else if (!writeSpecsCompliant && fieldDescriptor.isRepeated()) { // the old schemas style used to write maps as repeated fields instead of wrapping them in a LIST writer = new RepeatedWriter(writer); } writer.setFieldName(name); writer.setIndex(schema.getFieldIndex(name)); fieldWriters[fieldDescriptor.getIndex()] = writer; } }
Example 2
Source File: GeneratedMessage.java From play-store-api with GNU General Public License v3.0 | 5 votes |
/** Get the FieldAccessor for a particular field. */ private FieldAccessor getField(final FieldDescriptor field) { if (field.getContainingType() != descriptor) { throw new IllegalArgumentException( "FieldDescriptor does not match message type."); } else if (field.isExtension()) { // If this type had extensions, it would subclass ExtendableMessage, // which overrides the reflection interface to handle extensions. throw new IllegalArgumentException( "This type does not have extensions."); } return fields[field.getIndex()]; }
Example 3
Source File: GeneratedMessage.java From travelguide with Apache License 2.0 | 5 votes |
/** Get the FieldAccessor for a particular field. */ private FieldAccessor getField(final FieldDescriptor field) { if (field.getContainingType() != descriptor) { throw new IllegalArgumentException( "FieldDescriptor does not match message type."); } else if (field.isExtension()) { // If this type had extensions, it would subclass ExtendableMessage, // which overrides the reflection interface to handle extensions. throw new IllegalArgumentException( "This type does not have extensions."); } return fields[field.getIndex()]; }
Example 4
Source File: GeneratedMessage.java From 365browser with Apache License 2.0 | 5 votes |
/** Get the FieldAccessor for a particular field. */ private FieldAccessor getField(final FieldDescriptor field) { if (field.getContainingType() != descriptor) { throw new IllegalArgumentException( "FieldDescriptor does not match message type."); } else if (field.isExtension()) { // If this type had extensions, it would subclass ExtendableMessage, // which overrides the reflection interface to handle extensions. throw new IllegalArgumentException( "This type does not have extensions."); } return fields[field.getIndex()]; }
Example 5
Source File: ProtoWriteSupport.java From parquet-mr with Apache License 2.0 | 5 votes |
/** validates mapping between protobuffer fields and parquet fields.*/ private void validatedMapping(Descriptor descriptor, GroupType parquetSchema) { List<FieldDescriptor> allFields = descriptor.getFields(); for (FieldDescriptor fieldDescriptor: allFields) { String fieldName = fieldDescriptor.getName(); int fieldIndex = fieldDescriptor.getIndex(); int parquetIndex = parquetSchema.getFieldIndex(fieldName); if (fieldIndex != parquetIndex) { String message = "FieldIndex mismatch name=" + fieldName + ": " + fieldIndex + " != " + parquetIndex; throw new IncompatibleSchemaModificationException(message); } } }
Example 6
Source File: GeneratedMessage.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** Get the FieldAccessor for a particular field. */ private FieldAccessor getField(final FieldDescriptor field) { if (field.getContainingType() != descriptor) { throw new IllegalArgumentException( "FieldDescriptor does not match message type."); } else if (field.isExtension()) { // If this type had extensions, it would subclass ExtendableMessage, // which overrides the reflection interface to handle extensions. throw new IllegalArgumentException( "This type does not have extensions."); } return fields[field.getIndex()]; }
Example 7
Source File: GeneratedMessage.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** Get the FieldAccessor for a particular field. */ private FieldAccessor getField(final FieldDescriptor field) { if (field.getContainingType() != descriptor) { throw new IllegalArgumentException( "FieldDescriptor does not match message type."); } else if (field.isExtension()) { // If this type had extensions, it would subclass ExtendableMessage, // which overrides the reflection interface to handle extensions. throw new IllegalArgumentException( "This type does not have extensions."); } return fields[field.getIndex()]; }