[GitHub] incubator-carbondata pull request #337: [CARBONDATA-428] Removed Redundant C...

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata pull request #337: [CARBONDATA-428] Removed Redundant C...

qiuchenjian-2
GitHub user PallaviSingh1992 opened a pull request:

    https://github.com/apache/incubator-carbondata/pull/337

    [CARBONDATA-428] Removed Redundant Condition Checks

    Remove the redundant conditional checking of dictionaryCacheAlreadyExists(cacheType) in CacheProvider.
   


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/PallaviSingh1992/incubator-carbondata feature/RedundantConditionChecks

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-carbondata/pull/337.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #337
   
----
commit 242e2e76f3afe0cb690a16493f04616f9c879f4e
Author: PallaviSingh1992 <[hidden email]>
Date:   2016-11-21T07:40:32Z

    removed redundant condition checks

----


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata pull request #337: [CARBONDATA-428] Removed Redundant C...

qiuchenjian-2
Github user manishgupta88 commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/337#discussion_r88889114
 
    --- Diff: core/src/main/java/org/apache/carbondata/core/cache/CacheProvider.java ---
    @@ -84,14 +84,13 @@ public static CacheProvider getInstance() {
         //check if cache is null for given cache type, if null create one
         if (!dictionaryCacheAlreadyExists(cacheType)) {
           synchronized (lock) {
    -        if (!dictionaryCacheAlreadyExists(cacheType)) {
    -          if (null == cacheTypeToLRUCacheMap.get(cacheType)) {
    -            createLRULevelCacheInstance(cacheType);
    -          }
    -          createDictionaryCacheForGivenType(cacheType, carbonStorePath);
    +        if (null == cacheTypeToLRUCacheMap.get(cacheType)) {
    +          createLRULevelCacheInstance(cacheType);
             }
    +        createDictionaryCacheForGivenType(cacheType, carbonStorePath);
    --- End diff --
   
    @PallaviSingh1992 ....dictionaryCacheAlreadyExists will check if for a given cache type (Forward/Reverse), the object has already been created. Now this check is before and inside synchronized block to handle concurrent access (double locking mechanism). If this check is removed inside the synchronized block then it can happen that in concurrent scenarios, multiple threads end up in creating multiple objects for the same cache type and the object in the map keeps getting overridden.
    Therefore I think that this double check is required. Please correct me if I am wrong.


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata pull request #337: [CARBONDATA-428] Removed Redundant C...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user PallaviSingh1992 commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/337#discussion_r89041271
 
    --- Diff: core/src/main/java/org/apache/carbondata/core/cache/CacheProvider.java ---
    @@ -84,14 +84,13 @@ public static CacheProvider getInstance() {
         //check if cache is null for given cache type, if null create one
         if (!dictionaryCacheAlreadyExists(cacheType)) {
           synchronized (lock) {
    -        if (!dictionaryCacheAlreadyExists(cacheType)) {
    -          if (null == cacheTypeToLRUCacheMap.get(cacheType)) {
    -            createLRULevelCacheInstance(cacheType);
    -          }
    -          createDictionaryCacheForGivenType(cacheType, carbonStorePath);
    +        if (null == cacheTypeToLRUCacheMap.get(cacheType)) {
    +          createLRULevelCacheInstance(cacheType);
             }
    +        createDictionaryCacheForGivenType(cacheType, carbonStorePath);
    --- End diff --
   
    synchronized blocks synchronized on the same object can only have one thread executing inside them at the same time.


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata pull request #337: [CARBONDATA-428] Removed Redundant C...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user PallaviSingh1992 closed the pull request at:

    https://github.com/apache/incubator-carbondata/pull/337


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---