Skip to content

Commit

Permalink
Count old subject types
Browse files Browse the repository at this point in the history
  • Loading branch information
kerim1 committed Oct 18, 2022
1 parent b3844d9 commit a94e456
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ public void empty() {
}
}

public long count() {
return database.count();
}

public <U> KeyValueConverter<KeyT, ValueT, U> keyValueConverter(BiFunction<KeyT, ValueT, U> converter) {
return new CleanFilteringKeyValueConverter<>(converter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public OldSubjectTypesStore(BdbWrapper<String, String> bdbWrapper) throws DataSt
this.bdbWrapper = bdbWrapper;
}

public long size() {
return bdbWrapper.count();
}

public void put(String subject, String type, int version) throws DatabaseWriteException {
bdbWrapper.put(type, version + "\n" + subject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class StoreUpdater implements RdfProcessor {
private long prevCount;
private long prevTime;
private String logString;
private boolean hasOldSubjectTypes;

public StoreUpdater(BdbQuadStore quadStore, GraphStore graphStore,
BdbTypeNameStore typeNameStore, BdbPatchVersionStore patchVersionStore,
Expand Down Expand Up @@ -135,7 +136,7 @@ private void putQuad(String subject, String predicate, Direction direction, Stri
updatedPerPatchStore.put(version, subject);
graphStore.put(graph, subject);

if (predicate.equals(RDF_TYPE)) {
if (hasOldSubjectTypes && predicate.equals(RDF_TYPE)) {
for (int v = 0; v < version; v++) {
oldSubjectTypesStore.delete(subject, object, v);
}
Expand Down Expand Up @@ -222,6 +223,7 @@ public void start(int index) throws RdfProcessingFailedException {
startTransactions();
logString = "Processed {} triples ({} triples/s)";
count = 0; // reset the count to make sure the right amount of imported triples are logged.
hasOldSubjectTypes = oldSubjectTypesStore.size() > 0;
}

private void startTransactions() {
Expand Down

0 comments on commit a94e456

Please sign in to comment.