Skip to content

Commit

Permalink
fix latest orders and patch pom.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
ate47 committed Dec 2, 2024
1 parent 2e4d655 commit c79073b
Show file tree
Hide file tree
Showing 9 changed files with 397 additions and 111 deletions.
7 changes: 6 additions & 1 deletion qendpoint-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<rdf4j.version>5.0.2</rdf4j.version>
<spring.version>3.4.0</spring.version>
<logback.version>1.5.6</logback.version>

<gson.version>2.11.0</gson.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
Expand Down Expand Up @@ -112,6 +112,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>
<!-- v1.15 is needed for Jena 3.14+ - copied from org.apache.jena:jena:pom -->
<dependency>
<groupId>commons-codec</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import com.the_qa_company.qendpoint.store.EndpointStoreUtils;
import com.the_qa_company.qendpoint.utils.FileUtils;
import com.the_qa_company.qendpoint.utils.RDFStreamUtils;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.model.util.Values;
import org.eclipse.rdf4j.repository.RepositoryConnection;
Expand All @@ -34,8 +36,6 @@
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebInputException;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
Expand Down
4 changes: 2 additions & 2 deletions qendpoint-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<logback.version>1.5.6</logback.version>
<roaringbitmap.version>0.9.44</roaringbitmap.version>

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

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -75,7 +75,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.21</version>
<version>1.26.0</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public GraphFilteringTripleId(IteratorTripleID iterator, long[] graphIds) {
this.graphIds = graphIds;
}


@Override
public void goToStart() {
throw new NotImplementedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,35 @@ default boolean isLastTriplePositionBoundToOrder() {

/**
* goto the next subject >= id
*
* @param id id
* @return true if the next subject == id
* @see #canGoToSubject() if can goto returns false, this function is not available
* @see #canGoToSubject() if can goto returns false, this function is not
* available
*/
default boolean gotoSubject(long id) {
return false;
}

/**
* goto the next predicate >= id
*
* @param id id
* @return true if the next predicate == id
* @see #canGoToPredicate() if can goto returns false, this function is not available
* @see #canGoToPredicate() if can goto returns false, this function is not
* available
*/
default boolean gotoPredicate(long id) {
return false;
}

/**
* goto the next object >= id
*
* @param id id
* @return true if the next object == id
* @see #canGoToObject() if can goto returns false, this function is not available
* @see #canGoToObject() if can goto returns false, this function is not
* available
*/
default boolean gotoObject(long id) {
return false;
Expand All @@ -126,12 +132,14 @@ default boolean gotoObject(long id) {
default boolean canGoToSubject() {
return false;
}

/**
* @return true if {@link #gotoPredicate(long)} can be used, false otherwise
*/
default boolean canGoToPredicate() {
return false;
}

/**
* @return true if {@link #gotoObject(long)} can be used, false otherwise
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,39 +272,50 @@ public boolean isLastTriplePositionBoundToOrder() {

private boolean gotoOrder(long id, TripleComponentRole role) {
switch (role) {
case SUBJECT -> {
if (patX != 0) {
return id == patX; // can't jump or already on the right element
}

patX = id;
findRange();
patX = 0;
case SUBJECT -> {
if (patX != 0) {
return id == patX; // can't jump or already on the right element
}

return true; // we know x exists because we are using
if (x >= id) {
return id == x;
}
case PREDICATE -> {
if (patY != 0) {
return id == patY; // can't jump or already on the right element
}

if (posY == nextY) {
return false; // no next element
}
x = id;
posY = adjY.find(x - 1);
posZ = adjZ.find(posY);
y = adjY.get(posY);
nextY = adjY.last(x - 1) + 1;
nextZ = adjZ.find(posY + 1);

long curr = this.adjY.get(posY);
return true; // we know x exists
}
case PREDICATE -> {
if (patY != 0) {
return id == patY; // can't jump or already on the right element
}

if (curr >= id) {
return curr == id;
}
if (posY + 1 == nextY) {
return false; // no next element
}
if (posY == nextY) {
return false; // no next element
}

long last = this.adjY.get(nextY - 1);
long curr = this.adjY.get(posY);

if (curr >= id) {
return curr == id;
}

boolean res;
boolean res;
if (posY + 1 == nextY) {
// no next element, go next X
x++;
posY = nextY;
nextY = adjY.findNext(posY) + 1;
y = adjY.get(posY);

res = false;
} else {
long last = this.adjY.get(nextY - 1);

if (last > id) {
// binary search between curr <-> last id
Expand All @@ -319,77 +330,79 @@ private boolean gotoOrder(long id, TripleComponentRole role) {
posY = -loc - 1;
y = adjY.get(posY);
}
} else if (last != id) {
// last < id - GOTO end + 1
posY = nextY;
res = false;
} else {
// last == id - GOTO last
posY = nextY - 1;
y = adjY.get(posY);
res = true;
if (last != id) {
// last < id - GOTO end + 1
posY = nextY;
res = false;
} else {
// last == id - GOTO last
posY = nextY - 1;
y = adjY.get(posY);
res = true;
}
nextY = adjY.findNext(posY) + 1;
}
}

nextY = adjY.findNext(posY) + 1;

// down to z/posZ/nextZ?
posZ = adjZ.find(posY, patZ);
nextZ = adjZ.findNext(posZ) + 1;
// down to z/posZ/nextZ?
posZ = adjZ.find(posY); // assert patZ != 0
nextZ = adjZ.findNext(posZ) + 1;

return res;
return res;
}
case OBJECT -> {
if (patZ != 0) {
return id == patZ; // can't jump or already on the right element
}
case OBJECT -> {
if (patZ != 0) {
return id == patZ; // can't jump or already on the right element
}

if (posZ == nextZ) {
return false; // no next element
}

long curr = this.adjZ.get(posZ);
if (posZ == nextZ) {
return false; // no next element
}

if (curr >= id) {
return curr == id;
}
if (posZ + 1 == nextZ) {
return false; // no next element
}
long curr = this.adjZ.get(posZ);

long last = this.adjZ.get(nextZ - 1);
if (curr >= id) {
return curr == id;
}
if (posZ + 1 == nextZ) {
return false; // no next element
}

long last = this.adjZ.get(nextZ - 1);

boolean res;
boolean res;

if (last > id) {
// binary search between curr <-> last id
long loc = this.adjZ.searchLoc(id, posZ + 1, nextZ - 2);
if (last > id) {
// binary search between curr <-> last id
long loc = this.adjZ.searchLoc(id, posZ + 1, nextZ - 2);

if (loc >= 0) { //match
res = true;
posZ = loc;
//z = id; // no need to compute the z, it is only used in next()
} else {
res = false;
posZ = -loc - 1;
//z = adjZ.get(posZ);
}
} else if (last != id) {
// last < id - GOTO end
posZ = nextZ;
res = false;
} else {
// last == id - GOTO last
posZ = nextZ - 1;
//z = adjZ.get(posZ);
if (loc >= 0) { // match
res = true;
posZ = loc;
// z = id; // no need to compute the z, it is only used in
// next()
} else {
res = false;
posZ = -loc - 1;
// z = adjZ.get(posZ);
}
} else if (last != id) {
// last < id - GOTO end
posZ = nextZ;
res = false;
} else {
// last == id - GOTO last
posZ = nextZ - 1;
// z = adjZ.get(posZ);
res = true;
}

nextZ = adjZ.findNext(posZ) + 1;
nextZ = adjZ.findNext(posZ) + 1;

return res;
}
default -> throw new NotImplementedException("goto " + role);
return res;
}
default -> throw new NotImplementedException("goto " + role);
}
}

Expand All @@ -402,6 +415,7 @@ public boolean gotoSubject(long id) {
public boolean gotoPredicate(long id) {
return gotoOrder(id, idx.getOrder().getPredicateMapping());
}

@Override
public boolean gotoObject(long id) {
return gotoOrder(id, idx.getOrder().getObjectMapping());
Expand All @@ -411,10 +425,12 @@ public boolean gotoObject(long id) {
public boolean canGoToSubject() {
return true;
}

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

@Override
public boolean canGoToObject() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,6 @@ public TripleID next() {
return triplesList.arrayOfTriples.get(pos++).asTripleID();
}


/*
* (non-Javadoc)
* @see hdt.iterator.IteratorTripleID#goToStart()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ private static IteratorTripleID fromList(List<TripleID> lst) {
private int current;
private int lastLoc;


@Override
public void goToStart() {
current = 0;
Expand Down
Loading

0 comments on commit c79073b

Please sign in to comment.