本文整理汇总了Java中org.apache.spark.sql.SparkSession.createDataset方法的典型用法代码示例。如果您正苦于以下问题:Java SparkSession.createDataset方法的具体用法?Java SparkSession.createDataset怎么用?Java SparkSession.createDataset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.spark.sql.SparkSession
的用法示例。
在下文中一共展示了SparkSession.createDataset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractEntry
import org.apache.spark.sql.SparkSession; //导入方法依赖的package包/类
/**
* Extracts the given resource type from the RDD of bundles and returns
* it as a Dataset of that type.
*
* @param spark the spark session
* @param bundles an RDD of FHIR Bundles
* @param resourceName the FHIR name of the resource type to extract
* (e.g., condition, patient. etc).
* @param encoders the Encoders instance defining how the resources are encoded.
* @param <T> the type of the resource being extracted from the bundles.
* @return a dataset of the given resource
*/
public static <T extends IBaseResource> Dataset<T> extractEntry(SparkSession spark,
JavaRDD<Bundle> bundles,
String resourceName,
FhirEncoders encoders) {
RuntimeResourceDefinition def = context.getResourceDefinition(resourceName);
JavaRDD<T> resourceRdd = bundles.flatMap(new ToResource<T>(def.getName()));
Encoder<T> encoder = encoders.of((Class<T>) def.getImplementingClass());
return spark.createDataset(resourceRdd.rdd(), encoder);
}