Indhumathi27 commented on a change in pull request #4219:
URL: https://github.com/apache/carbondata/pull/4219#discussion_r711931261
##########
File path:
integration/spark/src/main/scala/org/apache/carbondata/indexserver/DistributedRDDUtils.scala
##########
@@ -313,31 +340,34 @@ object DistributedRDDUtils {
case None => throw new RuntimeException("Could not find any alive
executors.")
}
}
- val existingExecutorMapping = executorToCacheSizeMapping.get(newHost)
- if (existingExecutorMapping != null) {
- val existingSize = existingExecutorMapping.get(newExecutor)
- if (existingSize != null) {
- existingExecutorMapping.put(newExecutor, existingSize +
segment.getIndexSize
- .toInt)
- } else {
- existingExecutorMapping.put(newExecutor, segment.getIndexSize
- .toInt)
- }
+ tableToExecutorMapping.putIfAbsent(tableUniqueName, new
ConcurrentHashMap[String, String]())
+ val existingSegmentMapping = tableToExecutorMapping.get(tableUniqueName)
+ val oldMapping = existingSegmentMapping.putIfAbsent(segment.getSegmentNo,
+ s"${ newHost }_$newExecutor")
+ if (oldMapping == null) {
+ updateCacheSize(newHost, newExecutor, segment)
+ s"executor_${newHost}_$newExecutor"
} else {
- val newExecutorMapping = new ConcurrentHashMap[String, Long]()
- newExecutorMapping.put(newExecutor, segment.getIndexSize)
- executorToCacheSizeMapping.put(newHost, newExecutorMapping)
+ s"executor_$oldMapping"
}
- val existingSegmentMapping = tableToExecutorMapping.get(tableUniqueName)
- if (existingSegmentMapping == null) {
- val newSegmentMapping = new ConcurrentHashMap[String, String]()
- newSegmentMapping.put(segment.getSegmentNo, s"${newHost}_$newExecutor")
- tableToExecutorMapping.putIfAbsent(tableUniqueName, newSegmentMapping)
+ }
+ }
+
+ private def updateCacheSize(host: String, executor: String, segment:
Segment) = {
+ val existingExecutorMapping = executorToCacheSizeMapping.get(host)
+ if (existingExecutorMapping != null) {
+ val existingSize = existingExecutorMapping.get(executor)
+ if (existingSize != null) {
+ existingExecutorMapping.put(executor, existingSize +
segment.getIndexSize
Review comment:
can get size based on existing size and can move common code
"existingExecutorMapping.put(executor, size)" down
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]