The performance optimization of the $nin operator in MongoDB
According to the MongoDB official document:
The inequality operator $nin is not very selective since it often
matches a large portion of the index. As a result, in many cases,
a $nin query with an index may perform no better than a $nin query
that must scan all documents in a collection.
It is not recommended to use $nin
operator in a production server because it will often do a full collection scan. But in my project, I have to query some results which does not contain some elements. So I started to optimize the performance.
TypeScript with Redux store in a child component
When I was designing some general components in my website, there are some data to be read in redux store. With TypeScript, we can simply use connect and mapStateToProps like this:
A Go imlementation of Discrete Probability Distribution
In the mobile game Princess Connect Re:Dive, you can battle with other players in a 5v5 arena. In this arena, you only need to select your team with 5 units and the battle progress is fully automatic. So building a strong team is really important.
I'm building a function to generate a random team which based on the unit strength. Unit strength is easy to get because I have a database which record each match, and the unit strength should be the occurrence of one unit in all matches divided by the occurrence of all units. So the final question is, how can I choose a unit randomly by the unit strength?
自动配队的实现思路
事情起源于和森佬折腾小仓唯机器人的娱乐功能。
因为机器人的抽卡已经做的比较完善了,每个人都有了自己的box信息,而这些信息目前来说除了晒欧/非之外并没有任何用处。所以就想着搞一个根据自己的box来群内pvp(咕咕咕)
假设群内对战双方为A和B,完成这个需求需要以下几个步骤: