private static void areIsomorphic(ResultSet x, ResultSet y) { ResultSetRewindable rs1 = ResultSetFactory.makeRewindable(x) ; ResultSetRewindable rs2 = ResultSetFactory.makeRewindable(y) ; // System.out.println(ResultSetFormatter.asText(rs1)); // System.out.println(); // System.out.println(ResultSetFormatter.asText(rs2)); // rs1.reset(); // rs2.reset(); Assert.assertTrue(ResultSetCompare.isomorphic(rs1, rs2)) ; }
/** Compare two result sets for equivalence. Equivalence means: * A row rs1 has one matching row in rs2, and vice versa. * A row is only matched once. * Rows match if they have the same variables with the same values. * bNodes must map to a consistent other bNodes. Value comparisons of nodes. * * Destructive - rs1 and rs2 are both read, possibly to exhaustion. * @param rs1 * @param rs2 * @return true if they are equivalent */ public static boolean equalsByValue(ResultSet rs1, ResultSet rs2) { if ( ! compareHeader(rs1, rs2) ) return false ; //return equivalent(convert(rs1), convert(rs2), new BNodeIso(NodeUtils.sameValue)) ; ResultSetRewindable rs1a = ResultSetFactory.makeRewindable(rs1) ; ResultSetRewindable rs2a = ResultSetFactory.makeRewindable(rs2) ; if ( equivalent(convert(rs1a), convert(rs2a), new BNodeIso(NodeUtils.sameValue)) ) return true ; rs1a.reset() ; rs2a.reset() ; return isomorphic(rs1a, rs2a) ; }
/** compare two result sets for equivalence. Equivalence means: * A row rs1 has one matching row in rs2, and vice versa. * A row is only matched once. * Rows match if they have the same variables with the same values, * bNodes must map to a consistent other bNodes. * Term comparisons of nodes. * * Destructive - rs1 and rs2 are both read, possibly to exhaustion. * @param rs1 * @param rs2 * @return true if they are equivalent */ public static boolean equalsByTerm(ResultSet rs1, ResultSet rs2) { if ( ! compareHeader(rs1, rs2) ) return false ; //return equivalent(convert(rs1), convert(rs2), new BNodeIso(NodeUtils.sameTerm)) ; ResultSetRewindable rs1a = ResultSetFactory.makeRewindable(rs1) ; ResultSetRewindable rs2a = ResultSetFactory.makeRewindable(rs2) ; // Aligned rows if ( equivalent(convert(rs1a), convert(rs2a), new BNodeIso(NodeUtils.sameTerm)) ) return true ; rs1a.reset() ; rs2a.reset() ; return isomorphic(rs1a, rs2a) ; }
private void isotest(String[] rs1$2, String[] rs2$2) { ResultSetRewindable rs1 = ResultSetFactory.makeRewindable(BuilderResultSet.build(SSE.parseItem(StrUtils.strjoinNL(rs1$)))) ; ResultSetRewindable rs2 = ResultSetFactory.makeRewindable(BuilderResultSet.build(SSE.parseItem(StrUtils.strjoinNL(rs2$)))) ; assertTrue(ResultSetCompare.isomorphic(rs1, rs2)) ; rs1.reset() ; rs2.reset() ; assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ; assertTrue(ResultSetCompare.equalsByValue(rs1, rs2)) ; }
Assert.assertTrue(ResultSetCompare.isomorphic(rs, rsOpt)); } finally {
iterOpt.close(); Assert.assertTrue(ResultSetCompare.isomorphic(rs, rsOpt)); } finally {