pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cheol...@apache.org
Subject svn commit: r1601191 - in /pig/trunk: CHANGES.txt src/org/apache/pig/builtin/PigStorage.java
Date Sun, 08 Jun 2014 00:53:23 GMT
Author: cheolsoo
Date: Sun Jun  8 00:53:22 2014
New Revision: 1601191

URL: http://svn.apache.org/r1601191
Log:
PIG-3988: PigStorage: CommandLineParser is not thread safe (tmwoodruff via cheolsoo)

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/builtin/PigStorage.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1601191&r1=1601190&r2=1601191&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Sun Jun  8 00:53:22 2014
@@ -32,6 +32,8 @@ OPTIMIZATIONS
  
 BUG FIXES
 
+PIG-3988: PigStorage: CommandLineParser is not thread safe (tmwoodruff via cheolsoo)
+
 PIG-2409: Pig show wrong tracking URL for hadoop 2 (lbendig via rohini)
 
 PIG-3978: Container reuse does not across PigServer (daijy)

Modified: pig/trunk/src/org/apache/pig/builtin/PigStorage.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/builtin/PigStorage.java?rev=1601191&r1=1601190&r2=1601191&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/builtin/PigStorage.java (original)
+++ pig/trunk/src/org/apache/pig/builtin/PigStorage.java Sun Jun  8 00:53:22 2014
@@ -149,10 +149,6 @@ LoadPushDown, LoadMetadata, StoreMetadat
     protected ResourceSchema schema;
     protected LoadCaster caster;
 
-    private final CommandLine configuredOptions;
-    private final Options validOptions = new Options();
-    private final static CommandLineParser parser = new GnuParser();
-
     protected boolean[] mRequiredColumns = null;
     private boolean mRequiredColumnsInitialized = false;
 
@@ -163,14 +159,21 @@ LoadPushDown, LoadMetadata, StoreMetadat
     private static final String TAG_SOURCE_PATH = "tagPath";
     private Path sourcePath = null;
 
-    private void populateValidOptions() {
+    private Options populateValidOptions() {
+        Options validOptions = new Options();
         validOptions.addOption("schema", false, "Loads / Stores the schema of the relation
using a hidden JSON file.");
         validOptions.addOption("noschema", false, "Disable attempting to load data schema
from the filesystem.");
         validOptions.addOption(TAG_SOURCE_FILE, false, "Appends input source file name to
beginning of each tuple.");
         validOptions.addOption(TAG_SOURCE_PATH, false, "Appends input source file path to
beginning of each tuple.");
         validOptions.addOption("tagsource", false, "Appends input source file name to beginning
of each tuple.");
-        Option overwrite = OptionBuilder.hasOptionalArgs(1).withArgName("overwrite").withLongOpt("overwrite").withDescription("Overwrites
the destination.").create();
-        validOptions.addOption(overwrite);        
+        Option overwrite = new Option(null, "Overwrites the destination.");
+        overwrite.setLongOpt("overwrite");
+        overwrite.setOptionalArg(true);
+        overwrite.setArgs(1);
+        overwrite.setArgName("overwrite");
+        validOptions.addOption(overwrite);
+        
+        return validOptions;
     }
 
     public PigStorage() {
@@ -204,11 +207,12 @@ LoadPushDown, LoadMetadata, StoreMetadat
      * @throws ParseException
      */
     public PigStorage(String delimiter, String options) {
-        populateValidOptions();
         fieldDel = StorageUtil.parseFieldDel(delimiter);
+        Options validOptions = populateValidOptions();
         String[] optsArr = options.split(" ");
         try {
-            configuredOptions = parser.parse(validOptions, optsArr);
+            CommandLineParser parser = new GnuParser();
+            CommandLine configuredOptions = parser.parse(validOptions, optsArr);
             isSchemaOn = configuredOptions.hasOption("schema");
             if (configuredOptions.hasOption("overwrite")) {
                 String value = configuredOptions.getOptionValue("overwrite");



Mime
View raw message