[Mulgara-svn] r2087 - in trunk/src/jar: driver/java/org/mulgara/server/driver query/java/org/jrdf/graph query/java/org/mulgara/query query/java/org/mulgara/query/filter/value query/java/org/mulgara/query/rdf resolver/java/org/mulgara/resolver resolver-prefix/java/org/mulgara/resolver/prefix resolver-spi/java/org/mulgara/resolver/spi store-stringpool/java/org/mulgara/store/stringpool tuples/java/org/mulgara/store/tuples tuples-hybrid/java/org/mulgara/store/xa

pag at mulgara.org pag at mulgara.org
Thu Jan 5 19:11:28 UTC 2012


Author: pag
Date: 2012-01-05 19:11:27 +0000 (Thu, 05 Jan 2012)
New Revision: 2087

Modified:
   trunk/src/jar/driver/java/org/mulgara/server/driver/SessionFactoryFinder.java
   trunk/src/jar/query/java/org/jrdf/graph/AbstractLiteral.java
   trunk/src/jar/query/java/org/mulgara/query/ConstraintFalse.java
   trunk/src/jar/query/java/org/mulgara/query/ConstraintTrue.java
   trunk/src/jar/query/java/org/mulgara/query/filter/value/ExternalFn.java
   trunk/src/jar/query/java/org/mulgara/query/rdf/VariableNodeImpl.java
   trunk/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/PrefixResolver.java
   trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/PersistTuplesWrapperStatements.java
   trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TuplesWrapperStatements.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/ConstraintOperations.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/OrderByRowComparator.java
   trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/AbstractSPObject.java
   trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java
   trunk/src/jar/tuples/java/org/mulgara/store/tuples/DefaultRowComparator.java
   trunk/src/jar/tuples/java/org/mulgara/store/tuples/PartialColumnComparator.java
Log:
wrapping logging statements that calculate a message with calls to isDebugEnabled, and adding hashCode methods to classes with their own equals

Modified: trunk/src/jar/driver/java/org/mulgara/server/driver/SessionFactoryFinder.java
===================================================================
--- trunk/src/jar/driver/java/org/mulgara/server/driver/SessionFactoryFinder.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/driver/java/org/mulgara/server/driver/SessionFactoryFinder.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -149,11 +149,15 @@
         // If the lookup is successful connect using RMI.
         className = (String)schemeMap.get(scheme);
       } catch (NamingException ne) {
-        logger.debug("Failed to connect via RMI", ne);
+        if (logger.isDebugEnabled()) {
+          logger.debug("Failed to connect via RMI", ne);
+        }
 
         // If there is an exception connect locally.
         if (!isRemote) {
-          logger.debug("Attempting to fallback to local", ne);
+          if (logger.isDebugEnabled()) {
+            logger.debug("Attempting to fallback to local", ne);
+          }
           className = (String)schemeMap.get("local");
         } else {
           throw new SessionFactoryFinderException("Cannot find server " + serverURI, ne);

Modified: trunk/src/jar/query/java/org/jrdf/graph/AbstractLiteral.java
===================================================================
--- trunk/src/jar/query/java/org/jrdf/graph/AbstractLiteral.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/query/java/org/jrdf/graph/AbstractLiteral.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -261,6 +261,10 @@
            eq(getLanguage(), l.getLanguage());
   }
 
+  public int hashCode() {
+    return super.hashCode();
+  }
+
   public boolean isLiteral() { return true; }
 
   public boolean isBlankNode() { return false; }

Modified: trunk/src/jar/query/java/org/mulgara/query/ConstraintFalse.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ConstraintFalse.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/query/java/org/mulgara/query/ConstraintFalse.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -154,4 +154,8 @@
   public boolean equals(Object o) {
     return o == INSTANCE;
   }
+  
+  public int hashCode() {
+    return super.hashCode();
+  }
 }

Modified: trunk/src/jar/query/java/org/mulgara/query/ConstraintTrue.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ConstraintTrue.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/query/java/org/mulgara/query/ConstraintTrue.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -152,4 +152,8 @@
   public boolean equals(Object o) {
     return o == INSTANCE;
   }
+
+  public int hashCode() {
+    return super.hashCode();
+  }
 }

Modified: trunk/src/jar/query/java/org/mulgara/query/filter/value/ExternalFn.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/filter/value/ExternalFn.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/query/java/org/mulgara/query/filter/value/ExternalFn.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -183,7 +183,7 @@
       return TypedLiteral.newLiteral(value.toString(), fnUri, null);
     }
     if (extFn == null) {
-      logger.debug("Attempting to execute an unsupported function: " + fnUri + "(" + resolveArgs() + ")");
+      if (logger.isDebugEnabled()) logger.debug("Attempting to execute an unsupported function: " + fnUri + "(" + resolveArgs() + ")");
       return Bool.FALSE;
     }
     if (unrecoverableError) return Bool.FALSE;
@@ -249,6 +249,7 @@
           }
         } catch (Exception e) {
           // this resolver is unable to handle the given QName
+          result = null;
         }
       }
     }

Modified: trunk/src/jar/query/java/org/mulgara/query/rdf/VariableNodeImpl.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/rdf/VariableNodeImpl.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/query/java/org/mulgara/query/rdf/VariableNodeImpl.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -130,6 +130,10 @@
     return super.equals(obj);
   }
 
+  public int hashCode() {
+    return variableName.hashCode();
+  }
+
   public String getID() {
     return variableName;
   }

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/ConstraintOperations.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/ConstraintOperations.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/ConstraintOperations.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -208,9 +208,9 @@
     try {
       if (logger.isDebugEnabled()) {
         logger.debug("Binding Variables in ConstraintExpression[" + constraintExpr.getClass() + "]");
+        logger.debug("binding variables for: " + constraintExpr + " with " + bindings);
       }
 
-      logger.debug("binding variables for: " + constraintExpr + " with " + bindings);
       ConstraintBindingHandler op = (ConstraintBindingHandler)constraintBindingHandlers.get(constraintExpr.getClass());
       if (op == null) {
         throw new QueryException("Unknown ConstraintExpression type: " + constraintExpr.getClass() + " known types: " + constraintBindingHandlers.keySet());

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -742,7 +742,7 @@
       MulgaraTransaction transaction = transactionFactory.getTransaction(operation.isWriteOperation());
       transaction.execute(operation, metadata);
     } catch (MulgaraTransactionException em) {
-      logger.debug("Error executing operation: " + errorString, em);
+      if (logger.isDebugEnabled()) logger.debug("Error executing operation: " + errorString, em);
       throw new QueryException(errorString + ": " + StackTrace.getReasonMessage(em), em);
     }
   }

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/OrderByRowComparator.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/OrderByRowComparator.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/OrderByRowComparator.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -179,6 +179,10 @@
         Arrays.equals(columnMap, obrc.columnMap);
   }
 
+  public int hashCode() {
+    return columnMap.hashCode() + orderList.hashCode() * 5 + session.hashCode() * 7;
+  }
+
   /**
    * METHOD TO DO
    *

Modified: trunk/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/PrefixResolver.java
===================================================================
--- trunk/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/PrefixResolver.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/PrefixResolver.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -202,8 +202,10 @@
 
       // check the constraint for consistency
       if ((property != mulgaraPrefix && property != mulgaraStringPrefix) || !(prefixNode instanceof Literal || prefixNode instanceof URIReference)) {
-        logger.debug("property = " + property +", mulgaraPrefix = " + mulgaraPrefix);
-        logger.debug("element(2): " + prefixNode + " [" + prefixNode.getClass().getName() + "]");
+        if (logger.isDebugEnabled()) {
+          logger.debug("property = " + property +", mulgaraPrefix = " + mulgaraPrefix);
+          logger.debug("element(2): " + prefixNode + " [" + prefixNode.getClass().getName() + "]");
+        }
         throw new QueryException("Prefix resolver can only be used for prefix constraints: " + constraint);
       }
 

Modified: trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/PersistTuplesWrapperStatements.java
===================================================================
--- trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/PersistTuplesWrapperStatements.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/PersistTuplesWrapperStatements.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -55,7 +55,7 @@
 {
   /** Logger.  */
   @SuppressWarnings("unused")
-  private final Logger logger = Logger.getLogger(PersistTuplesWrapperStatements.class.getName());
+  private static final Logger logger = Logger.getLogger(PersistTuplesWrapperStatements.class.getName());
 
   ResolverSession resolverSession;
   

Modified: trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TuplesWrapperStatements.java
===================================================================
--- trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TuplesWrapperStatements.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TuplesWrapperStatements.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -53,7 +53,7 @@
 public class TuplesWrapperStatements extends WrappedTuples implements Statements
 {
   /** Logger.  */
-  private final Logger logger =
+  private static final Logger logger =
     Logger.getLogger(TuplesWrapperStatements.class.getName());
 
   /** Column index of statement subjects.  */

Modified: trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/AbstractSPObject.java
===================================================================
--- trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/AbstractSPObject.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/store-stringpool/java/org/mulgara/store/stringpool/AbstractSPObject.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -219,6 +219,13 @@
    * Default equality test. Based on the data type and the raw buffer.
    */
   public boolean equals(Object o) {
-    return o.getClass() == getClass() && ((SPObject)o).getData().equals(getData());
+    return o != null && o.getClass() == getClass() && ((SPObject)o).getData().equals(getData());
   }
+
+  /**
+   * Default hashCode. Based on the raw buffer.
+   */
+  public int hashCode() {
+    return getData().hashCode();
+  }
 }

Modified: trunk/src/jar/tuples/java/org/mulgara/store/tuples/DefaultRowComparator.java
===================================================================
--- trunk/src/jar/tuples/java/org/mulgara/store/tuples/DefaultRowComparator.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/tuples/java/org/mulgara/store/tuples/DefaultRowComparator.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -83,9 +83,13 @@
    * This class is stateless, so equality is just a type check.
    */
   public boolean equals(Object o) {
-    return o.getClass() == DefaultRowComparator.class;
+    return o != null && o.getClass() == DefaultRowComparator.class;
   }
 
+  public int hashCode() {
+    return super.hashCode();
+  }
+
   //
   // Methods implementing RowComparator interface
   //

Modified: trunk/src/jar/tuples/java/org/mulgara/store/tuples/PartialColumnComparator.java
===================================================================
--- trunk/src/jar/tuples/java/org/mulgara/store/tuples/PartialColumnComparator.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/tuples/java/org/mulgara/store/tuples/PartialColumnComparator.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -129,4 +129,7 @@
            Arrays.equals(varMap, ((PartialColumnComparator)o).varMap);
   }
 
+  public int hashCode() {
+    return varMap.hashCode();
+  }
 }

Modified: trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java
===================================================================
--- trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java	2012-01-05 19:10:12 UTC (rev 2086)
+++ trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java	2012-01-05 19:11:27 UTC (rev 2087)
@@ -107,7 +107,7 @@
 
       // If just cloned, then read in previous block.
       if (block == null) {
-        logger.debug("BlockCache " + this + " Refreshing from clone block " + (nextBlockId - 1));
+        if (logger.isDebugEnabled()) logger.debug("BlockCache " + this + " Refreshing from clone block " + (nextBlockId - 1));
         block = file.readBlock(nextBlockId - 1);
       }
 



More information about the Mulgara-svn mailing list