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

Adding support for named graphs #196

Merged
merged 32 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f69df74
Implemented quad dictionaries for .nq files
QuentinJanuel May 31, 2023
728446d
temp triples can handle quads
QuentinJanuel Jun 1, 2023
3d9e29a
making sure graphs don't affect normal hdt
QuentinJanuel Jun 5, 2023
9a7d09d
FourQuadSectionDictionary needs to implement FourSectionDictionary, n…
QuentinJanuel Jun 15, 2023
7a024f5
quad patterns support (not implemented yet)
QuentinJanuel Jun 15, 2023
82cb465
fixed quadstring
QuentinJanuel Jun 22, 2023
3439c49
save triples (could be optimized)
QuentinJanuel Jun 22, 2023
a4f5bfb
search wip
QuentinJanuel Jun 26, 2023
d672ee9
Fixed search for triples (non quad)
QuentinJanuel Jun 29, 2023
c26b85e
number of graphs is now dynamic
QuentinJanuel Jun 29, 2023
f58cfa6
Adapt code for large files (RoaringBitmap)
QuentinJanuel Jul 11, 2023
bcc095a
roaring bitmap 64
QuentinJanuel Jul 13, 2023
f45facb
accelerated wildcard pattern a bit
QuentinJanuel Jul 13, 2023
1e612c3
BitmapQuadsIterator
QuentinJanuel Jul 17, 2023
8d31b3d
fixed roaring bitmap
QuentinJanuel Jul 20, 2023
c8b0c1e
let quads iterator variables be longs
QuentinJanuel Jul 20, 2023
b1ba3a6
support for ???G, S??G, SP?G & SPOG
QuentinJanuel Jul 20, 2023
0f1685b
?POG & ??OG (ZGFOQ)
QuentinJanuel Jul 28, 2023
5ccc86b
removed forgotten log
QuentinJanuel Jul 28, 2023
257aa30
?PO? & ??O? (ZFOQ)
QuentinJanuel Jul 28, 2023
76ee129
?P?G (YGFOQ)
QuentinJanuel Jul 31, 2023
41abd02
?P?? (YFOQ)
QuentinJanuel Aug 4, 2023
cbfeedc
address https://github.com/rdfhdt/hdt-java/pull/196#discussion_r12416…
QuentinJanuel Aug 28, 2023
b9002a6
address https://github.com/rdfhdt/hdt-java/pull/196#discussion_r12955…
QuentinJanuel Aug 28, 2023
fef55fb
address https://github.com/rdfhdt/hdt-java/pull/196#discussion_r12955…
QuentinJanuel Aug 28, 2023
5233663
address https://github.com/rdfhdt/hdt-java/pull/196#discussion_r12955…
QuentinJanuel Aug 28, 2023
59bba7c
address https://github.com/rdfhdt/hdt-java/pull/196#discussion_r12955…
QuentinJanuel Aug 28, 2023
7ae491c
address https://github.com/rdfhdt/hdt-java/pull/196#discussion_r12958…
QuentinJanuel Aug 28, 2023
eacd5bb
address https://github.com/rdfhdt/hdt-java/pull/196#discussion_r12958…
QuentinJanuel Aug 28, 2023
f61bc58
address https://github.com/rdfhdt/hdt-java/pull/196#discussion_r12959…
QuentinJanuel Aug 31, 2023
c675a01
cat tests for quads
QuentinJanuel Sep 4, 2023
3f4ba41
test quads iterators
QuentinJanuel Sep 5, 2023
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
Prev Previous commit
Next Next commit
support for ???G, S??G, SP?G & SPOG
  • Loading branch information
QuentinJanuel committed Jul 20, 2023
commit b1ba3a6246bde371ca5ef2c268ffa1228a676d71
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package org.rdfhdt.hdt.quads.impl;

import org.rdfhdt.hdt.compact.bitmap.Bitmap;
import org.rdfhdt.hdt.exceptions.NotImplementedException;
import org.rdfhdt.hdt.triples.TripleID;
import org.rdfhdt.hdt.triples.impl.BitmapTriples;
import org.rdfhdt.hdt.triples.impl.BitmapTriplesIterator;

public class BitmapQuadsIteratorG extends BitmapTriplesIterator {

// resolves ???G, S??G, SP?G, SPOG queries

private Bitmap bitmapGraph; // the graph bitmap for the search

public BitmapQuadsIteratorG(BitmapTriples triples, TripleID pattern) {
super();
this.triples = triples;
this.returnTriple = new TripleID();
this.pattern = new TripleID();
this.bitmapGraph = triples
.getQuadInfoAG()
.get((int)pattern.getGraph() - 1);
newSearch(pattern);
}

@Override
public void goToStart() {
if(minZ >= maxZ || minZ == -1) { // no results
posZ = maxZ;
} else {
super.goToStart();
}
if (!bitmapGraph.access(posZ)) {
posZ = bitmapGraph.selectNext1(posZ + 1);
}
}

@Override
public long estimatedNumResults() {
if (minZ == -1) {
return 0;
}
return bitmapGraph.rank1(maxZ - 1) - bitmapGraph.rank1(minZ - 1);
}

/*
* Check if there are more solution
*/
@Override
public boolean hasNext() {
return posZ<maxZ && posZ != -1; // Just check if we have arrived to the maximum position of the objects that resolve the query
}

/*
* Get the next solution
*/
@Override
public TripleID next() {
z = adjZ.get(posZ); // get the next object (Z). We just retrieve it from the list of objects (AdjZ) from current position posZ
if(posZ>=nextZ) { // if, with the current position of the object (posZ), we have reached the next list of objects (starting in nexZ), then we should update the associated predicate (Y) and, potentially, also the associated subject (X)
posY = triples.bitmapZ.rank1(posZ-1); // move to the next position of predicates
y = adjY.get(posY); // get the next predicate (Y). We just retrieve it from the list of predicates(AdjY) from current position posY
nextZ = adjZ.findNext(posZ)+1; // update nextZ, storing in which position (in adjZ) ends the list of objects associated with the current subject,predicate
if(posY>=nextY) { // if we have reached the next list of objects (starting in nexZ) we should update the associated predicate (Y) and, potentially, also the associated subject (X)
x = triples.bitmapY.rank1(posY - 1) + 1; // get the next subject (X)
nextY = adjY.findNext(posY)+1; // update nextY, storing in which position (in AdjY) ends the list of predicates associated with the current subject
}
}
posZ = bitmapGraph.selectNext1(posZ + 1);

updateOutput(); // set the components (subject,predicate,object,graph) of the returned triple
return returnTriple; // return the triple as solution
}

@Override
public boolean hasPrevious() {
throw new NotImplementedException();
}

@Override
public TripleID previous() {
throw new NotImplementedException();
}

@Override
public boolean canGoTo() {
throw new NotImplementedException();
}

@Override
public void goTo(long pos) {
throw new NotImplementedException();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.rdfhdt.hdt.options.ControlInformation;
import org.rdfhdt.hdt.options.HDTOptions;
import org.rdfhdt.hdt.quads.impl.BitmapQuadsIterator;
import org.rdfhdt.hdt.quads.impl.BitmapQuadsIteratorG;
import org.rdfhdt.hdt.triples.IteratorTripleID;
import org.rdfhdt.hdt.triples.TempTriples;
import org.rdfhdt.hdt.triples.TripleID;
Expand Down Expand Up @@ -295,15 +296,19 @@ public SuppliableIteratorTripleID search(TripleID pattern) {
}
}

SuppliableIteratorTripleID bitIt = new BitmapQuadsIterator(
this,
pattern
);
if(patternString.equals("????") || patternString.equals("S???") || patternString.equals("SP??") || patternString.equals("SPO?")) {
SuppliableIteratorTripleID bitIt;
if (patternString.endsWith("G"))
bitIt = new BitmapQuadsIteratorG(this, pattern);
else
bitIt = new BitmapQuadsIterator(this, pattern);
if( patternString.equals("????") || patternString.equals("???G")
|| patternString.equals("S???") || patternString.equals("S??G")
|| patternString.equals("SP??") || patternString.equals("SP?G")
|| patternString.equals("SPO?") || patternString.equals("SPOG")
) {
return bitIt;
} else {
return new SequentialSearchIteratorTripleID(pattern, bitIt);
}
return new SequentialSearchIteratorTripleID(pattern, bitIt);
}

@Override
Expand Down