klbostee/dumbo — pull request #72 by jkleint (2013-05-08 13:02:16+00:00)
Title: Fix JoinKey sort order and allow comparison with other types.

Primary and secondary `JoinKey`s seem to compare backwards when using the Python backend (e.g., with mapredtest), due to this code in `JoinKey.__cmp__()`:

return cmp(self.isprimary, other.isprimary)

because when comparing the `.isprimary` attribute of a JoinKey, `False` sorts before `True`.

This isn't noticed using the Unix or Hadoop backends because `isprimary` serializes to `1` for primary and `2` for secondary.

This patch also allows comparing a `JoinKey` to any other type without crashing (it arbitrarily sorts first). This is useful in a situation like:

def reducer(keysvals):
key, val = next(keysvals, (defaultkey, defaultval))
if key == defaultkey:
...