You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2009/10/17 19:45:57 UTC
svn commit: r826283 - in /activemq/sandbox/activemq-flow/hawtdb: ./
src/main/java/org/apache/hawtdb/api/
src/main/java/org/apache/hawtdb/internal/index/
src/main/java/org/apache/hawtdb/internal/page/
src/test/java/org/apache/hawtdb/internal/index/
Author: chirino
Date: Sat Oct 17 17:45:56 2009
New Revision: 826283
URL: http://svn.apache.org/viewvc?rev=826283&view=rev
Log:
hash index tests now working.
Added:
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/BTreeIndexFactory.java
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/HashIndexFactory.java
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/IndexFactory.java
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/Prefixer.java
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/StringPrefixer.java
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/MapEntry.java
Removed:
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/HashBins.java
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/KeyValueEntry.java
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/Prefixer.java
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/StringPrefixer.java
Modified:
activemq/sandbox/activemq-flow/hawtdb/pom.xml
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIndex.java
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIterator.java
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeNode.java
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/HashIndex.java
activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/page/ConcurrentTransaction.java
activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java
activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexTest.java
activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/HashIndexBenchmark.java
activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/HashIndexTest.java
Modified: activemq/sandbox/activemq-flow/hawtdb/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/pom.xml?rev=826283&r1=826282&r2=826283&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/pom.xml (original)
+++ activemq/sandbox/activemq-flow/hawtdb/pom.xml Sat Oct 17 17:45:56 2009
@@ -95,7 +95,7 @@
<include>**/*Test.java</include>
</includes>
<excludes>
- <exclude>**/**</exclude>
+ <!-- <exclude>**/**</exclude> -->
</excludes>
<parallel>methods</parallel>
<threadCount>16</threadCount>
Added: activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/BTreeIndexFactory.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/BTreeIndexFactory.java?rev=826283&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/BTreeIndexFactory.java (added)
+++ activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/BTreeIndexFactory.java Sat Oct 17 17:45:56 2009
@@ -0,0 +1,106 @@
+/**
+ * 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.hawtdb.api;
+
+import org.apache.activemq.util.marshaller.Marshaller;
+import org.apache.hawtdb.internal.index.BTreeIndex;
+
+/**
+ * This object is used to create variable magnitude b+tree indexes.
+ *
+ * A b+tree can be used for set or map-based indexing. Leaf
+ * nodes are linked together for faster iteration of the values.
+ *
+ * <br>
+ * The variable magnitude attribute means that the b+tree attempts
+ * to store as many values and pointers on one page as is possible.
+ *
+ * <br>
+ * It will act as a simple-prefix b+tree if a prefixer is configured.
+ *
+ * <br>
+ * In a simple-prefix b+tree, instead of promoting actual keys to branch pages, when
+ * leaves are split, a shortest-possible separator is generated at the pivot.
+ * That separator is what is promoted to the parent branch (and continuing up
+ * the list). As a result, actual keys and pointers can only be found at the
+ * leaf level. This also affords the index the ability to ignore costly merging
+ * and redistribution of pages when deletions occur. Deletions only affect leaf
+ * pages in this implementation, and so it is entirely possible for a leaf page
+ * to be completely empty after all of its keys have been removed.
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+public class BTreeIndexFactory<Key, Value> implements IndexFactory<Key, Value> {
+
+ private Marshaller<Key> keyMarshaller;
+ private Marshaller<Value> valueMarshaller;
+ private boolean deferredEncoding;
+ private Prefixer<Key> prefixer;
+
+ public Index<Key, Value> create(Paged paged, int page) {
+ BTreeIndex<Key, Value> index = createInstance(paged, page);
+ index.create();
+ return index;
+ }
+
+ public Index<Key, Value> open(Paged paged, int page) {
+ return createInstance(paged, page);
+ }
+
+ private BTreeIndex<Key, Value> createInstance(Paged paged, int page) {
+ if (keyMarshaller == null) {
+ throw new IllegalArgumentException("The key marshaller must be set before calling open");
+ }
+ if (valueMarshaller == null) {
+ throw new IllegalArgumentException("The key marshaller must be set before calling open");
+ }
+ return new BTreeIndex<Key, Value>(paged, page, this);
+ }
+
+ public Marshaller<Key> getKeyMarshaller() {
+ return keyMarshaller;
+ }
+
+ public void setKeyMarshaller(Marshaller<Key> keyMarshaller) {
+ this.keyMarshaller = keyMarshaller;
+ }
+
+ public Marshaller<Value> getValueMarshaller() {
+ return valueMarshaller;
+ }
+
+ public void setValueMarshaller(Marshaller<Value> valueMarshaller) {
+ this.valueMarshaller = valueMarshaller;
+ }
+
+ public boolean isDeferredEncoding() {
+ return deferredEncoding;
+ }
+
+ public void setDeferredEncoding(boolean deferredEncoding) {
+ this.deferredEncoding = deferredEncoding;
+ }
+
+ public Prefixer<Key> getPrefixer() {
+ return prefixer;
+ }
+
+ public void setPrefixer(Prefixer<Key> prefixer) {
+ this.prefixer = prefixer;
+ }
+
+}
\ No newline at end of file
Added: activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/HashIndexFactory.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/HashIndexFactory.java?rev=826283&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/HashIndexFactory.java (added)
+++ activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/HashIndexFactory.java Sat Oct 17 17:45:56 2009
@@ -0,0 +1,112 @@
+/**
+ * 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.hawtdb.api;
+
+import org.apache.activemq.util.marshaller.Marshaller;
+import org.apache.hawtdb.internal.index.HashIndex;
+
+/**
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+public class HashIndexFactory<Key, Value> implements IndexFactory<Key, Value> {
+
+ public static final String PROPERTY_PREFIX = HashIndex.class.getName()+".";
+ public static final int DEFAULT_BUCKET_CAPACITY = Integer.parseInt(System.getProperty(PROPERTY_PREFIX+"DEFAULT_BUCKET_CAPACITY", "1024"));
+ public static final int DEFAULT_MAXIMUM_BUCKET_CAPACITY = Integer.parseInt(System.getProperty(PROPERTY_PREFIX+"DEFAULT_MAXIMUM_BUCKET_CAPACITY", "16384"));
+ public static final int DEFAULT_MINIMUM_BUCKET_CAPACITY = Integer.parseInt(System.getProperty(PROPERTY_PREFIX+"DEFAULT_MINIMUM_BUCKET_CAPACITY", "16"));
+ public static final int DEFAULT_LOAD_FACTOR = Integer.parseInt(System.getProperty(PROPERTY_PREFIX+"DEFAULT_LOAD_FACTOR", "75"));
+
+ private Marshaller<Key> keyMarshaller;
+ private Marshaller<Value> valueMarshaller;
+ private int initialBucketCapacity = DEFAULT_BUCKET_CAPACITY;
+ private int maximumBucketCapacity = DEFAULT_MAXIMUM_BUCKET_CAPACITY;
+ private int minimumBucketCapacity = DEFAULT_MINIMUM_BUCKET_CAPACITY;
+ private int loadFactor = DEFAULT_LOAD_FACTOR;
+
+ public Index<Key, Value> open(Paged paged, int page) {
+ return docreate(paged, page).open();
+ }
+
+ public Index<Key, Value> create(Paged paged, int page) {
+ return docreate(paged, page).create();
+ }
+
+ private HashIndex<Key, Value> docreate(Paged paged, int page) {
+ assertFieldsSet();
+ return new HashIndex<Key, Value>(paged, page, this);
+ }
+
+ private void assertFieldsSet() {
+ if (keyMarshaller == null) {
+ throw new IllegalArgumentException("The key marshaller must be set before calling open");
+ }
+ if (valueMarshaller == null) {
+ throw new IllegalArgumentException("The key marshaller must be set before calling open");
+ }
+ }
+
+ public Marshaller<Key> getKeyMarshaller() {
+ return keyMarshaller;
+ }
+
+ public void setKeyMarshaller(Marshaller<Key> keyMarshaller) {
+ this.keyMarshaller = keyMarshaller;
+ }
+
+ public Marshaller<Value> getValueMarshaller() {
+ return valueMarshaller;
+ }
+
+ public void setValueMarshaller(Marshaller<Value> valueMarshaller) {
+ this.valueMarshaller = valueMarshaller;
+ }
+
+ public int getMaximumBucketCapacity() {
+ return maximumBucketCapacity;
+ }
+
+ public void setMaximumBucketCapacity(int maximumBucketCapacity) {
+ this.maximumBucketCapacity = maximumBucketCapacity;
+ }
+
+ public int getMinimumBucketCapacity() {
+ return minimumBucketCapacity;
+ }
+
+ public void setMinimumBucketCapacity(int minimumBucketCapacity) {
+ this.minimumBucketCapacity = minimumBucketCapacity;
+ }
+
+ public int getLoadFactor() {
+ return loadFactor;
+ }
+
+ public void setLoadFactor(int loadFactor) {
+ this.loadFactor = loadFactor;
+ }
+
+ public int getBucketCapacity() {
+ return initialBucketCapacity;
+ }
+
+ public void setBucketCapacity(int binCapacity) {
+ this.initialBucketCapacity = binCapacity;
+ }
+
+
+}
\ No newline at end of file
Added: activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/IndexFactory.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/IndexFactory.java?rev=826283&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/IndexFactory.java (added)
+++ activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/IndexFactory.java Sat Oct 17 17:45:56 2009
@@ -0,0 +1,43 @@
+/**
+ * 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.hawtdb.api;
+
+/**
+ * The common interface to {@link Index} factories. An index factory
+ * allows you to create or open an index in a {@link Paged} object.
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+public interface IndexFactory<Key, Value> {
+
+ /**
+ *
+ * @param paged
+ * @param page
+ * @return
+ */
+ public Index<Key, Value> create(Paged paged, int page);
+
+ /**
+ *
+ * @param paged
+ * @param page
+ * @return
+ */
+ public Index<Key, Value> open(Paged paged, int page);
+
+}
\ No newline at end of file
Added: activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/Prefixer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/Prefixer.java?rev=826283&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/Prefixer.java (added)
+++ activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/Prefixer.java Sat Oct 17 17:45:56 2009
@@ -0,0 +1,42 @@
+/**
+ * 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.hawtdb.api;
+
+/**
+ * Interface used to determine the simple prefix of two keys.
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+public interface Prefixer<Key> {
+
+ /**
+ * This methods should return shortest prefix of value2 where the
+ * following still holds:<br/>
+ * value1 <= prefix <= value2.<br/>
+ * <br/>
+ *
+ * When this method is called, the following is guaranteed:<br/>
+ * value1 < value2<br/>
+ * <br/>
+ *
+ *
+ * @param value1
+ * @param value2
+ * @return
+ */
+ public Key getSimplePrefix(Key value1, Key value2);
+}
\ No newline at end of file
Added: activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/StringPrefixer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/StringPrefixer.java?rev=826283&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/StringPrefixer.java (added)
+++ activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/api/StringPrefixer.java Sat Oct 17 17:45:56 2009
@@ -0,0 +1,50 @@
+/**
+ * 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.hawtdb.api;
+
+
+/**
+ * StringPrefixer is a {@link Prefixer} implementation that works on strings.
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+public class StringPrefixer implements Prefixer<String> {
+
+ /**
+ * Example: If value1 is "Hello World" and value 2 is "Help Me" then the
+ * result will be: "Help"
+ *
+ * @see Prefixer#getSimplePrefix
+ */
+ public String getSimplePrefix(String value1, String value2) {
+ char[] c1 = value1.toCharArray();
+ char[] c2 = value2.toCharArray();
+ int n = Math.min(c1.length, c2.length);
+ int i = 0;
+ while (i < n) {
+ if (c1[i] != c2[i]) {
+ return value2.substring(0, i + 1);
+ }
+ i++;
+ }
+
+ if (n == c2.length) {
+ return value2;
+ }
+ return value2.substring(0, n);
+ }
+}
\ No newline at end of file
Modified: activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIndex.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIndex.java?rev=826283&r1=826282&r2=826283&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIndex.java (original)
+++ activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIndex.java Sat Oct 17 17:45:56 2009
@@ -22,102 +22,22 @@
import java.util.Map;
import org.apache.activemq.util.marshaller.Marshaller;
+import org.apache.hawtdb.api.BTreeIndexFactory;
import org.apache.hawtdb.api.IndexVisitor;
import org.apache.hawtdb.api.Index;
import org.apache.hawtdb.api.Paged;
+import org.apache.hawtdb.api.Prefixer;
import org.apache.hawtdb.internal.index.BTreeNode.Data;
/**
- * BTreeIndex represents a Variable Magnitude B+Tree in a Page File. A BTree is
- * a bit flexible in that it can be used for set or map-based indexing. Leaf
- * nodes are linked together for faster iteration of the values.
- *
- * <br>
- * The Variable Magnitude attribute means that the BTree attempts to store as
- * many values and pointers on one page as is possible.
- *
- * <br>
- * The implementation can optionally a be Simple-Prefix B+Tree.
- *
- * <br>
- * For those who don't know how a Simple-Prefix B+Tree works, the primary
- * distinction is that instead of promoting actual keys to branch pages, when
- * leaves are split, a shortest-possible separator is generated at the pivot.
- * That separator is what is promoted to the parent branch (and continuing up
- * the list). As a result, actual keys and pointers can only be found at the
- * leaf level. This also affords the index the ability to ignore costly merging
- * and redistribution of pages when deletions occur. Deletions only affect leaf
- * pages in this implementation, and so it is entirely possible for a leaf page
- * to be completely empty after all of its keys have been removed.
+ * A variable magnitude b+tree indexes with support for optional
+ * simple-prefix optimization.
*
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
public class BTreeIndex<Key, Value> implements Index<Key, Value> {
- static class Factory<Key, Value> {
-
- private Marshaller<Key> keyMarshaller;
- private Marshaller<Value> valueMarshaller;
- private boolean deferredEncoding;
- private Prefixer<Key> prefixer;
-
- public BTreeIndex<Key, Value> create(Paged paged, int page) {
- BTreeIndex<Key, Value> index = createInstance(paged, page);
- BTreeNode<Key, Value> root = new BTreeNode<Key, Value>(page);
- index.storeNode(root); // Store the root page..
- return index;
- }
-
- public BTreeIndex<Key, Value> open(Paged paged, int page) {
- BTreeIndex<Key, Value> index = createInstance(paged, page);
- return index;
- }
-
- private BTreeIndex<Key, Value> createInstance(Paged paged, int page) {
- if (keyMarshaller == null) {
- throw new IllegalArgumentException("The key marshaller must be set before calling open");
- }
- if (valueMarshaller == null) {
- throw new IllegalArgumentException("The key marshaller must be set before calling open");
- }
- return new BTreeIndex<Key, Value>(paged, page, this);
- }
-
- public Marshaller<Key> getKeyMarshaller() {
- return keyMarshaller;
- }
-
- public void setKeyMarshaller(Marshaller<Key> keyMarshaller) {
- this.keyMarshaller = keyMarshaller;
- }
-
- public Marshaller<Value> getValueMarshaller() {
- return valueMarshaller;
- }
-
- public void setValueMarshaller(Marshaller<Value> valueMarshaller) {
- this.valueMarshaller = valueMarshaller;
- }
-
- public boolean isDeferredEncoding() {
- return deferredEncoding;
- }
-
- public void setDeferredEncoding(boolean deferredEncoding) {
- this.deferredEncoding = deferredEncoding;
- }
-
- public Prefixer<Key> getPrefixer() {
- return prefixer;
- }
-
- public void setPrefixer(Prefixer<Key> prefixer) {
- this.prefixer = prefixer;
- }
-
- }
-
private final BTreeNode.BTreeNodeEncoderDecoder<Key, Value> PAGE_ENCODER_DECODER = new BTreeNode.BTreeNodeEncoderDecoder<Key, Value>(this);
private final Paged paged;
@@ -127,7 +47,7 @@
private final Prefixer<Key> prefixer;
private final boolean deferredEncoding;
- public BTreeIndex(Paged paged, int page, Factory<Key, Value> factory) {
+ public BTreeIndex(Paged paged, int page, BTreeIndexFactory<Key, Value> factory) {
this.paged = paged;
this.page = page;
this.keyMarshaller = factory.getKeyMarshaller();
@@ -135,6 +55,12 @@
this.deferredEncoding = factory.isDeferredEncoding();
this.prefixer = factory.getPrefixer();
}
+
+ public void create() {
+ // Store the root page..
+ BTreeNode<Key, Value> root = new BTreeNode<Key, Value>(page);
+ storeNode(root);
+ }
public boolean containsKey(Key key) {
return root().contains(this, key);
Modified: activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIterator.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIterator.java?rev=826283&r1=826282&r2=826283&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIterator.java (original)
+++ activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIterator.java Sat Oct 17 17:45:56 2009
@@ -53,7 +53,7 @@
break;
}
} else {
- nextEntry = new KeyValueEntry<Key, Value>(current.data.keys[nextIndex], current.data.values[nextIndex]);
+ nextEntry = new MapEntry<Key, Value>(current.data.keys[nextIndex], current.data.values[nextIndex]);
nextIndex++;
break;
}
Modified: activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeNode.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeNode.java?rev=826283&r1=826282&r2=826283&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeNode.java (original)
+++ activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeNode.java Sat Oct 17 17:45:56 2009
@@ -30,6 +30,7 @@
import org.apache.hawtdb.api.EncoderDecoder;
import org.apache.hawtdb.api.IndexException;
import org.apache.hawtdb.api.Paged;
+import org.apache.hawtdb.api.Prefixer;
import org.apache.hawtdb.internal.page.Extent;
import org.apache.hawtdb.internal.page.ExtentInputStream;
import org.apache.hawtdb.internal.page.ExtentOutputStream;
@@ -599,7 +600,7 @@
node = node.getChild(index, 0);
}
if (node.data.values.length > 0) {
- return new KeyValueEntry<Key, Value>(node.data.keys[0], node.data.values[0]);
+ return new MapEntry<Key, Value>(node.data.keys[0], node.data.values[0]);
} else {
return null;
}
@@ -612,7 +613,7 @@
}
if (node.data.values.length > 0) {
int idx = node.data.values.length - 1;
- return new KeyValueEntry<Key, Value>(node.data.keys[idx], node.data.values[idx]);
+ return new MapEntry<Key, Value>(node.data.keys[idx], node.data.values[idx]);
} else {
return null;
}
Modified: activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/HashIndex.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/HashIndex.java?rev=826283&r1=826282&r2=826283&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/HashIndex.java (original)
+++ activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/HashIndex.java Sat Oct 17 17:45:56 2009
@@ -16,176 +16,239 @@
*/
package org.apache.hawtdb.internal.index;
+import java.nio.ByteBuffer;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
-import org.apache.activemq.util.marshaller.Marshaller;
+import javolution.io.Struct;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.hawtdb.api.BTreeIndexFactory;
+import org.apache.hawtdb.api.HashIndexFactory;
import org.apache.hawtdb.api.Index;
import org.apache.hawtdb.api.Paged;
+import org.apache.hawtdb.api.Paged.SliceType;
/**
- * Hash Index implementation. The hash buckets use a BTree.
+ * Hash Index implementation. The hash buckets store entries in a b+tree.
*
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
public class HashIndex<Key,Value> implements Index<Key,Value> {
private static final Log LOG = LogFactory.getLog(HashIndex.class);
-
- public static final String PROPERTY_PREFIX = HashIndex.class.getName()+".";
- public static final int DEFAULT_BIN_CAPACITY = Integer.parseInt(System.getProperty(PROPERTY_PREFIX+"DEFAULT_BIN_CAPACITY", "1024"));
- public static final int DEFAULT_MAXIMUM_BIN_CAPACITY = Integer.parseInt(System.getProperty(PROPERTY_PREFIX+"DEFAULT_MAXIMUM_BIN_CAPACITY", "16384"));
- public static final int DEFAULT_MINIMUM_BIN_CAPACITY = Integer.parseInt(System.getProperty(PROPERTY_PREFIX+"DEFAULT_MINIMUM_BIN_CAPACITY", "16"));
- public static final int DEFAULT_LOAD_FACTOR = Integer.parseInt(System.getProperty(PROPERTY_PREFIX+"DEFAULT_LOAD_FACTOR", "75"));
- static class Factory<Key, Value> {
- private Marshaller<Key> keyMarshaller;
- private Marshaller<Value> valueMarshaller;
- private int maximumBinCapacity = DEFAULT_MAXIMUM_BIN_CAPACITY;
- private int minimumBinCapacity = DEFAULT_MINIMUM_BIN_CAPACITY;
- private int loadFactor = DEFAULT_LOAD_FACTOR;
-
- public HashIndex<Key, Value> open(Paged paged, int page) {
- return docreate(paged, page).open();
+ static private class Header extends Struct {
+ public final UTF8String magic = new UTF8String(4);
+ public final Signed32 page = new Signed32();
+ public final Signed32 capacity = new Signed32();
+ public final Signed32 size = new Signed32();
+ public final Signed32 active = new Signed32();
+
+ static Header create(ByteBuffer buffer) {
+ Header header = new Header();
+ header.setByteBuffer(buffer, buffer.position());
+ return header;
}
+ }
- public HashIndex<Key, Value> create(Paged paged, int page) {
- return docreate(paged, page).create();
- }
+ /**
+ * This is the data stored in the index header. It knows where
+ * the hash buckets are stored at an keeps usage statistics about
+ * those buckets.
+ */
+ private class Buckets {
+
+ int bucketsPage=-1;
+ int active;
+ int capacity;
+ int size;
+
+ int increaseThreshold;
+ int decreaseThreshold;
- private HashIndex<Key, Value> docreate(Paged paged, int page) {
- assertFieldsSet();
- return new HashIndex<Key, Value>(paged, page, keyMarshaller, valueMarshaller, maximumBinCapacity, minimumBinCapacity, loadFactor);
+ private void calcThresholds() {
+ increaseThreshold = (capacity * loadFactor)/100;
+ decreaseThreshold = (capacity * loadFactor * loadFactor ) / 20000;
}
- private void assertFieldsSet() {
- if (keyMarshaller == null) {
- throw new IllegalArgumentException("The key marshaller must be set before calling open");
- }
- if (valueMarshaller == null) {
- throw new IllegalArgumentException("The key marshaller must be set before calling open");
+ void create(int capacity) {
+ this.size = 0;
+ this.active = 0;
+ this.capacity = capacity;
+ this.bucketsPage = paged.allocator().alloc(capacity);
+ for (int i = 0; i < capacity; i++) {
+ BIN_FACTORY.create(paged, (bucketsPage + i));
}
+ calcThresholds();
+ store();
}
-
- public Marshaller<Key> getKeyMarshaller() {
- return keyMarshaller;
- }
-
- public void setKeyMarshaller(Marshaller<Key> keyMarshaller) {
- this.keyMarshaller = keyMarshaller;
- }
-
- public Marshaller<Value> getValueMarshaller() {
- return valueMarshaller;
- }
-
- public void setValueMarshaller(Marshaller<Value> valueMarshaller) {
- this.valueMarshaller = valueMarshaller;
+
+ public void destroy() {
+ clear();
+ paged.allocator().free(bucketsPage, capacity);
}
-
- public int getMaximumBinCapacity() {
- return maximumBinCapacity;
+
+ public void clear() {
+ for (int i = 0; i < buckets.capacity; i++) {
+ buckets.bucket(i).clear();
+ }
+ buckets.size = 0;
+ buckets.active = 0;
+ buckets.calcThresholds();
+ }
+
+ void store() {
+ ByteBuffer slice = paged.slice(SliceType.WRITE, page, 1);
+ try {
+ Header header = Header.create(slice);
+ header.magic.set("HASH");
+ header.page.set(this.bucketsPage);
+ header.capacity.set(this.capacity);
+ header.size.set(this.size);
+ header.active.set(this.active);
+ } finally {
+ paged.unslice(slice);
+ }
}
-
- public void setMaximumBinCapacity(int maximumBinCapacity) {
- this.maximumBinCapacity = maximumBinCapacity;
+
+ void load() {
+ ByteBuffer slice = paged.slice(SliceType.READ, page, 1);
+ try {
+ Header header = Header.create(slice);
+ this.bucketsPage = header.page.get();
+ this.capacity = header.capacity.get();
+ this.size = header.size.get();
+ this.active = header.active.get();
+ calcThresholds();
+ } finally {
+ paged.unslice(slice);
+ }
}
-
- public int getMinimumBinCapacity() {
- return minimumBinCapacity;
+
+ Index<Key,Value> bucket(int index) {
+ return BIN_FACTORY.open(paged, bucketsPage+index);
}
- public void setMinimumBinCapacity(int minimumBinCapacity) {
- this.minimumBinCapacity = minimumBinCapacity;
+ Index<Key,Value> bucket(Key key) {
+ int i = index(key);
+ return BIN_FACTORY.open(paged, bucketsPage+i);
+ }
+
+ int index(Key x) {
+ try {
+ return Math.abs(x.hashCode()%capacity);
+ } catch (ArithmeticException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ throw e;
+ }
}
-
- public int getLoadFactor() {
- return loadFactor;
+
+ @Override
+ public String toString() {
+ return "{ page:"+bucketsPage+", size: "+size+", capacity: "+capacity+", active: "+active+", increase threshold: "+increaseThreshold+", decrease threshold: "+decreaseThreshold+" }";
}
- public void setLoadFactor(int loadFactor) {
- this.loadFactor = loadFactor;
- }
-
}
- final BTreeIndex.Factory<Key, Value> BIN_FACTORY = new BTreeIndex.Factory<Key, Value>();
-
- final Paged paged;
- final int page;
- final int maximumBinCapacity;
- final int minimumBinCapacity;
+ private final BTreeIndexFactory<Key, Value> BIN_FACTORY = new BTreeIndexFactory<Key, Value>();
+
+ private final Paged paged;
+ private final int page;
+ private final int maximumBucketCapacity;
+ private final int minimumBucketCapacity;
private final int loadFactor;
+ private final int initialBucketCapacity;
- private HashBins bins;
- int increaseThreshold;
- int decreaseThreshold;
+ private Buckets buckets;
- public HashIndex(Paged paged, int page, Marshaller<Key> keyMarshaller, Marshaller<Value> valueMarshaller, int maximumBinCapacity, int minimumBinCapacity, int loadFactor) {
+ public HashIndex(Paged paged, int page, HashIndexFactory<Key,Value> factory) {
this.paged = paged;
this.page = page;
- this.maximumBinCapacity = maximumBinCapacity;
- this.minimumBinCapacity = minimumBinCapacity;
- this.loadFactor = loadFactor;
- this.BIN_FACTORY.setKeyMarshaller(keyMarshaller);
- this.BIN_FACTORY.setValueMarshaller(valueMarshaller);
+ this.maximumBucketCapacity = factory.getMaximumBucketCapacity();
+ this.minimumBucketCapacity = factory.getMinimumBucketCapacity();
+ this.loadFactor = factory.getLoadFactor();
+ this.initialBucketCapacity = factory.getBucketCapacity();
+ this.BIN_FACTORY.setKeyMarshaller(factory.getKeyMarshaller());
+ this.BIN_FACTORY.setValueMarshaller(factory.getValueMarshaller());
}
public HashIndex<Key, Value> create() {
- this.bins = new HashBins();
- this.bins.create(this, DEFAULT_BIN_CAPACITY);
- paged.put(HashBins.ENCODER_DECODER, page, bins);
- calcThresholds();
+ buckets = new Buckets();
+ buckets.create(initialBucketCapacity);
return this;
}
public HashIndex<Key, Value> open() {
- this.bins = paged.get(HashBins.ENCODER_DECODER, page);
- calcThresholds();
+ buckets = new Buckets();
+ buckets.load();
return this;
}
public Value get(Key key) {
- return bins.bin(this, key).get(key);
+ return buckets.bucket(key).get(key);
}
public boolean containsKey(Key key) {
- return bins.bin(this, key).containsKey(key);
+ return buckets.bucket(key).containsKey(key);
}
-
+
public Value put(Key key, Value value) {
- Value put = bins.put(this, key, value);
- if (bins.active >= this.increaseThreshold) {
- int newSize = Math.min(this.maximumBinCapacity, bins.capacity*2);
- if(bins.capacity!=newSize) {
- this.resize(newSize);
+ Index<Key, Value> bucket = buckets.bucket(key);
+
+ int originalSize = bucket.size();
+ Value put = bucket.put(key,value);
+ int newSize = bucket.size();
+
+ if (newSize != originalSize) {
+ buckets.size++;
+ if (newSize == 1) {
+ buckets.active++;
+ }
+ buckets.store();
+ }
+
+ if (buckets.active >= buckets.increaseThreshold) {
+ newSize = Math.min(this.maximumBucketCapacity, buckets.capacity*4);
+ if(buckets.capacity!=newSize) {
+ this.changeCapacity(newSize);
}
}
return put;
}
public Value remove(Key key) {
- Value rc = bins.remove(this, key);
- if (bins.active <= this.decreaseThreshold) {
- int newSize = Math.max(minimumBinCapacity, bins.capacity/2);
- if(bins.capacity!=newSize) {
- resize(newSize);
+ Index<Key, Value> bucket = buckets.bucket(key);
+ int originalSize = bucket.size();
+ Value rc = bucket.remove(key);
+ int newSize = bucket.size();
+
+ if (newSize != originalSize) {
+ buckets.size--;
+ if (newSize == 0) {
+ buckets.active--;
+ }
+ buckets.store();
+ }
+
+ if (buckets.active <= buckets.decreaseThreshold) {
+ newSize = Math.max(minimumBucketCapacity, buckets.capacity/2);
+ if(buckets.capacity!=newSize) {
+ changeCapacity(newSize);
}
}
return rc;
}
public void clear() {
- bins.clear(this);
- if (bins.active <= this.decreaseThreshold) {
- int newSize = Math.max(minimumBinCapacity, bins.capacity/2);
- if(bins.capacity!=newSize) {
- resize(newSize);
- }
+ buckets.clear();
+ if (buckets.capacity!=initialBucketCapacity) {
+ changeCapacity(initialBucketCapacity);
}
}
@@ -194,47 +257,48 @@
}
public int size() {
- return bins.size;
+ return buckets.size;
}
public void destroy() {
- bins.destroy(this);
- bins = null;
+ buckets.destroy();
+ buckets = null;
}
-
- public String toString() {
- return "{ page: "+page+", bins: "+bins+" }";
+ public int getPage() {
+ return page;
}
// /////////////////////////////////////////////////////////////////
- // Implementation Methods
+ // Helper methods Methods
// /////////////////////////////////////////////////////////////////
- void resize(final int capacity) {
+ private void changeCapacity(final int capacity) {
LOG.debug("Resizing to: "+capacity);
- HashBins newBins = new HashBins();
- newBins.create(this, capacity);
+ Buckets next = new Buckets();
+ next.create(capacity);
- // Copy the data from the old bins to the new bins.
- for (int i = 0; i < bins.capacity; i++) {
- Index<Key, Value> bin = bins.bin(this, i);
+ // Copy the data from the old buckets to the new buckets.
+ for (int i = 0; i < buckets.capacity; i++) {
+ Index<Key, Value> bin = buckets.bucket(i);
+ HashSet<Integer> activeBuckets = new HashSet<Integer>();
for (Map.Entry<Key, Value> entry : bin) {
- newBins.put(this, entry.getKey(), entry.getValue());
+ Key key = entry.getKey();
+ Value value = entry.getValue();
+ Index<Key, Value> bucket = next.bucket(key);
+ bucket.put(key, value);
+ if( activeBuckets.add(bucket.getPage()) ) {
+ next.active++;
+ }
}
}
+ next.size = buckets.size;
- bins.destroy(this);
- bins = newBins;
- calcThresholds();
- LOG.debug("Resizing done. New bins start at: "+bins.page);
- }
-
- private void calcThresholds() {
- increaseThreshold = (bins.capacity * loadFactor)/100;
- decreaseThreshold = (bins.capacity * loadFactor * loadFactor ) / 20000;
+ buckets.destroy();
+ buckets = next;
+ LOG.debug("Resizing done. New bins start at: "+buckets.bucketsPage);
}
- public int getPage() {
- return page;
+ public String toString() {
+ return "{ page: "+page+", buckets: "+buckets+" }";
}
}
Added: activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/MapEntry.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/MapEntry.java?rev=826283&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/MapEntry.java (added)
+++ activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/index/MapEntry.java Sat Oct 17 17:45:56 2009
@@ -0,0 +1,52 @@
+/**
+ * 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.hawtdb.internal.index;
+
+import java.util.Map;
+
+/**
+ * A basic implementation of {@link Map.Entry}.
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+final class MapEntry<Key, Value> implements Map.Entry<Key, Value> {
+
+ private final Key key;
+ private final Value value;
+
+ public MapEntry(Key key, Value value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public Key getKey() {
+ return key;
+ }
+
+ public Value getValue() {
+ return value;
+ }
+
+ public Value setValue(Value value) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String toString() {
+ return "{ key: "+key+", value: "+value+" }";
+ }
+}
\ No newline at end of file
Modified: activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/page/ConcurrentTransaction.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/page/ConcurrentTransaction.java?rev=826283&r1=826282&r2=826283&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/page/ConcurrentTransaction.java (original)
+++ activemq/sandbox/activemq-flow/hawtdb/src/main/java/org/apache/hawtdb/internal/page/ConcurrentTransaction.java Sat Oct 17 17:45:56 2009
@@ -1,3 +1,19 @@
+/**
+ * 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.hawtdb.internal.page;
import java.nio.ByteBuffer;
@@ -18,7 +34,7 @@
* Transaction objects are NOT thread safe. Users of this object should
* guard it from concurrent access.
*
- * @author chirino
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
final class ConcurrentTransaction implements Transaction {
/**
Modified: activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java?rev=826283&r1=826282&r2=826283&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java (original)
+++ activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java Sat Oct 17 17:45:56 2009
@@ -19,10 +19,9 @@
import org.apache.activemq.util.buffer.Buffer;
import org.apache.activemq.util.marshaller.FixedBufferMarshaller;
import org.apache.activemq.util.marshaller.LongMarshaller;
+import org.apache.hawtdb.api.BTreeIndexFactory;
import org.apache.hawtdb.api.Index;
import org.apache.hawtdb.api.Transaction;
-import org.apache.hawtdb.internal.index.BTreeIndex;
-import org.apache.hawtdb.internal.index.BTreeIndex.Factory;
/**
*
@@ -31,7 +30,7 @@
public class BTreeIndexBenchmark extends IndexBenchmark {
protected Index<Long, Buffer> createIndex(Transaction tx) {
- Factory<Long, Buffer> factory = new BTreeIndex.Factory<Long, Buffer>();
+ BTreeIndexFactory<Long, Buffer> factory = new BTreeIndexFactory<Long, Buffer>();
factory.setKeyMarshaller(LongMarshaller.INSTANCE);
factory.setValueMarshaller(new FixedBufferMarshaller(DATA.length));
return factory.open(tx, tx.allocator().alloc(1));
Modified: activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexTest.java?rev=826283&r1=826282&r2=826283&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexTest.java (original)
+++ activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexTest.java Sat Oct 17 17:45:56 2009
@@ -26,10 +26,10 @@
import org.apache.activemq.util.marshaller.LongMarshaller;
import org.apache.activemq.util.marshaller.StringMarshaller;
+import org.apache.hawtdb.api.BTreeIndexFactory;
import org.apache.hawtdb.api.IndexVisitor;
import org.apache.hawtdb.api.Index;
import org.apache.hawtdb.internal.index.BTreeIndex;
-import org.apache.hawtdb.internal.index.BTreeIndex.Factory;
import org.junit.Before;
import org.junit.Test;
@@ -51,7 +51,7 @@
@Override
protected Index<String, Long> createIndex(int page) {
- Factory<String,Long> factory = new Factory<String,Long>();
+ BTreeIndexFactory<String,Long> factory = new BTreeIndexFactory<String,Long>();
factory.setKeyMarshaller(StringMarshaller.INSTANCE);
factory.setValueMarshaller(LongMarshaller.INSTANCE);
factory.setDeferredEncoding(deferredEncoding);
Modified: activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/HashIndexBenchmark.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/HashIndexBenchmark.java?rev=826283&r1=826282&r2=826283&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/HashIndexBenchmark.java (original)
+++ activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/HashIndexBenchmark.java Sat Oct 17 17:45:56 2009
@@ -19,9 +19,9 @@
import org.apache.activemq.util.buffer.Buffer;
import org.apache.activemq.util.marshaller.FixedBufferMarshaller;
import org.apache.activemq.util.marshaller.LongMarshaller;
+import org.apache.hawtdb.api.HashIndexFactory;
import org.apache.hawtdb.api.Index;
import org.apache.hawtdb.api.Transaction;
-import org.apache.hawtdb.internal.index.HashIndex.Factory;
/**
@@ -31,7 +31,7 @@
public class HashIndexBenchmark extends IndexBenchmark {
protected Index<Long, Buffer> createIndex(Transaction tx) {
- Factory<Long, Buffer> factory = new Factory<Long, Buffer>();
+ HashIndexFactory<Long, Buffer> factory = new HashIndexFactory<Long, Buffer>();
factory.setKeyMarshaller(LongMarshaller.INSTANCE);
factory.setValueMarshaller(new FixedBufferMarshaller(DATA.length));
return factory.open(tx, tx.allocator().alloc(1));
Modified: activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/HashIndexTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/HashIndexTest.java?rev=826283&r1=826282&r2=826283&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/HashIndexTest.java (original)
+++ activemq/sandbox/activemq-flow/hawtdb/src/test/java/org/apache/hawtdb/internal/index/HashIndexTest.java Sat Oct 17 17:45:56 2009
@@ -18,8 +18,8 @@
import org.apache.activemq.util.marshaller.LongMarshaller;
import org.apache.activemq.util.marshaller.StringMarshaller;
+import org.apache.hawtdb.api.HashIndexFactory;
import org.apache.hawtdb.api.Index;
-import org.apache.hawtdb.internal.index.HashIndex.Factory;
/**
@@ -30,7 +30,7 @@
@Override
protected Index<String, Long> createIndex(int page) {
- Factory<String,Long> factory = new Factory<String,Long>();
+ HashIndexFactory<String,Long> factory = new HashIndexFactory<String,Long>();
factory.setKeyMarshaller(StringMarshaller.INSTANCE);
factory.setValueMarshaller(LongMarshaller.INSTANCE);
if( page==-1 ) {