incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1204303 - in /incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore: Index.java Table.java TableStore.java
Date Mon, 21 Nov 2011 00:40:23 GMT
Author: kwright
Date: Mon Nov 21 00:40:22 2011
New Revision: 1204303

URL: http://svn.apache.org/viewvc?rev=1204303&view=rev
Log:
Add index cleanup logic

Modified:
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/Index.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/Table.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/Index.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/Index.java?rev=1204303&r1=1204302&r2=1204303&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/Index.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/Index.java
Mon Nov 21 00:40:22 2011
@@ -328,6 +328,37 @@ public class Index implements WHIndex
     deleteIndexNodeTableRow(deleteNodeID);
   }
   
+  /** Remove an entire index.
+  * WARNING: This effectively requires the entire index to fit in memory!
+  * It's far better to remove a bit at a time, in separate transactions.
+  */
+  protected void remove()
+    throws WHException
+  {
+    deleteSubtree(new IndexRootKey(indexName));
+  }
+  
+  /** Delete a subtree described by a WHKey */
+  protected void deleteSubtree(WHKey key)
+    throws WHException
+  {
+    long child = readIndexParentChild(key);
+    if (child == -1L)
+      return;
+    // Delete the child.
+    // First, unlink from the parent.
+    deleteIndexParentChild(key);
+    // Delete the link to the table row.
+    deleteIndexNodeTableRow(child);
+    // Recursively clean up all child links.
+    deleteSubtree(new IndexNodeEqualsKey(indexName,child));
+    for (int i = 0 ; i < columnNames.length ; i++)
+    {
+      String currentColumn = columnNames[i];
+      deleteSubtree(new IndexNodeLesserKey(indexName,child,currentColumn));
+      deleteSubtree(new IndexNodeGreaterKey(indexName,child,currentColumn));
+    }
+  }
   
   // Protected methods
   

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/Table.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/Table.java?rev=1204303&r1=1204302&r2=1204303&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/Table.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/Table.java
Mon Nov 21 00:40:22 2011
@@ -143,6 +143,16 @@ public class Table implements WHTable
   
   // Protected methods
   
+  /** Remove all rows.
+  * WARNING: This effectively causes the entire table to have to fit into memory!
+  * It is better to delete rows piecemeal in separate transactions.
+  */
+  protected void remove()
+    throws WHException
+  {
+    deleteRows(buildAccessor(),null);
+  }
+
   /** Add a table row to the linked list for that table.
   * We add it at the end, although technically we could just as well add at the
   * beginning.

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java?rev=1204303&r1=1204302&r2=1204303&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java
Mon Nov 21 00:40:22 2011
@@ -265,7 +265,7 @@ public class TableStore implements WHTab
     }
     
     // Now that the indexes are gone, delete all the table rows
-    t.deleteRows(t.buildAccessor(),null);
+    t.remove();
 
     // Delete the keys that belong to the table, and clean up cached values
     tables.remove(t.getName());
@@ -301,7 +301,7 @@ public class TableStore implements WHTab
     currentTransaction.put(new TableIndexKey(t.getName()),new StringArray(newIndexList));
     indexesPerTable.remove(t.getName());
 
-    // MHL to delete the index nodes
+    i.remove();
 
     // Clean out the index definition and other associated keys, and blow away cached copies
     indexes.remove(i.getName());



Mime
View raw message