original_docstring: Determine the number of index rows that need to change.
  
    We assume that old_entity represents the current state of the Datastore.
  
    Args:
      composite_indexes: The composite_indexes for the kind of the entities.
      old_entity: Entity representing the current state in the Datastore.
      new_entity: Entity representing the desired state in the Datastore
  
    Returns:
      The number of index rows that need to change.
    
docstring: Determine the number of index rows that need to change.
  We assume that old_entity represents the current state of the Datastore.
docstring_tokens: Determine the number of index rows that need to change . We assume that old_entity represents the current state of the Datastore .
code: def _ChangedIndexRows(composite_indexes, old_entity, new_entity):
    """Determine the number of index rows that need to change.
  
    We assume that old_entity represents the current state of the Datastore.
  
    Args:
      composite_indexes: The composite_indexes for the kind of the entities.
      old_entity: Entity representing the current state in the Datastore.
      new_entity: Entity representing the desired state in the Datastore
  
    Returns:
      The number of index rows that need to change.
    """
  
  
  
    unique_old_properties = collections.defaultdict(set)
  
  
  
  
    unique_new_properties = collections.defaultdict(set)
  
    if old_entity is not None:
      for old_prop in old_entity.property_list():
        _PopulateUniquePropertiesSet(old_prop, unique_old_properties)
  
  
    unchanged = collections.defaultdict(int)
  
    for new_prop in new_entity.property_list():
      new_prop_as_str = _PopulateUniquePropertiesSet(
          new_prop, unique_new_properties)
      if new_prop_as_str in unique_old_properties[new_prop.name()]:
        unchanged[new_prop.name()] += 1
  
  
  
  
    all_property_names = set(unique_old_properties.iterkeys())
    all_property_names.update(unique_old_properties.iterkeys())
    all_property_names.update(unchanged.iterkeys())
  
    all_indexes = _GetEntityByPropertyIndexes(all_property_names)
    all_indexes.extend([comp.definition() for comp in composite_indexes])
    path_size = new_entity.key().path().element_size()
    writes = 0
    for index in all_indexes:
  
  
  
      ancestor_multiplier = 1
      if index.ancestor() and index.property_size() > 1:
        ancestor_multiplier = path_size
      writes += (_CalculateWritesForCompositeIndex(
          index, unique_old_properties, unique_new_properties, unchanged) *
                 ancestor_multiplier)
    return writes
code_tokens: def _ChangedIndexRows ( composite_indexes , old_entity , new_entity ) : unique_old_properties = collections . defaultdict ( set ) unique_new_properties = collections . defaultdict ( set ) if old_entity is not None : for old_prop in old_entity . property_list ( ) : _PopulateUniquePropertiesSet ( old_prop , unique_old_properties ) unchanged = collections . defaultdict ( int ) for new_prop in new_entity . property_list ( ) : new_prop_as_str = _PopulateUniquePropertiesSet ( new_prop , unique_new_properties ) if new_prop_as_str in unique_old_properties [ new_prop . name ( ) ] : unchanged [ new_prop . name ( ) ] += 1 all_property_names = set ( unique_old_properties . iterkeys ( ) ) all_property_names . update ( unique_old_properties . iterkeys ( ) ) all_property_names . update ( unchanged . iterkeys ( ) ) all_indexes = _GetEntityByPropertyIndexes ( all_property_names ) all_indexes . extend ( [ comp . definition ( ) for comp in composite_indexes ] ) path_size = new_entity . key ( ) . path ( ) . element_size ( ) writes = 0 for index in all_indexes : ancestor_multiplier = 1 if index . ancestor ( ) and index . property_size ( ) > 1 : ancestor_multiplier = path_size writes += ( _CalculateWritesForCompositeIndex ( index , unique_old_properties , unique_new_properties , unchanged ) * ancestor_multiplier ) return writes
short_docstring: Determine the number of index rows that need to change.
short_docstring_tokens: Determine the number of index rows that need to change .
comment: """Determine the number of index rows that need to change.
  
    We assume that old_entity represents the current state of the Datastore.
  
    Args:
      composite_indexes: The composite_indexes for the kind of the entities.
      old_entity: Entity representing the current state in the Datastore.
      new_entity: Entity representing the desired state in the Datastore
  
    Returns:
      The number of index rows that need to change.
    """