Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3239594
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:59:18+00:00 2026-05-17T17:59:18+00:00

I just watched Batch data processing with App Engine session of Google I/O 2010

  • 0

I just watched Batch data processing with App Engine session of Google I/O 2010, read some parts of MapReduce article from Google Research and now I am thinking to use MapReduce on Google App Engine to implement a recommender system in Python.

I prefer using appengine-mapreduce instead of Task Queue API because the former offers easy iteration over all instances of some kind, automatic batching, automatic task chaining, etc. The problem is: my recommender system needs to calculate correlation between instances of two different Models, i.e., instances of two distinct kinds.

Example:
I have these two Models: User and Item. Each one has a list of tags as an attribute. Below are the functions to calculate correlation between users and items. Note that calculateCorrelation should be called for every combination of users and items:

def calculateCorrelation(user, item):
    return calculateCorrelationAverage(u.tags, i.tags)

def calculateCorrelationAverage(tags1, tags2):
    correlationSum = 0.0
    for (tag1, tag2) in allCombinations(tags1, tags2):
        correlationSum += correlation(tag1, tag2)
    return correlationSum / (len(tags1) + len(tags2))

def allCombinations(list1, list2):
    combinations = []
    for x in list1:
        for y in list2:
            combinations.append((x, y))
    return combinations             

But that calculateCorrelation is not a valid Mapper in appengine-mapreduce and maybe this function is not even compatible with MapReduce computation concept. Yet, I need to be sure… it would be really great for me having those appengine-mapreduce advantages like automatic batching and task chaining.

Is there any solution for that?

Should I define my own InputReader? A new InputReader that reads all instances of two different kinds is compatible with the current appengine-mapreduce implementation?

Or should I try the following?

  • Combine all keys of all entities of these two kinds, two by two, into instances of a new Model (possibly using MapReduce)
  • Iterate using mappers over instances of this new Model
  • For each instance, use keys inside it to get the two entities of different kinds and calculate the correlation between them.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:59:19+00:00Added an answer on May 17, 2026 at 5:59 pm

    Following Nick Johnson suggestion, I wrote my own InputReader. This reader fetch entities from two different kinds. It yields tuples with all combinations of these entities. Here it is:

    class TwoKindsInputReader(InputReader):
        _APP_PARAM = "_app"
        _KIND1_PARAM = "kind1"
        _KIND2_PARAM = "kind2"
        MAPPER_PARAMS = "mapper_params"
    
        def __init__(self, reader1, reader2):
            self._reader1 = reader1
            self._reader2 = reader2
    
        def __iter__(self):
            for u in self._reader1:
                for e in self._reader2:
                    yield (u, e)
    
        @classmethod
        def from_json(cls, input_shard_state):
            reader1 = DatastoreInputReader.from_json(input_shard_state[cls._KIND1_PARAM])
            reader2 = DatastoreInputReader.from_json(input_shard_state[cls._KIND2_PARAM])
    
            return cls(reader1, reader2)
    
        def to_json(self):
            json_dict = {}
            json_dict[self._KIND1_PARAM] = self._reader1.to_json()
            json_dict[self._KIND2_PARAM] = self._reader2.to_json()
            return json_dict
    
        @classmethod
        def split_input(cls, mapper_spec):
            params = mapper_spec.params
            app = params.get(cls._APP_PARAM)
            kind1 = params.get(cls._KIND1_PARAM)
            kind2 = params.get(cls._KIND2_PARAM)
            shard_count = mapper_spec.shard_count
            shard_count_sqrt = int(math.sqrt(shard_count))
    
            splitted1 = DatastoreInputReader._split_input_from_params(app, kind1, params, shard_count_sqrt)
            splitted2 = DatastoreInputReader._split_input_from_params(app, kind2, params, shard_count_sqrt)
            inputs = []
    
            for u in splitted1:
                for e in splitted2:
                    inputs.append(TwoKindsInputReader(u, e))
    
            #mapper_spec.shard_count = len(inputs) #uncomment this in case of "Incorrect number of shard states" (at line 408 in handlers.py)
            return inputs
    
        @classmethod
        def validate(cls, mapper_spec):
            return True #TODO
    

    This code should be used when you need to process all combinations of entities of two kinds. You can also generalize this for more than two kinds.

    Here it is a valid the mapreduce.yaml for TwoKindsInputReader:

    mapreduce:
    - name: recommendationMapReduce
      mapper:
        input_reader: customInputReaders.TwoKindsInputReader
        handler: recommendation.calculateCorrelationHandler
        params:
        - name: kind1
          default: kinds.User
        - name: kind2
          default: kinds.Item
        - name: shard_count
          default: 16
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I watched a video today and the guy in the video just write this
When I watched the Dalvik VM Internals talk, I had a question about one
I'm having a problem with youtube video embedding; In some places on my site
I would like to write an app which can be run on iOS 3.1.3
Summary I'm a seasoned programmer with years of experience in Windows Forms development using
I wanted to move a sql file to my staging server that was related
I'll prefix this with: I don't much about SCORM. I'm the maintainer for a
I'm confused about how asyncnotifier works. What exactly is threaded in the notifier? Is
In my WinForms c# application I've created a method, which starts when a .mp4

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.