Package org.apache.druid.query.cache
Class CacheKeyBuilder
java.lang.Object
org.apache.druid.query.cache.CacheKeyBuilder
CacheKeyBuilder is a tool for easily generating cache keys of
Cacheable objects.
The layout of the serialized cache key is like below.
+--------------------------------------------------------+
| ID (1 byte) |
| type key (1 byte) | serialized value (variable length) |
| type key (1 byte) | serialized value (variable length) |
| ... |
+--------------------------------------------------------+-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappendBoolean(boolean input) appendByte(byte input) appendByteArray(byte[] input) appendCacheable(Cacheable input) appendCacheables(Collection<? extends Cacheable> input) Add a collection of Cacheables to the cache key.appendCacheablesIgnoringOrder(Collection<? extends Cacheable> input) Add a collection of Cacheables to the cache key.appendDouble(double input) appendDoubleArray(double[] input) appendFloat(float input) appendFloatArray(float[] input) appendInt(int input) appendLong(long input) appendString(String input) appendStrings(Collection<String> input) Add a collection of strings to the cache key.Add a collection of strings to the cache key.byte[]build()
-
Constructor Details
-
CacheKeyBuilder
public CacheKeyBuilder(byte id)
-
-
Method Details
-
appendByte
-
appendByteArray
-
appendString
-
appendStrings
Add a collection of strings to the cache key. Strings in the collection are concatenated with a separator of '0xFF', and they appear in the cache key in their input order.- Parameters:
input- a collection of strings to be included in the cache key- Returns:
- this instance
-
appendStringsIgnoringOrder
Add a collection of strings to the cache key. Strings in the collection are sorted by their byte representation and concatenated with a separator of '0xFF'.- Parameters:
input- a collection of strings to be included in the cache key- Returns:
- this instance
-
appendBoolean
-
appendInt
-
appendLong
-
appendFloat
-
appendDouble
-
appendDoubleArray
-
appendFloatArray
-
appendCacheable
-
appendCacheables
Add a collection of Cacheables to the cache key. Cacheables in the collection are concatenated without any separator, and they appear in the cache key in their input order.- Parameters:
input- a collection of Cacheables to be included in the cache key- Returns:
- this instance
-
appendCacheablesIgnoringOrder
Add a collection of Cacheables to the cache key. Cacheables in the collection are sorted by their byte representation and concatenated without any separator.- Parameters:
input- a collection of Cacheables to be included in the cache key- Returns:
- this instance
-
build
@Nullable public byte[] build()
-