001/* Hadoop OutputFormat for Ptolemy tokens.
002 * 
003 * Copyright (c) 2014 The Regents of the University of California.
004 * All rights reserved.
005 *
006 * '$Author: crawl $'
007 * '$Date: 2014-07-02 15:58:19 +0000 (Wed, 02 Jul 2014) $' 
008 * '$Revision: 32804 $'
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.hadoop.io.output;
031
032import java.io.IOException;
033
034import org.apache.hadoop.io.Writable;
035import org.apache.hadoop.mapreduce.JobContext;
036import org.apache.hadoop.mapreduce.OutputCommitter;
037import org.apache.hadoop.mapreduce.OutputFormat;
038import org.apache.hadoop.mapreduce.RecordWriter;
039import org.apache.hadoop.mapreduce.TaskAttemptContext;
040
041/** Hadoop OutputFormat for Ptolemy tokens.
042 * 
043 *  @author Daniel Crawl
044 *  @verion $Id: TokenOutputFormat.java 32804 2014-07-02 15:58:19Z crawl $
045 */
046public class TokenOutputFormat extends OutputFormat<Writable,Writable> {
047
048    /** Get the record writer. */
049    @Override
050    public RecordWriter<Writable, Writable> getRecordWriter(
051            TaskAttemptContext context) throws IOException,
052            InterruptedException {
053        return new TokenRecordWriter(context.getConfiguration());
054    }
055
056    @Override
057    public void checkOutputSpecs(JobContext context) throws IOException,
058            InterruptedException {
059        // TODO Auto-generated method stub
060        
061    }
062
063    /** Get the output commiter. */
064    @Override
065    public OutputCommitter getOutputCommitter(TaskAttemptContext context)
066            throws IOException, InterruptedException {
067        return new TokenOutputCommitter();
068    }
069
070    public static class TokenOutputCommitter extends OutputCommitter {
071
072        public TokenOutputCommitter() {
073            super();
074        }
075
076        @Override
077        public boolean needsTaskCommit(TaskAttemptContext taskContext)
078                throws IOException {
079            // TODO Auto-generated method stub
080            return false;
081        }
082
083        @Override
084        public void commitTask(TaskAttemptContext taskContext)
085                throws IOException {
086            // TODO Auto-generated method stub
087
088        }
089
090        @Override
091        public void abortTask(TaskAttemptContext taskContext)
092                throws IOException {
093            // TODO Auto-generated method stub
094
095        }
096
097        @Override
098        public void setupJob(JobContext jobContext) throws IOException {
099            // TODO Auto-generated method stub
100            
101        }
102
103        @Override
104        public void setupTask(TaskAttemptContext taskContext)
105                throws IOException {
106            // TODO Auto-generated method stub
107            
108        }
109    }
110}