You can change this function to get the shard-map from somewhere/somehow place else in conjuction with
        save_shard_map().
339522
def get_shard_map(self, force_refresh=False):
        
        now = datetime.utcnow()
        if force_refresh is True or \
                        self.shard_map is None or \
                        (now - self.last_refresh).total_seconds() > self.refresh_ttl:
            self.last_refresh = now
            self.refresh_shard_map()
        return self.shard_map
1262025
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;
    }
659711
def _construct_sharded(self):
        """"""

        current_version = self.getMongoDVersion()

        num_mongos = self.args['mongos'] if self.args['mongos'] > 0 else 1
        shard_names = self._get_shard_names(self.args)

        # create shards as stand-alones or replica sets
        nextport = self.args['port'] + num_mongos
        for shard in shard_names:
            if (self.args['single'] and
                    LooseVersion(current_version) >= LooseVersion("3.6.0")):
                errmsg = " \n * In MongoDB 3.6 and above a Shard must be " \
                         "made up of a replica set. Please use --replicaset " \
                         "option when starting a sharded cluster.*"
                raise SystemExit(errmsg)

            elif (self.args['single'] and
                    LooseVersion(current_version) < LooseVersion("3.6.0")):
                self.shard_connection_str.append(
                    self._construct_single(
                        self.dir, nextport, name=shard, extra='--shardsvr'))
                nextport += 1
            elif self.args['replicaset']:
                self.shard_connection_str.append(
                    self._construct_replset(
                        self.dir, nextport, shard,
                        num_nodes=list(range(self.args['nodes'])),
                        arbiter=self.args['arbiter'], extra='--shardsvr'))
                nextport += self.args['nodes']
                if self.args['arbiter']:
                    nextport += 1

        # start up config server(s)
        config_string = []

        # SCCC config servers (MongoDB <3.3.0)
        if not self.args['csrs'] and self.args['config'] >= 3:
            config_names = ['config1', 'config2', 'config3']
        else:
            config_names = ['config']

        # CSRS config servers (MongoDB >=3.1.0)
        if self.args['csrs']:
            config_string.append(self._construct_config(self.dir, nextport,
                                                        "configRepl", True))
        else:
            for name in config_names:
                self._construct_config(self.dir, nextport, name)
                config_string.append('%s:%i' % (self.args['hostname'],
                                                nextport))
                nextport += 1

        # multiple mongos use <datadir>/mongos/ as subdir for log files
        if num_mongos > 1:
            mongosdir = os.path.join(self.dir, 'mongos')
            if not os.path.exists(mongosdir):
                if self.args['verbose']:
                    print("creating directory: %s" % mongosdir)
                os.makedirs(mongosdir)

        # start up mongos, but put them to the front of the port range
        nextport = self.args['port']
        for i in range(num_mongos):
            if num_mongos > 1:
                mongos_logfile = 'mongos/mongos_%i.log' % nextport
            else:
                mongos_logfile = 'mongos.log'
            self._construct_mongos(os.path.join(self.dir, mongos_logfile),
                                   nextport, ','.join(config_string))

            nextport += 1
64200
@SuppressWarnings("unchecked")
  private HashMap<String, HashMap<String, HashSet<String>>> computeMissingTermvectorItemsPerShard(
      List<ShardRequest> requests, String... args) throws IOException {
    HashMap<String, HashMap<String, HashSet<String>>> result = new HashMap<>();
    HashMap<String, HashMap<String, HashSet<String>>> itemsPerShardSets = new HashMap<>();
    HashMap<String, HashSet<String>> itemSets = new HashMap<>();
    // loop over responses different shards
    for (ShardRequest sreq : requests) {
      if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)
          && sreq.params.getBool(PARAM_MTAS_TERMVECTOR, false)) {
        for (ShardResponse shardResponse : sreq.responses) {
          NamedList<Object> response = shardResponse.getSolrResponse()
              .getResponse();
          try {
            // get termvector data
            ArrayList<NamedList<Object>> data = (ArrayList<NamedList<Object>>) response
                .findRecursive(args);
            if (data != null) {
              // loop over temvector results
              for (int i = 0; i < data.size(); i++) {
                NamedList<Object> dataItem = data.get(i);
                try {
                  // get termvector result
                  String termvectorKey = (String) dataItem.get("key");
                  MtasSolrMtasResult list = (MtasSolrMtasResult) dataItem
                      .get("list");
                  if (termvectorKey != null && list != null) {
                    // get keys
                    Set<String> keyList = list.getKeyList();
                    HashMap<String, HashSet<String>> itemsPerShardSet;
                    HashSet<String> itemSet;
                    HashSet<String> tmpItemSet = new HashSet<>();
                    if (itemsPerShardSets.containsKey(termvectorKey)) {
                      itemsPerShardSet = itemsPerShardSets.get(termvectorKey);
                      itemSet = itemSets.get(termvectorKey);
                    } else {
                      itemsPerShardSet = new HashMap<>();
                      itemSet = new HashSet<>();
                      itemsPerShardSets.put(termvectorKey, itemsPerShardSet);
                      itemSets.put(termvectorKey, itemSet);
                    }
                    itemsPerShardSet.put(shardResponse.getShardAddress(),
                        tmpItemSet);
                    tmpItemSet.addAll(keyList);
                    itemSet.addAll(keyList);
                  }
                } catch (ClassCastException e) {
                  log.debug(e);
                }
              }
            }
          } catch (ClassCastException e) {
            log.debug(e);
          }
        }
      }
    }

    // construct result
    for (Entry<String, HashSet<String>> entry : itemSets.entrySet()) {
      String termvectorKey = entry.getKey();
      HashSet<String> termvectorKeyList = entry.getValue();
      if (itemsPerShardSets.containsKey(termvectorKey)) {
        HashMap<String, HashSet<String>> itemsPerShardSet = itemsPerShardSets
            .get(termvectorKey);
        for (Entry<String, HashSet<String>> subEntry : itemsPerShardSet
            .entrySet()) {
          String shardName = subEntry.getKey();
          HashMap<String, HashSet<String>> tmpShardKeySet;
          if (result.containsKey(shardName)) {
            tmpShardKeySet = result.get(shardName);
          } else {
            tmpShardKeySet = new HashMap<>();
            result.put(shardName, tmpShardKeySet);
          }
          HashSet<String> tmpResult = new HashSet<>();
          HashSet<String> shardItemsSet = subEntry.getValue();
          for (String termvectorKeyListItem : termvectorKeyList) {
            if (!shardItemsSet.contains(termvectorKeyListItem)) {
              tmpResult.add(termvectorKeyListItem);
            }
          }
          tmpShardKeySet.put(termvectorKey, tmpResult);
        }
      }
    }
    return result;
  }
453553
def substitute(self, var_map):
        
        if self in var_map:
            return var_map[self]
        return self._substitute(var_map)
91211
def to_json(self):
    """"""
    result = {
        "mapper_handler_spec": self.handler_spec,
        "mapper_input_reader": self.input_reader_spec,
        "mapper_params": self.params,
        "mapper_shard_count": self.shard_count
    }
    if self.output_writer_spec:
      result["mapper_output_writer"] = self.output_writer_spec
    return result
217389
List<Contig> getShards(long numberOfBasesPerShard) {
    double shardCount = (end - start) / (double) numberOfBasesPerShard;
    List<Contig> shards = Lists.newArrayList();
    for (int i = 0; i < shardCount; i++) {
      long shardStart = start + (i * numberOfBasesPerShard);
      long shardEnd = Math.min(end, shardStart + numberOfBasesPerShard);

      shards.add(new Contig(referenceName, shardStart, shardEnd));
    }
    return shards;
  }
659358
function getMapOption(from) {
        if (typeof options.map === 'string') {
            var mapPath = options.map + path.basename(from) + '.map';

            if (grunt.file.exists(mapPath)) {
                return grunt.file.read(mapPath);
            }
        }

        return options.map;
    }
384832
def get_as_map(self, key):
        
        if key == None:
            map = {}
            for (k, v) in self.items():
                map[k] = v
            return map
        else:
            value = self.get(key)
            return MapConverter.to_map(value)
822517
function copyAndOffsetMapping(existingMapping) {
    var column     = getColumnAfter(existingMapping.generatedLine - 1, existingMapping.generatedColumn);
    var newMapping = {
      generated: {
        line  : existingMapping.generatedLine,
        column: column
      }
    };
    if (existingMapping.source) {
      newMapping.source   = existingMapping.source;
      newMapping.original = {
        line  : existingMapping.originalLine,
        column: existingMapping.originalColumn
      };
      if (existingMapping.name) {
        newMapping.name = existingMapping.name;
      }
    }
    generator.addMapping(newMapping);
  }
581222
def plash_map(*args):
    from subprocess import check_output
    ''
    out = check_output(['plash', 'map'] + list(args))
    if out == '':
        return None
    return out.decode().strip('\n')
822529
def save_map(self, map_path, map_data):
    """"""
    return self._client.send(save_map=sc_pb.RequestSaveMap(
        map_path=map_path, map_data=map_data))
1346421
function fixturizeCommitSha (map, sha) {
  // Do nothing if the passed sha is already set
  if (map[sha]) {
    return map[sha]
  }

  // Do nothing if the passed sha is one of our fixturized ones
  if (Object.values(map).includes(sha)) {
    return sha
  }

  // Otherwise calculate the new sha and set it on the passed state map.
  const counter = Object.keys(map).length + 1
  map[sha] = ('0000000000000000000000000000000000000000' + counter).substr(-40)

  return map[sha]
}
1035444
public ShardInformation getShardInformation(String shard) {
    ShardInformation shardInformation = shardIndex.get(Objects.requireNonNull(shard, "shard required"));
    if (shardInformation == null) {
      shardInformation = createShardInformation(shard);
    }
    return shardInformation;
  }
931534
def shard_key_selector
      selector = {}
      shard_key_fields.each do |field|
        selector[field.to_s] = new_record? ? send(field) : attribute_was(field)
      end
      selector
    end
307050
def _get_next_open_shard(stream_details, shard_id):
    '''
    
    '''
    found = False
    for shard in stream_details["OpenShards"]:
        current_shard_id = shard["ShardId"]
        if current_shard_id == shard_id:
            found = True
            continue
        if found:
            return current_shard_id
14851
function getShardID(int $shardCount) {
        if(\PHP_INT_SIZE === 4) {
            $time = \base_convert(\substr($this->binary, 0, 42), 2, 10);
            $shard = (int) \bcmod($time, ((string) $shardCount));
            
            return $shard;
        } else {
            $time = $this->value >> 22;
            return ($time % $shardCount);
        }
    }