Skip to content

Commit 93d571a

Browse files
Removing the documentation related to typ[e conversions as per PR comments
1 parent fe19447 commit 93d571a

File tree

2 files changed

+0
-141
lines changed

2 files changed

+0
-141
lines changed

website/docs/apis/java-client.md

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ List<User> users = List.of(
170170
);
171171
```
172172

173-
**Note:** Data in Fluss is written in the form of `rows`. You can either manually convert your POJO to `GenericRow` or use the `PojoToRowConverter` utility for automatic conversion.
174-
175-
#### Manual Conversion
176173
```java
177174
Table table = connection.getTable(tablePath);
178175

@@ -194,66 +191,6 @@ rows.forEach(writer::upsert);
194191
// call flush() to blocking the thread until all data is written successfully
195192
writer.flush();
196193
```
197-
198-
#### Using POJO Converter
199-
For a more convenient approach, you can use `PojoToRowConverter` to automatically convert your POJOs to rows:
200-
201-
```java
202-
import org.apache.fluss.client.converter.PojoToRowConverter;
203-
204-
// Create a converter for your POJO class
205-
RowType tableType = table.getTableInfo().getSchema().toRowType();
206-
PojoToRowConverter<User> converter = PojoToRowConverter.of(User.class, tableType, tableType);
207-
208-
// Convert POJOs to rows automatically
209-
List<GenericRow> rows = users.stream()
210-
.map(converter::toRow)
211-
.collect(Collectors.toList());
212-
213-
UpsertWriter writer = table.newUpsert().createWriter();
214-
rows.forEach(writer::upsert);
215-
writer.flush();
216-
```
217-
218-
##### Numeric Type Widening
219-
220-
The POJO converter supports automatic numeric type widening following Java's safe widening rules. This means you can use smaller numeric types in your POJOs even when the table schema specifies larger types.
221-
222-
**Supported Widenings**:
223-
- `byte``short`, `int`, `long`, `float`, `double`
224-
- `short``int`, `long`, `float`, `double`
225-
- `int``long`, `float`, `double`
226-
- `long``float`, `double`
227-
- `float``double`
228-
229-
**Example**:
230-
```java
231-
// POJO with int field
232-
public class Order {
233-
public int orderId; // Will automatically widen to BIGINT
234-
public String customerName;
235-
}
236-
237-
// Table schema with BIGINT
238-
Schema schema = Schema.newBuilder()
239-
.column("orderId", DataTypes.BIGINT())
240-
.column("customerName", DataTypes.STRING())
241-
.primaryKey("orderId")
242-
.build();
243-
244-
// This works! int will be automatically widened to long
245-
RowType tableType = schema.toRowType();
246-
PojoToRowConverter<Order> converter = PojoToRowConverter.of(Order.class, tableType, tableType);
247-
248-
Order order = new Order();
249-
order.orderId = 12345;
250-
order.customerName = "Alice";
251-
252-
GenericRow row = converter.toRow(order); // orderId is automatically converted to long
253-
```
254-
255-
**Note**: Narrowing conversions (e.g., `long``int`) are NOT supported and will fail at converter creation time.
256-
257194
For a Log table you can use the `AppendWriter` API to write data.
258195
```java
259196
table.newAppend().createWriter().append(row);

website/docs/engine-flink/datastream.mdx

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -163,84 +163,6 @@ public class OrderDeserializationSchema implements FlussDeserializationSchema<Or
163163
}
164164
}
165165
```
166-
167-
#### Using POJO Converter
168-
169-
For a more convenient approach when deserializing to POJOs, you can use the `PojoToRowConverter` utility from the `fluss-flink-common` module:
170-
171-
```java
172-
import org.apache.fluss.flink.utils.PojoToRowConverter;
173-
174-
public class PojoDeserializationSchema implements FlussDeserializationSchema<Order> {
175-
private transient PojoToRowConverter<Order> converter;
176-
177-
@Override
178-
public void open(InitializationContext context) throws Exception {
179-
// The converter will be initialized when we have the row schema
180-
}
181-
182-
@Override
183-
public Order deserialize(LogRecord record) throws Exception {
184-
InternalRow row = record.getRow();
185-
186-
// If you need to convert InternalRow to your POJO, you'll need to handle it manually
187-
// The PojoToRowConverter is designed for POJO -> Row conversion
188-
// For Row -> POJO, use manual field extraction as shown in the previous example
189-
190-
return new Order(
191-
row.getLong(0),
192-
row.getLong(1),
193-
row.getInt(2),
194-
row.getString(3).toString()
195-
);
196-
}
197-
198-
@Override
199-
public TypeInformation<Order> getProducedType(RowType rowSchema) {
200-
return TypeInformation.of(Order.class);
201-
}
202-
}
203-
```
204-
205-
**Note:** The `PojoToRowConverter` is primarily designed for converting POJOs to Fluss rows (for writing). For reading (deserializing rows to POJOs), you'll need to manually extract fields from the `InternalRow` as shown in the examples above.
206-
207-
##### Numeric Type Widening for POJO Converters
208-
209-
When using `PojoToRowConverter` for serialization, the converter supports automatic numeric type widening following Java's safe widening rules. This allows you to use smaller numeric types in your POJOs even when the table schema specifies larger types.
210-
211-
**Supported Widenings**:
212-
- `byte``short`, `int`, `long`, `float`, `double`
213-
- `short``int`, `long`, `float`, `double`
214-
- `int``long`, `float`, `double`
215-
- `long``float`, `double`
216-
- `float``double`
217-
218-
**Example**:
219-
```java
220-
// POJO with int field
221-
public class Order {
222-
public int orderId; // Will automatically widen to BIGINT
223-
public String customerName;
224-
}
225-
226-
// Table schema with BIGINT
227-
RowType rowType = RowType.builder()
228-
.field("orderId", DataTypes.BIGINT())
229-
.field("customerName", DataTypes.STRING())
230-
.build();
231-
232-
// Create converter - int will be automatically widened to long
233-
PojoToRowConverter<Order> converter = new PojoToRowConverter<>(Order.class, rowType);
234-
235-
Order order = new Order();
236-
order.orderId = 12345;
237-
order.customerName = "Alice";
238-
239-
InternalRow row = converter.convert(order); // orderId is automatically converted to long
240-
```
241-
242-
**Note**: Narrowing conversions (e.g., `long``int`) are NOT supported and will fail at converter creation time.
243-
244166
### Examples
245167

246168
#### Reading from a Primary Key Table

0 commit comments

Comments
 (0)