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


Java Row.getAs方法代码示例

本文整理汇总了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( ",", "" );
}
 
开发者ID:dataloom,项目名称:integrations,代码行数:19,代码来源:CaseChargesWithDispo2010.java

示例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();
}
 
开发者ID:dataloom,项目名称:integrations,代码行数:18,代码来源:ClerkOfCourtsCharges2010.java

示例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 ) );
}
 
开发者ID:dataloom,项目名称:integrations,代码行数:13,代码来源:SlcStolenCars.java

示例4: safeOffenseDateParse

import org.apache.spark.sql.Row; //导入方法依赖的package包/类
public static String safeOffenseDateParse(Row row) {
    String OffDate = row.getAs("IncidentDate");
    return bdHelper.parse(OffDate);
}
 
开发者ID:dataloom,项目名称:integrations,代码行数:5,代码来源:DemoDataHealth.java

示例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 );
}
 
开发者ID:dataloom,项目名称:integrations,代码行数:12,代码来源:IowaCityCallsForService.java

示例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 );
}
 
开发者ID:dataloom,项目名称:integrations,代码行数:34,代码来源:MadisonPoliceDept.java

示例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 ) );
}
 
开发者ID:dataloom,项目名称:integrations,代码行数:12,代码来源:SlcStolenCars.java

示例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" ) );
}
 
开发者ID:dataloom,项目名称:integrations,代码行数:11,代码来源:MadisonPoliceDept.java

示例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 );
}
 
开发者ID:dataloom,项目名称:integrations,代码行数:12,代码来源:IowaCityCallsForService.java

示例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 );
}
 
开发者ID:dataloom,项目名称:integrations,代码行数:7,代码来源:ClerkOfCourtsCharges2010.java

示例11: getSubjectIdentification

import org.apache.spark.sql.Row; //导入方法依赖的package包/类
public static String getSubjectIdentification( Row row ) {
    return row.getAs( "Agency" ) + "-" + row.getAs( "SuspectUniqueIDforyourAgency" );
}
 
开发者ID:dataloom,项目名称:integrations,代码行数:4,代码来源:VeronaPoliceDept.java

示例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 );
}
 
开发者ID:dataloom,项目名称:integrations,代码行数:7,代码来源:ClerkOfCourtsCharges2010.java

示例13: getArrestSequenceID

import org.apache.spark.sql.Row; //导入方法依赖的package包/类
public static String getArrestSequenceID( Row row ) {
    return row.getAs( "Agency" ) + "-" + row.getAs( "ArrestorCitationNumber" );
}
 
开发者ID:dataloom,项目名称:integrations,代码行数:4,代码来源:VeronaPoliceDept.java

示例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();
}
 
开发者ID:jgperrin,项目名称:net.jgp.labs.informix2spark,代码行数:57,代码来源:SalesTargetApp.java

示例15: getSubjectIdentification

import org.apache.spark.sql.Row; //导入方法依赖的package包/类
public static String getSubjectIdentification(Row row) {

        return "PERSON-" + row.getAs("SubjectIdentification");
    }
 
开发者ID:dataloom,项目名称:integrations,代码行数:5,代码来源:DemoDataHealth.java


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