carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jackylk <...@git.apache.org>
Subject [GitHub] incubator-carbondata pull request #765: [CARBONDATA-887]lazy rdd iterator fo...
Date Sun, 09 Apr 2017 03:08:27 GMT
Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/765#discussion_r110531875
  
    --- Diff: integration/spark-common/src/main/scala/org/apache/carbondata/spark/rdd/NewCarbonDataLoadRDD.scala
---
    @@ -504,3 +500,66 @@ class NewRddIterator(rddIter: Iterator[Row],
       }
     
     }
    +
    +/**
    + * LazyRddIterator invoke rdd.iterator method when invoking hasNext method.
    + * @param serializer
    + * @param serializeBytes
    + * @param partition
    + * @param carbonLoadModel
    + * @param context
    + */
    +class LazyRddIterator(serializer: SerializerInstance,
    +    serializeBytes: Array[Byte],
    +    partition: Partition,
    +    carbonLoadModel: CarbonLoadModel,
    +    context: TaskContext) extends CarbonIterator[Array[AnyRef]] {
    +
    +  val timeStampformatString = CarbonProperties.getInstance().getProperty(CarbonCommonConstants
    +    .CARBON_TIMESTAMP_FORMAT, CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT)
    +  val timeStampFormat = new SimpleDateFormat(timeStampformatString)
    +  val dateFormatString = CarbonProperties.getInstance().getProperty(CarbonCommonConstants
    +    .CARBON_DATE_FORMAT, CarbonCommonConstants.CARBON_DATE_DEFAULT_FORMAT)
    +  val dateFormat = new SimpleDateFormat(dateFormatString)
    +  val delimiterLevel1 = carbonLoadModel.getComplexDelimiterLevel1
    +  val delimiterLevel2 = carbonLoadModel.getComplexDelimiterLevel2
    +  val serializationNullFormat =
    +    carbonLoadModel.getSerializationNullFormat.split(CarbonCommonConstants.COMMA, 2)(1)
    +
    +  var rddIter: Iterator[Row] = null
    +  var uninitialized = true
    +  var closed = false
    +
    +  def hasNext: Boolean = {
    +    if (uninitialized) {
    +      uninitialized = false
    +      rddIter = serializer.deserialize[RDD[Row]](ByteBuffer.wrap(serializeBytes))
    +        .iterator(partition, context)
    +    }
    +    if (closed) {
    +      false
    +    } else {
    +      rddIter.hasNext
    +    }
    +  }
    +
    +  def next: Array[AnyRef] = {
    +    val row = rddIter.next()
    +    val columns = new Array[AnyRef](row.length)
    +    for (i <- 0 until columns.length) {
    +      columns(i) = CarbonScalaUtil.getString(row.get(i), serializationNullFormat,
    +        delimiterLevel1, delimiterLevel2, timeStampFormat, dateFormat)
    +    }
    +    columns
    +  }
    +
    +  override def initialize: Unit = {
    --- End diff --
    
    add empty parentheses, for scala coding convention


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message