incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1220349 [2/6] - in /incubator/lcf/branches/CONNECTORS-286/warthog-reimport: ./ lib/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/warthog/ src/main/java/org/apache/warthog/api/ src/main...
Date Sun, 18 Dec 2011 08:26:34 GMT
Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEquals.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEquals.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEquals.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEquals.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,62 @@
+/* $Id: IndexEquals.java -1   $ */
+
+/**
+* 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.api;
+
+/** This class represents index criteria designed to locate only exact matches against
+* a specific WHValue.
+*/
+public class IndexEquals extends IndexCriteria
+{
+  protected WHValue value;
+  
+  /** Constructor */
+  public IndexEquals(WHValue value)
+  {
+    super();
+    this.value = value;
+  }
+  
+  /** Evaluate a given value (which comes from a table row described by a btree node, and which
+  * may turn out to be null) against the criteria as determined by this class, and return
+  * an appropriate bit pattern.  The bit pattern is used to limit which branches of the index tree the search
+  * should descend.
+  *
+  * The comparator is provided to allow simple inequality comparisons against known values using the same logic
+  * as the index is organized by.
+  */
+  public int evaluateValue(WHValue value, WHComparator comparator)
+    throws WHException
+  {
+    int result = comparator.compare(value,this.value);
+    if (result == WHComparator.RESULT_EQUALS)
+      return SIGNAL_EQUALS;
+    
+    if (result == WHComparator.RESULT_GREATER)
+      return SIGNAL_GREATER;
+    
+    if (result == WHComparator.RESULT_LESS)
+      return SIGNAL_LESSER;
+    
+    throw new WHException("Comparator returned unexpected value");
+  }
+    
+}
+  
+  
\ No newline at end of file

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsMultiple.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsMultiple.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsMultiple.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsMultiple.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,73 @@
+/* $Id: IndexEqualsMultiple.java -1   $ */
+
+/**
+* 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.api;
+
+/** This class represents index criteria designed to locate only exact matches against
+* a specific set of WHValues.
+*/
+public class IndexEqualsMultiple extends IndexCriteria
+{
+  protected WHValue[] values;
+  
+  /** Constructor */
+  public IndexEqualsMultiple(WHValue[] values)
+  {
+    super();
+    this.values = values;
+  }
+  
+  /** Evaluate a given value (which comes from a table row described by a btree node, and which
+  * may turn out to be null) against the criteria as determined by this class, and return
+  * an appropriate bit pattern.  The bit pattern is used to limit which branches of the index tree the search
+  * should descend.
+  *
+  * The comparator is provided to allow simple inequality comparisons against known values using the same logic
+  * as the index is organized by.
+  */
+  public int evaluateValue(WHValue value, WHComparator comparator)
+    throws WHException
+  {
+    
+    // Accumulate result
+    int rval = 0;
+    
+    for (int i = 0 ; i < values.length ; i++)
+    {
+      // Look at this value, and accumulate results
+      int result = comparator.compare(value,values[i]);
+      if (result == WHComparator.RESULT_EQUALS)
+        rval |= SIGNAL_EQUALS;
+      
+      else if (result == WHComparator.RESULT_GREATER)
+        rval |= SIGNAL_GREATER;
+      
+      else if (result == WHComparator.RESULT_LESS)
+        rval |= SIGNAL_LESSER;
+      
+      else
+        throw new WHException("Comparator returned unexpected value");
+    }
+    
+    return rval;
+  }
+    
+}
+  
+  
\ No newline at end of file

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsOrAfter.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsOrAfter.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsOrAfter.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsOrAfter.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,62 @@
+/* $Id: IndexEqualsOrAfter.java -1   $ */
+
+/**
+* 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.api;
+
+/** This class represents index criteria designed to locate matches that equal or come after
+* a specific WHValue.
+*/
+public class IndexEqualsOrAfter extends IndexCriteria
+{
+  protected WHValue value;
+  
+  /** Constructor */
+  public IndexEqualsOrAfter(WHValue value)
+  {
+    super();
+    this.value = value;
+  }
+  
+  /** Evaluate a given value (which comes from a table row described by a btree node, and which
+  * may turn out to be null) against the criteria as determined by this class, and return
+  * an appropriate bit pattern.  The bit pattern is used to limit which branches of the index tree the search
+  * should descend.
+  *
+  * The comparator is provided to allow simple inequality comparisons against known values using the same logic
+  * as the index is organized by.
+  */
+  public int evaluateValue(WHValue value, WHComparator comparator)
+    throws WHException
+  {
+    int result = comparator.compare(value,this.value);
+    if (result == WHComparator.RESULT_EQUALS)
+      return SIGNAL_GREATER | SIGNAL_EQUALS;
+    
+    if (result == WHComparator.RESULT_GREATER)
+      return SIGNAL_GREATER;
+    
+    if (result == WHComparator.RESULT_LESS)
+      return SIGNAL_LESSER | SIGNAL_EQUALS | SIGNAL_GREATER;
+    
+    throw new WHException("Comparator returned unexpected value");
+  }
+    
+}
+  
+  
\ No newline at end of file

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsOrBefore.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsOrBefore.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsOrBefore.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexEqualsOrBefore.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,62 @@
+/* $Id: IndexEqualsOrBefore.java -1   $ */
+
+/**
+* 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.api;
+
+/** This class represents index criteria designed to locate that precede or equal
+* a specific WHValue.
+*/
+public class IndexEqualsOrBefore extends IndexCriteria
+{
+  protected WHValue value;
+  
+  /** Constructor */
+  public IndexEqualsOrBefore(WHValue value)
+  {
+    super();
+    this.value = value;
+  }
+  
+  /** Evaluate a given value (which comes from a table row described by a btree node, and which
+  * may turn out to be null) against the criteria as determined by this class, and return
+  * an appropriate bit pattern.  The bit pattern is used to limit which branches of the index tree the search
+  * should descend.
+  *
+  * The comparator is provided to allow simple inequality comparisons against known values using the same logic
+  * as the index is organized by.
+  */
+  public int evaluateValue(WHValue value, WHComparator comparator)
+    throws WHException
+  {
+    int result = comparator.compare(value,this.value);
+    if (result == WHComparator.RESULT_EQUALS)
+      return SIGNAL_LESSER | SIGNAL_EQUALS;
+    
+    if (result == WHComparator.RESULT_GREATER)
+      return SIGNAL_GREATER | SIGNAL_EQUALS | SIGNAL_LESSER;
+    
+    if (result == WHComparator.RESULT_LESS)
+      return SIGNAL_LESSER;
+    
+    throw new WHException("Comparator returned unexpected value");
+  }
+    
+}
+  
+  
\ No newline at end of file

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexRelationship.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexRelationship.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexRelationship.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexRelationship.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,56 @@
+/* $Id: IndexRelationship.java -1   $ */
+
+/**
+* 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.api;
+
+/** The index relationship basically views another relationship (a table) through
+* an index with criteria and ordering.
+*/
+public class IndexRelationship implements WHRelationship
+{
+  protected WHIndex index;
+  protected IndexCriteria[] criteria;
+  protected boolean[] orderReversed;
+  
+  /** Constructor */
+  public IndexRelationship(WHIndex index, IndexCriteria[] criteria, boolean[] orderReversed)
+  {
+    this.index = index;
+    this.criteria = criteria;
+    this.orderReversed = orderReversed;
+  }
+  
+  /** Get the column names represented by the relationship. */
+  public String[] getColumnNames()
+    throws WHException
+  {
+    return index.getColumnNames();
+  }
+
+  /** Get the row accessor.  This determines
+  * both the initial set of rows and the ordering.  The results can be later filtered to
+  * yield the final output data.
+  */
+  public WHAccessor buildAccessor()
+    throws WHException
+  {
+    return index.buildAccessor(criteria,orderReversed);
+  }
+  
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexRelationshipBuilder.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexRelationshipBuilder.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexRelationshipBuilder.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/IndexRelationshipBuilder.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,111 @@
+/* $Id: IndexRelationshipBuilder.java -1   $ */
+
+/**
+* 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.api;
+
+import java.lang.reflect.*;
+
+/** Build an index relationship based on a row in an accessor.
+*/
+public class IndexRelationshipBuilder implements WHRelationshipBuilder
+{
+  protected WHIndex index;
+  protected IndexCriteria[] criteria;
+  protected String[] accessorColumn;
+  protected String[] criteriaClassName;
+  protected boolean[] orderReversed;
+
+  /** Constructor.  The criteria passed to the index will include
+  * both criteria we specify in the constructor, and criteria based
+  * the accessor row we see.  Thus the segregation of the incoming
+  * arguments.
+  * The way it works is that whenever the accessorColumn value is non-null, then
+  * the matching criteriaClass is instantiated (with a single WHValue argument).
+  * Otherwise, the criteria passed in the "criteria" argument is used.
+  */
+  public IndexRelationshipBuilder(WHIndex index,
+    IndexCriteria[] criteria,
+    String[] accessorColumn,
+    String[] criteriaClassName,
+    boolean[] orderReversed)
+    throws WHException
+  {
+    if (criteria.length != accessorColumn.length ||
+      criteria.length != criteriaClassName.length ||
+      criteria.length != orderReversed.length)
+      throw new WHException("Criteria, accessorColumn, criteriaClassName, and orderReversed all must be the same size");
+    this.index = index;
+    this.criteria = criteria;
+    this.orderReversed = orderReversed;
+    this.accessorColumn = accessorColumn;
+    this.criteriaClassName = criteriaClassName;
+  }
+  
+  /** Construct a relationship based on the specified accessor row.
+  */
+  public WHRelationship createRelationship(WHAccessor accessor)
+    throws WHException
+  {
+    IndexCriteria[] currentCriteria = new IndexCriteria[criteria.length];
+    
+    // Fill in the missing pieces from the current accessor.
+    for (int i = 0 ; i < criteria.length ; i++)
+    {
+      if (accessorColumn[i] != null && criteriaClassName[i] != null)
+      {
+        WHValue theMatchValue = accessor.getValue(accessorColumn[i]);
+        try
+        {
+          Class classValue = Class.forName(criteriaClassName[i]);
+          Constructor constructor = classValue.getConstructor(new Class[]{WHValue.class});
+          Object object = constructor.newInstance(new Object[]{theMatchValue});
+          if (!(object instanceof IndexCriteria))
+            throw new WHException("Criteria class '"+criteriaClassName[i]+"' does not extend IndexCriteria");
+          currentCriteria[i] = (IndexCriteria)object;
+        }
+        catch (ClassNotFoundException e)
+        {
+          throw new WHException("Can't find criteria class '"+criteriaClassName[i]+"': "+e.getMessage(),e);
+        }
+        catch (NoSuchMethodException e)
+        {
+          throw new WHException("Criteria class '"+criteriaClassName[i]+"' does not have a constructor with a WHValue argument: "+e.getMessage(),e);
+        }
+        catch (InvocationTargetException e)
+        {
+          throw new WHException("Constructor exception instantiating criteria class '"+criteriaClassName[i]+"': "+e.getMessage(),e);
+        }
+        catch (InstantiationException e)
+        {
+          throw new WHException("Instantiation exception for criteria class '"+criteriaClassName[i]+"': "+e.getMessage(),e);
+        }
+        catch (IllegalAccessException e)
+        {
+          throw new WHException("Criteria class '"+criteriaClassName[i]+"' WHValue constructor has protected access",e);
+        }
+      }
+      else
+        currentCriteria[i] = criteria[i];
+    }
+    
+    // Create an index relationship so we can get its accessor
+    return new IndexRelationship(index,currentCriteria,orderReversed);
+  }
+  
+}
\ No newline at end of file

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/JoinAccessor.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/JoinAccessor.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/JoinAccessor.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/JoinAccessor.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,120 @@
+/* $Id: JoinAccessor.java -1   $ */
+
+/**
+* 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.api;
+
+import java.util.*;
+
+/** Accessor class that returns a join of two tables.
+*/
+public class JoinAccessor implements WHAccessor
+{
+  protected WHAccessor primeAccessor;
+  protected WHRelationshipBuilder secondaryRelationshipBuilder;
+  protected Map<String,String> secondaryColumnMap;
+  
+  protected WHAccessor currentSecondaryAccessor;
+  protected WHRowID currentRowID;
+    
+  public JoinAccessor(WHAccessor primeAccessor, WHRelationshipBuilder secondaryRelationshipBuilder,
+    Map<String,String> secondaryColumnMap)
+    throws WHException
+  {
+    this.primeAccessor = primeAccessor;
+    this.secondaryRelationshipBuilder = secondaryRelationshipBuilder;
+    this.secondaryColumnMap = secondaryColumnMap;
+    goToNextLegalRow();
+  }
+  
+  protected void goToNextLegalRow()
+    throws WHException
+  {
+    while (true)
+    {
+      WHRowID primeRowID = primeAccessor.getCurrentRowID();
+      if (primeRowID == null)
+      {
+        currentRowID = null;
+        return;
+      }
+      if (currentSecondaryAccessor == null)
+      {
+        currentSecondaryAccessor = secondaryRelationshipBuilder.createRelationship(primeAccessor).buildAccessor();
+      }
+      WHRowID secondaryRowID = currentSecondaryAccessor.getCurrentRowID();
+      if (secondaryRowID == null)
+      {
+        // Done with secondary for this primary row, so advance primary
+        primeAccessor.advance();
+        currentSecondaryAccessor = null;
+        // Since we haven't found a row yet, loop
+        continue;
+      }
+      // We've found a row!  Construct a row ID
+      currentRowID = new JoinRowID(primeRowID,secondaryRowID);
+      break;
+    }
+  }
+
+  /** Advance to the next row.
+  */
+  public void advance()
+    throws WHException
+  {
+    if (currentRowID != null)
+    {
+      currentSecondaryAccessor.advance();
+      goToNextLegalRow();
+    }
+  }
+  
+  /** Read the current relationship row ID,  Null will be returned if we are
+  * at the end of the sequence.
+  */
+  public WHRowID getCurrentRowID()
+    throws WHException
+  {
+    return currentRowID;
+  }
+	
+  /** Get the data for the current row and specified column. 
+  */
+  public WHValue getValue(String columnName)
+    throws WHException
+  {
+    String secondaryKey = secondaryColumnMap.get(columnName);
+    if (secondaryKey == null)
+      return primeAccessor.getValue(columnName);
+    return currentSecondaryAccessor.getValue(secondaryKey);
+  }
+
+  /** This class represents a joined rowID */
+  protected static class JoinRowID implements WHRowID
+  {
+    protected WHRowID primaryRow;
+    protected WHRowID secondaryRow;
+    
+    public JoinRowID(WHRowID primaryRow, WHRowID secondaryRow)
+    {
+      this.primaryRow = primaryRow;
+      this.secondaryRow = secondaryRow;
+    }
+  }
+  
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/JoinRelationship.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/JoinRelationship.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/JoinRelationship.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/JoinRelationship.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,80 @@
+/* $Id: JoinRelationship.java -1   $ */
+
+/**
+* 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.api;
+
+import java.util.*;
+
+/** This relationship type represents the joining of a primary relationship and a
+* secondary relationship, plus a joining criteria, yielding a result with columns that
+* includes the columns from both.  To build a three-way join, just nest join
+* relationships appropriately.
+*/
+public class JoinRelationship implements WHRelationship
+{
+  protected WHRelationship primeRelationship;
+  protected WHRelationshipBuilder secondaryRelationshipBuilder;
+  
+  protected Map<String,String> secondaryColumnMap;
+  protected String[] returnColumns;
+  
+  /** Constructor. */
+  public JoinRelationship(WHRelationship primeRelationship,
+    String[] secondaryColumns,
+    String[] secondaryReturnColumns,
+    WHRelationshipBuilder secondaryRelationshipBuilder)
+    throws WHException
+  {
+    if (secondaryColumns.length != secondaryReturnColumns.length)
+      throw new WHException("Secondary columns and return columns must be the same number");
+    this.primeRelationship = primeRelationship;
+    this.secondaryRelationshipBuilder = secondaryRelationshipBuilder;
+    String[] primaryColumns = primeRelationship.getColumnNames();
+    returnColumns = new String[primaryColumns.length + secondaryReturnColumns.length];
+    int position = 0;
+    for (int i = 0 ; i < primaryColumns.length ; i++)
+    {
+      returnColumns[position++] = primaryColumns[i];
+    }
+    secondaryColumnMap = new HashMap<String,String>();
+    for (int i = 0 ; i < secondaryReturnColumns.length ; i++)
+    {
+      returnColumns[position++] = secondaryReturnColumns[i];
+      secondaryColumnMap.put(secondaryReturnColumns[i],secondaryColumns[i]);
+    }
+  }
+  
+  /** Get the column names represented by the relationship. */
+  public String[] getColumnNames()
+    throws WHException
+  {
+    return returnColumns;
+  }
+
+  /** Get the row accessor.  This determines
+  * both the initial set of rows and the ordering.  The results can be later filtered to
+  * yield the final output data.
+  */
+  public WHAccessor buildAccessor()
+    throws WHException
+  {
+    return new JoinAccessor(primeRelationship.buildAccessor(),secondaryRelationshipBuilder,secondaryColumnMap);
+  }
+  
+}
\ No newline at end of file

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/RowSkipAccessor.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/RowSkipAccessor.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/RowSkipAccessor.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/RowSkipAccessor.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,96 @@
+/* $Id: RowSkipAccessor.java -1   $ */
+
+/**
+* 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.api;
+
+/** Accessor class that returns only rows from a parent between a specific numeric range.
+*/
+public class RowSkipAccessor implements WHAccessor
+{
+  protected WHAccessor baseAccessor;
+  protected Long startRow;
+  protected Long endRow;
+  protected WHRowID currentRowID;
+  long rowNumber = 0L;
+    
+  public RowSkipAccessor(WHAccessor baseAccessor, Long startRow, Long rowCount)
+    throws WHException
+  {
+    this.baseAccessor = baseAccessor;
+    this.startRow = startRow;
+    if (rowCount != null)
+      endRow = new Long(((startRow==null)?0L:startRow.longValue())+rowCount.longValue());
+    else
+      endRow = null;
+    goToNextLegalRow();
+  }
+  
+  protected void goToNextLegalRow()
+    throws WHException
+  {
+    while (true)
+    {
+      currentRowID = baseAccessor.getCurrentRowID();
+      if (currentRowID == null)
+        return;
+      if (startRow != null && rowNumber < startRow.longValue())
+      {
+        rowNumber++;
+        baseAccessor.advance();
+        continue;
+      }
+      if (endRow != null && rowNumber >= endRow.longValue())
+      {
+        currentRowID = null;
+        return;
+      }
+      break;
+    }
+  }
+
+  /** Advance to the next row.
+  */
+  public void advance()
+    throws WHException
+  {
+    if (currentRowID != null)
+    {
+      baseAccessor.advance();
+      goToNextLegalRow();
+    }
+  }
+  
+  /** Read the current relationship row ID,  Null will be returned if we are
+  * at the end of the sequence.
+  */
+  public WHRowID getCurrentRowID()
+    throws WHException
+  {
+    return currentRowID;
+  }
+	
+  /** Get the data for the current row and specified column. 
+  */
+  public WHValue getValue(String columnName)
+    throws WHException
+  {
+    return baseAccessor.getValue(columnName);
+  }
+
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/RowSkipRelationship.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/RowSkipRelationship.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/RowSkipRelationship.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/RowSkipRelationship.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,55 @@
+/* $Id: RowSkipRelationship.java -1   $ */
+
+/**
+* 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.api;
+
+/** This relationship type applies row filtering on top of another relationship.
+*/
+public class RowSkipRelationship implements WHRelationship
+{
+  protected WHRelationship relationshipToFilter;
+  Long startRow;
+  Long rowCount;
+  
+  /** Constructor */
+  public RowSkipRelationship(WHRelationship relationshipToFilter, Long startRow, Long rowCount)
+  {
+    this.relationshipToFilter = relationshipToFilter;
+    this.startRow = startRow;
+    this.rowCount = rowCount;
+  }
+  
+  /** Get the column names represented by the relationship. */
+  public String[] getColumnNames()
+    throws WHException
+  {
+    return relationshipToFilter.getColumnNames();
+  }
+
+  /** Get the row accessor.  This determines
+  * both the initial set of rows and the ordering.  The results can be later filtered to
+  * yield the final output data.
+  */
+  public WHAccessor buildAccessor()
+    throws WHException
+  {
+    return new RowSkipAccessor(relationshipToFilter.buildAccessor(),startRow,rowCount);
+  }
+  
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHAccessor.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHAccessor.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHAccessor.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHAccessor.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,44 @@
+/* $Id: WHAccessor.java -1   $ */
+
+/**
+* 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.api;
+
+/** Use one of several means to find rows within a relationship.  The implementer
+* of this interface determines just how this is to be done.
+*/
+public interface WHAccessor
+{
+  /** Advance to the next row.
+  */
+  public void advance()
+    throws WHException;
+  
+  /** Read the current relationship row ID,  Null will be returned if we are
+  * at the end of the sequence.
+  */
+  public WHRowID getCurrentRowID()
+    throws WHException;
+	
+  /** Get the data for the current row and specified column. 
+  */
+  public WHValue getValue(String columnName)
+    throws WHException;
+
+
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHColumnCalculator.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHColumnCalculator.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHColumnCalculator.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHColumnCalculator.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,65 @@
+/* $Id: WHColumnCalculator.java -1   $ */
+
+/**
+* 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.api;
+
+/** Interface describing a set of return values for a result set.
+* This interface describes both row-based calculations AND
+* cross-row aggregations.  In order to do that, each instance receives
+* data from each row, and optionally coughs out a result value for the column.
+* Every time any column coughs out a value, the done() method will be called for all
+* the other columns as well, yielding a row of data.
+*
+* For some kinds of aggregation to work right it may require the accessor to order
+* results in a certain way.  This should be readily acheivable, however, with the use
+* of the proper indexes.
+* 
+* Note that the single-valued version of this abstraction is able to handle the
+* following well-known SQL constructs easily: SUM(), AVG(), MIN(), MAX(),
+* COUNT(), DISTINCT, and GROUP BY.
+*/
+public interface WHColumnCalculator
+{
+  /** Check whether a row can be added to to the column calculator.
+  * Does NOT actually change the result of the calculator!
+  *@param accessor is the current accessor.
+  *@return true if the row can be added, and false if it can't and a tally should be done immediately.
+  */
+  public boolean canProcessRowValue(WHAccessor accessor)
+    throws WHException;
+  
+  /** Check whether this calculator is capable of generating a final summary row value.
+  *@return true if it is capable.  tally() will only be called at the end for the summary
+  *     row if all columns are capable of generating a summary value.
+  */
+  public boolean canGenerateSummaryValue()
+    throws WHException;
+  
+  /** Feed a row to the column calculator.
+  */
+  public void processRowValue(WHAccessor accessor)
+    throws WHException;
+  
+  /** Tally a final result, obtaining whatever current aggregate value there is.
+  * Also resets the calculator in preparation for another set of rows.
+  */
+  public WHValue tally()
+    throws WHException;
+
+}
\ No newline at end of file

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHColumnDescription.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHColumnDescription.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHColumnDescription.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHColumnDescription.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,37 @@
+/* $Id: WHColumnDescription.java -1   $ */
+
+/**
+* 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.api;
+
+/** Interface describing a return value for a result set.
+* This interface describes the name of the returned column,
+* and provides a factory for creating a matching column calculator,
+* to go along with each accessor.
+*/
+public interface WHColumnDescription
+{
+  /** Get the name of the return column */
+  public String getReturnColumnName()
+    throws WHException;
+  
+  /** Create a return column calculator for this column.
+  */
+  public WHColumnCalculator createCalculator()
+    throws WHException;
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHComparator.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHComparator.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHComparator.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHComparator.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,39 @@
+/* $Id: WHComparator.java -1   $ */
+
+/**
+* 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.api;
+
+/** Interface that describes comparison functionality.
+* This is an underpinning of the btree structure.
+*/
+public interface WHComparator
+{
+  // Comparison result values
+  
+  public static int RESULT_EQUALS = 0;
+  public static int RESULT_LESS = -1;
+  public static int RESULT_GREATER = 1;
+  
+  /** Comparison method.
+  * This is only ever used to compare values; it cannot be used to compare null vs. non-null.
+  */
+  public int compare(WHValue leftValue, WHValue rightValue)
+    throws WHException;
+  
+}
\ No newline at end of file

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHConcurrencyException.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHConcurrencyException.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHConcurrencyException.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHConcurrencyException.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,36 @@
+/* $Id: WHConcurrencyException.java -1   $ */
+
+/**
+* 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.api;
+
+/** This exception is special in that it indicates a deadlock detection, which means
+* transaction has to be backed out and retried from start.
+*/
+public class WHConcurrencyException extends WHException
+{
+  public WHConcurrencyException()
+  {
+    super("Concurrent modification detected");
+  }
+  
+  public WHConcurrencyException(String msg)
+  {
+    super(msg);
+  }
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHException.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHException.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHException.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHException.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,34 @@
+/* $Id: WHException.java -1   $ */
+
+/**
+* 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.api;
+
+/** General exception */
+public class WHException extends Exception
+{
+  public WHException(String message)
+  {
+    super(message);
+  }
+  
+  public WHException(String message, Throwable e)
+  {
+    super(message,e);
+  }
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHIndex.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHIndex.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHIndex.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHIndex.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,49 @@
+/* $Id: WHIndex.java -1   $ */
+
+/**
+* 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.api;
+
+/** This abstraction provides access to a btree index.   Note: This is a permanent
+* structure, and can only index a permanent table.
+*/
+public interface WHIndex extends WHRelationship
+{
+  /** Get the underlying relationship the index applies to.
+  */
+  public WHRelationship getRelationship()
+    throws WHException;
+  
+  // Additional accessor support method.
+  //
+  // Index access supports any kind of matches which allow pruning of whole subtrees
+  // during index scanning.  Effectively this means that any criteria supplied must have
+  // something to do with the comparator order for this index and the column in
+  // question.
+  
+  /** Create an accessor based on this index which uses the provided criteria.  The
+  * criteria must align with the index's columns.  Null values are permitted where
+  * no criteria are present. 
+  *@param criteria are the criteria that apply to each individual index column; null for no criteria at all.
+  *@param orderReversed is a boolean for each individual index column; true if the comparator order of that column
+  * should be reversed for the accessor.  Null indicates no reversal for any column.
+  */
+  public WHAccessor buildAccessor(IndexCriteria[] criteria, boolean[] orderReversed)
+    throws WHException;
+  
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRelationship.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRelationship.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRelationship.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRelationship.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,39 @@
+/* $Id: WHRelationship.java -1   $ */
+
+/**
+* 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.api;
+
+/** This describes an abstract "table" of rows and columns.  This can be implemented
+* in a number of ways: as a straight table, as a join (with join criteria), and as the
+* result of a query.
+*/
+public interface WHRelationship
+{
+  /** Get the column names represented by the relationship. */
+  public String[] getColumnNames()
+    throws WHException;
+  
+  /** Get the row accessor.  This determines
+  * both the initial set of rows and the ordering.  The results can be later filtered to
+  * yield the final output data.
+  */
+  public WHAccessor buildAccessor()
+    throws WHException;
+  
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRelationshipBuilder.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRelationshipBuilder.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRelationshipBuilder.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRelationshipBuilder.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,33 @@
+/* $Id: WHRelationshipBuilder.java -1   $ */
+
+/**
+* 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.api;
+
+/** Classes that implement this interface construct WHRelationship objects based
+* on criteria they receive from a specific row in another relationship.
+*/
+public interface WHRelationshipBuilder
+{
+  /** Construct a relationship based on the specified row of the specified
+  * relationship.
+  */
+  public WHRelationship createRelationship(WHAccessor accessor)
+    throws WHException;
+  
+}
\ No newline at end of file

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRowID.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRowID.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRowID.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHRowID.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,32 @@
+/* $Id: WHRowID.java -1   $ */
+
+/**
+* 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.api;
+
+/** This interface describes a kind of key or value that is used to describe
+* a table row.  For simple tables, the implementation is likely to be just a 
+* LongValue, but for joins there is likely to be a compound value consisting of
+* individual WHRowID's from each table participating in the join.  The basic
+* idea is that the precise form of a row ID is only known to the relationship
+* from which it came (and in which it will be interpreted).
+*/
+public interface WHRowID
+{
+  // Right at the moment, there are no special methods needed
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHTable.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHTable.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHTable.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHTable.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,41 @@
+/* $Id: WHTable.java -1   $ */
+
+/**
+* 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.api;
+
+/** This abstraction permits access to a table structure.  An object of this kind can ONLY
+* be used within the context of the WHTableStore object that created it.  Note: This is a
+* permanent structure.
+*/
+public interface WHTable extends WHRelationship
+{
+  /** Insert a row */
+  public void insertRow(String[] columns, WHValue[] values)
+    throws WHException;
+  
+  /** Update row(s) */
+  public void updateRows(String[] columns, WHValue[] values,
+    WHAccessor accessor)
+    throws WHException;
+    
+  /** Delete row(s) */
+  public void deleteRows(WHAccessor accessor)
+    throws WHException;
+  
+}
\ No newline at end of file

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHTableStore.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHTableStore.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHTableStore.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHTableStore.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,65 @@
+/* $Id: WHTableStore.java -1   $ */
+
+/**
+* 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.api;
+
+/** This interface describes a table-based store built on top of a transactional
+* key-value store.  The basic representation is similar to SQL in that there are
+* tables and indexes; the difference is that the API used to manipulate and query
+* these constructs is not SQL based, but is rather a general Java API.
+*/
+public interface WHTableStore
+{
+  /** Begin a transaction */
+  public void beginTransaction()
+    throws WHException;
+  
+  /** Commit a transaction */
+  public void commitTransaction()
+    throws WHException;
+  
+  /** Abandon any transaction in progress */
+  public void abandonTransaction()
+    throws WHException;
+  
+  /** Lookup table */
+  public WHTable lookupTable(String name)
+    throws WHException;
+  
+  /** Create a table */
+  public WHTable createTable(String name, String[] columnNames)
+    throws WHException;
+  
+  /** Drop a table */
+  public void dropTable(String name)
+    throws WHException;
+  
+  /** Find an index */
+  public WHIndex lookupIndex(String name)
+    throws WHException;
+    
+  /** Create an index */
+  public WHIndex createIndex(String name, WHTable table, String[] columnNames, String[] comparatorClasses, boolean unique)
+    throws WHException;
+    
+  /** Drop an index */
+  public void dropIndex(String name)
+    throws WHException;
+    
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHUniqueConstraintViolationException.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHUniqueConstraintViolationException.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHUniqueConstraintViolationException.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHUniqueConstraintViolationException.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,36 @@
+/* $Id: WHUniqueConstraintViolationException.java -1   $ */
+
+/**
+* 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.api;
+
+/** This exception signals a constraint violation, which usually indicates deadlock.
+*/
+public class WHUniqueConstraintViolationException extends WHConcurrencyException
+{
+  public WHUniqueConstraintViolationException()
+  {
+    super();
+  }
+
+  public WHUniqueConstraintViolationException(String msg)
+  {
+    super(msg);
+  }
+  
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHValue.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHValue.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHValue.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/api/WHValue.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,30 @@
+/* $Id: WHValue.java -1   $ */
+
+/**
+* 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.api;
+
+/** This object represents a value in a transaction key/value store.
+* Pretty much anything can be a value, provided it can be serialized.
+* Reconstitution will consist of calling the constructor for the object class
+* with the object's serialized byte array as the sole argument.
+*/
+public interface WHValue
+{
+  // Nothing needed right now
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHAtomicByteKeyValueStore.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHAtomicByteKeyValueStore.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHAtomicByteKeyValueStore.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHAtomicByteKeyValueStore.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,51 @@
+/* $Id: WHAtomicByteKeyValueStore.java -1   $ */
+
+/**
+* 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.bytekeyvalue;
+
+import org.apache.warthog.api.*;
+import java.util.*;
+
+/** Describes the general functionality requirements of an underlying (distributed?)
+* byte-array-based key value store, which use conflict detection as its mechanism for handling transactional
+* integrity.
+*/
+public interface WHAtomicByteKeyValueStore
+{
+  /** Get a value */
+  public byte[] get(byte[] key)
+    throws WHException;
+  
+  /** Check a bunch of values atomically for consistency.
+  *@param checkValues is a map of keys/values that must be unchanged.  If any value is
+  * changed, a WHConcurrencyException is thrown.
+  */
+  public void check(WHByteKeyMap checkValues)
+    throws WHException;
+  
+  /** Set a bunch of values atomically.
+  *@param checkValues is a map of keys/values that must be unchanged in order for the
+  * commit to proceed.  If these values are detected to have been changed, a WHConcurrencyException
+  * will be thrown.  Null values are permitted.
+  *@param setValues is a map of keys to set to specified new values.  A null value implies removal of
+  * the key.
+  */
+  public void setAll(WHByteKeyMap checkValues, WHByteKeyMap setValues)
+    throws WHException;
+}

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHByteKeyIterator.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHByteKeyIterator.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHByteKeyIterator.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHByteKeyIterator.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,37 @@
+/* $Id: WHByteKeyIterator.java -1   $ */
+
+/**
+* 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.bytekeyvalue;
+
+import org.apache.warthog.api.*;
+
+/** This interface describes an iterator over a set of byte-based keys.  WHException
+* is possible on every iterator step.
+*/
+public interface WHByteKeyIterator
+{
+  /** Check if there is another value */
+  public boolean hasNext()
+    throws WHException;
+  
+  /** Get the next value */
+  public byte[] next()
+    throws WHException;
+}
+

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHByteKeyMap.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHByteKeyMap.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHByteKeyMap.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/bytekeyvalue/WHByteKeyMap.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,46 @@
+/* $Id: WHByteKeyMap.java -1   $ */
+
+/**
+* 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.bytekeyvalue;
+
+import org.apache.warthog.api.*;
+import java.util.*;
+
+/** This interface describes a set of byte-array-based key/value pairs that
+* is maintained locally.
+*/
+public interface WHByteKeyMap
+{
+  /** Get a value from the map.
+  */
+  public byte[] get(byte[] key)
+    throws WHException;
+  
+  /** Iterate over the keys in the map.
+  */
+  public WHByteKeyIterator iterator()
+    throws WHException;
+
+  /** Get the size of the map.
+  */
+  public long size()
+    throws WHException;
+
+}
+

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/BooleanValue.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/BooleanValue.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/BooleanValue.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/BooleanValue.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,87 @@
+/* $Id: BooleanValue.java 1207794 2011-11-29 08:57:22Z 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.common;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+
+/** Boolean value, serializable.
+*/
+public class BooleanValue implements WHValue,WHKeyValue
+{
+  boolean value;
+  
+  public BooleanValue(boolean value)
+  {
+    this.value = value;
+  }
+  
+  public BooleanValue(byte[] bytes)
+  {
+    value = readObject(new BufferPointer(bytes));
+  }
+  
+  public byte[] serializeObject()
+  {
+    byte[] rval = new byte[sizeObject()];
+    writeObject(new BufferPointer(rval),value);
+    return rval;
+  }
+  
+  public boolean getValue()
+  {
+    return value;
+  }
+
+  public boolean isEquals(WHKeyValue value)
+  {
+    return this.value == ((BooleanValue)value).value;
+  }
+
+  public int hashCode()
+  {
+    return value?101:97;
+  }
+  
+  public boolean equals(Object o)
+  {
+    if (this.getClass() != o.getClass())
+      return false;
+    return ((BooleanValue)o).value == value;
+  }
+
+  public static boolean readObject(BufferPointer bp)
+  {
+    return ((((int)bp.readValue()) & 0xff) == 0)?false:true;
+  }
+  
+  public static int sizeObject()
+  {
+    return 1;
+  }
+  
+  public static void writeObject(BufferPointer bp, boolean value)
+  {
+    bp.writeValue((byte)(value?1:0));
+  }
+  
+}
+
+

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/BufferPointer.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/BufferPointer.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/BufferPointer.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/BufferPointer.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,48 @@
+/* $Id: BufferPointer.java 1202068 2011-11-15 06:57:24Z 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.common;
+
+/** A byte buffer and offset, for serialization. */
+public class BufferPointer
+{
+  /** The buffer */
+  protected byte[] buffer;
+  /** The pointer */
+  protected int pointer = 0;
+  
+  /** Constructor */
+  public BufferPointer(byte[] buffer)
+  {
+    this.buffer = buffer;
+  }
+  
+  /** Get the value at the current pointer and advance */
+  public byte readValue()
+  {
+    return buffer[pointer++];
+  }
+  
+  /** Write a value to the current pointer and advance */
+  public void writeValue(byte value)
+  {
+    buffer[pointer++] = value;
+  }
+  
+}
\ No newline at end of file

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/CharacterArray.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/CharacterArray.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/CharacterArray.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/CharacterArray.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,128 @@
+/* $Id: CharacterArray.java 1207794 2011-11-29 08:57:22Z 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.common;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+
+/** Character array, serializable.
+*/
+public class CharacterArray implements WHValue,WHKeyValue
+{
+  char[] value;
+  
+  public CharacterArray(char[] value)
+  {
+    this.value = value;
+  }
+  
+  public CharacterArray()
+  {
+  }
+  
+  public CharacterArray(byte[] bytes)
+  {
+    value = readObject(new BufferPointer(bytes));
+  }
+  
+  public byte[] serializeObject()
+  {
+    byte[] rval = new byte[sizeObject(value.length)];
+    writeObject(new BufferPointer(rval),value);
+    return rval;
+  }
+  
+  public char[] getValue()
+  {
+    return value;
+  }
+
+  /** Check if equals (classes must already agree) */
+  public boolean isEquals(WHKeyValue value)
+  {
+    char[] otherValue = ((CharacterArray)value).value;
+    return compareObject(this.value,otherValue);
+  }
+
+  public int hashCode()
+  {
+    int rval = 0;
+    for (int i = 0 ; i < value.length ; i++)
+    {
+      rval += (((int)value[i]) << 5) ^ (((int)value[i]) >> 3);
+    }
+    return rval;
+  }
+  
+  public boolean equals(Object o)
+  {
+    if (this.getClass() != o.getClass())
+      return false;
+    CharacterArray sa = (CharacterArray)o;
+    if (sa.value.length != value.length)
+      return false;
+    for (int i = 0 ; i < value.length ; i++)
+    {
+      if (sa.value[i] != value[i])
+        return false;
+    }
+    return true;
+  }
+
+  public static char[] readObject(BufferPointer bp)
+  {
+    int size = IntegerValue.readObject(bp);
+    char[] rval = new char[size];
+    for (int i = 0 ; i < size ; i++)
+    {
+      rval[i] = CharacterValue.readObject(bp);
+    }
+    return rval;
+  }
+  
+  public static int sizeObject(int size)
+  {
+    return IntegerValue.sizeObject() + CharacterValue.sizeObject() * size;
+  }
+  
+  public static void writeObject(BufferPointer bp, char[] value)
+  {
+    IntegerValue.writeObject(bp,value.length);
+    for (int i = 0 ; i < value.length ; i++)
+    {
+      CharacterValue.writeObject(bp,value[i]);
+    }
+  }
+  
+  public static boolean compareObject(char[] value, char[] otherValue)
+  {
+    if (otherValue.length != value.length)
+      return false;
+    for (int i = 0 ; i < otherValue.length ; i++)
+    {
+      if (otherValue[i] != value[i])
+        return false;
+    }
+    return true;
+  }
+  
+}
+
+

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/CharacterValue.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/CharacterValue.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/CharacterValue.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/CharacterValue.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,90 @@
+/* $Id: CharacterValue.java 1207794 2011-11-29 08:57:22Z 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.common;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+
+/** Character value, serializable.
+*/
+public class CharacterValue implements WHValue,WHKeyValue
+{
+  char value;
+  
+  public CharacterValue(char value)
+  {
+    this.value = value;
+  }
+  
+  public CharacterValue(byte[] bytes)
+  {
+    value = readObject(new BufferPointer(bytes));
+  }
+  
+  public byte[] serializeObject()
+  {
+    byte[] rval = new byte[sizeObject()];
+    writeObject(new BufferPointer(rval),value);
+    return rval;
+  }
+  
+  /** Check if equals (classes must already agree) */
+  public boolean isEquals(WHKeyValue value)
+  {
+    return this.value == ((CharacterValue)value).value;
+  }
+
+  public char getValue()
+  {
+    return value;
+  }
+  
+  public int hashCode()
+  {
+    return (((int)value) << 5) ^ (((int)value) >> 3);
+  }
+  
+  public boolean equals(Object o)
+  {
+    if (this.getClass() != o.getClass())
+      return false;
+    return ((CharacterValue)o).value == value;
+  }
+
+  public static char readObject(BufferPointer bp)
+  {
+    int value = (((int)bp.readValue()) & 0xff);
+    value += ((((int)bp.readValue()) << 8) & 0xff00);
+    return (char)value;
+  }
+  
+  public static int sizeObject()
+  {
+    return 2;
+  }
+  
+  public static void writeObject(BufferPointer bp, char value)
+  {
+    bp.writeValue((byte)(((int)value) & 0xff));
+    bp.writeValue((byte)((((int)value) >> 8) & 0xff));
+  }
+}
+
+

Added: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/ColumnCount.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/ColumnCount.java?rev=1220349&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/ColumnCount.java (added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/common/ColumnCount.java Sun Dec 18 08:26:30 2011
@@ -0,0 +1,102 @@
+/* $Id: ColumnCount.java 1210225 2011-12-04 21:09:35Z 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.common;
+
+import org.apache.warthog.api.*;
+
+/** This class is used to count the rows found.
+*/
+public class ColumnCount implements WHColumnDescription
+{
+  protected String returnColumnName;
+  
+  /** Constructor */
+  public ColumnCount(String returnColumnName)
+  {
+    this.returnColumnName = returnColumnName;
+  }
+  
+  /** Get the name of the return column */
+  public String getReturnColumnName()
+    throws WHException
+  {
+    return returnColumnName;
+  }
+  
+  /** Create a return column calculator for this column.
+  */
+  public WHColumnCalculator createCalculator()
+    throws WHException
+  {
+    return new CountCalculator();
+  }
+  
+  protected static class CountCalculator implements WHColumnCalculator
+  {
+    protected long counter = 0L;
+    
+    public CountCalculator()
+    {
+    }
+
+    /** Check whether a row can be added to to the column calculator.
+    * Does NOT actually change the result of the calculator!
+    *@return true if the row can be added and false if a tally should be done immediately.
+    */
+    public boolean canProcessRowValue(WHAccessor accessor)
+      throws WHException
+    {
+      return true;
+    }
+
+    /** Check whether this calculator is capable of generating a final summary row value.
+    *@return true if it is capable.  tally() will only be called at the end for the summary
+    *     row if all columns are capable of generating a summary value.
+    */
+    public boolean canGenerateSummaryValue()
+      throws WHException
+    {
+      return true;
+    }
+
+    /** Feed a row to the column calculator.
+    */
+    public void processRowValue(WHAccessor accessor)
+      throws WHException
+    {
+      counter++;
+    }
+    
+    /** Tally a final result, obtaining whatever current aggregate value there is.
+    * Also resets the calculator in preparation for another set of rows.
+    */
+    public WHValue tally()
+      throws WHException
+    {
+      WHValue rval = new LongValue(counter);
+      counter = 0L;
+      return rval;
+    }
+
+  }
+    
+}
+  
+  
\ No newline at end of file



Mime
View raw message