@Override
 protected double getCardinality(StatementPattern sp) {
   logger.info("get cardinality");
   try {
     Value subj = getConstantValue(sp.getSubjectVar());
     if (!(subj instanceof Resource)) {
       // can happen when a previous optimizer has inlined a
       // comparison operator.
       // this can cause, for example, the subject variable to be
       // equated to a literal value.
       // See SES-970
       subj = null;
     }
     Value pred = getConstantValue(sp.getPredicateVar());
     if (!(pred instanceof URI)) {
       // can happen when a previous optimizer has inlined a
       // comparison operator. See SES-970
       pred = null;
     }
     Value obj = getConstantValue(sp.getObjectVar());
     Value context = getConstantValue(sp.getContextVar());
     if (!(context instanceof Resource)) {
       // can happen when a previous optimizer has inlined a
       // comparison operator. See SES-970
       context = null;
     }
     //				System.out.println("begin to do kvStore.cardinalitty");
     return kvStore.cardinality((Resource) subj, (URI) pred, obj, (Resource) context);
   } catch (Exception e) {
     logger.error(
         "Failed to estimate statement pattern cardinality, falling back to generic implementation",
         e);
     return super.getCardinality(sp);
   }
 }
 public void meet(StatementPattern node) {
   if (!Scope.DEFAULT_CONTEXTS.equals(node.getScope())) {
     basicPattern = false;
   } else if (node.getContextVar() != null) {
     basicPattern = false;
   } else {
     super.meet(node);
   }
 }
 @Override
 public void meet(StatementPattern node) throws RepositoryException {
   Resource subj = (Resource) node.getSubjectVar().getValue();
   IRI pred = (IRI) node.getPredicateVar().getValue();
   Value obj = node.getObjectVar().getValue();
   Resource[] ctx = getContexts(node.getContextVar());
   for (RepositoryConnection member : members) {
     if (member.hasStatement(subj, pred, obj, true, ctx)) {
       return;
     }
   }
   node.replaceWith(new EmptySet());
 }
  @Override
  protected void meetSP(StatementPattern node) throws Exception {
    StatementPattern sp = node.clone();
    final Var predVar = sp.getPredicateVar();

    URI pred = (URI) 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)) {

      URI transPropUri = (URI) predVar.getValue();
      if (inferenceEngine.isTransitiveProperty(transPropUri)) {
        node.replaceWith(
            new TransitivePropertySP(
                sp.getSubjectVar(), sp.getPredicateVar(), sp.getObjectVar(), sp.getContextVar()));
      }
    }
  }