db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r795312 - /db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/system/mailjdbc/utils/DbTasks.java
Date Sat, 18 Jul 2009 04:32:38 GMT
Author: kmarsden
Date: Sat Jul 18 04:32:38 2009
New Revision: 795312

URL: http://svn.apache.org/viewvc?rev=795312&view=rev
Log:
DERBY-4166 (partial) improvements to the mailjdbc test
Make databaseSize a recursive method to calculate the disk usage properly

merged revision 795310 from trunk.
Contributed by Lily Wei (lilywei at yahoo dot com)


Modified:
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/system/mailjdbc/utils/DbTasks.java

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/system/mailjdbc/utils/DbTasks.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/system/mailjdbc/utils/DbTasks.java?rev=795312&r1=795311&r2=795312&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/system/mailjdbc/utils/DbTasks.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/system/mailjdbc/utils/DbTasks.java
Sat Jul 18 04:32:38 2009
@@ -621,7 +621,7 @@
 	// the deletion of some rows
 	{
 		long s_compress = System.currentTimeMillis();
-		long dbsize = databaseSize("mailsdb/seg0");
+		long dbsize = databaseSize(new File("mailsdb"));
 		MailJdbc.logAct.logMsg(LogFile.INFO + thread_name + " : "
 				+ "dbsize before compress : " + dbsize);
 		boolean saveAutoCommit = conn.getAutoCommit();
@@ -652,7 +652,7 @@
 		log.logMsg(LogFile.INFO + thread_name + " : "
 				+ "Time taken to compress the table : " + tabname
 				+ PerfTime.readableTime(e_compress - s_compress));
-		dbsize = databaseSize("mailsdb/seg0");
+		dbsize = databaseSize(new File("mailsdb"));
 		MailJdbc.logAct.logMsg(LogFile.INFO + thread_name + " : "
 				+ "dbsize after compress : " + dbsize);
 	}
@@ -746,16 +746,16 @@
 			conn.setAutoCommit(saveAutoCommit);
 		}
 	}
-	public static long databaseSize(String dbname) {
-		File dir = new File(dbname);
-		File[] files = dir.listFiles();
-		long length = 0;
-		int count = 0;
-		for (int i = 0; i < files.length; i++) {
-			length = length + files[i].length();
-			count++;
-		}
-		return length;
+	public static long databaseSize(File dbname) {
+	    long length = 0;
+	    if (dbname.isDirectory()) {
+	        String[] children = dbname.list();
+	        for (int i=0; i<children.length; i++) 
+	            length = length + databaseSize(new File(dbname, children[i]));
+	        return length;
+	    }
+	    else
+	        return dbname.length();	
 	}
 
 	public static void setSystemProperty(String key, String value) {



Mime
View raw message