Github user meiercaleb commented on a diff in the pull request:
https://github.com/apache/incubator-rya/pull/135#discussion_r94295897
--- Diff:
extras/indexing/src/main/java/org/apache/rya/indexing/entity/EntityToSegmentConverter.java
---
@@ -0,0 +1,109 @@
+package org.apache.rya.indexing.entity;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.rya.indexing.entity.query.EntityQueryNode;
+import org.apache.rya.indexing.external.matching.ExternalSetConverter;
+import org.apache.rya.indexing.external.matching.JoinSegment;
+import org.apache.rya.indexing.external.matching.OptionalJoinSegment;
+import org.apache.rya.indexing.external.matching.QuerySegment;
+import org.openrdf.query.algebra.Filter;
+import org.openrdf.query.algebra.Join;
+import org.openrdf.query.algebra.LeftJoin;
+import org.openrdf.query.algebra.QueryModelNode;
+import org.openrdf.query.algebra.TupleExpr;
+import org.openrdf.query.algebra.ValueExpr;
+import org.openrdf.query.algebra.helpers.QueryModelVisitorBase;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * Implementation of {@link ExternalSetConverter} to convert {@link
EntityQueryNode}s
+ * to {@link QuerySegment}s.
+ *
+ */
+public class EntityToSegmentConverter implements
ExternalSetConverter<EntityQueryNode> {
+
+ private static final EntityToOptionalJoinSegment optional = new
EntityToOptionalJoinSegment();
+ private static final EntityToJoinSegment join = new
EntityToJoinSegment();
+
+
+ @Override
+ public QuerySegment<EntityQueryNode> setToSegment(final
EntityQueryNode set) {
+ Preconditions.checkNotNull(set);
+ //if
(PCJOptimizerUtilities.tupleContainsLeftJoins(set.getTupleExpr())) {
+ return optional.getSegment(set);
+ // } else {
+ // return join.getSegment(set);
+ //}
+ }
+
+ /**
+ * This class extracts the {@link JoinSegment} from the {@link
TupleExpr} of
+ * specified PCJ.
+ *
+ */
+ static class EntityToJoinSegment extends
QueryModelVisitorBase<RuntimeException> {
+
--- End diff --
There is no tree structure to your EntityQueryNode. Why are you using a
visitor here? Probably just a copy and paste issue. Migrate the code in lines
57 - 59 into the method starting at 36. Or just have a getSegment method.
This code does not need to be contained inside two distinct visitor classes
(you're not even using one of them!)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---