You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2012/08/01 21:18:22 UTC

svn commit: r1368202 - in /jena/trunk/jena-core/src: main/java/com/hp/hpl/jena/graph/ main/java/com/hp/hpl/jena/rdf/arp/ test/java/com/hp/hpl/jena/graph/test/ test/java/com/hp/hpl/jena/test/

Author: andy
Date: Wed Aug  1 19:18:22 2012
New Revision: 1368202

URL: http://svn.apache.org/viewvc?rev=1368202&view=rev
Log:
Remove caching code and then remove unnecessary synchronization.

Modified:
    jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Node.java
    jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Triple.java
    jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/arp/ARPErrorNumbers.java
    jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestNode.java
    jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTriple.java
    jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/test/TestPackage.java

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Node.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Node.java?rev=1368202&r1=1368201&r2=1368202&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Node.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Node.java Wed Aug  1 19:18:22 2012
@@ -41,8 +41,6 @@ public abstract class Node {
     final protected Object label;
     static final int THRESHOLD = 10000;
     
-    static final NodeCache present = new NodeCache(); 
-    
     /**
         The canonical instance of Node_ANY. No other instances are required.
     */       
@@ -288,45 +286,28 @@ public abstract class Node {
     /* package visibility only */ Node( Object label ) 
         { this.label = label; }
         
-    static private boolean caching = false;
-    
     /**
         provided only for testing purposes. _cache(false)_ switches off caching and
         clears the cache. _cache(true)_ switches caching [back] on. This allows
         structural equality to be tested. 
     */
-    public static void cache( boolean wantCache )
-        {
-        if (wantCache == false) present.clear();
-        caching = wantCache;
-        }
-        
+    @Deprecated
+    public static void cache( boolean wantCache ) {}
+
+    @Deprecated
+    public static boolean isCaching() { return false ;}
+
+    
     /**
-        We object strongly to null labels: for example, they make .equals flaky. We reuse nodes 
-        from the recent cache if we can. Otherwise, the maker knows how to construct a new
-        node of the correct class, and we add that node to the cache. create is
-        synchronised to avoid threading problems - a separate thread might zap the
-        cache entry that get is currently looking at.
+        We object strongly to null labels: for example, they make .equals flaky.
     */
-    public static synchronized Node create( NodeMaker maker, Object label )
+    public static Node create( NodeMaker maker, Object label )
         {
         if (label == null) throw new JenaException( "Node.make: null label" );
-        Node node = present.get( label );
-        return node == null ? cacheNewNode( label, maker.construct( label ) ) : node;
+        return maker.construct( label ) ;
         }
-        
+
     /**
-         cache the node <code>n</code> under the key <code>label</code>,
-         and return that node.
-    */
-    private static Node cacheNewNode( Object label, Node n )
-        { 
-        if (present.size() > THRESHOLD) { /* System.err.println( "> trashing node cache" ); */ present.clear(); }
-        if (caching) present.put( label, n );
-        return n;
-        }
-        
-	/**
 		Nodes only equal other Nodes that have equal labels.
 	*/	
     @Override

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Triple.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Triple.java?rev=1368202&r1=1368201&r2=1368202&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Triple.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/graph/Triple.java Wed Aug  1 19:18:22 2012
@@ -167,29 +167,12 @@ public class Triple implements TripleMat
     */    
     public static int hashCode( Node s, Node p, Node o ) 
         { return (s.hashCode() >> 1) ^ p.hashCode() ^ (o.hashCode() << 1); }
-    
-//    /**
-//        Factory method for creating triples, allows caching opportunities. Attempts
-//        to use triples from the cache, if any suitable ones exist.
-//        
-//        @return a triple with subject=s, predicate=p, object=o
-//    */
-//    public static Triple create( Node s, Node p, Node o )
-//        { 
-//        Triple already = cache.get( s, p, o );
-//        return already == null ? cache.put( new Triple( s, p, o ) ) : already;
-//        }
 
-      public static Triple create( Node s, Node p, Node o )
-      {
-          return new Triple( s, p, o ) ;
-      }
+    public static Triple create( Node s, Node p, Node o )
+    {
+        return new Triple( s, p, o ) ;
+    }
     
-    /**
-        The cache of already-created triples.
-    */
-    protected static TripleCache cache = new TripleCache();
-        
     public static Triple createMatch( Node s, Node p, Node o )
         { return Triple.create( nullToAny( s ), nullToAny( p ), nullToAny( o ) ); }
         

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/arp/ARPErrorNumbers.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/arp/ARPErrorNumbers.java?rev=1368202&r1=1368201&r2=1368202&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/arp/ARPErrorNumbers.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/arp/ARPErrorNumbers.java Wed Aug  1 19:18:22 2012
@@ -60,6 +60,7 @@ For input involving no errors, ARP creat
 
     // All error numbers must be between 1 and 399.
     // Divide by 100 to get class.
+    // Don't see->@see : some javadoc production then generates warning (incorrectly)
     /**
      An xml:lang attribute uses one or more of the extension
      facilities in RFC3066 or ISO639. 
@@ -68,9 +69,9 @@ For input involving no errors, ARP creat
      *In both default and strict modes this is ignored; a conservative application
      *in verbose mode may wish to raise a warning.
      * (W001)
-     *@see com.hp.hpl.jena.rdf.arp.lang.LanguageTagCodes#LT_PRIVATE_USE
-     *@see com.hp.hpl.jena.rdf.arp.lang.LanguageTagCodes#LT_LOCAL_USE
-     *@see com.hp.hpl.jena.rdf.arp.lang.LanguageTagCodes#LT_EXTRA
+     * see LanguageTagCodes#LT_PRIVATE_USE
+     * see LanguageTagCodes#LT_LOCAL_USE
+     * see LanguageTagCodes#LT_EXTRA
      */
 
     public int IGN_PRIVATE_XMLLANG = 1;

Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestNode.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestNode.java?rev=1368202&r1=1368201&r2=1368202&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestNode.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestNode.java Wed Aug  1 19:18:22 2012
@@ -19,22 +19,29 @@
 package com.hp.hpl.jena.graph.test;
 
 
-import com.hp.hpl.jena.graph.*;
-import com.hp.hpl.jena.graph.impl.*;
-import com.hp.hpl.jena.rdf.model.AnonId;
-import com.hp.hpl.jena.rdf.model.impl.Util;
-import com.hp.hpl.jena.shared.*;
-import com.hp.hpl.jena.datatypes.*;
-import com.hp.hpl.jena.vocabulary.*;
+import junit.framework.TestSuite ;
 
-import junit.framework.*;
+import com.hp.hpl.jena.datatypes.RDFDatatype ;
+import com.hp.hpl.jena.datatypes.TypeMapper ;
+import com.hp.hpl.jena.graph.* ;
+import com.hp.hpl.jena.graph.impl.LiteralLabel ;
+import com.hp.hpl.jena.graph.impl.LiteralLabelFactory ;
+import com.hp.hpl.jena.rdf.model.AnonId ;
+import com.hp.hpl.jena.rdf.model.impl.Util ;
+import com.hp.hpl.jena.shared.JenaException ;
+import com.hp.hpl.jena.shared.PrefixMapping ;
+import com.hp.hpl.jena.vocabulary.DC ;
+import com.hp.hpl.jena.vocabulary.OWL ;
+import com.hp.hpl.jena.vocabulary.RSS ;
+import com.hp.hpl.jena.vocabulary.VCARD ;
 
 /**
     @author bwm out of kers
     Exercise nodes. Make sure that the different node types do not overlap
     and that the test predicates work properly on the different node kinds.
 */
-
+@SuppressWarnings("deprecation")
+// Node.useCache is deprecated.
 public class TestNode extends GraphTestBase
     {    
     public TestNode( String name )
@@ -270,15 +277,17 @@ public class TestNode extends GraphTestB
         }
     
     public void testCache()
+    {
+        if ( Node.isCaching() )
         {
-        assertEquals( Node_Variable.variable( "xxx" ), Node_Variable.variable( "xxx" ) );
-        assertTrue( "remembers URI", Node.createURI( U ) == Node.createURI( U ) );   
-        assertTrue( "remembers literal", Node.createLiteral( L ) == Node.createLiteral( L ) );
-        assertTrue( "remembers hyphens", Node.createAnon( A ) == Node.createAnon( A ) );
-        assertTrue( "remembers variables", Node.createVariable( N ) == Node.createVariable( N ) );
-        assertFalse( "is not confused", Node.createVariable( N ) == Node.createURI( N ) );
+            assertEquals( Node_Variable.variable( "xxx" ), Node_Variable.variable( "xxx" ) );
+            assertTrue( "remembers URI", Node.createURI( U ) == Node.createURI( U ) );   
+            assertTrue( "remembers literal", Node.createLiteral( L ) == Node.createLiteral( L ) );
+            assertTrue( "remembers hyphens", Node.createAnon( A ) == Node.createAnon( A ) );
+            assertTrue( "remembers variables", Node.createVariable( N ) == Node.createVariable( N ) );
+            assertFalse( "is not confused", Node.createVariable( N ) == Node.createURI( N ) );
         }
-        
+    }        
     /** 
         Test that the create method does sensible things on null and ""
     */

Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTriple.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTriple.java?rev=1368202&r1=1368201&r2=1368202&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTriple.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/graph/test/TestTriple.java Wed Aug  1 19:18:22 2012
@@ -30,6 +30,8 @@ import com.hp.hpl.jena.shared.*;
 
 import junit.framework.*;
 
+@SuppressWarnings("deprecation")
+//Node.useCache is deprecated.
 public class TestTriple extends GraphTestBase
     {    
         

Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/test/TestPackage.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/test/TestPackage.java?rev=1368202&r1=1368201&r2=1368202&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/test/TestPackage.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/test/TestPackage.java Wed Aug  1 19:18:22 2012
@@ -29,7 +29,6 @@ import com.hp.hpl.jena.assembler.test.Te
  * Please try to name your tests and test suites appropriately.
  * Note, it is better to name your test suites on creation
  * rather than in this file.
- * @author  jjc
  */
 public class TestPackage extends TestCase{