kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mj...@apache.org
Subject [kafka] branch 2.3 updated: KAFKA-8736: Streams performance improvement, use isEmpty() rather than size() == 0 (#7164)
Date Tue, 06 Aug 2019 17:16:29 GMT
This is an automated email from the ASF dual-hosted git repository.

mjsax pushed a commit to branch 2.3
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/2.3 by this push:
     new 0826d6e  KAFKA-8736: Streams performance improvement, use isEmpty() rather than size()
== 0 (#7164)
0826d6e is described below

commit 0826d6e90d4ff9648f512cdd9bc00307d4ef3b3e
Author: mjarvie <30092781+mjarvie@users.noreply.github.com>
AuthorDate: Tue Aug 6 10:05:44 2019 -0700

    KAFKA-8736: Streams performance improvement, use isEmpty() rather than size() == 0 (#7164)
    
    Reviewers: A. Sophie Blee-Goldman <sophie@confluent.io>, Matthias J. Sax <matthias@confluent.io>,
Guozhang Wang <guozhang@confluent.io>
---
 .../java/org/apache/kafka/streams/state/internals/NamedCache.java     | 4 ++++
 .../java/org/apache/kafka/streams/state/internals/ThreadCache.java    | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/streams/src/main/java/org/apache/kafka/streams/state/internals/NamedCache.java
b/streams/src/main/java/org/apache/kafka/streams/state/internals/NamedCache.java
index 0201f20..ec53dfa 100644
--- a/streams/src/main/java/org/apache/kafka/streams/state/internals/NamedCache.java
+++ b/streams/src/main/java/org/apache/kafka/streams/state/internals/NamedCache.java
@@ -266,6 +266,10 @@ class NamedCache {
         return cache.size();
     }
 
+    public boolean isEmpty() {
+        return cache.isEmpty();
+    }
+
     synchronized Iterator<Map.Entry<Bytes, LRUNode>> subMapIterator(final Bytes
from, final Bytes to) {
         return cache.subMap(from, true, to, true).entrySet().iterator();
     }
diff --git a/streams/src/main/java/org/apache/kafka/streams/state/internals/ThreadCache.java
b/streams/src/main/java/org/apache/kafka/streams/state/internals/ThreadCache.java
index 0db6c78..116b1ef 100644
--- a/streams/src/main/java/org/apache/kafka/streams/state/internals/ThreadCache.java
+++ b/streams/src/main/java/org/apache/kafka/streams/state/internals/ThreadCache.java
@@ -193,7 +193,7 @@ public class ThreadCache {
         }
         return new MemoryLRUCacheBytesIterator(cache.allIterator());
     }
-    
+
     public long size() {
         long size = 0;
         for (final NamedCache cache : caches.values()) {
@@ -235,7 +235,7 @@ public class ThreadCache {
             // a put on another cache. So even though the sizeInBytes() is
             // still > maxCacheSizeBytes there is nothing to evict from this
             // namespaced cache.
-            if (cache.size() == 0) {
+            if (cache.isEmpty()) {
                 return;
             }
             cache.evict();


Mime
View raw message