Perhaps the use of a filtered iterator went in the wrong direction. The normal way to get the "binary search" kind of behavior is to get a plain iterator over the sorted index, and then use the moveTo method, specifying a target FS as the one to move to. The target FS can be a "temporary" FS, one that is never added to the indexes, itself; it is just used to supply values used in the comparison.
With this, you can "jump to" the nearest element (see the javadocs for the exact definition of this). Does this help? When using uima version 3, the moveto method can be made to ignore type priorities in the ordering, which is what is wanted in many use cases. See http://uima.apache.org/d/uimaj-current/version_3_users_guide.html#uv3.select -Marshall On 9/4/2019 3:45 PM, Mario Juric wrote: > Hi, > > I created a custom FSIndex for an annotation type in the hope of speeding up > lookup based on one of it’s fields, but after some profiling I found to my > surprise that this doesn’t appear to be what I get. I specified the index to > be sorted according to two fields where the first is a key and the next is a > value field. After creating a filtered iterator with the key field as one of > the constraints I thought it would do a quick lookup to the first element in > the list that matches the key constraint, after all it’s sorted according to > that field, so I assume at least binary search is possible, but to my > surprise that is not what happens. It seems to simply iterate through all > elements and skips those that don’t match the constraint. There doesn’t seem > to be other ways I can do a more efficient jump to the first element in the > index and then stop iterating when the key no longer matches. > > I am somewhat baffled by this, and it appears to me I could have achieved the > same using a normal select with some simple filtering, which kinda makes the > FSIndex redundant. There is another way to obtain an iterator, which takes a > FeatureStructure, but I am not sure if that is more efficient, and does this > mean that you create FeatureStructures for the sole purpose of lookup into > the index? I would appreciate if someone could explain this to me, thanks! :) > > Cheers, > Mario > > > > > > > > > > > > > >
