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

Class StoreFunc

src/org/apache/pig/StoreFunc.java:38–250  ·  view source on GitHub ↗

StoreFuncs take records from Pig's processing and store them into a data store. Most frequently this is an HDFS file, but it could also be an HBase instance, RDBMS, etc.

Source from the content-addressed store, hash-verified

36* this is an HDFS file, but it could also be an HBase instance, RDBMS, etc.
37*/
38@InterfaceAudience.Public
39@InterfaceStability.Stable
40public abstract class StoreFunc implements StoreFuncInterface {
41
42 /**
43 * This method is called by the Pig runtime in the front end to convert the
44 * output location to an absolute path if the location is relative. The
45 * StoreFunc implementation is free to choose how it converts a relative
46 * location to an absolute location since this may depend on what the location
47 * string represent (hdfs path or some other data source).
48 *
49 *
50 * @param location location as provided in the "store" statement of the script
51 * @param curDir the current working direction based on any "cd" statements
52 * in the script before the "store" statement. If there are no "cd" statements
53 * in the script, this would be the home directory -
54 * <pre>/user/<username> </pre>
55 * @return the absolute location based on the arguments passed
56 * @throws IOException if the conversion is not possible
57 */
58 @Override
59 public String relToAbsPathForStoreLocation(String location, Path curDir)
60 throws IOException {
61 return LoadFunc.getAbsolutePath(location, curDir);
62 }
63
64 /**
65 * Return the OutputFormat associated with StoreFunc. This will be called
66 * on the front end during planning and on the backend during
67 * execution.
68 * @return the {@link OutputFormat} associated with StoreFunc
69 * @throws IOException if an exception occurs while constructing the
70 * OutputFormat
71 *
72 */
73 @Override
74 public abstract OutputFormat getOutputFormat() throws IOException;
75
76 /**
77 * Communicate to the storer the location where the data needs to be stored.
78 * The location string passed to the {@link StoreFunc} here is the
79 * return value of {@link StoreFunc#relToAbsPathForStoreLocation(String, Path)}
80 * This method will be called in the frontend and backend multiple times. Implementations
81 * should bear in mind that this method is called multiple times and should
82 * ensure there are no inconsistent side effects due to the multiple calls.
83 * {@link #checkSchema(ResourceSchema)} will be called before any call to
84 * {@link #setStoreLocation(String, Job)}.
85 *
86
87 * @param location Location returned by
88 * {@link StoreFunc#relToAbsPathForStoreLocation(String, Path)}
89 * @param job The {@link Job} object
90 * @throws IOException if the location is not valid.
91 */
92 @Override
93 public abstract void setStoreLocation(String location, Job job) throws IOException;
94
95 /**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected