当前位置: 首页>>代码示例>>Java>>正文


Java DataFrame.except方法代码示例

本文整理汇总了Java中org.apache.spark.sql.DataFrame.except方法的典型用法代码示例。如果您正苦于以下问题:Java DataFrame.except方法的具体用法?Java DataFrame.except怎么用?Java DataFrame.except使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.spark.sql.DataFrame的用法示例。


在下文中一共展示了DataFrame.except方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: savePropertiesIntoTable

import org.apache.spark.sql.DataFrame; //导入方法依赖的package包/类
/**
 * Create "properties" table. See:
 * {@link ComplexPropertyTableLoader#tablename_properties}.
 */
public void savePropertiesIntoTable() {
	// return rows of format <predicate, is_complex>
	// is_complex can be 1 or 0
	// 1 for multivalued predicate, 0 for single predicate

	// select the properties that are complex
	DataFrame multivaluedProperties = this.hiveContext.sql(String.format(
			"SELECT DISTINCT(%1$s) AS %1$s FROM (SELECT %2$s, %1$s, COUNT(*) AS rc FROM %3$s GROUP BY %2$s, %1$s HAVING rc > 1) AS grouped",
			column_name_predicate, column_name_subject, tablename_triple_table));

	// select all the properties
	DataFrame allProperties = this.hiveContext.sql(String.format("SELECT DISTINCT(%1$s) AS %1$s FROM %2$s",
			column_name_predicate, tablename_triple_table));

	// select the properties that are not complex
	DataFrame singledValueProperties = allProperties.except(multivaluedProperties);

	// combine them
	DataFrame combinedProperties = singledValueProperties
			.selectExpr(column_name_predicate, "0 AS " + column_name_is_complex)
			.unionAll(multivaluedProperties.selectExpr(column_name_predicate, "1 AS " + column_name_is_complex));
	
	// remove '<' and '>', convert the characters
	DataFrame cleanedProperties = combinedProperties.withColumn("p", functions.regexp_replace(functions.translate(combinedProperties.col("p"), "<>", ""), 
			"[[^\\w]+]", "_"));
	
	// write the result
	cleanedProperties.write().mode(SaveMode.Overwrite).saveAsTable(tablename_properties);
}
 
开发者ID:aschaetzle,项目名称:Sempala,代码行数:34,代码来源:ComplexPropertyTableLoader.java


注:本文中的org.apache.spark.sql.DataFrame.except方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。