001/* A base class for PairFlatMapFunctions used in Kepler.
002 * 
003 * Copyright (c) 2014 The Regents of the University of California.
004 * All rights reserved.
005 *
006 * '$Author: crawl $'
007 * '$Date: 2014-07-03 17:22:59 +0000 (Thu, 03 Jul 2014) $' 
008 * '$Revision: 32816 $'
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.spark.stub;
031
032import java.io.Externalizable;
033import java.io.IOException;
034import java.io.ObjectInput;
035import java.io.ObjectOutput;
036
037import org.apache.hadoop.conf.Configuration;
038import org.apache.spark.api.java.function.PairFlatMapFunction;
039
040/** A base class for PairFlatMapFunctions used in Kepler.
041 * 
042 *  @author Daniel Crawl
043 *  @version $Id: PairFlatMapFunctionBase.java 32816 2014-07-03 17:22:59Z crawl $
044 *  
045 */
046public abstract class PairFlatMapFunctionBase<T,K,V>
047    implements PairFlatMapFunction<T, K, V>, Externalizable {
048        
049    /** Set the configuration parameters. */
050    public void setConfiguration(Configuration parameters) {
051        _parameters = parameters;
052    }
053    
054    /** Deserialize the configuration. */
055    @Override
056    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
057        _parameters = new Configuration();
058        _parameters.readFields(in);
059    }
060
061    /** Serialize the configuration. */
062    @Override
063    public void writeExternal(ObjectOutput out) throws IOException {
064        _parameters.write(out);
065    }    
066
067    /** Configuration parameters. */
068    protected Configuration _parameters;
069        
070}