marchpure commented on a change in pull request #4043:
URL: https://github.com/apache/carbondata/pull/4043#discussion_r537066618



##########
File path: 
core/src/main/java/org/apache/carbondata/core/mutate/CarbonUpdateUtil.java
##########
@@ -341,8 +341,11 @@ public static boolean 
updateTableMetadataStatus(Set<String> updatedSegmentsList,
                   // this means for first time it is getting updated .
                   loadMetadata.setUpdateDeltaStartTimestamp(updatedTimeStamp);
                 }
-                // update end timestamp for each time.
+                // update delta end timestamp for each time.
                 loadMetadata.setUpdateDeltaEndTimestamp(updatedTimeStamp);
+                // record end timestamp of operation each time
+                long operationEndTimestamp = System.currentTimeMillis();
+                
loadMetadata.setLatestUpdateEndTimestamp(String.valueOf(operationEndTimestamp));

Review comment:
       take care about format

##########
File path: 
integration/spark/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala
##########
@@ -334,6 +334,8 @@ object CarbonDataRDDFactory {
     val segmentLock = 
CarbonLockFactory.getCarbonLockObj(carbonTable.getAbsoluteTableIdentifier,
       CarbonTablePath.addSegmentPrefix(carbonLoadModel.getSegmentId) + 
LockUsage.LOCK)
 
+    mockForConcurrentTest()

Review comment:
       remove it

##########
File path: 
core/src/main/java/org/apache/carbondata/core/statusmanager/LoadMetadataDetails.java
##########
@@ -453,6 +456,14 @@ public void setExtraInfo(String extraInfo) {
     this.extraInfo = extraInfo;
   }
 
+  public String getLatestUpdateEndTimestamp() {
+    return latestUpdateEndTimestamp;
+  }
+
+  public void setLatestUpdateEndTimestamp(String latestUpdateEndTimestamp) {

Review comment:
       don't add parameters in tablestatus.

##########
File path: 
integration/spark/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala
##########
@@ -607,6 +609,14 @@ object CarbonDataRDDFactory {
     }
   }
 
+  def mockForConcurrentTest(): Unit = {

Review comment:
       remove it.

##########
File path: 
integration/spark/src/main/scala/org/apache/spark/sql/execution/command/mutation/CarbonProjectForDeleteCommand.scala
##########
@@ -25,9 +25,11 @@ import org.apache.spark.sql._
 import org.apache.spark.sql.catalyst.expressions.{Attribute, 
AttributeReference}
 import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
 import org.apache.spark.sql.execution.command._
+import 
org.apache.spark.sql.execution.command.mutation.transaction.{TransactionManager,
 TransactionType}
 import org.apache.spark.sql.types.LongType
 
 import org.apache.carbondata.common.logging.LogServiceFactory
+import org.apache.carbondata.core.exception.ConcurrentOperationException

Review comment:
       just use exception. don't use ConcurrentOperationException

##########
File path: 
integration/spark/src/main/scala/org/apache/spark/sql/execution/command/mutation/CarbonProjectForUpdateCommand.scala
##########
@@ -113,8 +116,14 @@ case class CarbonProjectForUpdateCommand(
       updatedRowCount = updatedRowCountTmp
       if (updatedRowCount == 0) return Seq(Row(0L))
 
+      if (IUDCommonUtil.isTest()) {

Review comment:
       remove it.

##########
File path: 
integration/spark/src/main/scala/org/apache/spark/sql/execution/command/mutation/IUDCommonUtil.scala
##########
@@ -268,4 +270,43 @@ object IUDCommonUtil {
       case _ =>
     }
   }
+
+  def checkIfSegmentsAlreadyUpdated(
+      carbonTable: CarbonTable,
+      startTimestamp: String,
+      updatedSegments: util.Set[String]): Boolean = {
+
+    val loadMetadataDetails = 
SegmentStatusManager.readLoadMetadata(carbonTable.getMetadataPath)
+    var isChanged = false
+    breakable {
+      loadMetadataDetails
+        .filter(load => updatedSegments.contains(load.getLoadName))
+        .foreach(load =>
+          if (load.getLatestUpdateEndTimestamp != null &&

Review comment:
       use getTransctionId(). don't use getLatestUpdateEndTimestamp.

##########
File path: 
integration/spark/src/main/scala/org/apache/spark/sql/execution/command/mutation/CarbonProjectForUpdateCommand.scala
##########
@@ -152,6 +161,9 @@ case class CarbonProjectForUpdateCommand(
       IndexStoreManager.getInstance()
         .clearInvalidSegments(carbonTable, 
deletedSegmentList.asScala.toList.asJava)
     } catch {
+      case e: ConcurrentOperationException =>

Review comment:
       use exception. remove ConcurrentOperationException 

##########
File path: 
integration/spark/src/main/scala/org/apache/spark/sql/execution/command/mutation/IUDCommonUtil.scala
##########
@@ -268,4 +270,43 @@ object IUDCommonUtil {
       case _ =>
     }
   }
+
+  def checkIfSegmentsAlreadyUpdated(
+      carbonTable: CarbonTable,
+      startTimestamp: String,
+      updatedSegments: util.Set[String]): Boolean = {
+
+    val loadMetadataDetails = 
SegmentStatusManager.readLoadMetadata(carbonTable.getMetadataPath)
+    var isChanged = false
+    breakable {
+      loadMetadataDetails
+        .filter(load => updatedSegments.contains(load.getLoadName))
+        .foreach(load =>
+          if (load.getLatestUpdateEndTimestamp != null &&
+            load.getLatestUpdateEndTimestamp.toLong > startTimestamp.toLong) {
+            isChanged = true
+            break()
+          }
+        )
+    }
+    isChanged
+  }
+
+  def mockForConcurrentTest(carbonTable: CarbonTable,

Review comment:
       remove it.

##########
File path: 
integration/spark/src/main/scala/org/apache/spark/sql/execution/command/mutation/transaction/TransactionManager.scala
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.command.mutation.transaction
+
+import org.apache.carbondata.core.metadata.schema.table.CarbonTable
+
+case class TransactionManager(carbonTable: CarbonTable) {
+
+  def beginTransaction(transactionType: TransactionType.Value): Transaction = {

Review comment:
       confused. only have beginTranscation. don't have commitTranscation

##########
File path: 
integration/spark/src/main/scala/org/apache/spark/sql/execution/command/mutation/transaction/TransactionType.scala
##########
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.command.mutation.transaction
+
+object TransactionType extends Enumeration {
+
+  val UPDATE = Value("Update")

Review comment:
       TransactionType is useful? 
   What's different with UpdateTranscation and DeleteTranscation?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to