parameters: (self, sample_size)
return_statement: return samples
docstring: Randomly sample 'sample_size' hash entries from the table.
docstring_summary: Randomly sample 'sample_size' hash entries from the table.
docstring_tokens: Randomly sample sample_size hash entries from the table .
function: def random_sample(self, sample_size):
          """Randomly sample 'sample_size' hash entries from the table."""
          samples = []
          index = random.randint(0, len(self.table) - 1)
          pos = index
          # Starting from index, adding hash entries to the sample list until
          # sample_size is met or we ran out of entries.
          while True:
              if self.table[pos] is not None:
                  for i in range(len(self.table[pos])):
                      if self.table[pos][i] is None:
                          continue
                      samples.append(self.table[pos][i])
                      if len(samples) == sample_size:
                          break
              pos += 1
              pos = pos % len(self.table)
              if pos == index or len(samples) == sample_size:
                  break
          assert len(samples) <= sample_size
          return samples
function_tokens: def random_sample ( self , sample_size ) : samples = [ ] index = random . randint ( 0 , len ( self . table ) - 1 ) pos = index # Starting from index, adding hash entries to the sample list until # sample_size is met or we ran out of entries. while True : if self . table [ pos ] is not None : for i in range ( len ( self . table [ pos ] ) ) : if self . table [ pos ] [ i ] is None : continue samples . append ( self . table [ pos ] [ i ] ) if len ( samples ) == sample_size : break pos += 1 pos = pos % len ( self . table ) if pos == index or len ( samples ) == sample_size : break assert len ( samples ) <= sample_size return samples