예제 #1
0
 def makeChanges(self, tableName=None, dbName=None, samplesPerShard=None, connections=None):
     '''make a minor change to records, and return those ids'''
     
     if tableName is None:
         tableName = self.tableName
     if dbName is None:
         dbName = self.dbName
     
     if samplesPerShard is None:
         samplesPerShard = self.samplesPerShard
     
     if connections is None:
         connections = itertools.cycle([self.conn])
     else:
         connections = itertools.cycle(connections)
     
     changedRecordIds = []
     for lower, upper in utils.getShardRanges(connections.next(), tableName):
         
         conn = connections.next()
         sampleIds = (x['id'] for x in self.r.db(dbName).table(tableName).between(lower, upper).sample(samplesPerShard).run(conn))
         
         for thisId in sampleIds:
             self.r.db(dbName).table(tableName).get(thisId).update({'randomChange':random.randint(0, 65536)}).run(conn)
             changedRecordIds.append(thisId)
     
     changedRecordIds.sort()
     return changedRecordIds
예제 #2
0
    def makeChanges(self,
                    tableName=None,
                    dbName=None,
                    samplesPerShard=None,
                    connections=None):
        '''make a minor change to records, and return those ids'''

        if tableName is None:
            tableName = self.tableName
        if dbName is None:
            dbName = self.dbName

        if samplesPerShard is None:
            samplesPerShard = self.samplesPerShard

        if connections is None:
            connections = itertools.cycle([self.conn])
        else:
            connections = itertools.cycle(connections)

        changedRecordIds = []
        for lower, upper in utils.getShardRanges(connections.next(),
                                                 tableName):

            conn = connections.next()
            sampleIds = (x['id']
                         for x in self.r.db(dbName).table(tableName).between(
                             lower, upper).sample(samplesPerShard).run(conn))

            for thisId in sampleIds:
                self.r.db(dbName).table(tableName).get(thisId).update({
                    'randomChange':
                    random.randint(0, 65536)
                }).run(conn)
                changedRecordIds.append(thisId)

        changedRecordIds.sort()
        return changedRecordIds