carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jackylk <...@git.apache.org>
Subject [GitHub] carbondata pull request #1718: [CARBONDATA-1929][Validation]carbon property ...
Date Sat, 23 Dec 2017 01:32:09 GMT
Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1718#discussion_r158573603
  
    --- Diff: core/src/main/java/org/apache/carbondata/core/util/CarbonProperties.java ---
    @@ -107,36 +108,103 @@ private void validateAndLoadDefaultProperties() {
         validateCarbonCSVReadBufferSizeByte();
         validateHandoffSize();
         validateCombineSmallInputFiles();
    +    // The method validate the validity of configured carbon.timestamp.format value
    +    // and reset to default value if validation fail
    +    validateCarbonKey(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
    +        CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT);
    +    // The method validate the validity of configured carbon.date.format value
    +    // and reset to default value if validation fail
    +    validateCarbonKey(CarbonCommonConstants.CARBON_DATE_FORMAT,
    +        CarbonCommonConstants.CARBON_DATE_DEFAULT_FORMAT);
    +    validateSortFileWriteBufferSize();
    +    validateSortIntermediateFilesLimit();
       }
     
    -  private void validateCarbonCSVReadBufferSizeByte() {
    -    String csvReadBufferSizeStr =
    -        carbonProperties.getProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE);
    -    if (null != csvReadBufferSizeStr) {
    +  /**
    +   * Sort intermediate file size validation and if not valid then reset to the default
value
    +   */
    +  private void validateSortIntermediateFilesLimit() {
    +    validateRange(CarbonCommonConstants.SORT_INTERMEDIATE_FILES_LIMIT,
    +        CarbonCommonConstants.SORT_INTERMEDIATE_FILES_LIMIT_DEFAULT_VALUE,
    +        CarbonCommonConstants.SORT_INTERMEDIATE_FILES_LIMIT_MIN,
    +        CarbonCommonConstants.SORT_INTERMEDIATE_FILES_LIMIT_MAX);
    +  }
    +
    +  /**
    +   *
    +   * @param key
    +   * @param defaultValue default value for the given key
    +   * @param minValue Minimum value for the given key
    +   * @param maxValue Max value for the given key
    +   */
    +  private void validateRange(String key, String defaultValue, int minValue, int maxValue)
{
    +    String fileBufferSize = carbonProperties
    +        .getProperty(key, defaultValue);
    +    if (null != fileBufferSize) {
           try {
    -        int bufferSize = Integer.parseInt(csvReadBufferSizeStr);
    -        if (bufferSize < CarbonCommonConstants.CSV_READ_BUFFER_SIZE_MIN
    -            || bufferSize > CarbonCommonConstants.CSV_READ_BUFFER_SIZE_MAX) {
    -          LOGGER.warn("The value \"" + csvReadBufferSizeStr + "\" configured for key
"
    -              + CarbonCommonConstants.CSV_READ_BUFFER_SIZE
    +        int bufferSize = Integer.parseInt(fileBufferSize);
    +
    +        if (bufferSize < minValue
    +            || bufferSize > maxValue) {
    +          LOGGER.warn("The value \"" + fileBufferSize + "\" configured for key "
    +              + key
                   + "\" is not in range. Valid range is (byte) \""
    -              + CarbonCommonConstants.CSV_READ_BUFFER_SIZE_MIN + " to \""
    -              + CarbonCommonConstants.CSV_READ_BUFFER_SIZE_MAX + ". Using the default
value \""
    -              + CarbonCommonConstants.CSV_READ_BUFFER_SIZE_DEFAULT);
    -          carbonProperties.setProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE,
    -              CarbonCommonConstants.CSV_READ_BUFFER_SIZE_DEFAULT);
    +              + minValue + " to \""
    +              + maxValue +
    +              ". Using the default value \""
    +              + defaultValue);
    +          carbonProperties.setProperty(key,
    +              defaultValue);
             }
           } catch (NumberFormatException nfe) {
    -        LOGGER.warn("The value \"" + csvReadBufferSizeStr + "\" configured for key "
    -            + CarbonCommonConstants.CSV_READ_BUFFER_SIZE
    +        LOGGER.warn("The value \"" + fileBufferSize + "\" configured for key "
    +            + key
                 + "\" is invalid. Using the default value \""
    -            + CarbonCommonConstants.CSV_READ_BUFFER_SIZE_DEFAULT);
    -        carbonProperties.setProperty(CarbonCommonConstants.CSV_READ_BUFFER_SIZE,
    -            CarbonCommonConstants.CSV_READ_BUFFER_SIZE_DEFAULT);
    +            + defaultValue);
    +        carbonProperties.setProperty(key,
    +            defaultValue);
           }
         }
       }
     
    +  /**
    +   * validate carbon.sort.file.write.buffer.size and if not valid then reset to the default
value
    +   */
    +  private void validateSortFileWriteBufferSize() {
    +    validateRange(CarbonCommonConstants.CARBON_SORT_FILE_WRITE_BUFFER_SIZE,
    +        CarbonCommonConstants.CARBON_SORT_FILE_WRITE_BUFFER_SIZE_DEFAULT_VALUE,
    +        CarbonCommonConstants.CARBON_SORT_FILE_WRITE_BUFFER_SIZE_MIN,
    +        CarbonCommonConstants.CARBON_SORT_FILE_WRITE_BUFFER_SIZE_MAX);
    +  }
    +
    +  /**
    +   * The method validate the validity of configured carbon.date.format value
    +   * and reset to default value if validation fail
    +   */
    +  private void validateCarbonKey(String key, String defaultValue) {
    --- End diff --
    
    This signature is too generic, should validate carbon.date.format only


---

Mime
View raw message