From: <tho...@us...> - 2010-10-05 20:28:28
|
Revision: 3732 http://bigdata.svn.sourceforge.net/bigdata/?rev=3732&view=rev Author: thompsonbry Date: 2010-10-05 20:28:22 +0000 (Tue, 05 Oct 2010) Log Message: ----------- Bug fix for "duplicate bop" reporting problem. I've simply taken out the definition of equals() and hashCode() for Predicate. Those methods were once used to cache access paths, but they have not been used in that manner for a long time. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpBase.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpUtility.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/Predicate.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOPredicate.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpBase.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpBase.java 2010-10-05 20:18:36 UTC (rev 3731) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpBase.java 2010-10-05 20:28:22 UTC (rev 3732) @@ -603,4 +603,95 @@ } + /* + * Note: I've played around with a few hash functions and senses of + * equality. Predicate (before the bops were introduced) used to have a + * hashCode() and equals() which was used to cache access paths, but that is + * long gone. The problem with specifying a hashCode() and equals() method + * for BOp/BOpBase/Predicate is that we wind up with duplicate bop + * exceptions being reported by BOpUtility#getIndex(BOp). + */ + +// /** +// * <code>true</code> if all arguments and annotations are the same. +// */ +// public boolean equals(final Object other) { +// +// if (this == other) +// return true; +// +// if (!(other instanceof BOp)) +// return false; +// +// final BOp o = (BOp) other; +// +// final int arity = arity(); +// +// if (arity != o.arity()) +// return false; +// +// for (int i = 0; i < arity; i++) { +// +// final BOp x = get(i); +// +// final BOp y = o.get(i); +// +// /* +// * X Y +// * same same : continue (includes null == null); +// * null other : return false; +// * !null other : if(!x.equals(y)) return false. +// */ +// if (x != y || x == null || !(x.equals(y))) { +//// && (// +//// (x != null && !(x.equals(y))) || // +//// (y != null && !(y.equals(x))))// +//// ) { +// +// return false; +// +// } +// +// } +// +// return annotations.equals(o.annotations()); +// +// } +// +// /** +// * The hash code is based on the hash of the operands plus the optional +// * {@link BOp.Annotations#BOP_ID}. It is cached. +// */ +// public int hashCode() { +// +// int h = hash; +// +// if (h == 0) { +// +// final int n = arity(); +// +// for (int i = 0; i < n; i++) { +// +// h = 31 * h + get(i).hashCode(); +// +// } +// +// Integer id = (Integer) getProperty(Annotations.BOP_ID); +// +// if (id != null) +// h = 31 * h + id.intValue(); +// +// hash = h; +// +// } +// +// return h; +// +// } +// +// /** +// * Caches the hash code. +// */ +// private int hash = 0; + } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpUtility.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpUtility.java 2010-10-05 20:18:36 UTC (rev 3731) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpUtility.java 2010-10-05 20:28:22 UTC (rev 3732) @@ -413,7 +413,7 @@ * trees whose sinks target a descendant, which is another way * to create a loop. */ - throw new DuplicateBOpException("id=" + t.getId() + ", root=" + throw new DuplicateBOpException("dup=" + t + ", root=" + toString(op)); } } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/Predicate.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/Predicate.java 2010-10-05 20:18:36 UTC (rev 3731) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/Predicate.java 2010-10-05 20:28:22 UTC (rev 3732) @@ -543,63 +543,70 @@ } - public boolean equals(final Object other) { - - if (this == other) - return true; - - if(!(other instanceof IPredicate<?>)) - return false; - - final IPredicate<?> o = (IPredicate<?>)other; - - final int arity = arity(); - - if(arity != o.arity()) return false; - - for (int i = 0; i < arity; i++) { - - final IVariableOrConstant<?> x = get(i); - - final IVariableOrConstant<?> y = o.get(i); - - if (x != y && !(x.equals(y))) { - - return false; - - } - - } - - return true; - - } + /* + * Intentionally removed. See BOpBase. + * + * hashCode() and equals() for Predicate were once used to cache access + * paths, but that code was history long before we developed the bop model. + */ - public int hashCode() { - - int h = hash; +// public boolean equals(final Object other) { +// +// if (this == other) +// return true; +// +// if(!(other instanceof IPredicate<?>)) +// return false; +// +// final IPredicate<?> o = (IPredicate<?>)other; +// +// final int arity = arity(); +// +// if(arity != o.arity()) return false; +// +// for (int i = 0; i < arity; i++) { +// +// final IVariableOrConstant<?> x = get(i); +// +// final IVariableOrConstant<?> y = o.get(i); +// +// if (x != y && !(x.equals(y))) { +// +// return false; +// +// } +// +// } +// +// return true; +// +// } +// +// public int hashCode() { +// +// int h = hash; +// +// if (h == 0) { +// +// final int n = arity(); +// +// for (int i = 0; i < n; i++) { +// +// h = 31 * h + get(i).hashCode(); +// +// } +// +// hash = h; +// +// } +// +// return h; +// +// } +// +// /** +// * Caches the hash code. +// */ +// private int hash = 0; - if (h == 0) { - - final int n = arity(); - - for (int i = 0; i < n; i++) { - - h = 31 * h + get(i).hashCode(); - - } - - hash = h; - - } - - return h; - - } - - /** - * Caches the hash code. - */ - private int hash = 0; - } Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOPredicate.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOPredicate.java 2010-10-05 20:18:36 UTC (rev 3731) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOPredicate.java 2010-10-05 20:28:22 UTC (rev 3732) @@ -79,9 +79,6 @@ * @param s * @param p * @param o - * - * @deprecated Only used by the unit tests. They should use the shallow - * copy constructor form. */ public SPOPredicate(final String relationName, final IVariableOrConstant<IV> s, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |