protected IEnumerable <uint> GetAccounts() { IReadOnlyCollection <uint> result = Database.GetAccountIds(); FilterTypes filteredBy = FilterTypes.empty; FilterTypes filteredByUnion = FilterTypes.empty; if (_filters.ContainsAll(FilterTypes.interests_any | FilterTypes.likes_all)) { _filters = _filters.ResetFlags(FilterTypes.likes_all); if (likes.Count == 1) { return(LikesIndexer.GetAllWhoLikes(likes[0])); } foreach (var likee in likes) { _intersect.Add(LikesIndexer.GetAllWhoLikes(likee)); } foreach (var interest in interestIndexes) { _intersect.Add(StringIndexer.Interests.GetList(interest)); } _filters = _filters.ResetFlags(FilterTypes.interests_any); return(_intersect); } if (_filters.ContainsAll(FilterTypes.fname_any | FilterTypes.sex_eq)) { if (fnamesIndexes == null || fnamesIndexes.Count == 0) { return(Array.Empty <uint>()); } var probeNameList = StringIndexer.FirstNames.GetList(fnamesIndexes[0]); var probeSex = Database.GetAccount(probeNameList[0]).SexStatus & SexStatus.AllSex; if ((probeSex & _sexStatus) == SexStatus.None) { return(Array.Empty <uint>()); } } if (_filters.ContainsAll(FilterTypes.birth_year) && _filters.ContainsAny(FilterTypes.cities_all_types) && _filters.ContainsAny(FilterTypes.sex_status_all_types)) { ref StatusGroup filtered = ref GroupIndex.SexGroupByCity(cityIndex); var birthYear = (ushort)birth; var list = filtered.GetListBy(_sexStatus, birthYear, _union); _filters = _filters.ResetFlags(FilterTypes.birth_year | FilterTypes.cities_all_types | FilterTypes.sex_status_all_types); return(list); }
public HList <Account> ExecuteWithoutIndex(Account me) { if (me.likes == null || _cityIndex == 0 || _countryIndex == 0) { return(HList <Account> .Empty); } //TODO: city or country index highly likely to work better cause of smaller final record set foreach (Like likedByMe in me.likes) { HList <uint> candidates = LikesIndexer.GetAllWhoLikes(likedByMe.Id); _resultSet.UnionWith(candidates); } _resultSet.Remove(me.id); Span <uint> accounts = stackalloc uint[150]; if (_cityIndex < ushort.MaxValue) { foreach (uint cid in _resultSet) { Account candidate = Database.GetAccount(cid); if (_cityIndex != candidate.cityIndex) { continue; } CalcSimilarity(me, candidate, ref accounts); } } else if (_countryIndex < ushort.MaxValue) { foreach (uint cid in _resultSet) { Account candidate = Database.GetAccount(cid); if (_countryIndex != candidate.countryIndex) { continue; } CalcSimilarity(me, candidate, ref accounts); } } else { foreach (uint cid in _resultSet) { Account candidate = Database.GetAccount(cid); CalcSimilarity(me, candidate, ref accounts); } } var maxItems = Math.Min(limit, _list.Count); for (uint i = 0; i < maxItems; i++) { _result.Add(Database.GetAccount(_list[i].Key)); } return(_result); }