Github user QiangCai commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/2176#discussion_r182000845
  
    --- Diff: 
core/src/main/java/org/apache/carbondata/core/metadata/schema/table/DiskBasedDMSchemaStorageProvider.java
 ---
    @@ -135,9 +161,49 @@ public DiskBasedDMSchemaStorageProvider(String 
storePath) {
         if (!FileFactory.isFileExist(schemaPath, 
FileFactory.getFileType(schemaPath))) {
           throw new IOException("DataMap with name " + dataMapName + " does 
not exists in storage");
         }
    -
    +    DataMapSchema dataMapSchemaToRemove = null;
    +    for (DataMapSchema dataMapSchema : dataMapSchemas) {
    +      if (dataMapSchema.getDataMapName().equalsIgnoreCase(dataMapName)) {
    +        dataMapSchemaToRemove =  dataMapSchema;
    +      }
    +    }
    +    if (dataMapSchemaToRemove != null) {
    +      dataMapSchemas.remove(dataMapSchemaToRemove);
    +    }
         if (!FileFactory.deleteFile(schemaPath, 
FileFactory.getFileType(schemaPath))) {
           throw new IOException("DataMap with name " + dataMapName + " cannot 
be deleted");
    +    } else {
    +      touchMDTFile();
    +    }
    +  }
    +
    +  private void checkAndReloadDataMapSchemas() throws IOException {
    +    if (FileFactory.isFileExist(mdtFilePath)) {
    +      long lastModifiedTime = 
FileFactory.getCarbonFile(mdtFilePath).getLastModifiedTime();
    +      if (this.lastModifiedTime != lastModifiedTime) {
    +        dataMapSchemas = retrieveAllSchemasInternal();
    +        this.lastModifiedTime = lastModifiedTime;
    +      }
    +    } else {
    +      touchMDTFile();
    +      retrieveAllSchemasInternal();
    +    }
    +  }
    +
    +  private void touchMDTFile() throws IOException {
    +    if (!FileFactory.isFileExist(storePath)) {
    +      FileFactory.createDirectoryAndSetPermission(
    +          storePath,
    +          new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL));
    +    }
    +    if (!FileFactory.isFileExist(mdtFilePath)) {
    +      FileFactory
    +          .createNewFile(mdtFilePath,
    --- End diff --
    
    code style: move to last line


---

Reply via email to