我有30907个项目的大数据。目前,即时通讯使用NSPredicate进行过滤。但这很慢。因此,即时通讯正在寻找一种更快地处理它们的最佳方法。
这是我当前的代码,用于过滤30907个项目:
predicate = [NSPredicate predicateWithFormat:
@"((full beginswith[cd] %@) OR (full == [cd] %@) OR (search ==[cd] %@)) OR (search CONTAINS[cd] %@) OR (search beginswith[cd] %@)",matchString,matchString,matchString,strNoSpace,strNoSpace];
NSArray * arrResult = [arrSongs filteredArrayUsingPredicate:predicate];
结果是正确的,但是非常慢。
也许您可以尝试删除(full == [cd] %@)
,这种情况已经得到充分评估beginswith[cd]
。换句话说,具有的字符串(full == [cd] %@)
是的子集beginswith[cd]
。
碰巧的是(search beginswith[cd] %@)
,这是的子集(search CONTAINS[cd] %@)
。
因此,请尝试以下操作:
[NSPredicate predicateWithFormat:
@"((full beginswith[cd] %@) OR (search ==[cd] %@)) OR (search CONTAINS[cd] %@)",matchString,matchString,strNoSpace];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句