Java Code Examples for org.eclipse.rdf4j.query.algebra.StatementPattern#getObjectVar()

The following examples show how to use org.eclipse.rdf4j.query.algebra.StatementPattern#getObjectVar() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReflexivePropertyVisitor.java    From rya with Apache License 2.0 6 votes vote down vote up
/**
 * Check whether any solution for the {@link StatementPattern} could be derived from
 * reflexive property inference, and if so, replace the pattern with a union of itself and the
 * reflexive solution.
 */
@Override
protected void meetSP(StatementPattern node) throws Exception {
    // Only applies when the predicate is defined and reflexive
    final Var predVar = node.getPredicateVar();
    if (predVar.getValue() != null && inferenceEngine.isReflexiveProperty((IRI) predVar.getValue())) {
        final StatementPattern originalSP = node.clone();
        // The reflexive solution is a ZeroLengthPath between subject and
        // object: they can be matched to one another, whether constants or
        // variables.
        final Var subjVar = node.getSubjectVar();
        final Var objVar = node.getObjectVar();
        final ZeroLengthPath reflexiveSolution = new ZeroLengthPath(subjVar, objVar);
        node.replaceWith(new InferUnion(originalSP, reflexiveSolution));
    }
}
 
Example 2
Source File: TransitivePropertyVisitor.java    From rya with Apache License 2.0 6 votes vote down vote up
@Override
protected void meetSP(final StatementPattern node) throws Exception {
    final StatementPattern sp = node.clone();
    final Var predVar = sp.getPredicateVar();

    final IRI pred = (IRI) predVar.getValue();
    final String predNamespace = pred.getNamespace();

    final Var objVar = sp.getObjectVar();
    final Var cntxtVar = sp.getContextVar();
    if (objVar != null &&
            !RDF.NAMESPACE.equals(predNamespace) &&
            !SESAME.NAMESPACE.equals(predNamespace) &&
            !RDFS.NAMESPACE.equals(predNamespace)
            && !EXPANDED.equals(cntxtVar)) {

        final IRI transPropIri = (IRI) predVar.getValue();
        if (inferenceEngine.isTransitiveProperty(transPropIri)) {
            node.replaceWith(new TransitivePropertySP(sp.getSubjectVar(), sp.getPredicateVar(), sp.getObjectVar(), sp.getContextVar()));
        }
    }
}
 
Example 3
Source File: HalyardEvaluationStatistics.java    From Halyard with Apache License 2.0 6 votes vote down vote up
@Override
protected double getCardinality(StatementPattern sp) {
    //always preffer HALYARD.SEARCH_TYPE object literals to move such statements higher in the joins tree
    Var objectVar = sp.getObjectVar();
    if (objectVar.hasValue() && (objectVar.getValue() instanceof Literal) && HALYARD.SEARCH_TYPE.equals(((Literal) objectVar.getValue()).getDatatype())) {
        return 0.0001;
    }
    Double card = spcalc == null ? null : spcalc.getCardinality(sp, boundVars);
    if (card == null) { //fallback to default cardinality calculation
        card = (hasValue(sp.getSubjectVar(), boundVars) ? 1.0 : 10.0) * (hasValue(sp.getPredicateVar(), boundVars) ? 1.0 : 10.0) * (hasValue(sp.getObjectVar(), boundVars) ? 1.0 : 10.0) * (hasValue(sp.getContextVar(), boundVars) ? 1.0 : 10.0);
    }
    for (Var v : sp.getVarList()) {
        //decrease cardinality for each priority variable present
        if (v != null && priorityVariables.contains(v.getName())) card /= 1000000.0;
    }
    return card;
}
 
Example 4
Source File: StatementMetadataNode.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a {@link StatementPattern} from the StatementPatterns
 * representing a reified query. This StatementPattern has as a subject, the
 * object of the StatementPattern containing the predicate
 * {@link RDF#SUBJECT}. This StatementPattern has as predicate, the object
 * of the StatementPattern containing the predicate {@link RDF#PREDICATE}.
 * This StatementPattern has as an object, the object of the
 * StatementPattern containing the predicate {@link RDF#OBJECT}. This method
 * also builds a map between all predicates that are not of the above type
 * and the object {@link Var}s they are associated with. This map contains
 * the user specified metadata properties and is used for comparison with
 * the metadata properties extracted from RyaStatements passed back by the
 * {@link RyaQueryEngine}.
 *
 * @param patterns
 *            - collection of patterns representing a reified query
 */
private void setStatementPatternAndProperties(final Collection<StatementPattern> patterns) {

    final StatementPattern sp = new StatementPattern();
    final Map<RyaIRI, Var> properties = new HashMap<>();

    for (final StatementPattern pattern : patterns) {
        final RyaIRI predicate = new RyaIRI(pattern.getPredicateVar().getValue().toString());

        if (!uriList.contains(predicate)) {
            final Var objVar = pattern.getObjectVar();
            properties.put(predicate, objVar);
            continue;
        }

        if (predicate.equals(SUBJ_ID_URI)) {
            sp.setContextVar(pattern.getContextVar());
            sp.setSubjectVar(pattern.getObjectVar());
        }

        if (predicate.equals(PRED_ID_URI)) {
            sp.setPredicateVar(pattern.getObjectVar());
        }

        if (predicate.equals(OBJ_ID_URI)) {
            sp.setObjectVar(pattern.getObjectVar());
        }
    }
    this.statement = sp;
    this.properties = properties;
}
 
Example 5
Source File: SymmetricPropertyVisitor.java    From rya with Apache License 2.0 5 votes vote down vote up
@Override
protected void meetSP(StatementPattern node) throws Exception {
    StatementPattern sp = node.clone();

    final Var predVar = sp.getPredicateVar();
    IRI pred = (IRI) predVar.getValue();
    String predNamespace = pred.getNamespace();

    final Var objVar = sp.getObjectVar();
    final Var cntxtVar = sp.getContextVar();
    if (objVar != null &&
            !RDF.NAMESPACE.equals(predNamespace) &&
            !SESAME.NAMESPACE.equals(predNamespace) &&
            !RDFS.NAMESPACE.equals(predNamespace)
            && !EXPANDED.equals(cntxtVar)) {
        /**
         *
         * { ?a ?pred ?b .}\n" +
         "       UNION " +
         "      { ?b ?pred ?a }
         */

        IRI symmPropIri = (IRI) predVar.getValue();
        if(inferenceEngine.isSymmetricProperty(symmPropIri)) {
            Var subjVar = sp.getSubjectVar();
            Union union = new InferUnion();
            union.setLeftArg(sp);
            union.setRightArg(new StatementPattern(objVar, predVar, subjVar, cntxtVar));
            node.replaceWith(union);
        }
    }
}
 
Example 6
Source File: GeoTemporalIndexSetProvider.java    From rya with Apache License 2.0 5 votes vote down vote up
private void discoverPatterns(final StatementPattern pattern, final List<QueryModelNode> unmatched) {
    final Var subj = pattern.getSubjectVar();
    final Var objVar = pattern.getObjectVar();

    patternMap.put(subj, pattern);
    objectPatterns.put(objVar, pattern);
    //check for existing filters.
    if(unmatchedFilters.containsKey(objVar)) {
        final Collection<FunctionCall> calls = unmatchedFilters.removeAll(objVar);
        for(final FunctionCall call : calls) {
            addFilter(call);
            matchedFilters.put(objVar, call);
        }
    }
}
 
Example 7
Source File: AllValuesFromVisitor.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Checks whether the StatementPattern is a type query whose solutions could be inferred
 * by allValuesFrom inference, and if so, replaces the node with a union of itself and any
 * possible inference.
 */
@Override
protected void meetSP(StatementPattern node) throws Exception {
    final Var subjVar = node.getSubjectVar();
    final Var predVar = node.getPredicateVar();
    final Var objVar = node.getObjectVar();
    // Only applies to type queries where the type is defined
    if (predVar != null && RDF.TYPE.equals(predVar.getValue()) && objVar != null && objVar.getValue() instanceof Resource) {
        final Resource typeToInfer = (Resource) objVar.getValue();
        Map<Resource, Set<IRI>> relevantAvfRestrictions = inferenceEngine.getAllValuesFromByValueType(typeToInfer);
        if (!relevantAvfRestrictions.isEmpty()) {
            // We can infer the queried type if, for an allValuesFrom restriction type
            // associated  with the queried type, some anonymous neighboring node belongs to the
            // restriction type and has the node in question (subjVar) as a value for the
            // restriction's property.
            final Var avfTypeVar = new Var("t-" + UUID.randomUUID());
            final Var avfPredVar = new Var("p-" + UUID.randomUUID());
            final Var neighborVar = new Var("n-" + UUID.randomUUID());
            neighborVar.setAnonymous(true);
            final StatementPattern membershipPattern = new DoNotExpandSP(neighborVar,
                    new Var(RDF.TYPE.stringValue(), RDF.TYPE), avfTypeVar);
            final StatementPattern valuePattern = new StatementPattern(neighborVar, avfPredVar, subjVar);
            final InferJoin avfPattern = new InferJoin(membershipPattern, valuePattern);
            // Use a FixedStatementPattern to contain the appropriate (restriction, predicate)
            // pairs, and check each one against the general pattern.
            final FixedStatementPattern avfPropertyTypes = new FixedStatementPattern(avfTypeVar,
                    new Var(OWL.ONPROPERTY.stringValue(), OWL.ONPROPERTY), avfPredVar);
            for (Resource avfRestrictionType : relevantAvfRestrictions.keySet()) {
                for (IRI avfProperty : relevantAvfRestrictions.get(avfRestrictionType)) {
                    avfPropertyTypes.statements.add(new NullableStatementImpl(avfRestrictionType,
                            OWL.ONPROPERTY, avfProperty));
                }
            }
            final InferJoin avfInferenceQuery = new InferJoin(avfPropertyTypes, avfPattern);
            node.replaceWith(new InferUnion(node.clone(), avfInferenceQuery));
        }
    }
}
 
Example 8
Source File: SomeValuesFromVisitor.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Checks whether the StatementPattern is a type query whose solutions could be inferred by
 * someValuesFrom inference, and if so, replaces the node with a union of itself and any
 * possible inference.
 */
@Override
protected void meetSP(StatementPattern node) throws Exception {
    final Var subjVar = node.getSubjectVar();
    final Var predVar = node.getPredicateVar();
    final Var objVar = node.getObjectVar();
    // Only applies to type queries where the type is defined
    if (predVar != null && RDF.TYPE.equals(predVar.getValue()) && objVar != null && objVar.getValue() instanceof Resource) {
        final Resource typeToInfer = (Resource) objVar.getValue();
        Map<Resource, Set<IRI>> relevantSvfRestrictions = inferenceEngine.getSomeValuesFromByRestrictionType(typeToInfer);
        if (!relevantSvfRestrictions.isEmpty()) {
            // We can infer the queried type if it is to a someValuesFrom restriction (or a
            // supertype of one), and the node in question (subjVar) is the subject of a triple
            // whose predicate is the restriction's property and whose object is an arbitrary
            // node of the restriction's value type.
            final Var valueTypeVar = new Var("t-" + UUID.randomUUID());
            final Var svfPredVar = new Var("p-" + UUID.randomUUID());
            final Var neighborVar = new Var("n-" + UUID.randomUUID());
            neighborVar.setAnonymous(true);
            final StatementPattern membershipPattern = new DoNotExpandSP(neighborVar,
                    new Var(RDF.TYPE.stringValue(), RDF.TYPE), valueTypeVar);
            final StatementPattern valuePattern = new StatementPattern(subjVar, svfPredVar, neighborVar);
            final InferJoin svfPattern = new InferJoin(membershipPattern, valuePattern);
            // Use a FixedStatementPattern to contain the appropriate (predicate, value type)
            // pairs, and check each one against the general pattern.
            final FixedStatementPattern svfPropertyTypes = new FixedStatementPattern(svfPredVar,
                    new Var(OWL.SOMEVALUESFROM.stringValue(), OWL.SOMEVALUESFROM), valueTypeVar);
            for (Resource svfValueType : relevantSvfRestrictions.keySet()) {
                for (IRI svfProperty : relevantSvfRestrictions.get(svfValueType)) {
                    svfPropertyTypes.statements.add(new NullableStatementImpl(svfProperty,
                            OWL.SOMEVALUESFROM, svfValueType));
                }
            }
            final InferJoin svfInferenceQuery = new InferJoin(svfPropertyTypes, svfPattern);
            node.replaceWith(new InferUnion(node.clone(), svfInferenceQuery));
        }
    }
}
 
Example 9
Source File: IntersectionOfVisitor.java    From rya with Apache License 2.0 5 votes vote down vote up
@Override
protected void meetSP(final StatementPattern node) throws Exception {
    final StatementPattern currentNode = node.clone();
    final Var subVar = node.getSubjectVar();
    final Var predVar = node.getPredicateVar();
    final Var objVar = node.getObjectVar();
    final Var conVar = node.getContextVar();
    if (predVar != null && objVar != null && objVar.getValue() != null && RDF.TYPE.equals(predVar.getValue()) && !EXPANDED.equals(conVar)) {
        final List<Set<Resource>> intersections = inferenceEngine.getIntersectionsImplying((IRI) objVar.getValue());
        if (intersections != null && !intersections.isEmpty()) {
            final List<TupleExpr> joins = new ArrayList<>();
            for (final Set<Resource> intersection : intersections) {
                final Set<Resource> sortedIntersection = new TreeSet<>(new ResourceComparator());
                sortedIntersection.addAll(intersection);

                // Create a join tree of all statement patterns in the
                // current intersection.
                final TupleExpr joinTree = createJoinTree(new ArrayList<>(sortedIntersection), subVar, conVar);
                if (joinTree != null) {
                    joins.add(joinTree);
                }
            }

            if (!joins.isEmpty()) {
                // Combine all the intersection join trees for the type
                // together into a union tree.  This will be a join tree if
                // only one intersection exists.
                final TupleExpr unionTree = createUnionTree(joins);
                // Union the above union tree of intersections with the
                // original node.
                final Union union = new InferUnion(unionTree, currentNode);
                node.replaceWith(union);
                log.trace("Replacing node with inferred intersection union: " + union);
            }
        }
    }
}
 
Example 10
Source File: InverseOfVisitor.java    From rya with Apache License 2.0 5 votes vote down vote up
@Override
protected void meetSP(StatementPattern node) throws Exception {
    StatementPattern sp = node.clone();
    final Var predVar = sp.getPredicateVar();

    IRI pred = (IRI) predVar.getValue();
    String predNamespace = pred.getNamespace();

    final Var objVar = sp.getObjectVar();
    final Var cntxtVar = sp.getContextVar();
    if (objVar != null &&
            !RDF.NAMESPACE.equals(predNamespace) &&
            !SESAME.NAMESPACE.equals(predNamespace) &&
            !RDFS.NAMESPACE.equals(predNamespace)
            && !EXPANDED.equals(cntxtVar)) {
        /**
         *
         * { ?a ?pred ?b .}\n" +
         "       UNION " +
         "      { ?b ?pred ?a }
         */

        IRI predIri = (IRI) predVar.getValue();
        IRI invPropIri = inferenceEngine.findInverseOf(predIri);
        if (invPropIri != null) {
            Var subjVar = sp.getSubjectVar();
            Union union = new InferUnion();
            union.setLeftArg(sp);
            union.setRightArg(new StatementPattern(objVar, new Var(predVar.getName(), invPropIri), subjVar, cntxtVar));
            node.replaceWith(union);
        }
    }
}
 
Example 11
Source File: FedXStatementPattern.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public FedXStatementPattern(StatementPattern node, QueryInfo queryInfo) {
	super(node.getSubjectVar(), node.getPredicateVar(), node.getObjectVar(), node.getContextVar());
	setScope(node.getScope());
	this.id = NodeFactory.getNextId();
	this.queryInfo = queryInfo;
	initFreeVars();
}
 
Example 12
Source File: FluoStringConverter.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Provides a string representation of an SP which contains info about
 * whether each component (subj, pred, obj) is constant and its data and
 * data type if it is constant.
 *
 * @param sp - The statement pattern to convert. (not null)
 * @return A String representation of the statement pattern that may be
 *   used to do triple matching.
 */
public static String toStatementPatternString(final StatementPattern sp) {
    checkNotNull(sp);

    final Var subjVar = sp.getSubjectVar();
    String subj = subjVar.getName();
    if(subjVar.getValue() != null) {
        final Value subjValue = subjVar.getValue();
        subj = VarNameUtils.createSimpleConstVarName(subjVar);
        if (subjValue instanceof BNode ) {
            subj = subj + TYPE_DELIM + RyaSchema.BNODE_NAMESPACE + TYPE_DELIM + ((BNode) subjValue).getID();
        } else {
            subj = subj + TYPE_DELIM + URI_TYPE;
        }
    }

    final Var predVar = sp.getPredicateVar();
    String pred = predVar.getName();
    if(predVar.getValue() != null) {
        pred = VarNameUtils.createSimpleConstVarName(predVar);
        pred = pred + TYPE_DELIM + URI_TYPE;
    }

    final Var objVar = sp.getObjectVar();
    String obj = objVar.getName();
    if (objVar.getValue() != null) {
        final Value objValue = objVar.getValue();
        obj = VarNameUtils.createSimpleConstVarName(objVar);
        final RyaType rt = RdfToRyaConversions.convertValue(objValue);
        obj =  obj + TYPE_DELIM + rt.getDataType().stringValue();
    }

    return subj + DELIM + pred + DELIM + obj;
}
 
Example 13
Source File: EmptyStatementPattern.java    From CostFed with GNU Affero General Public License v3.0 4 votes vote down vote up
public EmptyStatementPattern(StatementPattern node) {
	super(node.getSubjectVar(), node.getPredicateVar(), node.getObjectVar(), node.getContextVar());
}
 
Example 14
Source File: ConstructProjection.java    From rya with Apache License 2.0 4 votes vote down vote up
public ConstructProjection(StatementPattern pattern) {
    this(pattern.getSubjectVar(), pattern.getPredicateVar(), pattern.getObjectVar());
}
 
Example 15
Source File: PrepareOwnedTupleExpr.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void meet(StatementPattern node) throws RepositoryException {
	StringBuilder builder = new StringBuilder();
	Scope scope = node.getScope();
	Var subj = node.getSubjectVar();
	Var pred = node.getPredicateVar();
	Var obj = node.getObjectVar();
	Var ctx = node.getContextVar();
	boolean cokay = ctx == null && scope.equals(Scope.DEFAULT_CONTEXTS)
			|| ctx != null && scope.equals(Scope.NAMED_CONTEXTS);
	boolean sokay = !subj.hasValue() || subj.isAnonymous() || subj.getValue() instanceof IRI;
	boolean ookay = !obj.hasValue() || obj.isAnonymous() || obj.getValue() instanceof IRI
			|| obj.getValue() instanceof Literal;
	if (cokay && sokay && ookay) {
		variables.clear();
		if (ctx != null) {
			builder.append("GRAPH ");
			appendVar(builder, ctx.getName());
			builder.append(" {\n");
		}
		appendVar(builder, subj);
		appendVar(builder, pred);
		appendVar(builder, obj);
		builder.append(" .");
		appendFilter(builder, subj);
		appendFilter(builder, pred);
		appendFilter(builder, obj);
		if (ctx != null) {
			if (ctx.hasValue()) {
				builder.append("\nFILTER sameTerm(");
				appendVar(builder, ctx.getName());
				builder.append(", ");
				writeValue(builder, ctx.getValue());
				builder.append(")\n");
			}
			builder.append("}");
		}
		this.pattern = builder.toString();
		this.patternNode = node;
	} else {
		this.patternNode = null; // NOPMD
	}
}
 
Example 16
Source File: SpinMagicPropertyInterpreter.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private TupleExpr addList(List<? super Var> list, Var subj,
		Map<String, Map<IRI, List<StatementPattern>>> spIndex) {
	TupleExpr node = null;
	do {
		Map<IRI, List<StatementPattern>> predMap = spIndex.get(subj.getName());
		if (predMap == null) {
			return null;
		}

		List<StatementPattern> firstStmts = predMap.get(RDF.FIRST);
		if (firstStmts == null) {
			return null;
		}
		if (firstStmts.size() != 1) {
			return null;
		}

		List<StatementPattern> restStmts = predMap.get(RDF.REST);
		if (restStmts == null) {
			return null;
		}
		if (restStmts.size() != 1) {
			return null;
		}

		StatementPattern firstStmt = firstStmts.get(0);
		list.add(firstStmt.getObjectVar());
		node = join(node, firstStmt);

		StatementPattern restStmt = restStmts.get(0);
		subj = restStmt.getObjectVar();
		node = join(node, restStmt);

		List<StatementPattern> typeStmts = predMap.get(RDF.TYPE);
		if (typeStmts != null) {
			for (StatementPattern sp : firstStmts) {
				Value type = sp.getObjectVar().getValue();
				if (RDFS.RESOURCE.equals(type) || RDF.LIST.equals(type)) {
					node = join(node, sp);
				}
			}
		}
	} while (!RDF.NIL.equals(subj.getValue()));
	return node;
}
 
Example 17
Source File: TrueStatementPattern.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public TrueStatementPattern(StatementPattern node) {
	super(node.getSubjectVar(), node.getPredicateVar(), node.getObjectVar(), node.getContextVar());
}
 
Example 18
Source File: EmptyStatementPattern.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public EmptyStatementPattern(StatementPattern node) {
	super(node.getSubjectVar(), node.getPredicateVar(), node.getObjectVar(), node.getContextVar());
}
 
Example 19
Source File: GeoTemporalIndexSetProvider.java    From rya with Apache License 2.0 4 votes vote down vote up
private EventQueryNode getGeoTemporalNode(final Var subj) {
    final Collection<StatementPattern> patterns = patternMap.get(subj);
    final Collection<FunctionCall> usedFilters = new ArrayList<>();
    Optional<StatementPattern> geoPattern = Optional.empty();
    Optional<StatementPattern> temporalPattern = Optional.empty();
    Optional<Collection<IndexingExpr>> geoFilters = Optional.empty();
    Optional<Collection<IndexingExpr>> temporalFilters = Optional.empty();

    //should only be 2 patterns.
    for(final StatementPattern sp : patterns) {
        final Var obj = sp.getObjectVar();

        ///filter map does not have _const_


        if(filterMap.containsKey(obj)) {
            final Collection<IndexingExpr> filters = filterMap.get(obj);
            final IndexingFunctionRegistry.FUNCTION_TYPE type = ensureSameType(filters);
            if(type != null && type == FUNCTION_TYPE.GEO) {
                geoPattern = Optional.of(sp);
                geoFilters = Optional.of(filters);
                usedFilters.addAll(matchedFilters.get(obj));
            } else if(type != null && type == FUNCTION_TYPE.TEMPORAL) {
                temporalPattern = Optional.of(sp);
                temporalFilters = Optional.of(filters);
                usedFilters.addAll(matchedFilters.get(obj));
            } else {
                return null;
            }
        } else {
            return null;
        }
    }

    if(geoFilters.isPresent() && temporalFilters.isPresent() && geoPattern.isPresent() && temporalPattern.isPresent()) {
        return new EventQueryNodeBuilder()
                .setStorage(eventStorage)
                .setGeoPattern(geoPattern.get())
                .setTemporalPattern(temporalPattern.get())
                .setGeoFilters(geoFilters.get())
                .setTemporalFilters(temporalFilters.get())
                .setUsedFilters(usedFilters)
                .build();
    } else {
        return null;
    }
}
 
Example 20
Source File: SubClassOfVisitor.java    From rya with Apache License 2.0 4 votes vote down vote up
@Override
    protected void meetSP(final StatementPattern node) throws Exception {
        final StatementPattern sp = node.clone();
        final Var predVar = sp.getPredicateVar();
        final Var objVar = sp.getObjectVar();
        final Var conVar = sp.getContextVar();
        if (predVar != null && objVar != null && objVar.getValue() != null && RDF.TYPE.equals(predVar.getValue())
                && !EXPANDED.equals(conVar)) {
            /**
             * ?type sesame:directSubClassOf ub:Student . ?student rdf:type ?type +
             */
//            String s = UUID.randomUUID().toString();
//            Var typeVar = new Var(s);
//            StatementPattern subClassOf = new StatementPattern(typeVar, new Var("c-" + s, SESAME.DIRECTSUBCLASSOF), objVar, SUBCLASS_EXPANDED);
//            StatementPattern rdfType = new StatementPattern(sp.getSubjectVar(), sp.getPredicateVar(), typeVar, SUBCLASS_EXPANDED);
//            InferJoin join = new InferJoin(subClassOf, rdfType);
//            join.getProperties().put(InferConstants.INFERRED, InferConstants.TRUE);
//            node.replaceWith(join);

            final IRI subclassof_iri = (IRI) objVar.getValue();
            final Collection<IRI> parents = InferenceEngine.findParents(inferenceEngine.getSubClassOfGraph(), subclassof_iri);
            if (parents != null && parents.size() > 0) {
                final String s = UUID.randomUUID().toString();
                final Var typeVar = new Var(s);
                final FixedStatementPattern fsp = new FixedStatementPattern(typeVar, new Var("c-" + s, RDFS.SUBCLASSOF), objVar, conVar);
                parents.add(subclassof_iri);
                for (final IRI iri : parents) {
                    fsp.statements.add(new NullableStatementImpl(iri, RDFS.SUBCLASSOF, subclassof_iri));
                }

                final StatementPattern rdfType = new DoNotExpandSP(sp.getSubjectVar(), sp.getPredicateVar(), typeVar, conVar);
                final InferJoin join = new InferJoin(fsp, rdfType);
                join.getProperties().put(InferConstants.INFERRED, InferConstants.TRUE);
                node.replaceWith(join);
            }

//            if (parents != null && parents.size() > 0) {
//                StatementPatterns statementPatterns = new StatementPatterns();
//                statementPatterns.patterns.add(node);
//                Var subjVar = node.getSubjectVar();
//                for (IRI iri : parents) {
//                    statementPatterns.patterns.add(new StatementPattern(subjVar, predVar, new Var(objVar.getName(), iri)));
//                }
//                node.replaceWith(statementPatterns);
//            }

//            if (parents != null && parents.size() > 0) {
//                VarCollection vc = new VarCollection();
//                vc.setName(objVar.getName());
//                vc.values.add(objVar);
//                for (IRI iri : parents) {
//                    vc.values.add(new Var(objVar.getName(), iri));
//                }
//                Var subjVar = node.getSubjectVar();
//                node.replaceWith(new StatementPattern(subjVar, predVar, vc, node.getContextVar()));
//            }
        }
    }