Skip to content

Commit

Permalink
[skip ci] wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ate47 committed Feb 16, 2024
1 parent ffdee23 commit 98c9eef
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -43,6 +46,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.Objects;

public class Utility {

Expand Down Expand Up @@ -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);
}
Expand All @@ -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<Statement> 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 {
Expand Down

0 comments on commit 98c9eef

Please sign in to comment.