本文整理汇总了Java中org.apache.spark.sql.DataFrame.collect方法的典型用法代码示例。如果您正苦于以下问题:Java DataFrame.collect方法的具体用法?Java DataFrame.collect怎么用?Java DataFrame.collect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.spark.sql.DataFrame
的用法示例。
在下文中一共展示了DataFrame.collect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CreateQuery
import org.apache.spark.sql.DataFrame; //导入方法依赖的package包/类
/**
* Heuristic Naive SPARK implementation of Transitive closure.
*
* @param oldTableName
* @param newTableName
* @param whereExpression
* @param joinOnExpression
* @param kleeneDepth1
* @param kleeneDepth2
* @param kleeneType
* @param selectionPart
*/
public static void CreateQuery(String[] oldTableName, String newTableName, String whereExpression,
ArrayList<String> joinOnExpression, int kleeneDepth1, int kleeneDepth2, String kleeneType,
String[] selectionPart) {
DataFrame resultFrame = null;
SQLContext sqlContext = AppSpark.sqlContext;
int numberOfLines = -1;
KleeneFixed.CreateQuery(oldTableName, newTableName, whereExpression, joinOnExpression, 0, 3, kleeneType,
selectionPart);
String insertTmp = KleeneFixed.baseQuery;
resultFrame = sqlContext.sql(insertTmp);
resultFrame.registerTempTable("temp1");
KleeneFixed.CreateQuery(oldTableName, newTableName, whereExpression, joinOnExpression, 4, -1, kleeneType,
selectionPart);
String minusOperation = "SELECT DISTINCT t.subject, t.predicate, t.object FROM (" + KleeneFixed.baseQuery
+ ") t"
+ " LEFT JOIN temp1 ON t.subject = temp1.subject AND t.predicate = temp1.predicate AND t.object = "
+ " temp1.object WHERE temp1.predicate IS NULL ";
baseQuery = baseQuery + minusOperation + "\n";
resultFrame = sqlContext.sql(minusOperation);
resultFrame.registerTempTable("temp2");
String resultsChecking = "SELECT COUNT(*) AS count FROM temp2";
resultFrame = sqlContext.sql(resultsChecking);
Row[] results = resultFrame.collect();
numberOfLines = (int) results[0].getLong(0);
baseQuery = baseQuery + resultsChecking + "\n";
System.out.println("# of new lines " + numberOfLines);
if (numberOfLines != 0) {
KleeneSemiNaiveSPARK.CreateQuery(oldTableName, newTableName, joinOnExpression, kleeneType, selectionPart,
kleeneDepth1, "temp2");
} else {
resultFrame = sqlContext.sql("SELECT subject, predicate, object FROM temp1");
QueryStruct.fillStructure(oldTableName, newTableName, baseQuery, "none", "none");
ResultStruct.fillStructureSpark(resultFrame);
}
}