gempir

RQ Algorithm

Sep 28th, 2018
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. CREATE TABLE IF NOT EXISTS logstv.messages (
  2. timestamp timestamp,
  3. channelid bigint,
  4. userid bigint,
  5. message text,
  6. PRIMARY KEY ((channelid, userid), timestamp)
  7. ) WITH CLUSTERING ORDER BY (timestamp DESC);
  8.  
  9. Random Algorithm:
  10. - ORDER BY DESC/ASC (2 queries) and find last and first ever message
  11. - Generate random month in go between the 2 dates
  12. - SELECT the months messages
  13. - If zero messages, generate a new random month and SELECT that one. (Recursive) Stop when all Months between last and first message have been checked
  14. - Count rows in selected months and do a random on that
Advertisement
Add Comment
Please, Sign In to add comment