incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1201816 - in /incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces: IndexCriteria.java WHComparator.java WHIndex.java WHIndexCriteria.java
Date Mon, 14 Nov 2011 18:12:08 GMT
Author: kwright
Date: Mon Nov 14 18:12:07 2011
New Revision: 1201816

URL: http://svn.apache.org/viewvc?rev=1201816&view=rev
Log:
More modification, to get index APIs sensible

Added:
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/IndexCriteria.java
      - copied, changed from r1201811, incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndexCriteria.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHComparator.java
Removed:
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndexCriteria.java
Modified:
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndex.java

Copied: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/IndexCriteria.java
(from r1201811, incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndexCriteria.java)
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/IndexCriteria.java?p2=incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/IndexCriteria.java&p1=incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndexCriteria.java&r1=1201811&r2=1201816&rev=1201816&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndexCriteria.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/IndexCriteria.java
Mon Nov 14 18:12:07 2011
@@ -19,25 +19,44 @@
 
 package org.apache.warthog.interfaces;
 
-/** This interface represents what is needed to scan an index and make decisions about
-* what subtrees to descend into, and which not to.  The implementation of this interface
-* determines the actual behavior.  An instance of this interface may be present for each
-* column present in the index.
+/** This class represents what is needed to scan an index and make decisions about
+* what subtrees to descend into, and which not to.  An instance of this interface will
+* be present for each column present in the index.  Override this class to provide
+* specific exclusions for specific index scans.
 */
-public interface WHIndexCriteria
+public class IndexCriteria
 {
-  // Return signals.  This constitutes 3 bits which determine how to proceed.
-  // Zero value for the bit indicates "skip", while a 1 value indicates "accept".
+  // Return signals.  This constitutes 3 bits which determine how to proceed in order
+  // to locate the next matching row in the index, at least as far as the current
+  // comparator and key are concerned.
+  
+  // Zero value for the bit indicates "skip", while a 1 value indicates "descend".
+  
   public static final int SIGNAL_LESSER = 1;
   public static final int SIGNAL_GREATER = 2;
   public static final int SIGNAL_EQUALS = 4;
   
-  /** Evaluate a given value (which may be null) against the criteria described
-  * by the implementer of this interface, and return the appropriate bit pattern.
-  * The comparator is provided.
+  /** Constructor */
+  public IndexCriteria()
+  {
+  }
+  
+  /** 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;
+    throws WHException
+  {
+    // The base case is that there is no limiting criteria, so that the criteria places no
restrictions
+    // on which way we are allowed to descend.
+    return SIGNAL_LESSER | SIGNAL_GREATER | SIGNAL_EQUALS;
+  }
+    
 }
   
   
\ No newline at end of file

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHComparator.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHComparator.java?rev=1201816&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHComparator.java
(added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHComparator.java
Mon Nov 14 18:12:07 2011
@@ -0,0 +1,39 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.warthog.interfaces;
+
+/** 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

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndex.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndex.java?rev=1201816&r1=1201815&r2=1201816&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndex.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHIndex.java
Mon Nov 14 18:12:07 2011
@@ -24,21 +24,37 @@ package org.apache.warthog.interfaces;
 */
 public interface WHIndex
 {
-  /** Get the table name the index applies to.
+  /** Get the table the index applies to.
   */
-  public String getTableName()
+  public WHTable getTable()
     throws WHException;
   
   /** Get the columns that are indexed
   */
   public String[] getColumnNames()
     throws WHException;
+
+  // 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.
+  */
+  public WHAccessor buildAccessor(IndexCriteria[] criteria);
+  
+  // Below this line are methods that are not meant to be used for general purposes,
+  // which may be moved to implementation classes.
   
-  /** Get the comparator class names corresponding to the columns.
+  /** Get the comparators corresponding to the columns.
   * Effectively also returns the index order for each of those columns
   * (as determined by the comparator).
   */
-  public String[] getComparatorClassNames()
+  public WHComparator[] getComparators()
     throws WHException;
   
   /** Add a new row to the index.
@@ -51,29 +67,4 @@ public interface WHIndex
   public void deleteRow(int rowNumber)
     throws WHException;
   
-  // Accessor support methods.
-  //
-  // 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.
-  //
-  // Furthermore, the btree is set up specifically to allow efficient pruning.  That
-  // means that each node has a greater/lesser link for index criteria, in order.  It
-  // is therefore the first column in the index which has the greatest ability to prune,
-  // while secondary, tertiary columns etc. have progressively less ability.
-  // Thus, it is very possible that a limited index scan with criteria may be expensive
-  // as a result of those criteria applying too low down in order of columns, thus
-  // requiring too many nodes to be processed.
-  //
-  // One can imagine index structures which would not have this flaw, but would gain
-  // performance at the expense of more complicated structures.  I've yet to come up
-  // with an algorithm, though, that has all the right characteristics.
-  
-  /** 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.
-  */
-  public WHAccessor buildAccessor(WHIndexCriteria[] criteria);
-  
 }



Mime
View raw message