MCPcopy Create free account
hub / github.com/apache/pig / TFileStorage

Class TFileStorage

src/org/apache/pig/impl/io/TFileStorage.java:59–218  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

57 * should NOT be used to store any persistent data.
58 */
59@InterfaceAudience.Private
60public class TFileStorage extends FileInputLoadFunc implements
61 StoreFuncInterface, LoadMetadata {
62
63 private static final Log mLog = LogFactory.getLog(TFileStorage.class);
64 public static final String useLog = "TFile storage in use";
65
66 private TFileRecordReader recReader = null;
67 private TFileRecordWriter recWriter = null;
68
69 /**
70 * Simple binary nested reader format
71 */
72 public TFileStorage() throws IOException {
73 mLog.debug(useLog);
74 }
75
76 @Override
77 public Tuple getNext() throws IOException {
78 if (recReader.nextKeyValue()) {
79 return recReader.getCurrentValue();
80 }
81 else {
82 return null;
83 }
84 }
85
86 @Override
87 public void putNext(Tuple t) throws IOException {
88 try {
89 recWriter.write(null, t);
90 }
91 catch (InterruptedException e) {
92 throw new IOException(e);
93 }
94 }
95
96 public static class TFileInputFormat extends
97 PigFileInputFormat<Text, Tuple> {
98
99 /* (non-Javadoc)
100 * @see org.apache.hadoop.mapreduce.InputFormat#createRecordReader(org.apache.hadoop.mapreduce.InputSplit, org.apache.hadoop.mapreduce.TaskAttemptContext)
101 */
102 @Override
103 public RecordReader<Text, Tuple> createRecordReader(InputSplit split,
104 TaskAttemptContext context) throws IOException,
105 InterruptedException {
106 return new TFileRecordReader();
107 }
108
109 }
110
111 @Override
112 public InputFormat getInputFormat() {
113 return new TFileInputFormat();
114 }
115
116 @Override

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected