incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1228664 - in /incubator/lcf/warthog/trunk/src: main/java/org/apache/warthog/api/ main/java/org/apache/warthog/common/ main/java/org/apache/warthog/keyvaluetablestore/ test/java/org/apache/warthog/tests/
Date Sat, 07 Jan 2012 16:54:06 GMT
Author: kwright
Date: Sat Jan  7 16:54:05 2012
New Revision: 1228664

URL: http://svn.apache.org/viewvc?rev=1228664&view=rev
Log:
Pull the comparator instantiation into the interface also.

Added:
    incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/DoubleComparatorAscending.java
      - copied, changed from r1228612, incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/DoubleComparatorAscending.java
    incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/LongComparatorAscending.java
      - copied, changed from r1228611, incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/LongComparatorAscending.java
    incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/StringComparatorAscending.java
      - copied, changed from r1228611, incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/StringComparatorAscending.java
Removed:
    incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/DoubleComparatorAscending.java
    incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/LongComparatorAscending.java
    incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/StringComparatorAscending.java
Modified:
    incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/WHTableStore.java
    incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/keyvaluetablestore/TableStore.java
    incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/MultiThreadTest.java
    incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/PerformanceTest.java
    incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/SanityTest.java

Modified: incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/WHTableStore.java
URL: http://svn.apache.org/viewvc/incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/WHTableStore.java?rev=1228664&r1=1228663&r2=1228664&view=diff
==============================================================================
--- incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/WHTableStore.java (original)
+++ incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/WHTableStore.java Sat
Jan  7 16:54:05 2012
@@ -59,7 +59,7 @@ public interface WHTableStore
     throws WHException;
     
   /** Create an index */
-  public WHIndex createIndex(String name, WHTable table, String[] columnNames, String[] comparatorClasses,
boolean unique)
+  public WHIndex createIndex(String name, WHTable table, String[] columnNames, WHComparator[]
comparators, boolean unique)
     throws WHException;
     
   /** Drop an index */
@@ -112,4 +112,21 @@ public interface WHTableStore
   public WHValue make(Reader reader)
     throws IOException,WHException;
 
+  // Comparators can be constructed here, of various types
+  
+  /** Construct a long comparator.
+  */
+  public WHComparator makeLongComparator()
+    throws WHException;
+    
+  /** Construct a string comparator.
+  */
+  public WHComparator makeStringComparator()
+    throws WHException;
+    
+  /** Construct a double comparator.
+  */
+  public WHComparator makeDoubleComparator()
+    throws WHException;
+    
 }

Copied: incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/DoubleComparatorAscending.java
(from r1228612, incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/DoubleComparatorAscending.java)
URL: http://svn.apache.org/viewvc/incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/DoubleComparatorAscending.java?p2=incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/DoubleComparatorAscending.java&p1=incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/DoubleComparatorAscending.java&r1=1228612&r2=1228664&rev=1228664&view=diff
==============================================================================
--- incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/DoubleComparatorAscending.java
(original)
+++ incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/DoubleComparatorAscending.java
Sat Jan  7 16:54:05 2012
@@ -17,7 +17,9 @@
 * limitations under the License.
 */
 
-package org.apache.warthog.api;
+package org.apache.warthog.common;
+
+import org.apache.warthog.api.*;
 
 /** Class that compares double values, and sorts in ascending order.
 */

Copied: incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/LongComparatorAscending.java
(from r1228611, incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/LongComparatorAscending.java)
URL: http://svn.apache.org/viewvc/incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/LongComparatorAscending.java?p2=incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/LongComparatorAscending.java&p1=incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/LongComparatorAscending.java&r1=1228611&r2=1228664&rev=1228664&view=diff
==============================================================================
--- incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/LongComparatorAscending.java
(original)
+++ incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/LongComparatorAscending.java
Sat Jan  7 16:54:05 2012
@@ -17,7 +17,9 @@
 * limitations under the License.
 */
 
-package org.apache.warthog.api;
+package org.apache.warthog.common;
+
+import org.apache.warthog.api.*;
 
 /** Class that compares long values, and sorts in ascending order.
 */

Copied: incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/StringComparatorAscending.java
(from r1228611, incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/StringComparatorAscending.java)
URL: http://svn.apache.org/viewvc/incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/StringComparatorAscending.java?p2=incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/StringComparatorAscending.java&p1=incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/StringComparatorAscending.java&r1=1228611&r2=1228664&rev=1228664&view=diff
==============================================================================
--- incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/api/StringComparatorAscending.java
(original)
+++ incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/common/StringComparatorAscending.java
Sat Jan  7 16:54:05 2012
@@ -17,7 +17,9 @@
 * limitations under the License.
 */
 
-package org.apache.warthog.api;
+package org.apache.warthog.common;
+
+import org.apache.warthog.api.*;
 
 /** Class that compares string values, and sorts in ascending order.
 */

Modified: incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/keyvaluetablestore/TableStore.java
URL: http://svn.apache.org/viewvc/incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/keyvaluetablestore/TableStore.java?rev=1228664&r1=1228663&r2=1228664&view=diff
==============================================================================
--- incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/keyvaluetablestore/TableStore.java
(original)
+++ incubator/lcf/warthog/trunk/src/main/java/org/apache/warthog/keyvaluetablestore/TableStore.java
Sat Jan  7 16:54:05 2012
@@ -153,7 +153,7 @@ public class TableStore implements WHTab
   
     
   /** Create an index */
-  public WHIndex createIndex(String name, WHTable table, String[] columnNames, String[] comparatorClasses,
boolean unique)
+  public WHIndex createIndex(String name, WHTable table, String[] columnNames, WHComparator[]
comparators, boolean unique)
     throws WHException
   {
     if (currentTransaction == null)
@@ -163,9 +163,11 @@ public class TableStore implements WHTab
       throw new WHException("Index already exists");
     LongValue indexID = allocateNewGeneralID();
     long[] columnIDs = new long[columnNames.length];
+    String[] comparatorClasses = new String[columnNames.length];
     for (int i = 0 ; i < columnIDs.length ; i++)
     {
       columnIDs[i] = t.getColumnID(columnNames[i]);
+      comparatorClasses[i] = comparators[i].getClass().getName();
     }
     setIndexName(indexID,name);
     currentTransaction.put(new IndexKey(indexID.getValue()),new IndexValue(t.getIDValue(),columnIDs,comparatorClasses,unique));
@@ -272,6 +274,32 @@ public class TableStore implements WHTab
     //return new ExtendedTextValue(reader);
   }
 
+  // Comparators can be constructed here, of various types
+  
+  /** Construct a long comparator.
+  */
+  public WHComparator makeLongComparator()
+    throws WHException
+  {
+    return new LongComparatorAscending();
+  }
+    
+  /** Construct a string comparator.
+  */
+  public WHComparator makeStringComparator()
+    throws WHException
+  {
+    return new StringComparatorAscending();
+  }
+    
+  /** Construct a double comparator.
+  */
+  public WHComparator makeDoubleComparator()
+    throws WHException
+  {
+    return new DoubleComparatorAscending();
+  }
+
   // Non-interface public methods
   
   protected Map<LongValue,LongValue> startMap = new HashMap<LongValue,LongValue>();

Modified: incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/MultiThreadTest.java
URL: http://svn.apache.org/viewvc/incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/MultiThreadTest.java?rev=1228664&r1=1228663&r2=1228664&view=diff
==============================================================================
--- incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/MultiThreadTest.java
(original)
+++ incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/MultiThreadTest.java
Sat Jan  7 16:54:05 2012
@@ -111,24 +111,19 @@ public class MultiThreadTest
     WHTable table = ts.lookupTable("testtable");
     ts.createIndex("testindex1",table,
       new String[]{"colB","colA"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.createIndex("testindex2",table,
       new String[]{"colD","colC"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.createIndex("testindex3",table,
       new String[]{"colF","colE"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.createIndex("testindex4",table,
       new String[]{"colH","colG"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.createIndex("testindex5",table,
       new String[]{"colJ","colI"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.commitTransaction();
 
     InsertThread[] threads = new InsertThread[threadCount];
@@ -188,24 +183,19 @@ public class MultiThreadTest
     WHTable table = ts.lookupTable("testtable");
     ts.createIndex("testindex1",table,
       new String[]{"colB","colA"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.createIndex("testindex2",table,
       new String[]{"colD","colC"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.createIndex("testindex3",table,
       new String[]{"colF","colE"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.createIndex("testindex4",table,
       new String[]{"colH","colG"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.createIndex("testindex5",table,
       new String[]{"colJ","colI"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.commitTransaction();
 
     TaskThread[] threads = new TaskThread[threadCount];

Modified: incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/PerformanceTest.java
URL: http://svn.apache.org/viewvc/incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/PerformanceTest.java?rev=1228664&r1=1228663&r2=1228664&view=diff
==============================================================================
--- incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/PerformanceTest.java
(original)
+++ incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/PerformanceTest.java
Sat Jan  7 16:54:05 2012
@@ -43,24 +43,19 @@ public class PerformanceTest
     WHTable table = ts.lookupTable("testtable");
     ts.createIndex("testindex1",table,
       new String[]{"colB","colA"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.createIndex("testindex2",table,
       new String[]{"colD","colC"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.createIndex("testindex3",table,
       new String[]{"colF","colE"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.createIndex("testindex4",table,
       new String[]{"colH","colG"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.createIndex("testindex5",table,
       new String[]{"colJ","colI"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},false);
     ts.commitTransaction();
 
     int rowCount = 10000;

Modified: incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/SanityTest.java
URL: http://svn.apache.org/viewvc/incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/SanityTest.java?rev=1228664&r1=1228663&r2=1228664&view=diff
==============================================================================
--- incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/SanityTest.java (original)
+++ incubator/lcf/warthog/trunk/src/test/java/org/apache/warthog/tests/SanityTest.java Sat
Jan  7 16:54:05 2012
@@ -110,7 +110,7 @@ public class SanityTest
     // Now build a one-column unique index on colA
     ts.beginTransaction(true);
     WHTable table = ts.lookupTable("testtable");
-    ts.createIndex("testindex",table,new String[]{"colA"},new String[]{"org.apache.warthog.api.LongComparatorAscending"},true);
+    ts.createIndex("testindex",table,new String[]{"colA"},new WHComparator[]{ts.makeLongComparator()},true);
     ts.commitTransaction();
     
     // Read in index order
@@ -372,8 +372,7 @@ public class SanityTest
     WHTable table = ts.lookupTable("testtable");
     ts.createIndex("testindex",table,
       new String[]{"colB","colA"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending",
-        "org.apache.warthog.api.LongComparatorAscending"},true);
+      new WHComparator[]{ts.makeStringComparator(),ts.makeLongComparator()},true);
     ts.commitTransaction();
     
     // Read in index order
@@ -463,7 +462,7 @@ public class SanityTest
     table = ts.lookupTable("testtable");
     ts.createIndex("testindex",table,
       new String[]{"colB"},
-      new String[]{"org.apache.warthog.api.StringComparatorAscending"},false);
+      new WHComparator[]{ts.makeStringComparator()},false);
     ts.commitTransaction();
 
     // Now use the index as a relationship (to provide ordering), and build an aggregate
relationship based on it
@@ -548,8 +547,8 @@ public class SanityTest
     ts.beginTransaction(true);
     table = ts.lookupTable("testtable");
     aggregateRelationship = new AggregateRelationship(table,new WHColumnDescription[]{
-      new ColumnMin(new LongComparatorAscending(),"colA","minA"),
-      new ColumnMax(new LongComparatorAscending(),"colA","maxA")});
+      new ColumnMin(ts.makeLongComparator(),"colA","minA"),
+      new ColumnMax(ts.makeLongComparator(),"colA","maxA")});
     // Grab the accessor and verify it is correct
     accessor = aggregateRelationship.buildAccessor();
     assertNotNull(accessor.getCurrentRowID());
@@ -578,7 +577,7 @@ public class SanityTest
     // Now build a one-column unique index on colA
     ts.beginTransaction(true);
     WHTable table = ts.lookupTable("testtable");
-    ts.createIndex("testindex",table,new String[]{"colA"},new String[]{"org.apache.warthog.api.LongComparatorAscending"},true);
+    ts.createIndex("testindex",table,new String[]{"colA"},new WHComparator[]{ts.makeLongComparator()},true);
     ts.commitTransaction();
 
     WHIndex index;
@@ -589,7 +588,7 @@ public class SanityTest
     ts.beginTransaction(true);
     index = ts.lookupIndex("testindex");
     filterRelationship = new FilterRelationship(index,new FilterEqualsOrBefore("colA",ts.make(124L),
-      new LongComparatorAscending()));
+      ts.makeLongComparator()));
     accessor = filterRelationship.buildAccessor();
     assertNotNull(accessor.getCurrentRowID());
     value = accessor.getValue("colA");
@@ -615,7 +614,7 @@ public class SanityTest
     ts.beginTransaction(true);
     index = ts.lookupIndex("testindex");
     filterRelationship = new FilterRelationship(index,new FilterEqualsOrAfter("colA",ts.make(124L),
-      new LongComparatorAscending()));
+      ts.makeLongComparator()));
     accessor = filterRelationship.buildAccessor();
     assertNotNull(accessor.getCurrentRowID());
     value = accessor.getValue("colA");
@@ -635,7 +634,7 @@ public class SanityTest
     ts.beginTransaction(true);
     index = ts.lookupIndex("testindex");
     filterRelationship = new FilterRelationship(index,new FilterBefore("colA",ts.make(124L),
-      new LongComparatorAscending()));
+      ts.makeLongComparator()));
     accessor = filterRelationship.buildAccessor();
     assertNotNull(accessor.getCurrentRowID());
     value = accessor.getValue("colA");
@@ -655,7 +654,7 @@ public class SanityTest
     ts.beginTransaction(true);
     index = ts.lookupIndex("testindex");
     filterRelationship = new FilterRelationship(index,new FilterAfter("colA",ts.make(124L),
-      new LongComparatorAscending()));
+      ts.makeLongComparator()));
     accessor = filterRelationship.buildAccessor();
     value = accessor.getValue("colA");
     assertNotNull(value);
@@ -668,7 +667,7 @@ public class SanityTest
     ts.beginTransaction(true);
     index = ts.lookupIndex("testindex");
     filterRelationship = new FilterRelationship(index,new FilterEqualsMultiple("colA",new
WHValue[]{ts.make(123L),ts.make(333L)},
-      new LongComparatorAscending()));
+      ts.makeLongComparator()));
     accessor = filterRelationship.buildAccessor();
     assertNotNull(accessor.getCurrentRowID());
     value = accessor.getValue("colA");
@@ -682,7 +681,7 @@ public class SanityTest
     ts.beginTransaction(true);
     index = ts.lookupIndex("testindex");
     filterRelationship = new FilterRelationship(index,new FilterBetween("colA",ts.make(123L),ts.make(333L),
-      new LongComparatorAscending()));
+      ts.makeLongComparator()));
     accessor = filterRelationship.buildAccessor();
     assertNotNull(accessor.getCurrentRowID());
     value = accessor.getValue("colA");
@@ -758,13 +757,13 @@ public class SanityTest
     // Build indexes on both of these so we establish order for the test
     ts.beginTransaction(true);
     table = ts.lookupTable("testtable1");
-    ts.createIndex("testindex1",table,new String[]{"colC"},new String[]{"org.apache.warthog.api.LongComparatorAscending"},true);
+    ts.createIndex("testindex1",table,new String[]{"colC"},new WHComparator[]{ts.makeLongComparator()},true);
     ts.commitTransaction();
 
     ts.beginTransaction(true);
     table = ts.lookupTable("testtable2");
-    ts.createIndex("testindex2",table,new String[]{"colA","colB"},new String[]{"org.apache.warthog.api.LongComparatorAscending",
-      "org.apache.warthog.api.StringComparatorAscending"},false);
+    ts.createIndex("testindex2",table,new String[]{"colA","colB"},new WHComparator[]{ts.makeLongComparator(),
+      ts.makeStringComparator()},false);
     ts.commitTransaction();
 
     // Now, build the join and iterate over it.



Mime
View raw message