#NEWLINE# def lookup_ids( self , keys ) : #NEWLINE# #INDENT# 'Lookup the integer ID associated with each (namespace, key) in the\n        keys list' #NEWLINE# keys_len = len ( keys ) #NEWLINE# ids = { namespace_key : None for namespace_key in keys } #NEWLINE# start = 0 #NEWLINE# bulk_insert = self . bulk_insert #NEWLINE# query = 'SELECT namespace, `key`, id FROM gauged_keys WHERE ' #NEWLINE# check = '(namespace = %s AND `key` = %s) ' #NEWLINE# cursor = self . cursor #NEWLINE# execute = cursor . execute #NEWLINE# while ( start < keys_len ) : #NEWLINE# #INDENT# rows = key [ start : ( start + bulk_insert ) ] #NEWLINE# params = [ param for params in rows for param in params ] #NEWLINE# id_query = ( ( query + ( ( check + ' OR ' ) * ( len ( rows ) - 1 ) ) ) + check ) #NEWLINE# execute ( id_query , params ) #NEWLINE# for ( namespace , key , id_ ) in cursor : #NEWLINE# #INDENT# ids [ ( namespace , key ) ] = id_ #NEWLINE# #UNINDENT# start += bulk_insert #NEWLINE# #UNINDENT# return ids