incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1203555 - in /incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog: common/ interfaces/ tablestore/
Date Fri, 18 Nov 2011 09:47:58 GMT
Author: kwright
Date: Fri Nov 18 09:47:57 2011
New Revision: 1203555

URL: http://svn.apache.org/viewvc?rev=1203555&view=rev
Log:
Separate keys from values, and make hash code be a long.

Added:
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/IntegerKey.java
  (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongKey.java
  (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringKey.java
  (with props)
Modified:
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/BooleanValue.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CharacterValue.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/IntegerValue.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongValue.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringArray.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringValue.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHKey.java
    incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/BooleanValue.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/BooleanValue.java?rev=1203555&r1=1203554&r2=1203555&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/BooleanValue.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/BooleanValue.java
Fri Nov 18 09:47:57 2011
@@ -23,7 +23,7 @@ import org.apache.warthog.interfaces.*;
 
 /** Boolean value, serializable.
 */
-public class BooleanValue implements WHKey
+public class BooleanValue implements WHValue
 {
   boolean value;
   
@@ -32,10 +32,6 @@ public class BooleanValue implements WHK
     this.value = value;
   }
   
-  public BooleanValue()
-  {
-  }
-  
   public BooleanValue(byte[] bytes)
   {
     value = readObject(new BufferPointer(bytes));
@@ -52,19 +48,6 @@ public class BooleanValue implements WHK
   {
     return value;
   }
-  
-  public int hashCode()
-  {
-    return value?12351:31;
-  }
-  
-  public boolean equals(Object o)
-  {
-    if (!(o instanceof BooleanValue))
-      return false;
-    BooleanValue other = (BooleanValue)o;
-    return value == other.value;
-  }
 
   public static boolean readObject(BufferPointer bp)
   {
@@ -80,6 +63,7 @@ public class BooleanValue implements WHK
   {
     bp.writeValue((byte)(value?1:0));
   }
+  
 }
 
 

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CharacterValue.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CharacterValue.java?rev=1203555&r1=1203554&r2=1203555&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CharacterValue.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/CharacterValue.java
Fri Nov 18 09:47:57 2011
@@ -32,10 +32,6 @@ public class CharacterValue implements W
     this.value = value;
   }
   
-  public CharacterValue()
-  {
-  }
-  
   public CharacterValue(byte[] bytes)
   {
     value = readObject(new BufferPointer(bytes));

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/IntegerKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/IntegerKey.java?rev=1203555&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/IntegerKey.java
(added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/IntegerKey.java
Fri Nov 18 09:47:57 2011
@@ -0,0 +1,59 @@
+/* $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.common;
+
+import org.apache.warthog.interfaces.*;
+
+/** Integer key.
+*/
+public class IntegerKey extends IntegerValue implements WHKey
+{
+  public IntegerKey(int value)
+  {
+    super(value);
+  }
+  
+  public IntegerKey(byte[] bytes)
+  {
+    super(bytes);
+  }
+
+  /** Calculate the hash function. */
+  public long getHashCode()
+  {
+    return calculateHashCode(value);
+  }
+  
+  /** Check if equals (classes must already agree) */
+  public boolean isEquals(WHKey key)
+  {
+    IntegerKey x = (IntegerKey)key;
+    return x.value == value;
+  }
+
+  public static long calculateHashCode(int value)
+  {
+    long x = (long)value;
+    return (x << 5) ^ (x >> 3);
+  }
+  
+}
+
+

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

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

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/IntegerValue.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/IntegerValue.java?rev=1203555&r1=1203554&r2=1203555&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/IntegerValue.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/IntegerValue.java
Fri Nov 18 09:47:57 2011
@@ -23,7 +23,7 @@ import org.apache.warthog.interfaces.*;
 
 /** Integer value, serializable.
 */
-public class IntegerValue implements WHKey
+public class IntegerValue implements WHValue
 {
   int value;
   
@@ -32,10 +32,6 @@ public class IntegerValue implements WHK
     this.value = value;
   }
   
-  public IntegerValue()
-  {
-  }
-  
   public IntegerValue(byte[] bytes)
   {
     value = readObject(new BufferPointer(bytes));
@@ -53,19 +49,6 @@ public class IntegerValue implements WHK
     return value;
   }
   
-  public int hashCode()
-  {
-    return (value << 4) ^ (value >> 1);
-  }
-  
-  public boolean equals(Object o)
-  {
-    if (!(o instanceof IntegerValue))
-      return false;
-    IntegerValue other = (IntegerValue)o;
-    return value == other.value;
-  }
-
   public static int readObject(BufferPointer bp)
   {
     int value = (((int)bp.readValue()) & 0xff);

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongKey.java?rev=1203555&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongKey.java
(added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongKey.java
Fri Nov 18 09:47:57 2011
@@ -0,0 +1,58 @@
+/* $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.common;
+
+import org.apache.warthog.interfaces.*;
+
+/** Long key.
+*/
+public class LongKey extends LongValue implements WHKey
+{
+  public LongKey(long value)
+  {
+    super(value);
+  }
+  
+  public LongKey(byte[] bytes)
+  {
+    super(bytes);
+  }
+
+  /** Calculate the hash function. */
+  public long getHashCode()
+  {
+    return calculateHashCode(value);
+  }
+  
+  /** Check if equals (classes must already agree) */
+  public boolean isEquals(WHKey key)
+  {
+    LongKey k = (LongKey)key;
+    return k.value == value;
+  }
+  
+  public static long calculateHashCode(long value)
+  {
+    return (value << 5) ^ (value >> 3);
+  }
+  
+}
+
+

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

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

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongValue.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongValue.java?rev=1203555&r1=1203554&r2=1203555&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongValue.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/LongValue.java
Fri Nov 18 09:47:57 2011
@@ -23,7 +23,7 @@ import org.apache.warthog.interfaces.*;
 
 /** Long value, serializable.
 */
-public class LongValue implements WHKey
+public class LongValue implements WHValue
 {
   long value;
   
@@ -32,10 +32,6 @@ public class LongValue implements WHKey
     this.value = value;
   }
   
-  public LongValue()
-  {
-  }
-  
   public LongValue(byte[] bytes)
   {
     value = readObject(new BufferPointer(bytes));
@@ -53,20 +49,6 @@ public class LongValue implements WHKey
     return value;
   }
 
-  public int hashCode()
-  {
-    return new Long(value).hashCode();
-  }
-  
-  public boolean equals(Object o)
-  {
-    if (!(o instanceof LongValue))
-      return false;
-    LongValue other = (LongValue)o;
-    return value == other.value;
-  }
-
-
   public static long readObject(BufferPointer bp)
   {
     long value = (((long)bp.readValue()) & 0xffL);

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringArray.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringArray.java?rev=1203555&r1=1203554&r2=1203555&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringArray.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringArray.java
Fri Nov 18 09:47:57 2011
@@ -32,10 +32,6 @@ public class StringArray implements WHVa
     this.value = value;
   }
   
-  public StringArray()
-  {
-  }
-  
   public StringArray(byte[] bytes)
   {
     value = readObject(new BufferPointer(bytes));

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringKey.java?rev=1203555&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringKey.java
(added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringKey.java
Fri Nov 18 09:47:57 2011
@@ -0,0 +1,63 @@
+/* $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.common;
+
+import org.apache.warthog.interfaces.*;
+
+/** This object represents a string that can be used as a key in the key/value store.
+*/
+public class StringKey extends StringValue implements WHKey
+{
+  public StringKey(String value)
+  {
+    super(value);
+  }
+  
+  public StringKey(byte[] bytes)
+  {
+    super(bytes);
+  }
+
+  /** Calculate the hash function. */
+  public long getHashCode()
+  {
+    return calculateHashCode(value);
+  }
+  
+  /** Check if equals (classes must already agree) */
+  public boolean isEquals(WHKey key)
+  {
+    StringKey thisKey = (StringKey)key;
+    return thisKey.value.equals(value);
+  }
+  
+  public static long calculateHashCode(String value)
+  {
+    // Should be independent of JVM, which is why I do this myself
+    long rval = 0L;
+    for (int i = 0 ; i < value.length() ; i++)
+    {
+      long x = (long)value.charAt(i);
+      rval += (x << 5) ^ (x >> 3);
+    }
+    return rval;
+  }
+  
+}
\ No newline at end of file

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

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

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringValue.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringValue.java?rev=1203555&r1=1203554&r2=1203555&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringValue.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/common/StringValue.java
Fri Nov 18 09:47:57 2011
@@ -23,7 +23,7 @@ import org.apache.warthog.interfaces.*;
 
 /** This object represents a string that can be stored in the key/value store.
 */
-public class StringValue implements WHKey
+public class StringValue implements WHValue
 {
   protected String value;
   
@@ -32,11 +32,6 @@ public class StringValue implements WHKe
     this.value = value;
   }
   
-  public StringValue()
-  {
-    value = null;
-  }
-
   public StringValue(byte[] bytes)
   {
     value = readObject(new BufferPointer(bytes));
@@ -54,19 +49,6 @@ public class StringValue implements WHKe
     return rval;
   }
 
-  public int hashCode()
-  {
-    return value.hashCode();
-  }
-  
-  public boolean equals(Object o)
-  {
-    if (!(o instanceof StringValue))
-      return false;
-    StringValue other = (StringValue)o;
-    return value.equals(other.value);
-  }
-  
   public static String readObject(BufferPointer bp)
   {
     char[] array = CharacterArray.readObject(bp);

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHKey.java?rev=1203555&r1=1203554&r2=1203555&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHKey.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/interfaces/WHKey.java
Fri Nov 18 09:47:57 2011
@@ -26,6 +26,9 @@ package org.apache.warthog.interfaces;
 public interface WHKey extends WHValue
 {
   /** Calculate the hash function. */
-  public int hashCode();
+  public long getHashCode();
+  
+  /** Check if equals (classes must already agree) */
+  public boolean isEquals(WHKey key);
   
 }

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java?rev=1203555&r1=1203554&r2=1203555&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/main/java/org/apache/warthog/tablestore/TableStore.java
Fri Nov 18 09:47:57 2011
@@ -108,8 +108,8 @@ public class TableStore implements WHTab
     TableIndexKey tik = new TableIndexKey(name);
     TableIndexValue tiv = new TableIndexValue(new String[0]);
     currentTransaction.put(tik,tiv);
-    TableRowLimitKey tlk = new TableRowLimitKey(name);
-    currentTransaction.put(tlk,new TableRowLimitValue(0));
+    TableRowIDFactoryKey tlk = new TableRowIDFactoryKey(name);
+    currentTransaction.put(tlk,new IntegerValue(0));
     return t;
   }
   
@@ -164,8 +164,8 @@ public class TableStore implements WHTab
     tiv = new TableIndexValue(newIndexList);
     currentTransaction.put(tik,tiv);
     indexesPerTable.remove(t.getName());
-    IndexNodeLimitKey tlk = new IndexNodeLimitKey(name);
-    currentTransaction.put(tlk,new IndexNodeLimitValue(0));
+    IndexNodeIDFactoryKey tlk = new IndexNodeIDFactoryKey(name);
+    currentTransaction.put(tlk,new IntegerValue(0));
     return i;
   }
     
@@ -230,38 +230,26 @@ public class TableStore implements WHTab
   public int allocateNewTableRow(String tableName)
     throws WHException
   {
-    TableRowLimitKey tlk = new TableRowLimitKey(tableName);
-    TableRowLimitValue tlv = (TableRowLimitValue)currentTransaction.get(tlk);
+    TableRowIDFactoryKey tlk = new TableRowIDFactoryKey(tableName);
+    IntegerValue tlv = (IntegerValue)currentTransaction.get(tlk);
     if (tlv == null)
       throw new WHDeadlockException();
-    int rval = tlv.getRowCounter();
-    currentTransaction.put(tlk,new TableRowLimitValue(rval+1));
+    int rval = tlv.getValue();
+    currentTransaction.put(tlk,new IntegerValue(rval+1));
     return rval;
   }
   
-  /** Get the current max table row number, plus one.
-  */
-  public int getMaxTableRow(String tableName)
-    throws WHException
-  {
-    TableRowLimitKey tlk = new TableRowLimitKey(tableName);
-    TableRowLimitValue tlv = (TableRowLimitValue)currentTransaction.get(tlk);
-    if (tlv == null)
-      throw new WHDeadlockException();
-    return tlv.getRowCounter();
-  }
-  
   /** Allocate the next index node number.
   */
   public int allocateNextIndexNode(String indexName)
     throws WHException
   {
-    IndexNodeLimitKey tlk = new IndexNodeLimitKey(indexName);
-    IndexNodeLimitValue tlv = (IndexNodeLimitValue)currentTransaction.get(tlk);
+    IndexNodeIDFactoryKey tlk = new IndexNodeIDFactoryKey(indexName);
+    IntegerValue tlv = (IntegerValue)currentTransaction.get(tlk);
     if (tlv == null)
       throw new WHDeadlockException();
-    int rval = tlv.getNodeCounter();
-    currentTransaction.put(tlk,new IndexNodeLimitValue(rval+1));
+    int rval = tlv.getValue();
+    currentTransaction.put(tlk,new IntegerValue(rval+1));
     return rval;
   }
   
@@ -287,7 +275,7 @@ public class TableStore implements WHTab
     
     TableKey tk = new TableKey(t.getName());
     currentTransaction.put(tk,null);
-    TableRowLimitKey tlk = new TableRowLimitKey(t.getName());
+    TableRowIDFactoryKey tlk = new TableRowIDFactoryKey(t.getName());
     currentTransaction.put(tlk,null);
   }
   
@@ -319,7 +307,7 @@ public class TableStore implements WHTab
     indexesPerTable.remove(t.getName());
     IndexKey ik = new IndexKey(i.getName());
     currentTransaction.put(ik,null);
-    IndexNodeLimitKey tlk = new IndexNodeLimitKey(i.getName());
+    IndexNodeIDFactoryKey tlk = new IndexNodeIDFactoryKey(i.getName());
     currentTransaction.put(tlk,null);
   }
     
@@ -378,7 +366,9 @@ public class TableStore implements WHTab
     return indexes;
   }
   
-  protected static class TableKey extends StringValue
+  // Table definition key/value
+  
+  protected static class TableKey extends StringKey
   {
     /** Constructor */
     public TableKey(String name)
@@ -390,14 +380,6 @@ public class TableStore implements WHTab
     {
       super(data);
     }
-
-    public boolean equals(Object o)
-    {
-      if (!(o instanceof TableKey))
-        return false;
-      return super.equals(o);
-    }
-
   }
   
   protected static class TableValue extends StringArray
@@ -419,7 +401,9 @@ public class TableStore implements WHTab
     }
   }
   
-  protected static class TableIndexKey extends StringValue
+  // Table index list key/value
+  
+  protected static class TableIndexKey extends StringKey
   {
     /** Constructor */
     public TableIndexKey(String name)
@@ -431,14 +415,6 @@ public class TableStore implements WHTab
     {
       super(data);
     }
-    
-    public boolean equals(Object o)
-    {
-      if (!(o instanceof TableIndexKey))
-        return false;
-      return super.equals(o);
-    }
-
   }
   
   protected static class TableIndexValue extends StringArray
@@ -460,7 +436,9 @@ public class TableStore implements WHTab
     }
   }
   
-  protected static class IndexKey extends StringValue
+  // Index definition key/value
+  
+  protected static class IndexKey extends StringKey
   {
     /** Constructor */
     public IndexKey(String name)
@@ -472,13 +450,6 @@ public class TableStore implements WHTab
     {
       super(data);
     }
-    
-    public boolean equals(Object o)
-    {
-      if (!(o instanceof IndexKey))
-        return false;
-      return super.equals(o);
-    }
   }
   
   protected static class IndexValue implements WHValue
@@ -541,86 +512,127 @@ public class TableStore implements WHTab
     }
   }
   
-  protected static class TableRowLimitKey extends StringValue
+  // Table row ID factory key/value
+  
+  protected static class TableRowIDFactoryKey extends StringKey
   {
     /** Constructor */
-    public TableRowLimitKey(String name)
+    public TableRowIDFactoryKey(String name)
     {
       super(name);
     }
     
-    public TableRowLimitKey(byte[] data)
+    public TableRowIDFactoryKey(byte[] data)
     {
       super(data);
     }
 
-    public boolean equals(Object o)
-    {
-      if (!(o instanceof TableRowLimitKey))
-        return false;
-      return super.equals(o);
-    }
-
   }
 
-  protected static class TableRowLimitValue extends IntegerValue
+  // TableRowIDFactoryValue is just IntegerValue
+  
+  // Index node ID factory key/value
+  
+  protected static class IndexNodeIDFactoryKey extends StringKey
   {
     /** Constructor */
-    public TableRowLimitValue(int value)
+    public IndexNodeIDFactoryKey(String name)
     {
-      super(value);
+      super(name);
     }
     
-    public TableRowLimitValue(byte[] data)
+    public IndexNodeIDFactoryKey(byte[] data)
     {
       super(data);
     }
-    
-    public int getRowCounter()
-    {
-      return getValue();
-    }
+
   }
+
+  // IndexNodeIDFactoryValue is just IntegerValue
+
+  // Table head pointer key/value
   
-  protected static class IndexNodeLimitKey extends StringValue
+  protected static class TableHeadKey extends StringKey
   {
     /** Constructor */
-    public IndexNodeLimitKey(String name)
+    public TableHeadKey(String name)
     {
       super(name);
     }
     
-    public IndexNodeLimitKey(byte[] data)
+    public TableHeadKey(byte[] data)
     {
       super(data);
     }
+  }
+
+  // Table head value is just IntegerValue
 
-    public boolean equals(Object o)
+  // Table tail pointer key/value
+  
+  protected static class TableTailKey extends StringKey
+  {
+    /** Constructor */
+    public TableTailKey(String name)
+    {
+      super(name);
+    }
+    
+    public TableTailKey(byte[] data)
     {
-      if (!(o instanceof IndexNodeLimitKey))
-        return false;
-      return super.equals(o);
+      super(data);
     }
 
   }
 
-  protected static class IndexNodeLimitValue extends IntegerValue
+  // Table tail value is just IntegerValue
+  
+  // Table row prev pointer key/value
+  
+  protected static class TableRowPrevKey implements WHKey
   {
+    protected String tableName;
+    protected int rowNumber;
+    
     /** Constructor */
-    public IndexNodeLimitValue(int value)
+    public TableRowPrevKey(String tableName, int rowNumber)
     {
-      super(value);
+      this.tableName = tableName;
+      this.rowNumber = rowNumber;
     }
     
-    public IndexNodeLimitValue(byte[] data)
+    public TableRowPrevKey(byte[] data)
     {
-      super(data);
+      BufferPointer bp = new BufferPointer(data);
+      this.tableName = StringKey.readObject(bp);
+      this.rowNumber = IntegerKey.readObject(bp);
+    }
+
+    public byte[] serializeObject()
+    {
+      byte[] rval = new byte[StringKey.sizeObject(tableName)+
+        IntegerKey.sizeObject()];
+      BufferPointer bp = new BufferPointer(rval);
+      StringKey.writeObject(bp,tableName);
+      IntegerKey.writeObject(bp,rowNumber);
+      return rval;
     }
     
-    public int getNodeCounter()
+    public long getHashCode()
     {
-      return getValue();
+      return StringKey.calculateHashCode(tableName) + IntegerKey.calculateHashCode(rowNumber);
+    }
+    
+    public boolean isEquals(WHKey o)
+    {
+      TableRowPrevKey key = (TableRowPrevKey)o;
+      return key.tableName.equals(tableName) &&
+        key.rowNumber == rowNumber;
     }
+
   }
 
+  // Table row prev pointer value is just IntegerValue
+  
+  
 }



Mime
View raw message