Advertisement
flok99

Untitled

Mar 11th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. // table sm:
  2. // sector_nr bigint(16) not null,
  3. // hash varchar(128) not null,
  4. // primary key(sector_nr),
  5. // index(hash)
  6.  
  7. // table dm:
  8. // hash varchar(128) not null,
  9. // count bigint(16) not null,
  10. // data blob not null,
  11. // primary key(hash)
  12.  
  13. // function put_block(long sectornr_in, byte [] data_in, byte [] hash_in)
  14. // {
  15. // SELECT count AS prev_count, hash AS previous_hash FROM sm, dm WHERE sm.hash=dm.hash AND sectornr=sectornr_in (*1)
  16.  
  17. // if (previous_hash == null || previous_hash != hash_in) {
  18. // if prev_count == 1
  19. // DELETE from dm WHERE hash=previous_hash (*2)
  20. //
  21. // SELECT new_count FROM dm WHERE hash=hash_in; (*3)
  22. // if (new_count == null)
  23. // INSERT INTO dm(hash, count, data) VALUES(hash_in, 1, data_in) (*4)
  24. // else
  25. // UPDATE dm SET count=count+1 WHERE hash=hash_in; (*5)
  26. // }
  27.  
  28. // if previous_count == null
  29. // INSERT INTO sm(sectornr, hash) VALUES(sectornr_in, hash_in); (*6)
  30. // else
  31. // UPDATE sm SET hash=hash_in WHERE sectornr=sectornr_in (*7)
  32. // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement