private boolean objectIsChangingShards ( DBObject dbObj , Map < String , String > currScalarMap ) { if ( ! m_tableDef . isSharded ( ) ) { return false ; } // If object had no prior sharding-field value, it is considered in shard 0. int oldShardNumber = 0 ; String shardingFieldName = m_tableDef . getShardingField ( ) . getName ( ) ; String currShardFieldValue = currScalarMap . get ( shardingFieldName ) ; if ( currShardFieldValue != null ) { oldShardNumber = m_tableDef . computeShardNumber ( Utils . dateFromString ( currShardFieldValue ) ) ; } // Propagate old sharding-field value if not being updated now. int newShardNumber = m_tableDef . getShardNumber ( dbObj ) ; String newShardFieldValue = dbObj . getFieldValue ( shardingFieldName ) ; if ( newShardFieldValue == null && currShardFieldValue != null ) { dbObj . addFieldValue ( shardingFieldName , currShardFieldValue ) ; return false ; } // May or may not be moving to a new shard. return oldShardNumber != newShardNumber ; }
moved to a new shard .