'Update values/predicates for a given fraction of the subjects.'

def _UpdateRandom(self, subjects, fraction, change_test=True):

    if change_test:
        self.test_name = ('update    %d%%' % fraction)
    new_value = os.urandom(100)
    for i in subjects:
        subject = subjects[i]['name']
        predicates = subjects[i]['attrs']
        if (self.rand.randint(0, 100) > fraction):
            continue
        which = self.rand.randint(0, 2)
        if ((which == 0) or (which == 1)):
            for (j, timestamp_info) in predicates.items():
                number_timestamps = len(timestamp_info)
                if ((which == 0) and len(timestamp_info)):
                    data_store.DB.Set(subject, (self.predicate_template % j), new_value, timestamp=timestamp_info[(-1)], token=self.token)
                    self.Register()
                elif (which == 1):
                    timestamp_info.append(((100 * number_timestamps) + 1))
                    data_store.DB.Set(subject, (self.predicate_template % j), new_value, replace=False, timestamp=timestamp_info[(-1)], token=self.token)
                    self.values += 1
                    self.Register()
        elif (which == 2):
            j = len(predicates)
            number_timestamps = self.rand.randrange(1, 3)
            ts = [(100 * (ts + 1)) for ts in xrange(number_timestamps)]
            predicates[j] = ts
            self.values += number_timestamps
            self.predicates += 1
            values = [(new_value, t) for t in ts]
            data_store.DB.MultiSet(subject, {(self.predicate_template % j): values}, replace=False, timestamp=100, token=self.token)
            self.Register()
    data_store.DB.Flush()
