[ 
https://issues.apache.org/jira/browse/PIG-3211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13592486#comment-13592486
 ] 

Cheolsoo Park commented on PIG-3211:
------------------------------------

[~prkommireddi], I have two comments:
# I think we can simplify the code. Why don't we do this?
{code:title=buildLoadOp}
-            FuncSpec instantiatedFuncSpec =
-                    funcSpec == null ?
-                        new FuncSpec(PigStorage.class.getName()) :
-                        funcSpec;
-            loFunc = 
(LoadFunc)PigContext.instantiateFuncFromSpec(instantiatedFuncSpec);
-            String fileNameKey = 
QueryParserUtils.constructFileNameSignature(filename, instantiatedFuncSpec) + 
"_" + (loadIndex++);
+            String defaultLoadFuncName = 
pigContext.getProperties().getProperty("pig.default.load.func", 
PigStorage.class.getName());
+            funcSpec = funcSpec == null ? new FuncSpec(defaultLoadFuncName): 
funcSpec;
+            loFunc = (LoadFunc)PigContext.instantiateFuncFromSpec(funcSpec);
+            String fileNameKey = 
QueryParserUtils.constructFileNameSignature(filename, funcSpec) + "_" + 
(loadIndex++);
{code}
{code:title=buildStoreOp}
-            FuncSpec instantiatedFuncSpec =
-                    funcSpec == null ?
-                            new FuncSpec(PigStorage.class.getName()):
-                            funcSpec;
-
-            StoreFuncInterface stoFunc = 
(StoreFuncInterface)PigContext.instantiateFuncFromSpec(instantiatedFuncSpec);
+            String defaultStoreFuncName = 
pigContext.getProperties().getProperty("pig.default.store.func", 
PigStorage.class.getName());
+            funcSpec = funcSpec == null ? new FuncSpec(defaultStoreFuncName): 
funcSpec;
+            StoreFuncInterface stoFunc = 
(StoreFuncInterface)PigContext.instantiateFuncFromSpec(funcSpec);
{code}
I can confirm that your test cases pass with this, so I don't think we need the 
helper functions in Utils.java.
# In addition, we should change the following in QueryParserUtils.java:
{code:title=QueryParserUtils.java}
     public static void attachStorePlan(String scope, LogicalPlan lp, String 
fileName, String func, 
             Operator input, String alias, PigContext pigContext) throws 
FrontendException {
         if( func == null ) {
-            func = PigStorage.class.getName();
+            func = 
pigContext.getProperties().getProperty("pig.default.store.func", 
PigStorage.class.getName());
         }
{code}

Let me know what you think.
                
> Allow default Load/Store funcs to be configurable
> -------------------------------------------------
>
>                 Key: PIG-3211
>                 URL: https://issues.apache.org/jira/browse/PIG-3211
>             Project: Pig
>          Issue Type: New Feature
>    Affects Versions: 0.12
>            Reporter: Prashant Kommireddi
>            Assignee: Prashant Kommireddi
>             Fix For: 0.12
>
>         Attachments: PIG-3211.patch
>
>
> PigStorage is used by default when a Load/StoreFunc is not specified. It 
> would be useful to make this configurable.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to