carbondata-issues mailing list archives

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

    https://github.com/apache/incubator-carbondata/pull/765#discussion_r110675207
  
    --- 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) {
    --- End diff --
    
    need row.toseq.map, so better to keep it.


---
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