如何从Java中调用DataFrameFunctions.createCassandraTable?

cnwbcb6i  于 2022-11-23  发布在  Cassandra
关注(0)|答案(1)|浏览(114)

我如何从Java中调用这个函数?或者我需要一个scala的 Package 器吗?

package com.datastax.spark.connector

class DataFrameFunctions(dataFrame: DataFrame) extends Serializable {
...    
  def createCassandraTable(
    keyspaceName: String,
    tableName: String,
    partitionKeyColumns: Option[Seq[String]] = None,
    clusteringKeyColumns: Option[Seq[String]] = None)(
  implicit
    connector: CassandraConnector = CassandraConnector(sparkContext.getConf)): Unit = {
...
x9ybnkn6

x9ybnkn61#

我使用了以下代码:

DataFrameFunctions frameFunctions = new DataFrameFunctions(dfTemp2);
Seq<String> argumentsSeq1 = JavaConversions.asScalaBuffer(Arrays.asList("CategoryName")).seq();     
Option<Seq<String>> some1 = new Some<Seq<String>>(argumentsSeq1);       
Seq<String> argumentsSeq2 = JavaConversions.asScalaBuffer(Arrays.asList("DealType")).seq();         
Option<Seq<String>> some2 = new Some<Seq<String>>(argumentsSeq2);                                                               
frameFunctions.createCassandraTable("coupons", "IdealFeeds", some1, some2, connector);

相关问题