001/* An actor for the Reduce DDP pattern. 002 * 003 * Copyright (c) 2011-2012 The Regents of the University of California. 004 * All rights reserved. 005 * 006 * '$Author: jianwu $' 007 * '$Date: 2013-02-15 21:11:35 +0000 (Fri, 15 Feb 2013) $' 008 * '$Revision: 31450 $' 009 * 010 * Permission is hereby granted, without written agreement and without 011 * license or royalty fees, to use, copy, modify, and distribute this 012 * software and its documentation for any purpose, provided that the above 013 * copyright notice and the following two paragraphs appear in all copies 014 * of this software. 015 * 016 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 017 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 018 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 019 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 020 * SUCH DAMAGE. 021 * 022 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 023 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 024 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 025 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 026 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 027 * ENHANCEMENTS, OR MODIFICATIONS. 028 * 029 */ 030package org.kepler.ddp.actor.pattern; 031 032import ptolemy.data.BooleanToken; 033import ptolemy.data.expr.Parameter; 034import ptolemy.data.expr.StringParameter; 035import ptolemy.data.type.BaseType; 036import ptolemy.kernel.CompositeEntity; 037import ptolemy.kernel.util.IllegalActionException; 038import ptolemy.kernel.util.NameDuplicationException; 039import ptolemy.kernel.util.Workspace; 040 041/** An actor for the Reduce DDP pattern. This actor reads one 042 * input data set of key-value pairs. The sub-workflow in 043 * this actor needs to be completed by reading data 044 * from the output ports of the ReduceInput actor and sending 045 * key-value pairs (an array of <key, value> records) to the 046 * ReduceOutput actor. For each unique key, the sub-workflow 047 * is executed once with the key and all the values associated 048 * with that key. 049 * 050 * @author Daniel Crawl 051 * @version $Id: Reduce.java 31450 2013-02-15 21:11:35Z jianwu $ 052 */ 053public class Reduce extends SingleInputPatternActor { 054 055 /** Construct a new Reduce in a container with a given name. */ 056 public Reduce(CompositeEntity container, String name) 057 throws IllegalActionException, NameDuplicationException { 058 super(container, name); 059 060 useAsCombiner = new Parameter(this, "useAsCombiner"); 061 useAsCombiner.setTypeEquals(BaseType.BOOLEAN); 062 useAsCombiner.setToken(BooleanToken.FALSE); 063 064 combineExecutionClass = new StringParameter(this, "combineExecutionClass"); 065 066 groupingComparatorClass = new StringParameter(this, "groupingComparatorClass"); 067 068 } 069 070 /** Construct a new Reduce in a workspace. */ 071 public Reduce(Workspace workspace) { 072 super(workspace); 073 } 074 075 /** If true, use the sub-workflow or execution class to pre-reduce the 076 * data. 077 */ 078 public Parameter useAsCombiner; 079 080 /** The name of the combiner class. */ 081 public StringParameter combineExecutionClass; 082 083 /** The name of the GroupingComparatorClass, used only in hadoop for group input data of reducers. */ 084 public StringParameter groupingComparatorClass; 085}