Feature request: different indexing strategy

21 views
Skip to first unread message

Alex Rhomberg

unread,
Mar 25, 2013, 5:50:01 PM3/25/13
to twig-p...@googlegroups.com
It cost me the spare time of a week to realize that in twig 2.0 I have to explicitly declare an @Index annotation for every property that I might use for filtering or sorting at any time in the future.
This saves a couple of bytes for index storage and a couple of seconds CPU time for calculation (of which I have plenty), but it cost me a lot of lost spare time and nerves (which are much more limited).

I propose to switch back to an indexing strategy, where every property by default is indexed, if it contains an indexable type, by using entity.setProperty().

Users that need to reduce resource usage can use @Index(false) or perhaps a new class annotation @NoAutoIndex or a global switch in the Configuration to disable auto-indexing.

For anyone with the same problem, I now use the following method in my subclass of AnnotationConfiguration

private Boolean defaultindex = true;
/**
* Different indexing strategy: use information from {@code getDefaultIndex()} to determine whether 
* a non-annotated field should be indexed or not (default is index everything)
* @see com.google.code.twig.annotation.AnnotationConfiguration#index(java.lang.reflect.Field)
*/
@Override
public Boolean index(Field field) {
Boolean index =super.index(field);
if(index == null)
return defaultindex;
else
return index;
}

Reply all
Reply to author
Forward
0 new messages