Created
August 8, 2013 02:45
-
-
Save prisoner/6181008 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis.clients.jedis.Jedis; | |
import java.util.BitSet; | |
Jedis redis = new Jedis("localhost"); | |
public int uniqueCount(String action, String... dates) { | |
BitSet all = new BitSet(); | |
for (String date : dates) { | |
String key = action + ":" + date; | |
BitSet users = BitSet.valueOf(redis.get(key.getBytes())); | |
all.or(users); | |
} | |
return all.cardinality(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment