Giter Club home page Giter Club logo

marklogic-sesame's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

marklogic-sesame's Issues

The context of Statement objects returned by con.getStatements() is always null

The following tests fails at "assertThat(st.getContext(), is(equalTo((Resource)dirgraph1)));" , the context returned by st.getContext() is null always.

@test
public void testGetStatementsInMultipleContexts()
throws Exception
{
testAdminCon.begin();
testAdminCon.add(micah, lname, micahlname, dirgraph1);
testAdminCon.add(micah, fname, micahfname, dirgraph1);
testAdminCon.add(micah, homeTel, micahhomeTel, dirgraph1);
testAdminCon.commit();

CloseableIteration<? extends Statement, RepositoryException> iter = testAdminCon.getStatements(null, null, null, false, dirgraph1);
try {
int count = 0;
while (iter.hasNext()) {
count++;
Statement st = iter.next();
logger.debug("Test 1" +st.getContext());
logger.debug("Test 1" +st.getObject().stringValue());
assertThat(st.getContext(), is(equalTo((Resource)dirgraph1)));
}
assertEquals("there should be three statements", 3, count);
}
finally {
iter.close();
iter = null;
}

Literals getting inserted as URI's

When inserting triples using the method "add(Resource subject, URI predicate, Value object, Resource... contexts)", the object "Alice", gets inserted into the database as a URI and not as String "Alice". The query below returns empty dataset. As a result of this , email data gets inserted but when running size() method, RDFParseException is thrown as it complains the an email (for example '[email protected]) is not a valid URI format.

SELECT ?o
FROM http://marklogic.com/test/context5
WHERE
{
?s ?p ?o.
FILTER (?o = "Alice")
}

Sample code:

Resource context5 = testAdminCon.getValueFactory().createURI("http://marklogic.com/test/context5");
URI alice = testAdminCon.getValueFactory().createURI("http://example.org/people/alice");
URI name = testAdminCon.getValueFactory().createURI("http://example.org/ontology/name");
URI person = testAdminCon.getValueFactory().createURI("http://example.org/ontology/Person");
Literal alicesName = testAdminCon.getValueFactory().createLiteral("Alice");
testAdminCon.add(alice, RDF.TYPE, person,context5);
testAdminCon.add(alice, name, alicesName,context5);

con.hasStatement() generating syntactically incorrect ASK query

testAdminCon.hasStatement(john, homeTel, johnhomeTel, false) generates the following ASK query which is incorrect syntactically. This occurs only when the context is not specified or if one of the context is explicitly specified as null.

Scenarios:

  1. testAdminCon.hasStatement(john, homeTel, johnhomeTel, false)
  2. testAdminCon.hasStatement(john, homeTel, johnhomeTel, false, null)
  3. testAdminCon.hasStatement(john, homeTel, johnhomeTel, false, null, dirgraph)
  4. testAdminCon.hasStatement(st1, false);
  5. testWriterCon.hasStatement(st1, false, null);

ASK { http://marklogicsparql.com/id#1111 http://marklogicsparql.com/addressbook#homeTel "1.11111111E8"@http://www.w3.org/2001/xmlschema#double }

org.openrdf.repository.RepositoryException: org.openrdf.query.QueryEvaluationException: Local message: failed to apply resource at /graphs/sparql: Bad Request. Server Message: XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected , expecting }
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection.hasStatement(MarkLogicRepositoryConnection.java:348)
at com.marklogic.sesame.functionaltests.MarkLogicRepositoryConnectionTest.testGetStatementsInSingleContext(MarkLogicRepositoryConnectionTest.java:1642)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.openrdf.query.QueryEvaluationException: Local message: failed to apply resource at /graphs/sparql: Bad Request. Server Message: XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected , expecting }
at com.marklogic.semantics.sesame.query.MarkLogicBooleanQuery.evaluate(MarkLogicBooleanQuery.java:59)
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection.hasStatement(MarkLogicRepositoryConnection.java:342)
... 27 more
Caused by: com.marklogic.client.FailedRequestException: Local message: failed to apply resource at /graphs/sparql: Bad Request. Server Message: XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected , expecting }
at com.marklogic.client.impl.JerseyServices.checkStatus(JerseyServices.java:4598)
at com.marklogic.client.impl.JerseyServices.postResource(JerseyServices.java:3492)
at com.marklogic.client.impl.JerseyServices.executeSparql(JerseyServices.java:5606)
at com.marklogic.client.impl.SPARQLQueryManagerImpl.executeQueryImpl(SPARQLQueryManagerImpl.java:101)
at com.marklogic.client.impl.SPARQLQueryManagerImpl.executeQueryImpl(SPARQLQueryManagerImpl.java:94)
at com.marklogic.client.impl.SPARQLQueryManagerImpl.executeAsk(SPARQLQueryManagerImpl.java:140)
at com.marklogic.semantics.sesame.client.MarkLogicClientImpl.performBooleanQuery(MarkLogicClientImpl.java:225)
at com.marklogic.semantics.sesame.client.MarkLogicClient.sendBooleanQuery(MarkLogicClient.java:125)
at com.marklogic.semantics.sesame.query.MarkLogicBooleanQuery.evaluate(MarkLogicBooleanQuery.java:51)
... 28 more

Sesame strict URI checking may limit graph names

Sesame's org.openrdf.model.impl.URI (and undelrying org.openrdf.model.impl.URIImpl) strictly check URI's. In MarkLogic, URI are constrained as xs:string so its possible to generate URI (ex. graph names)that Sesame classes (derived or otherwise) will choke on.

Investigate what chicanery might be required to bypass this limitation and table discussion to broader group.

NullPointerException thrown when running con.add(Statement st, Context ct)

Statement st1 = vf.createStatement(john, fname, johnfname);
con.add(st1,dirgraph);

java.lang.NullPointerException
at com.marklogic.semantics.sesame.client.MarkLogicClientImpl.performAdd(MarkLogicClientImpl.java:273)
at com.marklogic.semantics.sesame.client.MarkLogicClient.sendAdd(MarkLogicClient.java:145)
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection.add(MarkLogicRepositoryConnection.java:448)
at com.marklogic.sesame.functionaltests.MarkLogicRepositoryConnectionTest.testPrepareTupleQuery3(MarkLogicRepositoryConnectionTest.java:518)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Adding triples using InputStream fails when context is not specified

The following code fails when 'context' is not set as it looks like it is not handled in 'performAdd' method in 'MarkLogicClientImpl' class

//testAdminCon is an instance of RepositoryConnection
InputStream in = MarkLogicRepositoryConnectionTest.class.getResourceAsStream(TEST_DIR_PREFIX
+ "directory.ttl");
testAdminCon.add(in, "", RDFFormat.TURTLE);

result.hasNext() throws an exception if the result set is empty

When the result set from a query execution is empty, an exception is thrown when referencing the hasNext() method. The exception stack trace is as follows:

org.openrdf.query.QueryEvaluationException: org.openrdf.rio.RDFParseException: Expected '<' or '', found: { [line 1]
at org.openrdf.http.client.QueueCursor.checkException(QueueCursor.java:170)
at org.openrdf.http.client.QueueCursor.getNextElement(QueueCursor.java:125)
at info.aduna.iteration.LookAheadIteration.lookAhead(LookAheadIteration.java:91)
at info.aduna.iteration.LookAheadIteration.hasNext(LookAheadIteration.java:60)
at org.openrdf.http.client.BackgroundGraphResult.hasNext(BackgroundGraphResult.java:81)
at com.marklogic.sesame.functionaltests.MarkLogicRepositoryConnectionTest.testPrepareGraphQuery1(MarkLogicRepositoryConnectionTest.java:750)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.openrdf.rio.RDFParseException: Expected '<' or '
', found: { [line 1]
at org.openrdf.rio.helpers.RDFParserHelper.reportFatalError(RDFParserHelper.java:440)
at org.openrdf.rio.helpers.RDFParserBase.reportFatalError(RDFParserBase.java:704)
at org.openrdf.rio.ntriples.NTriplesParser.reportFatalError(NTriplesParser.java:674)
at org.openrdf.rio.ntriples.NTriplesParser.parseSubject(NTriplesParser.java:369)
at org.openrdf.rio.ntriples.NTriplesParser.parseTriple(NTriplesParser.java:301)
at org.openrdf.rio.ntriples.NTriplesParser.parse(NTriplesParser.java:192)
at org.openrdf.http.client.BackgroundGraphResult.run(BackgroundGraphResult.java:124)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

RDFParse exception not thrown when adding malformed turtle file

The exception stack trace seen below is thrown and not RDFParseException when adding malformed turtle file

com.marklogic.client.FailedRequestException: Local message: failed to apply resource at graphs: Internal Server Error. Server Message: XDMP-DOCBADCHAR: xdmp:turtle($body, $options) -- Unexpected character found: '_' (0x005f) at :6:26 . See the MarkLogic server error log for further detail.
at com.marklogic.client.impl.JerseyServices.checkStatus(JerseyServices.java:4600)
at com.marklogic.client.impl.JerseyServices.postResource(JerseyServices.java:3494)
at com.marklogic.client.impl.JerseyServices.mergeGraph(JerseyServices.java:5429)
at com.marklogic.client.impl.GraphManagerImpl.merge(GraphManagerImpl.java:207)
at com.marklogic.client.impl.GraphManagerImpl.merge(GraphManagerImpl.java:193)
at com.marklogic.semantics.sesame.client.MarkLogicClientImpl.performAdd(MarkLogicClientImpl.java:246)
at com.marklogic.semantics.sesame.client.MarkLogicClient.sendAdd(MarkLogicClient.java:138)
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection.add(MarkLogicRepositoryConnection.java:500)
at com.marklogic.sesame.functionaltests.MarkLogicRepositoryConnectionTest.testAddMalformedLiteralsDefaultConfig(MarkLogicRepositoryConnectionTest.java:1207)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

con.clear() dosesn't work

The method connection.clear() , I think without arguments is supposed to clear all the contents of the database which doesn’t happen. But connection.clear(context) clears the specified graph.

con.size() on empty database without any triples throws exception

con.size() on an empty database and with no arguments throws the following exception

org.openrdf.repository.RepositoryException: org.openrdf.query.QueryEvaluationException: org.openrdf.rio.RDFParseException: Expected '<' or '', found: { [line 1]
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection$4.convert(MarkLogicRepositoryConnection.java:262)
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection$4.convert(MarkLogicRepositoryConnection.java:1)
at info.aduna.iteration.ExceptionConvertingIteration.hasNext(ExceptionConvertingIteration.java:81)
at org.openrdf.repository.RepositoryResult.hasNext(RepositoryResult.java:66)
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection.size(MarkLogicRepositoryConnection.java:306)
at com.marklogic.sesame.functionaltests.MarkLogicRepositoryConnectionTest.createRepository(MarkLogicRepositoryConnectionTest.java:217)
at com.marklogic.sesame.functionaltests.MarkLogicRepositoryConnectionTest.setUp(MarkLogicRepositoryConnectionTest.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.openrdf.query.QueryEvaluationException: org.openrdf.rio.RDFParseException: Expected '<' or '
', found: { [line 1]
at org.openrdf.http.client.QueueCursor.checkException(QueueCursor.java:170)
at org.openrdf.http.client.QueueCursor.getNextElement(QueueCursor.java:125)
at info.aduna.iteration.LookAheadIteration.lookAhead(LookAheadIteration.java:91)
at info.aduna.iteration.LookAheadIteration.hasNext(LookAheadIteration.java:60)
at org.openrdf.http.client.BackgroundGraphResult.hasNext(BackgroundGraphResult.java:81)
at info.aduna.iteration.ExceptionConvertingIteration.hasNext(ExceptionConvertingIteration.java:78)
... 29 more
Caused by: org.openrdf.rio.RDFParseException: Expected '<' or '_', found: { [line 1]
at org.openrdf.rio.helpers.RDFParserHelper.reportFatalError(RDFParserHelper.java:440)
at org.openrdf.rio.helpers.RDFParserBase.reportFatalError(RDFParserBase.java:704)
at org.openrdf.rio.ntriples.NTriplesParser.reportFatalError(NTriplesParser.java:674)
at org.openrdf.rio.ntriples.NTriplesParser.parseSubject(NTriplesParser.java:369)
at org.openrdf.rio.ntriples.NTriplesParser.parseTriple(NTriplesParser.java:301)
at org.openrdf.rio.ntriples.NTriplesParser.parse(NTriplesParser.java:192)
at org.openrdf.http.client.BackgroundGraphResult.run(BackgroundGraphResult.java:124)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

con.remove(statement) fails with a NullPointerException

con.remove(statement) fails with a following exception stack trace
The same behavior is seen for con.remove(statement, context) as well

java.lang.NullPointerException
at com.marklogic.semantics.sesame.client.MarkLogicClientImpl.performRemove(MarkLogicClientImpl.java:301)
at com.marklogic.semantics.sesame.client.MarkLogicClient.sendRemove(MarkLogicClient.java:150)
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection.remove(MarkLogicRepositoryConnection.java:474)
at com.marklogic.sesame.functionaltests.MarkLogicRepositoryConnectionTest.testInsertRemove(MarkLogicRepositoryConnectionTest.java:948)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

User with only 'rest-reader' role able to execute update statements

  1. A user 'reader' with 'rest-reader', 'rest-extension-user' roles was created.
  2. testReaderRepository = new MarkLogicRepository("localhost", restPort, "reader", "reader", "DIGEST");
    testReaderRepository.initialize();
    testReaderCon = (MarkLogicRepositoryConnection) testReaderRepository.getConnection();
  3. testReaderCon.prepareUpdate("CREATE GRAPH ").execute(); creates a graph which is not expected as the user doesn't have rest-writer role.

Wrong exception thrown by con.prepareQuery()

The method con.prepareQuery() throws UnsupportedOperationException for non SPARQL language instead of UnsupportedQueryLanguageException. Other prepare methods throw the correct exception

URI string in Sesame

I am creating a case for this question so that we don't lose track of it.
Sesame doesn't allow creation of URI unless the character ':' is present in the uri string (org.openrdf.model.impl.URIImpl) . Marklogic does allow creation of contexts without ":". So, can this pose a problem in that all the graphs created through any other methods in MarkLogic should essentially have ':' so that they can be used within Sesame ?

setRuleSet() method for MarkLogicRepositoryConnection class

At this point, it looks like we don't have a way of setting default ruleset(s) for the database from within marklogic-sesame in the MarkLogicRepositoryConnection class. Something like

public void setRulesets(SPARQLRuleset ruleset...)
public SPARQLRuleset [] getRulesets()

I assume that in the method "public RepositoryResult getStatements(Resource subj, URI pred, Value obj, boolean includeInferred, Resource... contexts)", when includeInferred is set to true, it applies the default rule set on the triples and returns the statements. But there doesn't seem to be a way to set default ruleset(s) as of now.

con.size(null) throws a NullPointerException

con.size(null) should provide the number of triples without context. But it throws the following exception.

java.lang.NullPointerException
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection.size(MarkLogicRepositoryConnection.java:419)
at com.marklogic.sesame.functionaltests.MarkLogicRepositoryConnectionTest.testGetStatementsInSingleContext(MarkLogicRepositoryConnectionTest.java:1434)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

con.remove(uri, uri, null) fails with NullPointerException

con.remove(uri, uri, null ) fails (when object is a null object ) with the following exception stack trace

java.lang.NullPointerException
at com.marklogic.semantics.sesame.client.MarkLogicClientImpl.performRemove(MarkLogicClientImpl.java:291)
at com.marklogic.semantics.sesame.client.MarkLogicClient.sendRemove(MarkLogicClient.java:150)
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection.remove(MarkLogicRepositoryConnection.java:542)
at com.marklogic.sesame.functionaltests.MarkLogicRepositoryConnectionTest.testRemoveStatements(MarkLogicRepositoryConnectionTest.java:1166)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Adding triples of format ntriples fails

Adding triples of format ntriples fails with exception.
con.add(MarkLogicRepositoryConnectionTest.class.getResourceAsStream( "family-tree.nt"), "", RDFFormat.NTRIPLES, dirgraph);

com.marklogic.client.FailedRequestException: Local message: failed to apply resource at graphs: Internal Server Error. Server Message: XDMP-DOCBADCHAR: xdmp:nquad($body, $options) -- Unexpected character found: '' (0xfeff) at :1:0 . See the MarkLogic server error log for further detail.
at com.marklogic.client.impl.JerseyServices.checkStatus(JerseyServices.java:4600)
at com.marklogic.client.impl.JerseyServices.postResource(JerseyServices.java:3494)
at com.marklogic.client.impl.JerseyServices.mergeGraph(JerseyServices.java:5429)
at com.marklogic.client.impl.GraphManagerImpl.merge(GraphManagerImpl.java:207)
at com.marklogic.client.impl.GraphManagerImpl.merge(GraphManagerImpl.java:193)
at com.marklogic.semantics.sesame.client.MarkLogicClientImpl.performAdd(MarkLogicClientImpl.java:244)
at com.marklogic.semantics.sesame.client.MarkLogicClient.sendAdd(MarkLogicClient.java:138)
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection.add(MarkLogicRepositoryConnection.java:500)
at com.marklogic.sesame.functionaltests.MarkLogicRepositoryConnectionTest.testPrepareQuery1(MarkLogicRepositoryConnectionTest.java:1074)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Pagination fix in java client breaks SPARQL query execution

Sam's fix in java client regarding pagination seems to have broken 'MarkLogicClientimpl.java'

java.lang.Error: Unresolved compilation problem:
The method executeSelect(SPARQLQueryDefinition, T, long, Transaction) in the type SPARQLQueryManager is not applicable for the arguments (SPARQLQueryDefinition, InputStreamHandle, long, long, Transaction)

at com.marklogic.semantics.sesame.client.MarkLogicClientImpl.performSPARQLQuery(MarkLogicClientImpl.java:178)
at com.marklogic.semantics.sesame.client.MarkLogicClientImpl.performSPARQLQuery(MarkLogicClientImpl.java:159)
at com.marklogic.semantics.sesame.client.MarkLogicClient.sendTupleQuery(MarkLogicClient.java:92)
at com.marklogic.semantics.sesame.query.MarkLogicTupleQuery.evaluate(MarkLogicTupleQuery.java:55)
at com.marklogic.semantics.sesame.query.MarkLogicTupleQuery.evaluate(MarkLogicTupleQuery.java:50)
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection.getStatements(MarkLogicRepositoryConnection.java:269)
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection.size(MarkLogicRepositoryConnection.java:419)
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection.isEmpty(MarkLogicRepositoryConnection.java:445)
at com.marklogic.sesame.functionaltests.MarkLogicRepositoryConnectionTest.testAddDeleteInsert(MarkLogicRepositoryConnectionTest.java:1281)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

update examples subproject

example subproject should be updated to;

  • illustrate how to use marklogic-sesame-repisotory as a gradle dependency
  • provide code examples 'in situ'.
  • links to relevant javadocs

con.getStatements() doesn't return results when multiple contexts are provided

The following test fails at "assertEquals("there should be three statements", 3, count);". The returned value of count is zero.

@test
public void testGetStatementsInMultipleContexts()
throws Exception
{
testAdminCon.getStatements(null, homeTel, null, false);
testAdminCon.begin();
testAdminCon.add(micah, lname, micahlname, dirgraph1);
testAdminCon.add(micah, fname, micahfname, dirgraph1);
testAdminCon.add(micah, homeTel, micahhomeTel, dirgraph1);
testAdminCon.commit();
CloseableIteration<? extends Statement, RepositoryException> iter = testAdminCon.getStatements(null, null, null, false, dirgraph1, dirgraph);
try {
int count = 0;
while (iter.hasNext()) {
count++;
Statement st = iter.next();
logger.debug("Test 2" +st.getContext());
logger.debug("Test 2" +st.getObject().stringValue());
// we should have only statements from context2
assertThat(st.getContext(), is(equalTo((Resource)dirgraph1)));
}
assertEquals("there should be three statements", 3, count);
}
finally {
iter.close();
iter = null;
}
}

Aggregate SPARQL query outputs are URI's

Query :
"PREFIX demor: http://demo/resource#
PREFIX demov: http://demo/verb#
PREFIX vcard: http://www.w3.org/2006/vcard/ns#
SELECT (COUNT(?company) AS ?total)
WHERE {
?company a vcard:Organization .
?company demov:industry ?industry .
?company vcard:hasAddress/vcard:postal-code ?zip .
?company vcard:hasAddress/vcard:postal-code ?whatcode
}",

the expected output is "12"^^http://www.w3.org/2001/XMLSchema#unsignedLong but a <12> is returned. I assume this would be the case for other aggregate functions as well and also for all datatypes of data used within the aggregate function

Exception:
java.lang.AssertionError: expected:<"12"^^http://www.w3.org/2001/XMLSchema#unsignedLong> but was:<12>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:834)
at org.junit.Assert.assertEquals(Assert.java:118)
at org.junit.Assert.assertEquals(Assert.java:144)
at com.marklogic.sesame.functionaltests.MarkLogicRepositoryConnectionTest.testPrepareQuery1(MarkLogicRepositoryConnectionTest.java:1621)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

NullPointer exception thrown when context is mentioned as null in con.add()

NullPointerException thrown when context is mentioned as null . It inserts fine into default graph when no argument is provided.

testAdminCon.add(ir, "", RDFFormat.TURTLE,null);

java.lang.NullPointerException
at com.marklogic.semantics.sesame.client.MarkLogicClientImpl.performAdd(MarkLogicClientImpl.java:243)
at com.marklogic.semantics.sesame.client.MarkLogicClient.sendAdd(MarkLogicClient.java:142)
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection.add(MarkLogicRepositoryConnection.java:508)
at com.marklogic.sesame.functionaltests.MarkLogicRepositoryConnectionTest.testPrepareQuery2(MarkLogicRepositoryConnectionTest.java:1636)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

con.size() returning incorrect results

con.size() is expected to return the number of triples in the entire db (triples with or without contexts). But the result returned is incorrect. Upon checking 'MarkLogicTupleQuery.java', the value of pagelength has been hardcoded to 50 and all select queries now return only a maximum of 50 results.

con.prepareBooleanQuery(QueryLanguage.SPARQL, String query,String baseUri) doesn't work

The following triple is inserted into db. The Xquery version runs and provides “true” which is expected whereas the method in Sesame returns false. I just want to be sure if the Xquery and java method are meant to have the same functionality. If so, then this might be an issue.

sem:triple
sem:subject
http://marklogic.com/baseball/players#119
/sem:subject
sem:predicate
http://marklogic.com/baseball/players#team
/sem:predicate
sem:object
http://marklogic.com/baseball/rules#Tigers
/sem:object
/sem:triple

XQuery:

xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics" at "MarkLogic/semantics.xqy";
let $query := '
PREFIX bb: http://marklogic.com/baseball/players#
ASK FROM http://marklogic.com/Graph1
WHERE
{
<players#119> <players#team> <rules#Tigers>.
}
'
let $boolean := sem:sparql($query, (), "base=http://marklogic.com/baseball/")
return $boolean

Sesame:

String query1 = "PREFIX bb: http://marklogic.com/baseball/players#"+
" ASK FROM http://marklogic.com/Graph1"+
" WHERE"+
" {"+
" <players#119> <players#team> <rules#Tigers>."+
" }";

boolean result1 = testAdminCon.prepareBooleanQuery(QueryLanguage.SPARQL, query1,"http://marklogic.com/baseball/").evaluate();

Wrong exceptions thrown by different methods

This bug tracks all the scenarios where the exceptions thrown in marklogic-sesame are not the ones specified in the spec but rather the one thrown by the ML client.

  1. As per spec, 'IllegalArgumentException' should be thrown by con.prepare*Query()
    for example for con.prepareGraphQuery() if a graph query is not provided (DESCRIBE or CONSTRUCT), IllegalArgumentException should be thrown. Right now, a different exception is thrown whenever a wrong query is passed
  2. If the SPARQL query has syntax errors, 'MalformedQueryException' should be thrown but right now, we throw the exception returned by the ML client.
  3. Running update statement with user with only rest-reader role should throw "UpdateExecutionException".
    "testReaderCon.prepareUpdate("CREATE GRAPH ").execute();"
  4. Adding malformed .ttl file should throw RDFParseException

The overloaded prepareQuery() methods calling the wrong methods

  1. In MarkLogicRepositoryConnection.java, each of the below prepareQuery methods call prepareTupleQuery instead of the method " public MarkLogicQuery prepareQuery(QueryLanguage queryLanguage, String queryString, String baseURI)".

  2. Also the returned instance of type 'Query' or 'MarkLogicQuery' is not executable (as in no execute() method unlike instances of TupleQuery etc)

    // prepareQuery entrypoint
    @OverRide
    public Query prepareQuery(String queryString) throws RepositoryException, MalformedQueryException {
    return prepareTupleQuery(QueryLanguage.SPARQL, queryString, null);
    }
    @OverRide
    public Query prepareQuery(String queryString, String baseURI) throws RepositoryException, MalformedQueryException {
    return prepareTupleQuery(QueryLanguage.SPARQL, queryString, baseURI);
    }
    @OverRide
    public Query prepareQuery(QueryLanguage queryLanguage, String queryString) throws RepositoryException, MalformedQueryException {
    return prepareTupleQuery(queryLanguage, queryString, null);
    }

Support for zip and gzip files

Sesame supports adding zip and gzip files using add(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) method. Are we planning on supporting them as well ?

provide write/read cache

Better write performance is achieved using an internal write cache, which batches up and periodically flushes statements to ML. For symmetry we already provide a BackgroundResults cache for reading from SPARQL results.

Different behavior between Sesame and marklogic-sesame for methods con.size() and con.getStatements() when context is explicitly specified as 'null'

As per Sesame, when ‘null’ is explicitly specified as context in getStatement(), it returns the statements that don’t have a context associated with it . I believe that this is the case for con.size() as well. The following snippet is from a test case for Sesame project.

// get statements with either no context or context2
CloseableIteration<? extends Statement, RepositoryException> iter = testCon.getStatements(null, null, null, false, null, context2);

con.remove(Iteration itr) doesn't work

The following tests fails in the final assert (Assert.assertEquals(0L,testAdminCon.size())) which is expected to succeed as the con.remove(Iteration itr) is expected to remove the entire contents of the db

@Test
public void testRemoveStatementIteration()
    throws Exception
{
    testAdminCon.begin();
    testAdminCon.add(fei, fname, feifname, dirgraph);
    testAdminCon.add(fei, lname, feilname, dirgraph);
    testAdminCon.add(fei, email, feiemail, dirgraph);
    testAdminCon.commit();

    Assert.assertEquals(3L,testAdminCon.size());

    Iteration<? extends Statement, RepositoryException> iter = testAdminCon.getStatements(null, null,
            null, false);

    testAdminCon.remove(iter);
    Assert.assertEquals(0L,testAdminCon.size());
}

Handling different input conditions in query.evaluate(int, int)

  1. For the method query.evaluate (int, int), if either start or pageLength or both are negative, the entire result set is returned. Is that an expected behavior or should an error be thrown ?
  2. Also if pageLength is out of bounds (as in size of result set is 10, start is 8 and pageLength is 5), results 8, 9 and 10 are returned with no errors thrown. IS that an expected behavior as well ?

Better handling when subject, predicate or object is null in con.add(Statement st, Context ct) and con.add(Resource r, URI u, Value v)

When subject, predicate or object is null in con.add(Statement st, Context ct) and con.add(Resource r, URI u, Value v) , a null pointer exception is thrown. Just wanted to check if we may want to handle it better may be wrap the exception along with a more clearer message

java.lang.NullPointerException
at com.marklogic.semantics.sesame.client.MarkLogicClientImpl.performAdd(MarkLogicClientImpl.java:263)
at com.marklogic.semantics.sesame.client.MarkLogicClient.sendAdd(MarkLogicClient.java:145)
at com.marklogic.semantics.sesame.MarkLogicRepositoryConnection.add(MarkLogicRepositoryConnection.java:521)
at com.marklogic.sesame.functionaltests.MarkLogicRepositoryConnectionTest.testPrepareTupleQuery1(MarkLogicRepositoryConnectionTest.java:403)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Unable to select triples inserted from Query console

The triples inserted from query console are not returned using 'SELECT' query from within Sesame.

Steps:

  1. Run INSERT DATA { GRAPH http://abcd { "fbefbj".} } in Queryconsole.
  2. URI ur = vf.createURI("http://abcd");
    logger.debug("Size of abcd is"+ testAdminCon.size(ur));

returns the size as zero. The query executed from Sesame is "SELECT * WHERE { GRAPH http://abcd {?s ?p ?o .} }" returns an empty result set but which as expected returns the result set when run from Query console.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.