forked from Merck/Halyard
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
111 changed files
with
1,629 additions
and
1,754 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 21 additions & 22 deletions
43
api/src/main/java/com/msd/gin/halyard/sail/BindingSetConsumerSailConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
package com.msd.gin.halyard.sail; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import org.eclipse.rdf4j.common.iteration.CloseableIteration; | ||
import org.eclipse.rdf4j.query.BindingSet; | ||
import org.eclipse.rdf4j.query.Dataset; | ||
import org.eclipse.rdf4j.query.QueryEvaluationException; | ||
import org.eclipse.rdf4j.query.algebra.TupleExpr; | ||
import org.eclipse.rdf4j.sail.SailConnection; | ||
|
||
public interface BindingSetConsumerSailConnection extends SailConnection { | ||
default void evaluate(Consumer<BindingSet> handler, final TupleExpr tupleExpr, final Dataset dataset, final BindingSet bindings, final boolean includeInferred) { | ||
report(evaluate(tupleExpr, dataset, bindings, includeInferred), handler); | ||
} | ||
|
||
static void report(CloseableIteration<? extends BindingSet, QueryEvaluationException> iter, Consumer<BindingSet> handler) { | ||
while (iter.hasNext()) { | ||
handler.accept(iter.next()); | ||
} | ||
} | ||
} | ||
package com.msd.gin.halyard.sail; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import org.eclipse.rdf4j.common.iteration.CloseableIteration; | ||
import org.eclipse.rdf4j.query.BindingSet; | ||
import org.eclipse.rdf4j.query.Dataset; | ||
import org.eclipse.rdf4j.query.algebra.TupleExpr; | ||
import org.eclipse.rdf4j.sail.SailConnection; | ||
|
||
public interface BindingSetConsumerSailConnection extends SailConnection { | ||
default void evaluate(Consumer<BindingSet> handler, final TupleExpr tupleExpr, final Dataset dataset, final BindingSet bindings, final boolean includeInferred) { | ||
report(evaluate(tupleExpr, dataset, bindings, includeInferred), handler); | ||
} | ||
|
||
static void report(CloseableIteration<? extends BindingSet> iter, Consumer<BindingSet> handler) { | ||
while (iter.hasNext()) { | ||
handler.accept(iter.next()); | ||
} | ||
} | ||
} |
63 changes: 31 additions & 32 deletions
63
api/src/main/java/com/msd/gin/halyard/sail/BindingSetPipeSailConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,31 @@ | ||
package com.msd.gin.halyard.sail; | ||
|
||
import com.msd.gin.halyard.query.BindingSetPipe; | ||
|
||
import org.eclipse.rdf4j.common.iteration.CloseableIteration; | ||
import org.eclipse.rdf4j.query.BindingSet; | ||
import org.eclipse.rdf4j.query.Dataset; | ||
import org.eclipse.rdf4j.query.QueryEvaluationException; | ||
import org.eclipse.rdf4j.query.algebra.TupleExpr; | ||
import org.eclipse.rdf4j.sail.SailConnection; | ||
|
||
public interface BindingSetPipeSailConnection extends SailConnection { | ||
default void evaluate(BindingSetPipe pipe, final TupleExpr tupleExpr, final Dataset dataset, final BindingSet bindings, final boolean includeInferred) { | ||
report(evaluate(tupleExpr, dataset, bindings, includeInferred), pipe); | ||
pipe.close(); | ||
} | ||
|
||
/** | ||
* NB: does not close the pipe so you can report multiple iterations to the same pipe. | ||
* @param iter iteration of binding sets to push to the pipe | ||
* @param pipe the pipe to push to | ||
* @return true if the pipe can accept more binding sets | ||
*/ | ||
static boolean report(CloseableIteration<? extends BindingSet, QueryEvaluationException> iter, BindingSetPipe pipe) { | ||
while (iter.hasNext()) { | ||
if (!pipe.push(iter.next())) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
} | ||
package com.msd.gin.halyard.sail; | ||
|
||
import org.eclipse.rdf4j.common.iteration.CloseableIteration; | ||
import org.eclipse.rdf4j.query.BindingSet; | ||
import org.eclipse.rdf4j.query.Dataset; | ||
import org.eclipse.rdf4j.query.algebra.TupleExpr; | ||
import org.eclipse.rdf4j.sail.SailConnection; | ||
|
||
import com.msd.gin.halyard.query.BindingSetPipe; | ||
|
||
public interface BindingSetPipeSailConnection extends SailConnection { | ||
default void evaluate(BindingSetPipe pipe, final TupleExpr tupleExpr, final Dataset dataset, final BindingSet bindings, final boolean includeInferred) { | ||
report(evaluate(tupleExpr, dataset, bindings, includeInferred), pipe); | ||
pipe.close(); | ||
} | ||
|
||
/** | ||
* NB: does not close the pipe so you can report multiple iterations to the same pipe. | ||
* @param iter iteration of binding sets to push to the pipe | ||
* @param pipe the pipe to push to | ||
* @return true if the pipe can accept more binding sets | ||
*/ | ||
static boolean report(CloseableIteration<? extends BindingSet> iter, BindingSetPipe pipe) { | ||
while (iter.hasNext()) { | ||
if (!pipe.push(iter.next())) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.