本文整理汇总了Java中org.apache.spark.api.java.JavaRDD.union方法的典型用法代码示例。如果您正苦于以下问题:Java JavaRDD.union方法的具体用法?Java JavaRDD.union怎么用?Java JavaRDD.union使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.spark.api.java.JavaRDD
的用法示例。
在下文中一共展示了JavaRDD.union方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: splitTrainTest
import org.apache.spark.api.java.JavaRDD; //导入方法依赖的package包/类
private Pair<JavaRDD<M>,JavaRDD<M>> splitTrainTest(JavaRDD<M> newData, JavaRDD<M> pastData) {
Objects.requireNonNull(newData);
if (testFraction <= 0.0) {
return new Pair<>(pastData == null ? newData : newData.union(pastData), null);
}
if (testFraction >= 1.0) {
return new Pair<>(pastData, newData);
}
if (empty(newData)) {
return new Pair<>(pastData, null);
}
Pair<JavaRDD<M>,JavaRDD<M>> newTrainTest = splitNewDataToTrainTest(newData);
JavaRDD<M> newTrainData = newTrainTest.getFirst();
return new Pair<>(pastData == null ? newTrainData : newTrainData.union(pastData),
newTrainTest.getSecond());
}
示例2: getNeighborResources
import org.apache.spark.api.java.JavaRDD; //导入方法依赖的package包/类
/**
* Get resources related to specified resources, computed by querying an in-memory set of subjects
*
* @param quads RDD of quads to filter
* @param subjectURIs set of requested subject URIs to grow from
* @param directed whether to use both directions of relations
* @return URIs of resources related to specified resources
*/
public static JavaRDD<String> getNeighborResources(JavaRDD<Quad> quads, Set<String> subjectURIs, boolean directed) {
JavaRDD<String> neighbors = filterQuadsByAllowedSubjects(quads, subjectURIs)
.filter(quad -> quad.getObject().isURI())
.map(quad -> quad.getObject().getURI());
if (!directed) {
neighbors = neighbors.union(filterQuadsByObjects(quads, subjectURIs)
.filter(quad -> quad.getSubject().isURI())
.map(quad -> quad.getSubject().getURI()));
}
return neighbors;
}