org.apache.spark.api.java.JavaRDDLike Java Examples

The following examples show how to use org.apache.spark.api.java.JavaRDDLike. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BoundedDataset.java    From beam with Apache License 2.0 6 votes vote down vote up
Iterable<WindowedValue<T>> getValues(PCollection<T> pcollection) {
  if (windowedValues == null) {
    WindowFn<?, ?> windowFn = pcollection.getWindowingStrategy().getWindowFn();
    Coder<? extends BoundedWindow> windowCoder = windowFn.windowCoder();
    final WindowedValue.WindowedValueCoder<T> windowedValueCoder;
    if (windowFn instanceof GlobalWindows) {
      windowedValueCoder = WindowedValue.ValueOnlyWindowedValueCoder.of(pcollection.getCoder());
    } else {
      windowedValueCoder =
          WindowedValue.FullWindowedValueCoder.of(pcollection.getCoder(), windowCoder);
    }
    JavaRDDLike<byte[], ?> bytesRDD = rdd.map(CoderHelpers.toByteFunction(windowedValueCoder));
    List<byte[]> clientBytes = bytesRDD.collect();
    windowedValues =
        clientBytes.stream()
            .map(bytes -> CoderHelpers.fromByteArray(bytes, windowedValueCoder))
            .collect(Collectors.toList());
  }
  return windowedValues;
}
 
Example #2
Source File: BoundedDataset.java    From beam with Apache License 2.0 5 votes vote down vote up
List<byte[]> getBytes(WindowedValue.WindowedValueCoder<T> wvCoder) {
  if (clientBytes == null) {
    JavaRDDLike<byte[], ?> bytesRDD = rdd.map(CoderHelpers.toByteFunction(wvCoder));
    clientBytes = bytesRDD.collect();
  }
  return clientBytes;
}
 
Example #3
Source File: SharedTrainingMaster.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
protected <T, Repr extends JavaRDDLike<T, Repr>> long getTotalDataSetObjectCount(
                JavaRDDLike<T, Repr> trainingData) {
    if (collectTrainingStats)
        stats.logCountStart();

    long totalDataSetObjectCount = trainingData.count();

    if (collectTrainingStats)
        stats.logCountEnd();

    return totalDataSetObjectCount;
}
 
Example #4
Source File: ParameterAveragingTrainingMaster.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
protected <T, Repr extends JavaRDDLike<T, Repr>> long getTotalDataSetObjectCount(
                JavaRDDLike<T, Repr> trainingData) {
    if (collectTrainingStats)
        stats.logCountStart();
    long totalDataSetObjectCount = trainingData.count();
    if (collectTrainingStats)
        stats.logCountEnd();
    return totalDataSetObjectCount;
}
 
Example #5
Source File: SparkUtils.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
public static int getPartitions(JavaRDDLike<?,?> rdd) {
    int rddPartitions = rdd.getNumPartitions();
    return Math.max(rddPartitions, getDefaultPartitions());
}
 
Example #6
Source File: SparkUtils.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
public static int getPartitions(JavaRDDLike<?,?> rdd1, JavaRDDLike<?,?> rdd2) {
    int rddPartitions1 = rdd1.getNumPartitions();
    int rddPartitions2 = rdd2.getNumPartitions();
    int max = Math.max(rddPartitions1, rddPartitions2);
    return Math.max(max, getDefaultPartitions());
}