Re: [PR] Fixes GitHub issue #30257 [beam]
je-ik merged PR #32074: URL: https://github.com/apache/beam/pull/32074 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Fixes GitHub issue #30257 [beam]
kirupha2000 commented on code in PR #32074: URL: https://github.com/apache/beam/pull/32074#discussion_r1715410401 ## sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/SerializableComparatorTest.java: ## @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.beam.sdk.transforms; + +import java.io.Serializable; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link SerializableComparator}. */ +@RunWith(JUnit4.class) +public class SerializableComparatorTest { + + /** Basic test of {@link SerializableComparator} being {@link java.io.Serializable}. */ + @Test + public void testIfImplementsSerializable() { +SerializableFunction fn = Integer::parseInt; + +SerializableComparator cmp = SerializableComparator.comparing(fn); +Assert.assertTrue(cmp instanceof Serializable); Review Comment: Re-added the original tests and used `org.apache.beam.sdk.util.SerializableUtils#ensureSerializable(T)`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Fixes GitHub issue #30257 [beam]
je-ik commented on code in PR #32074: URL: https://github.com/apache/beam/pull/32074#discussion_r1714824028 ## sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/SerializableComparator.java: ## @@ -19,10 +19,29 @@ import java.io.Serializable; import java.util.Comparator; +import java.util.Objects; +import java.util.function.Function; /** * A {@code Comparator} that is also {@code Serializable}. * * @param type of values being compared */ -public interface SerializableComparator extends Comparator, Serializable {} +public interface SerializableComparator extends Comparator, Serializable { + /** + * Analogous to {@link Comparator#comparing(Function)}, except that it takes in a {@link + * SerializableFunction} as the key extractor and returns a {@link SerializableComparator}. + * + * @param keyExtractor the function used to extract the {@link java.lang.Comparable} sort key + * @return A {@link SerializableComparator} that compares by an extracted key + * @param the type of element to be compared + * @param the type of the {@code Comparable} sort key + * @see Comparator#comparing(Function) + */ + static > SerializableComparator comparing( + SerializableFunction keyExtractor) { Review Comment: :+1: ## sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/SerializableComparator.java: ## @@ -19,10 +19,29 @@ import java.io.Serializable; import java.util.Comparator; +import java.util.Objects; +import java.util.function.Function; /** * A {@code Comparator} that is also {@code Serializable}. * * @param type of values being compared */ -public interface SerializableComparator extends Comparator, Serializable {} +public interface SerializableComparator extends Comparator, Serializable { + /** + * Analogous to {@link Comparator#comparing(Function)}, except that it takes in a {@link + * SerializableFunction} as the key extractor and returns a {@link SerializableComparator}. + * + * @param keyExtractor the function used to extract the {@link java.lang.Comparable} sort key + * @return A {@link SerializableComparator} that compares by an extracted key + * @param the type of element to be compared + * @param the type of the {@code Comparable} sort key + * @see Comparator#comparing(Function) + */ + static > SerializableComparator comparing( Review Comment: Makes sense. :+1: -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Fixes GitHub issue #30257 [beam]
je-ik commented on code in PR #32074: URL: https://github.com/apache/beam/pull/32074#discussion_r1714815846 ## sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/SerializableComparatorTest.java: ## @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.beam.sdk.transforms; + +import java.io.Serializable; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link SerializableComparator}. */ +@RunWith(JUnit4.class) +public class SerializableComparatorTest { + + /** Basic test of {@link SerializableComparator} being {@link java.io.Serializable}. */ + @Test + public void testIfImplementsSerializable() { +SerializableFunction fn = Integer::parseInt; + +SerializableComparator cmp = SerializableComparator.comparing(fn); +Assert.assertTrue(cmp instanceof Serializable); Review Comment: Yes, that is exactly the method to use. :+1: -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Fixes GitHub issue #30257 [beam]
kirupha2000 commented on code in PR #32074: URL: https://github.com/apache/beam/pull/32074#discussion_r1714591192 ## sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/SerializableComparatorTest.java: ## @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.beam.sdk.transforms; + +import java.io.Serializable; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link SerializableComparator}. */ +@RunWith(JUnit4.class) +public class SerializableComparatorTest { + + /** Basic test of {@link SerializableComparator} being {@link java.io.Serializable}. */ + @Test + public void testIfImplementsSerializable() { +SerializableFunction fn = Integer::parseInt; + +SerializableComparator cmp = SerializableComparator.comparing(fn); +Assert.assertTrue(cmp instanceof Serializable); Review Comment: Would it be sufficient to check if the returned `Comparator` is serializable using `org.apache.beam.sdk.util.SerializableUtils#ensureSerializable(T)` or should we check using something else? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Fixes GitHub issue #30257 [beam]
kirupha2000 commented on code in PR #32074: URL: https://github.com/apache/beam/pull/32074#discussion_r1714587676 ## sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/SerializableComparator.java: ## @@ -19,10 +19,29 @@ import java.io.Serializable; import java.util.Comparator; +import java.util.Objects; +import java.util.function.Function; /** * A {@code Comparator} that is also {@code Serializable}. * * @param type of values being compared */ -public interface SerializableComparator extends Comparator, Serializable {} +public interface SerializableComparator extends Comparator, Serializable { + /** + * Analogous to {@link Comparator#comparing(Function)}, except that it takes in a {@link + * SerializableFunction} as the key extractor and returns a {@link SerializableComparator}. + * + * @param keyExtractor the function used to extract the {@link java.lang.Comparable} sort key + * @return A {@link SerializableComparator} that compares by an extracted key + * @param the type of element to be compared + * @param the type of the {@code Comparable} sort key + * @see Comparator#comparing(Function) + */ + static > SerializableComparator comparing( Review Comment: I think it does not have any advantages in this context since the `comparing` method here takes in a `SerializableFunction`, meaning, because of the `? extends V` it would accept any type that is a sub type of `Comparable` as per my understanding. But I had the `? super V`, following the "**P**roducers **E**xtends **C**onsumers **S**uper" general rule of thumb just in case to be safe. ## sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/SerializableComparator.java: ## @@ -19,10 +19,29 @@ import java.io.Serializable; import java.util.Comparator; +import java.util.Objects; +import java.util.function.Function; /** * A {@code Comparator} that is also {@code Serializable}. * * @param type of values being compared */ -public interface SerializableComparator extends Comparator, Serializable {} +public interface SerializableComparator extends Comparator, Serializable { + /** + * Analogous to {@link Comparator#comparing(Function)}, except that it takes in a {@link + * SerializableFunction} as the key extractor and returns a {@link SerializableComparator}. + * + * @param keyExtractor the function used to extract the {@link java.lang.Comparable} sort key + * @return A {@link SerializableComparator} that compares by an extracted key + * @param the type of element to be compared + * @param the type of the {@code Comparable} sort key + * @see Comparator#comparing(Function) + */ + static > SerializableComparator comparing( + SerializableFunction keyExtractor) { Review Comment: Same here, wasn't able to think of a scenario where this would be useful but added it anyways, following **PECS**, just in case. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Fixes GitHub issue #30257 [beam]
je-ik commented on code in PR #32074: URL: https://github.com/apache/beam/pull/32074#discussion_r1714090124 ## sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/SerializableComparator.java: ## @@ -19,10 +19,29 @@ import java.io.Serializable; import java.util.Comparator; +import java.util.Objects; +import java.util.function.Function; /** * A {@code Comparator} that is also {@code Serializable}. * * @param type of values being compared */ -public interface SerializableComparator extends Comparator, Serializable {} +public interface SerializableComparator extends Comparator, Serializable { + /** + * Analogous to {@link Comparator#comparing(Function)}, except that it takes in a {@link + * SerializableFunction} as the key extractor and returns a {@link SerializableComparator}. + * + * @param keyExtractor the function used to extract the {@link java.lang.Comparable} sort key + * @return A {@link SerializableComparator} that compares by an extracted key + * @param the type of element to be compared + * @param the type of the {@code Comparable} sort key + * @see Comparator#comparing(Function) + */ + static > SerializableComparator comparing( Review Comment: I wonder, why `? super V` and not using `V` directly? Does it have any advantages? ## sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/SerializableComparator.java: ## @@ -19,10 +19,29 @@ import java.io.Serializable; import java.util.Comparator; +import java.util.Objects; +import java.util.function.Function; /** * A {@code Comparator} that is also {@code Serializable}. * * @param type of values being compared */ -public interface SerializableComparator extends Comparator, Serializable {} +public interface SerializableComparator extends Comparator, Serializable { + /** + * Analogous to {@link Comparator#comparing(Function)}, except that it takes in a {@link + * SerializableFunction} as the key extractor and returns a {@link SerializableComparator}. + * + * @param keyExtractor the function used to extract the {@link java.lang.Comparable} sort key + * @return A {@link SerializableComparator} that compares by an extracted key + * @param the type of element to be compared + * @param the type of the {@code Comparable} sort key + * @see Comparator#comparing(Function) + */ + static > SerializableComparator comparing( + SerializableFunction keyExtractor) { Review Comment: Same here probably for `T`? ## sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/SerializableComparatorTest.java: ## @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.beam.sdk.transforms; + +import java.io.Serializable; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link SerializableComparator}. */ +@RunWith(JUnit4.class) +public class SerializableComparatorTest { + + /** Basic test of {@link SerializableComparator} being {@link java.io.Serializable}. */ + @Test + public void testIfImplementsSerializable() { +SerializableFunction fn = Integer::parseInt; + +SerializableComparator cmp = SerializableComparator.comparing(fn); +Assert.assertTrue(cmp instanceof Serializable); Review Comment: This does not imply that the instance can be serialized. It would be better to use the `SerializableUtils` to check the serialization and deserialization. ## sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/SerializableComparatorTest.java: ## @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing
Re: [PR] Fixes GitHub issue #30257 [beam]
je-ik commented on PR #32074: URL: https://github.com/apache/beam/pull/32074#issuecomment-2283318883 Also please squash the change to single commit. There is a documentation about how to structure granularity of commits in https://github.com/apache/beam/blob/master/contributor-docs/committer-guide.md. Thanks! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Fixes GitHub issue #30257 [beam]
je-ik commented on PR #32074: URL: https://github.com/apache/beam/pull/32074#issuecomment-2277215703 Hi @kirupha2000 , I'm sorry, I'm OOO, currently. I will take a look at this next week. Thanks for the contribution! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Fixes GitHub issue #30257 [beam]
kirupha2000 commented on PR #32074: URL: https://github.com/apache/beam/pull/32074#issuecomment-2271690170 Hi @je-ik , it took a while for me to figure out that there were some check style errors in the code😅. I've fixed those but looks like there are some checks failing that passed in the previous commit. Can you please guide me here if it's anything that I should fix on my end? Thanks! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Fixes GitHub issue #30257 [beam]
github-actions[bot] commented on PR #32074: URL: https://github.com/apache/beam/pull/32074#issuecomment-2267420228 Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment `assign set of reviewers` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Fixes GitHub issue #30257 [beam]
je-ik commented on PR #32074: URL: https://github.com/apache/beam/pull/32074#issuecomment-2267419709 R: @je-ik -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Fixes GitHub issue #30257 [beam]
github-actions[bot] commented on PR #32074: URL: https://github.com/apache/beam/pull/32074#issuecomment-2267358689 Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment `assign set of reviewers` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Fixes GitHub issue #30257 [beam]
codecov[bot] commented on PR #32074: URL: https://github.com/apache/beam/pull/32074#issuecomment-2267350776 ## [Codecov](https://app.codecov.io/gh/apache/beam/pull/32074?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report All modified and coverable lines are covered by tests :white_check_mark: > Project coverage is 58.66%. Comparing base [(`bf42a81`)](https://app.codecov.io/gh/apache/beam/commit/bf42a8153af582e4dd97140bebf1a829f35dfe20?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`a89b7b9`)](https://app.codecov.io/gh/apache/beam/commit/a89b7b9d207e1651d7a7272d73fcb4087732b735?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache). > Report is 1 commits behind head on master. Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #32074 +/- ## + Coverage 57.18% 58.66% +1.48% - Complexity 1474 3023+1549 Files 963 1121 +158 Lines152697 172724 +20027 Branches 1076 3275+2199 + Hits 87313 101336 +14023 - Misses6320268084+4882 - Partials 2182 3304+1122 ``` | [Flag](https://app.codecov.io/gh/apache/beam/pull/32074/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | |---|---|---| | [java](https://app.codecov.io/gh/apache/beam/pull/32074/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `69.60% <ø> (+1.03%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more. [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/beam/pull/32074?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache). :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org