kafka-commits mailing list archives

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

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


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

commit 57352bb163ca54c8ff257300632cd28a8a35900f
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 12b4cf3..8f4166e 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
@@ -270,6 +270,10 @@ class NamedCache {
         return keySetIterator(cache.navigableKeySet().subSet(from, true, to, true));
     }
 
+    public boolean isEmpty() {
+        return cache.isEmpty();
+    }
+
     private Iterator<Bytes> keySetIterator(final Set<Bytes> keySet) {
         return new TreeSet<>(keySet).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 7ce03a1..ef8020e 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.allKeys(), cache);
     }
-    
+
     public long size() {
         long size = 0;
         for (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