code: private DeepPartition[] calculateShardChunks(DBCollection collection) {
  
          DBCursor chuncks = getChunks(collection);
  
          Map<String, String[]> shards = getShards(collection);
  
          MongoPartition[] deepPartitions = new MongoPartition[chuncks.count()];
          int i = 0;
          boolean keyAssigned = false;
          String key = null;
          while (chuncks.hasNext()) {
  
              DBObject dbObject = chuncks.next();
              if (!keyAssigned) {
                  Set<String> keySet = ((DBObject) dbObject.get("min")).keySet();
                  for (String s : keySet) {
                      key = s;
                      keyAssigned = true;
                  }
              }
              deepPartitions[i] = new MongoPartition(mongoDeepJobConfig.getRddId(), i,
                      new DeepTokenRange(shards.get(dbObject.get
                              ("shard")),
                              ((DBObject) dbObject.get
                                      ("min")).get(key),
                              ((DBObject) dbObject.get("max")).get(key)), key);
              i++;
          }
          List<MongoPartition> mongoPartitions = Arrays.asList(deepPartitions);
  
          Collections.shuffle(mongoPartitions);
          return mongoPartitions.toArray(new MongoPartition[mongoPartitions.size()]);
      }
docs: Calculates shard chunks.
  
  @param collection the collection
  @return the deep partition [ ]