Last active
October 29, 2015 16:54
-
-
Save yhemanth/5a7c0856ef25dd3ff37d to your computer and use it in GitHub Desktop.
Add IDs and hashes to a KMinHash key backed by a Redis sorted set using pipeline, truncating the set after every batch addition
This file contains 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
def update_min_hashes_batch(self, ids_batch): | |
pipeline = self.redis_client.pipeline() | |
for element_id in ids_batch: | |
min_hash = self.__element_hash(element_id) | |
pipeline.zadd(self.key, min_hash, element_id) | |
pipeline.zremrangebyrank(self.key, self.k, -1) | |
pipeline.execute() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment