kafka-commits mailing list archives

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

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


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

commit d606be3cc9e607c2f082542ba39dad0c95ec1c96
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 3ce7cbe..25b00b2 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 941b522..7e3231e 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
@@ -192,7 +192,7 @@ public class ThreadCache {
         }
         return new MemoryLRUCacheBytesIterator(cache.allKeys(), cache);
     }
-    
+
     public long size() {
         long size = 0;
         for (final NamedCache cache : caches.values()) {
@@ -234,7 +234,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