@Override
  public String toString() {
    QueryModelTreePrinter treePrinter = new QueryModelTreePrinter();
    UnarySqlOperator clone = this.clone();
    UnarySqlOperator parent =
        new UnarySqlOperator(clone) {

          @Override
          public <X extends Exception> void visit(RdbmsQueryModelVisitorBase<X> visitor) throws X {
            visitor.meetOther(this);
          }
        };
    new SqlConstantOptimizer().optimize(clone);
    parent.getArg().visit(treePrinter);
    return treePrinter.getTreeString();
  }
  public static void main(String[] args) throws Exception {

    Sail s = new MemoryStore();
    SailRepository repo = new SailRepository(s);
    repo.initialize();
    SailRepositoryConnection conn = repo.getConnection();

    URI sub = new URIImpl("uri:entity");
    URI subclass = new URIImpl("uri:class");
    URI obj = new URIImpl("uri:obj");
    URI talksTo = new URIImpl("uri:talksTo");

    conn.add(sub, RDF.TYPE, subclass);
    conn.add(sub, RDFS.LABEL, new LiteralImpl("label"));
    conn.add(sub, talksTo, obj);

    URI sub2 = new URIImpl("uri:entity2");
    URI subclass2 = new URIImpl("uri:class2");
    URI obj2 = new URIImpl("uri:obj2");

    conn.add(sub2, RDF.TYPE, subclass2);
    conn.add(sub2, RDFS.LABEL, new LiteralImpl("label2"));
    conn.add(sub2, talksTo, obj2);

    // TODO Auto-generated method stub
    String indexSparqlString =
        "" //
            + "SELECT ?e ?l ?c " //
            + "{" //
            + "  ?e a ?c . " //
            + "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l " //
            + "}"; //

    conn.prepareTupleQuery(QueryLanguage.SPARQL, indexSparqlString)
        .evaluate(new SPARQLResultsXMLWriter(System.out));

    SPARQLParser sp = new SPARQLParser();
    ParsedQuery pq = sp.parseQuery(indexSparqlString, null);
    System.out.println(pq);

    List<ExternalTupleSet> index = Lists.newArrayList();

    Connector accCon = new MockInstance().getConnector("root", "".getBytes());
    String tablename = "table";
    accCon.tableOperations().create(tablename);
    index.add(new AccumuloIndexSet(indexSparqlString, conn, accCon, tablename));

    String queryString =
        "" //
            + "SELECT ?e ?c ?l ?o " //
            + "{" //
            + "  ?e a ?c . " //
            + "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . " //
            + "  ?e <uri:talksTo> ?o . " //
            + "}"; //

    conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString)
        .evaluate(new SPARQLResultsXMLWriter(System.out));

    pq = sp.parseQuery(queryString, null);
    QueryModelTreePrinter mp = new QueryModelTreePrinter();
    pq.getTupleExpr().visit(mp);
    System.out.println(mp.getTreeString());
    System.out.println(pq.getTupleExpr());

    System.out.println("++++++++++++");
    ExternalProcessor processor = new ExternalProcessor(index);
    System.out.println(processor.process(pq.getTupleExpr()));

    System.out.println("----------------");
    Sail processingSail = new ExternalSail(s, processor);
    SailRepository smartSailRepo = new SailRepository(processingSail);
    smartSailRepo.initialize();

    smartSailRepo
        .getConnection()
        .prepareTupleQuery(QueryLanguage.SPARQL, queryString)
        .evaluate(new SPARQLResultsXMLWriter(System.out));
  }