fresh-borzoni commented on code in PR #415:
URL: https://github.com/apache/fluss-rust/pull/415#discussion_r2877902356


##########
crates/fluss/README.md:
##########
@@ -1,25 +1,104 @@
-# Apache Fluss™ Rust Client (Incubating)
+# Apache Fluss (Incubating) Official Rust Client
 
-Rust client library for [Apache Fluss™](https://fluss.apache.org/). This crate 
provides the core client used by the fluss-rust workspace and by the Python and 
C++ bindings.
+Official Rust client library for [Apache Fluss 
(Incubating)](https://fluss.apache.org/).
 
-# Todo: move how to use to the first, and how to build to the last, 
https://github.com/apache/opendal/blob/main/core/README.md 
-# is a good reference
+[![crates.io](https://img.shields.io/crates/v/fluss-rs.svg)](https://crates.io/crates/fluss-rs)
+[![docs.rs](https://img.shields.io/docsrs/fluss-rs)](https://docs.rs/fluss-rs/)
 
-## Requirements
+## Usage
 
-- Rust (see [rust-toolchain.toml](../../rust-toolchain.toml) at repo root)
-- protobuf (for build)
+The following example shows both **primary key (KV) tables** and **log 
tables** in one flow: connect, create a KV table (upsert + lookup), then create 
a log table (append + scan).
 
-## Build
+```rust
+use fluss::client::EARLIEST_OFFSET;
+use fluss::client::FlussConnection;
+use fluss::config::Config;
+use fluss::error::Result;
+use fluss::metadata::{DataTypes, Schema, TableDescriptor, TablePath};
+use fluss::row::{GenericRow, InternalRow};
+use std::time::Duration;
 
-From the repository root:
+#[tokio::main]
+async fn main() -> Result<()> {
+    let mut config = Config::default();
+    config.bootstrap_servers = "127.0.0.1:9123".to_string();
+    let connection = FlussConnection::new(config).await?;
+    let admin = connection.get_admin().await?;
 
-```bash
-cargo build -p fluss-rs
+    // ---- Primary key (KV) table: upsert and lookup ----
+    let kv_path = TablePath::new("fluss", "users");
+    let mut kv_schema = Schema::builder()
+        .column("id", DataTypes::int())
+        .column("name", DataTypes::string())
+        .column("age", DataTypes::bigint())
+        .primary_key(vec!["id"]);
+    let kv_descriptor = TableDescriptor::builder()
+        .schema(kv_schema.build()?)
+        .build()?;
+    admin.create_table(&kv_path, &kv_descriptor, false).await?;
+
+    let kv_table = connection.get_table(&kv_path).await?;
+    let upsert_writer = kv_table.new_upsert()?.create_writer()?;
+    let mut row = GenericRow::new(3);
+    row.set_field(0, 1i32);
+    row.set_field(1, "Alice");
+    row.set_field(2, 30i64);
+    upsert_writer.upsert(&row)?;
+    upsert_writer.flush().await?;
+
+    let mut lookuper = kv_table.new_lookup()?.create_lookuper()?;
+    let mut key = GenericRow::new(1);
+    key.set_field(0, 1i32);
+    let result = lookuper.lookup(&key).await?;
+    if let Some(r) = result.get_single_row()? {
+        println!("KV lookup: id={}, name={}, age={}",
+                 r.get_int(0)?, r.get_string(1)?, r.get_long(2)?);
+    }
+
+    // ---- Log table: append and scan ----
+    let log_path = TablePath::new("fluss", "events");
+    let mut log_schema_builder = Schema::builder()

Review Comment:
   Sorry, I meant  `build` and therefore `normalize_columns` methods take mut, 
that's why we thread it through, but we don't mutate there really, just use for 
reassignment, we can probably just do it in a different way and get rid of mut 
requirement
   
https://github.com/apache/fluss-rust/blob/257eb7dd3c16d8312f71286f0d420478277384d8/crates/fluss/src/metadata/table.rs#L269



-- 
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]

Reply via email to