Package org.infinispan.query.backend
Class KeyTransformationHandler
java.lang.Object
org.infinispan.query.backend.KeyTransformationHandler
This transforms arbitrary keys to a String which can be used by Lucene as a document identifier, and vice versa.
There are 2 approaches to doing so; one for simple keys: Java primitives (and their object wrappers), byte[], Strings and UUID, and one for custom, user-defined types that could be used as keys.
For simple keys, users don't need to do anything, these keys are automatically transformed by this class.
For user-defined keys, three options are supported. Types annotated with @Transformable, and declaring an appropriate
Transformer implementation, types for which a Transformer
has been explicitly registered through KeyTransformationHandler.registerTransformer() or through the indexing configuration
(IndexingConfigurationBuilder.addKeyTransformer(java.lang.Class<?>, java.lang.Class<?>)).
- Since:
- 4.0
- Author:
- Manik Surtani, Marko Luksa
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionKeyTransformationHandler(ClassLoader classLoader) Constructs a KeyTransformationHandler for an indexed Cache. -
Method Summary
Modifier and TypeMethodDescriptionkeyToString(Object key) Stringify a key so Lucene can use it as document id.voidregisterTransformer(Class<?> keyClass, Class<? extends Transformer> transformerClass) Registers aTransformerfor the supplied key class.Converts a Lucene document id from string form back to the original object.
-
Constructor Details
-
KeyTransformationHandler
Constructs a KeyTransformationHandler for an indexed Cache.- Parameters:
classLoader- the classloader of the cache that owns this KeyTransformationHandler ornullif the thread context classloader is to be used (acceptable for testing only!)
-
-
Method Details
-
stringToKey
Converts a Lucene document id from string form back to the original object.- Parameters:
s- the string form of the key- Returns:
- the key object
-
keyToString
Stringify a key so Lucene can use it as document id.- Parameters:
key- the key- Returns:
- a string form of the key
-
registerTransformer
Registers aTransformerfor the supplied key class.- Parameters:
keyClass- the key class for which the supplied transformerClass should be usedtransformerClass- the transformer class to use for the supplied key class
-