LOAD FUNCTION FOR PIG INTERNAL USE ONLY! This load function is used for storing intermediate data between MR jobs of a pig query. The serialization format of this load function can change in newer versions of pig, so this should NOT be used to store any persistent data.
| 57 | * versions of pig, so this should NOT be used to store any persistent data. |
| 58 | */ |
| 59 | @InterfaceAudience.Private |
| 60 | public class InterStorage extends FileInputLoadFunc |
| 61 | implements StoreFuncInterface, LoadMetadata { |
| 62 | |
| 63 | private static final Log mLog = LogFactory.getLog(InterStorage.class); |
| 64 | public static final String useLog = "Pig Internal storage in use"; |
| 65 | |
| 66 | private InterRecordReader recReader = null; |
| 67 | private InterRecordWriter recWriter = null; |
| 68 | |
| 69 | /** |
| 70 | * Simple binary nested reader format |
| 71 | */ |
| 72 | public InterStorage() { |
| 73 | mLog.debug(useLog); |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public Tuple getNext() throws IOException { |
| 78 | if(recReader.nextKeyValue()) { |
| 79 | return recReader.getCurrentValue(); |
| 80 | } else { |
| 81 | return null; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public void putNext(Tuple t) throws IOException { |
| 87 | try { |
| 88 | recWriter.write(null, t); |
| 89 | } catch (InterruptedException e) { |
| 90 | throw new IOException(e); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | |
| 95 | |
| 96 | public static class InterInputFormat extends PigFileInputFormat<Text, Tuple> { |
| 97 | |
| 98 | /* (non-Javadoc) |
| 99 | * @see org.apache.hadoop.mapreduce.InputFormat#createRecordReader(org.apache.hadoop.mapreduce.InputSplit, org.apache.hadoop.mapreduce.TaskAttemptContext) |
| 100 | */ |
| 101 | @Override |
| 102 | public RecordReader<Text, Tuple> createRecordReader(InputSplit split, |
| 103 | TaskAttemptContext context) throws IOException, |
| 104 | InterruptedException { |
| 105 | return new InterRecordReader(); |
| 106 | } |
| 107 | |
| 108 | } |
| 109 | |
| 110 | |
| 111 | @Override |
| 112 | public InputFormat getInputFormat() { |
| 113 | return new InterInputFormat(); |
| 114 | } |
| 115 | |
| 116 | @Override |
nothing calls this directly
no outgoing calls
no test coverage detected