Skip to content

Commit

Permalink
Fix schema building with patch store
Browse files Browse the repository at this point in the history
  • Loading branch information
kerim1 committed Oct 25, 2022
1 parent 5349c39 commit ceb9905
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
import java.util.Optional;

public class RebuildSchemaTask extends Task {
private final DataSetRepository dataSetRepository;
Expand All @@ -20,8 +21,16 @@ public RebuildSchemaTask(DataSetRepository dataSetRepository) {

@Override
public void execute(Map<String, List<String>> parameters, PrintWriter output) throws Exception {
for (DataSet dataSet : dataSetRepository.getDataSets()) {
rebuildSchemaFor(dataSet, output);
if (parameters.isEmpty()) {
for (DataSet dataSet : dataSetRepository.getDataSets()) {
rebuildSchemaFor(dataSet, output);
}
} else {
if (parameters.containsKey("userId") && parameters.containsKey("dataSetId")) {
Optional<DataSet> dataSet = dataSetRepository.unsafeGetDataSetWithoutCheckingPermissions(
parameters.get("userId").get(0), parameters.get("dataSetId").get(0));
dataSet.ifPresent(set -> rebuildSchemaFor(set, output));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public void put(String subject, String predicate, Direction direction, boolean i
(direction == OUT ? "1" : "0") + "\n" +
(valueType == null ? "" : valueType) + "\n" +
(language == null ? "" : language) + "\n" +
(graph == null ? "" : graph) + "\n" +
object;
object + "\n" +
(graph == null ? "" : graph);

bdbWrapper.delete(subject + "\n" + (!isAssertion ? 1 : 0), value);
bdbWrapper.put(subject + "\n" + (isAssertion ? 1 : 0), value);
Expand Down Expand Up @@ -76,18 +76,20 @@ public Stream<CursorQuad> retrieveChanges() {
}

public CursorQuad makeCursorQuad(String subject, boolean assertions, String value) {
String[] parts = value.split("\n", 6);
String[] parts = value.split("\n", 5);
Direction direction = parts[1].charAt(0) == '1' ? OUT : IN;
ChangeType changeType = assertions ? ChangeType.ASSERTED : ChangeType.RETRACTED;
int objectGraphIdx = parts[4].lastIndexOf('\n');
return CursorQuad.create(
subject,
parts[0],
direction,
changeType,
parts[5],
parts[4].substring(0, objectGraphIdx),
parts[2].isEmpty() ? null : parts[2],
parts[3].isEmpty() ? null : parts[3],
parts[4].isEmpty() ? null : parts[4],
parts[4].substring(objectGraphIdx + 1).isEmpty() ?
null : parts[4].substring(objectGraphIdx + 1),
""
);
}
Expand All @@ -96,7 +98,7 @@ public void close() {
try {
bdbWrapper.close();
} catch (Exception e) {
LOG.error("Exception closing BdbpatchVersionStore", e);
LOG.error("Exception closing BdbPatchVersionStore", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import static com.google.common.base.Objects.equal;

public class Type {
private String name;
private Map<String, Predicate> predicates = new HashMap<>();
private final String name;
private final Map<String, Predicate> predicates;
private long subjectsWithThisType = 0;
private final BiFunction<String, Direction, Predicate> predicateMaker = (name, direction) -> {
Predicate predicate = new Predicate(name, direction);
Expand Down

0 comments on commit ceb9905

Please sign in to comment.