1515// specific language governing permissions and limitations
1616// under the License.
1717
18- use fluss:: client:: { FlussConnection , EARLIEST_OFFSET } ;
18+ use fluss:: client:: { EARLIEST_OFFSET , FlussConnection } ;
1919use fluss:: config:: Config ;
2020use fluss:: error:: Result ;
2121use fluss:: metadata:: TablePath ;
2222use fluss:: row:: InternalRow ;
23- use std:: time:: Duration ;
2423use fluss:: rpc:: message:: OffsetSpec ;
24+ use std:: time:: Duration ;
2525use std:: time:: SystemTime ;
2626use std:: time:: UNIX_EPOCH ;
2727
@@ -37,14 +37,15 @@ pub async fn main() -> Result<()> {
3737 let conn = FlussConnection :: new ( config) . await ?;
3838 println ! ( " Connected successfully!" ) ;
3939
40- let table_path = TablePath :: new ( "fluss" . to_owned ( ) , "mahong_log_table_cpp_test_1212" . to_owned ( ) ) ;
40+ let table_path = TablePath :: new (
41+ "fluss" . to_owned ( ) ,
42+ "mahong_log_table_cpp_test_1212" . to_owned ( ) ,
43+ ) ;
4144 println ! ( "2) Getting admin..." ) ;
4245 let admin = conn. get_admin ( ) . await ?;
4346 println ! ( " Admin obtained successfully!" ) ;
4447 // Step 1: 通过 admin API 查询时间戳对应的 offset
4548
46-
47-
4849 println ! ( "3) Getting table: {}" , table_path) ;
4950 let table = conn. get_table ( & table_path) . await ?;
5051 println ! ( " Table obtained successfully!" ) ;
@@ -54,16 +55,18 @@ pub async fn main() -> Result<()> {
5455 println ! ( " Table has {} buckets" , num_buckets) ;
5556 let now = SystemTime :: now ( ) ;
5657 let twenty_minutes_ago = now - Duration :: from_secs ( 20 * 60 ) ;
57-
58+
5859 let timestamp_ms = twenty_minutes_ago
5960 . duration_since ( UNIX_EPOCH )
6061 . expect ( "Time went backwards" )
6162 . as_secs ( ) ;
62- let offsets = admin. list_offsets (
63- & table_path,
64- & ( 0 ..num_buckets) . collect :: < Vec < i32 > > ( ) ,
65- OffsetSpec :: Timestamp ( timestamp_ms as i64 )
66- ) . await ?;
63+ let offsets = admin
64+ . list_offsets (
65+ & table_path,
66+ & ( 0 ..num_buckets) . collect :: < Vec < i32 > > ( ) ,
67+ OffsetSpec :: Timestamp ( timestamp_ms as i64 ) ,
68+ )
69+ . await ?;
6770
6871 // println!("4) Creating log scanner...");
6972 // let log_scanner = table.new_scan().create_log_scanner()?;
@@ -99,9 +102,7 @@ pub async fn main() -> Result<()> {
99102 // }
100103
101104 println ! ( "\n 7) Creating log scanner with projection (columns 0, 1)..." ) ;
102- let projected_scanner = table. new_scan ( )
103- . project ( & [ 0 , 2 ] ) ?
104- . create_log_scanner ( ) ?;
105+ let projected_scanner = table. new_scan ( ) . project ( & [ 0 , 2 ] ) ?. create_log_scanner ( ) ?;
105106 println ! ( " Projected scanner created successfully!" ) ;
106107
107108 println ! ( "8) Subscribing projected scanner to all buckets from EARLIEST_OFFSET..." ) ;
@@ -130,7 +131,12 @@ pub async fn main() -> Result<()> {
130131 }
131132
132133 if i < 10 {
133- println ! ( " Record {}: id={}, name={}" , i, row. get_long( 0 ) , row. get_string( 1 ) ) ;
134+ println ! (
135+ " Record {}: id={}, name={}" ,
136+ i,
137+ row. get_long( 0 ) ,
138+ row. get_string( 1 )
139+ ) ;
134140 }
135141 }
136142
@@ -144,9 +150,5 @@ pub async fn main() -> Result<()> {
144150 eprintln ! ( "\n Column pruning verification failed!" ) ;
145151 std:: process:: exit ( 1 ) ;
146152 }
147-
148153 }
149-
150-
151-
152154}
0 commit comments