Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // table sm:
- // sector_nr bigint(16) not null,
- // hash varchar(128) not null,
- // primary key(sector_nr),
- // index(hash)
- // table dm:
- // hash varchar(128) not null,
- // count bigint(16) not null,
- // data blob not null,
- // primary key(hash)
- // function put_block(long sectornr_in, byte [] data_in, byte [] hash_in)
- // {
- // SELECT count AS prev_count, hash AS previous_hash FROM sm, dm WHERE sm.hash=dm.hash AND sectornr=sectornr_in (*1)
- // if (previous_hash == null || previous_hash != hash_in) {
- // if prev_count == 1
- // DELETE from dm WHERE hash=previous_hash (*2)
- //
- // SELECT new_count FROM dm WHERE hash=hash_in; (*3)
- // if (new_count == null)
- // INSERT INTO dm(hash, count, data) VALUES(hash_in, 1, data_in) (*4)
- // else
- // UPDATE dm SET count=count+1 WHERE hash=hash_in; (*5)
- // }
- // if previous_count == null
- // INSERT INTO sm(sectornr, hash) VALUES(sectornr_in, hash_in); (*6)
- // else
- // UPDATE sm SET hash=hash_in WHERE sectornr=sectornr_in (*7)
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement