From d15cd8fde7fc762f5c52c68d6b01516992c2cdcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Tue, 26 Aug 2014 17:15:24 -0700 Subject: [PATCH] add some comments about string interning --- .../java/io/druid/segment/incremental/IncrementalIndex.java | 4 ++++ .../segment/incremental/IncrementalIndexStorageAdapter.java | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/processing/src/main/java/io/druid/segment/incremental/IncrementalIndex.java b/processing/src/main/java/io/druid/segment/incremental/IncrementalIndex.java index 4f6f6a0f67f..ca521a4f1f9 100644 --- a/processing/src/main/java/io/druid/segment/incremental/IncrementalIndex.java +++ b/processing/src/main/java/io/druid/segment/incremental/IncrementalIndex.java @@ -673,6 +673,10 @@ public class IncrementalIndex implements Iterable falseIdsReverse = biMap.inverse(); } + /** + * Returns the interned String value to allow fast comparisons using `==` instead of `.equals()` + * @see io.druid.segment.incremental.IncrementalIndexStorageAdapter.EntryHolderValueMatcherFactory#makeValueMatcher(String, String) + */ public String get(String value) { return value == null ? null : poorMansInterning.get(value); diff --git a/processing/src/main/java/io/druid/segment/incremental/IncrementalIndexStorageAdapter.java b/processing/src/main/java/io/druid/segment/incremental/IncrementalIndexStorageAdapter.java index 1c452496ffb..55e283fbb0d 100644 --- a/processing/src/main/java/io/druid/segment/incremental/IncrementalIndexStorageAdapter.java +++ b/processing/src/main/java/io/druid/segment/incremental/IncrementalIndexStorageAdapter.java @@ -525,6 +525,10 @@ public class IncrementalIndexStorageAdapter implements StorageAdapter } for (String dimVal : dims[dimIndex]) { + /** + * using == here instead of .equals() to speed up lookups made possible by + * {@link io.druid.segment.incremental.IncrementalIndex.DimDim#poorMansInterning} + */ if (id == dimVal) { return true; } @@ -597,4 +601,4 @@ public class IncrementalIndexStorageAdapter implements StorageAdapter }; } } -} \ No newline at end of file +}