Changeset 36576 in project
 Timestamp:
 09/09/18 23:32:57 (17 months ago)
 Location:
 release/5/bloomfilter/trunk
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

release/5/bloomfilter/trunk/bloomfilter.egg
r36501 r36576 4 4 ((synopsis "Bloom Filter") 5 5 (category data) 6 (version "2. 1.0")6 (version "2.2.0") 7 7 (author "[[kon lovett]]") 8 8 (license "BSD") … … 12 12 (messagedigesttype "4.0.2") 13 13 (messagedigestutils "4.1.1") 14 (checkerrors "3.1.0") 15 (recordvariants "1.0")) 14 (checkerrors "3.1.0")) 16 15 (testdependencies test sha1 sha2 md5 tigerhash ripemd) 17 16 (components … … 19 18 #;(inlinefile) 20 19 (typesfile) 21 (cscoptions "O3" "d1" "local" "noprocedurechecks fortoplevelbindings") ) ) )20 (cscoptions "O3" "d1" "local" "noprocedurechecks") ) ) ) 
release/5/bloomfilter/trunk/bloomfilter.scm
r36501 r36576 50 50 messagedigesttype 51 51 messagedigestitem 52 recordvariants53 52 (only typechecks 54 53 definecheck+errortype … … 56 55 (only typeerrorsbasic signalboundserror)) 57 56 58 (declare (boundtoprocedure ##sys#signalhook))59 60 57 ;;; 61 58 59 (definetype iset:integerset *) 60 62 61 (definetype messagedigestprimitive (struct messagedigestprimitive)) 63 62 … … 65 64 66 65 (definetype bloomfilterhasher (* (listof fixnum) > (listof fixnum))) 66 67 (definetype bloomfilterhashers (listof bloomfilterhasher)) 67 68 68 69 (definetype unsignednativeintegergetter (* fixnum > (or fixnum bignum))) … … 115 116 (definetype bloomfilter (struct bloomfilter)) 116 117 117 (definerecordtypevariant bloomfilter (unsafe unchecked inline) 118 (%makebloomfilter n m k bits hashes mdps) 119 %bloomfilter? 120 (n %bloomfiltern %bloomfilternset!) 121 (m %bloomfilterm) 122 (k %bloomfilterk) 123 (bits %bloomfilterbits %bloomfilterbitsset!) 124 (hashes %bloomfilterhashers) 125 (mdps %bloomfilteralgorithms) ) 118 (: *makebloomfilter (fixnum fixnum fixnum iset:integerset bloomfilterhashers messagedigestprimitives > bloomfilter)) 119 (: bloomfilter? (* > boolean : bloomfilter)) 120 (: *bloomfiltern (bloomfilter > fixnum)) 121 (: *bloomfilternset! (bloomfilter fixnum > void)) 122 (: *bloomfilterm (bloomfilter > fixnum)) 123 (: *bloomfilterk (bloomfilter > fixnum)) 124 (: *bloomfilterbits (bloomfilter > iset:integerset)) 125 (: *bloomfilterbitsset! (bloomfilter iset:integerset > void)) 126 (: *bloomfilterhashers (bloomfilter > bloomfilterhashers)) 127 (: *bloomfilteralgorithms (bloomfilter > messagedigestprimitives)) 128 ; 129 (define (bloomfilterk bf) 130 (*bloomfilterk (checkbloomfilter 'bloomfilterk bf)) ) 131 ; 132 (definerecordtype bloomfilter 133 (*makebloomfilter n m k bits hashes mdps) 134 bloomfilter? 135 (n *bloomfiltern *bloomfilternset!) 136 (m *bloomfilterm) 137 (k *bloomfilterk) 138 (bits *bloomfilterbits *bloomfilterbitsset!) 139 (hashes *bloomfilterhashers) 140 (mdps *bloomfilteralgorithms) ) 126 141 127 142 ;;; Support … … 140 155 (lambda (ls hasher) (hasher obj ls)) 141 156 '() 142 ( %bloomfilterhashers bf)) )157 (*bloomfilterhashers bf)) ) 143 158 144 159 (: bloomfilterkindices (bloomfilter * > list)) 145 160 ; 146 161 (define (bloomfilterkindices bf obj) 147 (take! (bloomfilterindices bf obj) ( %bloomfilterk bf)) )162 (take! (bloomfilterindices bf obj) (*bloomfilterk bf)) ) 148 163 149 164 (: bloomfilterfoldl (bloomfilter procedure * list > *)) … … 265 280 ;;; Bloom Filter 266 281 267 (: bloomfilter? (* > boolean : bloomfilter)) 268 ; 269 (define (bloomfilter? obj) 270 (%bloomfilter? obj) ) 271 272 (definecheck+errortype bloomfilter %bloomfilter?) 282 (definecheck+errortype bloomfilter bloomfilter?) 273 283 274 284 (: bloomfilteralgorithms (bloomfilter > messagedigestprimitives)) … … 276 286 (define (bloomfilteralgorithms bf) 277 287 (listcopy 278 ( %bloomfilteralgorithms288 (*bloomfilteralgorithms 279 289 (checkbloomfilter 'bloomfilteralgorithms bf))) ) 280 290 … … 282 292 ; 283 293 (define (bloomfiltern bf) 284 ( %bloomfiltern (checkbloomfilter 'bloomfiltern bf)) )294 (*bloomfiltern (checkbloomfilter 'bloomfiltern bf)) ) 285 295 286 296 (: bloomfilterm (bloomfilter > fixnum)) 287 297 ; 288 298 (define (bloomfilterm bf) 289 ( %bloomfilterm (checkbloomfilter 'bloomfilterm bf)) )299 (*bloomfilterm (checkbloomfilter 'bloomfilterm bf)) ) 290 300 291 301 (: bloomfilterk (bloomfilter > fixnum)) 292 302 ; 293 303 (define (bloomfilterk bf) 294 ( %bloomfilterk (checkbloomfilter 'bloomfilterk bf)) )304 (*bloomfilterk (checkbloomfilter 'bloomfilterk bf)) ) 295 305 296 306 ;FIXME makebloomfilter type is ugh … … 324 334 (bits (makebitvector m)) 325 335 (hashers (map (cut makebloomfilterhasher <> m) mdps)) ) 326 ( %makebloomfilter 0 m desk bits hashers mdps) ) )336 (*makebloomfilter 0 m desk bits hashers mdps) ) ) 327 337 328 338 (: bloomfilterpfalsepositive (bloomfilter > float)) … … 331 341 (checkbloomfilter 'bloomfilterpfalsepositive bf) 332 342 (pfalsepositive 333 (%bloomfilterk bf) 334 (optional n (%bloomfiltern bf)) 335 (%bloomfilterm bf)) ) 336 337 ; 338 (define (*bitset bits idx) 343 (*bloomfilterk bf) 344 (optional n (*bloomfiltern bf)) 345 (*bloomfilterm bf)) ) 346 347 (: *biton! (iset:integerset fixnum > iset:integerset)) 348 ; 349 (define (*biton! bits idx) 339 350 (bitvectorset! bits idx #t) 340 351 bits ) … … 346 357 (unless (bloomfilterexists? (checkbloomfilter 'bloomfilterset! bf) obj) 347 358 ;spray rep bits 348 (let ((bits (bloomfilterfoldl bf *bit set (%bloomfilterbits bf) obj)))349 ( %bloomfilterbitsset! bf bits) )359 (let ((bits (bloomfilterfoldl bf *biton! (*bloomfilterbits bf) obj))) 360 (*bloomfilterbitsset! bf bits) ) 350 361 ;bump actual pop 351 ( %bloomfilternset! bf (fx+ (%bloomfiltern bf) 1)) ) )362 (*bloomfilternset! bf (fx+ (*bloomfiltern bf) 1)) ) ) 352 363 353 364 (: bloomfilterexists? (bloomfilter * > boolean)) … … 356 367 (let* ( 357 368 (bits 358 ( %bloomfilterbits (checkbloomfilter 'bloomfilterexists? bf)) )369 (*bloomfilterbits (checkbloomfilter 'bloomfilterexists? bf)) ) 359 370 (bitcnt 360 371 (lambda (cnt idx) (if (bitvectorref bits idx) (fx+ cnt 1) cnt)) ) 361 372 (refs 362 373 (bloomfilterfoldl bf bitcnt 0 obj)) ) 363 (fx<= ( %bloomfilterk bf) refs) ) )374 (fx<= (*bloomfilterk bf) refs) ) ) 364 375 365 376 ) ;module bloomfilter
Note: See TracChangeset
for help on using the changeset viewer.