Jackie-Jiang commented on a change in pull request #7450:
URL: https://github.com/apache/pinot/pull/7450#discussion_r712426897



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/operator/combine/GroupByOrderByCombineOperator.java
##########
@@ -125,43 +123,44 @@ public String getOperatorName() {
    */
   @Override
   protected void processSegments(int threadIndex) {
-    try {
-      IntermediateResultsBlock intermediateResultsBlock =
-          (IntermediateResultsBlock) _operators.get(threadIndex).nextBlock();
-
-      _initLock.lock();
-      try {
-        if (_dataSchema == null) {
-          _dataSchema = intermediateResultsBlock.getDataSchema();
-          // NOTE: Use trimSize as resultSize on server size.
-          if (_trimThreshold >= MAX_TRIM_THRESHOLD) {
-            // special case of trim threshold where it is set to max value.
-            // there won't be any trimming during upsert in this case.
-            // thus we can avoid the overhead of read-lock and write-lock
-            // in the upsert method.
-            _indexedTable = new UnboundedConcurrentIndexedTable(_dataSchema, 
_queryContext, _trimSize);
-          } else {
-            _indexedTable =
-                new ConcurrentIndexedTable(_dataSchema, _queryContext, 
_trimSize, _trimSize, _trimThreshold);
+    for (int operatorIndex = threadIndex; operatorIndex < _numOperators; 
operatorIndex += _numThreads) {
+      IntermediateResultsBlock resultsBlock = (IntermediateResultsBlock) 
_operators.get(operatorIndex).nextBlock();
+
+      if (_indexedTable == null) {
+        _initLock.lock();
+        try {
+          if (_indexedTable == null) {

Review comment:
       Lock will enforce the memory synchronization, thus guarantee that the 
inner check getting the latest value. I don't think JVM can reorder the check 
and lock because of the memory barrier.
   More can be read here under the `Memory Synchronization` section: 
https://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/locks/Lock.html




-- 
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: commits-unsubscr...@pinot.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to