core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentAbstract.java
public long countClass(final String iClassName, final boolean iPolymorphic) {
    final OClass cls = getMetadata().getImmutableSchemaSnapshot().getClass(iClassName);
    if (cls == null)
      throw new IllegalArgumentException("Class '" + cls + "' not found in database");

    return countClass(cls, iPolymorphic);
  }
public long countClass(final String iClassName, final boolean iPolymorphic) {
    final OClass cls = getMetadata().getImmutableSchemaSnapshot().getClass(iClassName);
    if (cls == null)
      throw new IllegalArgumentException("Class '" + cls + "' not found in database");

    return countClass(cls, iPolymorphic);
  }
Returns the number of the records of the class iClassName considering also sub classes if polymorphic is true.