luoyuxia commented on code in PR #2274: URL: https://github.com/apache/fluss/pull/2274#discussion_r2659648409
########## fluss-common/src/test/java/org/apache/fluss/bucketing/BucketingFunctionTest.java: ########## @@ -0,0 +1,124 @@ +/* + * 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.fluss.bucketing; + +import org.apache.fluss.metadata.DataLakeFormat; + +import org.junit.jupiter.api.Test; + +import java.nio.charset.StandardCharsets; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Unit test for {@link BucketingFunction}. Rust client side has similar tests to ensure hashing Review Comment: ```suggestion /** * Unit tests for {@link BucketingFunction}. * * <p>Maintains parity with Rust client tests to guarantee cross-client * hashing consistency. */ ``` ########## fluss-common/src/test/java/org/apache/fluss/bucketing/BucketingFunctionTest.java: ########## @@ -0,0 +1,124 @@ +/* + * 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.fluss.bucketing; + +import org.apache.fluss.metadata.DataLakeFormat; + +import org.junit.jupiter.api.Test; + +import java.nio.charset.StandardCharsets; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Unit test for {@link BucketingFunction}. Rust client side has similar tests to ensure hashing + * consistency + */ +public class BucketingFunctionTest { + @Test + public void testDefaultBucketing() { + BucketingFunction defaultBucketing = BucketingFunction.of(null); + + assertThat(defaultBucketing.bucketing(new byte[] {(byte) 0, (byte) 10}, 7)).isEqualTo(1); + assertThat( + defaultBucketing.bucketing( + new byte[] {(byte) 0, (byte) 10, (byte) 10, (byte) 10}, 12)) + .isEqualTo(0); + assertThat( + defaultBucketing.bucketing( + "2bb87d68-baf9-4e64-90f9-f80910419fa6" + .getBytes(StandardCharsets.UTF_8), + 16)) + .isEqualTo(6); + assertThat( + defaultBucketing.bucketing( + "The quick brown fox jumps over the lazy dog" + .getBytes(StandardCharsets.UTF_8), + 8)) + .isEqualTo(6); + } + + @Test + public void testPaimonBucketing() { + BucketingFunction paimonBucketing = BucketingFunction.of(DataLakeFormat.PAIMON); + + assertThat(paimonBucketing.bucketing(new byte[] {(byte) 0, (byte) 10}, 7)).isEqualTo(1); + assertThat( + paimonBucketing.bucketing( + new byte[] {(byte) 0, (byte) 10, (byte) 10, (byte) 10}, 12)) + .isEqualTo(11); + assertThat( + paimonBucketing.bucketing( + "2bb87d68-baf9-4e64-90f9-f80910419fa6" + .getBytes(StandardCharsets.UTF_8), + 16)) + .isEqualTo(12); + assertThat( + paimonBucketing.bucketing( + "The quick brown fox jumps over the lazy dog" + .getBytes(StandardCharsets.UTF_8), + 8)) + .isEqualTo(0); + } + + @Test + public void testLanceBucketing() { Review Comment: ```suggestion void testLanceBucketing() { ``` ########## fluss-common/src/test/java/org/apache/fluss/bucketing/BucketingFunctionTest.java: ########## @@ -0,0 +1,124 @@ +/* + * 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.fluss.bucketing; + +import org.apache.fluss.metadata.DataLakeFormat; + +import org.junit.jupiter.api.Test; + +import java.nio.charset.StandardCharsets; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Unit test for {@link BucketingFunction}. Rust client side has similar tests to ensure hashing + * consistency + */ +public class BucketingFunctionTest { + @Test + public void testDefaultBucketing() { + BucketingFunction defaultBucketing = BucketingFunction.of(null); + + assertThat(defaultBucketing.bucketing(new byte[] {(byte) 0, (byte) 10}, 7)).isEqualTo(1); + assertThat( + defaultBucketing.bucketing( + new byte[] {(byte) 0, (byte) 10, (byte) 10, (byte) 10}, 12)) + .isEqualTo(0); + assertThat( + defaultBucketing.bucketing( + "2bb87d68-baf9-4e64-90f9-f80910419fa6" + .getBytes(StandardCharsets.UTF_8), + 16)) + .isEqualTo(6); + assertThat( + defaultBucketing.bucketing( + "The quick brown fox jumps over the lazy dog" + .getBytes(StandardCharsets.UTF_8), + 8)) + .isEqualTo(6); + } + + @Test + public void testPaimonBucketing() { Review Comment: nit: ```suggestion void testPaimonBucketing() { ``` ########## fluss-common/src/test/java/org/apache/fluss/bucketing/BucketingFunctionTest.java: ########## @@ -0,0 +1,124 @@ +/* + * 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.fluss.bucketing; + +import org.apache.fluss.metadata.DataLakeFormat; + +import org.junit.jupiter.api.Test; + +import java.nio.charset.StandardCharsets; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Unit test for {@link BucketingFunction}. Rust client side has similar tests to ensure hashing + * consistency + */ +public class BucketingFunctionTest { + @Test + public void testDefaultBucketing() { Review Comment: nit: ```suggestion void testDefaultBucketing() { ``` ########## fluss-common/src/test/java/org/apache/fluss/bucketing/BucketingFunctionTest.java: ########## @@ -0,0 +1,124 @@ +/* + * 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.fluss.bucketing; + +import org.apache.fluss.metadata.DataLakeFormat; + +import org.junit.jupiter.api.Test; + +import java.nio.charset.StandardCharsets; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Unit test for {@link BucketingFunction}. Rust client side has similar tests to ensure hashing + * consistency + */ +public class BucketingFunctionTest { Review Comment: nit: ```suggestion class BucketingFunctionTest { ``` ########## fluss-common/src/test/java/org/apache/fluss/bucketing/BucketingFunctionTest.java: ########## @@ -0,0 +1,124 @@ +/* + * 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.fluss.bucketing; + +import org.apache.fluss.metadata.DataLakeFormat; + +import org.junit.jupiter.api.Test; + +import java.nio.charset.StandardCharsets; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Unit test for {@link BucketingFunction}. Rust client side has similar tests to ensure hashing + * consistency + */ +public class BucketingFunctionTest { + @Test + public void testDefaultBucketing() { + BucketingFunction defaultBucketing = BucketingFunction.of(null); + + assertThat(defaultBucketing.bucketing(new byte[] {(byte) 0, (byte) 10}, 7)).isEqualTo(1); + assertThat( + defaultBucketing.bucketing( + new byte[] {(byte) 0, (byte) 10, (byte) 10, (byte) 10}, 12)) + .isEqualTo(0); + assertThat( + defaultBucketing.bucketing( + "2bb87d68-baf9-4e64-90f9-f80910419fa6" + .getBytes(StandardCharsets.UTF_8), + 16)) + .isEqualTo(6); + assertThat( + defaultBucketing.bucketing( + "The quick brown fox jumps over the lazy dog" + .getBytes(StandardCharsets.UTF_8), + 8)) + .isEqualTo(6); + } + + @Test + public void testPaimonBucketing() { + BucketingFunction paimonBucketing = BucketingFunction.of(DataLakeFormat.PAIMON); + + assertThat(paimonBucketing.bucketing(new byte[] {(byte) 0, (byte) 10}, 7)).isEqualTo(1); + assertThat( + paimonBucketing.bucketing( + new byte[] {(byte) 0, (byte) 10, (byte) 10, (byte) 10}, 12)) + .isEqualTo(11); + assertThat( + paimonBucketing.bucketing( + "2bb87d68-baf9-4e64-90f9-f80910419fa6" + .getBytes(StandardCharsets.UTF_8), + 16)) + .isEqualTo(12); + assertThat( + paimonBucketing.bucketing( + "The quick brown fox jumps over the lazy dog" + .getBytes(StandardCharsets.UTF_8), + 8)) + .isEqualTo(0); + } + + @Test + public void testLanceBucketing() { + BucketingFunction lanceBucketing = BucketingFunction.of(DataLakeFormat.LANCE); + + assertThat(lanceBucketing.bucketing(new byte[] {(byte) 0, (byte) 10}, 7)).isEqualTo(1); + assertThat( + lanceBucketing.bucketing( + new byte[] {(byte) 0, (byte) 10, (byte) 10, (byte) 10}, 12)) + .isEqualTo(0); + assertThat( + lanceBucketing.bucketing( + "2bb87d68-baf9-4e64-90f9-f80910419fa6" + .getBytes(StandardCharsets.UTF_8), + 16)) + .isEqualTo(6); + assertThat( + lanceBucketing.bucketing( + "The quick brown fox jumps over the lazy dog" + .getBytes(StandardCharsets.UTF_8), + 8)) + .isEqualTo(6); + } + + @Test + public void testIcebergBucketing() { Review Comment: ```suggestion void testIcebergBucketing() { ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
