由于名称重复而在maven中编译scala代码时出现堆栈溢出

时间:2015-06-04 15:10:25

标签: scala maven stack-overflow

我需要对我的包中的类进行一些更改,但我不想放弃初始类。我复制类并将其粘贴到同一个项目中并更改所有函数和类的名称,但是当我尝试使用maven中的新类编译包时,我得到堆栈溢出异常。这是错误消息:

 [INFO]
 [INFO]   last tree to typer: TypeTree(class CustomerMiddleCombo)
 [INFO]               symbol: class CustomerMiddleCombo in package      churnstory (fl ags: )
 [INFO]    symbol definition: class CustomerMiddleCombo extends Serializable
 [INFO]                  tpe: com.cloudera.sa.bell.churnstory.CustomerMiddleCombo

 [INFO]        symbol owners: class CustomerMiddleCombo -> package churnstory
 [INFO]       context owners: method apply -> anonymous class $anonfun -> method generatedComboCountMore -> object ComboCounterJobM5 -> package churnstory
 [INFO]
 [INFO] == Enclosing template or block ==
 [INFO]
 [INFO] Apply( // val custId(): String in class UserAndSingleSeqCounts
 [INFO]   "r"."custId" // val custId(): String in class       UserAndSingleSeqCounts
 [INFO]   Nil
 [INFO] )
 [INFO]
 [INFO] == Expanded type of tree ==
 [INFO]
 [INFO] TypeRef(TypeSymbol(class CustomerMiddleCombo extends Serializable))
 [INFO]
 [ERROR] uncaught exception during compilation: java.lang.StackOverflowError
 [ERROR] error: java.lang.StackOverflowError

我认为在Scala包中有类或对象或者具有相同名称的函数应该存在问题,但是我已经更改了新类中的所有名称。如果我摆脱这个新类(没有任何新行)我可以编译包没有任何问题! 任何人都可以帮我解决这个问题吗?

这是抛出异常的代码部分:

comboCountsRDD.map(r => {
  val sortedOrderedCounts2 = r.origOrderedCounts.sortedCounts
  r.custId + "," + //CustID
    dateFormat.format(currentDate) + "," + //generated_record_dt
    dateFormat.format(new Date(r.timeOfRootEvent)) + "," + //z
    r.origOrderedCounts.seq + "," + //orig_order_seq
    r.origOrderedCounts.totalCount + "," + //orig_order_total_count
    convertMillisecondsToDays(r.origOrderedCounts.minTimeFromRootEvent) + "," + //orig_order_min_time_from_root
    convertMillisecondsToDays(r.origOrderedCounts.totalTimeFromRootEvent / r.origOrderedCounts.totalCount.toDouble) + "," + //orig_order_avg_time_from_root
    r.origOrderedCounts.countOfTimeFromRootEventWithInAWeek + "," + //orig_order_with_in_week_of_root
    r.origOrderedCounts.countOfTimeFromRootEventWithInAMonth + "," + //orig_order_with_in_month_of_root
    r.origOrderedCounts.countOfTimeFromRootEventWithInAQrt + "," + //orig_order_with_in_qrt_of_root
    convertMillisecondsToDays(r.origOrderedCounts.minTimeOverLifeOfSeq) + "," + //orig_order_min_seq_time
    convertMillisecondsToDays(r.origOrderedCounts.totalTimeOverLifeOfSeq / r.origOrderedCounts.totalCount.toDouble) + "," + //orig_order_avg_seq_time
    r.origOrderedCounts.countOfTimeOverLifeOfSeqWithInAWeek + "," + //orig_order_with_in_week_over_seq
    r.origOrderedCounts.countOfTimeOverLifeOfSeqWithInAMonth + "," + //orig_order_with_in_month_over_seq
    r.origOrderedCounts.countOfTimeOverLifeOfSeqWithInAQrt + "," + //orig_order_with_in_qrt_over_seq
    convertMillisecondsToDays(r.origOrderedCounts.minTimeFromNow) + "," + //orig_order_min_time_from_now
    convertMillisecondsToDays(r.origOrderedCounts.totalTimeFromNow / r.origOrderedCounts.totalCount.toDouble) + "," + //orig_order_avg_time_from_now
    r.origOrderedCounts.countOfTimeFromNowWithInAWeek + "," + //orig_order_with_in_week_of_now
    r.origOrderedCounts.countOfTimeFromNowWithInAMonth + "," + //orig_order_with_in_month_of_now
    r.origOrderedCounts.countOfTimeFromNowWithInAQrt+","+
    sortedOrderedCounts2.seq + "," + //sort_order_seq
    sortedOrderedCounts2.totalCount + "," + //sorted_order_total_count
    convertMillisecondsToDays(sortedOrderedCounts2.minTimeFromRootEvent) + "," + //sorted_order_min_time_from_root
    //convertMillisecondsToDays(sortedOrderedCounts2.totalTimeFromRootEvent / sortedOrderedCounts2.totalCount.toDouble) + "," + //sorted_order_avg_time_from_root-->exception
    sortedOrderedCounts2.countOfTimeFromRootEventWithInAWeek + "," + //sorted_order_with_in_week_of_root
    sortedOrderedCounts2.countOfTimeFromRootEventWithInAMonth + "," + //sorted_order_with_in_month_of_root
    sortedOrderedCounts2.countOfTimeFromRootEventWithInAQrt + "," + //sorted_order_with_in_qrt_of_root
    //convertMillisecondsToDays(sortedOrderedCounts2.minTimeOverLifeOfSeq) + "," + //sorted_order_min_seq_time-->exception
    //convertMillisecondsToDays(sortedOrderedCounts2.totalTimeOverLifeOfSeq / sortedOrderedCounts2.totalCount.toDouble) + "," + //sorted_order_avg_seq_time-->exception
    sortedOrderedCounts2.countOfTimeOverLifeOfSeqWithInAWeek + "," + //sorted_order_with_in_week_over_seq
    sortedOrderedCounts2.countOfTimeOverLifeOfSeqWithInAMonth + "," + //sorted_order_with_in_month_over_seq
    sortedOrderedCounts2.countOfTimeOverLifeOfSeqWithInAQrt + "," + //sorted_order_with_in_qrt_over_seq
    //convertMillisecondsToDays(sortedOrderedCounts2.minTimeFromNow) + ","  //sorted_order_min_time_from_now-->exception
    //convertMillisecondsToDays(sortedOrderedCounts2.totalTimeFromNow / sortedOrderedCounts2.totalCount.toDouble) + ","// + //sorted_order_avg_time_from_now -->exception
    //sortedOrderedCounts2.countOfTimeFromNowWithInAWeek + "," //+ //sorted_order_with_in_week_of_now-->exception
    //sortedOrderedCounts2.countOfTimeFromNowWithInAMonth + ","// + //sorted_order_with_in_month_of_now-->exception
    sortedOrderedCounts2.countOfTimeFromNowWithInAQrt //orig_order_with_in_qrt_of_now*/
}).saveAsTextFile(outputPath)

我逐行测试代码,我注释掉的行和最后的异常导致我出现问题。 comboCountsRDD类型是UserAndSingleSeqCounts:

  class UserAndSingleSeqCounts(val custId: String,val timeOfRootEvent: Long, val origOrderedCounts: TotalCountsAndSubCounts)      extends Serializable {}

和origOrderedCounts有一个嵌套结构:

      class TotalCountsAndSubCounts(var seq: String,
                            var totalCount: Long,
                            var minTimeFromRootEvent: Long,
                            var totalTimeFromRootEvent: Long,
                            var countOfTimeFromRootEventWithInAWeek: Int,
                            var countOfTimeFromRootEventWithInAMonth: Int,
                            var countOfTimeFromRootEventWithInAQrt: Int,
                            var minTimeOverLifeOfSeq: Long,
                            var totalTimeOverLifeOfSeq: Long,
                            var countOfTimeOverLifeOfSeqWithInAWeek: Int,
                            var countOfTimeOverLifeOfSeqWithInAMonth: Int,
                            var countOfTimeOverLifeOfSeqWithInAQrt: Int,
                            var minTimeFromNow: Long,
                            var totalTimeFromNow: Long,
                            var countOfTimeFromNowWithInAWeek: Int,
                            var countOfTimeFromNowWithInAMonth: Int,
                            var countOfTimeFromNowWithInAQrt: Int,
                            var countOfDifferentOrders: Int,
                            var sortedCounts: TotalCountsAndSubCounts) extends Serializable

我很困惑:为什么从sortedOrderedCounts2请求一些而不是所有属性会在编译时导致异常!

0 个答案:

没有答案