code: 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_) { // initial phase, take the first reservoirSize_ items
        if (itemsSeen_ >= currItemsAlloc_) {
          growReservoir();
        }
        assert itemsSeen_ < currItemsAlloc_;
        // we'll randomize replacement positions, so in-order should be valid for now
        data_[(int) itemsSeen_] = item; // since less than reservoir size, cast is safe
        ++itemsSeen_;
      } else { // code for steady state where we sample randomly
        ++itemsSeen_;
        // prob(keep_item) < k / n = reservoirSize_ / itemsSeen_
        // so multiply to get: keep if rand * itemsSeen_ < reservoirSize_
        if ((SamplingUtil.rand.nextDouble() * itemsSeen_) < reservoirSize_) {
          final int newSlot = SamplingUtil.rand.nextInt(reservoirSize_);
          data_[newSlot] = item;
        }
      }
    }
docs: Randomly decide whether or not to include an item in the sample set.
  
  @param item a unit-weight (equivalently, unweighted) item of the set being sampled from