本文整理匯總了Java中org.apache.spark.sql.Row.getAs方法的典型用法代碼示例。如果您正苦於以下問題:Java Row.getAs方法的具體用法?Java Row.getAs怎麽用?Java Row.getAs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.spark.sql.Row
的用法示例。
在下文中一共展示了Row.getAs方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLastName
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
public static String getLastName( Row row ) {
String name = row.getAs( "Defendant Name" );
if ( StringUtils.isBlank( name ) ) {
return null;
}
List<String> names = nameSplitter.splitToList( name );
Preconditions.checkState( names.size() > 0, "Must have at least some parts of name" );
if ( name.contains( " Jr" ) || name.contains( " JR" ) ) {
return names.get( 0 ).trim().replace( ",", "" ) + " Jr";
}
if ( name.contains( " Sr" ) || name.contains( " SR" ) ) {
return names.get( 0 ).trim().replace( ",", "" ) + " Sr";
}
return names.get( 0 ).replace( ",", "" );
}
示例2: getSubjectIdentification
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
public static String getSubjectIdentification( Row row ) {
String name = row.getAs( "Defendant Name" );
String gender = row.getAs( "Gender" );
String race = row.getAs( "Race" );
String dob = row.getAs( "DOB" );
StringBuilder sb = new StringBuilder();
sb
.append( encoder.encodeToString( StringUtils.getBytesUtf8( name ) ) )
.append( "|" )
.append( encoder.encodeToString( StringUtils.getBytesUtf8( gender ) ) )
.append( "|" )
.append( encoder.encodeToString( StringUtils.getBytesUtf8( race ) ) )
.append( "|" )
.append( encoder.encodeToString( StringUtils.getBytesUtf8( dob ) ) );
return sb.toString();
}
示例3: getLat
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
public static double getLat( Row row ) {
String location = row.getAs( "LOCATION" );
if ( StringUtils.isBlank( location ) ) {
return 0D;
}
Matcher m = p.matcher( location );
m.matches();
if ( !m.matches() ) {
return 0D;
}
return Double.parseDouble( m.group( 1 ) );
}
示例4: safeOffenseDateParse
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
public static String safeOffenseDateParse(Row row) {
String OffDate = row.getAs("IncidentDate");
return bdHelper.parse(OffDate);
}
示例5: getLastName
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
public static String getLastName( Row row ) {
String name = row.getAs( "NAME" );
if ( StringUtils.isBlank( name ) ) {
return null;
}
Matcher m = p.matcher( name );
if ( !m.matches() ) {
return null;
}
return (String) m.group( 1 );
}
示例6: safeParse
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
public static String safeParse( Row row ) {
String date = row.getAs( "Date" );
String time = row.getAs( "Time" );
if ( StringUtils.endsWith( date, "/10" ) ) {
date = "2010";
}
if ( StringUtils.endsWith( date, "/11" ) ) {
date = "2011";
}
if ( StringUtils.endsWith( date, "/12" ) ) {
date = "2012";
}
if ( StringUtils.endsWith( date, "/13" ) ) {
date = "2013";
}
if ( StringUtils.endsWith( date, "/14" ) ) {
date = "2014";
}
if ( StringUtils.endsWith( date, "/15" ) ) {
date = "2015";
}
if ( StringUtils.endsWith( date, "/16" ) ) {
date = "2016";
}
if ( StringUtils.endsWith( date, "/17" ) ) {
date = "2017";
}
if ( date.contains( "#" ) || time.contains( "#" ) ) {
return null;
}
return dtHelper.parse( date + " " + time );
}
示例7: getLon
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
public static double getLon( Row row ) {
String location = row.getAs( "LOCATION" );
if ( StringUtils.isBlank( location ) ) {
return 0D;
}
Matcher m = p.matcher( location );
if ( !m.matches() ) {
return 0D;
}
return Double.parseDouble( m.group( 2 ) );
}
示例8: safeDOBParse
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
public static String safeDOBParse( Row row ) {
String dob = row.getAs( "DOB" );
if ( dob == null ) {
return null;
}
if ( dob.contains( "#" ) ) {
return null;
}
return bdHelper.parse( row.getAs( "DOB" ) );
}
示例9: getFirstName
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
public static String getFirstName( Row row ) {
String name = row.getAs( "NAME" );
if ( StringUtils.isBlank( name ) ) {
return null;
}
Matcher m = p.matcher( name );
if ( !m.matches() ) {
return null;
}
return (String) m.group( 2 );
}
示例10: getFirstName
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
public static String getFirstName( Row row ) {
String name = row.getAs( "Defendant Name" );
List<String> names = nameSplitter.splitToList( name );
Preconditions.checkState( names.size() > 0, "Must have at least some parts of name" );
return names.get( 0 ) + " " + names.get( 1 );
}
示例11: getSubjectIdentification
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
public static String getSubjectIdentification( Row row ) {
return row.getAs( "Agency" ) + "-" + row.getAs( "SuspectUniqueIDforyourAgency" );
}
示例12: getLastName
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
public static String getLastName( Row row ) {
String name = row.getAs( "Defendant Name" );
List<String> names = nameSplitter.splitToList( name );
Preconditions.checkState( names.size() > 0, "Must have at least some parts of name" );
return names.get( names.size() - 1 );
}
示例13: getArrestSequenceID
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
public static String getArrestSequenceID( Row row ) {
return row.getAs( "Agency" ) + "-" + row.getAs( "ArrestorCitationNumber" );
}
示例14: start
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
private void start() {
Dataset<Row> householdDf = getHouseholdDataframe();
Dataset<Row> populationDf = getPopulationDataframe();
Dataset<Row> indexDf = joinHouseholdPopulation(householdDf, populationDf);
Dataset<Row> salesDf = getSalesData();
Dataset<Row> salesIndexDf = salesDf
.join(indexDf, salesDf.col("zipcode").equalTo(indexDf.col("zipcode")), "left")
.drop(indexDf.col("zipcode"));
salesIndexDf = salesIndexDf.withColumn("revenue_by_inh", salesIndexDf.col("revenue")
.divide(salesIndexDf.col("pop")));
salesIndexDf = salesIndexDf.orderBy(col("revenue_by_inh").desc());
Row bestRow = salesIndexDf.first();
double bestRevenuePerInhabitant = ((BigDecimal) bestRow.getAs("revenue_by_inh"))
.doubleValue();
int populationOfBestRevenuePerInhabitant = bestRow.getAs("pop");
double incomeOfBestRevenuePerInhabitant = bestRow.getAs("income_per_inh");
salesIndexDf = salesIndexDf.withColumn(
"best_revenue_per_inh",
salesIndexDf.col("pop").divide(salesIndexDf.col("pop"))
.multiply(bestRevenuePerInhabitant));
salesIndexDf = salesIndexDf.withColumn(
"pop_of_best",
lit(populationOfBestRevenuePerInhabitant));
salesIndexDf = salesIndexDf.withColumn(
"income_of_best",
lit(incomeOfBestRevenuePerInhabitant));
salesIndexDf = salesIndexDf.withColumn(
"idx_revenue",
salesIndexDf.col("best_revenue_per_inh")
.divide(salesIndexDf.col("revenue_by_inh")));
salesIndexDf = salesIndexDf.withColumn(
"idx_pop",
salesIndexDf.col("pop").divide(salesIndexDf.col("pop_of_best")));
salesIndexDf = salesIndexDf.withColumn(
"idx_income",
salesIndexDf.col("income_per_inh").divide(salesIndexDf.col("income_of_best")));
salesIndexDf = salesIndexDf.withColumn(
"index",
salesIndexDf.col("idx_revenue").multiply(salesIndexDf.col("idx_pop")
.multiply(salesIndexDf.col("idx_income"))));
salesIndexDf = salesIndexDf.withColumn(
"potential_revenue",
salesIndexDf.col("revenue").multiply(salesIndexDf.col("index")));
salesIndexDf = salesIndexDf
.drop("idx_income")
.drop("idx_pop")
.drop("idx_revenue")
.drop("income_of_best")
.drop("total_income")
.drop("revenue_by_inh")
.drop("pop_of_best")
.drop("best_revenue_per_inh")
.orderBy(salesIndexDf.col("potential_revenue").desc());
salesIndexDf.show();
}
示例15: getSubjectIdentification
import org.apache.spark.sql.Row; //導入方法依賴的package包/類
public static String getSubjectIdentification(Row row) {
return "PERSON-" + row.getAs("SubjectIdentification");
}