phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maryannxue <...@git.apache.org>
Subject [GitHub] phoenix pull request #298: PHOENIX-4666 Persistent subquery cache for hash j...
Date Fri, 20 Apr 2018 18:38:07 GMT
Github user maryannxue commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/298#discussion_r183128249
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java ---
    @@ -77,57 +153,164 @@ public MemoryManager getMemoryManager() {
             return memoryManager;
         }
     
    -    private Cache<ImmutableBytesPtr,Closeable> getServerCaches() {
    +    private Cache<ImmutableBytesPtr,CacheEntry> getServerCaches() {
             /* Delay creation of this map until it's needed */
             if (serverCaches == null) {
                 synchronized(this) {
                     if (serverCaches == null) {
    -                    serverCaches = CacheBuilder.newBuilder()
    -                        .expireAfterAccess(maxTimeToLiveMs, TimeUnit.MILLISECONDS)
    -                        .ticker(getTicker())
    -                        .removalListener(new RemovalListener<ImmutableBytesPtr, Closeable>(){
    -                            @Override
    -                            public void onRemoval(RemovalNotification<ImmutableBytesPtr,
Closeable> notification) {
    -                                Closeables.closeAllQuietly(Collections.singletonList(notification.getValue()));
    -                            }
    -                        })
    -                        .build();
    +                    serverCaches = buildCache(maxTimeToLiveMs, false);
                     }
                 }
             }
             return serverCaches;
         }
    +
    +    private Cache<ImmutableBytesPtr,CacheEntry> getPersistentServerCaches() {
    +        /* Delay creation of this map until it's needed */
    +        if (persistentServerCaches == null) {
    +            synchronized(this) {
    +                if (persistentServerCaches == null) {
    +                    persistentServerCaches = buildCache(maxPersistenceTimeToLiveMs, true);
    +                }
    +            }
    +        }
    +        return persistentServerCaches;
    +    }
    +
    +    private Cache<ImmutableBytesPtr, CacheEntry> buildCache(final int ttl, final
boolean isPersistent) {
    +        return CacheBuilder.newBuilder()
    +            .expireAfterAccess(ttl, TimeUnit.MILLISECONDS)
    +            .ticker(getTicker())
    +            .removalListener(new RemovalListener<ImmutableBytesPtr, CacheEntry>(){
    +                @Override
    +                public void onRemoval(RemovalNotification<ImmutableBytesPtr, CacheEntry>
notification) {
    +                	if (isPersistent || !notification.getValue().getUsePersistentCache())
{
    +                        Closeables.closeAllQuietly(Collections.singletonList(notification.getValue()));
    --- End diff --
    
    Looks like the indentation is not right here. Can you perform a check through the entire
PR?


---

Mime
View raw message