pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From the...@apache.org
Subject svn commit: r1147929 - in /pig/trunk: CHANGES.txt src/org/apache/pig/impl/util/UDFContext.java
Date Mon, 18 Jul 2011 15:25:10 GMT
Author: thejas
Date: Mon Jul 18 15:25:10 2011
New Revision: 1147929

URL: http://svn.apache.org/viewvc?rev=1147929&view=rev
Log:
PIG-1973: UDFContext.getUDFContext usage of ThreadLocal pattern
 is not typical (woody via thejas)

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/impl/util/UDFContext.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1147929&r1=1147928&r2=1147929&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Mon Jul 18 15:25:10 2011
@@ -24,6 +24,9 @@ INCOMPATIBLE CHANGES
 
 IMPROVEMENTS
 
+PIG-1973: UDFContext.getUDFContext usage of ThreadLocal pattern 
+ is not typical (woody via thejas)
+
 PIG-2053: PigInputFormat uses class.isAssignableFrom() where 
  instanceof is more appropriate (woody via thejas)
 

Modified: pig/trunk/src/org/apache/pig/impl/util/UDFContext.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/impl/util/UDFContext.java?rev=1147929&r1=1147928&r2=1147929&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/impl/util/UDFContext.java (original)
+++ pig/trunk/src/org/apache/pig/impl/util/UDFContext.java Mon Jul 18 15:25:10 2011
@@ -33,17 +33,21 @@ public class UDFContext {
     private static final String CLIENT_SYS_PROPS = "pig.client.sys.props";
     private static final String UDF_CONTEXT = "pig.udf.context"; 
     
-    private static ThreadLocal<UDFContext> tss = new ThreadLocal<UDFContext>();
-   
+    private static ThreadLocal<UDFContext> tss = new ThreadLocal<UDFContext>()
{                                                                                        
                                
+        @Override                                                                       
                                                                                         
                      
+        public UDFContext initialValue() {                                              
                                                                                         
                      
+            return new UDFContext();                                                    
                                                                                         
                      
+        }                                                                               
                                                                                         
                      
+    };           
+    
     private UDFContext() {
         udfConfs = new HashMap<UDFContextKey, Properties>();
     }
 
+    /**
+     * @return a Thread Local {@link UDFContext}
+     */
     public static UDFContext getUDFContext() {
-        if (tss.get() == null) {
-            UDFContext ctx = new UDFContext();
-            tss.set(ctx);
-        }
         return tss.get();
     }
 



Mime
View raw message