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

Merge join #428

Merged
merged 7 commits into from
Jan 16, 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ release/RELEASE_OUTPUT.md
.idea
data
.nvmrc
wikidata
qendpoint-store/wdbench-indexes
wdbench-results
15 changes: 14 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@
<maven.compiler.target>17</maven.compiler.target>
</properties>

<repositories>
<repository>
<id>oss.sonatype.org-snapshot</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
Comment on lines +72 to +83
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have note published a new milestone build of RDF4J 5.0.0 yet, so we need to use the snapshots repo in the meantime.


<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
Expand Down Expand Up @@ -205,4 +218,4 @@
<system>Github</system>
<url>https://github.com/the-qa-company/qEndpoint/issues</url>
</issueManagement>
</project>
</project>
17 changes: 15 additions & 2 deletions qendpoint-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,25 @@
</license>
</licenses>

<repositories>
<repository>
<id>oss.sonatype.org-snapshot</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<properties>
<common_codec.version>1.15</common_codec.version>
<json_simple.version>1.1.1</json_simple.version>
<junit.version>4.13.2</junit.version>
<lwjgl.version>3.3.1</lwjgl.version>
<rdf4j.version>4.2.3</rdf4j.version>
<rdf4j.version>5.0.0-SNAPSHOT</rdf4j.version>
<spring.version>3.0.2</spring.version>
<logback.version>1.4.5</logback.version>

Expand Down Expand Up @@ -132,4 +145,4 @@
</plugins>
</build>

</project>
</project>
19 changes: 5 additions & 14 deletions qendpoint-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

<parent>
<groupId>com.the-qa-company</groupId>
<artifactId>
qendpoint-parent
</artifactId>
<artifactId>qendpoint-parent</artifactId>
<version>1.14.1</version>
</parent>

Expand All @@ -46,17 +44,14 @@
<json_simple.version>1.1.1</json_simple.version>
<junit.version>4.13.2</junit.version>
<lwjgl.version>3.3.1</lwjgl.version>
<rdf4j.version>4.2.3</rdf4j.version>
<spring.version>2.7.5</spring.version>
<logback.version>1.4.5</logback.version>
<roaringbitmap.version>0.9.44</roaringbitmap.version>

<jena.version>4.3.2</jena.version>
<slf4j.version>1.7.30</slf4j.version>

<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

Expand Down Expand Up @@ -99,18 +94,14 @@
</dependency>
<dependency>
<groupId>pl.pragmatists</groupId>
<artifactId>
JUnitParams
</artifactId>
<artifactId>JUnitParams</artifactId>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.tukaani</groupId>
<artifactId>xz</artifactId>
<version>
1.6
</version>
<version>1.6</version>
</dependency>
<dependency>
<groupId>com.beust</groupId>
Expand All @@ -123,4 +114,4 @@
<version>${roaringbitmap.version}</version>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package com.the_qa_company.qendpoint.core.enums;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
Expand Down Expand Up @@ -78,6 +80,24 @@ public enum TripleComponentOrder {
this.mask = mask;
}

/**
* Search for an acceptable value in a map of orders
*
* @param flags flags to search the value
* @param map map
* @param <T> value type
* @return find value, null for no matching value
*/
public static <T, Z extends TripleComponentOrder> List<Z> fetchAllBestForCfg(int flags, Map<Z, T> map) {
ArrayList<Z> ret = new ArrayList<>();
for (Map.Entry<Z, T> e : map.entrySet()) {
if ((e.getKey().mask & flags) != 0) {
ret.add(e.getKey());
}
}
return ret;
}

/**
* Search for an acceptable value in a map of orders
*
Expand Down Expand Up @@ -123,4 +143,5 @@ public TripleComponentRole getPredicateMapping() {
public TripleComponentRole getObjectMapping() {
return objectMapping;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ public void mapFromHDT(File f, long offset, ProgressListener listener) throws IO
String hdtFormat = ci.getFormat();
if (!hdtFormat.equals(HDTVocabulary.HDT_CONTAINER) && !hdtFormat.equals(HDTVocabulary.HDT_CONTAINER_2)) {
throw new IllegalFormatException("This software (v" + HDTVersion.HDT_VERSION + ".x.x | v"
+ HDTVersion.HDT_VERSION_2 + ".x.x) cannot open this version of HDT File (" + hdtFormat + ")");
+ HDTVersion.HDT_VERSION_2 + ".x.x) cannot open this version of HDT File hdtFileName:"
+ hdtFileName + " format:" + hdtFormat + "");
}

input.printIndex("HDT Header");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serial;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -21,10 +23,14 @@
*
* @author Antoine Willerval
*/
public class QEPComponent implements Cloneable {
record SharedElement(long id, DictionarySectionRole role, QEPDataset dataset, String debugMapped) {}
public class QEPComponent implements Cloneable, Serializable {
@Serial
private static final long serialVersionUID = 6621230579376315429L;

record PredicateElement(long id, QEPDataset dataset) {}
record SharedElement(long id, DictionarySectionRole role, QEPDataset dataset, String debugMapped)
implements Serializable {}

record PredicateElement(long id, QEPDataset dataset) implements Serializable {}

private static final Logger logger = LoggerFactory.getLogger(QEPComponent.class);

Expand All @@ -34,7 +40,7 @@ record PredicateElement(long id, QEPDataset dataset) {}
RDFNodeType rdfNodeType;
Optional<CharSequence> language;
CharSequence datatype;
final QEPCore core;
transient final QEPCore core;

private QEPComponent(QEPComponent other) {
this.predicateIds = new HashMap<>(other.predicateIds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.the_qa_company.qendpoint.core.options.HDTOptions;
import com.the_qa_company.qendpoint.core.storage.converter.NodeConverter;
import com.the_qa_company.qendpoint.core.storage.iterator.CatQueryCloseable;
import com.the_qa_company.qendpoint.core.storage.iterator.CloseableIterator;
import com.the_qa_company.qendpoint.core.storage.iterator.QueryCloseableIterator;
import com.the_qa_company.qendpoint.core.storage.merge.QEPCoreMergeThread;
import com.the_qa_company.qendpoint.core.storage.search.QEPComponentTriple;
Expand All @@ -31,6 +32,8 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.Serial;
import java.io.Serializable;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
Expand Down Expand Up @@ -79,6 +82,7 @@
* @author Antoine Willerval
*/
public class QEPCore implements AutoCloseable {

private static final Logger logger = LoggerFactory.getLogger(QEPCore.class);
/**
* the max size of a dataset id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import java.io.Closeable;
import java.io.IOException;
import java.io.Serial;
import java.io.Serializable;
import java.nio.file.Path;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
Expand All @@ -26,7 +28,10 @@
* @author Antoine Willerval
* @see QEPCore
*/
public class QEPDataset implements Closeable {
public class QEPDataset implements Closeable, Serializable {

@Serial
private static final long serialVersionUID = 7525689572432598258L;
Comment on lines +31 to +34
Copy link
Contributor Author

@hmottestad hmottestad Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some requirements for serializable classes in RDF4J that were not explicitly tested for. From what I remember when migrating the code to RDF4J 5.0.0 this class is used transitively from within a query plan because it is used in QEPComponent which is used in QEPCoreBNode which is used in StatementPattern through Var.


public record ComponentFind(QEPDataset dataset, TripleComponentRole role, long id, long pid) {
public boolean isFind() {
Expand Down Expand Up @@ -261,7 +266,7 @@ public void setComponentInDelta(TripleComponentRole role, long component) {
public QueryCloseableIterator search(CharSequence subject, CharSequence predicate, CharSequence object)
throws QEPCoreException {
QEPDatasetContext ctx = createContext();
return search(ctx, subject, predicate, object).attach(ctx);
return (QueryCloseableIterator) search(ctx, subject, predicate, object).attach(ctx);
}

Comment on lines 266 to 271
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may not be the correct fix, but it was the best I could manage when migrating to RDF4J 5.0.0.

/**
Expand All @@ -278,7 +283,7 @@ public QueryCloseableIterator search(CharSequence subject, CharSequence predicat
public QueryCloseableIterator search(QEPComponent subject, QEPComponent predicate, QEPComponent object)
throws QEPCoreException {
QEPDatasetContext ctx = createContext();
return search(ctx, subject, predicate, object).attach(ctx);
return (QueryCloseableIterator) search(ctx, subject, predicate, object).attach(ctx);
}

/**
Expand All @@ -292,7 +297,7 @@ public QueryCloseableIterator search(QEPComponent subject, QEPComponent predicat
*/
public QueryCloseableIterator search(QEPComponentTriple pattern) throws QEPCoreException {
QEPDatasetContext ctx = createContext();
return search(ctx, pattern).attach(ctx);
return (QueryCloseableIterator) search(ctx, pattern).attach(ctx);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,33 @@
* @param <T>
* @param <E>
*/
public class CloseableAttachIterator<T, E extends Exception> implements CloseableIterator<T, E> {
public class CloseableAttachIterator<T extends RuntimeException> implements CloseableIterator<T> {
@SafeVarargs
public static <T, E extends Exception> CloseableIterator<T, E> of(CloseableIterator<T, E> it,
AutoCloseableGeneric<E>... closeables) {
public static <T> CloseableIterator<T> of(CloseableIterator<T> it,
AutoCloseableGeneric<? extends RuntimeException>... closeables) {
if (closeables.length == 0) {
return it;
}
return new CloseableAttachIterator<>(it, closeables);
return new CloseableAttachIterator(it, closeables);
}

private final CloseableIterator<T, E> handle;
private final List<AutoCloseableGeneric<E>> closeables;
private final CloseableIterator<T> handle;
private final List<AutoCloseableGeneric<RuntimeException>> closeables;

@SafeVarargs
private CloseableAttachIterator(CloseableIterator<T, E> handle, AutoCloseableGeneric<E>... closeableGenerics) {
private CloseableAttachIterator(CloseableIterator<T> handle,
AutoCloseableGeneric<RuntimeException>... closeableGenerics) {
this.handle = handle;
closeables = new ArrayList<>(List.of(closeableGenerics));
}

@Override
public void close() throws E {
public void close() {
try {
handle.close();
} catch (Error | Exception t) {
try {
AutoCloseableGeneric.<E>closeAll(closeables);
AutoCloseableGeneric.closeAll(closeables);
} catch (RuntimeException | Error err) {
err.addSuppressed(t);
throw err;
Expand All @@ -62,12 +63,6 @@ public void remove() {
handle.remove();
}

@Override
public CloseableIterator<T, E> attach(AutoCloseableGeneric<E> closeable) {
closeables.add(closeable);
return this;
}

@Override
public void forEachRemaining(Consumer<? super T> action) {
handle.forEachRemaining(action);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class CloseableAttachQueryIterator implements QueryCloseableIterator {

@SafeVarargs
public static QueryCloseableIterator of(QueryCloseableIterator it,
AutoCloseableGeneric<QEPCoreException>... closeables) {
AutoCloseableGeneric<? extends RuntimeException>... closeables) {
Objects.requireNonNull(it, "it can't be null!");
if (closeables.length == 0) {
return it;
Comment on lines 13 to 18
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again I'm not sure if this is the correct approach to fixing the issues when migrating to RDF4J 5.0.0.

Expand All @@ -21,11 +21,11 @@ public static QueryCloseableIterator of(QueryCloseableIterator it,
}

private final QueryCloseableIterator handle;
private final List<AutoCloseableGeneric<QEPCoreException>> closeables;
private final List<AutoCloseableGeneric<? extends RuntimeException>> closeables;

@SafeVarargs
private CloseableAttachQueryIterator(QueryCloseableIterator handle,
AutoCloseableGeneric<QEPCoreException>... closeableGenerics) {
AutoCloseableGeneric<? extends RuntimeException>... closeableGenerics) {
this.handle = handle;
closeables = new ArrayList<>(List.of(closeableGenerics));
}
Expand Down Expand Up @@ -68,7 +68,7 @@ public long estimateCardinality() {
}

@Override
public QueryCloseableIterator attach(AutoCloseableGeneric<QEPCoreException> closeable) {
public QueryCloseableIterator attach(AutoCloseableGeneric<? extends RuntimeException> closeable) {
closeables.add(closeable);
return this;
}
Expand Down
Loading
Loading