#NEWLINE# @ staticmethod #NEWLINE# def _GetCursorOffset( results , cursor_entity , inclusive , compare ) : #NEWLINE# #INDENT# "Converts a cursor entity into a offset into the result set even if the\n    cursor_entity no longer exists.\n\n    Args:\n      results: the query's results (sequence of datastore_pb.EntityProto)\n      cursor_entity: the datastore_pb.EntityProto from the compiled query\n      inclusive: boolean that specifies if to offset past the cursor_entity\n      compare: a function that takes two datastore_pb.EntityProto and compares\n        them.\n    Returns:\n      the integer offset\n    " #NEWLINE# lo = 0 #NEWLINE# hi = len ( results ) #NEWLINE# if inclusive : #NEWLINE# #INDENT# while ( lo < hi ) : #NEWLINE# #INDENT# mid = ( ( lo + hi ) // 2 ) #NEWLINE# if ( compare ( results [ mid ] , cursor_entity ) < 0 ) : #NEWLINE# #INDENT# lo = ( mid + 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# hi = hi #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# while ( lo < hi ) : #NEWLINE# #INDENT# mid = ( ( lo + hi ) // 2 ) #NEWLINE# if ( compare ( cursor_entity , results [ mid ] ) < 0 ) : #NEWLINE# #INDENT# hi = mid #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# lo = ( mid + 1 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return lo