You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "nhuantho (via GitHub)" <gi...@apache.org> on 2026/03/09 08:37:58 UTC
[PR] [fluss-client] Support Complex Data Types on the Java Typed API (Map and Array) [fluss]
nhuantho opened a new pull request, #2814:
URL: https://github.com/apache/fluss/pull/2814
<!--
*Thank you very much for contributing to Fluss - we are happy that you want to help us improve Fluss. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [GitHub issue](https://github.com/apache/fluss/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no issue.
- Name the pull request in the format "[component] Title of the pull request", where *[component]* should be replaced by the name of the component being changed. Typically, this corresponds to the component label assigned to the issue (e.g., [kv], [log], [client], [flink]). Skip *[component]* if you are unsure about which is the best component.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes.
- Each pull request should address only one issue, not mix up code from multiple issues.
**(The sections below can be removed for hotfixes or typos)**
-->
### Purpose
<!-- Linking this pull request to the issue -->
Linked issue: close https://github.com/apache/fluss/issues/2805
* This PR adds support for `ARRAY` and `MAP` types when converting between `Fluss internal types` and `POJO types`.
<!-- What is the purpose of the change -->
### Brief change log
* New Utilities
* Created `FlussTypeToPojoTypeConverter`: shared utilities for converting Fluss types to POJO types.
* Moved `charLengthExceptionMessage` to `ConverterCommons`, since it is used by both:
* `toBinaryStringForText` in `ConverterCommons`.
* `convertTextValue` in `FlussTypeToPojoTypeConverter`.
* New Adapter Classes:
* Created `FlussArrayToPojoArray`: converts Fluss InternalArray → POJO array.
* Created `FlussMapToPojoMap`: converts Fluss InternalMap → POJO Map.
* Created `PojoArrayToFlussArray`: converts POJO array → Fluss InternalArray.
* Created `PojoMapToFlussMap`: converts POJO Map → Fluss InternalMap.
* Converter Updates
* Added support for `ARRAY` and `MAP` in:
* `PojoToRowConverter`.
* `RowToPojoConverter`.
<!-- Please describe the changes made in this pull request and explain how they address the issue -->
### Tests
* Updated `ConvertersTestFixtures` to include logic for `MAP` and `ARRAY` types.
* Added `FlussArrayToPojoArrayTest` to verify all array conversion cases.
* Added `PojoArrayToFlussArrayTest` to verify all array conversion cases.
* Added testMapType in:
* `PojoToRowConverterTest`.
* `RowToPojoConverterTest`.
* Removed `testUnsupportedSchemaFieldTypeThrows` from `PojoToRowConverterTest`.
<!-- List UT and IT cases to verify this change -->
### API and Format
<!-- Does this change affect API or storage format -->
### Documentation
<!-- Does this change introduce a new feature -->
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fluss-client] Support Complex Data Types on the Java Typed API (Map and Array) [fluss]
Posted by "nhuantho (via GitHub)" <gi...@apache.org>.
nhuantho commented on code in PR #2814:
URL: https://github.com/apache/fluss/pull/2814#discussion_r2905795162
##########
website/docs/_configs/_partial_config.mdx:
##########
@@ -284,7 +284,7 @@
| `table.auto-partition.enabled` | `false` | Boolean | Whether enable auto partition for the table. Disable by default. When auto partition is enabled, the partitions of the table will be created automatically. |
| `table.auto-partition.key` | `none` | String | This configuration defines the time-based partition key to be used for auto-partitioning when a table is partitioned with multiple keys. Auto-partitioning utilizes a time-based partition key to handle partitions automatically, including creating new ones and removing outdated ones, by comparing the time value of the partition with the current system time. In the case of a table using multiple partition keys (such as a composite partitioning strategy), this feature determines which key should serve as the primary time dimension for making auto-partitioning decisions.And If the table has only one partition key, this config is not necessary. Otherwise, it must be specified. |
| `table.auto-partition.time-unit` | `DAY` | AutoPartitionTimeUnit | The time granularity for auto created partitions. The default value is `DAY`. Valid values are `HOUR`, `DAY`, `MONTH`, `QUARTER`, `YEAR`. If the value is `HOUR`, the partition format for auto created is yyyyMMddHH. If the value is `DAY`, the partition format for auto created is yyyyMMdd. If the value is `MONTH`, the partition format for auto created is yyyyMM. If the value is `QUARTER`, the partition format for auto created is yyyyQ. If the value is `YEAR`, the partition format for auto created is yyyy. |
-| `table.auto-partition.time-zone` | `Europe/Paris` | String | The time zone for auto partitions, which is by default the same as the system time zone. |
+| `table.auto-partition.time-zone` | `Asia/Ho_Chi_Minh` | String | The time zone for auto partitions, which is by default the same as the system time zone. |
Review Comment:
It changed when I ran the test, but I will remove it.
##########
website/docs/_configs/_partial_config.mdx:
##########
@@ -78,7 +78,7 @@
| `client.lookup.batch-timeout` | `0 s` | Duration | The maximum time to wait for the lookup batch to full, if this timeout is reached, the lookup batch will be closed to send. |
| `client.lookup.max-retries` | `2147483647` | Integer | Setting a value greater than zero will cause the client to resend any lookup request that fails with a potentially transient error. |
| `client.scanner.remote-log.prefetch-num` | `4` | Integer | The number of remote log segments to keep in local temp file for LogScanner, which download from remote storage. The default setting is 4. |
-| `client.scanner.io.tmpdir` | `/var/folders/bp/v2l48kz51mx86d743qv0zhzh0000gn/T//fluss` | String | Local directory that is used by client for storing the data files (like kv snapshot, log segment files) to read temporarily |
+| `client.scanner.io.tmpdir` | `/var/folders/p1/4yvqmcrs6n92xl_w_k3z43th0000gn/T//fluss` | String | Local directory that is used by client for storing the data files (like kv snapshot, log segment files) to read temporarily |
Review Comment:
It changed when I ran the test, but I will remove it.
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fluss-client] Support Complex Data Types on the Java Typed API (Map and Array) [fluss]
Posted by "nhuantho (via GitHub)" <gi...@apache.org>.
nhuantho commented on PR #2814:
URL: https://github.com/apache/fluss/pull/2814#issuecomment-4028334822
Hi @polyzos, could you review it again for me?
* Changed the `PojoMapToFlussMap` lazy `InternalMap` approach to an eager conversion, consistent with how `PojoArrayToFlussArray` works.
* Updated the `validateCompatibility` logic for `MAP` and `ARRAY` types.
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fluss-client] Support Complex Data Types on the Java Typed API (Map and Array) [fluss]
Posted by "polyzos (via GitHub)" <gi...@apache.org>.
polyzos commented on PR #2814:
URL: https://github.com/apache/fluss/pull/2814#issuecomment-4023509355
@nhuantho thank you for your contribution. It's almost there, and I left a few comments.
One design issue worth resolving alongside the above: the **PojoMaptoFlussMap** lazy InternalMap approach should be replaced with an eager conversion consistent with how PojoArrayToFlussArray works.
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fluss-client] Support Complex Data Types on the Java Typed API (Map and Array) [fluss]
Posted by "nhuantho (via GitHub)" <gi...@apache.org>.
nhuantho commented on code in PR #2814:
URL: https://github.com/apache/fluss/pull/2814#discussion_r2909063897
##########
fluss-client/src/main/java/org/apache/fluss/client/converter/ConverterCommons.java:
##########
@@ -63,6 +64,8 @@ private static Map<DataTypeRoot, Set<Class<?>>> createSupportedTypes() {
map.put(
DataTypeRoot.TIMESTAMP_WITH_LOCAL_TIME_ZONE,
setOf(java.time.Instant.class, java.time.OffsetDateTime.class));
+ map.put(DataTypeRoot.ARRAY, setOf(java.util.Arrays.class));
Review Comment:
I changed the validateCompatibility logic for MAP and ARRAY types.
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fluss-client] Support Complex Data Types on the Java Typed API (Map and Array) [fluss]
Posted by "polyzos (via GitHub)" <gi...@apache.org>.
polyzos commented on PR #2814:
URL: https://github.com/apache/fluss/pull/2814#issuecomment-4037477528
@nhuantho Thank you for this.. i pushed some small improvements and added test to the existing `FlussTypedClientITCase` for end2end scenarios.
I will merge once CI passes
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fluss-client] Support Complex Data Types on the Java Typed API (Map and Array) [fluss]
Posted by "nhuantho (via GitHub)" <gi...@apache.org>.
nhuantho commented on code in PR #2814:
URL: https://github.com/apache/fluss/pull/2814#discussion_r2909060911
##########
fluss-client/src/main/java/org/apache/fluss/client/converter/ConverterCommons.java:
##########
@@ -42,6 +41,8 @@
final class ConverterCommons {
static final Map<DataTypeRoot, Set<Class<?>>> SUPPORTED_TYPES = createSupportedTypes();
+ static final Set<DataTypeRoot> SUPPORTED_COMPLEX_TYPES =
+ EnumSet.of(DataTypeRoot.ARRAY, DataTypeRoot.MAP);
Review Comment:
Yes, I removed it.
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fluss-client] Support Complex Data Types on the Java Typed API (Map and Array) [fluss]
Posted by "polyzos (via GitHub)" <gi...@apache.org>.
polyzos commented on code in PR #2814:
URL: https://github.com/apache/fluss/pull/2814#discussion_r2905166155
##########
fluss-client/src/test/java/org/apache/fluss/client/converter/RowToPojoConverterTest.java:
##########
@@ -41,7 +44,7 @@ public void testRoundTripFullSchema() {
ConvertersTestFixtures.TestPojo pojo = ConvertersTestFixtures.TestPojo.sample();
GenericRow row = writer.toRow(pojo);
- assertThat(row.getFieldCount()).isEqualTo(15);
+ assertThat(row.getFieldCount()).isEqualTo(17);
Review Comment:
why changes this?
##########
fluss-client/src/main/java/org/apache/fluss/client/converter/PojoArrayToFlussArray.java:
##########
@@ -0,0 +1,137 @@
+/*
+ * 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.client.converter;
+
+import org.apache.fluss.row.GenericArray;
+import org.apache.fluss.types.ArrayType;
+import org.apache.fluss.types.DataType;
+import org.apache.fluss.types.DataTypeChecks;
+import org.apache.fluss.types.DecimalType;
+import org.apache.fluss.types.MapType;
+
+import javax.annotation.Nullable;
+
+import java.util.Collection;
+import java.util.Map;
+
+/** Adapter class for converting Pojo Array to Fluss InternalArray. */
+public class PojoArrayToFlussArray {
+ private final Object obj;
+ private final DataType fieldType;
+ private final String fieldName;
+
+ public PojoArrayToFlussArray(Object obj, DataType fieldType, String fieldName) {
+ this.obj = obj;
+ this.fieldType = fieldType;
+ this.fieldName = fieldName;
+ }
+
+ public GenericArray convertArray() {
+ if (obj == null) {
+ return null;
+ }
+
+ ArrayType arrayType = (ArrayType) fieldType;
+ DataType elementType = arrayType.getElementType();
+
+ // Handle primitive arrays directly
+ if (obj instanceof Boolean[]) {
Review Comment:
The fast-path only checks boxed types (Boolean[], Long[], etc.). A field declared as int[], long[], boolean[], etc. will not match any instanceof check and throw an IllegalArgumentException at runtime with a misleading message. Add explicit handling for each primitive array type (e.g. int[], long[], double[], float[], boolean[], short[], byte[]) alongside the existing boxed checks.
##########
fluss-client/src/main/java/org/apache/fluss/client/converter/ConverterCommons.java:
##########
@@ -120,14 +123,21 @@ static void validateCompatibility(DataType fieldType, PojoType.Property prop) {
"Unsupported field type %s for field %s.",
fieldType.getTypeRoot(), prop.name));
}
- if (!supported.contains(actual)) {
+ if (!supported.contains(actual)
+ & !SUPPORTED_COMPLEX_TYPES.contains(fieldType.getTypeRoot())) {
Review Comment:
did you mean && here?
##########
website/docs/_configs/_partial_config.mdx:
##########
@@ -78,7 +78,7 @@
| `client.lookup.batch-timeout` | `0 s` | Duration | The maximum time to wait for the lookup batch to full, if this timeout is reached, the lookup batch will be closed to send. |
| `client.lookup.max-retries` | `2147483647` | Integer | Setting a value greater than zero will cause the client to resend any lookup request that fails with a potentially transient error. |
| `client.scanner.remote-log.prefetch-num` | `4` | Integer | The number of remote log segments to keep in local temp file for LogScanner, which download from remote storage. The default setting is 4. |
-| `client.scanner.io.tmpdir` | `/var/folders/bp/v2l48kz51mx86d743qv0zhzh0000gn/T//fluss` | String | Local directory that is used by client for storing the data files (like kv snapshot, log segment files) to read temporarily |
+| `client.scanner.io.tmpdir` | `/var/folders/p1/4yvqmcrs6n92xl_w_k3z43th0000gn/T//fluss` | String | Local directory that is used by client for storing the data files (like kv snapshot, log segment files) to read temporarily |
Review Comment:
why changes this?
##########
fluss-client/src/test/java/org/apache/fluss/client/converter/ConvertersTestFixtures.java:
##########
@@ -172,8 +191,9 @@ public int hashCode() {
timeField,
timestampField,
timestampLtzField,
- offsetDateTimeField);
- result = 31 * result + Arrays.hashCode(bytesField);
+ offsetDateTimeField,
+ mapField);
+ result = 31 * result + Arrays.hashCode(bytesField) + Arrays.hashCode(arrayField);
Review Comment:
// Change to two separate lines to preserve hash distribution
result = 31 * result + Arrays.hashCode(bytesField); // correct
##########
website/docs/_configs/_partial_config.mdx:
##########
@@ -284,7 +284,7 @@
| `table.auto-partition.enabled` | `false` | Boolean | Whether enable auto partition for the table. Disable by default. When auto partition is enabled, the partitions of the table will be created automatically. |
| `table.auto-partition.key` | `none` | String | This configuration defines the time-based partition key to be used for auto-partitioning when a table is partitioned with multiple keys. Auto-partitioning utilizes a time-based partition key to handle partitions automatically, including creating new ones and removing outdated ones, by comparing the time value of the partition with the current system time. In the case of a table using multiple partition keys (such as a composite partitioning strategy), this feature determines which key should serve as the primary time dimension for making auto-partitioning decisions.And If the table has only one partition key, this config is not necessary. Otherwise, it must be specified. |
| `table.auto-partition.time-unit` | `DAY` | AutoPartitionTimeUnit | The time granularity for auto created partitions. The default value is `DAY`. Valid values are `HOUR`, `DAY`, `MONTH`, `QUARTER`, `YEAR`. If the value is `HOUR`, the partition format for auto created is yyyyMMddHH. If the value is `DAY`, the partition format for auto created is yyyyMMdd. If the value is `MONTH`, the partition format for auto created is yyyyMM. If the value is `QUARTER`, the partition format for auto created is yyyyQ. If the value is `YEAR`, the partition format for auto created is yyyy. |
-| `table.auto-partition.time-zone` | `Europe/Paris` | String | The time zone for auto partitions, which is by default the same as the system time zone. |
+| `table.auto-partition.time-zone` | `Asia/Ho_Chi_Minh` | String | The time zone for auto partitions, which is by default the same as the system time zone. |
Review Comment:
why changes this?
##########
fluss-client/src/main/java/org/apache/fluss/client/converter/ConverterCommons.java:
##########
@@ -42,6 +41,8 @@
final class ConverterCommons {
static final Map<DataTypeRoot, Set<Class<?>>> SUPPORTED_TYPES = createSupportedTypes();
+ static final Set<DataTypeRoot> SUPPORTED_COMPLEX_TYPES =
+ EnumSet.of(DataTypeRoot.ARRAY, DataTypeRoot.MAP);
Review Comment:
SUPPORTED_COMPLEX_TYPES and its ARRAY/MAP entries in SUPPORTED_TYPES are redundant
##########
fluss-client/src/main/java/org/apache/fluss/client/converter/ConverterCommons.java:
##########
@@ -63,6 +64,8 @@ private static Map<DataTypeRoot, Set<Class<?>>> createSupportedTypes() {
map.put(
DataTypeRoot.TIMESTAMP_WITH_LOCAL_TIME_ZONE,
setOf(java.time.Instant.class, java.time.OffsetDateTime.class));
+ map.put(DataTypeRoot.ARRAY, setOf(java.util.Arrays.class));
Review Comment:
java.util.Arrays.class is a utility class, not an array type so this sentinel is wrong. More importantly, the SUPPORTED_COMPLEX_TYPES bypass on line 127 makes these two SUPPORTED_TYPES entries dead code.
Pick one approach: either validate the Java type properly for ARRAY/MAP and remove SUPPORTED_COMPLEX_TYPES, or remove the dead SUPPORTED_TYPES entries and keep the bypass.
##########
fluss-client/src/main/java/org/apache/fluss/client/converter/PojoMaptoFlussMap.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.client.converter;
+
+import org.apache.fluss.row.InternalArray;
+import org.apache.fluss.row.InternalMap;
+import org.apache.fluss.types.ArrayType;
+import org.apache.fluss.types.MapType;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/** Adapter class for converting Pojo Map to Fluss InternalMap. */
+public class PojoMaptoFlussMap implements InternalMap {
+ private final Map<?, ?> pojoMap;
+ private final MapType mapType;
+ private final String fieldName;
+
+ public PojoMaptoFlussMap(Map<?, ?> pojoMap, MapType mapType, String fieldName) {
+ this.pojoMap = pojoMap;
+ this.mapType = mapType;
+ this.fieldName = fieldName;
+ }
+
+ @Override
+ public int size() {
+ return pojoMap.size();
+ }
+
+ @Override
+ public InternalArray keyArray() {
Review Comment:
keyArray() and valueArray() iterate the map independently; keys and values can misalign
Two separate iterations over a HashMap are not guaranteed to match order.
Convert once at construction time and cache both arrays.
public InternalArray keyArray() {
List<?> pojoArray = new ArrayList<>(pojoMap.keySet()); // iteration 1
...
}
public InternalArray valueArray() {
List<?> pojoArray = new ArrayList<>(pojoMap.values()); // iteration 2 — order may differ
...
}
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fluss-client] Support Complex Data Types on the Java Typed API (Map and Array) [fluss]
Posted by "nhuantho (via GitHub)" <gi...@apache.org>.
nhuantho commented on code in PR #2814:
URL: https://github.com/apache/fluss/pull/2814#discussion_r2905815446
##########
fluss-client/src/test/java/org/apache/fluss/client/converter/RowToPojoConverterTest.java:
##########
@@ -41,7 +44,7 @@ public void testRoundTripFullSchema() {
ConvertersTestFixtures.TestPojo pojo = ConvertersTestFixtures.TestPojo.sample();
GenericRow row = writer.toRow(pojo);
- assertThat(row.getFieldCount()).isEqualTo(15);
+ assertThat(row.getFieldCount()).isEqualTo(17);
Review Comment:
I added two fields: arrayField and mapField
<img width="620" height="546" alt="image" src="https://github.com/user-attachments/assets/4cf3ef59-cec6-4314-9a13-adf06713849e" />
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fluss-client] Support Complex Data Types on the Java Typed API (Map and Array) [fluss]
Posted by "polyzos (via GitHub)" <gi...@apache.org>.
polyzos merged PR #2814:
URL: https://github.com/apache/fluss/pull/2814
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fluss-client] Support Complex Data Types on the Java Typed API (Map and Array) [fluss]
Posted by "nhuantho (via GitHub)" <gi...@apache.org>.
nhuantho commented on code in PR #2814:
URL: https://github.com/apache/fluss/pull/2814#discussion_r2909058938
##########
fluss-client/src/main/java/org/apache/fluss/client/converter/PojoArrayToFlussArray.java:
##########
@@ -0,0 +1,137 @@
+/*
+ * 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.client.converter;
+
+import org.apache.fluss.row.GenericArray;
+import org.apache.fluss.types.ArrayType;
+import org.apache.fluss.types.DataType;
+import org.apache.fluss.types.DataTypeChecks;
+import org.apache.fluss.types.DecimalType;
+import org.apache.fluss.types.MapType;
+
+import javax.annotation.Nullable;
+
+import java.util.Collection;
+import java.util.Map;
+
+/** Adapter class for converting Pojo Array to Fluss InternalArray. */
+public class PojoArrayToFlussArray {
+ private final Object obj;
+ private final DataType fieldType;
+ private final String fieldName;
+
+ public PojoArrayToFlussArray(Object obj, DataType fieldType, String fieldName) {
+ this.obj = obj;
+ this.fieldType = fieldType;
+ this.fieldName = fieldName;
+ }
+
+ public GenericArray convertArray() {
+ if (obj == null) {
+ return null;
+ }
+
+ ArrayType arrayType = (ArrayType) fieldType;
+ DataType elementType = arrayType.getElementType();
+
+ // Handle primitive arrays directly
+ if (obj instanceof Boolean[]) {
Review Comment:
I added logic to handle the primitive array types and added unit tests for it.
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fluss-client] Support Complex Data Types on the Java Typed API (Map and Array) [fluss]
Posted by "nhuantho (via GitHub)" <gi...@apache.org>.
nhuantho commented on code in PR #2814:
URL: https://github.com/apache/fluss/pull/2814#discussion_r2909073713
##########
fluss-client/src/main/java/org/apache/fluss/client/converter/PojoMaptoFlussMap.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.client.converter;
+
+import org.apache.fluss.row.InternalArray;
+import org.apache.fluss.row.InternalMap;
+import org.apache.fluss.types.ArrayType;
+import org.apache.fluss.types.MapType;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/** Adapter class for converting Pojo Map to Fluss InternalMap. */
+public class PojoMaptoFlussMap implements InternalMap {
+ private final Map<?, ?> pojoMap;
+ private final MapType mapType;
+ private final String fieldName;
+
+ public PojoMaptoFlussMap(Map<?, ?> pojoMap, MapType mapType, String fieldName) {
+ this.pojoMap = pojoMap;
+ this.mapType = mapType;
+ this.fieldName = fieldName;
+ }
+
+ @Override
+ public int size() {
+ return pojoMap.size();
+ }
+
+ @Override
+ public InternalArray keyArray() {
Review Comment:
Yes, I changed the logic to convert each key–value pair individually, since HashMap does not guarantee iteration order.
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org