incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1206460 [1/2] - in /incubator/lcf/branches/CONNECTORS-286/warthog: ./ src/main/java/org/apache/warthog/atomicserialization/ src/main/java/org/apache/warthog/atomictransaction/ src/main/java/org/apache/warthog/common/ src/main/java/org/apac...
Date Sat, 26 Nov 2011 15:27:45 GMT
Author: kwright
Date: Sat Nov 26 15:27:37 2011
New Revision: 1206460

URL: http://svn.apache.org/viewvc?rev=1206460&view=rev
Log:
Add tests and debug; also add various index constraint criteria.

Added:
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaAfter.java   (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaBefore.java   (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaBetween.java   (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEquals.java   (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsMultiple.java   (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsOrAfter.java   (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsOrBefore.java   (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongComparatorAscending.java   (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringComparatorAscending.java   (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/IndexRelationship.java   (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHConcurrencyException.java
      - copied, changed from r1205962, incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHDeadlockException.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHUniqueConstraintViolationException.java   (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/PerformanceTest.java   (with props)
Removed:
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/atomicserialization/
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/atomictransaction/
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/QueryRelationship.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/TableRelationship.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHDeadlockException.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHQueryResult.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/LongRowID.java
Modified:
    incubator/lcf/branches/CONNECTORS-286/warthog/build.xml
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongKey.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongValue.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringKey.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/FilterAccessor.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/FilterRelationship.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/JoinRelationship.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/SubqueryFilter.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHAccessor.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHAccessorBuilder.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHFilter.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndex.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHRelationship.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHRowID.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHTable.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHTableStore.java
    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/IndexAccessor.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/IndexNodeKey.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/TableAccessor.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableColumnKey.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableRowKey.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemAtomicKeyValueStore.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/SanityTest.java

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/build.xml?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/build.xml (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/build.xml Sat Nov 26 15:27:37 2011
@@ -47,7 +47,7 @@
 
     <target name="run-tests" depends="compile-tests">
         <mkdir dir="build/test-output"/>
-        <junit fork="true" maxmemory="512m" dir="build/test-output" outputtoformatters="true" showoutput="true" haltonfailure="true">
+        <junit fork="true" maxmemory="128m" dir="build/test-output" outputtoformatters="true" showoutput="true" haltonfailure="true">
             <classpath>
                 <fileset dir="lib">
                     <include name="*.jar"/>
@@ -63,6 +63,24 @@
         </junit>
     </target>
 
-    <target name="all" depends="compile"/>
+    <target name="run-perf-tests" depends="compile-tests">
+        <mkdir dir="build/test-output"/>
+        <junit fork="true" maxmemory="512m" dir="build/test-output" outputtoformatters="true" showoutput="true" haltonfailure="true">
+            <classpath>
+                <fileset dir="lib">
+                    <include name="*.jar"/>
+                </fileset>
+                <pathelement location="build/classes"/>
+                <pathelement location="build/test-classes"/>
+            </classpath>
+            <formatter type="brief" usefile="false"/>
+
+            <test name="org.apache.warthog.tests.PerformanceTest" todir="build/test-output"/>
+            <!-- MHL -->
+            
+        </junit>
+    </target>
+
+    <target name="all" depends="compile,run-tests"/>
     
 </project>

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaAfter.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaAfter.java?rev=1206460&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaAfter.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaAfter.java Sat Nov 26 15:27:37 2011
@@ -0,0 +1,64 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.warthog.common;
+
+import org.apache.warthog.interfaces.*;
+
+/** This class represents index criteria designed to locate matches that follow
+* a specific WHValue.
+*/
+public class CriteriaAfter extends IndexCriteria
+{
+  protected WHValue value;
+  
+  /** Constructor */
+  public CriteriaAfter(WHValue value)
+  {
+    super();
+    this.value = value;
+  }
+  
+  /** Evaluate a given value (which comes from a table row described by a btree node, and which
+  * may turn out to be null) against the criteria as determined by this class, and return
+  * an appropriate bit pattern.  The bit pattern is used to limit which branches of the index tree the search
+  * should descend.
+  *
+  * The comparator is provided to allow simple inequality comparisons against known values using the same logic
+  * as the index is organized by.
+  */
+  public int evaluateValue(WHValue value, WHComparator comparator)
+    throws WHException
+  {
+    int result = comparator.compare(value,this.value);
+    if (result == WHComparator.RESULT_EQUALS)
+      return SIGNAL_GREATER;
+    
+    if (result == WHComparator.RESULT_GREATER)
+      return SIGNAL_GREATER;
+    
+    if (result == WHComparator.RESULT_LESS)
+      return SIGNAL_LESSER | SIGNAL_EQUALS | SIGNAL_GREATER;
+    
+    throw new WHException("Comparator returned unexpected value");
+  }
+    
+}
+  
+  
\ No newline at end of file

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaAfter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaAfter.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaBefore.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaBefore.java?rev=1206460&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaBefore.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaBefore.java Sat Nov 26 15:27:37 2011
@@ -0,0 +1,64 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.warthog.common;
+
+import org.apache.warthog.interfaces.*;
+
+/** This class represents index criteria designed to locate matches that precede
+* a specific WHValue.
+*/
+public class CriteriaBefore extends IndexCriteria
+{
+  protected WHValue value;
+  
+  /** Constructor */
+  public CriteriaBefore(WHValue value)
+  {
+    super();
+    this.value = value;
+  }
+  
+  /** Evaluate a given value (which comes from a table row described by a btree node, and which
+  * may turn out to be null) against the criteria as determined by this class, and return
+  * an appropriate bit pattern.  The bit pattern is used to limit which branches of the index tree the search
+  * should descend.
+  *
+  * The comparator is provided to allow simple inequality comparisons against known values using the same logic
+  * as the index is organized by.
+  */
+  public int evaluateValue(WHValue value, WHComparator comparator)
+    throws WHException
+  {
+    int result = comparator.compare(value,this.value);
+    if (result == WHComparator.RESULT_EQUALS)
+      return SIGNAL_LESSER;
+    
+    if (result == WHComparator.RESULT_GREATER)
+      return SIGNAL_GREATER | SIGNAL_EQUALS | SIGNAL_LESSER;
+    
+    if (result == WHComparator.RESULT_LESS)
+      return SIGNAL_LESSER;
+    
+    throw new WHException("Comparator returned unexpected value");
+  }
+    
+}
+  
+  
\ No newline at end of file

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaBefore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaBefore.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaBetween.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaBetween.java?rev=1206460&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaBetween.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaBetween.java Sat Nov 26 15:27:37 2011
@@ -0,0 +1,76 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.warthog.common;
+
+import org.apache.warthog.interfaces.*;
+
+/** This class represents index criteria designed to locate matches that follow
+* a specific WHValue, but precede a second WHValue, non-inclusive.
+*/
+public class CriteriaBetween extends IndexCriteria
+{
+  protected WHValue afterValue;
+  protected WHValue beforeValue;
+  
+  /** Constructor */
+  public CriteriaBetween(WHValue afterValue, WHValue beforeValue)
+  {
+    super();
+    this.afterValue = afterValue;
+    this.beforeValue = beforeValue;
+  }
+  
+  /** Evaluate a given value (which comes from a table row described by a btree node, and which
+  * may turn out to be null) against the criteria as determined by this class, and return
+  * an appropriate bit pattern.  The bit pattern is used to limit which branches of the index tree the search
+  * should descend.
+  *
+  * The comparator is provided to allow simple inequality comparisons against known values using the same logic
+  * as the index is organized by.
+  */
+  public int evaluateValue(WHValue value, WHComparator comparator)
+    throws WHException
+  {
+    int afterResult = comparator.compare(value,afterValue);
+    if (afterResult == WHComparator.RESULT_EQUALS)
+      return SIGNAL_GREATER;
+    
+    if (afterResult == WHComparator.RESULT_GREATER)
+      return SIGNAL_GREATER;
+    
+    if (afterResult == WHComparator.RESULT_LESS)
+    {
+      int beforeResult = comparator.compare(value,beforeValue);
+      if (beforeResult == WHComparator.RESULT_EQUALS)
+        return SIGNAL_LESSER;
+      
+      if (beforeResult == WHComparator.RESULT_GREATER)
+        return SIGNAL_LESSER | SIGNAL_EQUALS | SIGNAL_GREATER;
+      
+      if (beforeResult == WHComparator.RESULT_LESS)
+        return SIGNAL_LESSER;
+    }
+    
+    throw new WHException("Comparator returned unexpected value");
+  }
+    
+}
+  
+  
\ No newline at end of file

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaBetween.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaBetween.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEquals.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEquals.java?rev=1206460&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEquals.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEquals.java Sat Nov 26 15:27:37 2011
@@ -0,0 +1,64 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.warthog.common;
+
+import org.apache.warthog.interfaces.*;
+
+/** This class represents index criteria designed to locate only exact matches against
+* a specific WHValue.
+*/
+public class CriteriaEquals extends IndexCriteria
+{
+  protected WHValue value;
+  
+  /** Constructor */
+  public CriteriaEquals(WHValue value)
+  {
+    super();
+    this.value = value;
+  }
+  
+  /** Evaluate a given value (which comes from a table row described by a btree node, and which
+  * may turn out to be null) against the criteria as determined by this class, and return
+  * an appropriate bit pattern.  The bit pattern is used to limit which branches of the index tree the search
+  * should descend.
+  *
+  * The comparator is provided to allow simple inequality comparisons against known values using the same logic
+  * as the index is organized by.
+  */
+  public int evaluateValue(WHValue value, WHComparator comparator)
+    throws WHException
+  {
+    int result = comparator.compare(value,this.value);
+    if (result == WHComparator.RESULT_EQUALS)
+      return SIGNAL_EQUALS;
+    
+    if (result == WHComparator.RESULT_GREATER)
+      return SIGNAL_GREATER;
+    
+    if (result == WHComparator.RESULT_LESS)
+      return SIGNAL_LESSER;
+    
+    throw new WHException("Comparator returned unexpected value");
+  }
+    
+}
+  
+  
\ No newline at end of file

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEquals.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEquals.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsMultiple.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsMultiple.java?rev=1206460&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsMultiple.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsMultiple.java Sat Nov 26 15:27:37 2011
@@ -0,0 +1,75 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.warthog.common;
+
+import org.apache.warthog.interfaces.*;
+
+/** This class represents index criteria designed to locate only exact matches against
+* a specific set of WHValues.
+*/
+public class CriteriaEqualsMultiple extends IndexCriteria
+{
+  protected WHValue[] values;
+  
+  /** Constructor */
+  public CriteriaEqualsMultiple(WHValue[] values)
+  {
+    super();
+    this.values = values;
+  }
+  
+  /** Evaluate a given value (which comes from a table row described by a btree node, and which
+  * may turn out to be null) against the criteria as determined by this class, and return
+  * an appropriate bit pattern.  The bit pattern is used to limit which branches of the index tree the search
+  * should descend.
+  *
+  * The comparator is provided to allow simple inequality comparisons against known values using the same logic
+  * as the index is organized by.
+  */
+  public int evaluateValue(WHValue value, WHComparator comparator)
+    throws WHException
+  {
+    
+    // Accumulate result
+    int rval = 0;
+    
+    for (int i = 0 ; i < values.length ; i++)
+    {
+      // Look at this value, and accumulate results
+      int result = comparator.compare(value,values[i]);
+      if (result == WHComparator.RESULT_EQUALS)
+        rval |= SIGNAL_EQUALS;
+      
+      else if (result == WHComparator.RESULT_GREATER)
+        rval |= SIGNAL_GREATER;
+      
+      else if (result == WHComparator.RESULT_LESS)
+        rval |= SIGNAL_LESSER;
+      
+      else
+        throw new WHException("Comparator returned unexpected value");
+    }
+    
+    return rval;
+  }
+    
+}
+  
+  
\ No newline at end of file

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsMultiple.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsMultiple.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsOrAfter.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsOrAfter.java?rev=1206460&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsOrAfter.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsOrAfter.java Sat Nov 26 15:27:37 2011
@@ -0,0 +1,64 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.warthog.common;
+
+import org.apache.warthog.interfaces.*;
+
+/** This class represents index criteria designed to locate matches that equal or come after
+* a specific WHValue.
+*/
+public class CriteriaEqualsOrAfter extends IndexCriteria
+{
+  protected WHValue value;
+  
+  /** Constructor */
+  public CriteriaEqualsOrAfter(WHValue value)
+  {
+    super();
+    this.value = value;
+  }
+  
+  /** Evaluate a given value (which comes from a table row described by a btree node, and which
+  * may turn out to be null) against the criteria as determined by this class, and return
+  * an appropriate bit pattern.  The bit pattern is used to limit which branches of the index tree the search
+  * should descend.
+  *
+  * The comparator is provided to allow simple inequality comparisons against known values using the same logic
+  * as the index is organized by.
+  */
+  public int evaluateValue(WHValue value, WHComparator comparator)
+    throws WHException
+  {
+    int result = comparator.compare(value,this.value);
+    if (result == WHComparator.RESULT_EQUALS)
+      return SIGNAL_GREATER | SIGNAL_EQUALS;
+    
+    if (result == WHComparator.RESULT_GREATER)
+      return SIGNAL_GREATER;
+    
+    if (result == WHComparator.RESULT_LESS)
+      return SIGNAL_LESSER | SIGNAL_EQUALS | SIGNAL_GREATER;
+    
+    throw new WHException("Comparator returned unexpected value");
+  }
+    
+}
+  
+  
\ No newline at end of file

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsOrAfter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsOrAfter.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsOrBefore.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsOrBefore.java?rev=1206460&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsOrBefore.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsOrBefore.java Sat Nov 26 15:27:37 2011
@@ -0,0 +1,64 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.warthog.common;
+
+import org.apache.warthog.interfaces.*;
+
+/** This class represents index criteria designed to locate that precede or equal
+* a specific WHValue.
+*/
+public class CriteriaEqualsOrBefore extends IndexCriteria
+{
+  protected WHValue value;
+  
+  /** Constructor */
+  public CriteriaEqualsOrBefore(WHValue value)
+  {
+    super();
+    this.value = value;
+  }
+  
+  /** Evaluate a given value (which comes from a table row described by a btree node, and which
+  * may turn out to be null) against the criteria as determined by this class, and return
+  * an appropriate bit pattern.  The bit pattern is used to limit which branches of the index tree the search
+  * should descend.
+  *
+  * The comparator is provided to allow simple inequality comparisons against known values using the same logic
+  * as the index is organized by.
+  */
+  public int evaluateValue(WHValue value, WHComparator comparator)
+    throws WHException
+  {
+    int result = comparator.compare(value,this.value);
+    if (result == WHComparator.RESULT_EQUALS)
+      return SIGNAL_LESSER | SIGNAL_EQUALS;
+    
+    if (result == WHComparator.RESULT_GREATER)
+      return SIGNAL_GREATER | SIGNAL_EQUALS | SIGNAL_LESSER;
+    
+    if (result == WHComparator.RESULT_LESS)
+      return SIGNAL_LESSER;
+    
+    throw new WHException("Comparator returned unexpected value");
+  }
+    
+}
+  
+  
\ No newline at end of file

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsOrBefore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CriteriaEqualsOrBefore.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongComparatorAscending.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongComparatorAscending.java?rev=1206460&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongComparatorAscending.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongComparatorAscending.java Sat Nov 26 15:27:37 2011
@@ -0,0 +1,50 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.warthog.common;
+
+import org.apache.warthog.interfaces.*;
+
+/** Class that compares long values, and sorts in ascending order.
+*/
+public class LongComparatorAscending implements WHComparator
+{
+  /** Comparison method.
+  * This is only ever used to compare values; it cannot be used to compare null vs. non-null.
+  */
+  public int compare(WHValue leftValue, WHValue rightValue)
+    throws WHException
+  {
+    if (leftValue == null && rightValue == null)
+      return RESULT_EQUALS;
+    // Sort null values to the end
+    if (leftValue == null)
+      return RESULT_LESS;
+    if (rightValue == null)
+      return RESULT_GREATER;
+    if (!(leftValue instanceof LongValue) || !(rightValue instanceof LongValue))
+      throw new WHException("Cannot compare anything other than LongValues here");
+    long leftLongValue = ((LongValue)leftValue).getValue();
+    long rightLongValue = ((LongValue)rightValue).getValue();
+    if (leftLongValue == rightLongValue)
+      return RESULT_EQUALS;
+    return (leftLongValue < rightLongValue)?RESULT_GREATER:RESULT_LESS;
+  }
+  
+}
\ No newline at end of file

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongComparatorAscending.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongComparatorAscending.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongKey.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongKey.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongKey.java Sat Nov 26 15:27:37 2011
@@ -25,20 +25,24 @@ import org.apache.warthog.interfaces.*;
 */
 public class LongKey extends LongValue implements WHKey
 {
+  protected long hashCodeValue;
+  
   public LongKey(long value)
   {
     super(value);
+    hashCodeValue = calculateHashCode(value);
   }
   
   public LongKey(byte[] bytes)
   {
     super(bytes);
+    hashCodeValue = calculateHashCode(value);
   }
 
   /** Calculate the hash function. */
   public long getHashCode()
   {
-    return calculateHashCode(value);
+    return hashCodeValue;
   }
   
   public static long calculateHashCode(long value)

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongValue.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongValue.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongValue.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongValue.java Sat Nov 26 15:27:37 2011
@@ -23,7 +23,7 @@ import org.apache.warthog.interfaces.*;
 
 /** Long value, serializable.
 */
-public class LongValue implements WHValue
+public class LongValue implements WHValue, WHRowID
 {
   long value;
   

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringComparatorAscending.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringComparatorAscending.java?rev=1206460&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringComparatorAscending.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringComparatorAscending.java Sat Nov 26 15:27:37 2011
@@ -0,0 +1,51 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.warthog.common;
+
+import org.apache.warthog.interfaces.*;
+
+/** Class that compares string values, and sorts in ascending order.
+*/
+public class StringComparatorAscending implements WHComparator
+{
+  /** Comparison method.
+  * This is only ever used to compare values; it cannot be used to compare null vs. non-null.
+  */
+  public int compare(WHValue leftValue, WHValue rightValue)
+    throws WHException
+  {
+    if (leftValue == null && rightValue == null)
+      return RESULT_EQUALS;
+    // Sort null values to the end
+    if (leftValue == null)
+      return RESULT_LESS;
+    if (rightValue == null)
+      return RESULT_GREATER;
+    if (!(leftValue instanceof StringValue) || !(rightValue instanceof StringValue))
+      throw new WHException("Cannot compare anything other than StringValues here");
+    String leftStringValue = ((StringValue)leftValue).getValue();
+    String rightStringValue = ((StringValue)rightValue).getValue();
+    int compare = leftStringValue.compareTo(rightStringValue);
+    if (compare == 0)
+      return RESULT_EQUALS;
+    return (compare < 0)?RESULT_GREATER:RESULT_LESS;
+  }
+  
+}
\ No newline at end of file

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringComparatorAscending.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringComparatorAscending.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringKey.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringKey.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringKey.java Sat Nov 26 15:27:37 2011
@@ -25,20 +25,24 @@ import org.apache.warthog.interfaces.*;
 */
 public class StringKey extends StringValue implements WHKey
 {
+  protected long hashCodeValue;
+  
   public StringKey(String value)
   {
     super(value);
+    hashCodeValue = calculateHashCode(value);
   }
   
   public StringKey(byte[] bytes)
   {
     super(bytes);
+    hashCodeValue = calculateHashCode(value);
   }
 
   /** Calculate the hash function. */
   public long getHashCode()
   {
-    return calculateHashCode(value);
+    return hashCodeValue;
   }
   
   public static long calculateHashCode(String value)

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/FilterAccessor.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/FilterAccessor.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/FilterAccessor.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/FilterAccessor.java Sat Nov 26 15:27:37 2011
@@ -26,7 +26,7 @@ public class FilterAccessor implements W
   protected WHRelationship relationshipToFilter;
   protected WHFilter filter;
   protected WHAccessor baseAccessor;
-  protected long nextRow = -1L;
+  protected WHRowID nextRow = null;
     
   public FilterAccessor(WHAccessor baseAccessor, WHRelationship relationshipToFilter, WHFilter filter)
     throws WHException
@@ -41,11 +41,11 @@ public class FilterAccessor implements W
   public boolean hasNext()
     throws WHException
   {
-    if (nextRow == -1L)
+    if (nextRow == null)
     {
       // Locate the next row, or bump into the end.
       nextRow = findNextRow();
-      if (nextRow == -1L)
+      if (nextRow == null)
         return false;
     }
     return true;
@@ -53,26 +53,26 @@ public class FilterAccessor implements W
     
   /** Read the next matching relationship row ID,
   */
-  public long getNext()
+  public WHRowID getNext()
     throws WHException
   {
-    if (nextRow == -1L)
+    if (nextRow == null)
       nextRow = findNextRow();
-    long rval = nextRow;
-    nextRow = -1L;
+    WHRowID rval = nextRow;
+    nextRow = null;
     return rval;
   }
 
   /** Find the next (filtered) row */
-  protected long findNextRow()
+  protected WHRowID findNextRow()
     throws WHException
   {
     while (baseAccessor.hasNext())
     {
-      long theRow = baseAccessor.getNext();
+      WHRowID theRow = baseAccessor.getNext();
       if (filter == null || filter.include(relationshipToFilter,theRow))
         return theRow;
     }
-    return -1L;
+    return null;
   }
 }

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/FilterRelationship.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/FilterRelationship.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/FilterRelationship.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/FilterRelationship.java Sat Nov 26 15:27:37 2011
@@ -41,7 +41,7 @@ public class FilterRelationship implemen
   }
   
   /** Get the data for a given row and column. */
-  public WHValue getValue(long rowID, String columnName)
+  public WHValue getValue(WHRowID rowID, String columnName)
     throws WHException
   {
     return relationshipToFilter.getValue(rowID,columnName);
@@ -51,10 +51,10 @@ public class FilterRelationship implemen
   * both the initial set of rows and the ordering.  The results can be later filtered to
   * yield the final output data.
   */
-  public WHAccessor getAccessor()
+  public WHAccessor buildAccessor()
     throws WHException
   {
-    return new FilterAccessor(relationshipToFilter.getAccessor(),this,filterer);
+    return new FilterAccessor(relationshipToFilter.buildAccessor(),this,filterer);
   }
   
 }

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/IndexRelationship.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/IndexRelationship.java?rev=1206460&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/IndexRelationship.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/IndexRelationship.java Sat Nov 26 15:27:37 2011
@@ -0,0 +1,61 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.warthog.interfaces;
+
+/** The index relationship basically views another relationship (a table) through
+* an index with criteria.
+*/
+public class IndexRelationship implements WHRelationship
+{
+  protected WHIndex index;
+  protected IndexCriteria[] criteria;
+  
+  /** Constructor */
+  public IndexRelationship(WHIndex index, IndexCriteria[] criteria)
+  {
+    this.index = index;
+    this.criteria = criteria;
+  }
+  
+  /** Get the column names represented by the relationship. */
+  public String[] getColumnNames()
+    throws WHException
+  {
+    return index.getRelationship().getColumnNames();
+  }
+  
+  /** Get the data for a given row and column. */
+  public WHValue getValue(WHRowID rowID, String columnName)
+    throws WHException
+  {
+    return index.getRelationship().getValue(rowID,columnName);
+  }
+
+  /** Get the row accessor.  This determines
+  * both the initial set of rows and the ordering.  The results can be later filtered to
+  * yield the final output data.
+  */
+  public WHAccessor buildAccessor()
+    throws WHException
+  {
+    return index.buildAccessor(criteria);
+  }
+  
+}

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/IndexRelationship.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/IndexRelationship.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/JoinRelationship.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/JoinRelationship.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/JoinRelationship.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/JoinRelationship.java Sat Nov 26 15:27:37 2011
@@ -36,7 +36,7 @@ public class JoinRelationship implements
   }
 
   /** Get the data for a given row and column. */
-  public WHValue getValue(long rowID, String columnName)
+  public WHValue getValue(WHRowID rowID, String columnName)
     throws WHException
   {
     // MHL
@@ -47,7 +47,7 @@ public class JoinRelationship implements
   * both the initial set of rows and the ordering.  The results can be later filtered to
   * yield the final output data.
   */
-  public WHAccessor getAccessor()
+  public WHAccessor buildAccessor()
     throws WHException
   {
     // MHL

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/SubqueryFilter.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/SubqueryFilter.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/SubqueryFilter.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/SubqueryFilter.java Sat Nov 26 15:27:37 2011
@@ -42,7 +42,7 @@ public class SubqueryFilter implements W
   
   /** Check if a row should be filtered or not.
   */
-  public boolean include(WHRelationship relationship, long rowID)
+  public boolean include(WHRelationship relationship, WHRowID rowID)
     throws WHException
   {
     WHAccessor accessor = builder.createAccessor(relationship,rowID);

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHAccessor.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHAccessor.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHAccessor.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHAccessor.java Sat Nov 26 15:27:37 2011
@@ -31,6 +31,6 @@ public interface WHAccessor
   
   /** Read the next matching relationship row ID,
   */
-  public long getNext()
+  public WHRowID getNext()
     throws WHException;
 }

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHAccessorBuilder.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHAccessorBuilder.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHAccessorBuilder.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHAccessorBuilder.java Sat Nov 26 15:27:37 2011
@@ -28,7 +28,7 @@ public interface WHAccessorBuilder
   * relationship.
   */
   public WHAccessor createAccessor(WHRelationship relationship,
-    long rowID)
+    WHRowID rowID)
     throws WHException;
   
 }
\ No newline at end of file

Copied: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHConcurrencyException.java (from r1205962, incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHDeadlockException.java)
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHConcurrencyException.java?p2=incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHConcurrencyException.java&p1=incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHDeadlockException.java&r1=1205962&r2=1206460&rev=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHDeadlockException.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHConcurrencyException.java Sat Nov 26 15:27:37 2011
@@ -22,11 +22,15 @@ package org.apache.warthog.interfaces;
 /** This exception is special in that it indicates a deadlock detection, which means
 * transaction has to be backed out and retried from start.
 */
-public class WHDeadlockException extends WHException
+public class WHConcurrencyException extends WHException
 {
-  public WHDeadlockException()
+  public WHConcurrencyException()
   {
-    super("Deadlock occurred");
+    super("Concurrent modification detected");
   }
   
+  public WHConcurrencyException(String msg)
+  {
+    super(msg);
+  }
 }

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHFilter.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHFilter.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHFilter.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHFilter.java Sat Nov 26 15:27:37 2011
@@ -25,7 +25,7 @@ public interface WHFilter
 {
   /** Check if a row should be filtered or not.
   */
-  public boolean include(WHRelationship relationship, long rowID)
+  public boolean include(WHRelationship relationship, WHRowID rowID)
     throws WHException;
   
 }

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndex.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndex.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndex.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndex.java Sat Nov 26 15:27:37 2011
@@ -22,24 +22,24 @@ package org.apache.warthog.interfaces;
 /** This abstraction provides access to a btree index.   Note: This is a permanent
 * structure, and can only index a permanent table.
 */
-public interface WHIndex
+public interface WHIndex extends WHRelationship
 {
   /** Get the index name.
   */
   public String getName()
     throws WHException;
 
-  /** Get the table the index applies to.
+  /** Get the relationship the index applies to.
   */
-  public WHTable getTable()
+  public WHRelationship getRelationship()
     throws WHException;
   
   /** Get the columns that are indexed
   */
-  public String[] getColumnNames()
+  public String[] getIndexColumns()
     throws WHException;
 
-  // Accessor support method.
+  // Additional accessor support method.
   //
   // Index access supports any kind of matches which allow pruning of whole subtrees
   // during index scanning.  Effectively this means that any criteria supplied must have

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHRelationship.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHRelationship.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHRelationship.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHRelationship.java Sat Nov 26 15:27:37 2011
@@ -30,14 +30,14 @@ public interface WHRelationship
     throws WHException;
   
   /** Get the data for a given row and column. */
-  public WHValue getValue(long rowID, String columnName)
+  public WHValue getValue(WHRowID rowID, String columnName)
     throws WHException;
 
   /** Get the row accessor.  This determines
   * both the initial set of rows and the ordering.  The results can be later filtered to
   * yield the final output data.
   */
-  public WHAccessor getAccessor()
+  public WHAccessor buildAccessor()
     throws WHException;
   
 }

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHRowID.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHRowID.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHRowID.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHRowID.java Sat Nov 26 15:27:37 2011
@@ -26,7 +26,7 @@ package org.apache.warthog.interfaces;
 * idea is that the precise form of a row ID is only known to the relationship
 * from which it came (and in which it will be interpreted).
 */
-public interface WHRowID extends WHKey
+public interface WHRowID
 {
-  // Right at the moment, there's no special methods needed
+  // Right at the moment, there are no special methods needed
 }

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHTable.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHTable.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHTable.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHTable.java Sat Nov 26 15:27:37 2011
@@ -23,18 +23,13 @@ package org.apache.warthog.interfaces;
 * be used within the context of the WHTableStore object that created it.  Note: This is a
 * permanent structure.
 */
-public interface WHTable
+public interface WHTable extends WHRelationship
 {
   /** Get the table name.
   */
   public String getName()
     throws WHException;
 
-  /** Get the column names.
-  */
-  public String[] getColumnNames()
-    throws WHException;
-  
   /** Insert a row */
   public void insertRow(String[] columns, WHValue[] values)
     throws WHException;
@@ -48,12 +43,4 @@ public interface WHTable
   public void deleteRows(WHAccessor accessor, WHFilter filter)
     throws WHException;
   
-  /** Get the data for a given row and column. */
-  public WHValue getValue(long rowID, String columnName)
-    throws WHException;
-
-  /** Build an accessor that simply scans all the rows in the table */
-  public WHAccessor buildAccessor()
-    throws WHException;
-
 }
\ No newline at end of file

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHTableStore.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHTableStore.java?rev=1206460&r1=1206459&r2=1206460&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHTableStore.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHTableStore.java Sat Nov 26 15:27:37 2011
@@ -63,7 +63,7 @@ public interface WHTableStore
     throws WHException;
     
   /** Perform a query */
-  public WHQueryResult performQuery(QueryDescription specification)
+  public WHRelationship performQuery(QueryDescription specification)
     throws WHException;
     
 }

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHUniqueConstraintViolationException.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHUniqueConstraintViolationException.java?rev=1206460&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHUniqueConstraintViolationException.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHUniqueConstraintViolationException.java Sat Nov 26 15:27:37 2011
@@ -0,0 +1,36 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.warthog.interfaces;
+
+/** This exception signals a constraint violation, which usually indicates deadlock.
+*/
+public class WHUniqueConstraintViolationException extends WHConcurrencyException
+{
+  public WHUniqueConstraintViolationException()
+  {
+    super();
+  }
+
+  public WHUniqueConstraintViolationException(String msg)
+  {
+    super(msg);
+  }
+  
+}

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHUniqueConstraintViolationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHUniqueConstraintViolationException.java
------------------------------------------------------------------------------
    svn:keywords = Id

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=1206460&r1=1206459&r2=1206460&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 Sat Nov 26 15:27:37 2011
@@ -63,6 +63,8 @@ public class Index implements WHIndex
   public Index(TableStore ts, Table table, String indexName, String[] columnNames, String[] comparatorClasses, boolean unique)
     throws WHException
   {
+    if (columnNames.length != comparatorClasses.length)
+      throw new WHException("Number of index column names must match number of comparator classes");
     this.ts = ts;
     this.table = table;
     this.indexName = indexName;
@@ -82,19 +84,43 @@ public class Index implements WHIndex
     }
   }
   
-  /** Get the table the index applies to.
+  /** Get the relationship the index applies to.
   */
-  public WHTable getTable()
+  public WHRelationship getRelationship()
     throws WHException
   {
     return table;
   }
   
-  /** Get the columns that are indexed
+  /** Get the underlying relationship column names.
   */
   public String[] getColumnNames()
     throws WHException
   {
+    return table.getColumnNames();
+  }
+
+  /** Get the data for a given row and column. */
+  public WHValue getValue(WHRowID rowID, String columnName)
+    throws WHException
+  {
+    return table.getValue(rowID,columnName);
+  }
+
+  /** Get a default accessor with ordering but no filtering.
+  */
+  public WHAccessor buildAccessor()
+    throws WHException
+  {
+    // Use null criteria
+    return buildAccessor(new IndexCriteria[columnNames.length]);
+  }
+  
+  /** Get the columns that are indexed
+  */
+  public String[] getIndexColumns()
+    throws WHException
+  {
     return columnNames;
   }
 
@@ -105,6 +131,8 @@ public class Index implements WHIndex
   public WHAccessor buildAccessor(IndexCriteria[] criteria)
     throws WHException
   {
+    if (criteria.length != columnNames.length)
+      throw new WHException("Criteria count must match index column count");
     return new IndexAccessor(this,criteria);
   }
   
@@ -116,6 +144,11 @@ public class Index implements WHIndex
   }
 
   // Below this line are methods that are not meant to be used for general purposes,
+
+  protected Table getTable()
+  {
+    return table;
+  }
   
   /** Get the comparators.
   */
@@ -127,7 +160,7 @@ public class Index implements WHIndex
   /** Add a new row to the index.
   * The row must already exist in the underlying table.
   */
-  protected void addNewRow(long rowID)
+  protected void addNewRow(LongValue rowID)
     throws WHException
   {
     // The algorithm here simply involves finding the right spot and adding a new node at that point.
@@ -138,7 +171,7 @@ public class Index implements WHIndex
   
   /** Method to add a given node into a subtree where we start only with a parent key.
   */
-  protected void addNodeInto(long rowID, WHKey parentKey)
+  protected void addNodeInto(LongValue rowID, WHKey parentKey)
     throws WHException
   {
     for (int columnIndex = 0 ; columnIndex < columnNames.length ; columnIndex++ )
@@ -147,19 +180,13 @@ public class Index implements WHIndex
       // This will either wind up in an equals chain (in which case, a link to the column child will already exist),
       // or it will wind up as a new primary node (in which case, the link to the column child will need to be created).
       
-      WHKey columnKey = placeIntoBtree(rowID,parentKey,columnIndex);
-
-      // Create the column link, if it needs creating
-      if (columnIndex + 1 < columnNames.length && columnKey == null)
-        parentKey = new IndexNodeColumnKey(indexName,rowID,columnNames[columnIndex]);
-      else
-        parentKey = columnKey;
+      parentKey = placeIntoBtree(rowID,parentKey,columnIndex);
     }
   }
   
   /** Method to place a new node into a specific tree for a column.
   */
-  protected WHKey placeIntoBtree(long rowID, WHKey parentKey, int columnIndex)
+  protected WHKey placeIntoBtree(LongValue rowID, WHKey parentKey, int columnIndex)
     throws WHException
   {
     // Get the current column
@@ -171,12 +198,12 @@ public class Index implements WHIndex
     while (true)
     {
       // Pick up the current node from the parent
-      long currentRowID = readIndexParentChild(parentKey);
-      if (currentRowID == -1L)
+      LongValue currentRowID = readIndexParentChild(parentKey);
+      if (currentRowID == null)
       {
         // Set the node in place
         setIndexParentChild(parentKey,columnName,rowID);
-        return new IndexNodeColumnKey(indexName,currentRowID,columnName);
+        return new IndexNodeColumnKey(indexName,rowID.getValue(),columnName);
       }
 
       // Read the value at this node
@@ -190,11 +217,11 @@ public class Index implements WHIndex
       {
       case WHComparator.RESULT_LESS:
         // Descend the lesser tree for this column.
-        parentKey = new IndexNodeLesserKey(indexName,currentRowID,columnName);
+        parentKey = new IndexNodeLesserKey(indexName,currentRowID.getValue(),columnName);
         continue;
       case WHComparator.RESULT_GREATER:
         // Descend the greater tree for this column.
-        parentKey = new IndexNodeGreaterKey(indexName,currentRowID,columnName);
+        parentKey = new IndexNodeGreaterKey(indexName,currentRowID.getValue(),columnName);
         continue;
       case WHComparator.RESULT_EQUALS:
         // Insert here!  into the chain if need be...
@@ -206,17 +233,17 @@ public class Index implements WHIndex
       if (unique && columnIndex +1 == columnNames.length)
       {
         // Unique constraint violation
-        throw new WHDeadlockException();
+        throw new WHUniqueConstraintViolationException("Row "+new Long(rowID.getValue()).toString()+" violates uniqueness constraint on index "+indexName);
       }
       
       // We keep a linked list of identical nodes.  We can insert into that chain at any point.
       // We insert the new node at the beginning of the chain so we don't have to scan it, obviously...
       
       // First, get the old ref, if there is one.
-      long currentEqualsRowID = readIndexNodeEqualsNode(currentRowID,columnName);
+      LongValue currentEqualsRowID = readIndexNodeEqualsNode(currentRowID,columnName);
       
       // Move the old pointer to the new position
-      if (currentEqualsRowID != -1L)
+      if (currentEqualsRowID != null)
       {
         // Delete the old one
         deleteIndexNodeEqualsNode(currentRowID,columnName);
@@ -227,13 +254,13 @@ public class Index implements WHIndex
       // Now, set the new ref.
       setIndexNodeEqualsNode(currentRowID,columnName,rowID);
       
-      return new IndexNodeEqualsKey(indexName,currentRowID,columnName);
+      return new IndexNodeColumnKey(indexName,currentRowID.getValue(),columnName);
     }
   }
   
   /** Remove a row from the index.  The row must currently exist.
   */
-  protected void deleteRow(long rowID)
+  protected void deleteRow(LongValue rowID)
     throws WHException
   {
     // The deletion algorithm must remove N keys, one per column.  We start with the key for
@@ -255,7 +282,7 @@ public class Index implements WHIndex
   
   /** Remove a row for a specific column from the corresponding btree.
   */
-  protected void removeFromBtree(long rowID, int columnIndex)
+  protected void removeFromBtree(LongValue rowID, int columnIndex)
     throws WHException
   {
     String columnName = columnNames[columnIndex];
@@ -264,8 +291,8 @@ public class Index implements WHIndex
     WHKey parentKey = readIndexNodeParentKey(rowID,columnName);
     
     // Look for an 'equals' child
-    long equalsChild = readIndexNodeEqualsNode(rowID,columnName);
-    if (equalsChild != -1L)
+    LongValue equalsChild = readIndexNodeEqualsNode(rowID,columnName);
+    if (equalsChild != null)
     {
       // Case (1) (as described above).  Promote the child.  We know the child has
       // no greater/lesser children.
@@ -273,14 +300,14 @@ public class Index implements WHIndex
       deleteIndexParentChild(parentKey,columnName);
       setIndexParentChild(parentKey,columnName,equalsChild);
       // Now, transfer the delete node's lesser/greater children to the equalsChild.
-      long lesserChild = readIndexNodeLesserNode(rowID,columnName);
-      if (lesserChild != -1L)
+      LongValue lesserChild = readIndexNodeLesserNode(rowID,columnName);
+      if (lesserChild != null)
       {
         deleteIndexNodeLesserNode(rowID,columnName);
         setIndexNodeLesserNode(equalsChild,columnName,lesserChild);
       }
-      long greaterChild = readIndexNodeGreaterNode(rowID,columnName);
-      if (greaterChild != -1L)
+      LongValue greaterChild = readIndexNodeGreaterNode(rowID,columnName);
+      if (greaterChild != null)
       {
         deleteIndexNodeGreaterNode(rowID,columnName);
         setIndexNodeGreaterNode(equalsChild,columnName,greaterChild);
@@ -297,37 +324,37 @@ public class Index implements WHIndex
     deleteIndexParentChild(parentKey,columnName);
     
     // Now look for a promotion candidate to hook in in its place.
-    long promotionCandidate = -1L;
-    if (promotionCandidate == -1L)
+    LongValue promotionCandidate = null;
+    if (promotionCandidate == null)
     {
       promotionCandidate = readIndexNodeLesserNode(rowID,columnName);
-      if (promotionCandidate != -1L)
+      if (promotionCandidate != null)
         // We found our promotion candidate!
         deleteIndexNodeLesserNode(rowID,columnName);
     }
-    if (promotionCandidate == -1L)
+    if (promotionCandidate == null)
     {
       promotionCandidate = readIndexNodeGreaterNode(rowID,columnName);
-      if (promotionCandidate != -1L)
+      if (promotionCandidate != null)
         // Candidate found
         deleteIndexNodeGreaterNode(rowID,columnName);
     }
     
-    if (promotionCandidate != -1L)
+    if (promotionCandidate != null)
     {
       // Hook in the promotion candidate as child of the parent.
       setIndexParentChild(parentKey,columnName,promotionCandidate);
       // Transfer the remaining lesser/greater children into the promotionCandidate node
-      long lesserChild = readIndexNodeLesserNode(rowID,columnName);
-      if (lesserChild != -1L)
+      LongValue lesserChild = readIndexNodeLesserNode(rowID,columnName);
+      if (lesserChild != null)
       {
         // Peel it away from the deleteNodeID
         deleteIndexNodeLesserNode(rowID,columnName);
         // Now insert this node into promotionCandidate via parentKey
         placeIntoBtree(lesserChild,parentKey,columnIndex);
       }
-      long greaterChild = readIndexNodeGreaterNode(rowID,columnName);
-      if (greaterChild != -1L)
+      LongValue greaterChild = readIndexNodeGreaterNode(rowID,columnName);
+      if (greaterChild != null)
       {
         // Delete the reference from the deletion node
         deleteIndexNodeGreaterNode(rowID,columnName);
@@ -348,7 +375,7 @@ public class Index implements WHIndex
     WHAccessor tableAccessor = table.buildAccessor();
     while (tableAccessor.hasNext())
     {
-      long rowID = tableAccessor.getNext();
+      LongValue rowID = (LongValue)tableAccessor.getNext();
       // Add this row to the index.
       addNewRow(rowID);
     }
@@ -373,9 +400,9 @@ public class Index implements WHIndex
       return;
 
     // For this btree, start with the root
-    long child = readIndexParentChild(key);
+    LongValue child = readIndexParentChild(key);
     // If there's no root, we are done
-    if (child == -1L)
+    if (child == null)
       return;
     
     // Delete the child.
@@ -383,11 +410,11 @@ public class Index implements WHIndex
     // First, unlink from the parent.
     deleteIndexParentChild(key,columnName);
     // Recursively clean up all child links.
-    deleteBtree(new IndexNodeEqualsKey(indexName,child,columnName),indexColumn);
-    deleteBtree(new IndexNodeLesserKey(indexName,child,columnName),indexColumn);
-    deleteBtree(new IndexNodeGreaterKey(indexName,child,columnName),indexColumn);
+    deleteBtree(new IndexNodeEqualsKey(indexName,child.getValue(),columnName),indexColumn);
+    deleteBtree(new IndexNodeLesserKey(indexName,child.getValue(),columnName),indexColumn);
+    deleteBtree(new IndexNodeGreaterKey(indexName,child.getValue(),columnName),indexColumn);
     // Move on to next column
-    deleteBtree(new IndexNodeColumnKey(indexName,child,columnName),indexColumn+1);
+    deleteBtree(new IndexNodeColumnKey(indexName,child.getValue(),columnName),indexColumn+1);
   }
   
   // Protected methods
@@ -395,35 +422,32 @@ public class Index implements WHIndex
   /** Get next column's root node for an index node.
   * This link is necessary in order to allow each tree to rebalance independently.
   */
-  protected long readIndexNodeColumnNode(long rowID, String columnName)
+  protected LongValue readIndexNodeColumnNode(LongValue rowID, String columnName)
     throws WHException
   {
-    LongValue outRowID = (LongValue)ts.get(new IndexNodeColumnKey(indexName,rowID,columnName));
-    if (outRowID == null)
-      return -1L;
-    return outRowID.getValue();
+    return (LongValue)ts.get(new IndexNodeColumnKey(indexName,rowID.getValue(),columnName));
   }
   
   /** Set next column's root node for an index node.
   */
-  protected void setIndexNodeColumnNode(long rowID, String columnName, long refRowID)
+  protected void setIndexNodeColumnNode(LongValue rowID, String columnName, LongValue refRowID)
     throws WHException
   {
-    IndexNodeColumnKey key = new IndexNodeColumnKey(indexName,rowID,columnName);
-    IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,refRowID,columnName);
-    ts.put(key,new LongValue(refRowID));
+    IndexNodeColumnKey key = new IndexNodeColumnKey(indexName,rowID.getValue(),columnName);
+    IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,refRowID.getValue(),columnName);
+    ts.put(key,refRowID);
     ts.put(parentKey,key);
   }
 
   /** Delete the column root-node child reference for an index node.  Presumes that the reference exists.
   */
-  protected void deleteIndexNodeColumnNode(long rowID, String columnName)
+  protected void deleteIndexNodeColumnNode(LongValue rowID, String columnName)
     throws WHException
   {
-    IndexNodeColumnKey key = new IndexNodeColumnKey(indexName,rowID,columnName);
+    IndexNodeColumnKey key = new IndexNodeColumnKey(indexName,rowID.getValue(),columnName);
     LongValue childReference = (LongValue)ts.get(key);
     if (childReference == null)
-      throw new WHDeadlockException();
+      throw new WHConcurrencyException();
     IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,childReference.getValue(),columnName);
     ts.put(key,null);
     ts.put(parentKey,null);
@@ -431,35 +455,32 @@ public class Index implements WHIndex
   
   /** Get the lesser child reference for an index node.
   */
-  protected long readIndexNodeLesserNode(long rowID, String columnName)
+  protected LongValue readIndexNodeLesserNode(LongValue rowID, String columnName)
     throws WHException
   {
-    LongValue outRowID = (LongValue)ts.get(new IndexNodeLesserKey(indexName,rowID,columnName));
-    if (outRowID == null)
-      return -1L;
-    return outRowID.getValue();
+    return (LongValue)ts.get(new IndexNodeLesserKey(indexName,rowID.getValue(),columnName));
   }
 
   /** Set the lesser child reference for an index node.  Presumes that no such reference already exists.
   */
-  protected void setIndexNodeLesserNode(long rowID, String columnName, long refRowID)
+  protected void setIndexNodeLesserNode(LongValue rowID, String columnName, LongValue refRowID)
     throws WHException
   {
-    IndexNodeLesserKey key = new IndexNodeLesserKey(indexName,rowID,columnName);
-    IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,refRowID,columnName);
-    ts.put(key,new LongValue(refRowID));
+    IndexNodeLesserKey key = new IndexNodeLesserKey(indexName,rowID.getValue(),columnName);
+    IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,refRowID.getValue(),columnName);
+    ts.put(key,refRowID);
     ts.put(parentKey,key);
   }
 
   /** Delete the lesser child reference for an index node.  Presumes that the reference exists.
   */
-  protected void deleteIndexNodeLesserNode(long rowID, String columnName)
+  protected void deleteIndexNodeLesserNode(LongValue rowID, String columnName)
     throws WHException
   {
-    IndexNodeLesserKey key = new IndexNodeLesserKey(indexName,rowID,columnName);
+    IndexNodeLesserKey key = new IndexNodeLesserKey(indexName,rowID.getValue(),columnName);
     LongValue childReference = (LongValue)ts.get(key);
     if (childReference == null)
-      throw new WHDeadlockException();
+      throw new WHConcurrencyException();
     IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,childReference.getValue(),columnName);
     ts.put(key,null);
     ts.put(parentKey,null);
@@ -467,35 +488,32 @@ public class Index implements WHIndex
 
   /** Get the greater child reference for an index node.
   */
-  protected long readIndexNodeGreaterNode(long rowID, String columnName)
+  protected LongValue readIndexNodeGreaterNode(LongValue rowID, String columnName)
     throws WHException
   {
-    LongValue outRowID = (LongValue)ts.get(new IndexNodeGreaterKey(indexName,rowID,columnName));
-    if (outRowID == null)
-      return -1L;
-    return outRowID.getValue();
+    return (LongValue)ts.get(new IndexNodeGreaterKey(indexName,rowID.getValue(),columnName));
   }
   
   /** Set the greater child reference for an index node.  Presumes that the reference is currently empty.
   */
-  protected void setIndexNodeGreaterNode(long rowID, String columnName, long refRowID)
+  protected void setIndexNodeGreaterNode(LongValue rowID, String columnName, LongValue refRowID)
     throws WHException
   {
-    IndexNodeGreaterKey key = new IndexNodeGreaterKey(indexName,rowID,columnName);
-    IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,refRowID,columnName);
-    ts.put(key,new LongValue(refRowID));
+    IndexNodeGreaterKey key = new IndexNodeGreaterKey(indexName,rowID.getValue(),columnName);
+    IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,refRowID.getValue(),columnName);
+    ts.put(key,refRowID);
     ts.put(parentKey,key);
   }
 
   /** Delete the greater child reference for an index node.  Presumes that the reference exists.
   */
-  protected void deleteIndexNodeGreaterNode(long rowID, String columnName)
+  protected void deleteIndexNodeGreaterNode(LongValue rowID, String columnName)
     throws WHException
   {
-    IndexNodeGreaterKey key = new IndexNodeGreaterKey(indexName,rowID,columnName);
+    IndexNodeGreaterKey key = new IndexNodeGreaterKey(indexName,rowID.getValue(),columnName);
     LongValue childReference = (LongValue)ts.get(key);
     if (childReference == null)
-      throw new WHDeadlockException();
+      throw new WHConcurrencyException();
     IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,childReference.getValue(),columnName);
     ts.put(key,null);
     ts.put(parentKey,null);
@@ -503,35 +521,32 @@ public class Index implements WHIndex
   
   /** Get the equals child reference for an index node.
   */
-  protected long readIndexNodeEqualsNode(long rowID, String columnName)
+  protected LongValue readIndexNodeEqualsNode(LongValue rowID, String columnName)
     throws WHException
   {
-    LongValue outRowID = (LongValue)ts.get(new IndexNodeEqualsKey(indexName,rowID,columnName));
-    if (outRowID == null)
-      return -1L;
-    return outRowID.getValue();
+    return (LongValue)ts.get(new IndexNodeEqualsKey(indexName,rowID.getValue(),columnName));
   }
   
   /** Set the equals child reference for an index node.  Presumes that a reference doesn't yet exist.
   */
-  protected void setIndexNodeEqualsNode(long rowID, String columnName, long refRowID)
+  protected void setIndexNodeEqualsNode(LongValue rowID, String columnName, LongValue refRowID)
     throws WHException
   {
-    IndexNodeEqualsKey key = new IndexNodeEqualsKey(indexName,rowID,columnName);
-    IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,refRowID,columnName);
-    ts.put(key,new LongValue(refRowID));
+    IndexNodeEqualsKey key = new IndexNodeEqualsKey(indexName,rowID.getValue(),columnName);
+    IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,refRowID.getValue(),columnName);
+    ts.put(key,refRowID);
     ts.put(parentKey,key);
   }
 
   /** Delete the equals child reference for an index node.  Presumes that the reference exists.
   */
-  protected void deleteIndexNodeEqualsNode(long rowID, String columnName)
+  protected void deleteIndexNodeEqualsNode(LongValue rowID, String columnName)
     throws WHException
   {
-    IndexNodeEqualsKey key = new IndexNodeEqualsKey(indexName,rowID,columnName);
+    IndexNodeEqualsKey key = new IndexNodeEqualsKey(indexName,rowID.getValue(),columnName);
     LongValue childReference = (LongValue)ts.get(key);
     if (childReference == null)
-      throw new WHDeadlockException();
+      throw new WHConcurrencyException();
     IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,childReference.getValue(),columnName);
     ts.put(key,null);
     ts.put(parentKey,null);
@@ -539,33 +554,30 @@ public class Index implements WHIndex
 
   /** Get the parent reference for an index node.
   */
-  protected WHKey readIndexNodeParentKey(long rowID, String columnName)
+  protected WHKey readIndexNodeParentKey(LongValue rowID, String columnName)
     throws WHException
   {
-    WHKey rval = (WHKey)ts.get(new IndexNodeParentKey(indexName,rowID,columnName));
+    WHKey rval = (WHKey)ts.get(new IndexNodeParentKey(indexName,rowID.getValue(),columnName));
     if (rval == null)
-      throw new WHDeadlockException();
+      throw new WHConcurrencyException();
     return rval;
   }
   
   /** Read the child node of a specified parent node.
   */
-  protected long readIndexParentChild(WHKey parentKey)
+  protected LongValue readIndexParentChild(WHKey parentKey)
     throws WHException
   {
-    LongValue value = (LongValue)ts.get(parentKey);
-    if (value == null)
-      return -1L;
-    return value.getValue();
+    return (LongValue)ts.get(parentKey);
   }
   
   /** Set an index parent's child node.  Presumes this child is not set yet.
   */
-  protected void setIndexParentChild(WHKey parentKey, String columnName, long rowID)
+  protected void setIndexParentChild(WHKey parentKey, String columnName, LongValue rowID)
     throws WHException
   {
-    ts.put(parentKey,new LongValue(rowID));
-    ts.put(new IndexNodeParentKey(indexName,rowID,columnName),parentKey);
+    ts.put(parentKey,rowID);
+    ts.put(new IndexNodeParentKey(indexName,rowID.getValue(),columnName),parentKey);
   }
   
   /** Remove an index parent's child node reference.  Presumes that this child exists.
@@ -576,30 +588,27 @@ public class Index implements WHIndex
     // Get the existing child
     LongValue childNodeRef = (LongValue)ts.get(parentKey);
     if (childNodeRef == null)
-      throw new WHDeadlockException();
+      throw new WHConcurrencyException();
     ts.put(parentKey,null);
     ts.put(new IndexNodeParentKey(indexName,childNodeRef.getValue(),columnName),null);
   }
   
   /** Get the root pointer for an index.
   */
-  protected long readIndexRootNode()
+  protected LongValue readIndexRootNode()
     throws WHException
   {
-    LongValue outRowID = (LongValue)ts.get(new IndexRootKey(indexName));
-    if (outRowID == null)
-      return -1L;
-    return outRowID.getValue();
+    return (LongValue)ts.get(new IndexRootKey(indexName));
   }
   
   /** Set the root pointer for an index.  Presumes the root pointer does not currently exist.
   */
-  protected void setIndexRootNode(long rootRowID, String columnName)
+  protected void setIndexRootNode(LongValue rootRowID, String columnName)
     throws WHException
   {
     IndexRootKey key = new IndexRootKey(indexName);
-    IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,rootRowID,columnName);
-    ts.put(key,new LongValue(rootRowID));
+    IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,rootRowID.getValue(),columnName);
+    ts.put(key,rootRowID);
     ts.put(parentKey,key);
   }
 
@@ -611,7 +620,7 @@ public class Index implements WHIndex
     IndexRootKey key = new IndexRootKey(indexName);
     LongValue childReference = (LongValue)ts.get(key);
     if (childReference == null)
-      throw new WHDeadlockException();
+      throw new WHConcurrencyException();
     IndexNodeParentKey parentKey = new IndexNodeParentKey(indexName,childReference.getValue(),columnName);
     ts.put(key,null);
     ts.put(parentKey,null);



Mime
View raw message