Skip to content

Commit

Permalink
Update result set testing for triple terms
Browse files Browse the repository at this point in the history
  • Loading branch information
afs committed Feb 4, 2025
1 parent 872a8d0 commit d93415b
Show file tree
Hide file tree
Showing 45 changed files with 2,357 additions and 1,019 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public static RowSetRewindable create(RowSet rowSet) {
* @param other The other RowSetMem object
*/
private RowSetMem(RowSetMem other) {
// Share vars and rows but not the iterator.
vars = other.vars;
// Share results (not the iterator).
rows = other.rows;
reset();
}
Expand All @@ -61,7 +61,6 @@ private RowSetMem(RowSetMem other) {
* necessary internal datastructures are shared. This operation destroys
* (uses up) a RowSet object that is not an in-memory one.
*/

private RowSetMem(RowSet other) {
if ( other instanceof RowSetMem rsm ) {
// See also the RowSetMem(RowSetMem) constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.apache.jena.irix.IRIs;
import org.apache.jena.irix.IRIx;
import org.apache.jena.query.ARQ;
import org.apache.jena.rdf.model.impl.Util;
import org.apache.jena.riot.out.NodeFmtLib;
import org.apache.jena.riot.system.RiotLib;
import org.apache.jena.sparql.expr.ExprEvalException;
Expand Down Expand Up @@ -127,22 +126,31 @@ public static NodeValue sameTerm(NodeValue nv1, NodeValue nv2) {
return NodeValue.booleanReturn(sameTerm(nv1.asNode(), nv2.asNode()));
}

// Jena - up to Jena 4.
// Language tags were kept in the case form they were given as.
// Jena5 - language tags are canonicalised.

/** sameTerm(x,y) */
public static boolean sameTerm(Node node1, Node node2) {
if ( node1.equals(node2) )
return true;
if ( Util.isLangString(node1) && Util.isLangString(node2) ) {
String lex1 = node1.getLiteralLexicalForm();
String lex2 = node2.getLiteralLexicalForm();
if ( !lex1.equals(lex2) )
return false;
return node1.getLiteralLanguage().equalsIgnoreCase(node2.getLiteralLanguage());
}
if ( node1.isTripleTerm() && node2.isTripleTerm() ) {
return sameTriples(node1.getTriple(), node2.getTriple());
}
return false;
}
return node1.sameTermAs(node2);
}

// /** sameTerm(x,y) */
// public static boolean sameTerm(Node node1, Node node2) {
// if ( node1.equals(node2) )
// return true;
// if ( Util.isLangString(node1) && Util.isLangString(node2) ) {
// String lex1 = node1.getLiteralLexicalForm();
// String lex2 = node2.getLiteralLexicalForm();
// if ( !lex1.equals(lex2) )
// return false;
// return node1.getLiteralLanguage().equalsIgnoreCase(node2.getLiteralLanguage());
// }
// if ( node1.isTripleTerm() && node2.isTripleTerm() ) {
// return sameTriples(node1.getTriple(), node2.getTriple());
// }
// return false;
// }

private static boolean sameTriples(Triple t1, Triple t2) {
return sameTerm(t1.getSubject(), t2.getSubject())
Expand Down
Loading

0 comments on commit d93415b

Please sign in to comment.