Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hmottestad committed Dec 20, 2023
1 parent 4201c71 commit f9049c4
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ public static <E> CloseableIteration<? extends E> getWildcardInstance(
public static <E> CloseableIteration<? extends E> getWildcardInstance(Comparator<E> cmp,
CloseableIteration<? extends E> leftIteration, CloseableIteration<? extends E> rightIteration) {

// if (rightIteration instanceof EmptyIteration) {
// return leftIteration;
// } else if (leftIteration instanceof EmptyIteration) {
// return rightIteration;
// } else {
return new DualUnionIteration<>(cmp, leftIteration, rightIteration);
// }
if (rightIteration instanceof EmptyIteration) {
return leftIteration;
} else if (leftIteration instanceof EmptyIteration) {
return rightIteration;
} else {
return new DualUnionIteration<>(cmp, leftIteration, rightIteration);
}
}

public static <E> CloseableIteration<E> getInstance(CloseableIteration<E> leftIteration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.eclipse.rdf4j.common.annotation.Experimental;

/**
* The index name of the underlying data structure, e.g. SPOC, POSC, etc.
* A way to signal which index is in use for a specific iterator (e.g. SPOC, POSC, etc.). Used in the query explanation.
*/
@Experimental
public interface IndexReportingIterator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,22 @@
import org.eclipse.rdf4j.model.Resource;
import org.eclipse.rdf4j.model.Value;

/**
* An interface for {@link StatementOrder} implementations that can report which orders they support for a given
* subject, predicate, object and contexts.
*/
@Experimental
public interface AvailableStatementOrder {

/**
* Returns the supported orders for the given subject, predicate, object and contexts.
*
* @param subj
* @param pred
* @param obj
* @param contexts
* @return the supported orders for the given subject, predicate, object and contexts.
*/
@Experimental
Set<StatementOrder> getSupportedOrders(Resource subj, IRI pred, Value obj, Resource... contexts);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.model.Value;

/**
* An enum for the different orders in which statements can be ordered.
*/
@Experimental
public enum StatementOrder {

S,
P,
O,
C;
S, // Subject
P, // Predicate
O, // Object
C; // Context

@Experimental
public Comparator<Statement> getComparator(Comparator<Value> comparator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.function.Function;
import java.util.function.Predicate;

import org.eclipse.rdf4j.common.annotation.Experimental;
import org.eclipse.rdf4j.model.Literal;
import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.model.ValueFactory;
Expand All @@ -36,7 +37,10 @@
*/
public interface QueryEvaluationContext {

Comparator<Value> getComparator();
@Experimental
default Comparator<Value> getComparator() {
return null;
}

class Minimal implements QueryEvaluationContext {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class GroupIteratorTest {
private final static ValueFactory vf = SimpleValueFactory.getInstance();
private static final EvaluationStrategy evaluator = new StrictEvaluationStrategy(null, null);
private static final QueryEvaluationContext context = new QueryEvaluationContext.Minimal(
vf.createLiteral(Date.from(Instant.now())), null);
vf.createLiteral(Date.from(Instant.now())), null, null);
private static BindingSetAssignment EMPTY_ASSIGNMENT;
private static BindingSetAssignment NONEMPTY_ASSIGNMENT;
private static AggregateFunctionFactory aggregateFunctionFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public CloseableIteration<? extends Statement> getStatements(Resource subj, IRI
}
}, null);
private final QueryEvaluationContext context = new QueryEvaluationContext.Minimal(
vf.createLiteral(Date.from(Instant.now())), null);
vf.createLiteral(Date.from(Instant.now())), null, null);

/**
* Tests joins between two different BindingSetAssignments with the same BindingSets but ordered differently.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
public class OrderComparatorTest {
private static final ValueFactory vf = SimpleValueFactory.getInstance();
private final QueryEvaluationContext context = new QueryEvaluationContext.Minimal(
vf.createLiteral(Date.from(Instant.now())), null);
vf.createLiteral(Date.from(Instant.now())), null, null);

class EvaluationStrategyStub implements EvaluationStrategy {
static class EvaluationStrategyStub implements EvaluationStrategy {

@Override
public CloseableIteration<BindingSet> evaluate(TupleExpr expr, BindingSet bindings)
Expand All @@ -69,19 +69,19 @@ public QueryEvaluationStep precompile(TupleExpr expr, QueryEvaluationContext con

@Override
public Value evaluate(ValueExpr expr, BindingSet bindings)
throws ValueExprEvaluationException, QueryEvaluationException {
throws QueryEvaluationException {
return null;
}

@Override
public boolean isTrue(ValueExpr expr, BindingSet bindings)
throws ValueExprEvaluationException, QueryEvaluationException {
throws QueryEvaluationException {
throw new UnsupportedOperationException();
}

@Override
public boolean isTrue(QueryValueEvaluationStep expr, BindingSet bindings)
throws ValueExprEvaluationException, QueryEvaluationException {
throws QueryEvaluationException {
throw new UnsupportedOperationException();
}

Expand Down

0 comments on commit f9049c4

Please sign in to comment.