incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1209929 [2/2] - in /incubator/lcf/branches/CONNECTORS-286/warthog/src: main/java/org/apache/warthog/interfaces/ main/java/org/apache/warthog/tablestore/ test/java/org/apache/warthog/tests/
Date Sat, 03 Dec 2011 15:06:23 GMT
Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableColumnKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableColumnKey.java?rev=1209929&r1=1209928&r2=1209929&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableColumnKey.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableColumnKey.java
Sat Dec  3 15:06:22 2011
@@ -26,17 +26,14 @@ public class TableColumnKey implements W
 {
   protected long tableID;
   protected long rowID;
-  protected String columnName;
-    
-  protected long hashCodeValue;
+  protected long columnID;
   
   /** Constructor */
-  public TableColumnKey(long tableID, long rowID, String columnName)
+  public TableColumnKey(long tableID, long rowID, long columnID)
   {
     this.tableID = tableID;
     this.rowID = rowID;
-    this.columnName = columnName;
-    //hashCodeValue = calculateHashCode(tableID,rowID,columnName);
+    this.columnID = columnID;
   }
     
   public TableColumnKey(byte[] data)
@@ -44,30 +41,29 @@ public class TableColumnKey implements W
     BufferPointer bp = new BufferPointer(data);
     this.tableID = LongKey.readObject(bp);
     this.rowID = LongKey.readObject(bp);
-    this.columnName = StringKey.readObject(bp);
-    //hashCodeValue = calculateHashCode(tableID,rowID,columnName);
+    this.columnID = LongKey.readObject(bp);
   }
 
   public byte[] serializeObject()
   {
     byte[] rval = new byte[LongKey.sizeObject()+
-      LongKey.sizeObject() + StringKey.sizeObject(columnName)];
+      LongKey.sizeObject() + LongKey.sizeObject()];
     BufferPointer bp = new BufferPointer(rval);
     LongKey.writeObject(bp,tableID);
     LongKey.writeObject(bp,rowID);
-    StringKey.writeObject(bp,columnName);
+    LongKey.writeObject(bp,columnID);
     return rval;
   }
     
   public long getHashCode()
   {
-    return hashCodeValue;
+    return calculateHashCode(tableID,rowID,columnID);
   }
   
-  public static long calculateHashCode(long tableID, long rowID, String columnName)
+  public static long calculateHashCode(long tableID, long rowID, long columnID)
   {
     return LongKey.calculateHashCode(tableID) + LongKey.calculateHashCode(rowID)
-      + StringKey.calculateHashCode(columnName);
+      + LongKey.calculateHashCode(columnID);
   }
     
   public boolean isEquals(WHValue o)
@@ -75,14 +71,14 @@ public class TableColumnKey implements W
     TableColumnKey key = (TableColumnKey)o;
     return key.tableID == tableID &&
       key.rowID == rowID &&
-      key.columnName.equals(columnName);
+      key.columnID == columnID;
   }
   
   public int hashCode()
   {
     return ((int)((tableID << 5) ^ (tableID >>3))) +
       ((int)((rowID << 5) ^ (rowID >> 3))) +
-      columnName.hashCode();
+      ((int)((columnID << 5) ^ (columnID >> 3)));
   }
   
   public boolean equals(Object o)
@@ -92,7 +88,7 @@ public class TableColumnKey implements W
     TableColumnKey other = (TableColumnKey)o;
     return other.tableID == tableID &&
       other.rowID == rowID &&
-      other.columnName.equals(columnName);
+      other.columnID == columnID;
   }
   
 }

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java?rev=1209929&r1=1209928&r2=1209929&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java
Sat Dec  3 15:06:22 2011
@@ -33,11 +33,11 @@ public class TableStore implements WHTab
   /** The current transaction, if any */
   protected WHTransaction currentTransaction = null;
   
-  /** Map of string to table object, good for the current transaction */
+  /** Map of tableID to table object, good for the current transaction */
   protected Map<LongValue,Table> tables = null;
-  /** Map of string to index object, good for the current transaction */
+  /** Map of tableID to index object, good for the current transaction */
   protected Map<LongValue,Index> indexes = null;
-  /** Map of table name to index set, good for the current transaction */
+  /** Map of table ID to index set, good for the current transaction */
   protected Map<LongValue,Index[]> indexesPerTable = null;
   
   /** Random number generator for this table store instance */
@@ -115,8 +115,13 @@ public class TableStore implements WHTab
       throw new WHException("Table already exists");
     LongValue tableIDValue = allocateNewGeneralID();
     setTableName(tableIDValue,name);
-    currentTransaction.put(new TableKey(tableIDValue.getValue()),new StringArray(columnNames));
-    Table t = new Table(this,tableIDValue,columnNames);
+    long[] columnIDs = new long[columnNames.length];
+    for (int i = 0 ; i < columnIDs.length ; i++)
+    {
+      columnIDs[i] = (long)i;
+    }
+    currentTransaction.put(new TableKey(tableIDValue.getValue()),new TableValue(columnNames,columnIDs,(long)columnNames.length));
+    Table t = new Table(this,tableIDValue,columnNames,columnIDs,(long)columnNames.length);
     tables.put(tableIDValue,t);
     currentTransaction.put(new TableIndexKey(tableIDValue.getValue()),new LongArray(new long[0]));
     currentTransaction.put(new TableRowIDFactoryKey(tableIDValue.getValue()),new LongValue(0L));
@@ -155,9 +160,14 @@ public class TableStore implements WHTab
     if (currentTransaction.get(new IndexLookupKey(name)) != null)
       throw new WHException("Index already exists");
     LongValue indexID = allocateNewGeneralID();
+    long[] columnIDs = new long[columnNames.length];
+    for (int i = 0 ; i < columnIDs.length ; i++)
+    {
+      columnIDs[i] = t.getColumnID(columnNames[i]);
+    }
     setIndexName(indexID,name);
-    currentTransaction.put(new IndexKey(indexID.getValue()),new IndexValue(t.getIDValue(),columnNames,comparatorClasses,unique));
-    Index i = new Index(this,indexID,t,columnNames,comparatorClasses,unique);
+    currentTransaction.put(new IndexKey(indexID.getValue()),new IndexValue(t.getIDValue(),columnIDs,comparatorClasses,unique));
+    Index i = new Index(this,indexID,t,columnIDs,comparatorClasses,unique);
     indexes.put(indexID,i);
     TableIndexKey tik = new TableIndexKey(t.getIDValue());
     LongArray tiv = (LongArray)currentTransaction.get(tik);
@@ -188,16 +198,6 @@ public class TableStore implements WHTab
     deleteIndex(i);
   }
   
-  /** Perform a query */
-  public WHRelationship performQuery(QueryDescription specification)
-    throws WHException
-  {
-    if (currentTransaction == null)
-      throw new WHException("Must be in a transaction");
-    // MHL
-    return null;
-  }
-
   // Non-interface public methods
   
   protected Map<LongValue,LongValue> startMap = new HashMap<LongValue,LongValue>();
@@ -303,7 +303,7 @@ public class TableStore implements WHTab
   
   /** Delete a table row from all the indexes that are based on a table.
   */
-  public void deleteIndexRow(LongValue tableID, LongValue rowID, Set<String> columns)
+  public void deleteIndexRow(LongValue tableID, LongValue rowID, Set<Long> columns)
     throws WHException
   {
     Index[] indexes = findIndexes(tableID);
@@ -316,7 +316,7 @@ public class TableStore implements WHTab
   
   /** Add a table row to all the indexes that are based on a table.
   */
-  public void addIndexRow(LongValue tableID, LongValue rowID, Set<String> columns)
+  public void addIndexRow(LongValue tableID, LongValue rowID, Set<Long> columns)
     throws WHException
   {
     Index[] indexes = findIndexes(tableID);
@@ -327,15 +327,15 @@ public class TableStore implements WHTab
     }
   }
 
-  protected boolean indexAffectedBy(Index index, Set<String> columns)
+  protected boolean indexAffectedBy(Index index, Set<Long> columns)
     throws WHException
   {
     if (columns == null)
       return true;
-    String[] indexColumns = index.getIndexColumns();
-    for (int i = 0 ; i < indexColumns.length ; i++)
+    long[] indexColumnIDs = index.getIndexColumnIDs();
+    for (int i = 0 ; i < indexColumnIDs.length ; i++)
     {
-      if (columns.contains(indexColumns[i]))
+      if (columns.contains(new Long(indexColumnIDs[i])))
         return true;
     }
     return false;
@@ -415,10 +415,10 @@ public class TableStore implements WHTab
     Table t = tables.get(tid);
     if (t != null)
       return t;
-    StringArray tv = (StringArray)currentTransaction.get(new TableKey(tid.getValue()));
+    TableValue tv = (TableValue)currentTransaction.get(new TableKey(tid.getValue()));
     if (tv == null)
       throw new WHConcurrencyException();
-    t = new Table(this,tid,tv.getValue());
+    t = new Table(this,tid,tv.getColumnNames(),tv.getColumnIdentifiers(),tv.getNextColumnIdentifier());
     tables.put(tid,t);
     return t;
   }
@@ -446,7 +446,7 @@ public class TableStore implements WHTab
     Table t = findTable(new LongValue(indexValue.getTableID()));
     if (t == null)
       throw new WHConcurrencyException();
-    i = new Index(this,indexID,t,indexValue.getColumnNames(),indexValue.getComparatorClassNames(),
+    i = new Index(this,indexID,t,indexValue.getColumnIDs(),indexValue.getComparatorClassNames(),
       indexValue.getUnique());
     indexes.put(indexID,i);
     return i;

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableValue.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableValue.java?rev=1209929&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableValue.java
(added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableValue.java
Sat Dec  3 15:06:22 2011
@@ -0,0 +1,103 @@
+/* $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.tablestore;
+
+import org.apache.warthog.interfaces.*;
+import org.apache.warthog.common.*;
+
+/** An index definition value */
+public class TableValue implements WHValue
+{
+  protected String[] columnNames;
+  protected long[] columnIdentifiers;
+  protected long nextColumnIdentifier;
+    
+  /** Constructor */
+  public TableValue(String[] columnNames, long[] columnIdentifiers, long nextColumnIdentifier)
+  {
+    this.columnNames = columnNames;
+    this.columnIdentifiers = columnIdentifiers;
+    this.nextColumnIdentifier = nextColumnIdentifier;
+  }
+    
+  public TableValue(byte[] data)
+  {
+    BufferPointer bp = new BufferPointer(data);
+    columnNames = StringArray.readObject(bp);
+    columnIdentifiers = LongArray.readObject(bp);
+    nextColumnIdentifier = LongValue.readObject(bp);
+  }
+    
+  public byte[] serializeObject()
+  {
+    byte[] rval = new byte[StringArray.sizeObject(columnNames)+
+      LongArray.sizeObject(columnIdentifiers.length)+
+      LongValue.sizeObject()
+      ];
+    BufferPointer bp = new BufferPointer(rval);
+    StringArray.writeObject(bp,columnNames);
+    LongArray.writeObject(bp,columnIdentifiers);
+    LongValue.writeObject(bp,nextColumnIdentifier);
+    return rval;
+  }
+
+  /** Check if equals (classes must already agree) */
+  public boolean isEquals(WHValue value)
+  {
+    TableValue other = (TableValue)value;
+    return StringArray.compareObject(other.columnNames,this.columnNames) &&
+      LongArray.compareObject(other.columnIdentifiers,this.columnIdentifiers) &&
+      other.nextColumnIdentifier == this.nextColumnIdentifier;
+  }
+  
+  public String[] getColumnNames()
+  {
+    return columnNames;
+  }
+
+  public long[] getColumnIdentifiers()
+  {
+    return columnIdentifiers;
+  }
+  
+  public long getNextColumnIdentifier()
+  {
+    return nextColumnIdentifier;
+  }
+  
+  public int hashCode()
+  {
+    int rval = 0;
+    for (int i = 0 ; i < columnNames.length ; i++)
+    {
+      rval += columnNames[i].hashCode();
+    }
+    return rval;
+  }
+  
+  public boolean equals(Object o)
+  {
+    if (this.getClass() != o.getClass())
+      return false;
+    TableValue other = (TableValue)o;
+    return StringArray.compareObject(other.columnNames,this.columnNames);
+  }
+  
+}

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

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

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/MultiThreadTest.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/MultiThreadTest.java?rev=1209929&r1=1209928&r2=1209929&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/MultiThreadTest.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/MultiThreadTest.java
Sat Dec  3 15:06:22 2011
@@ -382,9 +382,13 @@ public class MultiThreadTest
             WHIndex index = ts.lookupIndex("testindex1");
             WHAccessor accessor = index.buildAccessor(new IndexCriteria[]{
               new CriteriaBetween(new StringValue("1"),new StringValue("2")),
-              null});
-            while (accessor.hasNext())
-              accessor.getNext();
+              null},null);
+            while (true)
+            {
+              if (accessor.getCurrentRowID() == null)
+                break;
+              accessor.advance();
+            }
             ts.commitTransaction();
             break;
           }
@@ -408,9 +412,13 @@ public class MultiThreadTest
             WHIndex index = ts.lookupIndex("testindex2");
             WHAccessor accessor = index.buildAccessor(new IndexCriteria[]{
               new CriteriaBetween(new StringValue("23"),new StringValue("25")),
-              null});
-            while (accessor.hasNext())
-              accessor.getNext();
+              null},null);
+            while (true)
+            {
+              if (accessor.getCurrentRowID() == null)
+                break;
+              accessor.advance();
+            }
             ts.commitTransaction();
             break;
           }
@@ -434,9 +442,13 @@ public class MultiThreadTest
             WHIndex index = ts.lookupIndex("testindex3");
             WHAccessor accessor = index.buildAccessor(new IndexCriteria[]{
               new CriteriaBetween(new StringValue("02"),new StringValue("04")),
-              null});
-            while (accessor.hasNext())
-              accessor.getNext();
+              null},null);
+            while (true)
+            {
+              if (accessor.getCurrentRowID() == null)
+                break;
+              accessor.advance();
+            }
             ts.commitTransaction();
             break;
           }

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/SanityTest.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/SanityTest.java?rev=1209929&r1=1209928&r2=1209929&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/SanityTest.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/SanityTest.java
Sat Dec  3 15:06:22 2011
@@ -53,10 +53,12 @@ public class SanityTest
     WHAccessor accessor = table.buildAccessor();
     boolean seen123 = false;
     boolean seen456 = false;
-    while (accessor.hasNext())
+    while (true)
     {
-      WHRowID rowID = accessor.getNext();
-      WHValue value = table.getValue(rowID,"colA");
+      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;
@@ -66,6 +68,7 @@ public class SanityTest
         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");
@@ -73,19 +76,22 @@ public class SanityTest
     
     ts.beginTransaction();
     table = ts.lookupTable("testtable");
-    table.updateRows(new String[]{"colC"},new WHValue[]{new StringValue("abcdefg")},table.buildAccessor(),null);
+    table.updateRows(new String[]{"colC"},new WHValue[]{new StringValue("abcdefg")},table.buildAccessor());
     ts.commitTransaction();
     
     ts.beginTransaction();
     table = ts.lookupTable("testtable");
     accessor = table.buildAccessor();
-    while (accessor.hasNext())
+    while (true)
     {
-      WHRowID rowID = accessor.getNext();
-      WHValue value = table.getValue(rowID,"colC");
+      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();
     
@@ -112,35 +118,31 @@ public class SanityTest
     ts.beginTransaction();
     WHIndex index = ts.lookupIndex("testindex");
     WHAccessor accessor = index.buildAccessor();
-    assertEquals(accessor.hasNext(),true);
-    WHRowID rowID = accessor.getNext();
-    assertNotNull(rowID);
-    WHValue value = index.getValue(rowID,"colA");
+    assertNotNull(accessor.getCurrentRowID());
+    WHValue value = accessor.getValue("colA");
     assertNotNull(value);
     assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
     assertEquals(111L,((LongValue)value).getValue());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),false);
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
     ts.abandonTransaction();
     
     // Now add a row while the index is set up to see if it appears
@@ -153,225 +155,202 @@ public class SanityTest
     ts.beginTransaction();
     index = ts.lookupIndex("testindex");
     accessor = index.buildAccessor();
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
     assertNotNull(value);
     assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
     assertEquals(111L,((LongValue)value).getValue());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),false);
+    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 CriteriaEquals(new LongValue(124L))});
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    accessor = index.buildAccessor(new IndexCriteria[]{new CriteriaEquals(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());
-    assertEquals(accessor.hasNext(),false);
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
     ts.abandonTransaction();
 
     ts.beginTransaction();
     index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor(new IndexCriteria[]{new CriteriaEqualsOrBefore(new LongValue(124L))});
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    accessor = index.buildAccessor(new IndexCriteria[]{new CriteriaEqualsOrBefore(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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),false);
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
     ts.abandonTransaction();
 
     ts.beginTransaction();
     index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor(new IndexCriteria[]{new CriteriaEqualsOrAfter(new LongValue(124L))});
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    accessor = index.buildAccessor(new IndexCriteria[]{new CriteriaEqualsOrAfter(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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),false);
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
     ts.abandonTransaction();
 
     ts.beginTransaction();
     index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor(new IndexCriteria[]{new CriteriaBefore(new LongValue(124L))});
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    accessor = index.buildAccessor(new IndexCriteria[]{new CriteriaBefore(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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),false);
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
     ts.abandonTransaction();
 
     ts.beginTransaction();
     index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor(new IndexCriteria[]{new CriteriaAfter(new LongValue(124L))});
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    accessor = index.buildAccessor(new IndexCriteria[]{new CriteriaAfter(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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),false);
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
     ts.abandonTransaction();
     
     ts.beginTransaction();
     index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor(new IndexCriteria[]{new CriteriaEqualsMultiple(new WHValue[]{new
LongValue(123L),new LongValue(333L)})});
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    accessor = index.buildAccessor(new IndexCriteria[]{new CriteriaEqualsMultiple(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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),false);
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
     ts.abandonTransaction();
 
     ts.beginTransaction();
     index = ts.lookupIndex("testindex");
-    accessor = index.buildAccessor(new IndexCriteria[]{new CriteriaBetween(new LongValue(123L),new
LongValue(333L))});
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    accessor = index.buildAccessor(new IndexCriteria[]{new CriteriaBetween(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());
-    assertEquals(accessor.hasNext(),false);
+    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 CriteriaEquals(new LongValue(124L))}),null);
+    table.deleteRows(index.buildAccessor(new IndexCriteria[]{new CriteriaEquals(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();
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    assertNotNull(accessor.getCurrentRowID());
+    value = accessor.getValue("colA");
     assertNotNull(value);
     assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
     assertEquals(111L,((LongValue)value).getValue());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),false);
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
     ts.abandonTransaction();
 
     ts.beginTransaction();
@@ -401,50 +380,45 @@ public class SanityTest
     ts.beginTransaction();
     WHIndex index = ts.lookupIndex("testindex");
     WHAccessor accessor = index.buildAccessor();
-    assertEquals(accessor.hasNext(),true);
-    WHRowID rowID = accessor.getNext();
-    assertNotNull(rowID);
-    WHValue value = index.getValue(rowID,"colA");
+    assertNotNull(accessor.getCurrentRowID());
+    WHValue value = accessor.getValue("colA");
     assertNotNull(value);
     assertEquals("org.apache.warthog.common.LongValue",value.getClass().getName());
     assertEquals(124L,((LongValue)value).getValue());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+    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());
-    assertEquals(accessor.hasNext(),false);
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
     ts.abandonTransaction();
 
     ts.beginTransaction();
     index = ts.lookupIndex("testindex");
     accessor = index.buildAccessor(new IndexCriteria[]{
       new CriteriaEquals(new StringValue("hello")),
-      new CriteriaBefore(new LongValue(123L))});
-    assertEquals(accessor.hasNext(),true);
-    rowID = accessor.getNext();
-    assertNotNull(rowID);
-    value = index.getValue(rowID,"colA");
+      new CriteriaBefore(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());
-    assertEquals(accessor.hasNext(),false);
+    accessor.advance();
+    assertNull(accessor.getCurrentRowID());
     ts.abandonTransaction();
 
     ts.beginTransaction();



Mime
View raw message