You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2013/12/13 17:20:06 UTC
git commit: yet another take at MARMOTTA-401
Updated Branches:
refs/heads/develop 3bd9c85f1 -> 7c1f7d766
yet another take at MARMOTTA-401
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/7c1f7d76
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/7c1f7d76
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/7c1f7d76
Branch: refs/heads/develop
Commit: 7c1f7d7667dc4fca8a751ece877333d3c23eaded
Parents: 3bd9c85
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Fri Dec 13 17:20:00 2013 +0100
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Fri Dec 13 17:20:00 2013 +0100
----------------------------------------------------------------------
.../commons/sesame/tripletable/IntArray.java | 28 +++++++++++++++++---
1 file changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/7c1f7d76/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/IntArray.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/IntArray.java b/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/IntArray.java
index e7867b3..f1fe2ce 100644
--- a/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/IntArray.java
+++ b/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/IntArray.java
@@ -21,6 +21,7 @@ import com.google.common.hash.HashCode;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing;
+import org.openrdf.model.Literal;
import org.openrdf.model.Resource;
import org.openrdf.model.URI;
import org.openrdf.model.Value;
@@ -75,7 +76,7 @@ public final class IntArray implements Comparable<IntArray> {
int s = subject != null ? subject.hashCode() : Integer.MIN_VALUE;
int p = property != null ? property.hashCode() : Integer.MIN_VALUE;
- int o = object != null ? (object.hashCode() + 31 * object.getClass().hashCode()) : Integer.MIN_VALUE;
+ int o = object != null ? calcObjectHash(object) : Integer.MIN_VALUE;
int c = context != null ? context.hashCode() : Integer.MIN_VALUE;
IntBuffer bb = IntBuffer.allocate(4);
@@ -95,7 +96,7 @@ public final class IntArray implements Comparable<IntArray> {
int s = subject != null ? subject.hashCode() : Integer.MAX_VALUE;
int p = property != null ? property.hashCode() : Integer.MAX_VALUE;
- int o = object != null ? (object.hashCode() + 31 * object.getClass().hashCode()) : Integer.MAX_VALUE;
+ int o = object != null ? calcObjectHash(object) : Integer.MAX_VALUE;
int c = context != null ? context.hashCode() : Integer.MAX_VALUE;
IntBuffer bb = IntBuffer.allocate(4);
@@ -115,7 +116,7 @@ public final class IntArray implements Comparable<IntArray> {
int s = subject != null ? subject.hashCode() : Integer.MIN_VALUE;
int p = property != null ? property.hashCode() : Integer.MIN_VALUE;
- int o = object != null ? (object.hashCode() + 31 * object.getClass().hashCode()) : Integer.MIN_VALUE;
+ int o = object != null ? calcObjectHash(object) : Integer.MIN_VALUE;
int c = context != null ? context.hashCode() : Integer.MIN_VALUE;
IntBuffer bb = IntBuffer.allocate(4);
@@ -135,7 +136,7 @@ public final class IntArray implements Comparable<IntArray> {
int s = subject != null ? subject.hashCode() : Integer.MAX_VALUE;
int p = property != null ? property.hashCode() : Integer.MAX_VALUE;
- int o = object != null ? (object.hashCode() + 31 * object.getClass().hashCode()) : Integer.MAX_VALUE;
+ int o = object != null ? calcObjectHash(object) : Integer.MAX_VALUE;
int c = context != null ? context.hashCode() : Integer.MAX_VALUE;
IntBuffer bb = IntBuffer.allocate(4);
@@ -148,6 +149,25 @@ public final class IntArray implements Comparable<IntArray> {
}
+ private static int calcObjectHash(Value value) {
+ if(value instanceof Literal) {
+ int i = value.stringValue().hashCode();
+ if(((Literal) value).getLanguage() != null) {
+ i = i*31 + ((Literal) value).getLanguage().hashCode();
+ } else {
+ i = i*31;
+ }
+ if(((Literal) value).getDatatype() != null) {
+ i = i*31 + ((Literal) value).getDatatype().hashCode();
+ } else {
+ i = i*31;
+ }
+ return i;
+ } else {
+ return value.hashCode();
+ }
+ }
+
@Override
public String toString() {
return "IntArray{" +