Skip to content

Commit

Permalink
Removed some deprecated calls and unnecessary casts
Browse files Browse the repository at this point in the history
  • Loading branch information
joshsh committed May 29, 2014
1 parent 796e404 commit 3f2b225
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.tinkerpop.blueprints.oupls.sail;

import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.KeyIndexableGraph;
import com.tinkerpop.blueprints.TransactionalGraph;
Expand All @@ -22,7 +21,6 @@
import org.openrdf.sail.SailException;
import org.openrdf.sail.helpers.NotifyingSailBase;

import java.io.File;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
Expand Down Expand Up @@ -138,7 +136,7 @@ public GraphSail(final T graph, final String indexedPatterns) {
store.sail = this;
store.graph = graph;

store.manualTransactions = store.graph instanceof TransactionalGraph;
store.isTransactional = store.graph instanceof TransactionalGraph;

if (!store.graph.getIndexedKeys(Vertex.class).contains(VALUE)) {
store.graph.createKeyIndex(VALUE, Vertex.class);
Expand All @@ -154,7 +152,7 @@ public GraphSail(final T graph, final String indexedPatterns) {
try {
store.namespaces = store.addVertex(NAMESPACES_VERTEX_ID);
} finally {
if (store.manualTransactions) {
if (store.isTransactional) {
((TransactionalGraph) graph).commit();
}
}
Expand Down Expand Up @@ -236,7 +234,7 @@ class DataStore {
// A triple pattern matcher for each spoc combination
public final Matcher[] matchers = new Matcher[16];

public boolean manualTransactions;
public boolean isTransactional;
public boolean volatileStatements = false;
public boolean uniqueStatements = false;

Expand Down Expand Up @@ -293,8 +291,8 @@ public Vertex findVertex(final Value value) {

public boolean matches(final Vertex vertex,
final Value value) {
String kind = (String) vertex.getProperty(KIND);
String val = (String) vertex.getProperty(VALUE);
String kind = vertex.getProperty(KIND);
String val = vertex.getProperty(VALUE);
if (value instanceof URI) {
return kind.equals(URI) && val.equals(value.stringValue());
} else if (value instanceof Literal) {
Expand All @@ -303,8 +301,8 @@ public boolean matches(final Vertex vertex,
return false;
}

String type = (String) vertex.getProperty(TYPE);
String lang = (String) vertex.getProperty(LANG);
String type = vertex.getProperty(TYPE);
String lang = vertex.getProperty(LANG);

URI vType = ((Literal) value).getDatatype();
String vLang = ((Literal) value).getLanguage();
Expand Down Expand Up @@ -528,6 +526,7 @@ private void createIndexingMatcher(final String pattern) {
store.indexers.add(m);
}

/*
private static void debugEdge(final Edge e) {
System.out.println("edge " + e + ":");
for (String key : e.getPropertyKeys()) {
Expand All @@ -553,5 +552,5 @@ private static void debugVertex(final Vertex v) {
while (i.hasNext()) {
System.out.println("\t\t" + i.next());
}
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,9 @@
import org.openrdf.query.BindingSet;
import org.openrdf.query.Dataset;
import org.openrdf.query.QueryEvaluationException;
import org.openrdf.query.algebra.QueryRoot;
import org.openrdf.query.algebra.TupleExpr;
import org.openrdf.query.algebra.Var;
import org.openrdf.query.algebra.evaluation.EvaluationStrategy;
import org.openrdf.query.algebra.evaluation.TripleSource;
import org.openrdf.query.algebra.evaluation.impl.BindingAssigner;
import org.openrdf.query.algebra.evaluation.impl.CompareOptimizer;
import org.openrdf.query.algebra.evaluation.impl.ConjunctiveConstraintSplitter;
import org.openrdf.query.algebra.evaluation.impl.ConstantOptimizer;
import org.openrdf.query.algebra.evaluation.impl.DisjunctiveConstraintOptimizer;
import org.openrdf.query.algebra.evaluation.impl.EvaluationStrategyImpl;
import org.openrdf.query.algebra.evaluation.impl.FilterOptimizer;
import org.openrdf.query.algebra.evaluation.impl.IterativeEvaluationOptimizer;
import org.openrdf.query.algebra.evaluation.impl.OrderLimitOptimizer;
import org.openrdf.query.algebra.evaluation.impl.QueryJoinOptimizer;
import org.openrdf.query.algebra.evaluation.impl.QueryModelNormalizer;
import org.openrdf.query.algebra.evaluation.impl.SameTermFilterOptimizer;
import org.openrdf.query.algebra.helpers.QueryModelVisitorBase;
import org.openrdf.query.impl.EmptyBindingSet;
import org.openrdf.sail.SailException;
import org.openrdf.sail.helpers.DefaultSailChangedEvent;
import org.openrdf.sail.helpers.NotifyingSailConnectionBase;
Expand Down Expand Up @@ -82,7 +66,7 @@ protected void startTransactionInternal() throws SailException {
}

public void commitInternal() throws SailException {
if (store.manualTransactions) {
if (store.isTransactional) {
((TransactionalGraph) store.graph).commit();
}

Expand All @@ -95,15 +79,16 @@ public void commitInternal() throws SailException {
}

public void rollbackInternal() throws SailException {
if (store.manualTransactions) {
((TransactionalGraph) store.graph).stopTransaction(TransactionalGraph.Conclusion.FAILURE);
if (store.isTransactional) {

((TransactionalGraph) store.graph).rollback();
}
}

public void closeInternal() throws SailException {
// Roll back any uncommitted operations.
if (store.manualTransactions) {
((TransactionalGraph) store.graph).stopTransaction(TransactionalGraph.Conclusion.FAILURE);
if (store.isTransactional) {
((TransactionalGraph) store.graph).rollback();
}
}

Expand All @@ -118,44 +103,6 @@ public CloseableIteration<? extends BindingSet, QueryEvaluationException> evalua
} catch (QueryEvaluationException e) {
throw new SailException(e);
}

/*
// Clone the tuple expression to allow for more aggressive optimizations
tupleExpr = tupleExpr.clone();
if (!(tupleExpr instanceof QueryRoot)) {
// Add a dummy root node to the tuple expressions to allow the
// optimizers to modify the actual root node
tupleExpr = new QueryRoot(tupleExpr);
}
try {
//replaceValues(tupleExpr);
TripleSource tripleSource = new SailConnectionTripleSource(this, store.valueFactory, includeInferred);
EvaluationStrategy strategy = new EvaluationStrategyImpl(tripleSource, dataset);
new BindingAssigner().optimize(tupleExpr, dataset, bindings);
new ConstantOptimizer(strategy).optimize(tupleExpr, dataset, bindings);
new CompareOptimizer().optimize(tupleExpr, dataset, bindings);
new ConjunctiveConstraintSplitter().optimize(tupleExpr, dataset, bindings);
new DisjunctiveConstraintOptimizer().optimize(tupleExpr, dataset, bindings);
new SameTermFilterOptimizer().optimize(tupleExpr, dataset, bindings);
new QueryModelNormalizer().optimize(tupleExpr, dataset, bindings);
// new SubSelectJoinOptimizer().optimize(tupleExpr, dataset, bindings);
//new QueryJoinOptimizer(new NativeEvaluationStatistics(nativeStore)).optimize(tupleExpr, dataset, bindings);
new IterativeEvaluationOptimizer().optimize(tupleExpr, dataset, bindings);
new FilterOptimizer().optimize(tupleExpr, dataset, bindings);
new OrderLimitOptimizer().optimize(tupleExpr, dataset, bindings);
logger.trace("Optimized query model:\n{}", tupleExpr);
return strategy.evaluate(tupleExpr, EmptyBindingSet.getInstance());
}
catch (QueryEvaluationException e) {
throw new SailException(e);
}
*/
}

public CloseableIteration<? extends Resource, SailException> getContextIDsInternal() throws SailException {
Expand Down Expand Up @@ -368,7 +315,7 @@ private void removeStatementsInternal(final boolean inferred,
//System.out.println("matcher: " + indexes.matchers[index]);
Iterable<Edge> i = store.matchers[index].match(subject, predicate, object, context, inferred);
for (Edge e : i) {
Boolean b = (Boolean) e.getProperty(GraphSail.INFERRED);
Boolean b = e.getProperty(GraphSail.INFERRED);
if ((!inferred && null == b)
|| (inferred && null != b && b)) {
edgesToRemove.add(e);
Expand Down Expand Up @@ -436,7 +383,7 @@ private void deleteEdgesInIterator(final boolean inferred,
while (iter.hasNext()) {
Edge e = iter.next();

Boolean b = (Boolean) e.getProperty(GraphSail.INFERRED);
Boolean b = e.getProperty(GraphSail.INFERRED);
if ((!inferred && null == b)
|| (inferred && null != b && b)) {
SimpleStatement s;
Expand Down Expand Up @@ -505,7 +452,7 @@ public boolean hasNext() throws SailException {

public Namespace next() throws SailException {
String prefix = prefixes.next();
String uri = (String) store.namespaces.getProperty(prefix);
String uri = store.namespaces.getProperty(prefix);
return new NamespaceImpl(fromNativePrefixKey(prefix), uri);
}

Expand Down Expand Up @@ -802,13 +749,13 @@ private String fromNativePrefixKey(final String prefix) {
}

private Value toSesame(final Vertex v) {
String value = (String) v.getProperty(GraphSail.VALUE);
String kind = (String) v.getProperty(GraphSail.KIND);
String value = v.getProperty(GraphSail.VALUE);
String kind = v.getProperty(GraphSail.KIND);
if (kind.equals(GraphSail.URI)) {
return store.valueFactory.createURI(value);
} else if (kind.equals(GraphSail.LITERAL)) {
String datatype = (String) v.getProperty(GraphSail.TYPE);
String lang = (String) v.getProperty(GraphSail.LANG);
String datatype = v.getProperty(GraphSail.TYPE);
String lang = v.getProperty(GraphSail.LANG);
return null != datatype
? store.valueFactory.createLiteral(value, store.valueFactory.createURI(datatype))
: null != lang
Expand Down

0 comments on commit 3f2b225

Please sign in to comment.