You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commonsrdf.apache.org by an...@apache.org on 2015/03/30 03:10:03 UTC
[09/18] incubator-commonsrdf git commit: Add test to verify that
filter with no matches is significantly faster
Add test to verify that filter with no matches is significantly faster
Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/728270b6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/728270b6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/728270b6
Branch: refs/heads/master
Commit: 728270b68c0309ba5bbf2f4c83d1750015c8d51a
Parents: 5364be3
Author: Peter Ansell <p_...@yahoo.com>
Authored: Sat Mar 28 21:07:42 2015 +1100
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Sat Mar 28 21:07:42 2015 +1100
----------------------------------------------------------------------
.../commons/rdf/simple/TestWritingGraph.java | 22 +++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/728270b6/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java b/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
index 3c0ab63..681c6e9 100644
--- a/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
@@ -111,8 +111,7 @@ public class TestWritingGraph {
graphFile.toFile().deleteOnExit();
}
- Stream<CharSequence> stream = graph.getTriples().unordered()
- .map(Object::toString);
+ Stream<CharSequence> stream = graph.getTriples().map(Object::toString);
Files.write(graphFile, stream::iterator, Charset.forName("UTF-8"));
}
@@ -125,7 +124,24 @@ public class TestWritingGraph {
graphFile.toFile().deleteOnExit();
}
- BlankNode subject = factory.createBlankNode("subj");
+ IRI subject = factory.createIRI("subj");
+ IRI predicate = factory.createIRI("pred");
+ Stream<CharSequence> stream = graph
+ .getTriples(subject, predicate, null).map(Object::toString);
+ Files.write(graphFile, stream::iterator, Charset.forName("UTF-8"));
+
+ }
+
+ @Test
+ public void writeGraphFromStreamFilteredNoMatches() throws Exception {
+ Path graphFile = Files.createTempFile("graph-empty-", ".nt");
+ if (KEEP_FILES) {
+ System.out.println("Filtered stream: " + graphFile);
+ } else {
+ graphFile.toFile().deleteOnExit();
+ }
+
+ IRI subject = factory.createIRI("nonexistent");
IRI predicate = factory.createIRI("pred");
Stream<CharSequence> stream = graph
.getTriples(subject, predicate, null).map(Object::toString);