spring-data-redis
spring-data-redis copied to clipboard
Refactor IndexWriter implementation
Currently, the creation of secandary indexes and index helpers within IndexWriter
is difficult to read at a glance.
So I'm going to rewrite the code in a declarative style by isolating the methods for creating these indexes.
Secondary Index
AS-IS
Set<byte[]> existingKeys = connection
.keys(toBytes(indexedData.getKeyspace() + ":" + indexedData.getIndexName() + ":*"));
TO-BE
Set<byte[]> existingKeys = connection.keys(createIndexKey(indexedData, "*"));
Index Helper
AS-IS
byte[] indexHelperKey = ByteUtils.concatAll(toBytes(keyspace + ":"), binKey, toBytes(":idx"));
TO-BE
byte[] indexHelperKey = createIndexHelperKey(keyspace, binKey);