/* (non-Javadoc)
@see org.apache.hadoop.mapred.Partitioner#getPartition(java.lang.Object, java.lang.Object, int)
971353
public int getPartition(Shard key, IntermediateForm value, int numPartitions) {
    int partition = map.get(key).intValue();
    if (partition < numPartitions) {
      return partition;
    } else {
      return numPartitions - 1;
    }
  }
780939
public int getPartition(K2 key, V2 value,
                          int numReduceTasks) {
    return (key.hashCode() & Integer.MAX_VALUE) % numReduceTasks;
  }
683103
public List<ElementSubSet<E>> getPartitions() {
        final List<ElementSubSet<E>> partitions = new ArrayList<>();
        forEachPartition((idx, key, from, to) -> {
            partitions.add(new ElementSubSet<>(SplittableElementSet.this, key, from, to));
            return true;
        });
        return partitions;
    }
779529
public RedisClusterNode getPartition(String host, int port) {

        for (RedisClusterNode partition : nodeReadView) {

            RedisURI uri = partition.getUri();

            if (matches(uri, host, port)) {
                return partition;
            }

            for (RedisURI redisURI : partition.getAliases()) {

                if (matches(redisURI, host, port)) {
                    return partition;
                }
            }
        }

        return null;
    }
848614
@Override
    public InputStream getPart(String partName) throws IOException {
        ServletRESTRequestImpl ret = castRequest();
        if (ret != null)
            return ret.getPart(partName);
        return null;
    }
342213
public int getNumPartitions(String topicName) {
        Map<String, List<PartitionInfo>> topicInfo = getTopicInfo();
        List<PartitionInfo> partitionInfo = topicInfo != null ? topicInfo.get(topicName) : null;
        return partitionInfo != null ? partitionInfo.size() : 0;
    }
1100519
protected <S extends State, N> S getPartitionedState(
			N namespace,
			TypeSerializer<N> namespaceSerializer,
			StateDescriptor<S, ?> stateDescriptor) throws Exception {

		/*
	    TODO: NOTE: This method does a lot of work caching / retrieving states just to update the namespace.
	    This method should be removed for the sake of namespaces being lazily fetched from the keyed
	    state backend, or being set on the state directly.
	    */

		if (keyedStateStore != null) {
			return keyedStateBackend.getPartitionedState(namespace, namespaceSerializer, stateDescriptor);
		} else {
			throw new RuntimeException("Cannot create partitioned state. The keyed state " +
				"backend has not been set. This indicates that the operator is not " +
				"partitioned/keyed.");
		}
	}
1351578
public SortedGrouping<T> withPartitioner(Partitioner<?> partitioner) {
		Preconditions.checkNotNull(partitioner);

		getKeys().validateCustomPartitioner(partitioner, null);

		this.customPartitioner = partitioner;
		return this;
	}
1353345
public void partitionedOutput(int reduce, K key, 
                                V value) throws IOException {
    PipesPartitioner.setNextPartition(reduce);
    collector.collect(key, value);
  }
349229
def _FindPartition(self, key):
        
        hash_value = self.hash_generator.ComputeHash(key)
        return self._LowerBoundSearch(self.partitions, hash_value)
39909
protected byte[][] determineNewLargestElements(int numberOfPartitions) throws IOException {
        int elementsPerPart = determineElementsPerPart(numberOfPartitions);
        byte[][] keysToInsert = new byte[numberOfPartitions][];
        long offset;
        for (int i = 0; i < numberOfPartitions; i++) {
            if (i == numberOfPartitions - 1) {
                // Handling of last partition
                offset = sourceFile.getFilledUpFromContentStart() - sourceFile.getElementSize();
            } else {
                // Handling of all other partitions
                offset = ((i + 1) * elementsPerPart - 1) * sourceFile.getElementSize();
            }

            ByteBuffer keyBuffer = ByteBuffer.allocate(gp.getKeySize());
            sourceFile.read(offset, keyBuffer);
            keyBuffer.position(0);

            keysToInsert[i] = keyBuffer.array();
        }
        return keysToInsert;
    }
746936
public static int getPartitionStatic(LongWritable key, LongWritable value,
      int numPartitions) {
    return (int) (Math.abs(key.get()) % numPartitions);
  }
1172999
@Override
    public Partition[] getPartitions(ExtractorConfig<T> config) {

        GetPartitionsAction<T> getPartitionsAction = new GetPartitionsAction<>(config);

        channel.writeAndFlush(getPartitionsAction);

        Response response;
        boolean interrupted = false;
        for (; ; ) {
            try {
                response = answer.take();
                break;
            } catch (InterruptedException ignore) {
                interrupted = true;
            }
        }

        if (interrupted) {
            Thread.currentThread().interrupt();
        }

        return ((GetPartitionsResponse) response).getPartitions();
    }
833272
@GET
    @Timed
    public Response getPartitions(@Context final UriInfo uriInfo, @Context final HttpHeaders headers) {

        final IRI identifier = rdf.createIRI(
                properties.getProperty("baseUrl", uriInfo.getBaseUri().toString()));

        LOGGER.debug("Request for root resource at: {}", identifier.getIRIString());

        final List<Triple> graph = new ArrayList<>();
        partitions.entrySet().stream().map(e -> rdf.createIRI(e.getValue() + e.getKey()))
            .map(obj -> rdf.createTriple(identifier, LDP.contains, obj)).forEach(graph::add);

        properties.stringPropertyNames().stream().filter(propMapping::containsKey)
            .map(name -> rdf.createTriple(identifier, propMapping.get(name), isUrl(properties.getProperty(name)) ?
                        rdf.createIRI(properties.getProperty(name)) :
                        rdf.createLiteral(properties.getProperty(name))))
            .forEach(graph::add);

        final RDFSyntax syntax = getSyntax(headers.getAcceptableMediaTypes(), empty())
            .orElseThrow(NotAcceptableException::new);

        final IRI profile = ofNullable(getProfile(headers.getAcceptableMediaTypes(), syntax))
            .orElseGet(() -> getDefaultProfile(syntax, identifier));

        final StreamingOutput stream = new StreamingOutput() {
            @Override
            public void write(final OutputStream out) throws IOException {
                ioService.write(graph.stream(), out, syntax, profile);
            }
        };

        return ok().header(ALLOW, join(",", HttpMethod.GET, HEAD, OPTIONS))
                    .link(LDP.Resource.getIRIString(), "type")
                    .link(LDP.RDFSource.getIRIString(), "type")
                    .type(syntax.mediaType).entity(stream).build();
    }
684567
public Part getPart(String name) throws IOException {
        if (!_parsed)
            parse();
        throwIfError();
        return _parts.getValue(name, 0);
    }
1146994
@VisibleForTesting
  FeedPartition findPartitionToProcess(List<WorkerStatus> workerStatus, List<FeedPartition> feedPartitions){
    for (int i = 0; i < feedPartitions.size(); i++) {
      FeedPartition aPartition = feedPartitions.get(i);
      boolean partitionTaken = false;
      for (int j = 0; j < workerStatus.size(); j++) {
        if (workerStatus.get(j).getFeedPartitionId().equals(aPartition.getPartitionId())) {
          partitionTaken = true;
        }
      }
      if (partitionTaken == false){
        return aPartition;
      }
    }
    return null;
  }
275784
public void foreachPartition(final Action1<PartitionState> action) {
    int len = partitionStates.length();
    for (int i = 0; i < len; i++) {
      PartitionState ps = partitionStates.get(i);
      if (ps == null) {
        continue;
      }
      action.call(ps);
    }
  }