You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2010/01/21 10:45:36 UTC

svn commit: r901622 - in /incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core: ./ src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/ src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/

Author: reto
Date: Thu Jan 21 09:45:33 2010
New Revision: 901622

URL: http://svn.apache.org/viewvc?rev=901622&view=rev
Log:
moved IntHashMap to collections

Added:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashMap.java
      - copied, changed from r901331, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/IntHashMap.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashSet.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntIterator.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntSet.java
Removed:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/IntHashMap.java
Modified:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/pom.xml
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatching.java

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/pom.xml?rev=901622&r1=901621&r2=901622&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/pom.xml (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/pom.xml Thu Jan 21 09:45:33 2010
@@ -29,12 +29,6 @@
 			<artifactId>junit</artifactId>
 			<scope>test</scope>
 		</dependency>
-	 <dependency>
-	  <groupId>fastutil</groupId>
-	  <artifactId>fastutil</artifactId>
-	  <version>5.0.9</version>
-	  <type>jar</type>
-	 </dependency>
 	</dependencies>
 	<build>
 		<plugins>

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatching.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatching.java?rev=901622&r1=901621&r2=901622&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatching.java (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatching.java Thu Jan 21 09:45:33 2010
@@ -19,8 +19,8 @@
 
 package org.apache.clerezza.rdf.core.impl.graphmatching;
 
-import it.unimi.dsi.fastutil.ints.IntIterator;
 
+import org.apache.clerezza.rdf.core.impl.graphmatching.collections.IntHashMap;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -34,6 +34,7 @@
 import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.clerezza.rdf.core.impl.graphmatching.collections.IntIterator;
 
 /**
  *
@@ -118,7 +119,7 @@
 		}
 
 		matchingGroups = new HashMap<Set<BNode>, Set<BNode>>();
-		IntIterator hashIter = hashNodeMap1.keySet().iterator();
+		IntIterator hashIter = hashNodeMap1.keySet().intIterator();
 		while (hashIter.hasNext()) {
 			int hash = hashIter.next();
 			Set<BNode> nodes1 = hashNodeMap1.get(hash);

Copied: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashMap.java (from r901331, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/IntHashMap.java)
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashMap.java?p2=incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashMap.java&p1=incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/IntHashMap.java&r1=901331&r2=901622&rev=901622&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/IntHashMap.java (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashMap.java Thu Jan 21 09:45:33 2010
@@ -19,10 +19,9 @@
  * but rereleased by the original author under the ASF license (above).
  */
 
-package org.apache.clerezza.rdf.core.impl.graphmatching;
+package org.apache.clerezza.rdf.core.impl.graphmatching.collections;
+
 
-import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
-import it.unimi.dsi.fastutil.ints.IntSet;
 
 /**
  * <p>A hash map that uses primitive ints for the key rather than objects.</p>
@@ -38,9 +37,10 @@
  * @version $Revision: 1.2 $
  * @see java.util.HashMap
  */
-class  IntHashMap<T> {
-	
-	private IntSet keySet = new IntOpenHashSet();
+public class IntHashMap<T> {
+
+
+	private IntSet keySet = new IntHashSet();
 
     /**
      * The hash table data.

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashSet.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashSet.java?rev=901622&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashSet.java (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashSet.java Thu Jan 21 09:45:33 2010
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2002-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.clerezza.rdf.core.impl.graphmatching.collections;
+
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * This is currently just a placeholder implementation based onm HashSet<Integer>
+ * an efficient implementation is to store the primitives directly.
+ *
+ * @author reto
+ */
+public class IntHashSet extends HashSet<Integer> implements IntSet {
+
+	@Override
+	public IntIterator intIterator() {
+		final Iterator<Integer> base = iterator();
+		return new IntIterator() {
+
+			@Override
+			public int nextInt() {
+				return base.next();
+			}
+
+			@Override
+			public boolean hasNext() {
+				return base.hasNext();
+			}
+
+			@Override
+			public Integer next() {
+				return base.next();
+			}
+
+			@Override
+			public void remove() {
+				base.remove();
+			}
+		};
+	}
+
+	@Override
+	public void add(int i) {
+		super.add((Integer)i);
+	}
+
+}

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntIterator.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntIterator.java?rev=901622&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntIterator.java (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntIterator.java Thu Jan 21 09:45:33 2010
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2002-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.clerezza.rdf.core.impl.graphmatching.collections;
+
+import java.util.Iterator;
+
+
+/**
+ * An iterator allowing to iterate over ints, Iterator<Integer> is extended for
+ * compatibility, however accessing nextInt allows faster implementations.
+ *
+ * @author reto
+ */
+public interface IntIterator extends Iterator<Integer> {
+	public int nextInt();
+}

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntSet.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntSet.java?rev=901622&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntSet.java (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntSet.java Thu Jan 21 09:45:33 2010
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2002-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.clerezza.rdf.core.impl.graphmatching.collections;
+
+import java.util.Set;
+
+/**
+ * A IntSet allows directly adding primitive ints to a set, Set<Integer> is 
+ * extended, but accessingt he respective methods is less efficient.
+ *
+ * @author reto
+ */
+public interface IntSet extends Set<Integer> {
+	/**
+	 *
+	 * @return an iterator over the primitive int
+	 */
+	public IntIterator intIterator();
+	
+	public void add(int i);
+}