Skip to content

Commit c79073b

Browse files
committed
fix latest orders and patch pom.xml
1 parent 2e4d655 commit c79073b

File tree

9 files changed

+397
-111
lines changed

9 files changed

+397
-111
lines changed

qendpoint-backend/pom.xml

+6-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<rdf4j.version>5.0.2</rdf4j.version>
4747
<spring.version>3.4.0</spring.version>
4848
<logback.version>1.5.6</logback.version>
49-
49+
<gson.version>2.11.0</gson.version>
5050
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5151
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
5252
</properties>
@@ -112,6 +112,11 @@
112112
</exclusion>
113113
</exclusions>
114114
</dependency>
115+
<dependency>
116+
<groupId>com.google.code.gson</groupId>
117+
<artifactId>gson</artifactId>
118+
<version>${gson.version}</version>
119+
</dependency>
115120
<!-- v1.15 is needed for Jena 3.14+ - copied from org.apache.jena:jena:pom -->
116121
<dependency>
117122
<groupId>commons-codec</groupId>

qendpoint-backend/src/main/java/com/the_qa_company/qendpoint/controller/Sparql.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import com.the_qa_company.qendpoint.store.EndpointStoreUtils;
1313
import com.the_qa_company.qendpoint.utils.FileUtils;
1414
import com.the_qa_company.qendpoint.utils.RDFStreamUtils;
15+
import jakarta.annotation.PostConstruct;
16+
import jakarta.annotation.PreDestroy;
1517
import org.eclipse.rdf4j.model.Statement;
1618
import org.eclipse.rdf4j.model.util.Values;
1719
import org.eclipse.rdf4j.repository.RepositoryConnection;
@@ -34,8 +36,6 @@
3436
import org.springframework.stereotype.Component;
3537
import org.springframework.web.server.ServerWebInputException;
3638

37-
import javax.annotation.PostConstruct;
38-
import javax.annotation.PreDestroy;
3939
import java.io.File;
4040
import java.io.FileOutputStream;
4141
import java.io.IOException;

qendpoint-core/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<logback.version>1.5.6</logback.version>
4949
<roaringbitmap.version>0.9.44</roaringbitmap.version>
5050

51-
<jena.version>4.3.2</jena.version>
51+
<jena.version>4.9.0</jena.version>
5252
<slf4j.version>1.7.30</slf4j.version>
5353

5454
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -75,7 +75,7 @@
7575
<dependency>
7676
<groupId>org.apache.commons</groupId>
7777
<artifactId>commons-compress</artifactId>
78-
<version>1.21</version>
78+
<version>1.26.0</version>
7979
</dependency>
8080
<dependency>
8181
<groupId>org.apache.jena</groupId>

qendpoint-core/src/main/java/com/the_qa_company/qendpoint/core/iterator/utils/GraphFilteringTripleId.java

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public GraphFilteringTripleId(IteratorTripleID iterator, long[] graphIds) {
1616
this.graphIds = graphIds;
1717
}
1818

19-
2019
@Override
2120
public void goToStart() {
2221
throw new NotImplementedException();

qendpoint-core/src/main/java/com/the_qa_company/qendpoint/core/triples/IteratorTripleID.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -92,29 +92,35 @@ default boolean isLastTriplePositionBoundToOrder() {
9292

9393
/**
9494
* goto the next subject >= id
95+
*
9596
* @param id id
9697
* @return true if the next subject == id
97-
* @see #canGoToSubject() if can goto returns false, this function is not available
98+
* @see #canGoToSubject() if can goto returns false, this function is not
99+
* available
98100
*/
99101
default boolean gotoSubject(long id) {
100102
return false;
101103
}
102104

103105
/**
104106
* goto the next predicate >= id
107+
*
105108
* @param id id
106109
* @return true if the next predicate == id
107-
* @see #canGoToPredicate() if can goto returns false, this function is not available
110+
* @see #canGoToPredicate() if can goto returns false, this function is not
111+
* available
108112
*/
109113
default boolean gotoPredicate(long id) {
110114
return false;
111115
}
112116

113117
/**
114118
* goto the next object >= id
119+
*
115120
* @param id id
116121
* @return true if the next object == id
117-
* @see #canGoToObject() if can goto returns false, this function is not available
122+
* @see #canGoToObject() if can goto returns false, this function is not
123+
* available
118124
*/
119125
default boolean gotoObject(long id) {
120126
return false;
@@ -126,12 +132,14 @@ default boolean gotoObject(long id) {
126132
default boolean canGoToSubject() {
127133
return false;
128134
}
135+
129136
/**
130137
* @return true if {@link #gotoPredicate(long)} can be used, false otherwise
131138
*/
132139
default boolean canGoToPredicate() {
133140
return false;
134141
}
142+
135143
/**
136144
* @return true if {@link #gotoObject(long)} can be used, false otherwise
137145
*/

qendpoint-core/src/main/java/com/the_qa_company/qendpoint/core/triples/impl/BitmapTriplesIterator.java

+96-80
Original file line numberDiff line numberDiff line change
@@ -272,39 +272,50 @@ public boolean isLastTriplePositionBoundToOrder() {
272272

273273
private boolean gotoOrder(long id, TripleComponentRole role) {
274274
switch (role) {
275-
case SUBJECT -> {
276-
if (patX != 0) {
277-
return id == patX; // can't jump or already on the right element
278-
}
279-
280-
patX = id;
281-
findRange();
282-
patX = 0;
275+
case SUBJECT -> {
276+
if (patX != 0) {
277+
return id == patX; // can't jump or already on the right element
278+
}
283279

284-
return true; // we know x exists because we are using
280+
if (x >= id) {
281+
return id == x;
285282
}
286-
case PREDICATE -> {
287-
if (patY != 0) {
288-
return id == patY; // can't jump or already on the right element
289-
}
290283

291-
if (posY == nextY) {
292-
return false; // no next element
293-
}
284+
x = id;
285+
posY = adjY.find(x - 1);
286+
posZ = adjZ.find(posY);
287+
y = adjY.get(posY);
288+
nextY = adjY.last(x - 1) + 1;
289+
nextZ = adjZ.find(posY + 1);
294290

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

297-
if (curr >= id) {
298-
return curr == id;
299-
}
300-
if (posY + 1 == nextY) {
301-
return false; // no next element
302-
}
298+
if (posY == nextY) {
299+
return false; // no next element
300+
}
303301

304-
long last = this.adjY.get(nextY - 1);
302+
long curr = this.adjY.get(posY);
305303

304+
if (curr >= id) {
305+
return curr == id;
306+
}
306307

307-
boolean res;
308+
boolean res;
309+
if (posY + 1 == nextY) {
310+
// no next element, go next X
311+
x++;
312+
posY = nextY;
313+
nextY = adjY.findNext(posY) + 1;
314+
y = adjY.get(posY);
315+
316+
res = false;
317+
} else {
318+
long last = this.adjY.get(nextY - 1);
308319

309320
if (last > id) {
310321
// binary search between curr <-> last id
@@ -319,77 +330,79 @@ private boolean gotoOrder(long id, TripleComponentRole role) {
319330
posY = -loc - 1;
320331
y = adjY.get(posY);
321332
}
322-
} else if (last != id) {
323-
// last < id - GOTO end + 1
324-
posY = nextY;
325-
res = false;
326333
} else {
327-
// last == id - GOTO last
328-
posY = nextY - 1;
329-
y = adjY.get(posY);
330-
res = true;
334+
if (last != id) {
335+
// last < id - GOTO end + 1
336+
posY = nextY;
337+
res = false;
338+
} else {
339+
// last == id - GOTO last
340+
posY = nextY - 1;
341+
y = adjY.get(posY);
342+
res = true;
343+
}
344+
nextY = adjY.findNext(posY) + 1;
331345
}
346+
}
332347

333-
nextY = adjY.findNext(posY) + 1;
334-
335-
// down to z/posZ/nextZ?
336-
posZ = adjZ.find(posY, patZ);
337-
nextZ = adjZ.findNext(posZ) + 1;
348+
// down to z/posZ/nextZ?
349+
posZ = adjZ.find(posY); // assert patZ != 0
350+
nextZ = adjZ.findNext(posZ) + 1;
338351

339-
return res;
352+
return res;
353+
}
354+
case OBJECT -> {
355+
if (patZ != 0) {
356+
return id == patZ; // can't jump or already on the right element
340357
}
341-
case OBJECT -> {
342-
if (patZ != 0) {
343-
return id == patZ; // can't jump or already on the right element
344-
}
345358

346-
if (posZ == nextZ) {
347-
return false; // no next element
348-
}
349-
350-
long curr = this.adjZ.get(posZ);
359+
if (posZ == nextZ) {
360+
return false; // no next element
361+
}
351362

352-
if (curr >= id) {
353-
return curr == id;
354-
}
355-
if (posZ + 1 == nextZ) {
356-
return false; // no next element
357-
}
363+
long curr = this.adjZ.get(posZ);
358364

359-
long last = this.adjZ.get(nextZ - 1);
365+
if (curr >= id) {
366+
return curr == id;
367+
}
368+
if (posZ + 1 == nextZ) {
369+
return false; // no next element
370+
}
360371

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

362-
boolean res;
374+
boolean res;
363375

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

368-
if (loc >= 0) { //match
369-
res = true;
370-
posZ = loc;
371-
//z = id; // no need to compute the z, it is only used in next()
372-
} else {
373-
res = false;
374-
posZ = -loc - 1;
375-
//z = adjZ.get(posZ);
376-
}
377-
} else if (last != id) {
378-
// last < id - GOTO end
379-
posZ = nextZ;
380-
res = false;
381-
} else {
382-
// last == id - GOTO last
383-
posZ = nextZ - 1;
384-
//z = adjZ.get(posZ);
380+
if (loc >= 0) { // match
385381
res = true;
382+
posZ = loc;
383+
// z = id; // no need to compute the z, it is only used in
384+
// next()
385+
} else {
386+
res = false;
387+
posZ = -loc - 1;
388+
// z = adjZ.get(posZ);
386389
}
390+
} else if (last != id) {
391+
// last < id - GOTO end
392+
posZ = nextZ;
393+
res = false;
394+
} else {
395+
// last == id - GOTO last
396+
posZ = nextZ - 1;
397+
// z = adjZ.get(posZ);
398+
res = true;
399+
}
387400

388-
nextZ = adjZ.findNext(posZ) + 1;
401+
nextZ = adjZ.findNext(posZ) + 1;
389402

390-
return res;
391-
}
392-
default -> throw new NotImplementedException("goto " + role);
403+
return res;
404+
}
405+
default -> throw new NotImplementedException("goto " + role);
393406
}
394407
}
395408

@@ -402,6 +415,7 @@ public boolean gotoSubject(long id) {
402415
public boolean gotoPredicate(long id) {
403416
return gotoOrder(id, idx.getOrder().getPredicateMapping());
404417
}
418+
405419
@Override
406420
public boolean gotoObject(long id) {
407421
return gotoOrder(id, idx.getOrder().getObjectMapping());
@@ -411,10 +425,12 @@ public boolean gotoObject(long id) {
411425
public boolean canGoToSubject() {
412426
return true;
413427
}
428+
414429
@Override
415430
public boolean canGoToPredicate() {
416431
return true;
417432
}
433+
418434
@Override
419435
public boolean canGoToObject() {
420436
return true;

qendpoint-core/src/main/java/com/the_qa_company/qendpoint/core/triples/impl/TriplesList.java

-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ public TripleID next() {
448448
return triplesList.arrayOfTriples.get(pos++).asTripleID();
449449
}
450450

451-
452451
/*
453452
* (non-Javadoc)
454453
* @see hdt.iterator.IteratorTripleID#goToStart()

qendpoint-core/src/test/java/com/the_qa_company/qendpoint/core/triples/impl/BitmapQuadTriplesTest.java

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ private static IteratorTripleID fromList(List<TripleID> lst) {
3434
private int current;
3535
private int lastLoc;
3636

37-
3837
@Override
3938
public void goToStart() {
4039
current = 0;

0 commit comments

Comments
 (0)