openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r922311 - /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryStatistics.java
Date Fri, 12 Mar 2010 16:14:47 GMT
Author: ppoddar
Date: Fri Mar 12 16:14:47 2010
New Revision: 922311

URL: http://svn.apache.org/viewvc?rev=922311&view=rev
Log:
OPENJPA-1566: Allow access to keys of the statistics.

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryStatistics.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryStatistics.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryStatistics.java?rev=922311&r1=922310&r2=922311&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryStatistics.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryStatistics.java
Fri Mar 12 16:14:47 2010
@@ -23,6 +23,7 @@ import java.io.Serializable;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * Records query execution statistics.
@@ -38,6 +39,11 @@ import java.util.Map;
  * 
  */
 public interface QueryStatistics<T> extends Serializable {
+    
+    /**
+     *  Gets all the identifier keys for the cached queries.
+     */
+    public Set<T> keys();
 	
 	/**
 	 * Record that the given query has been executed. 
@@ -126,6 +132,10 @@ public interface QueryStatistics<T> exte
 		private Map<T, long[]> astats = new HashMap<T, long[]>();
 		private Date start = new Date();
 		private Date since = start;
+		
+		public Set<T> keys() {
+		    return stats.keySet();
+		}
 
 		public long getExecutionCount() {
 			return stat[READ];
@@ -205,6 +215,8 @@ public interface QueryStatistics<T> exte
 		}
 		
 		public void recordExecution(T query) {
+		    if (query == null)
+		        return;
 		    boolean cached = (astats.containsKey(query));
 			addSample(query, READ);
 			if (cached)



Mime
View raw message