core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OClassImpl.java
public void truncate() throws IOException {
    ODatabaseDocumentInternal db = getDatabase();
    db.checkSecurity(ORule.ResourceGeneric.CLASS, ORole.PERMISSION_UPDATE);

    if (isSubClassOf(OSecurityShared.RESTRICTED_CLASSNAME)) {
      throw new OSecurityException(
          "Class '" + getName() + "' cannot be truncated because has record level security enabled (extends '"
              + OSecurityShared.RESTRICTED_CLASSNAME + "')");
    }

    final OStorage storage = db.getStorage();
    acquireSchemaReadLock();
    try {

      for (int id : clusterIds) {
        OCluster cl = storage.getClusterById(id);
        db.checkForClusterPermissions(cl.getName());
        cl.truncate();
      }
      for (OIndex<?> index : getClassIndexes())
        index.clear();

      Set<OIndex<?>> superclassIndexes = new HashSet<OIndex<?>>();
      superclassIndexes.addAll(getIndexes());
      superclassIndexes.removeAll(getClassIndexes());
      for (OIndex index : superclassIndexes) {
        index.rebuild();
      }
    } finally {
      releaseSchemaReadLock();
    }
  }
public void truncate() throws IOException {
    ODatabaseDocumentInternal db = getDatabase();
    db.checkSecurity(ORule.ResourceGeneric.CLASS, ORole.PERMISSION_UPDATE);

    if (isSubClassOf(OSecurityShared.RESTRICTED_CLASSNAME)) {
      throw new OSecurityException(
          "Class '" + getName() + "' cannot be truncated because has record level security enabled (extends '"
              + OSecurityShared.RESTRICTED_CLASSNAME + "')");
    }

    final OStorage storage = db.getStorage();
    acquireSchemaReadLock();
    try {

      for (int id : clusterIds) {
        OCluster cl = storage.getClusterById(id);
        db.checkForClusterPermissions(cl.getName());
        cl.truncate();
      }
      for (OIndex<?> index : getClassIndexes())
        index.clear();

      Set<OIndex<?>> superclassIndexes = new HashSet<OIndex<?>>();
      superclassIndexes.addAll(getIndexes());
      superclassIndexes.removeAll(getClassIndexes());
      for (OIndex index : superclassIndexes) {
        index.rebuild();
      }
    } finally {
      releaseSchemaReadLock();
    }
  }
public void truncate ( ) throws IOException { ODatabaseDocumentInternal db = getDatabase ( ) ; db . checkSecurity ( ORule . ResourceGeneric . CLASS , ORole . PERMISSION_UPDATE ) ; if ( isSubClassOf ( OSecurityShared . RESTRICTED_CLASSNAME ) ) { throw new OSecurityException ( "Class '" + getName ( ) + "' cannot be truncated because has record level security enabled (extends '" + OSecurityShared . RESTRICTED_CLASSNAME + "')" ) ; } final OStorage storage = db . getStorage ( ) ; acquireSchemaReadLock ( ) ; try { for ( int id : clusterIds ) { OCluster cl = storage . getClusterById ( id ) ; db . checkForClusterPermissions ( cl . getName ( ) ) ; cl . truncate ( ) ; } for ( OIndex < ? > index : getClassIndexes ( ) ) index . clear ( ) ; Set < OIndex < ? > > superclassIndexes = new HashSet < OIndex < ? > > ( ) ; superclassIndexes . addAll ( getIndexes ( ) ) ; superclassIndexes . removeAll ( getClassIndexes ( ) ) ; for ( OIndex index : superclassIndexes ) { index . rebuild ( ) ; } } finally { releaseSchemaReadLock ( ) ; } }
Truncates all the clusters the class uses.
Truncates all the clusters the class uses .