Class MessageIndexFinder


  • public class MessageIndexFinder
    extends Object
    MessageIndexFinder finds the position of message type in the overall schema. This position is used to serialize / deserialize the correct Message type.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected com.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.
      Integer 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.Descriptor getByIndex​(com.google.protobuf.Descriptors.FileDescriptor schemaDescriptor, @NonNull Integer indexToFind)
      Parses the given Schema descriptor, assigns indices and finds the descriptor for given Index.
    • Constructor Detail

      • MessageIndexFinder

        public MessageIndexFinder()
    • Method Detail

      • 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 Descriptor
        descriptorToFind - 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 Descriptor
        indexToFind - Index for the descriptor.
        Returns:
        descriptor Protobuf descriptor matching the index.
      • getAll

        protected 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