Map-reduce with merge to process multiple relational datasets

A method of processing relationships of at least two datasets is provided. For each of the datasets, a map-reduce subsystem is provided such that the data of that dataset is mapped to corresponding intermediate data for that dataset. The intermediate data for that dataset is reduced to a set of reduced intermediate data for that dataset. Data corresponding to the sets of reduced intermediate data are merged, in accordance with a merge condition. In some examples, data being merged may include the output of one or more other mergers. That is, generally, merge functions may be flexibly placed among various map-reduce subsystems and, as such, the basic map-reduce architecture may be advantageously modified to process multiple relational datasets using, for example, clusters of computing devices.

BACKGROUND

MapReduce is a programming methodology to perform parallel computations over distributed (typically, very large) data sets. Some theory regarding the MapReduce programming methodology is described in “MapReduce: Simplified Data Processing on Large Clusters,” by Jeffrey Dean and Sanjay Ghemawat, appearing in OSDI'04: Sixth Symposium on Operating System Design and Implementation, San Francisco, Calif., December, 2004 (hereafter, “Dean and Ghemawat”). A similar, but not identical, presentation is also provided in HTML form at the following URL: http://labs.google.com/papers/mapreduce-osdi04-slides/index.html (hereafter, “Dean and Ghemawat HTML”).

FIG. 1simplistically illustrates the architecture of a map-reduce system100. Basically, a “map” function102maps key-value pairs to new (intermediate) key-value pairs. A “reduce” function104represents all mapped (intermediate) key-value pairs sharing the same key to a single key-value pair or a list of values. The “map” function102and “reduce” function104are typically user-provided.

In general, a map function (which may actually be a group of map functions, each operating on a different computer) iterates over a list of independent elements, performing an operation on each element as specified by the map function. The map function generates intermediate results. A reduce operation takes these intermediate results via an iterator and combines elements as specified by the reduce function.

It is useful to consider that the data within a map-reduce system may be thought of as being characterized by key/value pairs. For example, both the input dataset and the output of the reduce function may be thought of as a set of key value pairs. The programmer specifies the map function, to process input key/value pairs and produces a set of intermediate pairs. The set of intermediate pairs is not explicitly represented inFIG. 1. The reduce function combines all intermediate values for a particular key and produces a set of merged output values for the key, usually just one.

While the map function and reduce function have been discussed above as being a single map function, the map function may, in implementation, be accomplished by multiple map sub-functions, each of the multiple map sub-functions operating on a different split of the input dataset. In any case, however, the input data set is homogeneous in that the entire input dataset is characterized by a schema according to which all of the multiple map sub-functions operates. Similarly, even if multiple reduce sub-functions operate on different partitions of the mapper output(s), the intermediate data is set is homogeneous in that the entire intermediate data set is characterized according to a schema according to which all of the reduce sub-functions operate.

SUMMARY

A method of processing relationships of at least two datasets is provided. For each of the datasets, a map-reduce subsystem is provided such that the data of that dataset is mapped to corresponding intermediate data for that dataset. The intermediate data for that dataset is reduced to a set of reduced intermediate data for that dataset. Data corresponding to the sets of reduced intermediate data are merged, in accordance with a merge condition.

In some examples, data being merged may include the output of one or more other mergers. That is, generally, merge functions may be flexibly placed among various map-reduce subsystems and, as such, the basic map-reduce architecture may be advantageously modified to process multiple relational datasets using, for example, clusters of computing devices.

DETAILED DESCRIPTION

The inventors have realized that, by merging the outputs of map-reduce processes separately operating on two or more datasets, the relationships of the two or more datasets may be processed, for example, according to user-defined logic. More generally, an N-way merge may be accomplished by merging the outputs of map-reduce processes separately operating on N datasets. In many examples, the roles of the mappers and reducers may be conventional.

That is, for example, as shown inFIG. 2, map function202aand reduce function204acomprise a first map-reduce subsystem206a,with respect to an input dataset1. This is similar to the map-reduce system100ofFIG. 1. Moreover, a map function202band reduce function204bcomprise a second map-reduce subsystem206b,with respect to an input dataset2. Again, this is similar to the map-reduce system100ofFIG. 1.

Furthermore, a merge function208operates to collect records from the two map-reduce subsystems206aand206b,to merge records from the multiple sources based on a merge condition. The merge function208, then, operates to relate input dataset1to input dataset2. Due to the use of the map-reduce architecture, such a relation can be accomplished using a scalable, fault-tolerant, distributed and relatively inexpensive cluster-based storage system.

The merge function208is typically user-provided and may, for example, be effective to accomplish relational database operations, such as a “join” operation, over multiple individually homogeneous input datasets.

More generally, “N” such input datasets may be operated upon in this manner using, for example, “N” map-reduce subsystems. As is also illustrated herein, merge functions may be flexibly placed among various map-reduce subsystems and, as such, the basic map-reduce architecture may be advantageously modified to process multiple relational datasets using, for example, clusters of computing devices.

FIG. 3illustrates a configuration that may be thought of as an extension to theFIG. 2configuration. The portion of theFIG. 3including map-reduce subsystem302a,map-reduce subsystem302band merge function304is similar to theFIG. 2configuration. In addition, a map-reduce subsystem302cis provided, with respect to input data set3. An additional merge function306is provided that merges the output of the merge function304and of the reducer of the map-reduce subset302c.It can be seen, then, that a merge function may take, as input, the output of either reducers or other merge functions.

FIG. 4illustrates a configuration where some of merge functions take, as input, the output of two reducers. Another of the merge functions takes, as input, the output of two merge functions. In particular, referring toFIG. 4, the map-reduce subsystem402a,the map-reduce subsystem402b,the map-reduce subsystem402cand the map-reduce subsystem402dtake, as input respectively, the input data set1, the input data set2, the input data set3and the input data set4.

A merge function404takes, as input, the output of the reducers of the map-reduce subsystem402aand of the map-reduce subsystem402b.The merge function406takes, as input, the output of the reducers of the map-reduce subsystem402cand of the map-reduce subsystem402d.Finally, the merge function408takes, as input, the output of the merge functions404and406. Using merge functions, a parallel relational data processing system may be implemented with three or more parallel passes.

It should be noted, however, that more generally a merger can be associated with one or more reducers from a particular data source. Reading one partition from each source is a simple scenario. For example, one merger may read data from multiple reducers (e.g., if the number of mergers and reducers do not match). In some examples, a merger may merge one reducer partition from one source with multiple reducer partitions from another source.

FIG. 5illustrates how a merger output may be re-processed, re-partitioned and re-sorted (on different keys) before being passed to another merger. In theFIG. 5example, the output of the merge function504is passed through map-reduce subsystem502ebefore being passed to merger508. Re-processing and re-partitioning of the output of the merge function504is accomplished by the map function of the map-reduce subsystem502eand re-sorting is accomplished by the reduce function of the map-reduce subsystem502e.

We now discuss how the various map, reduce and merge functions may be allocated to computing devices of a computing cluster. In general, map and reduce functions may be allocated to different computing devices of a computing cluster and distributed file system, as described in Dean and Ghemawat and Dean and Ghemawat HTML, referenced in the Background portion of this patent application. It is known that, as a result, relatively fault-susceptible commodity computing devices may be combined in an effective and relatively fault-tolerant manner.

As discussed above, a merge function receives input from two sets of reducers. The merge function may include a merge input selector to determine which reducer outputs to merge. In one example, the merge input selector may be configured such that the merger is configured to read from only a selected set of reducers.

Furthermore, a merge function may have a one-to-one relationship with members of one reducer and, in fact, may be co-located with the associated reducer on the same computing device of a cluster of computing devices. In such a case, the merge function may obtain the associated reducer output locally and connect to members of the other set of reducers (e.g., using a remote procedure call) to obtain the output from those reducers. Thus, for example, the reducer output may not be provided to the distributed file system of the map-reduce system. Furthermore, the selector of the merge function use reducer output ranges (typically, user configurable) to determine which reducer outputs to merge. Thus, the selector may use these reducer output ranges to determine whether to even connect to members of the other set of reducers.

It is noted that, in some examples, the selector configuration may be user-defined to determine, in all instances, to connect to all members of the reducers. That is, the selectors may be configured to treat the reducer output ranges (if provided) as “don't care.”

Reducer output, in general, includes a set of values. In accordance with an example, the reducer output provides keys that correspond to the output set of values. Thus, in accordance with this example, the reducer output may be considered a tuple, where each tuple is characterized at least by a key/value pair.

A matcher of a merge function receives two keys, from two respective reducers, and determines from the received keys whether the tuples characterized by the key should be merged. For example, the signature of a merge function may follow the signature of the reducers or the signature of a merge function may follow the signature of the mappers. Specific applications are discussed below.

Thus, for example, there are various relational operations that can be enabled through the use of a merge function in a map-reduce system. For example, relational operations such as join operations, such as natural join, equijoin, theta-join, semi-join and anti-join operations. Conventional map-reduce architectures do not account for handling two or more data sets at the same time. Other relational operations that may be enabled through the use of a merge function include set operations, such as union, difference, intersection and Cartesian product. Yet another relational operation that may be enabled through the use of a merge function includes a division operation. Yet another relational operations that may be enabled includes outer join operations, such as left outer join, right outer join and full outer join, and projection and selection. (It is noted that in some examples, relational projection and relational select operations may be accomplished by appropriately configuring mappers. An SQL “having” operation and an aggregation operation may be accomplished by appropriately configuring reducers.)

The matchers may be considered to act as predicates such as in the “where” clause of a relational SQL query. For example, for an equal-join condition, tuples that have an equivalent key value would be merged. It is noted that they key values may be equivalent without necessarily being identical as is the case, for example, if the keys have different data types. The equivalency condition may be user-defined in the matcher.

As some specific merge examples, if the reducer output is sorted by key order (for example, in a range sorted manner), then the merger can be based on the ordered keys (e.g., by doing merge joins over the sorted ranges from each reducer). If the reducer output is sorted on a hashed key, then the merger can accomplish a hash-join merger. For example, a merger may use one set as a “build” set to build a hash table and another set as a “probe” set. The reducers may aggregate data with the same hashed partition number (the data may still have unique hash values but be partitioned to the same partition number), with partitioned being hash-joined in a merger.

A block-nested-loop merger may accomplish a block-nested-loop join operation (when, for example, the selectivity is high among reducer outputs). Data may be partitioned (e.g., by mappers and reducers) to reduce nested-loop size. Mergers may be read one partition from each of the two upstream reducers, and the partitions are nested-loop joined in a merger.

As yet another example, the reducer outputs need not be heterogeneous. That is, for example, a union merger may receive homogenous reducer outputs and produce a union of those homogeneous outputs. For example, a mapper may use a combiner to union data from a mapper partition, and the reducers may further unionize data from one dataset. The mergers may read one partition from each of the two upstream reducers and union the read partition.

We now discuss a particular example application in which there are two sources of data—employee data and department data. In the example, a join is used between the employee dataset and the department dataset in order to compute bonuses.

An employee mapper iterates through the employee dataset and gets an employee-id and a department-id. The mapper computes various bonuses and emits records with key as (department-id, employee-id) pair and bonus as value. An example of the employee mapper is shown below, in pseudocode:

An employee reducer sorts the outputs of the employee mapper based on the key (department-id, employee-id), sums up an employee's various bonuses, and emits the same key with a bonus-sum as value. An example of the employee reducer is shown below, in pseudocode:

A department mapper iterates through the department table, getting and emitting the department-id and department-info. An example of the department mapper is shown below, in pseudocode:

A department reducer sorts and emits the department mapper sorts and emits the department reducer output. An example of the department reducer is shown below, in pseudocode:

The merger's select task selects the intersection of the reducer outputs, so that they can be merged. An example of the merger's select task is shown below, in pseudocode:

Select (String keyDepartmentEmployeeIdStart,String keyDepartmentEmployeeIdEnd,String keyDepartmentIdStart,String keyDepartmentIdEnd):// keyDepartmentEmployeeIdStart, keyDepartmentEmployeeIdEnd: the//  range of the key values from a left reducer output.// keyDepartmentIdStart, keyDepartmentIdEnd: the range of the key values//  from a right reducer output.Return TRUE if (keyDepartmentEmployeeIdStart.department-id,keyDepartmentEmployeeIdEnd) intersects with(keyDepartmentIdStart, keyDepartmentIdEnd)else FALSE

The merger's match task matches records from the department reducer and from the employee reducer with the same department-name. An example of the merger's match task is shown below, in pseudocode:

Finally, the merger body adjusts employee-bonus using the department-info and emits employee-id and his/her final bonus number. An example of the merger is shown below, in pseudocode:

We now discuss some other example applications of applying a merge function within a map-reduce architecture. In one example, datasets maintained by a search engine are processed. For example, search engine datasets may include a web-page index, a web-page attribute repository, web crawl results and click logs. The datasets may be joined to obtain useful metrics about the search engine itself, such as joining the click logs dataset with the web-page attribute repository, to determine the attributes (such as page-rank or host-trust) of the most clicked web pages.

In accordance with another example, large databases across companies may be joined. For example, a car manufacturer may have a large part dataset organized by car, while a part provider has a large part-supplier dataset. The two datasets may be joined to obtain a complete list of part-suppliers for all the parts in a particular car.