Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
   * with the License.  You may obtain a copy of the License at
   *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.apache.pig.backend.hadoop.executionengine.mapReduceLayer;
 
 
 
 @SuppressWarnings("unchecked")
 public class PigTextOutputFormat extends
    
     private final byte fieldDel;
     
     protected static class PigLineRecordWriter extends
         private static final String utf8 = "UTF-8";
         private static final byte[] newline;
         static {
             try {
                  = "\n".getBytes();
             } catch (UnsupportedEncodingException uee) {
                 throw new IllegalArgumentException("can't find " + 
                         + " encoding");
             }
         }
         
         private final byte fieldDel;
         
         public PigLineRecordWriter(DataOutputStream outbyte fieldDel) {
             super(out);
             this. = fieldDel;
         }
         
         public synchronized void write(WritableComparable keyTuple value)
                 throws IOException {
                 int sz = value.size();
                 for (int i = 0; i < szi++) {
                     StorageUtil.putField(value.get(i));
                     if (i != sz - 1) {
                         .writeByte();
                     }
                 }
                 .write();       
         }
     }
     
     public PigTextOutputFormat(byte delimiter) {
         super();
          = delimiter;
     }
     
     @Override
             TaskAttemptContext jobthrows IOExceptionInterruptedException {
         Configuration conf = job.getConfiguration();
         boolean isCompressed = getCompressOutput(job);
         CompressionCodec codec = null;
         String extension = "";
         if (isCompressed) {
             Class<? extends CompressionCodeccodecClass = 
                 getOutputCompressorClass(jobGzipCodec.class);
             codec = (CompressionCodec) ReflectionUtils.newInstance(codecClassconf);
             extension = codec.getDefaultExtension();
         }
         Path file = getDefaultWorkFile(jobextension);
         FileSystem fs = file.getFileSystem(conf);
         if (!isCompressed) {
             FSDataOutputStream fileOut = fs.create(filefalse);
             return new PigLineRecordWriter(fileOut);
        } else {
            FSDataOutputStream fileOut = fs.create(filefalse);
            return new PigLineRecordWriter(new DataOutputStream
                                   (codec.createOutputStream(fileOut)), );
        }
    }
New to GrepCode? Check out our FAQ X