dynamoid

https://github.com/veraticus/dynamoid

Ruby ORM for Amazon's DynamoDB

DeclarativePolicy::Runner#steps_by_score

This is the core spot where all those `#score` methods matter.
It is critical for performance to run steps in the correct order,
so that we don't compute expensive conditions (potentially n times
if we're called on, say, a large list of users).

In order to determine the cheapest step to run next, we rely on
Step#score, which returns a numerical rating of how expensive
it would be to calculate - the lower the better. It would be
easy enough to statically sort by these scores, but we can do
a little better - the scores are cache-aware (conditions that
are already in the cache have score 0), which means that running
a step can actually change the scores of other steps.

So! The way we sort here involves re-scoring at every step. This
is by necessity quadratic, but most of the time the number of steps
will be low. But just in case, if the number of steps exceeds 50,
we print a warning and fall back to a static sort.

For each step, we yield the step object along with the computed score
for debugging purposes.

Source | Google | Stack overflow

Edit

git clone [email protected]:veraticus/dynamoid.git

cd dynamoid

open

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-DeclarativePolicy--Runner-steps_by_score-for-pr


# Commit to git

git add git commit -m "better docs for DeclarativePolicy::Runner#steps_by_score"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-DeclarativePolicy--Runner-steps_by_score-for-pr

hub pull-request


# Celebrate!