diff --git a/qendpoint-store/src/main/java/com/the_qa_company/qendpoint/store/EndpointStoreConnection.java b/qendpoint-store/src/main/java/com/the_qa_company/qendpoint/store/EndpointStoreConnection.java index fcdab7c5..4724fb76 100644 --- a/qendpoint-store/src/main/java/com/the_qa_company/qendpoint/store/EndpointStoreConnection.java +++ b/qendpoint-store/src/main/java/com/the_qa_company/qendpoint/store/EndpointStoreConnection.java @@ -318,6 +318,7 @@ public void removeNamespaceInternal(String prefix) throws SailException { @Override protected void clearInternal(Resource... contexts) throws SailException { getCurrentConnectionWrite().clear(contexts); + assignBitMapDeletes(new TripleID(), null, null, null); } @Override @@ -533,7 +534,7 @@ private void assignBitMapDeletes(TripleID tripleID, Resource subj, IRI pred, Val if (this.endpoint.isMerging()) { this.endpoint.getTempDeleteBitMap(sorder).set(index, true); } - if (order == TripleComponentOrder.SPO) { + if (order == TripleComponentOrder.SPO && subj != null && pred != null && obj != null) { notifyStatementRemoved(this.endpoint.getValueFactory().createStatement(subj, pred, obj)); } } diff --git a/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/EndpointMultIndexSPARQL11QueryComplianceTest.java b/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/EndpointMultIndexSPARQL11QueryComplianceTest.java index e93e8cb7..b91facd1 100644 --- a/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/EndpointMultIndexSPARQL11QueryComplianceTest.java +++ b/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/EndpointMultIndexSPARQL11QueryComplianceTest.java @@ -94,7 +94,7 @@ protected Repository newRepository() throws Exception { EnumSet.of(TripleComponentOrder.SPO, TripleComponentOrder.OPS, TripleComponentOrder.PSO)); Path fileName = Path.of(hdtStore.toAbsolutePath() + "/" + EndpointStoreTest.HDT_INDEX_NAME); if (this.hdt == null) { - hdt = Utility.createTempHdtIndex(tempDir.resolve("test.nt").toAbsolutePath().toString(), true, false, spec); + hdt = Utility.createTempHdtIndex(hdtStore.resolve("test.nt").toAbsolutePath().toString(), true, false, spec); } assert hdt != null; diff --git a/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/EndpointMultIndexSPARQL11UpdateComplianceTest.java b/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/EndpointMultIndexSPARQL11UpdateComplianceTest.java index 778cd259..9fdb3e9c 100644 --- a/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/EndpointMultIndexSPARQL11UpdateComplianceTest.java +++ b/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/EndpointMultIndexSPARQL11UpdateComplianceTest.java @@ -53,7 +53,7 @@ protected Repository newRepository() throws Exception { HDTOptionsKeys.DICTIONARY_TYPE_VALUE_MULTI_OBJECTS, HDTOptionsKeys.BITMAPTRIPLES_INDEX_OTHERS, EnumSet.of(TripleComponentOrder.SPO, TripleComponentOrder.OPS, TripleComponentOrder.PSO)); Path fileName = Path.of(hdtStore.toAbsolutePath() + "/" + EndpointStoreTest.HDT_INDEX_NAME); - try (HDT hdt = Utility.createTempHdtIndex(tempDir.resolve("test.nt").toAbsolutePath().toString(), true, false, spec)) { + try (HDT hdt = Utility.createTempHdtIndex(hdtStore.resolve("test.nt").toAbsolutePath().toString(), true, false, spec)) { assert hdt != null; hdt.saveToHDT(fileName, null); } diff --git a/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/EndpointSPARQL11QueryComplianceTest.java b/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/EndpointSPARQL11QueryComplianceTest.java index d8d45276..5ab3c291 100644 --- a/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/EndpointSPARQL11QueryComplianceTest.java +++ b/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/EndpointSPARQL11QueryComplianceTest.java @@ -23,7 +23,6 @@ import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -87,7 +86,7 @@ protected Repository newRepository() throws Exception { HDTOptions spec = HDTOptions.of(HDTOptionsKeys.DICTIONARY_TYPE_KEY, HDTOptionsKeys.DICTIONARY_TYPE_VALUE_MULTI_OBJECTS); if (this.hdt == null) { - hdt = Utility.createTempHdtIndex(tempDir.resolve("temp.nt").toAbsolutePath().toString(), true, false, spec); + hdt = Utility.createTempHdtIndex(hdtStore.resolve("temp.nt").toAbsolutePath().toString(), true, false, spec); } assert hdt != null; @@ -96,7 +95,7 @@ protected Repository newRepository() throws Exception { endpoint = new EndpointStore(hdtStore.toAbsolutePath() + "/", EndpointStoreTest.HDT_INDEX_NAME, spec, nativeStore.toAbsolutePath() + "/", true); // endpoint.setThreshold(2); - return new SailRepository(endpoint); + return Utility.convertToDumpRepository(new SailRepository(Utility.convertToDumpSail(endpoint))); } HDT hdt; diff --git a/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/Utility.java b/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/Utility.java index 2e805247..730fd92a 100644 --- a/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/Utility.java +++ b/qendpoint-store/src/test/java/com/the_qa_company/qendpoint/store/Utility.java @@ -1,5 +1,7 @@ package com.the_qa_company.qendpoint.store; +import com.the_qa_company.qendpoint.model.HDTValue; +import org.eclipse.rdf4j.common.iteration.CloseableIteration; import org.eclipse.rdf4j.model.IRI; import org.eclipse.rdf4j.model.Resource; import org.eclipse.rdf4j.model.Statement; @@ -17,9 +19,10 @@ import org.eclipse.rdf4j.repository.Repository; import org.eclipse.rdf4j.repository.RepositoryConnection; import org.eclipse.rdf4j.repository.RepositoryException; +import org.eclipse.rdf4j.repository.RepositoryResult; import org.eclipse.rdf4j.repository.base.RepositoryConnectionWrapper; import org.eclipse.rdf4j.repository.base.RepositoryWrapper; -import org.eclipse.rdf4j.repository.sail.SailRepository; +import org.eclipse.rdf4j.repository.util.Repositories; import org.eclipse.rdf4j.rio.RDFFormat; import org.eclipse.rdf4j.rio.RDFWriter; import org.eclipse.rdf4j.rio.Rio; @@ -43,6 +46,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Arrays; +import java.util.Objects; public class Utility { @@ -177,20 +181,26 @@ private static void writeTempRDF(File file) throws IOException { public static Sail convertToDumpSail(Sail sail) { return new SailWrapper(sail) { + private static String toInfoVal(Value value) { + if (value instanceof HDTValue hv) { + return value + "(" + hv.getHDTPosition() + "/" + hv.getHDTId() + ")"; + } + return Objects.toString(value); + } @Override public SailConnection getConnection() throws SailException { return new SailConnectionWrapper(super.getConnection()) { @Override public void addStatement(Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException { - System.out.printf("ADD : (%s, %s, %s %s)\n", subj, pred, obj, Arrays.toString(contexts)); + System.out.printf("ADD : (%s, %s, %s %s)\n", toInfoVal(subj), toInfoVal(pred), toInfoVal(obj), Arrays.toString(contexts)); super.addStatement(subj, pred, obj, contexts); } @Override public void removeStatement(UpdateContext modify, Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException { - System.out.printf("REMOVE[%s] : (%s, %s, %s %s)\n", modify, subj, pred, obj, + System.out.printf("REMOVE[%s] : (%s, %s, %s %s)\n", modify, toInfoVal(subj), toInfoVal(pred), toInfoVal(obj), Arrays.toString(contexts)); super.removeStatement(modify, subj, pred, obj, contexts); } @@ -206,6 +216,13 @@ public void clear(Resource... contexts) throws SailException { } public static Repository convertToDumpRepository(Repository repository) { + Repositories.consumeNoTransaction(repository, conn -> { + System.out.println("--All statements--"); + try (RepositoryResult statements = conn.getStatements(null, null, null, false)) { + statements.forEach(System.out::println); + } + System.out.println("------------------"); + }); return new RepositoryWrapper(repository) { @Override public void shutDown() throws RepositoryException {