You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2011/12/18 09:36:56 UTC

svn commit: r1220353 [11/11] - in /incubator/lcf/branches/CONNECTORS-286/warthog-reimport: ./ src/main/java/org/apache/warthog/api/ src/main/java/org/apache/warthog/bytekeyvalue/ src/main/java/org/apache/warthog/common/ src/main/java/org/apache/warthog...

Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/SanityTest.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/SanityTest.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/SanityTest.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/SanityTest.java Sun Dec 18 08:36:52 2011
@@ -1,919 +1,919 @@
-/* $Id: SanityTest.java 1212814 2011-12-10 15:26:17Z kwright $ */
-
-/**
-* 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.tests;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-import org.apache.warthog.keyvaluetablestore.*;
-import org.apache.warthog.keyvalue.*;
-import org.apache.warthog.common.*;
-import org.junit.*;
-import static org.junit.Assert.*;
-import java.util.*;
-
-public class SanityTest
-{
-
-  @Test
-  public void basicTable()
-    throws Exception
-  {
-    WHTableStore ts = createInMemTableStore();
-    
-    ts.beginTransaction();
-    ts.createTable("testtable",new String[]{"colA","colB","colC"});
-    ts.commitTransaction();
-    
-    ts.beginTransaction();
-    WHTable table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colC"},new WHValue[]{new LongValue(123L),new StringValue("hello")});
-    ts.commitTransaction();
-    
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colC","colB"},new WHValue[]{new LongValue(456L),new StringValue("goodbye"),new BooleanValue(true)});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    WHAccessor accessor = table.buildAccessor();
-    boolean seen123 = false;
-    boolean seen456 = false;
-    while (true)
-    {
-      WHRowID rowID = accessor.getCurrentRowID();
-      if (rowID == null)
-        break;
-      WHValue value = accessor.getValue("colA");
-      assertNotNull(value);
-      assertEquals(value.getClass().getName(),"org.apache.warthog.common.LongValue");
-      LongValue lv = (LongValue)value;
-      if (lv.getValue() == 123L)
-        seen123 = true;
-      else if (lv.getValue() == 456L)
-        seen456 = true;
-      else
-        throw new Exception("Unexpected value: "+new Long(lv.getValue()).toString());
-      accessor.advance();
-    }
-    if (seen123 == false || seen456 == false)
-      throw new Exception("Missing rows");
-    ts.abandonTransaction();
-    
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    table.updateRows(new String[]{"colC"},new WHValue[]{new StringValue("abcdefg")},table.buildAccessor());
-    ts.commitTransaction();
-    
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    accessor = table.buildAccessor();
-    while (true)
-    {
-      WHRowID rowID = accessor.getCurrentRowID();
-      if (rowID == null)
-        break;
-      WHValue value = accessor.getValue("colC");
-      assertNotNull(value);
-      assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
-      assertEquals("abcdefg",((StringValue)value).getValue());
-      accessor.advance();
-    }
-    ts.abandonTransaction();
-    
-    ts.beginTransaction();
-    ts.dropTable("testtable");
-    ts.commitTransaction();
-  }
-  
-  @Test
-  public void basicTableIndex()
-    throws Exception
-  {
-    WHTableStore ts = createInMemTableStore();
-  
-    buildNonOverlappingTestTable(ts);
-    
-    // Now build a one-column unique index on colA
-    ts.beginTransaction();
-    WHTable table = ts.lookupTable("testtable");
-    ts.createIndex("testindex",table,new String[]{"colA"},new String[]{"org.apache.warthog.common.LongComparatorAscending"},true);
-    ts.commitTransaction();
-    
-    // Read in index order
-    ts.beginTransaction();
-    WHIndex index = ts.lookupIndex("testindex");
-    WHAccessor accessor = index.buildAccessor();
-    assertNotNull(accessor.getCurrentRowID());
-    WHValue value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(111L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(123L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(124L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(456L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-    
-    // Now add a row while the index is set up to see if it appears
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(333L),new StringValue("><")});
-    ts.commitTransaction();
-    
-    // Read in index order
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(111L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(123L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(124L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(333L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(456L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-    
-    // Build a bunch of accessors and see if they do what we expect
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor(new IndexCriteria[]{new IndexEquals(new LongValue(124L))},null);
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(124L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-
-    // Various index criteria
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor(new IndexCriteria[]{new IndexEqualsOrBefore(new LongValue(124L))},null);
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(111L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(123L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(124L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor(new IndexCriteria[]{new IndexEqualsOrAfter(new LongValue(124L))},null);
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(124L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(333L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(456L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor(new IndexCriteria[]{new IndexBefore(new LongValue(124L))},null);
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(111L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(123L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor(new IndexCriteria[]{new IndexAfter(new LongValue(124L))},null);
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(333L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(456L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-    
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor(new IndexCriteria[]{new IndexEqualsMultiple(new WHValue[]{new LongValue(123L),new LongValue(333L)})},null);
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(123L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(333L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor(new IndexCriteria[]{new IndexBetween(new LongValue(123L),new LongValue(333L))},null);
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(124L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-
-    // Delete a table row and see if it goes away from the index
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    index = ts.lookupIndex("testindex");
-    table.deleteRows(index.buildAccessor(new IndexCriteria[]{new IndexEquals(new LongValue(124L))},null));
-    ts.commitTransaction();
-
-    // Go through the iterator to see if it's gone
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(111L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(123L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(333L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(456L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-
-    ts.beginTransaction();
-    ts.dropIndex("testindex");
-    ts.commitTransaction();
-    
-  }
-  
-  @Test
-  public void twoColumnIndex()
-    throws Exception
-  {
-    WHTableStore ts = createInMemTableStore();
-  
-    buildOverlappingTestTable(ts);
-    
-    // Now build a two-column unique index on colA
-    ts.beginTransaction();
-    WHTable table = ts.lookupTable("testtable");
-    ts.createIndex("testindex",table,
-      new String[]{"colB","colA"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},true);
-    ts.commitTransaction();
-    
-    // Read in index order
-    ts.beginTransaction();
-    WHIndex index = ts.lookupIndex("testindex");
-    WHAccessor accessor = index.buildAccessor();
-    assertNotNull(accessor.getCurrentRowID());
-    WHValue value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(124L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(456L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(111L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(123L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor(new IndexCriteria[]{
-      new IndexEquals(new StringValue("hello")),
-      new IndexBefore(new LongValue(123L))},null);
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(111L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-
-    ts.beginTransaction();
-    ts.dropIndex("testindex");
-    ts.commitTransaction();
-
-  }
-  
-  @Test
-  public void aggregates()
-    throws Exception
-  {
-    WHTableStore ts = createInMemTableStore();
-    
-    // Build a table with two columns, one of which can be summed, and the other of which has repeating values.
-    ts.beginTransaction();
-    ts.createTable("testtable",new String[]{"colA","colB"});
-    ts.commitTransaction();
-    
-    ts.beginTransaction();
-    WHTable table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(1L),new StringValue("hello")});
-    ts.commitTransaction();
-    
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(4L),new StringValue("goodbye")});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(3L),new StringValue("hello")});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(2L),new StringValue("goodbye")});
-    ts.commitTransaction();
-
-    // Build an index on this table to establish ordering on ColB
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    ts.createIndex("testindex",table,
-      new String[]{"colB"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending"},false);
-    ts.commitTransaction();
-
-    // Now use the index as a relationship (to provide ordering), and build an aggregate relationship based on it
-    ts.beginTransaction();
-    WHIndex index = ts.lookupIndex("testindex");
-    WHRelationship aggregateRelationship = new AggregateRelationship(index,new WHColumnDescription[]{
-      new ColumnSumLong("colA","sumA"),
-      new ColumnBreakOnChange("colB","uniqueB")});
-    // Grab the accessor and verify it is correct
-    WHAccessor accessor = aggregateRelationship.buildAccessor();
-    assertNotNull(accessor.getCurrentRowID());
-    WHValue value = accessor.getValue("sumA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(6L,((LongValue)value).getValue());
-    value = accessor.getValue("uniqueB");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
-    assertEquals("goodbye",((StringValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("sumA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(4L,((LongValue)value).getValue());
-    value = accessor.getValue("uniqueB");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
-    assertEquals("hello",((StringValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.commitTransaction();
-
-    // Again use the index and build a different aggregate relationship based on it
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    aggregateRelationship = new AggregateRelationship(index,new WHColumnDescription[]{
-      new ColumnCount("countA"),
-      new ColumnBreakOnChange("colB","uniqueB")});
-    // Grab the accessor and verify it is correct
-    accessor = aggregateRelationship.buildAccessor();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("countA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(2L,((LongValue)value).getValue());
-    value = accessor.getValue("uniqueB");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
-    assertEquals("goodbye",((StringValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("countA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(2L,((LongValue)value).getValue());
-    value = accessor.getValue("uniqueB");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
-    assertEquals("hello",((StringValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.commitTransaction();
-
-    // Use the table and calculate a row count
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    aggregateRelationship = new AggregateRelationship(table,new WHColumnDescription[]{
-      new ColumnCount("count")});
-    // Grab the accessor and verify it is correct
-    accessor = aggregateRelationship.buildAccessor();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("count");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(4L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.commitTransaction();
-
-    // Try out min and max
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    aggregateRelationship = new AggregateRelationship(table,new WHColumnDescription[]{
-      new ColumnMin(new LongComparatorAscending(),"colA","minA"),
-      new ColumnMax(new LongComparatorAscending(),"colA","maxA")});
-    // Grab the accessor and verify it is correct
-    accessor = aggregateRelationship.buildAccessor();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("minA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(1L,((LongValue)value).getValue());
-    value = accessor.getValue("maxA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(4L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.commitTransaction();
-
-  }
-  
-  @Test
-  public void filters()
-    throws Exception
-  {
-    WHTableStore ts = createInMemTableStore();
-  
-    buildNonOverlappingTestTable(ts);
-
-    // Now build a one-column unique index on colA
-    ts.beginTransaction();
-    WHTable table = ts.lookupTable("testtable");
-    ts.createIndex("testindex",table,new String[]{"colA"},new String[]{"org.apache.warthog.common.LongComparatorAscending"},true);
-    ts.commitTransaction();
-
-    WHIndex index;
-    WHRelationship filterRelationship;
-    WHAccessor accessor;
-    WHValue value;
-    
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    filterRelationship = new FilterRelationship(index,new FilterEqualsOrBefore("colA",new LongValue(124L),
-      new LongComparatorAscending()));
-    accessor = filterRelationship.buildAccessor();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(111L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(123L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(124L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    filterRelationship = new FilterRelationship(index,new FilterEqualsOrAfter("colA",new LongValue(124L),
-      new LongComparatorAscending()));
-    accessor = filterRelationship.buildAccessor();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(124L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(456L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    filterRelationship = new FilterRelationship(index,new FilterBefore("colA",new LongValue(124L),
-      new LongComparatorAscending()));
-    accessor = filterRelationship.buildAccessor();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(111L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(123L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    filterRelationship = new FilterRelationship(index,new FilterAfter("colA",new LongValue(124L),
-      new LongComparatorAscending()));
-    accessor = filterRelationship.buildAccessor();
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(456L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-    
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    filterRelationship = new FilterRelationship(index,new FilterEqualsMultiple("colA",new WHValue[]{new LongValue(123L),new LongValue(333L)},
-      new LongComparatorAscending()));
-    accessor = filterRelationship.buildAccessor();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(123L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-
-    ts.beginTransaction();
-    index = ts.lookupIndex("testindex");
-    filterRelationship = new FilterRelationship(index,new FilterBetween("colA",new LongValue(123L),new LongValue(333L),
-      new LongComparatorAscending()));
-    accessor = filterRelationship.buildAccessor();
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colA");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(124L,((LongValue)value).getValue());
-    accessor.advance();
-    assertNull(accessor.getCurrentRowID());
-    ts.abandonTransaction();
-
-  }
-  
-  @Test
-  public void joins()
-    throws Exception
-  {
-    // Build two tables.  First one has a single column.  Second one has two columns.
-    WHTableStore ts = createInMemTableStore();
-  
-    ts.beginTransaction();
-    ts.createTable("testtable1",new String[]{"colC"});
-    ts.commitTransaction();
-    
-    ts.beginTransaction();
-    WHTable table = ts.lookupTable("testtable1");
-    table.insertRow(new String[]{"colC"},new WHValue[]{new LongValue(123L)});
-    ts.commitTransaction();
-    
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable1");
-    table.insertRow(new String[]{"colC"},new WHValue[]{new LongValue(456L)});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable1");
-    table.insertRow(new String[]{"colC"},new WHValue[]{new LongValue(124L)});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable1");
-    table.insertRow(new String[]{"colC"},new WHValue[]{new LongValue(111L)});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    ts.createTable("testtable2",new String[]{"colA","colB"});
-    ts.commitTransaction();
-    
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable2");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(123L),new StringValue("hello")});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable2");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(123L),new StringValue("world")});
-    ts.commitTransaction();
-    
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable2");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(456L),new StringValue("goodbye")});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable2");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(456L),new StringValue("world")});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable2");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(124L),new StringValue("...")});
-    ts.commitTransaction();
-
-    // Build indexes on both of these so we establish order for the test
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable1");
-    ts.createIndex("testindex1",table,new String[]{"colC"},new String[]{"org.apache.warthog.common.LongComparatorAscending"},true);
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable2");
-    ts.createIndex("testindex2",table,new String[]{"colA","colB"},new String[]{"org.apache.warthog.common.LongComparatorAscending",
-      "org.apache.warthog.common.StringComparatorAscending"},false);
-    ts.commitTransaction();
-
-    // Now, build the join and iterate over it.
-    ts.beginTransaction();
-    WHIndex index2 = ts.lookupIndex("testindex2");
-    // Construct and index relationship builder linking the two
-    WHRelationshipBuilder indexRelationshipBuilder = new IndexRelationshipBuilder(index2,
-      new IndexCriteria[]{null,null},
-      new String[]{"colC",null},
-      new String[]{"org.apache.warthog.api.IndexEquals",null},
-      new boolean[]{false,false});
-    // Now construct the join
-    WHIndex index1 = ts.lookupIndex("testindex1");
-    WHRelationship joinRelationship = new JoinRelationship(index1,
-      new String[]{"colB"},
-      new String[]{"join-colB"},
-      indexRelationshipBuilder);
-      
-    // Read from the relationship in order.  Each row should have 2 columns: "colC" and "join-colB".
-    // The whole thing is ordered as follows: (1) by increasing "colC" value, (2) by increasing "join-colB" value.
-    WHAccessor accessor = joinRelationship.buildAccessor();
-    WHValue value;
-      
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colC");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(123L,((LongValue)value).getValue());
-    value = accessor.getValue("join-colB");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
-    assertEquals("hello",((StringValue)value).getValue());
-    accessor.advance();
-
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colC");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(123L,((LongValue)value).getValue());
-    value = accessor.getValue("join-colB");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
-    assertEquals("world",((StringValue)value).getValue());
-    accessor.advance();
-
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colC");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(124L,((LongValue)value).getValue());
-    value = accessor.getValue("join-colB");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
-    assertEquals("...",((StringValue)value).getValue());
-    accessor.advance();
-
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colC");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(456L,((LongValue)value).getValue());
-    value = accessor.getValue("join-colB");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
-    assertEquals("goodbye",((StringValue)value).getValue());
-    accessor.advance();
-
-    assertNotNull(accessor.getCurrentRowID());
-    value = accessor.getValue("colC");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
-    assertEquals(456L,((LongValue)value).getValue());
-    value = accessor.getValue("join-colB");
-    assertNotNull(value);
-    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
-    assertEquals("world",((StringValue)value).getValue());
-    accessor.advance();
-
-    assertNull(accessor.getCurrentRowID());
-      
-    ts.abandonTransaction();
-  }
-  
-  // Protected methods
-  
-  protected WHTableStore createInMemTableStore()
-    throws WHException
-  {
-    return new TableStore(new InMemNativeTransactionalStoreImpl(new InMemAtomicNativeNonblockingKeyValueStore(32768)));
-    //return new TableStore(new InMemTransactionalStoreImpl(new InMemAtomicKeyValueStore(32768)));
-  }
-    
-  protected void buildNonOverlappingTestTable(WHTableStore ts)
-    throws WHException
-  {
-    ts.beginTransaction();
-    ts.createTable("testtable",new String[]{"colA","colB"});
-    ts.commitTransaction();
-    
-    ts.beginTransaction();
-    WHTable table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(123L),new StringValue("hello")});
-    ts.commitTransaction();
-    
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(456L),new StringValue("goodbye")});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(124L),new StringValue("...")});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(111L),new StringValue("<>")});
-    ts.commitTransaction();
-  }
-
-  protected void buildOverlappingTestTable(WHTableStore ts)
-    throws WHException
-  {
-    ts.beginTransaction();
-    ts.createTable("testtable",new String[]{"colA","colB"});
-    ts.commitTransaction();
-    
-    ts.beginTransaction();
-    WHTable table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(123L),new StringValue("hello")});
-    ts.commitTransaction();
-    
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(456L),new StringValue("goodbye")});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(124L),new StringValue("...")});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    table = ts.lookupTable("testtable");
-    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(111L),new StringValue("hello")});
-    ts.commitTransaction();
-  }
-
+/* $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.tests;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+import org.apache.warthog.keyvaluetablestore.*;
+import org.apache.warthog.keyvalue.*;
+import org.apache.warthog.common.*;
+import org.junit.*;
+import static org.junit.Assert.*;
+import java.util.*;
+
+public class SanityTest
+{
+
+  @Test
+  public void basicTable()
+    throws Exception
+  {
+    WHTableStore ts = createInMemTableStore();
+    
+    ts.beginTransaction();
+    ts.createTable("testtable",new String[]{"colA","colB","colC"});
+    ts.commitTransaction();
+    
+    ts.beginTransaction();
+    WHTable table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colC"},new WHValue[]{new LongValue(123L),new StringValue("hello")});
+    ts.commitTransaction();
+    
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colC","colB"},new WHValue[]{new LongValue(456L),new StringValue("goodbye"),new BooleanValue(true)});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    WHAccessor accessor = table.buildAccessor();
+    boolean seen123 = false;
+    boolean seen456 = false;
+    while (true)
+    {
+      WHRowID rowID = accessor.getCurrentRowID();
+      if (rowID == null)
+        break;
+      WHValue value = accessor.getValue("colA");
+      assertNotNull(value);
+      assertEquals(value.getClass().getName(),"org.apache.warthog.common.LongValue");
+      LongValue lv = (LongValue)value;
+      if (lv.getValue() == 123L)
+        seen123 = true;
+      else if (lv.getValue() == 456L)
+        seen456 = true;
+      else
+        throw new Exception("Unexpected value: "+new Long(lv.getValue()).toString());
+      accessor.advance();
+    }
+    if (seen123 == false || seen456 == false)
+      throw new Exception("Missing rows");
+    ts.abandonTransaction();
+    
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    table.updateRows(new String[]{"colC"},new WHValue[]{new StringValue("abcdefg")},table.buildAccessor());
+    ts.commitTransaction();
+    
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    accessor = table.buildAccessor();
+    while (true)
+    {
+      WHRowID rowID = accessor.getCurrentRowID();
+      if (rowID == null)
+        break;
+      WHValue value = accessor.getValue("colC");
+      assertNotNull(value);
+      assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
+      assertEquals("abcdefg",((StringValue)value).getValue());
+      accessor.advance();
+    }
+    ts.abandonTransaction();
+    
+    ts.beginTransaction();
+    ts.dropTable("testtable");
+    ts.commitTransaction();
+  }
+  
+  @Test
+  public void basicTableIndex()
+    throws Exception
+  {
+    WHTableStore ts = createInMemTableStore();
+  
+    buildNonOverlappingTestTable(ts);
+    
+    // Now build a one-column unique index on colA
+    ts.beginTransaction();
+    WHTable table = ts.lookupTable("testtable");
+    ts.createIndex("testindex",table,new String[]{"colA"},new String[]{"org.apache.warthog.common.LongComparatorAscending"},true);
+    ts.commitTransaction();
+    
+    // Read in index order
+    ts.beginTransaction();
+    WHIndex index = ts.lookupIndex("testindex");
+    WHAccessor accessor = index.buildAccessor();
+    assertNotNull(accessor.getCurrentRowID());
+    WHValue value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(111L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(123L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(124L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(456L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+    
+    // Now add a row while the index is set up to see if it appears
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(333L),new StringValue("><")});
+    ts.commitTransaction();
+    
+    // Read in index order
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    accessor = index.buildAccessor();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(111L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(123L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(124L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(333L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(456L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+    
+    // Build a bunch of accessors and see if they do what we expect
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    accessor = index.buildAccessor(new IndexCriteria[]{new IndexEquals(new LongValue(124L))},null);
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(124L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+
+    // Various index criteria
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    accessor = index.buildAccessor(new IndexCriteria[]{new IndexEqualsOrBefore(new LongValue(124L))},null);
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(111L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(123L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(124L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    accessor = index.buildAccessor(new IndexCriteria[]{new IndexEqualsOrAfter(new LongValue(124L))},null);
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(124L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(333L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(456L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    accessor = index.buildAccessor(new IndexCriteria[]{new IndexBefore(new LongValue(124L))},null);
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(111L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(123L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    accessor = index.buildAccessor(new IndexCriteria[]{new IndexAfter(new LongValue(124L))},null);
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(333L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(456L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+    
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    accessor = index.buildAccessor(new IndexCriteria[]{new IndexEqualsMultiple(new WHValue[]{new LongValue(123L),new LongValue(333L)})},null);
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(123L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(333L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    accessor = index.buildAccessor(new IndexCriteria[]{new IndexBetween(new LongValue(123L),new LongValue(333L))},null);
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(124L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+
+    // Delete a table row and see if it goes away from the index
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    index = ts.lookupIndex("testindex");
+    table.deleteRows(index.buildAccessor(new IndexCriteria[]{new IndexEquals(new LongValue(124L))},null));
+    ts.commitTransaction();
+
+    // Go through the iterator to see if it's gone
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    accessor = index.buildAccessor();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(111L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(123L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(333L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(456L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+
+    ts.beginTransaction();
+    ts.dropIndex("testindex");
+    ts.commitTransaction();
+    
+  }
+  
+  @Test
+  public void twoColumnIndex()
+    throws Exception
+  {
+    WHTableStore ts = createInMemTableStore();
+  
+    buildOverlappingTestTable(ts);
+    
+    // Now build a two-column unique index on colA
+    ts.beginTransaction();
+    WHTable table = ts.lookupTable("testtable");
+    ts.createIndex("testindex",table,
+      new String[]{"colB","colA"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},true);
+    ts.commitTransaction();
+    
+    // Read in index order
+    ts.beginTransaction();
+    WHIndex index = ts.lookupIndex("testindex");
+    WHAccessor accessor = index.buildAccessor();
+    assertNotNull(accessor.getCurrentRowID());
+    WHValue value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(124L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(456L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(111L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(123L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    accessor = index.buildAccessor(new IndexCriteria[]{
+      new IndexEquals(new StringValue("hello")),
+      new IndexBefore(new LongValue(123L))},null);
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(111L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+
+    ts.beginTransaction();
+    ts.dropIndex("testindex");
+    ts.commitTransaction();
+
+  }
+  
+  @Test
+  public void aggregates()
+    throws Exception
+  {
+    WHTableStore ts = createInMemTableStore();
+    
+    // Build a table with two columns, one of which can be summed, and the other of which has repeating values.
+    ts.beginTransaction();
+    ts.createTable("testtable",new String[]{"colA","colB"});
+    ts.commitTransaction();
+    
+    ts.beginTransaction();
+    WHTable table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(1L),new StringValue("hello")});
+    ts.commitTransaction();
+    
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(4L),new StringValue("goodbye")});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(3L),new StringValue("hello")});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(2L),new StringValue("goodbye")});
+    ts.commitTransaction();
+
+    // Build an index on this table to establish ordering on ColB
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    ts.createIndex("testindex",table,
+      new String[]{"colB"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending"},false);
+    ts.commitTransaction();
+
+    // Now use the index as a relationship (to provide ordering), and build an aggregate relationship based on it
+    ts.beginTransaction();
+    WHIndex index = ts.lookupIndex("testindex");
+    WHRelationship aggregateRelationship = new AggregateRelationship(index,new WHColumnDescription[]{
+      new ColumnSumLong("colA","sumA"),
+      new ColumnBreakOnChange("colB","uniqueB")});
+    // Grab the accessor and verify it is correct
+    WHAccessor accessor = aggregateRelationship.buildAccessor();
+    assertNotNull(accessor.getCurrentRowID());
+    WHValue value = accessor.getValue("sumA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(6L,((LongValue)value).getValue());
+    value = accessor.getValue("uniqueB");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
+    assertEquals("goodbye",((StringValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("sumA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(4L,((LongValue)value).getValue());
+    value = accessor.getValue("uniqueB");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
+    assertEquals("hello",((StringValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.commitTransaction();
+
+    // Again use the index and build a different aggregate relationship based on it
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    aggregateRelationship = new AggregateRelationship(index,new WHColumnDescription[]{
+      new ColumnCount("countA"),
+      new ColumnBreakOnChange("colB","uniqueB")});
+    // Grab the accessor and verify it is correct
+    accessor = aggregateRelationship.buildAccessor();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("countA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(2L,((LongValue)value).getValue());
+    value = accessor.getValue("uniqueB");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
+    assertEquals("goodbye",((StringValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("countA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(2L,((LongValue)value).getValue());
+    value = accessor.getValue("uniqueB");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
+    assertEquals("hello",((StringValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.commitTransaction();
+
+    // Use the table and calculate a row count
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    aggregateRelationship = new AggregateRelationship(table,new WHColumnDescription[]{
+      new ColumnCount("count")});
+    // Grab the accessor and verify it is correct
+    accessor = aggregateRelationship.buildAccessor();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("count");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(4L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.commitTransaction();
+
+    // Try out min and max
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    aggregateRelationship = new AggregateRelationship(table,new WHColumnDescription[]{
+      new ColumnMin(new LongComparatorAscending(),"colA","minA"),
+      new ColumnMax(new LongComparatorAscending(),"colA","maxA")});
+    // Grab the accessor and verify it is correct
+    accessor = aggregateRelationship.buildAccessor();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("minA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(1L,((LongValue)value).getValue());
+    value = accessor.getValue("maxA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(4L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.commitTransaction();
+
+  }
+  
+  @Test
+  public void filters()
+    throws Exception
+  {
+    WHTableStore ts = createInMemTableStore();
+  
+    buildNonOverlappingTestTable(ts);
+
+    // Now build a one-column unique index on colA
+    ts.beginTransaction();
+    WHTable table = ts.lookupTable("testtable");
+    ts.createIndex("testindex",table,new String[]{"colA"},new String[]{"org.apache.warthog.common.LongComparatorAscending"},true);
+    ts.commitTransaction();
+
+    WHIndex index;
+    WHRelationship filterRelationship;
+    WHAccessor accessor;
+    WHValue value;
+    
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    filterRelationship = new FilterRelationship(index,new FilterEqualsOrBefore("colA",new LongValue(124L),
+      new LongComparatorAscending()));
+    accessor = filterRelationship.buildAccessor();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(111L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(123L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(124L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    filterRelationship = new FilterRelationship(index,new FilterEqualsOrAfter("colA",new LongValue(124L),
+      new LongComparatorAscending()));
+    accessor = filterRelationship.buildAccessor();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(124L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(456L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    filterRelationship = new FilterRelationship(index,new FilterBefore("colA",new LongValue(124L),
+      new LongComparatorAscending()));
+    accessor = filterRelationship.buildAccessor();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(111L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(123L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    filterRelationship = new FilterRelationship(index,new FilterAfter("colA",new LongValue(124L),
+      new LongComparatorAscending()));
+    accessor = filterRelationship.buildAccessor();
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(456L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+    
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    filterRelationship = new FilterRelationship(index,new FilterEqualsMultiple("colA",new WHValue[]{new LongValue(123L),new LongValue(333L)},
+      new LongComparatorAscending()));
+    accessor = filterRelationship.buildAccessor();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(123L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+
+    ts.beginTransaction();
+    index = ts.lookupIndex("testindex");
+    filterRelationship = new FilterRelationship(index,new FilterBetween("colA",new LongValue(123L),new LongValue(333L),
+      new LongComparatorAscending()));
+    accessor = filterRelationship.buildAccessor();
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(124L,((LongValue)value).getValue());
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
+    ts.abandonTransaction();
+
+  }
+  
+  @Test
+  public void joins()
+    throws Exception
+  {
+    // Build two tables.  First one has a single column.  Second one has two columns.
+    WHTableStore ts = createInMemTableStore();
+  
+    ts.beginTransaction();
+    ts.createTable("testtable1",new String[]{"colC"});
+    ts.commitTransaction();
+    
+    ts.beginTransaction();
+    WHTable table = ts.lookupTable("testtable1");
+    table.insertRow(new String[]{"colC"},new WHValue[]{new LongValue(123L)});
+    ts.commitTransaction();
+    
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable1");
+    table.insertRow(new String[]{"colC"},new WHValue[]{new LongValue(456L)});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable1");
+    table.insertRow(new String[]{"colC"},new WHValue[]{new LongValue(124L)});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable1");
+    table.insertRow(new String[]{"colC"},new WHValue[]{new LongValue(111L)});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    ts.createTable("testtable2",new String[]{"colA","colB"});
+    ts.commitTransaction();
+    
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable2");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(123L),new StringValue("hello")});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable2");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(123L),new StringValue("world")});
+    ts.commitTransaction();
+    
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable2");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(456L),new StringValue("goodbye")});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable2");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(456L),new StringValue("world")});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable2");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(124L),new StringValue("...")});
+    ts.commitTransaction();
+
+    // Build indexes on both of these so we establish order for the test
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable1");
+    ts.createIndex("testindex1",table,new String[]{"colC"},new String[]{"org.apache.warthog.common.LongComparatorAscending"},true);
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable2");
+    ts.createIndex("testindex2",table,new String[]{"colA","colB"},new String[]{"org.apache.warthog.common.LongComparatorAscending",
+      "org.apache.warthog.common.StringComparatorAscending"},false);
+    ts.commitTransaction();
+
+    // Now, build the join and iterate over it.
+    ts.beginTransaction();
+    WHIndex index2 = ts.lookupIndex("testindex2");
+    // Construct and index relationship builder linking the two
+    WHRelationshipBuilder indexRelationshipBuilder = new IndexRelationshipBuilder(index2,
+      new IndexCriteria[]{null,null},
+      new String[]{"colC",null},
+      new String[]{"org.apache.warthog.api.IndexEquals",null},
+      new boolean[]{false,false});
+    // Now construct the join
+    WHIndex index1 = ts.lookupIndex("testindex1");
+    WHRelationship joinRelationship = new JoinRelationship(index1,
+      new String[]{"colB"},
+      new String[]{"join-colB"},
+      indexRelationshipBuilder);
+      
+    // Read from the relationship in order.  Each row should have 2 columns: "colC" and "join-colB".
+    // The whole thing is ordered as follows: (1) by increasing "colC" value, (2) by increasing "join-colB" value.
+    WHAccessor accessor = joinRelationship.buildAccessor();
+    WHValue value;
+      
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colC");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(123L,((LongValue)value).getValue());
+    value = accessor.getValue("join-colB");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
+    assertEquals("hello",((StringValue)value).getValue());
+    accessor.advance();
+
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colC");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(123L,((LongValue)value).getValue());
+    value = accessor.getValue("join-colB");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
+    assertEquals("world",((StringValue)value).getValue());
+    accessor.advance();
+
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colC");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(124L,((LongValue)value).getValue());
+    value = accessor.getValue("join-colB");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
+    assertEquals("...",((StringValue)value).getValue());
+    accessor.advance();
+
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colC");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(456L,((LongValue)value).getValue());
+    value = accessor.getValue("join-colB");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
+    assertEquals("goodbye",((StringValue)value).getValue());
+    accessor.advance();
+
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colC");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
+    assertEquals(456L,((LongValue)value).getValue());
+    value = accessor.getValue("join-colB");
+    assertNotNull(value);
+    assertEquals("org.apache.warthog.common.StringValue",value.getClass().getName());
+    assertEquals("world",((StringValue)value).getValue());
+    accessor.advance();
+
+    assertNull(accessor.getCurrentRowID());
+      
+    ts.abandonTransaction();
+  }
+  
+  // Protected methods
+  
+  protected WHTableStore createInMemTableStore()
+    throws WHException
+  {
+    return new TableStore(new InMemNativeTransactionalStoreImpl(new InMemAtomicNativeNonblockingKeyValueStore(32768)));
+    //return new TableStore(new InMemTransactionalStoreImpl(new InMemAtomicKeyValueStore(32768)));
+  }
+    
+  protected void buildNonOverlappingTestTable(WHTableStore ts)
+    throws WHException
+  {
+    ts.beginTransaction();
+    ts.createTable("testtable",new String[]{"colA","colB"});
+    ts.commitTransaction();
+    
+    ts.beginTransaction();
+    WHTable table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(123L),new StringValue("hello")});
+    ts.commitTransaction();
+    
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(456L),new StringValue("goodbye")});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(124L),new StringValue("...")});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(111L),new StringValue("<>")});
+    ts.commitTransaction();
+  }
+
+  protected void buildOverlappingTestTable(WHTableStore ts)
+    throws WHException
+  {
+    ts.beginTransaction();
+    ts.createTable("testtable",new String[]{"colA","colB"});
+    ts.commitTransaction();
+    
+    ts.beginTransaction();
+    WHTable table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(123L),new StringValue("hello")});
+    ts.commitTransaction();
+    
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(456L),new StringValue("goodbye")});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(124L),new StringValue("...")});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    table = ts.lookupTable("testtable");
+    table.insertRow(new String[]{"colA","colB"},new WHValue[]{new LongValue(111L),new StringValue("hello")});
+    ts.commitTransaction();
+  }
+
 }
\ No newline at end of file

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/SanityTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/SanityTest.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/WrappedByteKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/WrappedByteKey.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/WrappedByteKey.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/WrappedByteKey.java Sun Dec 18 08:36:52 2011
@@ -1,65 +1,65 @@
-/* $Id: WrappedByteKey.java 1206939 2011-11-28 00:37:54Z kwright $ */
-
-/**
-* 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.tests;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.bytekeyvalue.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-
-public class WrappedByteKey
-{
-  protected byte[] key;
-    
-  public WrappedByteKey(byte[] key)
-  {
-    this.key = key;
-  }
-    
-  public int hashCode()
-  {
-    int rval = 0;
-    for (int i = 0 ; i < key.length ; i++)
-    {
-      int current = (int)key[i];
-      rval += (current << 5) ^ (current >> 3);
-    }
-    return rval;
-  }
-    
-  public boolean equals(Object o)
-  {
-    if (!(o instanceof WrappedByteKey))
-      return false;
-    WrappedByteKey other = (WrappedByteKey)o;
-    if (key.length != other.key.length)
-      return false;
-    for (int i = 0 ; i < key.length ; i++)
-    {
-      if (key[i] != other.key[i])
-        return false;
-    }
-    return true;
-  }
-  
-  public byte[] getKey()
-  {
-    return key;
-  }
-}
+/* $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.tests;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.bytekeyvalue.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+
+public class WrappedByteKey
+{
+  protected byte[] key;
+    
+  public WrappedByteKey(byte[] key)
+  {
+    this.key = key;
+  }
+    
+  public int hashCode()
+  {
+    int rval = 0;
+    for (int i = 0 ; i < key.length ; i++)
+    {
+      int current = (int)key[i];
+      rval += (current << 5) ^ (current >> 3);
+    }
+    return rval;
+  }
+    
+  public boolean equals(Object o)
+  {
+    if (!(o instanceof WrappedByteKey))
+      return false;
+    WrappedByteKey other = (WrappedByteKey)o;
+    if (key.length != other.key.length)
+      return false;
+    for (int i = 0 ; i < key.length ; i++)
+    {
+      if (key[i] != other.key[i])
+        return false;
+    }
+    return true;
+  }
+  
+  public byte[] getKey()
+  {
+    return key;
+  }
+}

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/WrappedByteKey.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/WrappedByteKey.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/WrappedKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/WrappedKey.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/WrappedKey.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/WrappedKey.java Sun Dec 18 08:36:52 2011
@@ -1,55 +1,55 @@
-/* $Id: WrappedKey.java 1205831 2011-11-24 13:57:15Z kwright $ */
-
-/**
-* 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.tests;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.keyvalue.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-
-public class WrappedKey
-{
-  protected WHKey key;
-    
-  public WrappedKey(WHKey key)
-  {
-    this.key = key;
-  }
-    
-  public int hashCode()
-  {
-    long code = key.getHashCode();
-    return (int)code;
-  }
-    
-  public boolean equals(Object o)
-  {
-    if (!(o instanceof WrappedKey))
-      return false;
-    WrappedKey other = (WrappedKey)o;
-    if (!key.getClass().equals(other.key.getClass()))
-      return false;
-    return key.isEquals(other.key);
-  }
-  
-  public WHKey getKey()
-  {
-    return key;
-  }
-}
+/* $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.tests;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.keyvalue.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+
+public class WrappedKey
+{
+  protected WHKey key;
+    
+  public WrappedKey(WHKey key)
+  {
+    this.key = key;
+  }
+    
+  public int hashCode()
+  {
+    long code = key.getHashCode();
+    return (int)code;
+  }
+    
+  public boolean equals(Object o)
+  {
+    if (!(o instanceof WrappedKey))
+      return false;
+    WrappedKey other = (WrappedKey)o;
+    if (!key.getClass().equals(other.key.getClass()))
+      return false;
+    return key.isEquals(other.key);
+  }
+  
+  public WHKey getKey()
+  {
+    return key;
+  }
+}

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/WrappedKey.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/WrappedKey.java
------------------------------------------------------------------------------
    svn:keywords = Id