Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-451 Add support for MSDL/GRAPH Dictionary in HDT verify #452

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ default boolean supportsLanguageOfId() {
return false;
}

/**
* @return if the dictionary is an MSD. if so, {@link #getObjects()} can't
* be used and the {@link #getAllObjects()} method should be used.
*/
default boolean isMultiSectionDictionary() {
return false;
}

/**
* Returns whether the dictionary supports graphs
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,11 @@ public void reset() {
}
}

@Override
public boolean isMultiSectionDictionary() {
return true;
}

@Override
public OptimizedExtractor createOptimizedMapExtractor() {
return new MultDictionaryPFCOptimizedExtractor(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,11 @@ public OptimizedExtractor createOptimizedMapExtractor() {
return new MultipleSectionDictionaryLangPFCOptimizedExtractor(this);
}

@Override
public boolean isMultiSectionDictionary() {
return true;
}

public int getObjectsSectionCount() {
return objectIdLocationsSec.length;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.beust.jcommander.Parameter;
import com.beust.jcommander.internal.Lists;
import com.the_qa_company.qendpoint.core.dictionary.DictionarySection;
import com.the_qa_company.qendpoint.core.dictionary.impl.MultipleBaseDictionary;
import com.the_qa_company.qendpoint.core.exceptions.NotFoundException;
import com.the_qa_company.qendpoint.core.hdt.HDT;
import com.the_qa_company.qendpoint.core.hdt.HDTManager;
Expand Down Expand Up @@ -237,7 +236,7 @@ public void exec() throws Throwable {
try (HDT hdt = hdtl) {
boolean error;
long count = 0;
if (hdt.getDictionary() instanceof MultipleBaseDictionary) {
if (hdt.getDictionary().isMultiSectionDictionary()) {
colorTool.log("Checking subject entries");
error = checkDictionarySectionOrder(binary, unicode, colorTool, "subject",
hdt.getDictionary().getSubjects(), console);
Expand Down Expand Up @@ -279,6 +278,12 @@ public void exec() throws Throwable {
hdt.getDictionary().getShared(), console);
count += hdt.getDictionary().getShared().getNumberOfElements();
}
if (hdt.getDictionary().supportGraphs()) {
colorTool.log("Checking graph entries");
error |= checkDictionarySectionOrder(binary, unicode, colorTool, "graph",
hdt.getDictionary().getGraphs(), console);
count += hdt.getDictionary().getGraphs().getNumberOfElements();
}

if (error) {
colorTool.error("This HDT isn't valid", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,10 @@
import com.the_qa_company.qendpoint.utils.sail.SourceSailConnectionWrapper;
import jakarta.json.Json;
import jakarta.json.stream.JsonGenerator;
import org.eclipse.rdf4j.model.Literal;
import org.eclipse.rdf4j.model.Namespace;
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.model.ValueFactory;
import org.eclipse.rdf4j.model.base.CoreDatatype;
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
import org.eclipse.rdf4j.model.util.Values;
import org.eclipse.rdf4j.query.*;
import org.eclipse.rdf4j.query.algebra.Var;
import org.eclipse.rdf4j.query.algebra.helpers.AbstractQueryModelVisitor;
import org.eclipse.rdf4j.query.explanation.Explanation;
import org.eclipse.rdf4j.query.explanation.GenericPlanNode;
import org.eclipse.rdf4j.query.parser.*;
Expand Down Expand Up @@ -104,9 +98,6 @@ public CompiledSailOptions getOptions() {

/**
* reindex all the lucene sails of this repository
*
* @throws Exception any exception returned by
* {@link org.eclipse.rdf4j.sail.lucene.LuceneSail#reindex()}
*/
public void reindexLuceneSails() {
compiledSail.reindexLuceneSails();
Expand Down Expand Up @@ -762,15 +753,17 @@ public void executeUpdate(String sparqlQuery, int timeout, OutputStream out) {
executeUpdate(sparqlQuery, timeout, out, null);

}

/**
* execute a sparql update query
*
* @param sparqlQuery the query
* @param timeout query timeout
* @param out the output stream, can be null
* @param sparqlQuery the query
* @param timeout query timeout
* @param out the output stream, can be null
* @param customConnection custom connection to use
*/
public void executeUpdate(String sparqlQuery, int timeout, OutputStream out, RepositoryConnection customConnection) {
public void executeUpdate(String sparqlQuery, int timeout, OutputStream out,
RepositoryConnection customConnection) {
// logger.info("Running update query:"+sparqlQuery);
sparqlQuery = applyPrefixes(sparqlQuery);
sparqlQuery = Pattern.compile("MINUS \\{(?s).*?}\\n {2}}").matcher(sparqlQuery).replaceAll("");
Expand Down
Loading