You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2011/12/18 09:36:56 UTC
svn commit: r1220353 [8/11] - in
/incubator/lcf/branches/CONNECTORS-286/warthog-reimport: ./
src/main/java/org/apache/warthog/api/
src/main/java/org/apache/warthog/bytekeyvalue/
src/main/java/org/apache/warthog/common/ src/main/java/org/apache/warthog/...
Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableKey.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableKey.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableKey.java Sun Dec 18 08:36:52 2011
@@ -1,39 +1,39 @@
-/* $Id: TableKey.java 1207727 2011-11-29 01:12:13Z 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.keyvaluetablestore;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-import org.apache.warthog.common.*;
-
-/** Key class for accessing table definition data given a table identifier */
-public class TableKey extends LongKey
-{
- /** Constructor */
- public TableKey(long tableID)
- {
- super(tableID);
- }
-
- public TableKey(byte[] data)
- {
- super(data);
- }
-}
+/* $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.keyvaluetablestore;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+import org.apache.warthog.common.*;
+
+/** Key class for accessing table definition data given a table identifier */
+public class TableKey extends LongKey
+{
+ /** Constructor */
+ public TableKey(long tableID)
+ {
+ super(tableID);
+ }
+
+ public TableKey(byte[] data)
+ {
+ super(data);
+ }
+}
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableKey.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableLookupKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableLookupKey.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableLookupKey.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableLookupKey.java Sun Dec 18 08:36:52 2011
@@ -1,39 +1,39 @@
-/* $Id: TableLookupKey.java 1207727 2011-11-29 01:12:13Z 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.keyvaluetablestore;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-import org.apache.warthog.common.*;
-
-/** Key class for accessing table ID given table name */
-public class TableLookupKey extends StringKey
-{
- /** Constructor */
- public TableLookupKey(String name)
- {
- super(name);
- }
-
- public TableLookupKey(byte[] data)
- {
- super(data);
- }
-}
+/* $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.keyvaluetablestore;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+import org.apache.warthog.common.*;
+
+/** Key class for accessing table ID given table name */
+public class TableLookupKey extends StringKey
+{
+ /** Constructor */
+ public TableLookupKey(String name)
+ {
+ super(name);
+ }
+
+ public TableLookupKey(byte[] data)
+ {
+ super(data);
+ }
+}
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableLookupKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableLookupKey.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableNameKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableNameKey.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableNameKey.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableNameKey.java Sun Dec 18 08:36:52 2011
@@ -1,39 +1,39 @@
-/* $Id: TableNameKey.java 1207727 2011-11-29 01:12:13Z 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.keyvaluetablestore;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-import org.apache.warthog.common.*;
-
-/** Key class for accessing table name given ID */
-public class TableNameKey extends LongKey
-{
- /** Constructor */
- public TableNameKey(long tableID)
- {
- super(tableID);
- }
-
- public TableNameKey(byte[] data)
- {
- super(data);
- }
-}
+/* $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.keyvaluetablestore;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+import org.apache.warthog.common.*;
+
+/** Key class for accessing table name given ID */
+public class TableNameKey extends LongKey
+{
+ /** Constructor */
+ public TableNameKey(long tableID)
+ {
+ super(tableID);
+ }
+
+ public TableNameKey(byte[] data)
+ {
+ super(data);
+ }
+}
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableNameKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableNameKey.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowIDFactoryKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowIDFactoryKey.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowIDFactoryKey.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowIDFactoryKey.java Sun Dec 18 08:36:52 2011
@@ -1,40 +1,40 @@
-/* $Id: TableRowIDFactoryKey.java 1207727 2011-11-29 01:12:13Z 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.keyvaluetablestore;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-import org.apache.warthog.common.*;
-
-/** Key for accessing each table's row ID factory */
-public class TableRowIDFactoryKey extends LongKey
-{
- /** Constructor */
- public TableRowIDFactoryKey(long tableID)
- {
- super(tableID);
- }
-
- public TableRowIDFactoryKey(byte[] data)
- {
- super(data);
- }
-
-}
+/* $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.keyvaluetablestore;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+import org.apache.warthog.common.*;
+
+/** Key for accessing each table's row ID factory */
+public class TableRowIDFactoryKey extends LongKey
+{
+ /** Constructor */
+ public TableRowIDFactoryKey(long tableID)
+ {
+ super(tableID);
+ }
+
+ public TableRowIDFactoryKey(byte[] data)
+ {
+ super(data);
+ }
+
+}
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowIDFactoryKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowIDFactoryKey.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowKey.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowKey.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowKey.java Sun Dec 18 08:36:52 2011
@@ -1,92 +1,92 @@
-/* $Id: TableRowKey.java 1208149 2011-11-29 23:47:56Z 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.keyvaluetablestore;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-import org.apache.warthog.common.*;
-
-/** Base class for table row prev/next keys */
-public class TableRowKey implements WHKey
-{
- protected long tableID;
- protected long rowID;
-
- protected long hashCodeValue;
-
- /** Constructor */
- public TableRowKey(long tableID, long rowID)
- {
- this.tableID = tableID;
- this.rowID = rowID;
- //hashCodeValue = calculateHashCode(tableID,rowID);
- }
-
- public TableRowKey(byte[] data)
- {
- BufferPointer bp = new BufferPointer(data);
- this.tableID = LongKey.readObject(bp);
- this.rowID = LongKey.readObject(bp);
- //hashCodeValue = calculateHashCode(tableID,rowID);
- }
-
- public byte[] serializeObject()
- {
- byte[] rval = new byte[LongKey.sizeObject()+
- LongKey.sizeObject()];
- BufferPointer bp = new BufferPointer(rval);
- LongKey.writeObject(bp,tableID);
- LongKey.writeObject(bp,rowID);
- return rval;
- }
-
- public long getHashCode()
- {
- return hashCodeValue;
- }
-
- public static long calculateHashCode(long tableID, long rowID)
- {
- return LongKey.calculateHashCode(tableID) + LongKey.calculateHashCode(rowID);
- }
-
- public boolean isEquals(WHKeyValue o)
- {
- TableRowKey key = (TableRowKey)o;
- return key.tableID == tableID &&
- key.rowID == rowID;
- }
-
- public int hashCode()
- {
- return ((int)((tableID << 5) ^ (tableID >> 3))) +
- ((int)((rowID << 5) ^ (rowID >> 3)));
- }
-
- public boolean equals(Object o)
- {
- if (getClass() != o.getClass())
- return false;
- TableRowKey other = (TableRowKey)o;
- return other.tableID == tableID &&
- other.rowID == rowID;
- }
-
-}
+/* $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.keyvaluetablestore;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+import org.apache.warthog.common.*;
+
+/** Base class for table row prev/next keys */
+public class TableRowKey implements WHKey
+{
+ protected long tableID;
+ protected long rowID;
+
+ protected long hashCodeValue;
+
+ /** Constructor */
+ public TableRowKey(long tableID, long rowID)
+ {
+ this.tableID = tableID;
+ this.rowID = rowID;
+ //hashCodeValue = calculateHashCode(tableID,rowID);
+ }
+
+ public TableRowKey(byte[] data)
+ {
+ BufferPointer bp = new BufferPointer(data);
+ this.tableID = LongKey.readObject(bp);
+ this.rowID = LongKey.readObject(bp);
+ //hashCodeValue = calculateHashCode(tableID,rowID);
+ }
+
+ public byte[] serializeObject()
+ {
+ byte[] rval = new byte[LongKey.sizeObject()+
+ LongKey.sizeObject()];
+ BufferPointer bp = new BufferPointer(rval);
+ LongKey.writeObject(bp,tableID);
+ LongKey.writeObject(bp,rowID);
+ return rval;
+ }
+
+ public long getHashCode()
+ {
+ return hashCodeValue;
+ }
+
+ public static long calculateHashCode(long tableID, long rowID)
+ {
+ return LongKey.calculateHashCode(tableID) + LongKey.calculateHashCode(rowID);
+ }
+
+ public boolean isEquals(WHKeyValue o)
+ {
+ TableRowKey key = (TableRowKey)o;
+ return key.tableID == tableID &&
+ key.rowID == rowID;
+ }
+
+ public int hashCode()
+ {
+ return ((int)((tableID << 5) ^ (tableID >> 3))) +
+ ((int)((rowID << 5) ^ (rowID >> 3)));
+ }
+
+ public boolean equals(Object o)
+ {
+ if (getClass() != o.getClass())
+ return false;
+ TableRowKey other = (TableRowKey)o;
+ return other.tableID == tableID &&
+ other.rowID == rowID;
+ }
+
+}
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowKey.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowNextKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowNextKey.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowNextKey.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowNextKey.java Sun Dec 18 08:36:52 2011
@@ -1,39 +1,39 @@
-/* $Id: TableRowNextKey.java 1207727 2011-11-29 01:12:13Z 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.keyvaluetablestore;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-import org.apache.warthog.common.*;
-
-/** Table row next pointer key */
-public class TableRowNextKey extends TableRowKey
-{
- /** Constructor */
- public TableRowNextKey(long tableID, long rowID)
- {
- super(tableID,rowID);
- }
-
- public TableRowNextKey(byte[] data)
- {
- super(data);
- }
+/* $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.keyvaluetablestore;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+import org.apache.warthog.common.*;
+
+/** Table row next pointer key */
+public class TableRowNextKey extends TableRowKey
+{
+ /** Constructor */
+ public TableRowNextKey(long tableID, long rowID)
+ {
+ super(tableID,rowID);
+ }
+
+ public TableRowNextKey(byte[] data)
+ {
+ super(data);
+ }
}
\ No newline at end of file
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowNextKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowNextKey.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowPrevKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowPrevKey.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowPrevKey.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowPrevKey.java Sun Dec 18 08:36:52 2011
@@ -1,39 +1,39 @@
-/* $Id: TableRowPrevKey.java 1207727 2011-11-29 01:12:13Z 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.keyvaluetablestore;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-import org.apache.warthog.common.*;
-
-/** Table row previous pointer key */
-public class TableRowPrevKey extends TableRowKey
-{
- /** Constructor */
- public TableRowPrevKey(long tableID, long rowID)
- {
- super(tableID,rowID);
- }
-
- public TableRowPrevKey(byte[] data)
- {
- super(data);
- }
+/* $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.keyvaluetablestore;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+import org.apache.warthog.common.*;
+
+/** Table row previous pointer key */
+public class TableRowPrevKey extends TableRowKey
+{
+ /** Constructor */
+ public TableRowPrevKey(long tableID, long rowID)
+ {
+ super(tableID,rowID);
+ }
+
+ public TableRowPrevKey(byte[] data)
+ {
+ super(data);
+ }
}
\ No newline at end of file
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowPrevKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableRowPrevKey.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableStore.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableStore.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableStore.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableStore.java Sun Dec 18 08:36:52 2011
@@ -1,520 +1,520 @@
-/* $Id: TableStore.java 1209929 2011-12-03 15:06: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.keyvaluetablestore;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-import org.apache.warthog.common.*;
-import java.util.*;
-
-/** This is the standard implementation of WHTableStore.
-*/
-public class TableStore implements WHTableStore
-{
- /** The underlying transactional store */
- protected WHTransactionalStore transactionalStore;
-
- /** The current transaction, if any */
- protected WHTransaction currentTransaction = null;
-
- /** Map of tableID to table object, good for the current transaction */
- protected Map<LongValue,Table> tables = null;
- /** Map of tableID to index object, good for the current transaction */
- protected Map<LongValue,Index> indexes = null;
- /** Map of table ID to index set, good for the current transaction */
- protected Map<LongValue,Index[]> indexesPerTable = null;
-
- /** Random number generator for this table store instance */
- protected Random randomGenerator;
-
- /** Constructor */
- public TableStore(WHTransactionalStore transactionalStore)
- {
- this.transactionalStore = transactionalStore;
- randomGenerator = new Random();
- }
-
- /** Constructor */
- public TableStore(WHTransactionalStore transactionalStore, int seed)
- {
- this.transactionalStore = transactionalStore;
- randomGenerator = new Random(seed);
- }
-
- /** Begin a transaction */
- public void beginTransaction()
- throws WHException
- {
- if (currentTransaction != null)
- throw new WHException("Already in a transaction");
- currentTransaction = transactionalStore.createTransaction();
- tables = new HashMap<LongValue,Table>();
- indexes = new HashMap<LongValue,Index>();
- indexesPerTable = new HashMap<LongValue,Index[]>();
- }
-
- /** Commit a transaction */
- public void commitTransaction()
- throws WHException
- {
- if (currentTransaction == null)
- throw new WHException("Not in a transaction");
- currentTransaction.commit();
- currentTransaction = null;
- tables = null;
- indexes = null;
- indexesPerTable = null;
- }
-
- /** Abandon any transaction in progress */
- public void abandonTransaction()
- throws WHException
- {
- if (currentTransaction == null)
- return;
- // As a nicety, tell the transaction we're done.
- currentTransaction.abandon();
- currentTransaction = null;
- tables = null;
- indexes = null;
- indexesPerTable = null;
- }
-
- /** Lookup table */
- public WHTable lookupTable(String name)
- throws WHException
- {
- if (currentTransaction == null)
- throw new WHException("Must be in a transaction");
- return findTable(name);
- }
-
- /** Create a table */
- public WHTable createTable(String name, String[] columnNames)
- throws WHException
- {
- if (currentTransaction == null)
- throw new WHException("Must be in a transaction");
- if (currentTransaction.get(new TableLookupKey(name)) != null)
- throw new WHException("Table already exists");
- LongValue tableIDValue = allocateNewGeneralID();
- setTableName(tableIDValue,name);
- long[] columnIDs = new long[columnNames.length];
- for (int i = 0 ; i < columnIDs.length ; i++)
- {
- columnIDs[i] = (long)i;
- }
- currentTransaction.put(new TableKey(tableIDValue.getValue()),new TableValue(columnNames,columnIDs,(long)columnNames.length));
- Table t = new Table(this,tableIDValue,columnNames,columnIDs,(long)columnNames.length);
- tables.put(tableIDValue,t);
- currentTransaction.put(new TableIndexKey(tableIDValue.getValue()),new LongArray(new long[0]));
- currentTransaction.put(new TableRowIDFactoryKey(tableIDValue.getValue()),new LongValue(0L));
- return t;
- }
-
- /** Drop a table */
- public void dropTable(String name)
- throws WHException
- {
- if (currentTransaction == null)
- throw new WHException("Must be in a transaction");
- Table t = findTable(name);
- if (t == null)
- throw new WHException("Table does not exist");
- deleteTable(t);
- }
-
- /** Find an index */
- public WHIndex lookupIndex(String name)
- throws WHException
- {
- if (currentTransaction == null)
- throw new WHException("Must be in a transaction");
- return findIndex(name);
- }
-
-
- /** Create an index */
- public WHIndex createIndex(String name, WHTable table, String[] columnNames, String[] comparatorClasses, boolean unique)
- throws WHException
- {
- if (currentTransaction == null)
- throw new WHException("Must be in a transaction");
- Table t = (Table)table;
- if (currentTransaction.get(new IndexLookupKey(name)) != null)
- throw new WHException("Index already exists");
- LongValue indexID = allocateNewGeneralID();
- long[] columnIDs = new long[columnNames.length];
- for (int i = 0 ; i < columnIDs.length ; i++)
- {
- columnIDs[i] = t.getColumnID(columnNames[i]);
- }
- setIndexName(indexID,name);
- currentTransaction.put(new IndexKey(indexID.getValue()),new IndexValue(t.getIDValue(),columnIDs,comparatorClasses,unique));
- Index i = new Index(this,indexID,t,columnIDs,comparatorClasses,unique);
- indexes.put(indexID,i);
- TableIndexKey tik = new TableIndexKey(t.getIDValue());
- LongArray tiv = (LongArray)currentTransaction.get(tik);
- if (tiv == null)
- throw new WHConcurrencyException();
- long[] indexList = tiv.getValue();
- long[] newIndexList = new long[indexList.length + 1];
- for (int j = 0 ; j < indexList.length ; j++)
- {
- newIndexList[j] = indexList[j];
- }
- newIndexList[indexList.length] = indexID.getValue();
- currentTransaction.put(tik,new LongArray(newIndexList));
- indexesPerTable.remove(t.getID());
- i.initialize();
- return i;
- }
-
- /** Drop an index */
- public void dropIndex(String name)
- throws WHException
- {
- if (currentTransaction == null)
- throw new WHException("Must be in a transaction");
- Index i = findIndex(name);
- if (i == null)
- throw new WHException("Index does not exist");
- deleteIndex(i);
- }
-
- // Non-interface public methods
-
- protected Map<LongValue,LongValue> startMap = new HashMap<LongValue,LongValue>();
- protected Map<LongValue,LongValue> endMap = new HashMap<LongValue,LongValue>();
-
- /** Allocate a new row ID */
- public LongValue allocateNewTableRow(LongValue tableID)
- throws WHException
- {
- LongValue start = startMap.get(tableID);
- LongValue end = endMap.get(tableID);
-
- if (start != null && start.getValue() < end.getValue())
- {
- startMap.put(tableID,new LongValue(start.getValue()+1L));
- return start;
- }
-
- // We always do this in our own transaction to limit the deadlock potential,
- // and we retry until we get the ID. We only throw a concurrency exception
- // if it seems clear that the table is gone.
- TableRowIDFactoryKey tlk = new TableRowIDFactoryKey(tableID.getValue());
-
- while (true)
- {
- WHTransaction allocateTransaction = transactionalStore.createTransaction();
- try
- {
- LongValue tlv = (LongValue)allocateTransaction.get(tlk);
- if (tlv == null)
- break;
- LongValue newValue = new LongValue(tlv.getValue()+100L);
- allocateTransaction.put(tlk,newValue);
- allocateTransaction.commit();
- startMap.put(tableID,new LongValue(tlv.getValue()+1L));
- endMap.put(tableID,newValue);
- return tlv;
- }
- catch (WHConcurrencyException e)
- {
- Thread.yield();
- }
- finally
- {
- allocateTransaction.abandon();
- }
- }
- throw new WHConcurrencyException();
- }
-
- /** Allocate a new general ID */
- public LongValue allocateNewGeneralID()
- throws WHException
- {
- // We always do this in our own transaction to limit the deadlock potential,
- // and we retry until we get the ID.
- GeneralIDFactoryKey tlk = new GeneralIDFactoryKey();
-
- while (true)
- {
- WHTransaction allocateTransaction = transactionalStore.createTransaction();
- try
- {
- LongValue tlv = (LongValue)allocateTransaction.get(tlk);
- if (tlv == null)
- tlv = new LongValue(0L);
- allocateTransaction.put(tlk,new LongValue(tlv.getValue()+1L));
- allocateTransaction.commit();
- return tlv;
- }
- catch (WHConcurrencyException e)
- {
- Thread.yield();
- }
- finally
- {
- allocateTransaction.abandon();
- }
- }
- }
-
- /** Random boolean decision */
- protected boolean randomDecision()
- {
- return randomGenerator.nextBoolean();
- }
-
- /** Read a value from current transaction.
- */
- protected WHKeyValue get(WHKey key)
- throws WHException
- {
- return currentTransaction.get(key);
- }
-
- /** Write a value to current transaction.
- */
- protected void put(WHKey key, WHKeyValue value)
- throws WHException
- {
- currentTransaction.put(key,value);
- }
-
- /** Delete a table row from all the indexes that are based on a table.
- */
- protected void deleteIndexRow(LongValue tableID, LongValue rowID, Set<Long> columns)
- throws WHException
- {
- Index[] indexes = findIndexes(tableID);
- for (int i = 0 ; i < indexes.length ; i++)
- {
- if (indexAffectedBy(indexes[i],columns))
- indexes[i].deleteRow(rowID);
- }
- }
-
- /** Add a table row to all the indexes that are based on a table.
- */
- protected void addIndexRow(LongValue tableID, LongValue rowID, Set<Long> columns)
- throws WHException
- {
- Index[] indexes = findIndexes(tableID);
- for (int i = 0 ; i < indexes.length ; i++)
- {
- if (indexAffectedBy(indexes[i],columns))
- indexes[i].addNewRow(rowID);
- }
- }
-
- protected boolean indexAffectedBy(Index index, Set<Long> columns)
- throws WHException
- {
- if (columns == null)
- return true;
- long[] indexColumnIDs = index.getIndexColumnIDs();
- for (int i = 0 ; i < indexColumnIDs.length ; i++)
- {
- if (columns.contains(new Long(indexColumnIDs[i])))
- return true;
- }
- return false;
- }
-
- /** Delete a table definition.
- * Also deletes associated indexes.
- */
- protected void deleteTable(Table t)
- throws WHException
- {
- // First, remove indexes associated with this table
- Index[] indexes = findIndexes(t.getID());
- for (int i = 0 ; i < indexes.length ; i++)
- {
- deleteIndex(indexes[i]);
- }
-
- // Now that the indexes are gone, delete all the table rows
- t.remove();
-
- // Delete the keys that belong to the table, and clean up cached values
- tables.remove(t.getID());
- indexesPerTable.remove(t.getID());
- currentTransaction.put(new TableIndexKey(t.getIDValue()),null);
- currentTransaction.put(new TableRowIDFactoryKey(t.getIDValue()),null);
- removeTableName(t.getID());
- }
-
- /** Delete an index definition.
- */
- protected void deleteIndex(Index i)
- throws WHException
- {
- // First, remove this index from the indexes stored for each table
- Table t = (Table)i.getTable();
- Index[] indexList = findIndexes(t.getID());
- if (indexList.length == 0)
- throw new WHConcurrencyException();
- long[] newIndexList = new long[indexList.length - 1];
- int k = 0;
- for (int j = 0 ; j < indexList.length ; j++)
- {
- if (indexList[j].getIDValue() != i.getIDValue())
- {
- newIndexList[k++] = indexList[j].getIDValue();
- if (k == newIndexList.length)
- break;
- }
- }
- if (k != newIndexList.length)
- throw new WHConcurrencyException();
- currentTransaction.put(new TableIndexKey(t.getIDValue()),new LongArray(newIndexList));
- indexesPerTable.remove(t.getID());
-
- i.remove();
-
- // Clean out the index definition and other associated keys, and blow away cached copies
- indexes.remove(i.getID());
- removeIndexName(i.getID());
- }
-
- /** Find a table definition given its name.
- */
- protected Table findTable(String name)
- throws WHException
- {
- LongValue tid = (LongValue)currentTransaction.get(new TableLookupKey(name));
- if (tid == null)
- return null;
- return findTable(tid);
- }
-
- protected Table findTable(LongValue tid)
- throws WHException
- {
- Table t = tables.get(tid);
- if (t != null)
- return t;
- TableValue tv = (TableValue)currentTransaction.get(new TableKey(tid.getValue()));
- if (tv == null)
- throw new WHConcurrencyException();
- t = new Table(this,tid,tv.getColumnNames(),tv.getColumnIdentifiers(),tv.getNextColumnIdentifier());
- tables.put(tid,t);
- return t;
- }
-
- /** Find an index definition given its name.
- */
- protected Index findIndex(String name)
- throws WHException
- {
- LongValue indexID = (LongValue)currentTransaction.get(new IndexLookupKey(name));
- if (indexID == null)
- return null;
- return findIndex(indexID);
- }
-
- protected Index findIndex(LongValue indexID)
- throws WHException
- {
- Index i = indexes.get(indexID);
- if (i != null)
- return i;
- IndexValue indexValue = (IndexValue)currentTransaction.get(new IndexKey(indexID.getValue()));
- if (indexValue == null)
- throw new WHConcurrencyException();
- Table t = findTable(new LongValue(indexValue.getTableID()));
- if (t == null)
- throw new WHConcurrencyException();
- i = new Index(this,indexID,t,indexValue.getColumnIDs(),indexValue.getComparatorClassNames(),
- indexValue.getUnique());
- indexes.put(indexID,i);
- return i;
- }
-
- /** Find a set of associated index definitions given a table name.
- */
- protected Index[] findIndexes(LongValue tableID)
- throws WHException
- {
- Index[] indexes = indexesPerTable.get(tableID);
- if (indexes == null)
- {
- LongArray tiv = (LongArray)currentTransaction.get(new TableIndexKey(tableID.getValue()));
- if (tiv == null)
- throw new WHConcurrencyException();
- long[] indexIDs = tiv.getValue();
- indexes = new Index[indexIDs.length];
- for (int i = 0; i < indexes.length ; i++)
- {
- indexes[i] = findIndex(new LongValue(indexIDs[i]));
- if (indexes[i] == null)
- throw new WHConcurrencyException();
- }
- indexesPerTable.put(tableID,indexes);
- }
- return indexes;
- }
-
- /** Set a reference from table name to id and visa versa. Presumes nothing has been set yet for this table ID. */
- protected void setTableName(LongValue tableID, String tableName)
- throws WHException
- {
- currentTransaction.put(new TableNameKey(tableID.getValue()),new StringValue(tableName));
- currentTransaction.put(new TableLookupKey(tableName),tableID);
- }
-
- /** Remove a table name reference. Presumed to exist. */
- protected void removeTableName(LongValue tableID)
- throws WHException
- {
- TableNameKey tnk = new TableNameKey(tableID.getValue());
- StringValue value = (StringValue)currentTransaction.get(tnk);
- if (value == null)
- throw new WHConcurrencyException();
- currentTransaction.put(tnk,null);
- currentTransaction.put(new TableLookupKey(value.getValue()),null);
- }
-
- /** Set a reference from index name to id and visa versa. Presumes nothing has been set yet for this index ID. */
- protected void setIndexName(LongValue indexID, String indexName)
- throws WHException
- {
- currentTransaction.put(new IndexNameKey(indexID.getValue()),new StringValue(indexName));
- currentTransaction.put(new IndexLookupKey(indexName),indexID);
- }
-
- /** Remove an index name reference. Presumed to exist. */
- protected void removeIndexName(LongValue indexID)
- throws WHException
- {
- IndexNameKey tnk = new IndexNameKey(indexID.getValue());
- StringValue value = (StringValue)currentTransaction.get(tnk);
- if (value == null)
- throw new WHConcurrencyException();
- currentTransaction.put(tnk,null);
- currentTransaction.put(new IndexLookupKey(value.getValue()),null);
- }
-
-}
+/* $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.keyvaluetablestore;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+import org.apache.warthog.common.*;
+import java.util.*;
+
+/** This is the standard implementation of WHTableStore.
+*/
+public class TableStore implements WHTableStore
+{
+ /** The underlying transactional store */
+ protected WHTransactionalStore transactionalStore;
+
+ /** The current transaction, if any */
+ protected WHTransaction currentTransaction = null;
+
+ /** Map of tableID to table object, good for the current transaction */
+ protected Map<LongValue,Table> tables = null;
+ /** Map of tableID to index object, good for the current transaction */
+ protected Map<LongValue,Index> indexes = null;
+ /** Map of table ID to index set, good for the current transaction */
+ protected Map<LongValue,Index[]> indexesPerTable = null;
+
+ /** Random number generator for this table store instance */
+ protected Random randomGenerator;
+
+ /** Constructor */
+ public TableStore(WHTransactionalStore transactionalStore)
+ {
+ this.transactionalStore = transactionalStore;
+ randomGenerator = new Random();
+ }
+
+ /** Constructor */
+ public TableStore(WHTransactionalStore transactionalStore, int seed)
+ {
+ this.transactionalStore = transactionalStore;
+ randomGenerator = new Random(seed);
+ }
+
+ /** Begin a transaction */
+ public void beginTransaction()
+ throws WHException
+ {
+ if (currentTransaction != null)
+ throw new WHException("Already in a transaction");
+ currentTransaction = transactionalStore.createTransaction();
+ tables = new HashMap<LongValue,Table>();
+ indexes = new HashMap<LongValue,Index>();
+ indexesPerTable = new HashMap<LongValue,Index[]>();
+ }
+
+ /** Commit a transaction */
+ public void commitTransaction()
+ throws WHException
+ {
+ if (currentTransaction == null)
+ throw new WHException("Not in a transaction");
+ currentTransaction.commit();
+ currentTransaction = null;
+ tables = null;
+ indexes = null;
+ indexesPerTable = null;
+ }
+
+ /** Abandon any transaction in progress */
+ public void abandonTransaction()
+ throws WHException
+ {
+ if (currentTransaction == null)
+ return;
+ // As a nicety, tell the transaction we're done.
+ currentTransaction.abandon();
+ currentTransaction = null;
+ tables = null;
+ indexes = null;
+ indexesPerTable = null;
+ }
+
+ /** Lookup table */
+ public WHTable lookupTable(String name)
+ throws WHException
+ {
+ if (currentTransaction == null)
+ throw new WHException("Must be in a transaction");
+ return findTable(name);
+ }
+
+ /** Create a table */
+ public WHTable createTable(String name, String[] columnNames)
+ throws WHException
+ {
+ if (currentTransaction == null)
+ throw new WHException("Must be in a transaction");
+ if (currentTransaction.get(new TableLookupKey(name)) != null)
+ throw new WHException("Table already exists");
+ LongValue tableIDValue = allocateNewGeneralID();
+ setTableName(tableIDValue,name);
+ long[] columnIDs = new long[columnNames.length];
+ for (int i = 0 ; i < columnIDs.length ; i++)
+ {
+ columnIDs[i] = (long)i;
+ }
+ currentTransaction.put(new TableKey(tableIDValue.getValue()),new TableValue(columnNames,columnIDs,(long)columnNames.length));
+ Table t = new Table(this,tableIDValue,columnNames,columnIDs,(long)columnNames.length);
+ tables.put(tableIDValue,t);
+ currentTransaction.put(new TableIndexKey(tableIDValue.getValue()),new LongArray(new long[0]));
+ currentTransaction.put(new TableRowIDFactoryKey(tableIDValue.getValue()),new LongValue(0L));
+ return t;
+ }
+
+ /** Drop a table */
+ public void dropTable(String name)
+ throws WHException
+ {
+ if (currentTransaction == null)
+ throw new WHException("Must be in a transaction");
+ Table t = findTable(name);
+ if (t == null)
+ throw new WHException("Table does not exist");
+ deleteTable(t);
+ }
+
+ /** Find an index */
+ public WHIndex lookupIndex(String name)
+ throws WHException
+ {
+ if (currentTransaction == null)
+ throw new WHException("Must be in a transaction");
+ return findIndex(name);
+ }
+
+
+ /** Create an index */
+ public WHIndex createIndex(String name, WHTable table, String[] columnNames, String[] comparatorClasses, boolean unique)
+ throws WHException
+ {
+ if (currentTransaction == null)
+ throw new WHException("Must be in a transaction");
+ Table t = (Table)table;
+ if (currentTransaction.get(new IndexLookupKey(name)) != null)
+ throw new WHException("Index already exists");
+ LongValue indexID = allocateNewGeneralID();
+ long[] columnIDs = new long[columnNames.length];
+ for (int i = 0 ; i < columnIDs.length ; i++)
+ {
+ columnIDs[i] = t.getColumnID(columnNames[i]);
+ }
+ setIndexName(indexID,name);
+ currentTransaction.put(new IndexKey(indexID.getValue()),new IndexValue(t.getIDValue(),columnIDs,comparatorClasses,unique));
+ Index i = new Index(this,indexID,t,columnIDs,comparatorClasses,unique);
+ indexes.put(indexID,i);
+ TableIndexKey tik = new TableIndexKey(t.getIDValue());
+ LongArray tiv = (LongArray)currentTransaction.get(tik);
+ if (tiv == null)
+ throw new WHConcurrencyException();
+ long[] indexList = tiv.getValue();
+ long[] newIndexList = new long[indexList.length + 1];
+ for (int j = 0 ; j < indexList.length ; j++)
+ {
+ newIndexList[j] = indexList[j];
+ }
+ newIndexList[indexList.length] = indexID.getValue();
+ currentTransaction.put(tik,new LongArray(newIndexList));
+ indexesPerTable.remove(t.getID());
+ i.initialize();
+ return i;
+ }
+
+ /** Drop an index */
+ public void dropIndex(String name)
+ throws WHException
+ {
+ if (currentTransaction == null)
+ throw new WHException("Must be in a transaction");
+ Index i = findIndex(name);
+ if (i == null)
+ throw new WHException("Index does not exist");
+ deleteIndex(i);
+ }
+
+ // Non-interface public methods
+
+ protected Map<LongValue,LongValue> startMap = new HashMap<LongValue,LongValue>();
+ protected Map<LongValue,LongValue> endMap = new HashMap<LongValue,LongValue>();
+
+ /** Allocate a new row ID */
+ public LongValue allocateNewTableRow(LongValue tableID)
+ throws WHException
+ {
+ LongValue start = startMap.get(tableID);
+ LongValue end = endMap.get(tableID);
+
+ if (start != null && start.getValue() < end.getValue())
+ {
+ startMap.put(tableID,new LongValue(start.getValue()+1L));
+ return start;
+ }
+
+ // We always do this in our own transaction to limit the deadlock potential,
+ // and we retry until we get the ID. We only throw a concurrency exception
+ // if it seems clear that the table is gone.
+ TableRowIDFactoryKey tlk = new TableRowIDFactoryKey(tableID.getValue());
+
+ while (true)
+ {
+ WHTransaction allocateTransaction = transactionalStore.createTransaction();
+ try
+ {
+ LongValue tlv = (LongValue)allocateTransaction.get(tlk);
+ if (tlv == null)
+ break;
+ LongValue newValue = new LongValue(tlv.getValue()+100L);
+ allocateTransaction.put(tlk,newValue);
+ allocateTransaction.commit();
+ startMap.put(tableID,new LongValue(tlv.getValue()+1L));
+ endMap.put(tableID,newValue);
+ return tlv;
+ }
+ catch (WHConcurrencyException e)
+ {
+ Thread.yield();
+ }
+ finally
+ {
+ allocateTransaction.abandon();
+ }
+ }
+ throw new WHConcurrencyException();
+ }
+
+ /** Allocate a new general ID */
+ public LongValue allocateNewGeneralID()
+ throws WHException
+ {
+ // We always do this in our own transaction to limit the deadlock potential,
+ // and we retry until we get the ID.
+ GeneralIDFactoryKey tlk = new GeneralIDFactoryKey();
+
+ while (true)
+ {
+ WHTransaction allocateTransaction = transactionalStore.createTransaction();
+ try
+ {
+ LongValue tlv = (LongValue)allocateTransaction.get(tlk);
+ if (tlv == null)
+ tlv = new LongValue(0L);
+ allocateTransaction.put(tlk,new LongValue(tlv.getValue()+1L));
+ allocateTransaction.commit();
+ return tlv;
+ }
+ catch (WHConcurrencyException e)
+ {
+ Thread.yield();
+ }
+ finally
+ {
+ allocateTransaction.abandon();
+ }
+ }
+ }
+
+ /** Random boolean decision */
+ protected boolean randomDecision()
+ {
+ return randomGenerator.nextBoolean();
+ }
+
+ /** Read a value from current transaction.
+ */
+ protected WHKeyValue get(WHKey key)
+ throws WHException
+ {
+ return currentTransaction.get(key);
+ }
+
+ /** Write a value to current transaction.
+ */
+ protected void put(WHKey key, WHKeyValue value)
+ throws WHException
+ {
+ currentTransaction.put(key,value);
+ }
+
+ /** Delete a table row from all the indexes that are based on a table.
+ */
+ protected void deleteIndexRow(LongValue tableID, LongValue rowID, Set<Long> columns)
+ throws WHException
+ {
+ Index[] indexes = findIndexes(tableID);
+ for (int i = 0 ; i < indexes.length ; i++)
+ {
+ if (indexAffectedBy(indexes[i],columns))
+ indexes[i].deleteRow(rowID);
+ }
+ }
+
+ /** Add a table row to all the indexes that are based on a table.
+ */
+ protected void addIndexRow(LongValue tableID, LongValue rowID, Set<Long> columns)
+ throws WHException
+ {
+ Index[] indexes = findIndexes(tableID);
+ for (int i = 0 ; i < indexes.length ; i++)
+ {
+ if (indexAffectedBy(indexes[i],columns))
+ indexes[i].addNewRow(rowID);
+ }
+ }
+
+ protected boolean indexAffectedBy(Index index, Set<Long> columns)
+ throws WHException
+ {
+ if (columns == null)
+ return true;
+ long[] indexColumnIDs = index.getIndexColumnIDs();
+ for (int i = 0 ; i < indexColumnIDs.length ; i++)
+ {
+ if (columns.contains(new Long(indexColumnIDs[i])))
+ return true;
+ }
+ return false;
+ }
+
+ /** Delete a table definition.
+ * Also deletes associated indexes.
+ */
+ protected void deleteTable(Table t)
+ throws WHException
+ {
+ // First, remove indexes associated with this table
+ Index[] indexes = findIndexes(t.getID());
+ for (int i = 0 ; i < indexes.length ; i++)
+ {
+ deleteIndex(indexes[i]);
+ }
+
+ // Now that the indexes are gone, delete all the table rows
+ t.remove();
+
+ // Delete the keys that belong to the table, and clean up cached values
+ tables.remove(t.getID());
+ indexesPerTable.remove(t.getID());
+ currentTransaction.put(new TableIndexKey(t.getIDValue()),null);
+ currentTransaction.put(new TableRowIDFactoryKey(t.getIDValue()),null);
+ removeTableName(t.getID());
+ }
+
+ /** Delete an index definition.
+ */
+ protected void deleteIndex(Index i)
+ throws WHException
+ {
+ // First, remove this index from the indexes stored for each table
+ Table t = (Table)i.getTable();
+ Index[] indexList = findIndexes(t.getID());
+ if (indexList.length == 0)
+ throw new WHConcurrencyException();
+ long[] newIndexList = new long[indexList.length - 1];
+ int k = 0;
+ for (int j = 0 ; j < indexList.length ; j++)
+ {
+ if (indexList[j].getIDValue() != i.getIDValue())
+ {
+ newIndexList[k++] = indexList[j].getIDValue();
+ if (k == newIndexList.length)
+ break;
+ }
+ }
+ if (k != newIndexList.length)
+ throw new WHConcurrencyException();
+ currentTransaction.put(new TableIndexKey(t.getIDValue()),new LongArray(newIndexList));
+ indexesPerTable.remove(t.getID());
+
+ i.remove();
+
+ // Clean out the index definition and other associated keys, and blow away cached copies
+ indexes.remove(i.getID());
+ removeIndexName(i.getID());
+ }
+
+ /** Find a table definition given its name.
+ */
+ protected Table findTable(String name)
+ throws WHException
+ {
+ LongValue tid = (LongValue)currentTransaction.get(new TableLookupKey(name));
+ if (tid == null)
+ return null;
+ return findTable(tid);
+ }
+
+ protected Table findTable(LongValue tid)
+ throws WHException
+ {
+ Table t = tables.get(tid);
+ if (t != null)
+ return t;
+ TableValue tv = (TableValue)currentTransaction.get(new TableKey(tid.getValue()));
+ if (tv == null)
+ throw new WHConcurrencyException();
+ t = new Table(this,tid,tv.getColumnNames(),tv.getColumnIdentifiers(),tv.getNextColumnIdentifier());
+ tables.put(tid,t);
+ return t;
+ }
+
+ /** Find an index definition given its name.
+ */
+ protected Index findIndex(String name)
+ throws WHException
+ {
+ LongValue indexID = (LongValue)currentTransaction.get(new IndexLookupKey(name));
+ if (indexID == null)
+ return null;
+ return findIndex(indexID);
+ }
+
+ protected Index findIndex(LongValue indexID)
+ throws WHException
+ {
+ Index i = indexes.get(indexID);
+ if (i != null)
+ return i;
+ IndexValue indexValue = (IndexValue)currentTransaction.get(new IndexKey(indexID.getValue()));
+ if (indexValue == null)
+ throw new WHConcurrencyException();
+ Table t = findTable(new LongValue(indexValue.getTableID()));
+ if (t == null)
+ throw new WHConcurrencyException();
+ i = new Index(this,indexID,t,indexValue.getColumnIDs(),indexValue.getComparatorClassNames(),
+ indexValue.getUnique());
+ indexes.put(indexID,i);
+ return i;
+ }
+
+ /** Find a set of associated index definitions given a table name.
+ */
+ protected Index[] findIndexes(LongValue tableID)
+ throws WHException
+ {
+ Index[] indexes = indexesPerTable.get(tableID);
+ if (indexes == null)
+ {
+ LongArray tiv = (LongArray)currentTransaction.get(new TableIndexKey(tableID.getValue()));
+ if (tiv == null)
+ throw new WHConcurrencyException();
+ long[] indexIDs = tiv.getValue();
+ indexes = new Index[indexIDs.length];
+ for (int i = 0; i < indexes.length ; i++)
+ {
+ indexes[i] = findIndex(new LongValue(indexIDs[i]));
+ if (indexes[i] == null)
+ throw new WHConcurrencyException();
+ }
+ indexesPerTable.put(tableID,indexes);
+ }
+ return indexes;
+ }
+
+ /** Set a reference from table name to id and visa versa. Presumes nothing has been set yet for this table ID. */
+ protected void setTableName(LongValue tableID, String tableName)
+ throws WHException
+ {
+ currentTransaction.put(new TableNameKey(tableID.getValue()),new StringValue(tableName));
+ currentTransaction.put(new TableLookupKey(tableName),tableID);
+ }
+
+ /** Remove a table name reference. Presumed to exist. */
+ protected void removeTableName(LongValue tableID)
+ throws WHException
+ {
+ TableNameKey tnk = new TableNameKey(tableID.getValue());
+ StringValue value = (StringValue)currentTransaction.get(tnk);
+ if (value == null)
+ throw new WHConcurrencyException();
+ currentTransaction.put(tnk,null);
+ currentTransaction.put(new TableLookupKey(value.getValue()),null);
+ }
+
+ /** Set a reference from index name to id and visa versa. Presumes nothing has been set yet for this index ID. */
+ protected void setIndexName(LongValue indexID, String indexName)
+ throws WHException
+ {
+ currentTransaction.put(new IndexNameKey(indexID.getValue()),new StringValue(indexName));
+ currentTransaction.put(new IndexLookupKey(indexName),indexID);
+ }
+
+ /** Remove an index name reference. Presumed to exist. */
+ protected void removeIndexName(LongValue indexID)
+ throws WHException
+ {
+ IndexNameKey tnk = new IndexNameKey(indexID.getValue());
+ StringValue value = (StringValue)currentTransaction.get(tnk);
+ if (value == null)
+ throw new WHConcurrencyException();
+ currentTransaction.put(tnk,null);
+ currentTransaction.put(new IndexLookupKey(value.getValue()),null);
+ }
+
+}
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableStore.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableStore.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableTailKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableTailKey.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableTailKey.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableTailKey.java Sun Dec 18 08:36:52 2011
@@ -1,40 +1,40 @@
-/* $Id: TableTailKey.java 1208927 2011-12-01 01:18:07Z 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.keyvaluetablestore;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-import org.apache.warthog.common.*;
-
-public class TableTailKey extends TableBaseKey
-{
- /** Constructor */
- public TableTailKey(long tableID, int instanceNumber)
- {
- super(tableID,instanceNumber);
- }
-
- public TableTailKey(byte[] data)
- {
- super(data);
- }
-
-}
-
+/* $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.keyvaluetablestore;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+import org.apache.warthog.common.*;
+
+public class TableTailKey extends TableBaseKey
+{
+ /** Constructor */
+ public TableTailKey(long tableID, int instanceNumber)
+ {
+ super(tableID,instanceNumber);
+ }
+
+ public TableTailKey(byte[] data)
+ {
+ super(data);
+ }
+
+}
+
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableTailKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableTailKey.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableValue.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableValue.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableValue.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableValue.java Sun Dec 18 08:36:52 2011
@@ -1,104 +1,104 @@
-/* $Id: TableValue.java 1209929 2011-12-03 15:06: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.keyvaluetablestore;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-import org.apache.warthog.common.*;
-
-/** An index definition value */
-public class TableValue implements WHKeyValue
-{
- protected String[] columnNames;
- protected long[] columnIdentifiers;
- protected long nextColumnIdentifier;
-
- /** Constructor */
- public TableValue(String[] columnNames, long[] columnIdentifiers, long nextColumnIdentifier)
- {
- this.columnNames = columnNames;
- this.columnIdentifiers = columnIdentifiers;
- this.nextColumnIdentifier = nextColumnIdentifier;
- }
-
- public TableValue(byte[] data)
- {
- BufferPointer bp = new BufferPointer(data);
- columnNames = StringArray.readObject(bp);
- columnIdentifiers = LongArray.readObject(bp);
- nextColumnIdentifier = LongValue.readObject(bp);
- }
-
- public byte[] serializeObject()
- {
- byte[] rval = new byte[StringArray.sizeObject(columnNames)+
- LongArray.sizeObject(columnIdentifiers.length)+
- LongValue.sizeObject()
- ];
- BufferPointer bp = new BufferPointer(rval);
- StringArray.writeObject(bp,columnNames);
- LongArray.writeObject(bp,columnIdentifiers);
- LongValue.writeObject(bp,nextColumnIdentifier);
- return rval;
- }
-
- /** Check if equals (classes must already agree) */
- public boolean isEquals(WHKeyValue value)
- {
- TableValue other = (TableValue)value;
- return StringArray.compareObject(other.columnNames,this.columnNames) &&
- LongArray.compareObject(other.columnIdentifiers,this.columnIdentifiers) &&
- other.nextColumnIdentifier == this.nextColumnIdentifier;
- }
-
- public String[] getColumnNames()
- {
- return columnNames;
- }
-
- public long[] getColumnIdentifiers()
- {
- return columnIdentifiers;
- }
-
- public long getNextColumnIdentifier()
- {
- return nextColumnIdentifier;
- }
-
- public int hashCode()
- {
- int rval = 0;
- for (int i = 0 ; i < columnNames.length ; i++)
- {
- rval += columnNames[i].hashCode();
- }
- return rval;
- }
-
- public boolean equals(Object o)
- {
- if (this.getClass() != o.getClass())
- return false;
- TableValue other = (TableValue)o;
- return StringArray.compareObject(other.columnNames,this.columnNames);
- }
-
-}
+/* $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.keyvaluetablestore;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+import org.apache.warthog.common.*;
+
+/** An index definition value */
+public class TableValue implements WHKeyValue
+{
+ protected String[] columnNames;
+ protected long[] columnIdentifiers;
+ protected long nextColumnIdentifier;
+
+ /** Constructor */
+ public TableValue(String[] columnNames, long[] columnIdentifiers, long nextColumnIdentifier)
+ {
+ this.columnNames = columnNames;
+ this.columnIdentifiers = columnIdentifiers;
+ this.nextColumnIdentifier = nextColumnIdentifier;
+ }
+
+ public TableValue(byte[] data)
+ {
+ BufferPointer bp = new BufferPointer(data);
+ columnNames = StringArray.readObject(bp);
+ columnIdentifiers = LongArray.readObject(bp);
+ nextColumnIdentifier = LongValue.readObject(bp);
+ }
+
+ public byte[] serializeObject()
+ {
+ byte[] rval = new byte[StringArray.sizeObject(columnNames)+
+ LongArray.sizeObject(columnIdentifiers.length)+
+ LongValue.sizeObject()
+ ];
+ BufferPointer bp = new BufferPointer(rval);
+ StringArray.writeObject(bp,columnNames);
+ LongArray.writeObject(bp,columnIdentifiers);
+ LongValue.writeObject(bp,nextColumnIdentifier);
+ return rval;
+ }
+
+ /** Check if equals (classes must already agree) */
+ public boolean isEquals(WHKeyValue value)
+ {
+ TableValue other = (TableValue)value;
+ return StringArray.compareObject(other.columnNames,this.columnNames) &&
+ LongArray.compareObject(other.columnIdentifiers,this.columnIdentifiers) &&
+ other.nextColumnIdentifier == this.nextColumnIdentifier;
+ }
+
+ public String[] getColumnNames()
+ {
+ return columnNames;
+ }
+
+ public long[] getColumnIdentifiers()
+ {
+ return columnIdentifiers;
+ }
+
+ public long getNextColumnIdentifier()
+ {
+ return nextColumnIdentifier;
+ }
+
+ public int hashCode()
+ {
+ int rval = 0;
+ for (int i = 0 ; i < columnNames.length ; i++)
+ {
+ rval += columnNames[i].hashCode();
+ }
+ return rval;
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this.getClass() != o.getClass())
+ return false;
+ TableValue other = (TableValue)o;
+ return StringArray.compareObject(other.columnNames,this.columnNames);
+ }
+
+}
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableValue.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/keyvaluetablestore/TableValue.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHKey.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHKey.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHKey.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHKey.java Sun Dec 18 08:36:52 2011
@@ -1,30 +1,30 @@
-/* $Id: WHKey.java 1205831 2011-11-24 13:57:15Z 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.transactionalkeyvaluestore;
-
-/** This object represents a key in a transactional key/value store.
-* Pretty much any (serializable) object can be used, provided there
-* is an available hash function and equals method.
-*/
-public interface WHKey extends WHKeyValue
-{
- /** Calculate the hash function. */
- public long getHashCode();
-}
+/* $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.transactionalkeyvaluestore;
+
+/** This object represents a key in a transactional key/value store.
+* Pretty much any (serializable) object can be used, provided there
+* is an available hash function and equals method.
+*/
+public interface WHKey extends WHKeyValue
+{
+ /** Calculate the hash function. */
+ public long getHashCode();
+}
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHKey.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHKeyValue.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHKeyValue.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHKeyValue.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHKeyValue.java Sun Dec 18 08:36:52 2011
@@ -1,33 +1,33 @@
-/* $Id: WHKey.java 1205831 2011-11-24 13:57:15Z 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.transactionalkeyvaluestore;
-
-/** This object represents a value in a transactional key/value store.
-* Pretty much any (serializable) object can be used, provided there
-* is an available hash function and equals method.
-*/
-public interface WHKeyValue
-{
- public byte[] serializeObject();
-
- /** Check if equals (classes must already agree) */
- public boolean isEquals(WHKeyValue value);
-
-}
+/* $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.transactionalkeyvaluestore;
+
+/** This object represents a value in a transactional key/value store.
+* Pretty much any (serializable) object can be used, provided there
+* is an available hash function and equals method.
+*/
+public interface WHKeyValue
+{
+ public byte[] serializeObject();
+
+ /** Check if equals (classes must already agree) */
+ public boolean isEquals(WHKeyValue value);
+
+}
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHKeyValue.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHKeyValue.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHTransaction.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHTransaction.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHTransaction.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/main/java/org/apache/warthog/transactionalkeyvaluestore/WHTransaction.java Sun Dec 18 08:36:52 2011
@@ -1,55 +1,55 @@
-/* $Id: WHTransaction.java 1204399 2011-11-21 08:44:53Z 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.transactionalkeyvaluestore;
-
-import org.apache.warthog.api.*;
-
-/** This interface represents a transaction that is in progress.
-*/
-public interface WHTransaction
-{
- /** Set a value. May be null. */
- public void put(WHKey key, WHKeyValue value)
- throws WHException;
-
- /** Get a value. Null returned if no value. */
- public WHKeyValue get(WHKey key)
- throws WHException;
-
- /** Check to see if this transaction has become inconsistent.
- * If so, a WHDeadlockException is thrown.
- */
- public void check()
- throws WHException;
-
- /** Commit this transaction. If the transaction is inconsistent,
- * a WHDeadlockException will be thrown. */
- public void commit()
- throws WHException;
-
- /** Abandon this transaction.
- * This is called as a nicety to free any resources associated with the
- * transaction. The implementation should also be robust as far as
- * freeing resources if this method is NOT called, but might perform
- * the necessary logic in a finalizer at an arbitrary time.
- */
- public void abandon();
-
-}
+/* $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.transactionalkeyvaluestore;
+
+import org.apache.warthog.api.*;
+
+/** This interface represents a transaction that is in progress.
+*/
+public interface WHTransaction
+{
+ /** Set a value. May be null. */
+ public void put(WHKey key, WHKeyValue value)
+ throws WHException;
+
+ /** Get a value. Null returned if no value. */
+ public WHKeyValue get(WHKey key)
+ throws WHException;
+
+ /** Check to see if this transaction has become inconsistent.
+ * If so, a WHDeadlockException is thrown.
+ */
+ public void check()
+ throws WHException;
+
+ /** Commit this transaction. If the transaction is inconsistent,
+ * a WHDeadlockException will be thrown. */
+ public void commit()
+ throws WHException;
+
+ /** Abandon this transaction.
+ * This is called as a nicety to free any resources associated with the
+ * transaction. The implementation should also be robust as far as
+ * freeing resources if this method is NOT called, but might perform
+ * the necessary logic in a finalizer at an arbitrary time.
+ */
+ public void abandon();
+
+}