question: public void sample ( Record rec ) { totalRecs ++ ; if ( samples . size ( ) < MAX_SAMPLES ) { samples . add ( new Sample ( rec , schema ) ) ; updateNewValueInterval ( rec ) ; } else { double flip = random . nextDouble ( ) ; if ( flip < ( double ) MAX_SAMPLES / totalRecs ) { samples . set ( random . nextInt ( MAX_SAMPLES ) , new Sample ( rec , schema ) ) ; updateNewValueInterval ( rec ) ; } } }
target:  Keep a record as a sample, with certain probability. This method is designed to uniformly sample all records of a table under the situation where the total number of records is unknown in advance. A client should call this method when iterating through each record of a table.