Github user meiercaleb commented on a diff in the pull request:
https://github.com/apache/incubator-rya/pull/135#discussion_r94295916
--- 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> {
+
+ private JoinSegment<EntityQueryNode> segment;
+
+ private EntityToJoinSegment(){};
+
+ public QuerySegment<EntityQueryNode> getSegment(final
EntityQueryNode entity) {
+ final Set<QueryModelNode> matched = new
HashSet<>(entity.getPatterns());
+ final List<QueryModelNode> unmatched = new
ArrayList<>(entity.getPatterns());
+ segment = new JoinSegment<EntityQueryNode>(matched, unmatched,
new HashMap<ValueExpr, Filter>());
+ return segment;
+ }
+
+ @Override
+ public void meet(final Join join) {
+ segment = new JoinSegment<EntityQueryNode>(join);
+ }
+
+ @Override
+ public void meet(final Filter filter) {
+ segment = new JoinSegment<EntityQueryNode>(filter);
+ }
+
+ }
+
+ /**
+ * This class extracts the {@link OptionalJoinSegment} of PCJ query.
+ *
+ */
+ static class EntityToOptionalJoinSegment extends
QueryModelVisitorBase<RuntimeException> {
--- End diff --
Get rid of this. See above comment.
---
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.
---