code: @Override
      public long size(Resource... contexts) throws RepositoryException {
          if (contexts == null) {
              contexts = new Resource[] { null };
          }
          try {
              StringBuilder sb = new StringBuilder();
              sb.append("SELECT (count(?s) as ?ct) where { GRAPH ?g { ?s ?p ?o }");
              boolean first = true;
              // with no args, measure the whole triple store.
              if (contexts != null && contexts.length > 0) {
                  sb.append("filter (?g = (");
                  for (Resource context : contexts) {
                      if (first) {
                          first = !first;
                      }
                      else {
                          sb.append(",");
                      }
                      if (context == null) {
                          sb.append("IRI(\""+DEFAULT_GRAPH_URI+"\")");
                      } else {
                          sb.append("IRI(\"" + context.toString() + "\")");
                      }
                  }
                  sb.append(") )");
              }else{
                  sb.append("filter (?g = (IRI(\""+DEFAULT_GRAPH_URI+"\")))");
              }
              sb.append("}");
              logger.debug(sb.toString());
              MarkLogicTupleQuery tupleQuery = prepareTupleQuery(sb.toString());
              tupleQuery.setIncludeInferred(false);
              tupleQuery.setRulesets((SPARQLRuleset) null);
              tupleQuery.setConstrainingQueryDefinition((QueryDefinition)null);
              TupleQueryResult qRes = tupleQuery.evaluate();
              // just one answer
              BindingSet result = qRes.next();
              qRes.close();
              // if 'null' was one or more of the arguments, then totalSize will be non-zero.
              return ((Literal) result.getBinding("ct").getValue()).longValue();
          } catch (QueryEvaluationException | MalformedQueryException e) {
              throw new RepositoryException(e);
          }
      }
docs: returns number of triples in supplied context
  
  @param contexts
  @return long
  @throws RepositoryException