core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLTruncateCluster.java
public Object execute(final Map<Object, Object> iArgs) {
    if (clusterName == null)
      throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");

    final ODatabaseDocumentInternal database = getDatabase();

    final int clusterId = database.getClusterIdByName(clusterName);
    if (clusterId < 0) {
      throw new ODatabaseException("Cluster with name " + clusterName + " does not exist");
    }

    final OSchema schema = database.getMetadata().getSchema();
    final OClass clazz = schema.getClassByClusterId(clusterId);
    if (clazz == null) {
      final OStorage storage = database.getStorage();
      final OCluster cluster = storage.getClusterById(clusterId);

      if (cluster == null) {
        throw new ODatabaseException("Cluster with name " + clusterName + " does not exist");
      }

      try {
        database.checkForClusterPermissions(cluster.getName());
        cluster.truncate();
      } catch (IOException ioe) {
        throw OException.wrapException(new ODatabaseException("Error during truncation of cluster with name " + clusterName), ioe);
      }
    } else {
      clazz.truncateCluster(clusterName);
    }
    return true;
  }
public Object execute(final Map<Object, Object> iArgs) {
    if (clusterName == null)
      throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");

    final ODatabaseDocumentInternal database = getDatabase();

    final int clusterId = database.getClusterIdByName(clusterName);
    if (clusterId < 0) {
      throw new ODatabaseException("Cluster with name " + clusterName + " does not exist");
    }

    final OSchema schema = database.getMetadata().getSchema();
    final OClass clazz = schema.getClassByClusterId(clusterId);
    if (clazz == null) {
      final OStorage storage = database.getStorage();
      final OCluster cluster = storage.getClusterById(clusterId);

      if (cluster == null) {
        throw new ODatabaseException("Cluster with name " + clusterName + " does not exist");
      }

      try {
        database.checkForClusterPermissions(cluster.getName());
        cluster.truncate();
      } catch (IOException ioe) {
        throw OException.wrapException(new ODatabaseException("Error during truncation of cluster with name " + clusterName), ioe);
      }
    } else {
      clazz.truncateCluster(clusterName);
    }
    return true;
  }
Execute the command.