Changeset 36576 in project


Ignore:
Timestamp:
09/09/18 23:32:57 (10 days ago)
Author:
kon
Message:

remove record-variants dependency, no procedure checks, type record procedures

Location:
release/5/bloom-filter/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/5/bloom-filter/trunk/bloom-filter.egg

    r36501 r36576  
    44((synopsis "Bloom Filter")
    55 (category data)
    6  (version "2.1.0")
     6 (version "2.2.0")
    77 (author "[[kon lovett]]")
    88 (license "BSD")
     
    1212        (message-digest-type "4.0.2")
    1313        (message-digest-utils "4.1.1")
    14         (check-errors "3.1.0")
    15         (record-variants "1.0"))
     14        (check-errors "3.1.0"))
    1615 (test-dependencies test sha1 sha2 md5 tiger-hash ripemd)
    1716 (components
     
    1918    #;(inline-file)
    2019    (types-file)
    21     (csc-options "-O3" "-d1" "-local" "-no-procedure-checks-for-toplevel-bindings") ) ) )
     20    (csc-options "-O3" "-d1" "-local" "-no-procedure-checks") ) ) )
  • release/5/bloom-filter/trunk/bloom-filter.scm

    r36501 r36576  
    5050  message-digest-type
    5151  message-digest-item
    52   record-variants
    5352  (only type-checks
    5453    define-check+error-type
     
    5655  (only type-errors-basic signal-bounds-error))
    5756
    58 (declare (bound-to-procedure ##sys#signal-hook))
    59 
    6057;;;
    6158
     59(define-type iset:integer-set *)
     60
    6261(define-type message-digest-primitive (struct message-digest-primitive))
    6362
     
    6564
    6665(define-type bloom-filter-hasher (* (list-of fixnum) -> (list-of fixnum)))
     66
     67(define-type bloom-filter-hashers (list-of bloom-filter-hasher))
    6768
    6869(define-type unsigned-native-integer-getter (* fixnum --> (or fixnum bignum)))
     
    115116(define-type bloom-filter (struct bloom-filter))
    116117
    117 (define-record-type-variant bloom-filter (unsafe unchecked inline)
    118   (%make-bloom-filter n m k bits hashes mdps)
    119   %bloom-filter?
    120   (n %bloom-filter-n %bloom-filter-n-set!)
    121   (m %bloom-filter-m)
    122   (k %bloom-filter-k)
    123   (bits %bloom-filter-bits %bloom-filter-bits-set!)
    124   (hashes %bloom-filter-hashers)
    125   (mdps %bloom-filter-algorithms) )
     118(: *make-bloom-filter (fixnum fixnum fixnum iset:integer-set bloom-filter-hashers message-digest-primitives -> bloom-filter))
     119(: bloom-filter? (* -> boolean : bloom-filter))
     120(: *bloom-filter-n (bloom-filter --> fixnum))
     121(: *bloom-filter-n-set! (bloom-filter fixnum -> void))
     122(: *bloom-filter-m (bloom-filter --> fixnum))
     123(: *bloom-filter-k (bloom-filter --> fixnum))
     124(: *bloom-filter-bits (bloom-filter --> iset:integer-set))
     125(: *bloom-filter-bits-set! (bloom-filter iset:integer-set -> void))
     126(: *bloom-filter-hashers (bloom-filter --> bloom-filter-hashers))
     127(: *bloom-filter-algorithms (bloom-filter --> message-digest-primitives))
     128;
     129(define (bloom-filter-k bf)
     130  (*bloom-filter-k (check-bloom-filter 'bloom-filter-k bf)) )
     131;
     132(define-record-type bloom-filter
     133  (*make-bloom-filter n m k bits hashes mdps)
     134  bloom-filter?
     135  (n *bloom-filter-n *bloom-filter-n-set!)
     136  (m *bloom-filter-m)
     137  (k *bloom-filter-k)
     138  (bits *bloom-filter-bits *bloom-filter-bits-set!)
     139  (hashes *bloom-filter-hashers)
     140  (mdps *bloom-filter-algorithms) )
    126141
    127142;;; Support
     
    140155    (lambda (ls hasher) (hasher obj ls))
    141156    '()
    142     (%bloom-filter-hashers bf)) )
     157    (*bloom-filter-hashers bf)) )
    143158
    144159(: bloom-filter-k-indices (bloom-filter * --> list))
    145160;
    146161(define (bloom-filter-k-indices bf obj)
    147   (take! (bloom-filter-indices bf obj) (%bloom-filter-k bf)) )
     162  (take! (bloom-filter-indices bf obj) (*bloom-filter-k bf)) )
    148163
    149164(: bloom-filter-foldl (bloom-filter procedure * list --> *))
     
    265280;;; Bloom Filter
    266281
    267 (: bloom-filter? (* -> boolean : bloom-filter))
    268 ;
    269 (define (bloom-filter? obj)
    270   (%bloom-filter? obj) )
    271 
    272 (define-check+error-type bloom-filter %bloom-filter?)
     282(define-check+error-type bloom-filter bloom-filter?)
    273283
    274284(: bloom-filter-algorithms (bloom-filter --> message-digest-primitives))
     
    276286(define (bloom-filter-algorithms bf)
    277287  (list-copy
    278     (%bloom-filter-algorithms
     288    (*bloom-filter-algorithms
    279289      (check-bloom-filter 'bloom-filter-algorithms bf))) )
    280290
     
    282292;
    283293(define (bloom-filter-n bf)
    284   (%bloom-filter-n (check-bloom-filter 'bloom-filter-n bf)) )
     294  (*bloom-filter-n (check-bloom-filter 'bloom-filter-n bf)) )
    285295
    286296(: bloom-filter-m (bloom-filter --> fixnum))
    287297;
    288298(define (bloom-filter-m bf)
    289   (%bloom-filter-m (check-bloom-filter 'bloom-filter-m bf)) )
     299  (*bloom-filter-m (check-bloom-filter 'bloom-filter-m bf)) )
    290300
    291301(: bloom-filter-k (bloom-filter --> fixnum))
    292302;
    293303(define (bloom-filter-k bf)
    294   (%bloom-filter-k (check-bloom-filter 'bloom-filter-k bf)) )
     304  (*bloom-filter-k (check-bloom-filter 'bloom-filter-k bf)) )
    295305
    296306;FIXME make-bloom-filter type is ugh
     
    324334    (bits (make-bit-vector m))
    325335    (hashers (map (cut make-bloom-filter-hasher <> m) mdps)) )
    326     (%make-bloom-filter 0 m des-k bits hashers mdps) ) )
     336    (*make-bloom-filter 0 m des-k bits hashers mdps) ) )
    327337
    328338(: bloom-filter-p-false-positive (bloom-filter --> float))
     
    331341  (check-bloom-filter 'bloom-filter-p-false-positive bf)
    332342  (p-false-positive
    333     (%bloom-filter-k bf)
    334     (optional n (%bloom-filter-n bf))
    335     (%bloom-filter-m bf)) )
    336 
    337 ;
    338 (define (*bitset bits idx)
     343    (*bloom-filter-k bf)
     344    (optional n (*bloom-filter-n bf))
     345    (*bloom-filter-m bf)) )
     346
     347(: *bit-on! (iset:integer-set fixnum -> iset:integer-set))
     348;
     349(define (*bit-on! bits idx)
    339350  (bit-vector-set! bits idx #t)
    340351  bits )
     
    346357  (unless (bloom-filter-exists? (check-bloom-filter 'bloom-filter-set! bf) obj)
    347358    ;spray rep bits
    348     (let ((bits (bloom-filter-foldl bf *bitset (%bloom-filter-bits bf) obj)))
    349       (%bloom-filter-bits-set! bf bits) )
     359    (let ((bits (bloom-filter-foldl bf *bit-on! (*bloom-filter-bits bf) obj)))
     360      (*bloom-filter-bits-set! bf bits) )
    350361    ;bump actual pop
    351     (%bloom-filter-n-set! bf (fx+ (%bloom-filter-n bf) 1)) ) )
     362    (*bloom-filter-n-set! bf (fx+ (*bloom-filter-n bf) 1)) ) )
    352363
    353364(: bloom-filter-exists? (bloom-filter * --> boolean))
     
    356367  (let* (
    357368    (bits
    358       (%bloom-filter-bits (check-bloom-filter 'bloom-filter-exists? bf)) )
     369      (*bloom-filter-bits (check-bloom-filter 'bloom-filter-exists? bf)) )
    359370    (bitcnt
    360371      (lambda (cnt idx) (if (bit-vector-ref bits idx) (fx+ cnt 1) cnt)) )
    361372    (refs
    362373      (bloom-filter-foldl bf bitcnt 0 obj)) )
    363     (fx<= (%bloom-filter-k bf) refs) ) )
     374    (fx<= (*bloom-filter-k bf) refs) ) )
    364375
    365376) ;module bloom-filter
Note: See TracChangeset for help on using the changeset viewer.