@Test public void stringCaching() { StringFieldMetadata metadata = new StringFieldMetadata("text", 1, 4, generateTokens(18)); StringFieldFactory factory = new StringFieldFactory(metadata.getTokensPerValue(), metadata.getTokens()); CachedFieldFactory<String> cachedFactory = new CachedFieldFactory<String>(factory, String.class, metadata.getUniqueValueCount()); for(int i = 0; i < 100; i++) { assertEquals(cachedFactory.newInstance(i), factory.newInstance(i)); } }
@Override public T newInstance(int uniqueId) { return fields[uniqueId % fields.length]; }
CachedFieldFactory extends AbstractFieldFactory<T> { @Override public T newInstance(int uniqueId) { return fields[uniqueId % fields.length]; } }
CachedFieldFactory extends AbstractFieldFactory<T> { @Override public T newInstance(int uniqueId) { return fields[uniqueId % fields.length]; } CachedFieldFactory(AbstractFieldFactory<T> factory, Class<T> classType, int maxItems); }
CachedFieldFactory extends AbstractFieldFactory<T> { @Override public T newInstance(int uniqueId) { return fields[uniqueId % fields.length]; } CachedFieldFactory(AbstractFieldFactory<T> factory, Class<T> classType, int maxItems); T[] getCachedFields(); @Override T newInstance(int uniqueId); }
CachedFieldFactory extends AbstractFieldFactory<T> { @Override public T newInstance(int uniqueId) { return fields[uniqueId % fields.length]; } CachedFieldFactory(AbstractFieldFactory<T> factory, Class<T> classType, int maxItems); T[] getCachedFields(); @Override T newInstance(int uniqueId);  }