Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and remove members to index automatically #206

Merged
merged 1 commit into from
Nov 15, 2019

Conversation

mtdowling
Copy link
Member

This commit updates the ShapeIndex to automatically add and remove
members from shapes that have members. This required some extra
functionality be introduced to shapes which then in turn resulted in
cleanup in other places in the codebase.

  1. ShapeIndex now automatically adds and removes members when shapes are
    added.
  2. There is now a members() method on all shapes to return the members
    contained in the shape (if any). Shapes that have no members just
    return an empty collection by default, and shapes that do contain
    members override the abstract method.
  3. Because members are now less important to contain a reference to
    outside of their containing shapes (since you don't need to
    explicitly add them to a shape index), you can now automatically
    create member shapes for container shapes by just passing in the
    target of the member or passing both the target and a consumer that
    accepts the created MemberShape.Builder type. This removes the need
    to create the right shape ID for the shape (suffixing with "$" + the
    member name).
  4. ShapeIndex doesn't really need a ConcurrentHashMap to cache different
    groups of shape types. The code that was used for that was overly
    complicated and likely made it slower rather than faster (the
    majority of models will use the prelude and will have more than 50
    shapes, so the optimizations that were in place don't really make
    sense any more).
  5. Because there's so much shared code between StructureShape and
    UnionShape, I created an abstract class for their shape and builders
    to make them simpler to maintain.
  6. A couple model transformations were updated to use the new members()
    method.
  7. Members of structures and unions are now sorted rather than maintain
    insert order. Nothing should ever depend on a stable order based on
    inserts since Smithy models can be loaded and aggregated from
    multiple sources.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This commit updates the ShapeIndex to automatically add and remove
members from shapes that have members. This required some extra
functionality be introduced to shapes which then in turn resulted in
cleanup in other places in the codebase.

1. ShapeIndex now automatically adds and removes members when shapes are
   added.
2. There is now a members() method on all shapes to return the members
   contained in the shape (if any). Shapes that have no members just
   return an empty collection by default, and shapes that do contain
   members override the abstract method.
3. Because members are now less important to contain a reference to
   outside of their containing shapes (since you don't need to
   explicitly add them to a shape index), you can now automatically
   create member shapes for container shapes by just passing in the
   target of the member or passing both the target and a consumer that
   accepts the created MemberShape.Builder type. This removes the need
   to create the right shape ID for the shape (suffixing with "$" + the
   member name).
4. ShapeIndex doesn't really need a ConcurrentHashMap to cache different
   groups of shape types. The code that was used for that was overly
   complicated and likely made it slower rather than faster (the
   majority of models will use the prelude and will have more than 50
   shapes, so the optimizations that were in place don't really make
   sense any more).
5. Because there's so much shared code between StructureShape and
   UnionShape, I created an abstract class for their shape and builders
   to make them simpler to maintain.
6. A couple model transformations were updated to use the new members()
   method.
7. Members of structures and unions are now sorted rather than maintain
   insert order. Nothing should ever depend on a stable order based on
   inserts since Smithy models can be loaded and aggregated from
   multiple sources.
@mtdowling mtdowling force-pushed the simplify-shape-index branch from e774e8f to 283ea69 Compare November 15, 2019 21:13
@mtdowling mtdowling requested a review from kstich November 15, 2019 21:13
@mtdowling mtdowling merged commit 68dd475 into master Nov 15, 2019
@mtdowling mtdowling deleted the simplify-shape-index branch November 15, 2019 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants