src/Sample.js
function update(t) {
    var p, idx;

    if (res.length < num) {
      res.push(t);
    } else {
      idx = ~~((cnt + 1) * random());
      if (idx < res.length && idx >= cap) {
        p = res[idx];
        if (map[tupleid(p)]) out.rem.push(p); // eviction
        res[idx] = t;
      }
    }
    ++cnt;
  }
function update(t) {
    var p, idx;

    if (res.length < num) {
      res.push(t);
    } else {
      idx = ~~((cnt + 1) * random());
      if (idx < res.length && idx >= cap) {
        p = res[idx];
        if (map[tupleid(p)]) out.rem.push(p); // eviction
        res[idx] = t;
      }
    }
    ++cnt;
  }
function update ( t ) { var p , idx ; if ( res . length < num ) { res . push ( t ) ; } else { idx = ~ ~ ( ( cnt + 1 ) * random ( ) ) ; if ( idx < res . length && idx >= cap ) { p = res [ idx ] ; if ( map [ tupleid ( p ) ] ) out . rem . push ( p ) ; // eviction res [ idx ] = t ; } } ++ cnt ; }
sample reservoir update function
sample reservoir update function