[GitHub] incubator-carbondata pull request #765: [CARBONDATA-887]lazy rdd iterator fo...

2017-04-11 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/incubator-carbondata/pull/765


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-carbondata pull request #765: [CARBONDATA-887]lazy rdd iterator fo...

2017-04-10 Thread QiangCai
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-carbondata pull request #765: [CARBONDATA-887]lazy rdd iterator fo...

2017-04-10 Thread QiangCai
Github user QiangCai commented on a diff in the pull request:


https://github.com/apache/incubator-carbondata/pull/765#discussion_r110675205
  
--- 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 --

ok


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-carbondata pull request #765: [CARBONDATA-887]lazy rdd iterator fo...

2017-04-10 Thread QiangCai
Github user QiangCai commented on a diff in the pull request:


https://github.com/apache/incubator-carbondata/pull/765#discussion_r110675213
  
--- 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 =
--- End diff --

ok


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-carbondata pull request #765: [CARBONDATA-887]lazy rdd iterator fo...

2017-04-08 Thread jackylk
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-carbondata pull request #765: [CARBONDATA-887]lazy rdd iterator fo...

2017-04-08 Thread jackylk
Github user jackylk commented on a diff in the pull request:


https://github.com/apache/incubator-carbondata/pull/765#discussion_r110531816
  
--- 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 --

use `row.map` to replace this for statement


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-carbondata pull request #765: [CARBONDATA-887]lazy rdd iterator fo...

2017-04-08 Thread jackylk
Github user jackylk commented on a diff in the pull request:


https://github.com/apache/incubator-carbondata/pull/765#discussion_r110531763
  
--- 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 =
--- End diff --

make all these variables private


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-carbondata pull request #765: [CARBONDATA-887]lazy rdd iterator fo...

2017-04-07 Thread QiangCai
GitHub user QiangCai opened a pull request:

https://github.com/apache/incubator-carbondata/pull/765

[CARBONDATA-887]lazy rdd iterator for InsertInto

Previously we also called the rdd.iterator method for all partitions, and 
released the resources after all partitions were executed.
Now we call rdd.iterator method one by one, and release the resource 
immediately after each partition is executed.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/QiangCai/incubator-carbondata rdddeserialize

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-carbondata/pull/765.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #765


commit 0d4a720d4f4157c8eab7a965f3dec224266fecdb
Author: QiangCai 
Date:   2017-04-07T14:08:19Z

lazy rdd iterator




---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---