muttakin2301/ccr2000 huggingface dataset:
Code review comment: I would go with `debug` as it won't affect runtime of an application, aside not having a warm startup.

Code under review:
private static void attemptToWarmupHttpClient(ReactorNettyClient reactorNettyClient) {
        
        if (HTTP_CLIENT_WARMUP == null) {
            return;
        }

        try {
            ((Mono<?>) HTTP_CLIENT_WARMUP.invoke(reactorNettyClient.httpClient)).block();
        } catch (ClassCastException | WrongMethodTypeException throwable) {
            
        } catch (Throwable throwable) {
            
            throw new RuntimeException(throwable);
        }
    }


Revised code:
private static void attemptToWarmupHttpClient(ReactorNettyClient reactorNettyClient) {
        
        if (HTTP_CLIENT_WARMUP == null) {
            return;
        }

        try {
            ((Mono<?>) HTTP_CLIENT_WARMUP.invoke(reactorNettyClient.httpClient)).block();
        } catch (ClassCastException | WrongMethodTypeException throwable) {
            
            logger.debug("Invoking HttpClient.warmup failed.", throwable);
        } catch (Throwable throwable) {
            
            throw new RuntimeException(throwable);
        }
    }
Code review comment: Yea, this was a code that we might have copied from somewhere (may be .Net long time back), until Anu pointed out this issue when we did spot bugs check for v4 during its GA phase. Never really got the chance to fix it, until I started going over the github issues. It fixes this one - https://github.com/Azure/azure-sdk-for-java/issues/9104

Code under review:
public void writeForBinaryEncoding(OutputStream outputStream) {
        try {
            outputStream.write((byte) PartitionKeyComponentType.STRING.type);
            boolean shortString = this.utf8Value.length <= MAX_STRING_BYTES_TO_APPEND;

            for (int index = 0; index < (shortString ? this.utf8Value.length : MAX_STRING_BYTES_TO_APPEND + 1); index++) {
                byte charByte = this.utf8Value[index];
                charByte++;
                outputStream.write(charByte);
            }

            if (shortString) {
                outputStream.write((byte) 0x00);
            }
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }

Line commented on: charByte++;

Revised code:
public void writeForBinaryEncoding(OutputStream outputStream) {
        try {
            outputStream.write((byte) PartitionKeyComponentType.STRING.type);
            boolean shortString = this.utf8Value.length <= MAX_STRING_BYTES_TO_APPEND;

            for (int index = 0; index < (shortString ? this.utf8Value.length : MAX_STRING_BYTES_TO_APPEND + 1); index++) {
                byte charByte = this.utf8Value[index];
                charByte++;
                outputStream.write(charByte);
            }

            if (shortString) {
                outputStream.write((byte) 0x00);
            }
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }
Code review comment: Don't you think that it would be better to do this check in `startBundle()` since the whole bundle will be processed entirely on one worker?  Also, it would be great to have a regression test for this case.

Code under review:
private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException {
        is.defaultReadObject();
        if (producer == null) {
          initKinesisProducer();
        }
      }

Line commented on: if (producer == null) {

Revised code:
private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException {
        is.defaultReadObject();
        initKinesisProducer();
      }
Code review comment: We should not swallow the causing and exception and pass it to the RuntimeException

Code under review:
private void deleteJobManagerTemporaryFiles() {
        try {
            final Container.ExecResult result =
                    jobManager.execInContainer(
                            "rm",
                            "-rf",
                            Paths.get(conf.get(CheckpointingOptions.CHECKPOINTS_DIRECTORY), "*")
                                    .toString(),
                            Paths.get(conf.get(HighAvailabilityOptions.HA_STORAGE_PATH), "*")
                                    .toString());
            if (result.getExitCode() != 0) {
                throw new IllegalStateException(
                        String.format(
                                "rm command returned non-zero exit code %d. \nSTDOUT: %s\nSTDERR: %s",
                                result.getExitCode(), result.getStdout(), result.getStderr()));
            }
        } catch (Exception e) {
            throw new RuntimeException("Failed to delete temporary files in JobManager");
        }
    }

Line commented on: throw new RuntimeException("Failed to delete temporary files in JobManager");

Revised code:
private void deleteJobManagerTemporaryFiles() {
        final String checkpointDir = conf.get(CheckpointingOptions.CHECKPOINTS_DIRECTORY);
        final String haDir = conf.get(HighAvailabilityOptions.HA_STORAGE_PATH);
        final Collection<String> usedPaths =
                Lists.newArrayList(checkpointDir, haDir).stream()
                        .filter(Objects::nonNull)
                        .collect(Collectors.toList());
        if (usedPaths.isEmpty()) {
            return;
        }
        final StringBuilder deletionBaseCommand = new StringBuilder("rm -rf");
        usedPaths.forEach(p -> deletionBaseCommand.append(formatFilePathForDeletion(p)));
        final String[] command = {"bash", "-c", deletionBaseCommand.toString()};
        final Container.ExecResult result;
        try {
            result = jobManager.execInContainer(command);
            if (result.getExitCode() != 0) {
                throw new IllegalStateException(
                        String.format(
                                "Command \"%s\" returned non-zero exit code %d. \nSTDOUT: %s\nSTDERR: %s",
                                String.join(" ", command),
                                result.getExitCode(),
                                result.getStdout(),
                                result.getStderr()));
            }
        } catch (IOException e) {
            throw new RuntimeException(
                    "Failed to delete temporary files generated by the flink cluster.", e);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(
                    "Failed to delete temporary files generated by the flink cluster.", e);
        }
    }
Code review comment: Don't you also need to consider the superclasses?

Code under review:
private boolean isJaxrsMethod(MethodInfo method) {
        ClassInfo clazz = method.declaringClass();
        return Stream.concat(Stream.of(clazz.name()), clazz.interfaceNames().stream())
                .anyMatch(dotName -> Optional.ofNullable(jaxRsMethods.get(dotName))
                        .map(methodNames -> methodNames.contains(method.name()))
                        .orElse(false));
    }

Line commented on: return Stream.concat(Stream.of(clazz.name()), clazz.interfaceNames().stream())

Revised code:
private boolean isJaxrsMethod(MethodInfo method) {
        ClassInfo clazz = method.declaringClass();
        SimpleMethodSignatureKey signatureKey = new SimpleMethodSignatureKey(method);

        if (isJaxrsMethod(signatureKey, clazz.name())) {
            return true;
        }

        
        for (DotName iface : clazz.interfaceNames()) {
            if (isJaxrsMethod(signatureKey, iface)) {
                return true;
            }
        }

        
        DotName superClass = clazz.superName();
        if (!superClass.equals(IndexingUtil.OBJECT)) {
            if (isJaxrsMethod(signatureKey, superClass)) {
                return true;
            }
        }
        return false;
    }
Code review comment: thanks for pointing this out, I will look in to that.

Code under review:
private STNode parsePanicStatement() {
        startContext(ParserRuleContext.PANIC_KEYWORD);
        STNode panicKeyword = parsePanicKeyword();
        STNode expression = parseExpression();
        STNode semicolon = parseSemicolon();
        endContext();
        return STNodeFactory.createPanicStatement(panicKeyword, expression, semicolon);
    }

Line commented on: startContext(ParserRuleContext.PANIC_KEYWORD);

Revised code:
private STNode parsePanicStatement() {
        startContext(ParserRuleContext.PANIC_STMT);
        STNode panicKeyword = parsePanicKeyword();
        STNode expression = parseExpression();
        STNode semicolon = parseSemicolon();
        endContext();
        return STNodeFactory.createPanicStatement(panicKeyword, expression, semicolon);
    }
Code review comment: I think you can replace the lambda with this::indexDescriptor

Code under review:
private void indexDescriptorByName() {
    descriptorMap = new HashMap<>();
    fileDescriptorMap
        .values()
        .forEach(
            fileDescriptor -> {
              fileDescriptor.getMessageTypes().forEach(descriptor -> indexDescriptor(descriptor));
            });
  }

Line commented on: fileDescriptor.getMessageTypes().forEach(descriptor -> indexDescriptor(descriptor));

Revised code:
private void indexDescriptorByName() {
    descriptorMap = new HashMap<>();
    fileDescriptorMap
        .values()
        .forEach(
            fileDescriptor -> {
              fileDescriptor.getMessageTypes().forEach(this::indexDescriptor);
            });
  }
Code review comment: @anamarija, it was just a doubt .. I also agree with your point. thanks for answering me

Code under review:
public boolean isValid(Connection connection) {
                    try (Statement stmt = connection.createStatement()) {
                        stmt.execute(validationQuery);
                        return true;
                    } catch (Exception e) {
                        log.warn("Connection validation failed", e);
                    }
                    return false;
                }

Line commented on: log.warn("Connection validation failed", e);

Revised code:
public boolean isValid(Connection connection) {
                    try (Statement stmt = connection.createStatement()) {
                        stmt.execute(validationQuery);
                        return true;
                    } catch (Exception e) {
                        log.warn("Connection validation failed", e);
                    }
                    return false;
                }
Code review comment: Add `equals` and `hashcode` to the `User` class, and here we can call `Assertions.assertEquals(testUser, user)`

Code under review:
public void testCosmosOperation() {
        LOGGER.info("CosmosIT begin.");
        User testUser = new User(
            "testCosmos",
            "testFirstName",
            "testLastName",
            "test address line two"
        );
        CosmosContainer container = client.getDatabase(databaseName).getContainer(containerName);
        container.createItem(testUser);
        CosmosPagedIterable<User> users = container.queryItems("SELECT * FROM c WHERE c.id = 'testCosmos'",
            new CosmosQueryRequestOptions(),
            User.class);
        if (users.stream().iterator().hasNext()) {
            User user = users.stream().iterator().next();
            Assertions.assertEquals(user.toString(), "testFirstName testLastName, test address line two");
        }
        container.deleteItem(testUser, new CosmosItemRequestOptions());
        CosmosPagedIterable<User> usersDelete = container.queryItems("SELECT * FROM c WHERE c.id = 'testCosmos'",
            new CosmosQueryRequestOptions(),
            User.class);
        Assertions.assertFalse(usersDelete.iterator().hasNext());
        LOGGER.info("CosmosIT end.");
    }

Line commented on: Assertions.assertEquals(user.toString(), "testFirstName testLastName, test address line two");

Revised code:
public void testCosmosOperation() {
        LOGGER.info("CosmosIT begin.");
        User testUser = new User(
            "testCosmos",
            "testFirstName",
            "testLastName",
            "test address line two"
        );
        CosmosContainer container = client.getDatabase(DATABASE_NAME).getContainer(CONTAINER_NAME);
        container.createItem(testUser);
        CosmosPagedIterable<User> users = container.queryItems("SELECT * FROM c WHERE c.id = 'testCosmos'",
            new CosmosQueryRequestOptions(),
            User.class);
        if (users.stream().iterator().hasNext()) {
            User user = users.stream().iterator().next();
            Assertions.assertEquals(testUser, user);
        }
        container.deleteItem(testUser, new CosmosItemRequestOptions());
        CosmosPagedIterable<User> usersAfterDeletion = container.queryItems("SELECT * FROM c WHERE c.id = 'testCosmos'",
            new CosmosQueryRequestOptions(),
            User.class);
        Assertions.assertFalse(usersAfterDeletion.iterator().hasNext());
        LOGGER.info("CosmosIT end.");
    }
Code review comment: why cannot init it in init function?

Code under review:
public void execute() {
        prepareExecution();
        tableSample = getTableSample();
        executeWithRetry();
        afterExecution();
    }

Line commented on: tableSample = getTableSample();

Revised code:
public void execute() {
        prepareExecution();
        executeWithRetry();
        afterExecution();
    }
Code review comment: Yes, this fixes test failures that arise because of this: https://github.com/apache/flink/pull/23553/files#diff-4a5eb9032bed78bb9f18e6523d4f7b3dc86ed10e3a3689757c1c4fa2335e7255R1307 the SingleOutputStreamOperator caps max parallelism to 1.  The current implementation of `fromSequence`, somewhat inconsistently, allows parallel execution.

Code under review:
public void testMaxParallelismWithConnectedKeyedStream() {
        int maxParallelism = 42;

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStream<Long> input1 = env.fromSequence(1, 4).setMaxParallelism(128);
        DataStream<Long> input2 = env.fromSequence(1, 4).setMaxParallelism(129);

        env.getConfig().setMaxParallelism(maxParallelism);

        DataStream<Long> keyedResult =
                input1.connect(input2)
                        .keyBy(value -> value, value -> value)
                        .map(new NoOpLongCoMap());

        keyedResult.sinkTo(new DiscardingSink<>());

        StreamGraph graph = env.getStreamGraph();

        StreamNode keyedResultNode = graph.getStreamNode(keyedResult.getId());

        StreamPartitioner<?> streamPartitioner1 =
                keyedResultNode.getInEdges().get(0).getPartitioner();
        StreamPartitioner<?> streamPartitioner2 =
                keyedResultNode.getInEdges().get(1).getPartitioner();
    }

Line commented on: DataStream<Long> input2 = env.fromSequence(1, 4).setMaxParallelism(129);

Revised code:
public void testMaxParallelismWithConnectedKeyedStream() {
        int maxParallelism = 42;

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStream<Long> input1 = env.fromSequence(1, 4).setMaxParallelism(128);
        DataStream<Long> input2 = env.fromSequence(1, 4).setMaxParallelism(129);

        env.getConfig().setMaxParallelism(maxParallelism);

        DataStream<Long> keyedResult =
                input1.connect(input2)
                        .keyBy(value -> value, value -> value)
                        .map(new NoOpLongCoMap());

        keyedResult.sinkTo(new DiscardingSink<>());

        StreamGraph graph = env.getStreamGraph();

        StreamNode keyedResultNode = graph.getStreamNode(keyedResult.getId());

        StreamPartitioner<?> streamPartitioner1 =
                keyedResultNode.getInEdges().get(0).getPartitioner();
        StreamPartitioner<?> streamPartitioner2 =
                keyedResultNode.getInEdges().get(1).getPartitioner();
    }
Code review comment: This will make the method less error prone in case the contract changes. ```suggestion     return Objects.equals(this.getUserKey(), that.getUserKey())         && Objects.equals(this.getDynamicTimerTag(), that.getDynamicTimerTag())         && Objects.equals(this.getWindows(), that.getWindows())         && (this.getClearBit() == that.getClearBit())         && Objects.equals(this.getFireTimestamp(), that.getFireTimestamp())         && Objects.equals(this.getHoldTimestamp(), that.getHoldTimestamp())         && Objects.equals(this.getPane(), that.getPane());   } ```

Code under review:
public boolean equals(Object other) {
    if (!(other instanceof Timer)) {
      return false;
    }
    Timer<?> that = (Timer<?>) other;
    if (this.getClearBit()) {
      return Objects.equals(this.getUserKey(), that.getUserKey())
          && this.getDynamicTimerTag().equals(that.getDynamicTimerTag())
          && (this.getClearBit() == that.getClearBit())
          && Objects.equals(this.getWindows(), that.getWindows());
    }
    return Objects.equals(this.getUserKey(), that.getUserKey())
        && this.getDynamicTimerTag().equals(that.getDynamicTimerTag())
        && (this.getClearBit() == that.getClearBit())
        && this.getFireTimestamp().equals(that.getFireTimestamp())
        && this.getHoldTimestamp().equals(that.getHoldTimestamp())
        && Objects.equals(this.getWindows(), that.getWindows())
        && Objects.equals(this.getPane(), that.getPane());
  }

Line commented on: && this.getHoldTimestamp().equals(that.getHoldTimestamp())

Revised code:
public boolean equals(Object other) {
    if (!(other instanceof Timer)) {
      return false;
    }
    Timer<?> that = (Timer<?>) other;
    return Objects.equals(this.getUserKey(), that.getUserKey())
        && Objects.equals(this.getDynamicTimerTag(), that.getDynamicTimerTag())
        && Objects.equals(this.getWindows(), that.getWindows())
        && (this.getClearBit() == that.getClearBit())
        && Objects.equals(this.getFireTimestamp(), that.getFireTimestamp())
        && Objects.equals(this.getHoldTimestamp(), that.getHoldTimestamp())
        && Objects.equals(this.getPane(), that.getPane());
  }
Code review comment: Thanks for the tip. Completely forgot that one :)

Code under review:
private static Optional<X509Certificate> getClientCertificate(DiscFilterRequest request) {
        List<X509Certificate> chain = request.getClientCertificateChain();
        if (chain.isEmpty()) return Optional.empty();
        return Optional.of(chain.get(0));
    }

Line commented on: List<X509Certificate> chain = request.getClientCertificateChain();

Revised code:
private static Optional<X509Certificate> getClientCertificate(DiscFilterRequest request) {
        List<X509Certificate> chain = request.getClientCertificateChain();
        if (chain.isEmpty()) return Optional.empty();
        return Optional.of(chain.get(0));
    }
Code review comment: Yeah I guess you are right. I should update it to be on the safe side

Code under review:
static Optional<String> getSpringCacheName(AnnotationInstance annotationInstance) {
        String cacheName = null;
        AnnotationValue cacheNameValue = annotationInstance.value("cacheNames");
        if (cacheNameValue != null) {
            cacheName = singleName(cacheNameValue, annotationInstance.target());
        }
        if (cacheName == null || cacheName.isEmpty()) {
            AnnotationValue value = annotationInstance.value();
            if (value != null) {
                cacheName = singleName(value, annotationInstance.target());
            }
        }
        return cacheName == null ? Optional.empty() : Optional.of(cacheName);
    }

Line commented on: return cacheName == null ? Optional.empty() : Optional.of(cacheName);

Revised code:
static Optional<String> getSpringCacheName(AnnotationInstance annotationInstance) {
        String cacheName = null;
        AnnotationValue cacheNameValue = annotationInstance.value("cacheNames");
        if (cacheNameValue != null) {
            cacheName = singleName(cacheNameValue, annotationInstance.target());
        }
        if (cacheName == null || cacheName.isEmpty()) {
            AnnotationValue value = annotationInstance.value();
            if (value != null) {
                cacheName = singleName(value, annotationInstance.target());
            }
        }
        return (cacheName == null || cacheName.isEmpty()) ? Optional.empty() : Optional.of(cacheName);
    }
Code review comment: shall we check the tag instead ?

Code under review:
public BLangNode transform(IndexedExpressionNode indexedExpressionNode) {
        BLangIndexBasedAccess indexBasedAccess = (BLangIndexBasedAccess) TreeBuilder.createIndexBasedAccessNode();
        indexBasedAccess.pos = getPosition(indexedExpressionNode);
        
        indexBasedAccess.indexExpr = createExpression(indexedExpressionNode.keyExpression().get(0));

        BLangExpression expression = createExpression(indexedExpressionNode.containerExpression());
        if (expression instanceof BLangGroupExpr) {
            indexBasedAccess.expr = ((BLangGroupExpr) expression).expression;
            BLangGroupExpr group = (BLangGroupExpr) TreeBuilder.createGroupExpressionNode();
            group.expression = indexBasedAccess;
            group.pos = getPosition(indexedExpressionNode);
            return group;
        } else if (expression instanceof BLangXMLNavigationAccess) {
            
            ((BLangXMLNavigationAccess) expression).childIndex = indexBasedAccess.indexExpr;
            return expression;
        }
        indexBasedAccess.expr = expression;

        return indexBasedAccess;
    }

Line commented on: if (expression instanceof BLangGroupExpr) {

Revised code:
public BLangNode transform(IndexedExpressionNode indexedExpressionNode) {
        BLangIndexBasedAccess indexBasedAccess = (BLangIndexBasedAccess) TreeBuilder.createIndexBasedAccessNode();
        indexBasedAccess.pos = getPosition(indexedExpressionNode);
        
        indexBasedAccess.indexExpr = createExpression(indexedExpressionNode.keyExpression().get(0));

        Node containerExpr = indexedExpressionNode.containerExpression();
        BLangExpression expression = createExpression(containerExpr);
        if (containerExpr.kind() == SyntaxKind.BRACED_EXPRESSION) {
            indexBasedAccess.expr = ((BLangGroupExpr) expression).expression;
            BLangGroupExpr group = (BLangGroupExpr) TreeBuilder.createGroupExpressionNode();
            group.expression = indexBasedAccess;
            group.pos = getPosition(indexedExpressionNode);
            return group;
        } else if (containerExpr.kind() == SyntaxKind.XML_STEP_EXPRESSION) {
            
            ((BLangXMLNavigationAccess) expression).childIndex = indexBasedAccess.indexExpr;
            return expression;
        }
        indexBasedAccess.expr = expression;

        return indexBasedAccess;
    }
Code review comment: I don't believe reset() should make this dirty since reset() should set this to the state it is at as if it was newly constructed.

Code under review:
public void reset() {
    dirty.afterModification();
    value.set(0L);
  }

Line commented on: dirty.afterModification();

Revised code:
public void reset() {
    dirty.afterModification();
    value.set(0L);
  }
Code review comment: the page size validation may fail.  ```java         int expectedPageSize = (allDatabases.size() + maxItemCount - 1) / maxItemCount;         FeedResponseListValidator<CosmosDatabaseProperties> validator = new FeedResponseListValidator.Builder<CosmosDatabaseProperties>()                 .totalSize(allDatabases.size())                 .exactlyContainsInAnyOrder(allDatabases.stream().map(d -> d.getResourceId()).collect(Collectors.toList()))                 .numberOfPages(expectedPageSize)                 .pageSatisfy(0, new FeedResponseValidator.Builder<CosmosDatabaseProperties>()                         .requestChargeGreaterThanOrEqualTo(1.0).build())                 .build();          validateQuerySuccess(feedObservable.byPage(maxItemCount), validator, FEED_TIMEOUT); ```

Code under review:
public void readDatabases() throws Exception {
        int maxItemCount = 2;

        CosmosPagedFlux<CosmosDatabaseProperties> feedObservable = client.readAllDatabases();

        int expectedPageSize = (allDatabases.size() + maxItemCount - 1) / maxItemCount;
        FeedResponseListValidator<CosmosDatabaseProperties> validator = new FeedResponseListValidator.Builder<CosmosDatabaseProperties>()
                .totalSize(allDatabases.size())
                .exactlyContainsInAnyOrder(allDatabases.stream().map(d -> d.getResourceId()).collect(Collectors.toList()))
                .numberOfPages(expectedPageSize)
                .pageSatisfy(0, new FeedResponseValidator.Builder<CosmosDatabaseProperties>()
                        .requestChargeGreaterThanOrEqualTo(1.0).build())
                .build();

        validateQuerySuccess(feedObservable.byPage(maxItemCount), validator, FEED_TIMEOUT);
    }

Line commented on: int expectedPageSize = (allDatabases.size() + maxItemCount - 1) / maxItemCount;

Revised code:
public void readDatabases() throws Exception {
        int maxItemCount = 2;

        CosmosPagedFlux<CosmosDatabaseProperties> feedObservable = client.readAllDatabases();

        int expectedPageSize = (allDatabases.size() + maxItemCount - 1) / maxItemCount;
        FeedResponseListValidator<CosmosDatabaseProperties> validator = new FeedResponseListValidator.Builder<CosmosDatabaseProperties>()
                .totalSize(allDatabases.size())
                .exactlyContainsInAnyOrder(allDatabases.stream().map(d -> d.getResourceId()).collect(Collectors.toList()))
                .numberOfPages(expectedPageSize)
                .pageSatisfy(0, new FeedResponseValidator.Builder<CosmosDatabaseProperties>()
                        .requestChargeGreaterThanOrEqualTo(1.0).build())
                .build();

        validateQuerySuccess(feedObservable.byPage(maxItemCount), validator, FEED_TIMEOUT);
    }
Code review comment: `HashMap` under the hood uses java's `equals` which is not 100% same as SQL.  We need to use SQL with `equalityEvaluator` like for instance done for `ARRAY_DISTINCT`

Code under review:
public MapDataForMapUnion(MapData map1, MapData map2) {

            this.map = new HashMap<>();
            for (int i = 0; i < map1.size(); i++) {
                final Object key = keyElementGetter.getElementOrNull(map1.keyArray(), i);
                final Object value = valueElementGetter.getElementOrNull(map1.valueArray(), i);
                this.map.put(key, value);
            }
            for (int i = 0; i < map2.size(); i++) {
                final Object key = keyElementGetter.getElementOrNull(map2.keyArray(), i);
                final Object value = valueElementGetter.getElementOrNull(map2.valueArray(), i);
                this.map.put(key, value);
            }
            this.updateArrays();
        }

Line commented on: this.map = new HashMap<>();

Revised code:
public MapDataForMapUnion(MapData map1, MapData map2) throws Throwable {
            List<Object> keysList = new ArrayList<>();
            List<Object> valuesList = new ArrayList<>();
            boolean isKeyNullExist = false;
            ArrayData keyArray2 = map2.keyArray();
            ArrayData valueArray2 = map2.valueArray();
            for (int i = 0; i < map2.size(); i++) {
                Object key = keyElementGetter.getElementOrNull(keyArray2, i);
                if (key == null) {
                    isKeyNullExist = true;
                }
                keysList.add(key);
                valuesList.add(valueElementGetter.getElementOrNull(valueArray2, i));
            }
            ArrayData keyArray1 = map1.keyArray();
            ArrayData valueArray1 = map1.valueArray();
            for (int i = 0; i < map1.size(); i++) {
                final Object key1 = keyElementGetter.getElementOrNull(keyArray1, i);

                boolean keyExists = false;
                if (key1 != null) {
                    for (int j = 0; j < keysList.size(); j++) {
                        final Object key2 = keysList.get(j);
                        if (key2 != null && (boolean) keyEqualityHandle.invoke(key1, key2)) {
                            
                            keyExists = true;
                            break;
                        }
                    }
                }

                if (isKeyNullExist && key1 == null) {
                    continue;
                }

                
                if (!keyExists) {
                    final Object value1 = valueElementGetter.getElementOrNull(valueArray1, i);
                    keysList.add(key1);
                    valuesList.add(value1);
                }
            }
            this.keysArray = new GenericArrayData(keysList.toArray());
            this.valuesArray = new GenericArrayData(valuesList.toArray());
        }
Code review comment: Lets not break at middle of the string value, rather break the line at one of the Paths argument string level.

Code under review:
public void testClientStreamingService() {
        Path balFilePath = Paths.get("src", "test", "resources", "grpc", "grpcservices", "client_streaming_service" +
                ".bal");
        CompileResult result = BCompileUtil.compile(balFilePath.toAbsolutePath().toString());
        Assert.assertEquals(result.getErrorCount(), 0, "Compilation errors in client_streaming_service.bal");
        Assert.assertEquals(result.getAST().getServices().size(), 1, "File should have one service defined.");
        Assert.assertEquals(result.getAST().getServices().get(0).getAnnotationAttachments().size(), 2, "Service " +
                "node should have one default annotation");
        Assert.assertEquals(result.getAST().getServices().get(0).getAnnotationAttachments().get(0).getAnnotationName
                ().getValue(), "ServiceConfig");
        Assert.assertEquals(result.getAST().getServices().get(0).getAnnotationAttachments().get(1).getAnnotationName
                ().getValue(), "ServiceDescriptor");
    }

Line commented on: ".bal");

Revised code:
public void testClientStreamingService() {
        Path balFilePath = Paths.get("src", "test", "resources", "grpc", "grpcservices",
                "client_streaming_service.bal");
        CompileResult result = BCompileUtil.compile(balFilePath.toAbsolutePath().toString());
        assertStreamingCompileResult(result);
    }
Code review comment: It would, but we want to limit this as much as possible to cases that we know don't work otherwise

Code under review:
public boolean canConvert(Class type) {
        return (type != null) && SUPPORTED_CLASS_NAMES.contains(type.getName());
    }

Line commented on: return (type != null) && SUPPORTED_CLASS_NAMES.contains(type.getName());

Revised code:
public boolean canConvert(Class type) {
        return (type != null) && SUPPORTED_CLASS_NAMES.contains(type.getName());
    }
Code review comment: I prefer to have these under ERROR_VARIABLE and default case to check some assert to imply that they are handled?

Code under review:
private BLangTupleVariableDef createTupleVariableDef(BLangVariable tupleVar) {

        BLangTupleVariableDef varDefNode = (BLangTupleVariableDef) TreeBuilder.createTupleVariableDefinitionNode();
        varDefNode.pos = tupleVar.pos;
        varDefNode.setVariable(tupleVar);
        return varDefNode;
    }

Line commented on: varDefNode.setVariable(tupleVar);

Revised code:
private BLangTupleVariableDef createTupleVariableDef(BLangVariable tupleVar) {

        BLangTupleVariableDef varDefNode = (BLangTupleVariableDef) TreeBuilder.createTupleVariableDefinitionNode();
        varDefNode.pos = tupleVar.pos;
        varDefNode.setVariable(tupleVar);
        return varDefNode;
    }
Code review comment: Do you mean something like that, https://github.com/ballerina-platform/ballerina-lang/pull/40287/files#diff-f33fd96d748c9aa10cdf8502de9966c2e338ef4ee796452e8c2ce5ca02d8c67fR777

Code under review:
public void visit(BLangQueryExpr queryExpr) {
        SymbolEnv prevQueryEnv = this.queryEnv;
        boolean prevWithinQuery = withinQuery;
        
        this.withinQuery = true;
        boolean prevAfterGroupBy = this.afterGroupBy;
        this.afterGroupBy = false;
        queryExpr.getQueryClauses().forEach(this::acceptNode);
        this.withinQuery = prevWithinQuery;
        this.queryEnv = prevQueryEnv;
        this.afterGroupBy = prevAfterGroupBy;
    }

Line commented on: boolean prevAfterGroupBy = this.afterGroupBy;

Revised code:
public void visit(BLangQueryExpr queryExpr) {
        SymbolEnv prevQueryEnv = this.queryEnv;
        boolean prevWithinQuery = withinQuery;
        
        this.withinQuery = true;
        boolean prevAfterGroupBy = this.afterGroupBy;
        this.afterGroupBy = false;
        queryExpr.getQueryClauses().forEach(this::acceptNode);
        this.withinQuery = prevWithinQuery;
        this.queryEnv = prevQueryEnv;
        this.afterGroupBy = prevAfterGroupBy;
    }
Code review comment: Do we need to handle more comprehensive cases, e.g., `group by a + 1`?  Maybe use `SlotExtractor` to gather all the input slot references of a group by expression.

Code under review:
public Rule build() {
        return logicalFilter(logicalAggregate()).then(filter -> {
            LogicalAggregate<GroupPlan> aggregate = filter.child();
            Set<Slot> groupBySlots = new HashSet<>();
            for (Expression groupByExpression : aggregate.getGroupByExpressionList()) {
                if (groupByExpression instanceof Slot) {
                    groupBySlots.add((Slot) groupByExpression);
                }
            }
            List<Expression> pushDownPredicates = Lists.newArrayList();
            List<Expression> filterPredicates = Lists.newArrayList();
            ExpressionUtils.extractConjunct(filter.getPredicates()).forEach(conjunct -> {
                Set<Slot> conjunctSlots = SlotExtractor.extractSlot(conjunct);
                if (groupBySlots.containsAll(conjunctSlots)) {
                    pushDownPredicates.add(conjunct);
                } else {
                    
                    filterPredicates.add(conjunct);
                }
            });

            return pushDownPredicate(filter, aggregate, pushDownPredicates, filterPredicates);
        }).toRule(RuleType.PUSH_DOWN_PREDICATE_THROUGH_AGGREGATION);
    }

Line commented on: if (groupByExpression instanceof Slot) {

Revised code:
public Rule build() {
        return logicalFilter(logicalAggregate()).then(filter -> {
            LogicalAggregate<GroupPlan> aggregate = filter.child();
            Set<Slot> groupBySlots = new HashSet<>();
            for (Expression groupByExpression : aggregate.getGroupByExpressionList()) {
                if (groupByExpression instanceof Slot) {
                    groupBySlots.add((Slot) groupByExpression);
                }
            }
            List<Expression> pushDownPredicates = Lists.newArrayList();
            List<Expression> filterPredicates = Lists.newArrayList();
            ExpressionUtils.extractConjunct(filter.getPredicates()).forEach(conjunct -> {
                Set<Slot> conjunctSlots = SlotExtractor.extractSlot(conjunct);
                if (groupBySlots.containsAll(conjunctSlots)) {
                    pushDownPredicates.add(conjunct);
                } else {
                    filterPredicates.add(conjunct);
                }
            });

            return pushDownPredicate(filter, aggregate, pushDownPredicates, filterPredicates);
        }).toRule(RuleType.PUSH_DOWN_PREDICATE_THROUGH_AGGREGATION);
    }
Code review comment: Good point, I have replaced the query logic with using a custom `NoOpBlockingInvokable`.

Code under review:
public void testPutSuspendedJobOnClusterShutdown() throws Exception {
        final Duration timeout = Duration.ofSeconds(5);
        try (final MiniCluster miniCluster =
                new PersistingMiniCluster(new MiniClusterConfiguration.Builder().build())) {
            miniCluster.start();
            final JobVertex vertex = new JobVertex("blockingVertex");
            vertex.setInvokableClass(BlockingNoOpInvokable.class);
            final JobGraph jobGraph = JobGraphTestUtils.streamingJobGraph(vertex);
            final JobID jobId = jobGraph.getJobID();
            miniCluster.submitJob(jobGraph);
            CommonTestUtils.waitUntilCondition(
                    () -> {
                        try {
                            
                            if (miniCluster.getJobStatus(jobId).get() != JobStatus.RUNNING) {
                                return false;
                            }
                        } catch (Exception e) {
                            
                            if (ExceptionUtils.findThrowable(e, FlinkJobNotFoundException.class)
                                    .isPresent()) {
                                return false;
                            }
                            throw e;
                        }
                        
                        
                        for (AccessExecutionVertex executionVertex :
                                miniCluster
                                        .getExecutionGraph(jobId)
                                        .get()
                                        .getAllExecutionVertices()) {
                            if (executionVertex.getExecutionState() == ExecutionState.RUNNING) {
                                continue;
                            }
                            return false;
                        }
                        return true;
                    },
                    Deadline.fromNow(timeout));
        }
    }

Line commented on: if (miniCluster.getJobStatus(jobId).get() != JobStatus.RUNNING) {

Revised code:
public void testPutSuspendedJobOnClusterShutdown() throws Exception {
        try (final MiniCluster miniCluster =
                new PersistingMiniCluster(new MiniClusterConfiguration.Builder().build())) {
            miniCluster.start();
            final JobVertex vertex = new JobVertex("blockingVertex");
            vertex.setInvokableClass(SignallingBlockingNoOpInvokable.class);
            final JobGraph jobGraph = JobGraphTestUtils.streamingJobGraph(vertex);
            miniCluster.submitJob(jobGraph);
            SignallingBlockingNoOpInvokable.LATCH.await();
        }
    }
Code review comment: What if it is not simple var ref but in the member var refs has an invalid assignment?

Code under review:
public void visit(BLangTupleDestructure tupleDeStmt) {
        for (BLangExpression tupleVar : tupleDeStmt.varRef.expressions) {
            setTypeOfVarRefForBindingPattern(tupleVar);
            if (tupleVar.getKind() == NodeKind.SIMPLE_VARIABLE_REF) {
                BLangSimpleVarRef variableRef = (BLangSimpleVarRef) tupleVar;
                if (variableRef.lhsVar && variableRef.symbol != null &&
                        (variableRef.symbol.tag & SymTag.TYPE_DEF) == SymTag.TYPE_DEF) {
                    dlog.error(tupleVar.pos, DiagnosticErrorCode.CANNOT_ASSIGN_VALUE_TO_TYPE_DEF);
                    return;
                }
            }
        }

        if (tupleDeStmt.varRef.restParam != null) {
            setTypeOfVarRefForBindingPattern((BLangExpression) tupleDeStmt.varRef.restParam);
        }

        setTypeOfVarRef(tupleDeStmt.varRef);

        BType type = typeChecker.checkExpr(tupleDeStmt.expr, this.env, tupleDeStmt.varRef.type);

        if (type.tag != TypeTags.SEMANTIC_ERROR) {
            checkTupleVarRefEquivalency(tupleDeStmt.pos, tupleDeStmt.varRef,
                    tupleDeStmt.expr.type, tupleDeStmt.expr.pos);
        }
    }

Line commented on: if (tupleVar.getKind() == NodeKind.SIMPLE_VARIABLE_REF) {

Revised code:
public void visit(BLangTupleDestructure tupleDeStmt) {
        for (BLangExpression tupleVar : tupleDeStmt.varRef.expressions) {
            setTypeOfVarRefForBindingPattern(tupleVar);
            checkInvalidTypeDef(tupleVar);
        }

        if (tupleDeStmt.varRef.restParam != null) {
            setTypeOfVarRefForBindingPattern((BLangExpression) tupleDeStmt.varRef.restParam);
            checkInvalidTypeDef((BLangExpression) tupleDeStmt.varRef.restParam);
        }

        setTypeOfVarRef(tupleDeStmt.varRef);

        BType type = typeChecker.checkExpr(tupleDeStmt.expr, this.env, tupleDeStmt.varRef.type);

        if (type.tag != TypeTags.SEMANTIC_ERROR) {
            checkTupleVarRefEquivalency(tupleDeStmt.pos, tupleDeStmt.varRef,
                    tupleDeStmt.expr.type, tupleDeStmt.expr.pos);
        }
    }
Code review comment: It's not a regex ;) But I have moved it up.

Code under review:
public void visitFieldInsn(int opcode, String owner, String fieldName, String descriptor) {
        
        if ((opcode == Opcodes.GETFIELD
                || opcode == Opcodes.PUTFIELD)
                
                
                && (!this.methodName.equals("<init>")
                        || !targetIsInHierarchy(this.owner.replace('/', '.'), owner.replace('/', '.')))
                && isEntityField(owner.replace('/', '.'), fieldName)) {
            String methodName;
            String methodDescriptor;
            if (opcode == Opcodes.GETFIELD) {
                methodName = JavaBeanUtil.getGetterName(fieldName, descriptor);
                methodDescriptor = "()" + descriptor;
            } else {
                methodName = JavaBeanUtil.getSetterName(fieldName);
                methodDescriptor = "(" + descriptor + ")V";
            }
            if (!owner.equals(this.owner)
                    || !methodName.equals(this.methodName)
                    || !methodDescriptor.equals(this.methodDescriptor)) {
                super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, methodName, methodDescriptor, false);
            } else {
                
                super.visitFieldInsn(opcode, owner, fieldName, descriptor);
            }
        } else {
            super.visitFieldInsn(opcode, owner, fieldName, descriptor);
        }
    }

Line commented on: || !targetIsInHierarchy(this.owner.replace('/', '.'), owner.replace('/', '.')))

Revised code:
public void visitFieldInsn(int opcode, String owner, String fieldName, String descriptor) {
        String ownerName = owner.replace('/', '.');
        if ((opcode == Opcodes.GETFIELD
                || opcode == Opcodes.PUTFIELD)
                
                
                && (!this.methodName.equals("<init>")
                        || !targetIsInHierarchy(this.owner.replace('/', '.'), ownerName))
                && isEntityField(ownerName, fieldName)) {
            String methodName;
            String methodDescriptor;
            if (opcode == Opcodes.GETFIELD) {
                methodName = JavaBeanUtil.getGetterName(fieldName, descriptor);
                methodDescriptor = "()" + descriptor;
            } else {
                methodName = JavaBeanUtil.getSetterName(fieldName);
                methodDescriptor = "(" + descriptor + ")V";
            }
            if (!owner.equals(this.owner)
                    || !methodName.equals(this.methodName)
                    || !methodDescriptor.equals(this.methodDescriptor)) {
                super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, methodName, methodDescriptor, false);
            } else {
                
                super.visitFieldInsn(opcode, owner, fieldName, descriptor);
            }
        } else {
            super.visitFieldInsn(opcode, owner, fieldName, descriptor);
        }
    }
Code review comment: Yeah I too feel like should be moved to the function itself. I'll fix

Code under review:
public void exitInclusiveRecordTypeDescriptor(BallerinaParser.InclusiveRecordTypeDescriptorContext ctx) {
        if (isInErrorState) {
            return;
        }

        boolean isAnonymous = !(ctx.parent.parent instanceof BallerinaParser.FiniteTypeUnitContext);

        
        if (!isAnonymous) {
            isAnonymous = checkIfAnonymousInTypeDef(ctx);
        }

        this.pkgBuilder.addRecordType(getCurrentPos(ctx), getWS(ctx), isAnonymous, false, false);
    }

Line commented on: boolean isAnonymous = !(ctx.parent.parent instanceof BallerinaParser.FiniteTypeUnitContext);

Revised code:
public void exitInclusiveRecordTypeDescriptor(BallerinaParser.InclusiveRecordTypeDescriptorContext ctx) {
        if (isInErrorState) {
            return;
        }

        
        boolean isAnonymous = checkIfAnonymousInTypeDef(ctx);

        this.pkgBuilder.addRecordType(getCurrentPos(ctx), getWS(ctx), isAnonymous, false, false);
    }
Code review comment: Perhaps better `Performs Quarkus pre-build preparations, such as sources generation`

Code under review:
public QuarkusPrepare() {
        super("Quarkus performs pre-build preparations, such as sources generation");
    }

Line commented on: super("Quarkus performs pre-build preparations, such as sources generation");

Revised code:
public QuarkusPrepare() {
        super("Quarkus performs pre-build preparations, such as sources generation");
    }
Code review comment: So can we ignore the exception here with a proper explanation added as a comment and return at the end of the method. That way it is more readable.

Code under review:
private static Path pathWithinZip(URI pathToZip) {
        try {
            URI pathInZip = new URI("jar:" + pathToZip.getScheme(),
                    pathToZip.getUserInfo(), pathToZip.getHost(), pathToZip.getPort(),
                    pathToZip.getPath() + "!/",
                    pathToZip.getQuery(), pathToZip.getFragment());
            initFS(pathInZip);
            return Paths.get(pathInZip);
        } catch (URISyntaxException ex) {
            return Paths.get(pathToZip);
        }
    }

Line commented on: return Paths.get(pathToZip);

Revised code:
private static Path pathWithinZip(URI pathToZip) {
        try {
            URI pathInZip = new URI("jar:" + pathToZip.getScheme(),
                    pathToZip.getUserInfo(), pathToZip.getHost(), pathToZip.getPort(),
                    pathToZip.getPath() + "!/",
                    pathToZip.getQuery(), pathToZip.getFragment());
            initFS(pathInZip);
            return Paths.get(pathInZip);
        } catch (URISyntaxException ignore) {
            
            
            
            
        }
        return Paths.get(pathToZip);
    }
Code review comment: Not really, other than using Beam's state descriptors instead of Flink's. Good point on other state backends potentially allowing to iterate over the keys without materializing first. Have reverted this back to the old behavior.

Code under review:
public void clearGlobalState() {
    try {
      for (StateTag stateTag : globalWindowStateTags) {
        State state =
            state(
                globalWindowNamespace,
                stateTag,
                StateContexts.windowOnlyContext(GlobalWindow.INSTANCE));
        
        
        List<ByteBuffer> keys =
            flinkStateBackend
                .getKeys(stateTag.getId(), globalWindowNamespace.stringKey())
                .collect(Collectors.toList());
        for (ByteBuffer key : keys) {
          flinkStateBackend.setCurrentKey(key);
          state.clear();
        }
      }
      
      globalWindowStateTags.clear();
    } catch (Exception e) {
      throw new RuntimeException("Failed to cleanup global state.", e);
    }
  }


Revised code:
public void clearGlobalState() {
    try {
      for (StateDescriptor stateDescriptor : globalWindowStateDescriptors) {
        flinkStateBackend.applyToAllKeys(
            globalWindowNamespace.stringKey(),
            StringSerializer.INSTANCE,
            stateDescriptor,
            (key, state) -> state.clear());
      }
      
      globalWindowStateDescriptors.clear();
    } catch (Exception e) {
      throw new RuntimeException("Failed to cleanup global state.", e);
    }
  }