Given a list of keys and a number of splits find the keys to split on.

@param keys the list of keys.
@param numSplits the number of splits.
772717
private Iterable<Key> getSplitKey(List<Key> keys, int numSplits) {
    // If the number of keys is less than the number of splits, we are limited in the number of
    // splits we can make.
    if (keys.size() < numSplits - 1) {
      return keys;
    }

    // Calculate the number of keys per split. This should be KEYS_PER_SPLIT, but may
    // be less if there are not KEYS_PER_SPLIT * (numSplits - 1) scatter entities.
    //
    // Consider the following dataset, where - represents an entity and * represents an entity
    // that is returned as a scatter entity:
    // ||---*-----*----*-----*-----*------*----*----||
    // If we want 4 splits in this data, the optimal split would look like:
    // ||---*-----*----*-----*-----*------*----*----||
    //            |          |            |
    // The scatter keys in the last region are not useful to us, so we never request them:
    // ||---*-----*----*-----*-----*------*---------||
    //            |          |            |
    // With 6 scatter keys we want to set scatter points at indexes: 1, 3, 5.
    //
    // We keep this as a double so that any "fractional" keys per split get distributed throughout
    // the splits and don't make the last split significantly larger than the rest.
    double numKeysPerSplit = Math.max(1.0, ((double) keys.size()) / (numSplits - 1));

    List<Key> keysList = new ArrayList<Key>(numSplits - 1);
    // Grab the last sample for each split, otherwise the first split will be too small.
    for (int i = 1; i < numSplits; i++) {
      int splitIndex = (int) Math.round(i * numKeysPerSplit) - 1;
      keysList.add(keys.get(splitIndex));
    }

    return keysList;
  }
815707
private static void splitMult(double a[], double b[], double ans[]) {
        ans[0] = a[0] * b[0];
        ans[1] = a[0] * b[1] + a[1] * b[0] + a[1] * b[1];

        /* Resplit */
        resplit(ans);
    }
621143
public CommandArgs<K, V> addKeys(Iterable<K> keys) {

        LettuceAssert.notNull(keys, "Keys must not be null");

        for (K key : keys) {
            addKey(key);
        }
        return this;
    }
1037757
public static <K, V> void putSetMult(Map<K, Set<V>> map, K key,
            Collection<? extends V> values) {
        for (V value : values) {
            putSet(map, key, value);
        }
    }
1114763
private void splitOn(String... columnNames) {

        List<Column<?>> columns = getSourceTable().columns(columnNames);
        int byteSize = getByteSize(columns);

        byte[] currentKey = null;
        String currentStringKey = null;
        TableSlice view;

        Selection selection = new BitmapBackedSelection();

        for (int row = 0; row < getSourceTable().rowCount(); row++) {

            ByteBuffer byteBuffer = ByteBuffer.allocate(byteSize);
            String newStringKey = "";

            for (int col = 0; col < columnNames.length; col++) {
                if (col > 0) {
                    newStringKey = newStringKey + SPLIT_STRING;
                }

                Column<?> c = getSourceTable().column(columnNames[col]);
                String groupKey = getSourceTable().getUnformatted(row, getSourceTable().columnIndex(c));
                newStringKey = newStringKey + groupKey;
                byteBuffer.put(c.asBytes(row));
            }
            byte[] newKey = byteBuffer.array();
            if (row == 0) {
                currentKey = newKey;
                currentStringKey = newStringKey;
            }
            if (!Arrays.equals(newKey, currentKey)) {
                currentKey = newKey;
                view = new TableSlice(getSourceTable(), selection);
                view.setName(currentStringKey);
                currentStringKey = newStringKey;
                addSlice(view);
                selection = new BitmapBackedSelection();
                selection.add(row);
            } else {
                selection.add(row);
            }
        }
        if (!selection.isEmpty()) {
            view = new TableSlice(getSourceTable(), selection);
            view.setName(currentStringKey);
            addSlice(view);
        }
    }
1328439
private Queue<List<Data>> createBatchChunks(List<Data> keys) {
        Queue<List<Data>> chunks = new LinkedList<>();
        int loadBatchSize = getLoadBatchSize();
        int page = 0;
        List<Data> tmpKeys;
        while ((tmpKeys = getBatchChunk(keys, loadBatchSize, page++)) != null) {
            chunks.add(tmpKeys);
        }
        return chunks;
    }
946019
private static int[] createIncrIntArray(int numKeys) {
		int[] keyFields = new int[numKeys];
		for (int i = 0; i < numKeys; i++) {
			keyFields[i] = i;
		}
		return keyFields;
	}
616345
private List<Object> convertToObjectKeys(Collection keys) {
        if (keys == null || keys.isEmpty()) {
            return Collections.emptyList();
        }
        final List<Object> objectKeys = new ArrayList<>(keys.size());
        for (Object key : keys) {
            objectKeys.add(toObject(key));
        }
        return objectKeys;
    }
1339020
public void setCounts(Collection<E> keys, int count) {
    for (E key : keys) {
      setCount(key, count);
    }
  }
149802
public void setKeys(java.util.Collection<java.util.Map<String, AttributeValue>> keys) {
        if (keys == null) {
            this.keys = null;
            return;
        }

        this.keys = new java.util.ArrayList<java.util.Map<String, AttributeValue>>(keys);
    }
1126511
public void splitShards(int targetNumShards) {
    int origionalShardCount = getShardCount();
    int splitFactor = targetNumShards / origionalShardCount;
    if (splitFactor <= 1) {
      return;
    }
    List<List<String>> oldAllFiles = allFiles;
    shardCount = splitFactor * origionalShardCount;
    allFiles = initAllFiles(shardCount);
    int shard = 0;
    for (List<String> files : oldAllFiles) {
      if (!files.isEmpty()) {
        for (List<String> forShard : SplitUtil.split(files, splitFactor, false)) {
          addFilesToShard(shard++, forShard);
        }
      }
    }
  }
434813
public void setKeys(java.util.Collection<DimensionKeyDescription> keys) {
        if (keys == null) {
            this.keys = null;
            return;
        }

        this.keys = new java.util.ArrayList<DimensionKeyDescription>(keys);
    }
1035219
def _choose_split_points(cls, sorted_keys, shard_count):
    """"""
    assert len(sorted_keys) >= shard_count
    index_stride = len(sorted_keys) / float(shard_count)
    return [sorted_keys[int(round(index_stride * i))]
            for i in range(1, shard_count)]
19470
private static Iterable<List<Map.Entry<Symbol, File>>> splitToNChunks(
      final ImmutableMap<Symbol, File> inputMap, int numChunks) {
    checkArgument(numChunks > 0);
    final List<Map.Entry<Symbol, File>> emptyChunk = ImmutableList.of();

    if (inputMap.isEmpty()) {
      return Collections.nCopies(numChunks, emptyChunk);
    }

    final int chunkSize = IntMath.divide(inputMap.size(), numChunks, RoundingMode.UP);
    final ImmutableList<List<Map.Entry<Symbol, File>>> chunks =
        ImmutableList.copyOf(splitToChunksOfFixedSize(inputMap, chunkSize));
    if (chunks.size() == numChunks) {
      return chunks;
    } else {
      // there weren't enough elements to make the desired number of chunks, so we need to
      // pad with empty chunks
      final int shortage = numChunks - chunks.size();
      final List<List<Map.Entry<Symbol, File>>> padding = Collections.nCopies(shortage, emptyChunk);
      return Iterables.concat(chunks, padding);
    }
  }
568165
@SuppressWarnings("deprecation")
  public InputSplit[] getSplits(JobConf job, int numSplits)
    throws IOException {
    LocatedFileStatus[] files = listLocatedStatus(job);
    
    long totalSize = 0;                           // compute total size
    for (FileStatus file: files) {                // check we have valid files
      if (file.isDir()) {
        throw new IOException("Not a file: "+ file.getPath());
      }
      totalSize += file.getLen();
    }

    long goalSize = totalSize / (numSplits == 0 ? 1 : numSplits);
    long minSize = Math.max(job.getLong("mapred.min.split.size", 1),
                            minSplitSize);

    // generate splits
    ArrayList<FileSplit> splits = new ArrayList<FileSplit>(numSplits);
    NetworkTopology clusterMap = new NetworkTopology();
    for (LocatedFileStatus file: files) {
      Path path = file.getPath();
      FileSystem fs = path.getFileSystem(job);
      long length = file.getLen();
      BlockLocation[] blkLocations = file.getBlockLocations();

      if ((length != 0) && isSplitable(fs, path)) { 
        long blockSize = file.getBlockSize();
        long splitSize = computeSplitSize(goalSize, minSize, blockSize);

        long bytesRemaining = length;
        while (((double) bytesRemaining)/splitSize > SPLIT_SLOP) {
          String[] splitHosts = getSplitHosts(blkLocations, 
              length-bytesRemaining, splitSize, clusterMap);
          splits.add(new FileSplit(path, length-bytesRemaining, splitSize, 
              splitHosts));
          bytesRemaining -= splitSize;
        }
        
        if (bytesRemaining != 0) {
          splits.add(new FileSplit(path, length-bytesRemaining, bytesRemaining, 
                     blkLocations[blkLocations.length-1].getHosts()));
        }
      } else if (length != 0) {
        String[] splitHosts = getSplitHosts(blkLocations,0,length,clusterMap);
        splits.add(new FileSplit(path, 0, length, splitHosts));
      } else { 
        //Create empty hosts array for zero length files
        splits.add(new FileSplit(path, 0, length, new String[0]));
      }
    }
    LOG.debug("Total # of splits: " + splits.size());
    return splits.toArray(new FileSplit[splits.size()]);
  }
634940
@SuppressWarnings("rawtypes")
	public List mget(Object... keys) {
		Jedis jedis = getJedis();
		try {
			byte[][] keysBytesArray = keysToBytesArray(keys);
			List<byte[]> data = jedis.mget(keysBytesArray);
			return valueListFromBytesList(data);
		}
		finally {close(jedis);}
	}
928383
function mergeKeys( &$originalKeys, $keys )
    {
        foreach ( $keys as $key )
        {
            if ( count( $key ) >= 2 )
                $originalKeys[$key[0]] = $key[1];
        }
    }