package org.radargun.stages.cache.generators;

import org.radargun.config.DefinitionElement;
import org.radargun.config.Property;

/**
 * @author Mircea Markus &lt;Mircea.Markus@jboss.com&gt;
 */
@DefinitionElement(name = "string", doc = "Generates strings with configurable format.")
public class StringKeyGenerator implements KeyGenerator {
   @Property(doc = "Formatting string for the keys. Default is 'key_%016X'.")
   private String format = "key_%016X";

   /* We generate the key indices as zero-padded hex numbers to keep key size with increasing keyIndex */
   @Override
   public Object generateKey(long keyIndex) {
      return String.format(format, keyIndex);
   }
}

@@ -336,16 +336,159 @@
 rator %7B%0A
+   private final static char%5B%5D DIGITS = %7B%0A         '0', '1', '2', '3', '4', '5', '6', '7',%0A         '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' %7D;%0A%0A
    @Prop
@@ -581,18 +581,24 @@
 g format
- =
+; // use
  %22key_%250
@@ -601,17 +601,42 @@
 y_%25016X%22
-;
+ but without the formatter
 %0A%0A   /* 
@@ -794,16 +794,47 @@
 ndex) %7B%0A
+      if (format != null) %7B%0A   
       re
@@ -871,15 +871,251 @@
 Index);%0A
+      %7D else %7B%0A         StringBuilder sb = new StringBuilder(20).append(%22key_%22);%0A         for (int i = 60; i %3E= 0; i -= 4) %7B%0A            sb.append(DIGITS%5B(int) ((keyIndex %3E%3E i) & 15)%5D);%0A         %7D%0A         return sb.toString();%0A      %7D%0A
    %7D%0A%7D%0A

Use more performant default algorithm for StringKeyGenerator