You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/apis/java-client.md
+170-2Lines changed: 170 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -170,7 +170,7 @@ List<User> users = List.of(
170
170
);
171
171
```
172
172
173
-
**Note:** Currently data in Fluss is written in the form of `rows`, so we need to convert our POJO to `GenericRow`. For a more user-friendly API for writing data, please refer to the [Java Typed API](./java-typed-api.md) documentation.
173
+
**Note:** Currently data in Fluss is written in the form of `rows`, so we need to convert our POJO to `GenericRow`. For a more user-friendly API for writing data, please refer to the [Java Typed API](#java-typed-api) section below.
Fluss provides a Typed API that allows you to work directly with Java POJOs (Plain Old Java Objects) instead of `InternalRow` objects. This simplifies development by automatically mapping your Java classes to Fluss table schemas.
251
+
252
+
:::info
253
+
The Typed API provides a more user-friendly experience but comes with a performance cost due to the overhead of converting between POJOs and internal row formats. For high-performance use cases, consider using the lower-level `InternalRow` API.
254
+
:::
255
+
256
+
### Defining POJOs
257
+
258
+
To use the Typed API, define a Java class where the field names and types match your Fluss table schema.
// Convert the result row back to a User POJO if needed
401
+
// Note: You might need a RowToPojoConverter for this part if you want the full User object
402
+
// or you can access fields from the InternalRow directly.
403
+
}
404
+
```
405
+
406
+
### Performance Considerations
407
+
408
+
While the Typed API offers convenience and type safety, it involves an additional layer of conversion between your POJOs and Fluss's internal binary row format (`InternalRow`). This conversion process (serialization and deserialization) introduces CPU overhead.
409
+
410
+
Benchmarks indicate that using the Typed API can be roughly **2x slower** than using the `InternalRow` API directly for both writing and reading operations.
411
+
412
+
**Recommendation:**
413
+
* Use the **Typed API** for ease of use, rapid development, and when type safety is preferred over raw performance.
414
+
* Use the **InternalRow API** for high-throughput, latency-sensitive applications where performance is critical.
0 commit comments