sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattm...@apache.org
Subject svn commit: r1307718 - in /incubator/sis/trunk/sis-core/src: main/java/org/apache/sis/storage/QuadTreeNode.java test/java/org/apache/sis/storage/ test/java/org/apache/sis/storage/TestQuadTreeNode.java
Date Sat, 31 Mar 2012 04:51:57 GMT
Author: mattmann
Date: Sat Mar 31 04:51:57 2012
New Revision: 1307718

URL: http://svn.apache.org/viewvc?rev=1307718&view=rev
Log:
- progress towards SIS-39: Capacity is not used and memory waste in QuadTreeNode (identified
by Peter Karich)

Added:
    incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/storage/
    incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/storage/TestQuadTreeNode.java
Modified:
    incubator/sis/trunk/sis-core/src/main/java/org/apache/sis/storage/QuadTreeNode.java

Modified: incubator/sis/trunk/sis-core/src/main/java/org/apache/sis/storage/QuadTreeNode.java
URL: http://svn.apache.org/viewvc/incubator/sis/trunk/sis-core/src/main/java/org/apache/sis/storage/QuadTreeNode.java?rev=1307718&r1=1307717&r2=1307718&view=diff
==============================================================================
--- incubator/sis/trunk/sis-core/src/main/java/org/apache/sis/storage/QuadTreeNode.java (original)
+++ incubator/sis/trunk/sis-core/src/main/java/org/apache/sis/storage/QuadTreeNode.java Sat
Mar 31 04:51:57 2012
@@ -32,6 +32,7 @@ public class QuadTreeNode {
   private int id;
   private int capacity;
   private int dataCount;
+  private static final int MIN_CAPACITY = 10;
 
   /**
    * Constructs a quad tree node that can store data
@@ -42,7 +43,7 @@ public class QuadTreeNode {
    *          node's capcacity
    */
   public QuadTreeNode(int id, int capacity) {
-    this.capacity = capacity;
+    this.capacity = capacity > 0 ? capacity:MIN_CAPACITY;
     this.dataCount = 0;
     this.data = new QuadTreeData[this.capacity];
     this.type = NodeType.BLACK;

Added: incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/storage/TestQuadTreeNode.java
URL: http://svn.apache.org/viewvc/incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/storage/TestQuadTreeNode.java?rev=1307718&view=auto
==============================================================================
--- incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/storage/TestQuadTreeNode.java
(added)
+++ incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/storage/TestQuadTreeNode.java
Sat Mar 31 04:51:57 2012
@@ -0,0 +1,15 @@
+package org.apache.sis.storage;
+
+import junit.framework.TestCase;
+
+public class TestQuadTreeNode extends TestCase{
+
+	/**
+	 * @since SIS-39 
+	 */
+	public void testCapacityGreaterThanZero(){
+		QuadTreeNode node = new QuadTreeNode(-1, -5);
+		assertNotNull(node);
+		assertTrue(node.getCapacity() > 0);
+	}
+}



Mime
View raw message