public void update(final long item){
  if (itemsSeen_ == MAX_ITEMS_SEEN) {
    throw new SketchesStateException("Sketch has exceeded capacity for total items seen: " + MAX_ITEMS_SEEN);
  }
  if (itemsSeen_ < reservoirSize_) {
    if (itemsSeen_ >= currItemsAlloc_) {
      growReservoir();
    }
    assert itemsSeen_ < currItemsAlloc_;
    data_[(int)itemsSeen_]=item;
    ++itemsSeen_;
  }
 else {
    ++itemsSeen_;
    if (SamplingUtil.rand.nextDouble() * itemsSeen_ < reservoirSize_) {
      int newSlot=SamplingUtil.rand.nextInt(reservoirSize_);
      data_[newSlot]=item;
    }
  }
}

public void update ( final long item ) { if ( itemsSeen_ == MAX_ITEMS_SEEN ) { throw new SketchesStateException ( "Sketch has exceeded capacity for total items seen: " + MAX_ITEMS_SEEN ) ; } if ( itemsSeen_ < reservoirSize_ ) { if ( itemsSeen_ >= currItemsAlloc_ ) { growReservoir ( ) ; } assert itemsSeen_ < currItemsAlloc_ ; data_ [ ( int ) itemsSeen_ ] = item ; ++ itemsSeen_ ; } else { ++ itemsSeen_ ; if ( SamplingUtil . rand . nextDouble ( ) * itemsSeen_ < reservoirSize_ ) { int newSlot = SamplingUtil . rand . nextInt ( reservoirSize_ ) ; data_ [ newSlot ] = item ; } } }
randomly decide whether or not to include an item in the sample set .
