use of org.apache.clerezza.commons.rdf.Triple in project stanbol by apache.
the class ClerezzaRDFParser method parse.
@Override
public RDFDataset parse(Object input) throws JsonLdError {
count = 0;
Map<BlankNode, String> bNodeMap = new HashMap<BlankNode, String>(1024);
final RDFDataset result = new RDFDataset();
if (input instanceof Graph) {
for (Triple t : ((Graph) input)) {
handleStatement(result, t, bNodeMap);
}
}
//help gc
bNodeMap.clear();
return result;
}
use of org.apache.clerezza.commons.rdf.Triple in project stanbol by apache.
the class IndexedGraphTest method remove.
@Test(expected = ConcurrentModificationException.class)
public void remove() {
Graph itc = new IndexedGraph();
itc.add(triple1);
itc.add(triple2);
itc.add(triple3);
itc.add(triple4);
itc.add(triple5);
Iterator<Triple> iter = itc.filter(uriRef1, null, null);
while (iter.hasNext()) {
Triple triple = iter.next();
itc.remove(triple);
}
Assert.assertEquals(3, itc.size());
}
use of org.apache.clerezza.commons.rdf.Triple in project stanbol by apache.
the class IndexedGraphTest method filterIteratorRemove.
@Test
public void filterIteratorRemove() {
Graph itc = new IndexedGraph();
itc.add(triple1);
itc.add(triple2);
itc.add(triple3);
itc.add(triple4);
itc.add(triple5);
Iterator<Triple> iter = itc.filter(uriRef1, null, null);
while (iter.hasNext()) {
iter.next();
iter.remove();
}
Assert.assertEquals(3, itc.size());
}
use of org.apache.clerezza.commons.rdf.Triple in project stanbol by apache.
the class IndexedGraphTest method iteratorRemove.
@Test
public void iteratorRemove() {
Graph itc = new IndexedGraph();
itc.add(triple1);
itc.add(triple2);
itc.add(triple3);
itc.add(triple4);
itc.add(triple5);
Iterator<Triple> iter = itc.iterator();
while (iter.hasNext()) {
iter.next();
iter.remove();
}
Assert.assertEquals(0, itc.size());
}
use of org.apache.clerezza.commons.rdf.Triple in project stanbol by apache.
the class TripleMatcherGroupImpl method getMatchingSubjects.
@Override
public Set<IRI> getMatchingSubjects(ImmutableGraph g) {
if (matchers.isEmpty()) {
return new HashSet<IRI>();
}
// For all matchers, find the set of subjects that match
// and compute the intersection of those sets
Set<IRI> intersection = null;
for (TripleMatcher m : matchers) {
final Set<IRI> s = new HashSet<IRI>();
final Iterator<Triple> it = g.iterator();
while (it.hasNext()) {
final Triple t = it.next();
if (m.matches(t)) {
final BlankNodeOrIRI n = t.getSubject();
if (n instanceof IRI) {
s.add((IRI) n);
} else {
// TODO do we need to handle non-IRI subjects?
}
}
}
if (intersection == null) {
intersection = s;
} else {
intersection.retainAll(s);
}
}
return intersection;
}
Aggregations