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

Fix #62 Optional path argument in JoinMapper #65

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

a4tunado
Copy link

Now to get source path from the mapper routine just add **kwargs to the arguments list. Here are some examples.

@dumbo.decor.primary
def map_primary(key, value, **kwargs):
  key, value = value.strip().split('\t')
  print >> sys.stderr, key, value, kwargs['path']
  yield key, value

Or you can specify desired argument directly

@dumbo.decor.primary
def map_primary(key, value, path, **kwargs):
  key, value = value.strip().split('\t')
  print >> sys.stderr, key, value, path
  yield key, value

Callable instances are also supported

@dumbo.decor.secondary
class MapSecondary(object):
  def __call__(self, key, value, path, **kwargs):
    key, value = value.strip().split(' ')
    print >> sys.stderr, value, path
    yield key, value

And previous mapper interface is working aswell

@dumbo.decor.primary
def map_primary(key, value):
  key, value = value.strip().split('\t')
  yield key, value

This approach allows easily extend interface to pass other arguments in the future

@klbostee
Copy link
Owner

klbostee commented Jan 8, 2013

Sounds good! Will try to find some time to review and merge this soonish.

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.

2 participants