labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ka...@apache.org
Subject svn commit: r747965 - in /labs/bananadb/trunk/src: main/java/org/apache/labs/bananadb/hashtable/Hashtable.java main/java/org/apache/labs/bananadb/hashtable/HashtableAccessor.java test/java/org/apache/labs/bananadb/hashtable/TestHashtable.java
Date Wed, 25 Feb 2009 23:24:48 GMT
Author: kalle
Date: Wed Feb 25 23:24:48 2009
New Revision: 747965

URL: http://svn.apache.org/viewvc?rev=747965&view=rev
Log:
BananaDB

New data partitions was not registred in existing accessors and would thus throw an exception
when too much data was added.

Modified:
    labs/bananadb/trunk/src/main/java/org/apache/labs/bananadb/hashtable/Hashtable.java
    labs/bananadb/trunk/src/main/java/org/apache/labs/bananadb/hashtable/HashtableAccessor.java
    labs/bananadb/trunk/src/test/java/org/apache/labs/bananadb/hashtable/TestHashtable.java

Modified: labs/bananadb/trunk/src/main/java/org/apache/labs/bananadb/hashtable/Hashtable.java
URL: http://svn.apache.org/viewvc/labs/bananadb/trunk/src/main/java/org/apache/labs/bananadb/hashtable/Hashtable.java?rev=747965&r1=747964&r2=747965&view=diff
==============================================================================
--- labs/bananadb/trunk/src/main/java/org/apache/labs/bananadb/hashtable/Hashtable.java (original)
+++ labs/bananadb/trunk/src/main/java/org/apache/labs/bananadb/hashtable/Hashtable.java Wed
Feb 25 23:24:48 2009
@@ -123,7 +123,9 @@
   private List<HashtableAccessor> accessors = new ArrayList<HashtableAccessor>();
 
   public HashtableAccessor createAccessor(boolean readOnly) throws IOException {
-    return new HashtableAccessor(this, readOnly);
+    HashtableAccessor accessor = new HashtableAccessor(this, readOnly);
+    accessors.add(accessor);
+    return accessor;
   }
 
   public Hashtable(File path, int capacity, KeyClassHandler<K> keyClassHandler, EntityClassHandler<V>
valueClassHandler) throws IOException {
@@ -189,7 +191,7 @@
     if (valueFiles.length > 0) {
       for (int i = 0; i < valueFiles.length; i++) {
         if (!valueFiles[i].getName().endsWith("." + i)) {
-          throw new FileNotFoundException("Exptected partition data." + i + " but found "
+ valueFiles[i].getName());
+          throw new FileNotFoundException("Expected partition data." + i + " but found "
+ valueFiles[i].getName());
         }
         Partition partition = new Partition(i);
         partition.open();

Modified: labs/bananadb/trunk/src/main/java/org/apache/labs/bananadb/hashtable/HashtableAccessor.java
URL: http://svn.apache.org/viewvc/labs/bananadb/trunk/src/main/java/org/apache/labs/bananadb/hashtable/HashtableAccessor.java?rev=747965&r1=747964&r2=747965&view=diff
==============================================================================
--- labs/bananadb/trunk/src/main/java/org/apache/labs/bananadb/hashtable/HashtableAccessor.java
(original)
+++ labs/bananadb/trunk/src/main/java/org/apache/labs/bananadb/hashtable/HashtableAccessor.java
Wed Feb 25 23:24:48 2009
@@ -65,7 +65,7 @@
     if (partitionRAF == null) {
       // todo perhaps it was created by some other accessor? need to handle this
       // todo but preferably without synchronizing the whole method!
-      throw new RuntimeException("Unknown partion!");
+      throw new RuntimeException("Unknown partition!");
     }
     return partitionRAF;
   }

Modified: labs/bananadb/trunk/src/test/java/org/apache/labs/bananadb/hashtable/TestHashtable.java
URL: http://svn.apache.org/viewvc/labs/bananadb/trunk/src/test/java/org/apache/labs/bananadb/hashtable/TestHashtable.java?rev=747965&r1=747964&r2=747965&view=diff
==============================================================================
--- labs/bananadb/trunk/src/test/java/org/apache/labs/bananadb/hashtable/TestHashtable.java
(original)
+++ labs/bananadb/trunk/src/test/java/org/apache/labs/bananadb/hashtable/TestHashtable.java
Wed Feb 25 23:24:48 2009
@@ -103,5 +103,24 @@
     }
 
     accessor.close();
+
+
+    // load lots of data to it in order to make sure it produce more than one partition
+    accessor = map.createAccessor(false);
+
+    StringBuilder sb = new StringBuilder(10000);
+    for (int i = 0; i < 1000; i++) {
+      sb.append("THIS WILL TURN OUT TO BE A RATHER LONG STRING");
+    }
+    String str = sb.toString();
+    for (int i = 101; i < 999999; i++) {
+      map.put(accessor, i, str);
+      if (map.getPartitions().size() > 1) {
+        break;
+      }
+    }
+
+    accessor.close();
+
   }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message