Class MessageIndexFinder
java.lang.Object
com.amazonaws.services.schemaregistry.serializers.protobuf.MessageIndexFinder
MessageIndexFinder finds the position of message type in the overall schema.
This position is used to serialize / deserialize the correct Message type.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.collect.BiMap<com.google.protobuf.Descriptors.Descriptor,Integer> getAll(com.google.protobuf.Descriptors.FileDescriptor schemaDescriptor) Parse the Protobuf Schema descriptor using level-order traversal, sort the descriptors lexicographically and assign an index for each message type.getByDescriptor(com.google.protobuf.Descriptors.FileDescriptor schemaDescriptor, com.google.protobuf.Descriptors.Descriptor descriptorToFind) Parses the given Schema descriptor, assigns indices and finds the index for the given descriptor.com.google.protobuf.Descriptors.DescriptorgetByIndex(com.google.protobuf.Descriptors.FileDescriptor schemaDescriptor, @NonNull Integer indexToFind) Parses the given Schema descriptor, assigns indices and finds the descriptor for given Index.
-
Constructor Details
-
MessageIndexFinder
public MessageIndexFinder()
-
-
Method Details
-
getByDescriptor
public Integer getByDescriptor(@NonNull com.google.protobuf.Descriptors.FileDescriptor schemaDescriptor, @NonNull com.google.protobuf.Descriptors.Descriptor descriptorToFind) Parses the given Schema descriptor, assigns indices and finds the index for the given descriptor.- Parameters:
schemaDescriptor- Protobuf Schema DescriptordescriptorToFind- Protobuf Descriptor to find.- Returns:
- Index Integer.
-
getByIndex
public com.google.protobuf.Descriptors.Descriptor getByIndex(@NonNull com.google.protobuf.Descriptors.FileDescriptor schemaDescriptor, @NonNull @NonNull Integer indexToFind) Parses the given Schema descriptor, assigns indices and finds the descriptor for given Index.- Parameters:
schemaDescriptor- Protobuf Schema DescriptorindexToFind- Index for the descriptor.- Returns:
- descriptor Protobuf descriptor matching the index.
-
getAll
public com.google.common.collect.BiMap<com.google.protobuf.Descriptors.Descriptor,Integer> getAll(@NonNull com.google.protobuf.Descriptors.FileDescriptor schemaDescriptor) Parse the Protobuf Schema descriptor using level-order traversal, sort the descriptors lexicographically and assign an index for each message type.TODO: Referencing other proto schemas using import statements is not supported yet. https://github.com/awslabs/aws-glue-schema-registry/issues/32
Example:
message B { message C { } message A { message D { } } }Assigned indices: B = 0, B.A = 1, B.A.D = 2, B.C = 3
- Parameters:
schemaDescriptor- Protobuf Schema Descriptor.- Returns:
- Set of MessageIndex
-