carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From QiangCai <...@git.apache.org>
Subject [GitHub] incubator-carbondata pull request #472: [CARBONDATA-568] clean up code for c...
Date Tue, 03 Jan 2017 08:45:50 GMT
Github user QiangCai commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/472#discussion_r94366862
  
    --- Diff: core/src/main/java/org/apache/carbondata/core/cache/dictionary/AbstractDictionaryCache.java
---
    @@ -149,65 +147,61 @@ private CarbonFile getDictionaryMetaCarbonFile(
        *                                         tableName and columnIdentifier
        * @param dictionaryInfo
        * @param lruCacheKey
    -   * @param loadSortIndex                    read and load sort index file in memory
    -   * @throws CarbonUtilException in case memory is not sufficient to load dictionary
into memory
    +   * @param IOException                    in case memory is not sufficient to load dictionary
    +   *                                       into memory
        */
       protected void checkAndLoadDictionaryData(
           DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier,
           DictionaryInfo dictionaryInfo, String lruCacheKey, boolean loadSortIndex)
    -      throws CarbonUtilException {
    -    try {
    -      // read last segment dictionary meta chunk entry to get the end offset of file
    -      CarbonFile carbonFile = getDictionaryMetaCarbonFile(dictionaryColumnUniqueIdentifier);
    -      boolean dictionaryMetaFileModified =
    -          isDictionaryMetaFileModified(carbonFile, dictionaryInfo.getFileTimeStamp(),
    -              dictionaryInfo.getDictionaryMetaFileLength());
    -      // if dictionary metadata file is modified then only read the last entry from dictionary
    -      // meta file
    -      if (dictionaryMetaFileModified) {
    -        synchronized (dictionaryInfo) {
    -          carbonFile = getDictionaryMetaCarbonFile(dictionaryColumnUniqueIdentifier);
    -          dictionaryMetaFileModified =
    -              isDictionaryMetaFileModified(carbonFile, dictionaryInfo.getFileTimeStamp(),
    -                  dictionaryInfo.getDictionaryMetaFileLength());
    -          // Double Check :
    -          // if dictionary metadata file is modified then only read the last entry from
dictionary
    -          // meta file
    -          if (dictionaryMetaFileModified) {
    -            CarbonDictionaryColumnMetaChunk carbonDictionaryColumnMetaChunk =
    -                readLastChunkFromDictionaryMetadataFile(dictionaryColumnUniqueIdentifier);
    -            // required size will be size total size of file - offset till file is
    -            // already read
    -            long requiredSize =
    -                carbonDictionaryColumnMetaChunk.getEnd_offset() - dictionaryInfo.getMemorySize();
    -            if (requiredSize > 0) {
    -              boolean columnAddedToLRUCache =
    -                  carbonLRUCache.put(lruCacheKey, dictionaryInfo, requiredSize);
    -              // if column is successfully added to lru cache then only load the
    -              // dictionary data
    -              if (columnAddedToLRUCache) {
    -                // load dictionary data
    -                loadDictionaryData(dictionaryInfo, dictionaryColumnUniqueIdentifier,
    -                    dictionaryInfo.getMemorySize(), carbonDictionaryColumnMetaChunk.getEnd_offset(),
    -                    loadSortIndex);
    -                // set the end offset till where file is read
    -                dictionaryInfo
    -                    .setOffsetTillFileIsRead(carbonDictionaryColumnMetaChunk.getEnd_offset());
    -                dictionaryInfo.setFileTimeStamp(carbonFile.getLastModifiedTime());
    -                dictionaryInfo.setDictionaryMetaFileLength(carbonFile.getSize());
    -              } else {
    -                throw new CarbonUtilException(
    -                    "Cannot load dictionary into memory. Not enough memory available");
    -              }
    +      throws IOException {
    +    // read last segment dictionary meta chunk entry to get the end offset of file
    +    CarbonFile carbonFile = getDictionaryMetaCarbonFile(dictionaryColumnUniqueIdentifier);
    +    boolean dictionaryMetaFileModified =
    +        isDictionaryMetaFileModified(carbonFile, dictionaryInfo.getFileTimeStamp(),
    +            dictionaryInfo.getDictionaryMetaFileLength());
    +    // if dictionary metadata file is modified then only read the last entry from dictionary
    +    // meta file
    +    if (dictionaryMetaFileModified) {
    +      synchronized (dictionaryInfo) {
    +        carbonFile = getDictionaryMetaCarbonFile(dictionaryColumnUniqueIdentifier);
    +        dictionaryMetaFileModified =
    +            isDictionaryMetaFileModified(carbonFile, dictionaryInfo.getFileTimeStamp(),
    +                dictionaryInfo.getDictionaryMetaFileLength());
    +        // Double Check :
    +        // if dictionary metadata file is modified then only read the last entry from
dictionary
    +        // meta file
    +        if (dictionaryMetaFileModified) {
    +          CarbonDictionaryColumnMetaChunk carbonDictionaryColumnMetaChunk =
    +              readLastChunkFromDictionaryMetadataFile(dictionaryColumnUniqueIdentifier);
    +          // required size will be size total size of file - offset till file is
    +          // already read
    +          long requiredSize =
    +              carbonDictionaryColumnMetaChunk.getEnd_offset() - dictionaryInfo.getMemorySize();
    +          if (requiredSize > 0) {
    +            boolean columnAddedToLRUCache =
    +                carbonLRUCache.put(lruCacheKey, dictionaryInfo, requiredSize);
    +            // if column is successfully added to lru cache then only load the
    +            // dictionary data
    +            if (columnAddedToLRUCache) {
    +              // load dictionary data
    +              loadDictionaryData(dictionaryInfo, dictionaryColumnUniqueIdentifier,
    +                  dictionaryInfo.getMemorySize(), carbonDictionaryColumnMetaChunk.getEnd_offset(),
    +                  loadSortIndex);
    +              // set the end offset till where file is read
    +              dictionaryInfo
    +                  .setOffsetTillFileIsRead(carbonDictionaryColumnMetaChunk.getEnd_offset());
    +              dictionaryInfo.setFileTimeStamp(carbonFile.getLastModifiedTime());
    +              dictionaryInfo.setDictionaryMetaFileLength(carbonFile.getSize());
    +            } else {
    +              throw new IOException(
    --- End diff --
    
    Why not use custom exception class?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message