Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sesame 2.8.11 upgrade #141

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ protected void configureConnectOptions(IPreparedQuery q) {
}
q.addRequestParam(RemoteRepositoryDecls.INCLUDE_INFERRED,
Boolean.toString(includeInferred));
if (maxQueryTime > 0) {
q.addRequestParam(RemoteRepositoryDecls.MAX_QUERY_TIME_MILLIS, Long.toString(1000L*maxQueryTime));
if (getMaxExecutionTime() > 0) {
q.addRequestParam(RemoteRepositoryDecls.MAX_QUERY_TIME_MILLIS, Long.toString(1000L*getMaxExecutionTime()));
}

if (dataset != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.concurrent.atomic.AtomicReference;

import org.apache.log4j.Logger;
import org.openrdf.IsolationLevel;
import org.openrdf.model.Graph;
import org.openrdf.model.Namespace;
import org.openrdf.model.Resource;
Expand Down Expand Up @@ -753,7 +754,7 @@ public Update prepareUpdate(final QueryLanguage ql, final String query)
* Only execute() is currently supported.
*/
return new Update() {

private int maxExecutionTime;
@Override
public void execute() throws UpdateExecutionException {
try {
Expand Down Expand Up @@ -797,7 +798,17 @@ public void setDataset(Dataset arg0) {
public boolean getIncludeInferred() {
throw new UnsupportedOperationException();
}


@Override
public void setMaxExecutionTime(int i) {
this.maxExecutionTime = i;
}

@Override
public int getMaxExecutionTime() {
return maxExecutionTime;
}

@Override
public void setIncludeInferred(boolean arg0) {
throw new UnsupportedOperationException();
Expand Down Expand Up @@ -1014,6 +1025,16 @@ public boolean isActive() throws UnknownTransactionStateException,
}
}

@Override
public void setIsolationLevel(IsolationLevel isolationLevel) throws IllegalStateException {
// TODO: what do we do here?
}

@Override
public IsolationLevel getIsolationLevel() {
return null;
}

@Override
public void begin() throws RepositoryException {
assertOpen(); // non-blocking.
Expand All @@ -1031,7 +1052,13 @@ public void begin() throws RepositoryException {
}
}

/**
@Override
public void begin(IsolationLevel isolationLevel) throws RepositoryException {
// There's only one isolation level supported - snapshot isolation
begin();
}

/**
* Begin a read-only transaction. Since all read operations have snapshot
* isolation, this is only necessary when multiple read operations need to
* read on the same commit point.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**

Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved.
Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved.

Contact:
SYSTAP, LLC DBA Blazegraph
Expand Down Expand Up @@ -162,13 +162,12 @@ public String toExternal(final Literal lit) {
if (languageCode != null) {
sb.append('@');
sb.append(languageCode);
} else {
if (datatypeURI != null && !XMLSchema.STRING.equals(datatypeURI)) {
sb.append("^^");
sb.append(datatypeStr);
}
}

if (datatypeURI != null) {
sb.append("^^");
sb.append(datatypeStr);
}

return sb.toString();

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**

Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved.
Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved.

Contact:
SYSTAP, LLC DBA Blazegraph
Expand Down Expand Up @@ -34,6 +34,8 @@
import org.openrdf.model.Value;
import org.openrdf.model.impl.LiteralImpl;
import org.openrdf.model.impl.URIImpl;
import org.openrdf.model.vocabulary.RDF;
import org.openrdf.model.vocabulary.XMLSchema;

/**
* Utility class to encode/decode RDF {@link Value}s for interchange with the
Expand Down Expand Up @@ -413,16 +415,29 @@ public static String encodeValue(final Value v) {
if (v instanceof Literal) {
final Literal lit = (Literal) v;
final StringBuilder sb = new StringBuilder();
URI datatype = lit.getDatatype();
sb.append("\"");
sb.append(lit.getLabel());
sb.append("\"");
if (lit.getLanguage() != null) {
sb.append("@");
sb.append(lit.getLanguage());
if (RDF.LANGSTRING.equals(datatype)) {
datatype = null;
} else {
if (datatype != null) {
// This violates RDF 1.1, language literals should have LangString type.
throw new IllegalArgumentException("Language literals must be rdf:langString");
}
}
} else {
if (XMLSchema.STRING.equals(datatype)) {
datatype = null;
}
}
if (lit.getDatatype() != null) {
if (datatype != null) {
sb.append("^^");
sb.append(encodeValue(lit.getDatatype()));
sb.append(encodeValue(datatype));
}
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,15 +772,21 @@ static public void compareTupleQueryResults(
message.append("\n============ ");
message.append(name);
message.append(" =======================\n");
message.append("Expected result: \n");
message.append("Expected result [")
.append(expectedResultTable.size())
.append("] not equal to query result [")
.append(queryResultTable.size())
.append("] \n");
message.append(" =======================\n");
message.append("Expected result [").append(expectedResultTable.size()).append("]: \n");
while (expectedResultTable.hasNext()) {
message.append(expectedResultTable.next());
message.append("\n");
}
message.append("=============");
StringUtil.appendN('=', name.length(), message);
message.append("========================\n");
message.append("Query result: \n");
message.append("Query result [").append(queryResultTable.size()).append("]: \n");
while (queryResultTable.hasNext()) {
message.append(queryResultTable.next());
message.append("\n");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**

Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved.
Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved.

Contact:
SYSTAP, LLC DBA Blazegraph
Expand Down Expand Up @@ -147,8 +147,8 @@ public BigdataURI resolve(final URI uri) {
noninline_languageCode_en_lit2.setValue(f.createLiteral("systap","en"));
noninline_languageCode_de_lit1.setValue(f.createLiteral("bigdata","de"));
noninline_languageCode_de_lit2.setValue(f.createLiteral("systap","de"));
noninline_xsd_string_lit1.setValue(f.createLiteral("bigdata",XSD.STRING));
noninline_xsd_string_lit2.setValue(f.createLiteral("systap",XSD.STRING));
noninline_xsd_string_lit1.setValue(f.createLiteral("bigdata", XSD.STRING));
noninline_xsd_string_lit2.setValue(f.createLiteral("systap", XSD.STRING));

noninline_uri1.setValue(f.createURI("http://www.bigdata.com/"));
noninline_uri2.setValue(f.createURI("http://www.bigdata.com/blog/"));
Expand Down Expand Up @@ -287,8 +287,7 @@ public void test_uri_ordering() {
}

/**
* Unit test of the broad ordering of literals (plain LT language code LT
* datatype).
* Unit test of the broad ordering of literals (plain LT language code).
*/
public void test_literal_ordering_plain_languageCode_datatype() {

Expand All @@ -299,9 +298,6 @@ public void test_literal_ordering_plain_languageCode_datatype() {
// plain LT languageCode
assertLT(c.compare(v.noninline_plain_lit1, v.noninline_languageCode_de_lit1));

// languageCode LT datatype
assertLT(c.compare(v.noninline_plain_lit1, v.noninline_xsd_string_lit1));

}

/**
Expand Down Expand Up @@ -351,6 +347,7 @@ public void test_languageCode_ordering() {
* - xsd:string
* - RDF term (equal and unequal only)
* </pre>
* However, since in RDF 1.1 simple strings are xsd:string, all strings are sorted first.
*/
public void test_datatype_ordering() {

Expand All @@ -359,14 +356,18 @@ public void test_datatype_ordering() {
final IVComparator c = new IVComparator();

// plain literal LT numeric
assertLT(c.compare(v.noninline_languageCode_en_lit1, v.inline_xsd_int1));
assertLT(c.compare(v.noninline_plain_lit1, v.inline_xsd_int1));

// numeric LT boolean
assertLT(c.compare(v.inline_xsd_int1, v.inline_xsd_boolean_true));

// assertLT(c.compare(v.inline_xsd_int1, v.inline_xsd_dateTime1));
// assertLT(c.compare(v.inline_xsd_boolean_true, v.inline_xsd_dateTime1));

assertLT(c.compare(v.inline_xsd_dateTime1, v.noninline_xsd_string_lit1));
// In RDF 1.1, xsd:string is simple string
assertLT(c.compare(v.noninline_xsd_string_lit1, v.inline_xsd_dateTime1));
assertLT(c.compare(v.noninline_plain_lit1, v.inline_xsd_dateTime1));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void test_history01() {
if(log.isInfoEnabled()) log.info("\n"+h.toString());

// add the first sample.
h.add(t0,12d);
h.add(t0+1,12d);

assertEquals(1,h.size());
assertEquals(60,h.capacity());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ private IV doGet(final IBindingSet bindingSet) {
final IValueExpression<IV> expr = (IValueExpression<IV>) get(0);

if (expr instanceof IVariable<?> && ((IVariable<?>) expr).isWildcard()) {
// Do not count empty binding sets
if (bindingSet.isEmpty()) {
return null;
}
// Do not attempt to evaluate "*".
aggregated++;
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import org.openrdf.model.URI;
import org.openrdf.model.Value;
import org.openrdf.model.vocabulary.RDF;

import com.bigdata.rdf.internal.impl.BlobIV;
import com.bigdata.rdf.lexicon.LexiconRelation;
Expand Down Expand Up @@ -379,6 +380,10 @@ static final public DTE valueOf(final URI datatype) {
return UUID;
if (datatype.equals(XSD.STRING))
return XSDString;
if (datatype.equals(RDF.LANGSTRING))
// Sesame 2.8 upgrade: RDF.LANGSTRING is converted to DTE.XSDString with termCode TERM_CODE_LCL
// so DTE and lang tag is stored in the key and decoded back in IVUtility.decodeInlineUnicodeLiteral
return XSDString;
/*
* Not a known DTE datatype.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**

Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved.
Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved.

Contact:
SYSTAP, LLC DBA Blazegraph
Expand All @@ -26,14 +26,13 @@
import java.util.Map;

import org.openrdf.model.Literal;
import org.openrdf.model.URI;
import org.openrdf.query.algebra.evaluation.util.QueryEvaluationUtil;

import com.bigdata.bop.BOp;
import com.bigdata.bop.IBindingSet;
import com.bigdata.bop.IValueExpression;
import com.bigdata.rdf.error.SparqlTypeErrorException;
import com.bigdata.rdf.internal.IV;
import com.bigdata.rdf.internal.XSD;
import com.bigdata.rdf.model.BigdataBNode;
import com.bigdata.rdf.sparql.ast.GlobalAnnotations;

Expand Down Expand Up @@ -82,9 +81,7 @@ public IV get(final IBindingSet bs) throws SparqlTypeErrorException {

final Literal lit = getAndCheckLiteralValue(0, bs);

final URI dt = lit.getDatatype();

if (dt != null && !dt.stringValue().equals(XSD.STRING.stringValue()))
if (!QueryEvaluationUtil.isStringLiteral(lit))
throw new SparqlTypeErrorException();

final BigdataBNode bnode = getValueFactory().createBNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,37 @@ public IV get(final IBindingSet bs) {
label = lit.getLabel();
if (lit.getDatatype() != null) {
if (lang != null) {
allSame = false;
} else if (datatype == null) {
allSame = lit.getDatatype().equals(datatype) && lang.equals(lit.getLanguage());
} else {
if (i == 0) {
datatype = lit.getDatatype();
} else {
allSame = false;
lang = lit.getLanguage();
}
} else if (!datatype.equals(lit.getDatatype())) {
allSame = false;
if (datatype == null) {
if (i == 0) {
datatype = lit.getDatatype();
} else {
allSame = false;
}
} else if (!datatype.equals(lit.getDatatype())) {
allSame = false;
}
}
} else if (lit.getLanguage() != null) {
if (datatype != null) {
allSame = false;
} else if (lang == null) {
allSame = lit.getLanguage().equals(lang) && datatype.equals(lit.getDatatype());
} else {
if (i == 0) {
lang = lit.getLanguage();
} else {
allSame = false;
datatype = lit.getDatatype();
}
} else if (!lang.equals(lit.getLanguage())) {
allSame = false;
if (lang == null) {
if (i == 0) {
lang = lit.getLanguage();
} else {
allSame = false;
}
} else if (!lang.equals(lit.getLanguage())) {
allSame = false;
}
}
} else {
allSame = false;
Expand All @@ -119,10 +129,10 @@ public IV get(final IBindingSet bs) {
sb.append(label);
}
if (allSame) {
if (datatype != null) {
return super.asIV(getValueFactory().createLiteral(sb.toString(),datatype), bs);
} else if (lang != null) {
if (lang != null) {
return super.asIV(getValueFactory().createLiteral(sb.toString(),lang), bs);
} else if (datatype != null) {
return super.asIV(getValueFactory().createLiteral(sb.toString(),datatype), bs);
}
}
return super.asIV(getValueFactory().createLiteral(sb.toString()), bs);
Expand Down
Loading