Skip to content

Commit

Permalink
Merge pull request #624 from eclipse/issues/#164-strategyfactory-hotfix
Browse files Browse the repository at this point in the history
#164 critical pre-release hotfix in native and memory store strategy selection
  • Loading branch information
abrokenjester authored Oct 20, 2016
2 parents f67cbfd + 10f1278 commit 80020f1
Show file tree
Hide file tree
Showing 13 changed files with 254 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright (c) 2016 Eclipse RDF4J contributors.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*/
package org.eclipse.rdf4j.repository.sail.memory;

import org.eclipse.rdf4j.repository.EvaluationStrategyTest;
import org.eclipse.rdf4j.sail.base.config.BaseSailConfig;
import org.eclipse.rdf4j.sail.memory.config.MemoryStoreConfig;


/**
* @author jeen
*
*/
public class MemoryEvaluationStrategyTest extends EvaluationStrategyTest {

@Override
protected BaseSailConfig getBaseSailConfig() {
return new MemoryStoreConfig(false);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright (c) 2016 Eclipse RDF4J contributors.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*/
package org.eclipse.rdf4j.repository.sail.nativerdf;

import org.eclipse.rdf4j.repository.EvaluationStrategyTest;
import org.eclipse.rdf4j.sail.base.config.BaseSailConfig;
import org.eclipse.rdf4j.sail.nativerdf.config.NativeStoreConfig;


/**
* @author jeen
*
*/
public class NativeEvaluationStrategyTest extends EvaluationStrategyTest {

@Override
protected BaseSailConfig getBaseSailConfig() {
return new NativeStoreConfig();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
*/
public interface EvaluationStrategyFactory {

/**
* Set the number of query solutions the {@link EvaluationStrategy} will keep in main memory before it
* attempts to sync to a temporary disk cache. If set to 0, no disk caching will occur.
* EvaluationStrategies that provide no disk caching functionality are free to ignore this parameter.
*
* @param threshold
* the number of query solutions that the EvaluationStrategy can cache in main memory before
* attempting disk sync.
*/
void setQuerySolutionCacheThreshold(long threshold);

/**
* Get the number of query solutions the {@link EvaluationStrategy} will keep in main memory before it
* attempts to sync to a temporary disk cache. If set to 0, no disk caching will occur.
* EvaluationStrategies that provide no disk caching functionality are free to ignore this parameter.
*/
long getQuerySolutionCacheThreshold();

/**
* Returns the {@link EvaluationStrategy} to use to evaluate queries for the given {@link Dataset} and
* {@link TripleSource}.
Expand All @@ -25,4 +43,5 @@ public interface EvaluationStrategyFactory {
* @return an EvaluationStrategy.
*/
EvaluationStrategy createEvaluationStrategy(Dataset dataset, TripleSource tripleSource);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2016 Eclipse RDF4J contributors.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*/
package org.eclipse.rdf4j.query.algebra.evaluation.impl;

import org.eclipse.rdf4j.query.algebra.evaluation.EvaluationStrategyFactory;

/**
* Abstract base class for {@link ExtendedEvaluationStrategy}.
*
* @author Jeen Broekstra
*/
public abstract class AbstractEvaluationStrategyFactory implements EvaluationStrategyFactory {

private long querySolutionCacheThreshold;

@Override
public void setQuerySolutionCacheThreshold(long threshold) {
this.querySolutionCacheThreshold = threshold;
}

@Override
public long getQuerySolutionCacheThreshold() {
return querySolutionCacheThreshold;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
public class ExtendedEvaluationStrategy extends TupleFunctionEvaluationStrategy {

public ExtendedEvaluationStrategy(TripleSource tripleSource, Dataset dataset,
FederatedServiceResolver serviceResolver)
FederatedServiceResolver serviceResolver, long iterationCacheSyncThreshold)
{
super(tripleSource, dataset, serviceResolver);
super(tripleSource, dataset, serviceResolver, iterationCacheSyncThreshold);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedServiceResolver;
import org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedServiceResolverClient;

public class ExtendedEvaluationStrategyFactory
public class ExtendedEvaluationStrategyFactory extends AbstractEvaluationStrategyFactory
implements EvaluationStrategyFactory, FederatedServiceResolverClient
{

Expand All @@ -37,7 +37,10 @@ public FederatedServiceResolver getFederatedServiceResolver() {
}

@Override
public EvaluationStrategy createEvaluationStrategy(Dataset dataset, TripleSource tripleSource) {
return new ExtendedEvaluationStrategy(tripleSource, dataset, serviceResolver);
public EvaluationStrategy createEvaluationStrategy(Dataset dataset, TripleSource tripleSource)
{
return new ExtendedEvaluationStrategy(tripleSource, dataset, serviceResolver,
getQuerySolutionCacheThreshold());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedServiceResolver;
import org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedServiceResolverClient;

public class StrictEvaluationStrategyFactory
public class StrictEvaluationStrategyFactory extends AbstractEvaluationStrategyFactory
implements EvaluationStrategyFactory, FederatedServiceResolverClient
{

Expand All @@ -37,7 +37,9 @@ public FederatedServiceResolver getFederatedServiceResolver() {
}

@Override
public EvaluationStrategy createEvaluationStrategy(Dataset dataset, TripleSource tripleSource) {
return new StrictEvaluationStrategy(tripleSource, dataset, serviceResolver);
public EvaluationStrategy createEvaluationStrategy(Dataset dataset, TripleSource tripleSource)
{
return new StrictEvaluationStrategy(tripleSource, dataset, serviceResolver,
getQuerySolutionCacheThreshold());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.eclipse.rdf4j.query.algebra.evaluation.EvaluationStrategy;
import org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet;
import org.eclipse.rdf4j.query.algebra.evaluation.TripleSource;
import org.eclipse.rdf4j.query.algebra.evaluation.federation.AbstractFederatedServiceResolver;
import org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedServiceResolver;
import org.eclipse.rdf4j.query.algebra.evaluation.function.TupleFunction;
import org.eclipse.rdf4j.query.algebra.evaluation.function.TupleFunctionRegistry;
Expand All @@ -37,17 +38,29 @@ public class TupleFunctionEvaluationStrategy extends StrictEvaluationStrategy {
public TupleFunctionEvaluationStrategy(TripleSource tripleSource, Dataset dataset,
FederatedServiceResolver serviceResolver)
{
this(tripleSource, dataset, serviceResolver, TupleFunctionRegistry.getInstance());
this(tripleSource, dataset, serviceResolver, 0);
}

public TupleFunctionEvaluationStrategy(TripleSource tripleSource, Dataset dataset,
FederatedServiceResolver serviceResolver, long iterationCacheSyncThreshold)
{
this(tripleSource, dataset, serviceResolver, TupleFunctionRegistry.getInstance(), iterationCacheSyncThreshold);
}

public TupleFunctionEvaluationStrategy(TripleSource tripleSource, Dataset dataset,
FederatedServiceResolver serviceResolver,
TupleFunctionRegistry tupleFuncRegistry)
TupleFunctionRegistry tupleFuncRegistry, long iterationCacheSyncThreshold)
{
super(tripleSource, dataset, serviceResolver);
super(tripleSource, dataset, serviceResolver, iterationCacheSyncThreshold);
this.tupleFuncRegistry = tupleFuncRegistry;
}

public TupleFunctionEvaluationStrategy(TripleSource tripleSource, Dataset dataset,
AbstractFederatedServiceResolver serviceResolver, TupleFunctionRegistry tupleFunctionRegistry)
{
this(tripleSource, dataset, serviceResolver, tupleFunctionRegistry, 0);
}

@Override
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(TupleExpr expr,
BindingSet bindings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public synchronized EvaluationStrategyFactory getEvaluationStrategyFactory() {
if (evalStratFactory == null) {
evalStratFactory = new StrictEvaluationStrategyFactory(getFederatedServiceResolver());
}
evalStratFactory.setQuerySolutionCacheThreshold(getIterationCacheSyncThreshold());
return evalStratFactory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Resource;
import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.query.Dataset;
import org.eclipse.rdf4j.query.algebra.evaluation.EvaluationStrategy;
import org.eclipse.rdf4j.query.algebra.evaluation.TripleSource;
import org.eclipse.rdf4j.query.algebra.evaluation.impl.StrictEvaluationStrategy;
import org.eclipse.rdf4j.sail.SailException;
import org.eclipse.rdf4j.sail.SailReadOnlyException;
import org.eclipse.rdf4j.sail.base.SailSourceConnection;
Expand Down Expand Up @@ -115,12 +111,6 @@ public boolean removeInferredStatement(Resource subj, IRI pred, Value obj, Resou
return ret;
}

@Override
protected EvaluationStrategy getEvaluationStrategy(Dataset dataset, TripleSource tripleSource) {
return new StrictEvaluationStrategy(tripleSource, dataset, getFederatedServiceResolver(),
sail.getIterationCacheSyncThreshold());
}

@Override
protected void clearInternal(Resource... contexts)
throws SailException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public synchronized EvaluationStrategyFactory getEvaluationStrategyFactory() {
if (evalStratFactory == null) {
evalStratFactory = new StrictEvaluationStrategyFactory(getFederatedServiceResolver());
}
evalStratFactory.setQuerySolutionCacheThreshold(getIterationCacheSyncThreshold());
return evalStratFactory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Resource;
import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.query.Dataset;
import org.eclipse.rdf4j.query.algebra.evaluation.EvaluationStrategy;
import org.eclipse.rdf4j.query.algebra.evaluation.TripleSource;
import org.eclipse.rdf4j.query.algebra.evaluation.impl.StrictEvaluationStrategy;
import org.eclipse.rdf4j.sail.SailException;
import org.eclipse.rdf4j.sail.SailReadOnlyException;
import org.eclipse.rdf4j.sail.base.SailSourceConnection;
Expand Down Expand Up @@ -148,12 +144,6 @@ public boolean removeInferredStatement(Resource subj, IRI pred, Value obj, Resou
return ret;
}

@Override
protected EvaluationStrategy getEvaluationStrategy(Dataset dataset, TripleSource tripleSource) {
return new StrictEvaluationStrategy(tripleSource, dataset, getFederatedServiceResolver(),
nativeStore.getIterationCacheSyncThreshold());
}

@Override
protected void clearInternal(Resource... contexts)
throws SailException
Expand Down
Loading

0 comments on commit 80020f1

Please sign in to comment.