muttakin2301/ccr2000 huggingface dataset:
Code review comment: Since you added this, you should probably remove the previous statement.

Code under review:
public void testFastJarFormatWorks() throws Exception {

        final File projectDir = getProjectDir("test-that-fast-jar-format-works");

        runGradleWrapper(projectDir, "clean", "build");

        final Path quarkusApp = projectDir.toPath().resolve("build").resolve("quarkus-app");
        assertThat(quarkusApp).exists();
        Path jar = quarkusApp.resolve("quarkus-run.jar");
        assertThat(jar).exists();

        File output = new File(projectDir, "build/output.log");
        output.createNewFile();
        Process process = launch(jar, output);
        try {
            
            dumpFileContentOnFailure(() -> {
                await()
                        .pollDelay(1, TimeUnit.SECONDS)
                        .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/hello", 200));
                return null;
            }, output, ConditionTimeoutException.class);

            String logs = FileUtils.readFileToString(output, "UTF-8");

            assertThatOutputWorksCorrectly(logs);
            

            getHttpResponse("/hello");
            assertThat(getHttpResponse("/hello").equals("hello"));
        } finally {
            process.destroy();
        }
    }

Line commented on: getHttpResponse("/hello");

Revised code:
public void testFastJarFormatWorks() throws Exception {

        final File projectDir = getProjectDir("test-that-fast-jar-format-works");

        runGradleWrapper(projectDir, "clean", "build");

        final Path quarkusApp = projectDir.toPath().resolve("build").resolve("quarkus-app");
        assertThat(quarkusApp).exists();
        Path jar = quarkusApp.resolve("quarkus-run.jar");
        assertThat(jar).exists();

        File output = new File(projectDir, "build/output.log");
        output.createNewFile();
        Process process = launch(jar, output);
        try {
            
            dumpFileContentOnFailure(() -> {
                await()
                        .pollDelay(1, TimeUnit.SECONDS)
                        .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/hello", 200));
                return null;
            }, output, ConditionTimeoutException.class);

            String logs = FileUtils.readFileToString(output, "UTF-8");

            assertThatOutputWorksCorrectly(logs);

            
            assertThat(DevModeTestUtils.getHttpResponse("/hello", getQuarkusDevBrokenReason()).equals("hello"));
        } finally {
            process.destroy();
        }
    }
Code review comment: Well, we usually don't do fancy things like that in other extensions and TBH I'm not sure I like it.  The contract we have for dev mode was: let's restart your Quarkus fully. And if we begin having all sorts of edge cases like that, I'm not sure it won't be a Pandora box of future bugs.

Code under review:
void initialize(Vertx vertx, MailConfig config) {
        if (client != null && config.equals(MailConfigRecorder.config)) {
            
            return;
        }

        this.close();
        MailConfigRecorder.config = config;
        io.vertx.ext.mail.MailConfig cfg = toVertxMailConfig(config);
        client = MailClient.createNonShared(vertx, cfg);
    }

Line commented on: if (client != null && config.equals(MailConfigRecorder.config)) {

Revised code:
void initialize(Vertx vertx, MailConfig config) {
        io.vertx.ext.mail.MailConfig cfg = toVertxMailConfig(config);
        client = MailClient.createNonShared(vertx, cfg);
    }
Code review comment: Shouldn't this be instead ``` if (!canceled) {    LOG.error("Received CancelTaskException while we are not canceled. This is a bug and should be reported", e); } ``` ?   I would prefer the cancellation mechanism to stay clean and `canceled` being set to `true` only in one place, without using exceptions for that.

Code under review:
private void runMailboxLoop() throws Exception {
		try {
			try {
				mailboxProcessor.runMailboxLoop();
			}
			catch (WrappingRuntimeException wrappingException) {
				Throwable unwrapped = wrappingException.unwrap();
				if (unwrapped instanceof Exception) {
					throw (Exception) unwrapped;
				}
				else {
					throw wrappingException;
				}
			}
		}
		catch (InterruptedException e) {
			if (!canceled) {
				Thread.currentThread().interrupt();
				throw e;
			}
		}
		catch (CancelTaskException e) {
			
			
			canceled = true;
		}
		catch (Exception e) {
			if (canceled) {
				LOG.warn("Error while canceling task.", e);
			}
			else {
				throw e;
			}
		}
	}

Line commented on: canceled = true;

Revised code:
private void runMailboxLoop() throws Exception {
		try {
			try {
				mailboxProcessor.runMailboxLoop();
			}
			catch (WrappingRuntimeException wrappingException) {
				Throwable unwrapped = wrappingException.unwrap();
				if (unwrapped instanceof Exception) {
					throw (Exception) unwrapped;
				}
				else {
					throw wrappingException;
				}
			}
		}
		catch (InterruptedException e) {
			if (!canceled) {
				Thread.currentThread().interrupt();
				throw e;
			}
		}
		catch (CancelTaskException e) {
			if (!canceled) {
				LOG.error("Received CancelTaskException while we are not canceled. This is a bug and should be reported", e);
			}
		}
		catch (Exception e) {
			if (canceled) {
				LOG.warn("Error while canceling task.", e);
			}
			else {
				throw e;
			}
		}
	}
Code review comment: Thanks for pointing this. We're going to add it to our feature improvement list.

Code under review:
public void processElement(ProcessContext context) {
      List<Object> csvItems = new ArrayList<>();
      for (Object o : context.element()) {
        if (o instanceof String) {
          String field = (String) o;
          field = field.replace("'", "''");
          field = quoteField(field);

          csvItems.add(field);
        } else {
          csvItems.add(o);
        }
      }
      context.output(Joiner.on(",").useForNull("").join(csvItems));
    }

Line commented on: context.output(Joiner.on(",").useForNull("").join(csvItems));

Revised code:
public void processElement(ProcessContext context) throws Exception {

        SnowflakeServiceConfig config =
            new SnowflakeServiceConfig(
                dataSourceProviderFn, table, query, storageIntegrationName, stagingBucketDir);

        String output = snowflakeService.read(config);

        context.output(output);
      }
Code review comment: Might be pedantic but I would re-order these checks to start with length validation followed by `startsWith` validation, finishing with SHA validation, as this is the order of which is cheapest to validate.

Code under review:
public static void validateDigest(MessageDigest messageDigest, String requestedDigest) {
        String sha256 = byteArrayToHex(messageDigest.digest());
        if (!requestedDigest.endsWith(sha256)
            || !requestedDigest.startsWith("sha256:")
            || requestedDigest.length() != 71) {
            throw LOGGER.atError()
                .addKeyValue("requestedDigest", requestedDigest)
                .addKeyValue("actualDigest", () -> "sha256:" + sha256)
                .log(new ServiceResponseException("The digest in the response does not match the expected digest."));
        }
    }

Line commented on: || requestedDigest.length() != 71) {

Revised code:
public static void validateDigest(MessageDigest messageDigest, String requestedDigest) {
        String sha256 = byteArrayToHex(messageDigest.digest());
        if (requestedDigest.length() != 71
            || !requestedDigest.startsWith("sha256:")
            || !requestedDigest.endsWith(sha256)) {
            throw LOGGER.atError()
                .addKeyValue("requestedDigest", requestedDigest)
                .addKeyValue("actualDigest", () -> "sha256:" + sha256)
                .log(new ServiceResponseException("The digest in the response does not match the expected digest."));
        }
    }
Code review comment: Not quite confirm the performance optimization issue.  From the precise aspect, my previous way was trying to maintain the old behavior which only judges the current input status except for the end status. I think all these ways would bring bad cases.  E.g. if current status is equal to `MORE_AVAILABLE` but the next selection is the other input which is actually `NOTHING_AVAILABLE`, then after calling `processInput` again it would actually return -1 while `selectNextReadingInputIndex()` to waste processing time.  Before introducing `InputStatus` it could also return precise status if maintaining both last input states as the way I did (`firstInputStatus`, `secondInputStatus`) in this PR. If we want to do that we need also consider three factors together (`firstInputStatus`, `secondInputStatus` and next selected input) to determine the final precise status for `StreamTask`.  If doing so, the above `selectNextReadingInputIndex` could only return -1 for the first calling `processInput`, and we could also refactor that part together.

Code under review:
public InputStatus processInput() throws Exception {
		
		
		prepareForProcessing();

		int readingInputIndex = selectNextReadingInputIndex();
		if (readingInputIndex == -1) {
			return InputStatus.NOTHING_AVAILABLE;
		}
		lastReadInputIndex = readingInputIndex;

		InputStatus status, anotherStatus;
		if (readingInputIndex == 0) {
			status = input1.emitNext(output1);
			firstInputStatus = status;
			anotherStatus = secondInputStatus;
		} else {
			status = input2.emitNext(output2);
			secondInputStatus = status;
			anotherStatus = firstInputStatus;
		}
		checkFinished(status, lastReadInputIndex);

		return status == InputStatus.END_OF_INPUT ? anotherStatus : status;
	}

Line commented on: return status == InputStatus.END_OF_INPUT ? anotherStatus : status;

Revised code:
public InputStatus processInput() throws Exception {
		int readingInputIndex;
		if (isPrepared) {
			readingInputIndex = selectNextReadingInputIndex();
			assert readingInputIndex != -1;
		} else {
			
			
			readingInputIndex = selectFirstReadingInputIndex();
			if (readingInputIndex == -1) {
				return InputStatus.NOTHING_AVAILABLE;
			}
		}

		lastReadInputIndex = readingInputIndex;

		if (readingInputIndex == 0) {
			firstInputStatus = input1.emitNext(output1);
			checkFinished(firstInputStatus, lastReadInputIndex);
		} else {
			secondInputStatus = input2.emitNext(output2);
			checkFinished(secondInputStatus, lastReadInputIndex);
		}

		return getInputStatus();
	}
Code review comment: When the logic and number of lines of two branches are the same I usually prefer an `if-else`.  It makes clear that there are two distinct paths of execution which I think is more readable. Having an early return would kind of imply that we are exiting with a specific scenario early which may confuse the reader.   Additionally, in nballerina we have written the logic the same way here, https://github.com/ballerina-platform/nballerina/blob/9c70a7cf23d11d2fc568a56ef04a709eefc51456/compiler/modules/types/cell.bal#L153-L159. So again I prefer to have the same style here.  WDYT?

Code under review:
private static ProperSubtypeData cellSubtypeDataEnsureProper(SubtypeData subtypeData) {
        if (subtypeData instanceof AllOrNothingSubtype allOrNothingSubtype) {
            Atom atom;
            if (allOrNothingSubtype.isAllSubtype()) {
                atom = ATOM_CELL_VAL;
            } else {
                atom = ATOM_CELL_NEVER;
            }
            return bddAtom(atom);
        } else {
            return (ProperSubtypeData) subtypeData;
        }
    }

Line commented on: return bddAtom(atom);

Revised code:
private static ProperSubtypeData cellSubtypeDataEnsureProper(SubtypeData subtypeData) {
        if (subtypeData instanceof AllOrNothingSubtype allOrNothingSubtype) {
            Atom atom;
            if (allOrNothingSubtype.isAllSubtype()) {
                atom = ATOM_CELL_VAL;
            } else {
                atom = ATOM_CELL_NEVER;
            }
            return bddAtom(atom);
        } else {
            return (ProperSubtypeData) subtypeData;
        }
    }
Code review comment: OK, I will add the check.

Code under review:
public void testReaperThreadStartFailed() throws Exception {

		try {
			new SafetyNetCloseableRegistry(() -> new OutOfMemoryReaperThread());
		} catch (java.lang.OutOfMemoryError error) {
		}

		
		SafetyNetCloseableRegistry closeableRegistry = new SafetyNetCloseableRegistry();
		closeableRegistry.close();
	}


Revised code:
public void testReaperThreadStartFailed() throws Exception {

		try {
			new SafetyNetCloseableRegistry(() -> new OutOfMemoryReaperThread());
		} catch (java.lang.OutOfMemoryError error) {
		}
		Assert.assertFalse(SafetyNetCloseableRegistry.isReaperThreadRunning());

		
		SafetyNetCloseableRegistry closeableRegistry = new SafetyNetCloseableRegistry();
		Assert.assertTrue(SafetyNetCloseableRegistry.isReaperThreadRunning());

		closeableRegistry.close();
	}
Code review comment: * typo: multiple * Why do you need to `ImmutableSet.copyOf()` - doesn't Iterables.getOnly work on keySet() as-is? * Can we standartize the key in this map, so that the default java environment always has the same id?

Code under review:
public String getOnlyEnvironmentId() {
    
    return Iterables.getOnlyElement(
        ImmutableSet.copyOf(componentsBuilder.getEnvironmentsMap().keySet()));
  }


Revised code:
public String getOnlyEnvironmentId() {
    
    return Iterables.getOnlyElement(componentsBuilder.getEnvironmentsMap().keySet());
  }
Code review comment: Wondering if we need to expose timers here, as I don't see how it makes sense to create a new timer in an expired window.

Code under review:
public Timer timer(String timerId) {
      try {
        TimerSpec spec = (TimerSpec) signature.timerDeclarations().get(timerId).field().get(fn);
        return new TimerInternalsTimer(
            window, getNamespace(), timerId, spec, timestamp, stepContext.timerInternals());
      } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
      }
    }

Line commented on: TimerSpec spec = (TimerSpec) signature.timerDeclarations().get(timerId).field().get(fn);

Revised code:
public Timer timer(String timerId) {
      try {
        TimerSpec spec = (TimerSpec) signature.timerDeclarations().get(timerId).field().get(fn);
        return new TimerInternalsTimer(
            window(), getNamespace(), timerId, spec, timestamp(), stepContext.timerInternals());
      } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
      }
    }
Code review comment: In my understanding the close method of result partition will be always called by the task thread to release the network resources regardless of success or failure. I think for network resources releasing, it is enough. I guess the only reason to call the close method in the TaskCanceler thread is as the comment suggested: >>>                // Early release of input and output buffer pools. We do this >>>                // in order to unblock async Threads, which produce/consume the >>>                // intermediate streams outside of the main Task Thread (like >>>                // the Kafka consumer). I did not look into this and just moved the BufferPool close operation to the fail method to avoid breaking this behavior.  About the fail method, I think it more likes another release method without knowing the partition id.

Code under review:
public void fail(@Nullable Throwable throwable) {
        closeBufferPool();
        partitionManager.releasePartition(partitionId, throwable);
    }

Line commented on: partitionManager.releasePartition(partitionId, throwable);

Revised code:
public void fail(@Nullable Throwable throwable) {
        
        closeBufferPool();
        partitionManager.releasePartition(partitionId, throwable);
    }
Code review comment: https://github.com/ballerina-platform/ballerina-lang/issues/32687 This issue has been fixed with https://github.com/ballerina-platform/ballerina-lang/pull/34669 PR. But the same issue with `byte` seems to have not been fixed. Therefore added the same fix for `byte` as well.

Code under review:
boolean isByteLiteralValue(Long longObject) {

        return (longObject >= BBYTE_MIN_VALUE && longObject <= BBYTE_MAX_VALUE);
    }

Line commented on: return (longObject >= BBYTE_MIN_VALUE && longObject <= BBYTE_MAX_VALUE);

Revised code:
boolean isByteLiteralValue(Long longObject) {

        return (longObject >= BBYTE_MIN_VALUE && longObject <= BBYTE_MAX_VALUE);
    }
Code review comment: Will this method always be called with arg `false` after a reconfig? If not, don't you risk having old non-existing clusters in the map forever?

Code under review:
public void setContainerHasClusters(boolean containerHasClusters) {
        synchronized (mutex) {
            this.containerHasClusters = containerHasClusters;
            if ( ! containerHasClusters)
                clusterStatus.clear(); 
        }
    }

Line commented on: clusterStatus.clear();

Revised code:
public void setContainerHasClusters(boolean containerHasClusters) {
        synchronized (mutex) {
            this.containerHasClusters = containerHasClusters;
            if ( ! containerHasClusters)
                clusterStatus.clear(); 
        }
    }
Code review comment: `addValue` will set `value` to null if the header was created with a single value or set the cached String value to null when there are multiple values in the header, same logic for query parameter.  ```java public void addValue(String value) {   if (values == null) {       values = new ArrayList<>(4); // 4 was selected to add a buffer of 2 as seen in the constructor.       values.add(this.value);       this.value = null;   }    this.values.add(value);   CACHED_STRING_VALUE_UPDATER.set(this, null); } ```

Code under review:
public String getValue() {
        if (value != null) {
            return value;
        }

        checkCachedStringValue();
        return CACHED_STRING_VALUE_UPDATER.get(this);
    }

Line commented on: return CACHED_STRING_VALUE_UPDATER.get(this);

Revised code:
public String getValue() {
        if (value != null) {
            return value;
        }

        checkCachedStringValue();
        return CACHED_STRING_VALUE_UPDATER.get(this);
    }
Code review comment: Use `Do not implement this method` as a comment. For the exception message, I think it is better to use another description.

Code under review:
public Expression withChildren(List<Expression> children) {
        throw  new RuntimeException("Do not implement this method");
    }

Line commented on: throw  new RuntimeException("Do not implement this method");

Revised code:
public Expression withChildren(List<Expression> children) {
        throw  new RuntimeException("The withChildren() method is not implemented");
    }
Code review comment: Unless we trap this error in Ballerina and convert to a error value, I don't think we need to do this here.

Code under review:
public static void setNotifyFailure(String msg, NonBlockingCallback callback) {
        WebSocketException exception = new WebSocketException(msg);
        BallerinaErrors.setTypeId(WebSocketConstants.ErrorCode.WsInvalidHandshakeError.toString(),
                WebSocketConstants.PROTOCOL_HTTP_PKG_ID, exception);
        callback.notifyFailure(exception);
    }

Line commented on: BallerinaErrors.setTypeId(WebSocketConstants.ErrorCode.WsInvalidHandshakeError.toString(),

Revised code:
public static void setNotifyFailure(String msg, NonBlockingCallback callback) {
        callback.notifyFailure(getWebSocketException(msg, null,
                WebSocketConstants.ErrorCode.WsInvalidHandshakeError.errorCode(), null));
    }
Code review comment: Good idea, I didn't think about that one. Would you like to add new PR @michalszynkiewicz?

Code under review:
public static RolesAllowedCheck of(String[] allowedRoles) {
        return CACHE.computeIfAbsent(Arrays.asList(allowedRoles), new Function<List<String>, RolesAllowedCheck>() {
            @Override
            public RolesAllowedCheck apply(List<String> allowedRolesList) {
                return new RolesAllowedCheck(allowedRolesList.toArray(new String[0]));
            }
        });
    }

Line commented on: return CACHE.computeIfAbsent(Arrays.asList(allowedRoles), new Function<List<String>, RolesAllowedCheck>() {

Revised code:
public static RolesAllowedCheck of(String[] allowedRoles) {
        return CACHE.computeIfAbsent(Arrays.asList(allowedRoles), new Function<List<String>, RolesAllowedCheck>() {
            @Override
            public RolesAllowedCheck apply(List<String> allowedRolesList) {
                return new RolesAllowedCheck(allowedRolesList.toArray(new String[0]));
            }
        });
    }
Code review comment: Note that this is a lot slower executing when compared to: ``` for (Receiver receiver : outputDataReceivers.values()) {   receiver.reset(); } ```  Also, you can merge this with the iteration above using an entryset and add the data/timer and reset the receiver in the loop above.

Code under review:
public void sendBufferedDataAndFinishOutboundStreams() {
    if (totalByteCounter.longValue() == 0
        && outputTimersReceivers.isEmpty()
        && outputDataReceivers.isEmpty()) {
      return;
    }
    Elements.Builder bufferedElements = convertBufferForTransmission();
    LOG.debug(
        "Closing streams for outbound endpoints {} and {}.",
        outputDataReceivers.keySet(),
        outputTimersReceivers.keySet());
    LOG.debug(
        "Sent outbound data : {}, outbound timers : {}.",
        outputDataReceivers,
        outputTimersReceivers);
    for (String pTransformID : outputDataReceivers.keySet()) {
      bufferedElements
          .addDataBuilder()
          .setInstructionId(processBundleRequestIdSupplier.get())
          .setTransformId(pTransformID)
          .setIsLast(true);
    }
    for (TimerEndpoint timerKey : outputTimersReceivers.keySet()) {
      bufferedElements
          .addTimersBuilder()
          .setInstructionId(processBundleRequestIdSupplier.get())
          .setTransformId(timerKey.pTransformId)
          .setTimerFamilyId(timerKey.timerFamilyId)
          .setIsLast(true);
    }
    outboundObserver.onNext(bufferedElements.build());
    outputDataReceivers.values().forEach(Receiver::reset);
    outputTimersReceivers.values().forEach(Receiver::reset);
  }

Line commented on: outputTimersReceivers.values().forEach(Receiver::reset);

Revised code:
public void sendBufferedDataAndFinishOutboundStreams() {
    if (outputTimersReceivers.isEmpty() && outputDataReceivers.isEmpty()) {
      return;
    }
    Elements.Builder bufferedElements;
    if (timeLimit > 0) {
      synchronized (flushLock) {
        bufferedElements = convertBufferForTransmission();
      }
    } else {
      bufferedElements = convertBufferForTransmission();
    }
    LOG.debug(
        "Closing streams for instruction {} and outbound data {} and timers {}.",
        processBundleRequestIdSupplier.get(),
        outputDataReceivers,
        outputTimersReceivers);
    for (Map.Entry<String, Receiver<?>> entry : outputDataReceivers.entrySet()) {
      String pTransformId = entry.getKey();
      bufferedElements
          .addDataBuilder()
          .setInstructionId(processBundleRequestIdSupplier.get())
          .setTransformId(pTransformId)
          .setIsLast(true);
      entry.getValue().resetStats();
    }
    for (Map.Entry<TimerEndpoint, Receiver<?>> entry : outputTimersReceivers.entrySet()) {
      TimerEndpoint timerKey = entry.getKey();
      bufferedElements
          .addTimersBuilder()
          .setInstructionId(processBundleRequestIdSupplier.get())
          .setTransformId(timerKey.pTransformId)
          .setTimerFamilyId(timerKey.timerFamilyId)
          .setIsLast(true);
      entry.getValue().resetStats();
    }
    outboundObserver.onNext(bufferedElements.build());
  }
Code review comment: This follows the implementation of the normal Reader, so I believe it would be better to keep them as they are.

Code under review:
private void waitReadRowsFuture() throws IOException {
      try {
        UpstreamResults r = future.get();
        buffer.addAll(r.rows);
        nextRequest = r.nextRequest;
        future = null;
        serviceCallMetric.call("ok");
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new IOException(e);
      } catch (ExecutionException e) {
        Throwable cause = e.getCause();
        if (cause instanceof StatusRuntimeException) {
          serviceCallMetric.call(((StatusRuntimeException) cause).getStatus().getCode().value());
        }
        throw new IOException(cause);
      }
    }

Line commented on: serviceCallMetric.call(((StatusRuntimeException) cause).getStatus().getCode().value());

Revised code:
private void waitReadRowsFuture() throws IOException {
      try {
        UpstreamResults r = future.get();
        buffer.addAll(r.rows);
        nextRequest = r.nextRequest;
        future = null;
        serviceCallMetric.call("ok");
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new IOException(e);
      } catch (ExecutionException e) {
        Throwable cause = e.getCause();
        if (cause instanceof StatusRuntimeException) {
          serviceCallMetric.call(((StatusRuntimeException) cause).getStatus().getCode().toString());
        }
        throw new IOException(cause);
      }
    }
Code review comment: Changed to 2 in new commit. I'll add the metrics as a separate sprint task

Code under review:
private void insertNetworkErrors() {
        
        boolean asErrors = answeredNodes == 0;

        if (!invokers.isEmpty()) {
            String keys = invokers.stream().map(SearchInvoker::distributionKey).map(dk -> dk.map(i -> i.toString()).orElse("(unspecified)"))
                    .collect(Collectors.joining(", "));

            if (asErrors) {
                result.hits().addError(ErrorMessage
                        .createTimeout("Backend communication timeout on all nodes in group (distribution-keys: " + keys + ")"));
            } else {
                query.trace("Backend communication timeout on nodes with distribution-keys: " + keys, 5);
            }
            timedOut = true;
        }
        if (alreadyFailedNodes != null) {
            var message = "Connection failure on nodes with distribution-keys: "
                    + alreadyFailedNodes.stream().map(v -> Integer.toString(v)).collect(Collectors.joining(", "));
            if (asErrors) {
                result.hits().addError(ErrorMessage.createBackendCommunicationError(message));
            } else {
                query.trace(message, 5);
            }
            int failed = alreadyFailedNodes.size();
            askedNodes += failed;
            answeredNodes += failed;
        }
    }

Line commented on: query.trace("Backend communication timeout on nodes with distribution-keys: " + keys, 5);

Revised code:
private void insertNetworkErrors() {
        
        boolean asErrors = answeredNodes == 0;

        if (!invokers.isEmpty()) {
            String keys = invokers.stream().map(SearchInvoker::distributionKey).map(dk -> dk.map(i -> i.toString()).orElse("(unspecified)"))
                    .collect(Collectors.joining(", "));

            if (asErrors) {
                result.hits().addError(ErrorMessage
                        .createTimeout("Backend communication timeout on all nodes in group (distribution-keys: " + keys + ")"));
            } else {
                query.trace("Backend communication timeout on nodes with distribution-keys: " + keys, 2);
            }
            timedOut = true;
        }
        if (alreadyFailedNodes != null) {
            var message = "Connection failure on nodes with distribution-keys: "
                    + alreadyFailedNodes.stream().map(v -> Integer.toString(v)).collect(Collectors.joining(", "));
            if (asErrors) {
                result.hits().addError(ErrorMessage.createBackendCommunicationError(message));
            } else {
                query.trace(message, 2);
            }
            int failed = alreadyFailedNodes.size();
            askedNodes += failed;
            answeredNodes += failed;
        }
    }
Code review comment: So tests are only run on the default instance because non-default instances are assumed to be tested implicitly by testing the default?  But someone set up only non-default instances?

Code under review:
private HttpResponse testConfig(ApplicationId id, JobType type) {
        
        ApplicationId defaultInstanceId = TenantAndApplicationId.from(id).defaultInstance();
        var deployments = controller.applications()
                                    .getInstance(defaultInstanceId).stream()
                                    .flatMap(instance -> instance.productionDeployments().keySet().stream())
                                    .map(zone -> new DeploymentId(defaultInstanceId, zone))
                                    .collect(Collectors.toSet());
        var testedZone = type.zone(controller.system());

        
        
        if ( ! type.isProduction())
            deployments.add(new DeploymentId(id, testedZone));

        return new SlimeJsonResponse(testConfigSerializer.configSlime(id,
                                                                      type,
                                                                      false,
                                                                      controller.applications().clusterEndpoints(deployments),
                                                                      controller.applications().contentClustersByZone(deployments)));
    }


Revised code:
private HttpResponse testConfig(ApplicationId id, JobType type) {
        
        ApplicationId defaultInstanceId = TenantAndApplicationId.from(id).defaultInstance();
        var deployments = controller.applications()
                                    .getInstance(defaultInstanceId).stream()
                                    .flatMap(instance -> instance.productionDeployments().keySet().stream())
                                    .map(zone -> new DeploymentId(defaultInstanceId, zone))
                                    .collect(Collectors.toSet());
        var testedZone = type.zone(controller.system());

        
        
        if ( ! type.isProduction())
            deployments.add(new DeploymentId(id, testedZone));

        return new SlimeJsonResponse(testConfigSerializer.configSlime(id,
                                                                      type,
                                                                      false,
                                                                      controller.applications().clusterEndpoints(deployments),
                                                                      controller.applications().contentClustersByZone(deployments)));
    }
Code review comment: I think that works too, +1. I thought `401` would be simpler due to the fact that this status would also mean a `window.reload` at the SPA, the actual authentication flow is managed by the server-side.

Code under review:
public AuthenticationRedirectException(Boolean autoRedirect, String redirectUri) {
        this(autoRedirect ? 302 : 444, redirectUri);
    }

Line commented on: this(autoRedirect ? 302 : 444, redirectUri);

Revised code:
public AuthenticationRedirectException(Boolean autoRedirect, String redirectUri) {
        this(autoRedirect ? 302 : 444, redirectUri);
    }
Code review comment: I guess we could remove this while logic, the following  `requestFuture.get();` would wait the results

Code under review:
public void testBackPressureRequestTimeout() throws Exception {
		long requestTimeout = 1000;
		coordinator = new BackPressureRequestCoordinator(executorService, requestTimeout);
		ExecutionVertex[] vertices = createExecutionVertices(ExecutionState.RUNNING, CompletionType.TIMEOUT, requestTimeout);

		CompletableFuture<BackPressureStats> requestFuture = coordinator.triggerBackPressureRequest(vertices);

		
		while (!requestFuture.isDone()) {
			Thread.sleep(100);
		}

		try {
			requestFuture.get();
			fail("Exception expected.");
		} catch (ExecutionException e) {
			assertTrue(e.getCause().getCause().getMessage().toLowerCase().contains("timeout"));
		}
	}

Line commented on: while (!requestFuture.isDone()) {

Revised code:
public void testBackPressureRequestTimeout() throws Exception {
		long requestTimeout = 100;
		ExecutionVertex[] vertices = createExecutionVertices(ExecutionState.RUNNING, CompletionType.TIMEOUT, requestTimeout);
		BackPressureRequestCoordinator coordinator = new BackPressureRequestCoordinator(executorService, requestTimeout);

		try {
			CompletableFuture<BackPressureStats> requestFuture = coordinator.triggerBackPressureRequest(vertices);
			requestFuture.get();
			fail("Exception expected.");
		} catch (ExecutionException e) {
			assertTrue(ExceptionUtils.findThrowableWithMessage(e, requestTimeoutMessage).isPresent());
		} finally {
			coordinator.shutDown();
		}
	}
Code review comment: Only LogicalScanOperator/PhysicalScanOperator orginates from CboTablePruneRule has salt. if no salt, two diffrent Groups will be merged into one,  that leads to mutal reference or self reference of groups

Code under review:
public Operator(OperatorType opType) {
        this.opType = opType;
    }

Line commented on: this.opType = opType;

Revised code:
public Operator(OperatorType opType) {
        this.opType = opType;
    }
Code review comment: Thank you so much @Abacn for this suggestion. This really helped clean up the code.

Code under review:
OutputT apply(InputT input) throws UserCodeExecutionException {
    Optional<UserCodeExecutionException> latestError = Optional.empty();
    long waitFor = 0L;
    while (waitFor != BackOff.STOP) {
      try {
        if (waitFor > 0L) {
          if (getSleeperCounter() != null) {
            checkStateNotNull(getSleeperCounter()).inc();
          }
          getSleeper().sleep(waitFor);
        }
        if (getCallCounter() != null) {
          checkStateNotNull(getCallCounter()).inc();
        }
        return getThrowableFunction().apply(input);
      } catch (UserCodeExecutionException e) {
        if (!e.shouldRepeat()) {
          throw e;
        }
        latestError = Optional.of(e);
      } catch (InterruptedException ignored) {
      }
      try {
        if (getBackoffCounter() != null) {
          checkStateNotNull(getBackoffCounter()).inc();
        }
        waitFor = getBackOff().nextBackOffMillis();
      } catch (IOException e) {
        throw new UserCodeExecutionException(e);
      }
    }
    throw latestError.orElse(
        new UserCodeExecutionException("failed to process for input: " + input));
  }

Line commented on: if (getSleeperCounter() != null) {

Revised code:
OutputT apply(InputT input) throws UserCodeExecutionException {
    Optional<UserCodeExecutionException> latestError = Optional.empty();
    long waitFor = 0L;
    while (waitFor != BackOff.STOP) {
      try {
        sleepIfNeeded(waitFor);
        incIfPresent(getCallCounter());
        return getThrowableFunction().apply(input);
      } catch (UserCodeExecutionException e) {
        if (!e.shouldRepeat()) {
          throw e;
        }
        latestError = Optional.of(e);
      } catch (InterruptedException ignored) {
      }
      try {
        incIfPresent(getBackoffCounter());
        waitFor = getBackOff().nextBackOffMillis();
      } catch (IOException e) {
        throw new UserCodeExecutionException(e);
      }
    }
    throw latestError.orElse(
        new UserCodeExecutionException("failed to process for input: " + input));
  }
Code review comment: why you delete origin `stringType` check  `stringType` check is used to make work with `char` and `varchar`, do you have test your path with `char` and `varchar` type with convert function which return is not these type?

Code under review:
private Expr castToSlot(SlotDescriptor slotDesc, Expr expr) throws UserException {
        PrimitiveType dstType = slotDesc.getType().getPrimitiveType();
        PrimitiveType srcType = expr.getType().getPrimitiveType();
        if (dstType != srcType) {
            return expr.castTo(slotDesc.getType());
        } else {
            return expr;
        }
    }

Line commented on: if (dstType != srcType) {

Revised code:
private Expr castToSlot(SlotDescriptor slotDesc, Expr expr) throws UserException {
        PrimitiveType dstType = slotDesc.getType().getPrimitiveType();
        PrimitiveType srcType = expr.getType().getPrimitiveType();
        if (dstType != srcType) {
            return expr.castTo(slotDesc.getType());
        } else {
            return expr;
        }
    }
Code review comment: What is the motivation here ? We should not stop the run on fixed error count, instead let the run complete and analysis the result later

Code under review:
public void run(final Set<Key> testKeys) {
        final ArrayList<Key> keys = new ArrayList<>(testKeys);
        Collections.shuffle(keys);
        final long runStartTime = System.currentTimeMillis();
        long i = 0;
        for (; BenchmarkHelper.shouldContinue(runStartTime, i, _configuration); i++) {
            if (exceedsErrorThreshold()) {
                return;
            }

            int index = (int) ((i % keys.size()) % Integer.MAX_VALUE);
            final Key key = keys.get(index);
            try {
                _semaphore.acquire();
            } catch (InterruptedException e) {
                
                _errorCount.incrementAndGet();
                continue;
            }
            _executorService.submit(() -> runOperation(key));
        }

        
        final Instant runEndTime = Instant.now();
        LOGGER.info("Number of iterations: {}, Errors: {}, Runtime: {} millis",
            _successCount.get(),
            _errorCount.get(),
            runEndTime.minusMillis(runStartTime).toEpochMilli());
    }

Line commented on: if (exceedsErrorThreshold()) {

Revised code:
public void run(final Set<Key> testKeys) {
        final ArrayList<Key> keys = new ArrayList<>(testKeys);
        Collections.shuffle(keys);
        final long runStartTime = System.currentTimeMillis();
        long i = 0;
        for (; BenchmarkHelper.shouldContinue(runStartTime, i, _configuration); i++) {
            int index = (int) ((i % keys.size()) % Integer.MAX_VALUE);
            final Key key = keys.get(index);
            try {
                _semaphore.acquire();
            } catch (InterruptedException e) {
                
                _errorCount.incrementAndGet();
                continue;
            }
            _executorService.submit(() -> runOperation(key));
        }

        
        final Instant runEndTime = Instant.now();
        LOGGER.info("Number of iterations: {}, Errors: {}, Runtime: {} millis",
            _successCount.get(),
            _errorCount.get(),
            runEndTime.minusMillis(runStartTime).toEpochMilli());
    }
Code review comment: Here is a code snipet to capture a duplicated context, and create if needed: ```java  private Context captureTheRightContext(Vertx vertx) {         Context context = Vertx.currentContext();         if (context == null) {             // Create both a root and a duplicated context             context = ((ContextInternal) vertx.getOrCreateContext()).duplicate();         } else {             if (isRootContext(context)) {                 context = ((ContextInternal) context).duplicate();             }         }         return context;     }      private boolean isRootContext(Context context) {         return context instanceof EventLoopContext || context instanceof WorkerContext;     } ```

Code under review:
public String uri() {
            return httpRequest.uri();
        }

Line commented on: return httpRequest.uri();

Revised code:
public String uri() {
            return httpRequest.uri();
        }
Code review comment: Good point, thank you.  I have enhanced the `ReturnCounter`, since it was used only for this check to include `break` and `continue`. I have extracted it to separate file and renamed to `ReturnAndJumpCounter`

Code under review:
private boolean shouldExtract(StatementContext ctx) {
            return ctx != null
                    && ctx.block() != null
                    && ctx.block().blockStatement() != null
                    
                    
                    && ctx.block().blockStatement().size() > 1
                    
                    && getNumReturnsInContext(ctx.block()) == 0;
        }

Line commented on: && getNumReturnsInContext(ctx.block()) == 0;

Revised code:
private boolean shouldExtract(StatementContext ctx) {
            return ctx != null
                    && ctx.block() != null
                    && ctx.block().blockStatement() != null
                    
                    
                    && ctx.block().blockStatement().size() > 1
                    
                    && getNumOfReturnOrJumpStatements(ctx.block()) == 0;
        }
Code review comment: set status to down after server.run()? Is this ever reached?  Or more slightly more generally, is there a good place to set status down?

Code under review:
public void run() {
        if (versionState.isUpgraded()) {
            log.log(LogLevel.INFO, "Configserver upgraded from " + versionState.storedVersion() + " to "
                    + versionState.currentVersion() + ". Redeploying all applications");
            try {
                applicationRepository.redeployAllApplications(deployer);
            } catch (InterruptedException e) {
                throw new RuntimeException("Redeploying applications failed", e);
            }
            log.log(LogLevel.INFO, "All applications redeployed");
        }
        versionState.saveNewVersion();
        stateMonitor.status(StateMonitor.Status.up);
        log.log(LogLevel.DEBUG, "Starting RPC server");
        server.run();
        log.log(LogLevel.DEBUG, "RPC server stopped");
    }

Line commented on: log.log(LogLevel.DEBUG, "RPC server stopped");

Revised code:
public void run() {
        if (versionState.isUpgraded()) {
            log.log(LogLevel.INFO, "Configserver upgraded from " + versionState.storedVersion() + " to "
                    + versionState.currentVersion() + ". Redeploying all applications");
            try {
                applicationRepository.redeployAllApplications(deployer);
            } catch (InterruptedException e) {
                throw new RuntimeException("Redeploying applications failed", e);
            }
            log.log(LogLevel.INFO, "All applications redeployed");
        }
        versionState.saveNewVersion();
        stateMonitor.status(StateMonitor.Status.up);
        log.log(LogLevel.DEBUG, "Starting RPC server");
        server.run();
        log.log(LogLevel.DEBUG, "RPC server stopped");
        stateMonitor.status(StateMonitor.Status.down);
    }
Code review comment: Might be nice with a log entry here, as in the VcmrMaintainer

Code under review:
private void approveChangeRequest(ChangeRequest changeRequest) {
        if (changeRequest.getApproval() == ChangeRequest.Approval.REQUESTED)
            changeRequestClient.approveChangeRequest(changeRequest);
    }

Line commented on: changeRequestClient.approveChangeRequest(changeRequest);

Revised code:
private void approveChangeRequest(ChangeRequest changeRequest) {
        if (changeRequest.getApproval() == ChangeRequest.Approval.REQUESTED)
            changeRequestClient.approveChangeRequest(changeRequest);
    }
Code review comment: The ctor already creates an instance of `RetryPolicy`.  Is there a reason for creating another instance instead of using `this.retryPolicy`?

Code under review:
protected AmqpSession createSession(String sessionName, Session session, SessionHandler handler) {
        return new ReactorSession(session, handler, sessionName, reactorProvider, handlerProvider,
            getClaimsBasedSecurityNode(), tokenManagerProvider, messageSerializer,
            connectionOptions.getRetry().getTryTimeout(), RetryUtil.getRetryPolicy(connectionOptions.getRetry()));
    }

Line commented on: connectionOptions.getRetry().getTryTimeout(), RetryUtil.getRetryPolicy(connectionOptions.getRetry()));

Revised code:
protected AmqpSession createSession(String sessionName, Session session, SessionHandler handler) {
        return new ReactorSession(session, handler, sessionName, reactorProvider, handlerProvider,
            getClaimsBasedSecurityNode(), tokenManagerProvider, messageSerializer,
            connectionOptions.getRetry().getTryTimeout(), retryPolicy);
    }
Code review comment: if we just want to process `group by null`, maybe a better way to do it is generating NullLiteral with TinyIntType when we do rewrite.

Code under review:
public static NormalizeToSlotTriplet toTriplet(Expression expression, @Nullable Alias existsAlias) {
            if (existsAlias != null) {
                return new NormalizeToSlotTriplet(expression, existsAlias.toSlot(), existsAlias);
            }

            if (expression instanceof NamedExpression) {
                NamedExpression namedExpression = (NamedExpression) expression;
                NormalizeToSlotTriplet normalizeToSlotTriplet =
                        new NormalizeToSlotTriplet(expression, namedExpression.toSlot(), namedExpression);
                return normalizeToSlotTriplet;
            }

            Alias alias = new Alias(expression, expression.toSql());
            SlotReference slot = (SlotReference) alias.toSlot();
            
            return new NormalizeToSlotTriplet(expression, expression instanceof NullLiteral ? slot.withDataType(
                    TinyIntType.INSTANCE) : slot, alias);
        }

Line commented on: TinyIntType.INSTANCE) : slot, alias);

Revised code:
public static NormalizeToSlotTriplet toTriplet(Expression expression, @Nullable Alias existsAlias) {
            if (existsAlias != null) {
                return new NormalizeToSlotTriplet(expression, existsAlias.toSlot(), existsAlias);
            }

            if (expression instanceof NamedExpression) {
                NamedExpression namedExpression = (NamedExpression) expression;
                NormalizeToSlotTriplet normalizeToSlotTriplet =
                        new NormalizeToSlotTriplet(expression, namedExpression.toSlot(), namedExpression);
                return normalizeToSlotTriplet;
            }

            Alias alias = new Alias(expression, expression.toSql());
            SlotReference slot = (SlotReference) alias.toSlot();
            
            return new NormalizeToSlotTriplet(expression, expression instanceof NullLiteral ? slot.withDataType(
                    TinyIntType.INSTANCE) : slot, alias);
        }