Return-Path: X-Original-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D976193A5 for ; Mon, 21 Nov 2011 00:40:50 +0000 (UTC) Received: (qmail 71551 invoked by uid 500); 21 Nov 2011 00:40:47 -0000 Delivered-To: apmail-incubator-connectors-commits-archive@incubator.apache.org Received: (qmail 71493 invoked by uid 500); 21 Nov 2011 00:40:47 -0000 Mailing-List: contact connectors-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: connectors-dev@incubator.apache.org Delivered-To: mailing list connectors-commits@incubator.apache.org Received: (qmail 71486 invoked by uid 99); 21 Nov 2011 00:40:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Nov 2011 00:40:47 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Nov 2011 00:40:44 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 409A623888FD; Mon, 21 Nov 2011 00:40:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: connectors-commits@incubator.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111121004023.409A623888FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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());