-
Notifications
You must be signed in to change notification settings - Fork 72
RYA-253 Converted the rya.prospector class from Groovy to Java. Also added documentation to the project. #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,11 @@ | |
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| import org.apache.accumulo.core.client.AccumuloException; | ||
| import org.apache.accumulo.core.client.AccumuloSecurityException; | ||
| import org.apache.accumulo.core.client.TableExistsException; | ||
| import org.apache.hadoop.conf.Configurable; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.rya.accumulo.AccumuloRdfConfiguration; | ||
| import org.apache.rya.api.RdfCloudTripleStoreConfiguration; | ||
| import org.apache.rya.api.persist.joinselect.SelectivityEvalDAO; | ||
|
|
@@ -33,11 +38,6 @@ | |
| import org.apache.rya.prospector.service.ProspectorServiceEvalStatsDAO; | ||
| import org.apache.rya.rdftriplestore.inference.DoNotExpandSP; | ||
| import org.apache.rya.rdftriplestore.utils.FixedStatementPattern; | ||
|
|
||
| import org.apache.accumulo.core.client.AccumuloException; | ||
| import org.apache.accumulo.core.client.AccumuloSecurityException; | ||
| import org.apache.hadoop.conf.Configurable; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.openrdf.query.BindingSet; | ||
| import org.openrdf.query.Dataset; | ||
| import org.openrdf.query.algebra.Filter; | ||
|
|
@@ -47,12 +47,15 @@ | |
| import org.openrdf.query.algebra.TupleExpr; | ||
| import org.openrdf.query.algebra.evaluation.QueryOptimizer; | ||
| import org.openrdf.query.algebra.helpers.QueryModelVisitorBase; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import com.google.common.collect.HashMultimap; | ||
| import com.google.common.collect.Lists; | ||
| import com.google.common.collect.Sets; | ||
|
|
||
| public class EntityOptimizer implements QueryOptimizer, Configurable { | ||
| private static final Logger LOG = LoggerFactory.getLogger(EntityTupleSet.class); | ||
|
|
||
| private SelectivityEvalDAO<RdfCloudTripleStoreConfiguration> eval; | ||
| private RdfCloudTripleStoreConfiguration conf; | ||
|
|
@@ -69,10 +72,8 @@ public EntityOptimizer(RdfCloudTripleStoreConfiguration conf) { | |
| eval = new AccumuloSelectivityEvalDAO(conf, ConfigUtils.getConnector(conf)); | ||
| ((AccumuloSelectivityEvalDAO)eval).setRdfEvalDAO(new ProspectorServiceEvalStatsDAO(ConfigUtils.getConnector(conf), conf)); | ||
| eval.init(); | ||
| } catch (AccumuloException e) { | ||
| e.printStackTrace(); | ||
| } catch (AccumuloSecurityException e) { | ||
| e.printStackTrace(); | ||
| } catch (final AccumuloException | AccumuloSecurityException | TableExistsException e) { | ||
| LOG.warn("A problem was encountered while constructing the EntityOptimizer.", e); | ||
| } | ||
|
|
||
| isEvalDaoSet = true; | ||
|
|
@@ -103,10 +104,8 @@ public void setConf(Configuration conf) { | |
| eval = new AccumuloSelectivityEvalDAO(this.conf, ConfigUtils.getConnector(this.conf)); | ||
| ((AccumuloSelectivityEvalDAO)eval).setRdfEvalDAO(new ProspectorServiceEvalStatsDAO(ConfigUtils.getConnector(this.conf), this.conf)); | ||
| eval.init(); | ||
| } catch (AccumuloException e) { | ||
| e.printStackTrace(); | ||
| } catch (AccumuloSecurityException e) { | ||
| e.printStackTrace(); | ||
| } catch (final AccumuloException | AccumuloSecurityException | TableExistsException e) { | ||
| LOG.warn("A problem was encountered while setting the Configuration for the EntityOptimizer.", e); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there a way we can make this more informative?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know what else you'd say here. The chained exception will have the details. |
||
| } | ||
|
|
||
| isEvalDaoSet = true; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| package org.apache.rya.indexing.accumulo.entity; | ||
|
|
||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
|
|
@@ -18,15 +16,17 @@ | |
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
|
|
||
| import info.aduna.iteration.CloseableIteration; | ||
| package org.apache.rya.indexing.accumulo.entity; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| import org.apache.accumulo.core.client.AccumuloException; | ||
| import org.apache.accumulo.core.client.AccumuloSecurityException; | ||
| import org.apache.accumulo.core.client.Connector; | ||
| import org.apache.commons.io.IOUtils; | ||
| import org.apache.rya.accumulo.AccumuloRdfConfiguration; | ||
| import org.apache.rya.accumulo.AccumuloRyaDAO; | ||
| import org.apache.rya.api.RdfCloudTripleStoreConfiguration; | ||
|
|
@@ -37,24 +37,23 @@ | |
| import org.apache.rya.rdftriplestore.RdfCloudTripleStore; | ||
| import org.apache.rya.rdftriplestore.RdfCloudTripleStoreConnection; | ||
| import org.apache.rya.rdftriplestore.evaluation.ExternalBatchingIterator; | ||
|
|
||
| import org.apache.accumulo.core.client.AccumuloException; | ||
| import org.apache.accumulo.core.client.AccumuloSecurityException; | ||
| import org.apache.accumulo.core.client.Connector; | ||
| import org.apache.commons.io.IOUtils; | ||
| import org.openrdf.query.BindingSet; | ||
| import org.openrdf.query.QueryEvaluationException; | ||
| import org.openrdf.query.algebra.StatementPattern; | ||
| import org.openrdf.query.algebra.Var; | ||
| import org.openrdf.query.algebra.evaluation.QueryBindingSet; | ||
| import org.openrdf.query.algebra.evaluation.impl.ExternalSet; | ||
| import org.openrdf.sail.SailException; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import com.beust.jcommander.internal.Sets; | ||
| import com.google.common.base.Joiner; | ||
|
|
||
| public class EntityTupleSet extends ExternalSet implements ExternalBatchingIterator { | ||
| import info.aduna.iteration.CloseableIteration; | ||
|
|
||
| public class EntityTupleSet extends ExternalSet implements ExternalBatchingIterator { | ||
| private static final Logger LOG = LoggerFactory.getLogger(EntityTupleSet.class); | ||
|
|
||
| private StarQuery starQuery; | ||
| private RdfCloudTripleStoreConfiguration conf; | ||
|
|
@@ -97,26 +96,29 @@ private void init() { | |
| } catch (AccumuloSecurityException e) { | ||
| e.printStackTrace(); | ||
| } | ||
| if (conf.isUseStats() && conf.isUseSelectivity()) { | ||
|
|
||
| ProspectorServiceEvalStatsDAO evalDao = new ProspectorServiceEvalStatsDAO(accCon, conf); | ||
| evalDao.init(); | ||
| AccumuloSelectivityEvalDAO ase = new AccumuloSelectivityEvalDAO(conf, accCon); | ||
| ase.setRdfEvalDAO(evalDao); | ||
| ase.init(); | ||
|
|
||
| cardinality = starQuery.getCardinality(ase); | ||
| CardinalityStatementPattern csp = starQuery.getMinCardSp(ase); | ||
|
|
||
| minCard = csp.getCardinality(); | ||
| minSp = csp.getSp(); | ||
| } else { | ||
| // TODO come up with a better default if cardinality is not | ||
| // initialized | ||
| cardinality = minCard = 1; | ||
| minSp = starQuery.getNodes().get(0); | ||
| try { | ||
| if (conf.isUseStats() && conf.isUseSelectivity()) { | ||
| ProspectorServiceEvalStatsDAO evalDao = new ProspectorServiceEvalStatsDAO(accCon, conf); | ||
| evalDao.init(); | ||
| AccumuloSelectivityEvalDAO ase = new AccumuloSelectivityEvalDAO(conf, accCon); | ||
| ase.setRdfEvalDAO(evalDao); | ||
| ase.init(); | ||
|
|
||
| cardinality = starQuery.getCardinality(ase); | ||
| CardinalityStatementPattern csp = starQuery.getMinCardSp(ase); | ||
|
|
||
| minCard = csp.getCardinality(); | ||
| minSp = csp.getSp(); | ||
| } else { | ||
| // TODO come up with a better default if cardinality is not | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this a 'make jira ticket' todo or can this be removed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea. This comment was already present when I was converting. |
||
| // initialized | ||
| cardinality = minCard = 1; | ||
| minSp = starQuery.getNodes().get(0); | ||
| } | ||
| } catch(final Exception e) { | ||
| LOG.warn("A problem was encountered while initializing the EntityTupleSet.", e); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -224,7 +226,7 @@ private int numberOfSpVars(StatementPattern sp) { | |
|
|
||
|
|
||
| @Override | ||
| public CloseableIteration<BindingSet,QueryEvaluationException> evaluate(final Collection<BindingSet> bindingset) throws QueryEvaluationException { | ||
| public CloseableIteration<BindingSet,QueryEvaluationException> evaluate(Collection<BindingSet> bindingset) throws QueryEvaluationException { | ||
|
|
||
| if(bindingset.size() < 2 && !this.evalOptUsed) { | ||
| BindingSet bs = new QueryBindingSet(); | ||
|
|
@@ -248,7 +250,7 @@ public CloseableIteration<BindingSet,QueryEvaluationException> evaluate(final Co | |
|
|
||
| private RdfCloudTripleStoreConnection getRyaSailConnection() throws AccumuloException, | ||
| AccumuloSecurityException, SailException { | ||
| final RdfCloudTripleStore store = new RdfCloudTripleStore(); | ||
| RdfCloudTripleStore store = new RdfCloudTripleStore(); | ||
| AccumuloRyaDAO crdfdao = new AccumuloRyaDAO(); | ||
| crdfdao.setConnector(accCon); | ||
| AccumuloRdfConfiguration acc = new AccumuloRdfConfiguration(conf); | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there a way we can make this more informative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what else you'd say here. The chained exception will have the details.