本文整理匯總了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;
}