diff --git a/bindings/c/src/table.rs b/bindings/c/src/table.rs index e6a91eaa7..bcaf42d6a 100644 --- a/bindings/c/src/table.rs +++ b/bindings/c/src/table.rs @@ -479,6 +479,7 @@ unsafe fn new_read_builder_state( resources: None, projected_columns: None, read_type: None, + index_score_name: None, filter: None, case_sensitive: true, limit: None, @@ -669,6 +670,40 @@ pub unsafe extern "C" fn paimon_read_builder_with_projection( std::ptr::null_mut() } +/// Append a nullable Float32 field containing the selected IndexedSplit's score. +/// The caller supplies the output name. A null name clears this projection. +/// Ordinary projection calls affect only table fields. An unscored selection +/// produces nulls. The reader accepts one indexed split per call. +/// +/// # Safety +/// `rb` must be a live builder. A non-null `name` must be a UTF-8 C string. +#[no_mangle] +pub unsafe extern "C" fn paimon_read_builder_with_index_score( + rb: *mut paimon_read_builder, + name: *const c_char, +) -> *mut paimon_error { + if let Err(error) = check_non_null(rb, "rb") { + return error; + } + let name = if name.is_null() { + None + } else { + match validate_cstr(name, "name") { + Ok(name) if !name.is_empty() => Some(name), + Ok(_) => { + return paimon_error::new( + PaimonErrorCode::InvalidInput, + "Empty score field name".into(), + ) + } + Err(error) => return error, + } + }; + let state = &mut *((*rb).inner as *mut ReadBuilderState); + state.index_score_name = name; + std::ptr::null_mut() +} + /// Set a structured read type, including nested ROW/ARRAY/MAP projections. /// /// `read_type_json` uses Paimon's JSON array of DataFields, preserving field IDs @@ -871,6 +906,7 @@ pub unsafe extern "C" fn paimon_read_builder_new_read( resources: state.resources.clone(), read_type: table_read.read_type().to_vec(), data_predicates: table_read.data_predicates().to_vec(), + index_score_name: state.index_score_name.clone(), }; paimon_result_new_read { read: box_table_read_state(read_state), @@ -947,9 +983,9 @@ pub unsafe extern "C" fn paimon_table_scan_plan( // ======================= Plan =============================== /// Build a one-split `paimon_plan` from a serialized Paimon-native `DataSplit` -/// byte buffer (the wire form produced by `DataSplit::serialize` / Java -/// `DataSplit#serialize`). `data` must be raw bytes (Base64 already decoded by -/// the caller). +/// or raw Java `IndexedSplit` byte buffer. `data` must be raw bytes (Base64 +/// already decoded by the caller). IndexedSplit row ranges and scores are +/// preserved for `paimon_table_read_to_arrow`. /// /// The returned plan is usable with `paimon_table_read_to_arrow` and must be /// freed with `paimon_plan_free`. @@ -1082,7 +1118,15 @@ pub unsafe extern "C" fn paimon_table_read_to_arrow( table_read = table_read.with_resources(resources.clone()); } - match table_read.to_arrow(selected) { + let stream = match (state.index_score_name.as_deref(), selected) { + (Some(name), [split]) => table_read.to_arrow_with_index_score(split, name), + (Some(_), [_, _, ..]) => Err(paimon::Error::DataInvalid { + message: "Index score projection requires at most one selected split".into(), + source: None, + }), + _ => table_read.to_arrow(selected), + }; + match stream { Ok(stream) => { let reader = Box::new(stream); let wrapper = Box::new(paimon_record_batch_reader { diff --git a/bindings/c/src/tests.rs b/bindings/c/src/tests.rs index 5d4d1b68e..b92e8b8d4 100644 --- a/bindings/c/src/tests.rs +++ b/bindings/c/src/tests.rs @@ -4537,6 +4537,154 @@ fn plan_from_split_bytes_round_trips() { unsafe { paimon_plan_free(result.plan) }; } +#[test] +fn plan_from_raw_indexed_split_bytes_round_trips() { + let framed = include_bytes!("../../../crates/paimon/src/table/goldens/split_v1_indexed.bin"); + let scores_len = 1 + 4 + 3 * 4; + let mut raw = framed[16..framed.len() - scores_len].to_vec(); + raw.push(0); // BTree IndexedSplit has no scores. + + let result = unsafe { paimon_plan_from_split_bytes(raw.as_ptr(), raw.len()) }; + assert!(result.error.is_null()); + assert_eq!(unsafe { paimon_plan_num_splits(result.plan) }, 1); + unsafe { paimon_plan_free(result.plan) }; +} + +#[test] +fn raw_scored_indexed_split_materializes_index_score() { + check_scored_indexed_split(false); +} + +#[test] +fn filtered_scored_indexed_split_joins_scores_by_row_id() { + check_scored_indexed_split(true); +} + +fn check_scored_indexed_split(tracked: bool) { + let path = "memory:/test_scored_indexed_split"; + let schema = Schema::builder() + .column("id", DataType::Int(IntType::new())) + .column( + "_INDEX_SCORE", + DataType::VarChar(VarCharType::string_type()), + ) + .option( + "row-tracking.enabled", + if tracked { "true" } else { "false" }, + ) + .build() + .unwrap(); + let file_io = memory_file_io(); + setup_table_dirs(&file_io, path); + let table = Table::new( + file_io, + Identifier::new("default", "test"), + path.to_string(), + TableSchema::new(0, &schema), + None, + ); + let batch = RecordBatch::try_from_iter(vec![ + ("id", Arc::new(Int32Array::from(vec![3, 1, 2])) as ArrayRef), + ( + "_INDEX_SCORE", + Arc::new(StringArray::from(vec!["a", "b", "c"])) as ArrayRef, + ), + ]) + .unwrap(); + write_data_rust(&table, &[batch]); + + let split = crate::runtime().block_on(async { + table + .new_read_builder() + .new_scan() + .plan() + .await + .unwrap() + .splits()[0] + .clone() + }); + let mut raw = Vec::new(); + raw.extend_from_slice(&(-938472394838495695i64).to_be_bytes()); + raw.extend_from_slice(&1i32.to_be_bytes()); + raw.extend_from_slice(&split.serialize().unwrap()); + raw.extend_from_slice(&1i32.to_be_bytes()); + raw.extend_from_slice(&0i64.to_be_bytes()); + raw.extend_from_slice(&2i64.to_be_bytes()); + raw.push(1); + raw.extend_from_slice(&3i32.to_be_bytes()); + for score in [0.9f32, 0.8, 0.7] { + raw.extend_from_slice(&score.to_be_bytes()); + } + + let handle = unsafe { wrap_table(table) }; + unsafe { + let rb_result = paimon_table_new_read_builder(handle); + assert!(rb_result.error.is_null()); + let name = CString::new("_INDEX_SCORE").unwrap(); + let score = CString::new("similarity").unwrap(); + let id = CString::new("id").unwrap(); + let projection = [name.as_ptr(), id.as_ptr(), ptr::null()]; + let error = + paimon_read_builder_with_projection(rb_result.read_builder, projection.as_ptr()); + assert!(error.is_null()); + + assert!( + paimon_read_builder_with_index_score(rb_result.read_builder, score.as_ptr()).is_null() + ); + if tracked { + let predicate = build_predicate_ge(handle, "id", 2); + assert!(paimon_read_builder_with_filter(rb_result.read_builder, predicate).is_null()); + } + let read_result = paimon_read_builder_new_read(rb_result.read_builder); + assert!(read_result.error.is_null()); + let plan_result = paimon_plan_from_split_bytes(raw.as_ptr(), raw.len()); + assert!(plan_result.error.is_null()); + let reader_result = paimon_table_read_to_arrow(read_result.read, plan_result.plan, 0, 1); + assert!(reader_result.error.is_null()); + + let next = paimon_record_batch_reader_next(reader_result.reader); + assert!(next.error.is_null()); + assert!(!next.batch.array.is_null()); + let batch = import_batch(&next.batch); + paimon_arrow_batch_free(next.batch); + + assert_eq!(batch.schema().fields().len(), 3); + assert_eq!(batch.schema().field(0).name(), "_INDEX_SCORE"); + assert_eq!(batch.schema().field(1).name(), "id"); + assert_eq!(batch.schema().field(2).name(), "similarity"); + let scores = batch + .column(2) + .as_any() + .downcast_ref::() + .unwrap(); + let physical = batch + .column(0) + .as_any() + .downcast_ref::() + .unwrap(); + if tracked { + assert_eq!(scores.values(), &[0.9, 0.7]); + assert_eq!(physical.iter().collect::>(), [Some("a"), Some("c")]); + } else { + assert_eq!(scores.values(), &[0.9, 0.8, 0.7]); + assert_eq!( + physical.iter().collect::>(), + [Some("a"), Some("b"), Some("c")] + ); + } + + let eof = paimon_record_batch_reader_next(reader_result.reader); + assert!(eof.error.is_null()); + assert!(eof.batch.array.is_null()); + + paimon_record_batch_reader_free(reader_result.reader); + paimon_plan_free(plan_result.plan); + paimon_table_read_free(read_result.read); + paimon_read_builder_free(rb_result.read_builder); + unwrap_table(handle); + } +} + #[test] fn plan_from_split_bytes_rejects_null_and_empty() { let r = unsafe { paimon_plan_from_split_bytes(std::ptr::null(), 0) }; diff --git a/bindings/c/src/types.rs b/bindings/c/src/types.rs index 490dd5a4e..4f8e2a943 100644 --- a/bindings/c/src/types.rs +++ b/bindings/c/src/types.rs @@ -269,6 +269,7 @@ pub(crate) struct ReadBuilderState { pub resources: Option, pub projected_columns: Option>, pub read_type: Option>, + pub index_score_name: Option, pub filter: Option, pub case_sensitive: bool, pub limit: Option, @@ -298,6 +299,7 @@ pub(crate) struct TableReadState { pub resources: Option, pub read_type: Vec, pub data_predicates: Vec, + pub index_score_name: Option, } #[repr(C)] diff --git a/crates/paimon/src/table/scored_split_read.rs b/crates/paimon/src/table/scored_split_read.rs new file mode 100644 index 000000000..2d6939847 --- /dev/null +++ b/crates/paimon/src/table/scored_split_read.rs @@ -0,0 +1,233 @@ +// 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. + +use super::{PaimonTableRead, TableRead, TableReadKind}; +use crate::spec::{row_id_data_field, ROW_ID_FIELD_ID}; +use crate::table::pk_vector_indexed_split_read::{PkVectorIndexedSplit, PkVectorIndexedSplitRead}; +use crate::table::{ArrowRecordBatchStream, DataSplit, RowRange}; +use arrow_array::{ArrayRef, Float32Array, Int64Array, RecordBatch}; +use arrow_schema::{DataType, Field, Schema}; +use futures::{stream, StreamExt}; +use std::sync::Arc; + +fn invalid(message: &str) -> crate::Error { + crate::Error::DataInvalid { + message: message.into(), + source: None, + } +} + +fn scored_batch( + batch: RecordBatch, + count: usize, + name: &str, + scores: ArrayRef, +) -> crate::Result { + let schema = batch.schema(); + let mut fields = schema.fields()[..count].to_vec(); + let mut columns = batch.columns()[..count].to_vec(); + fields.push(Arc::new(Field::new(name, DataType::Float32, true))); + columns.push(scores); + RecordBatch::try_new( + Arc::new(Schema::new_with_metadata(fields, schema.metadata().clone())), + columns, + ) + .map_err(|error| invalid(&format!("Invalid scored batch: {error}"))) +} + +impl TableRead<'_> { + /// Read one Java IndexedSplit, appending its nullable Float32 score under + /// `name`. A split without scores produces nulls. Tracked rows use global + /// row IDs; file-position selections use the same DV-aware reader as PK + /// vector search. Physical position reads require a predicate-free reader. + pub fn to_arrow_with_index_score( + &self, + split: &DataSplit, + name: &str, + ) -> crate::Result { + let selected = std::slice::from_ref(split); + let ranges = split + .row_ranges() + .ok_or_else(|| invalid("Score projection requires an IndexedSplit"))?; + if name.is_empty() || self.read_type().iter().any(|f| f.name() == name) { + return Err(invalid( + "Index score field name must be nonempty and distinct from the projected fields", + )); + } + let name = name.to_owned(); + let count = self.read_type().len(); + let Some(scores) = split.scores() else { + return Ok(self + .to_arrow(selected)? + .map(move |batch| { + let batch = batch?; + let scores = Arc::new(Float32Array::new_null(batch.num_rows())); + scored_batch(batch, count, &name, scores) + }) + .boxed()); + }; + if ranges.iter().any(|r| r.from() < 0) + || ranges.windows(2).any(|w| w[0].to() >= w[1].from()) + { + return Err(invalid( + "Scored ranges must be nonnegative, ordered and disjoint", + )); + } + let TableReadKind::Paimon(read) = &self.kind else { + return Err(invalid("Scored data splits require a Paimon table")); + }; + let options = read.table.schema().core_options(); + if read.table.schema().primary_keys().is_empty() + && (options.row_tracking_enabled() || options.data_evolution_enabled()) + { + return read_tracked(read.clone(), split, ranges, name); + } + + // A physical-position reader cannot apply an additional filter before + // recovering positions. Restricted grants must use the ordinary reader. + let grant = read.ensure_authorized_by_splits(&options, selected)?; + if grant.is_some() + || !read.data_predicates.is_empty() + || read.row_filter_factory.is_some() + || read.update_read + || read.limit.is_some() + { + return Err(crate::Error::Unsupported {message: "File-position score projection requires an unrestricted, predicate-free read without a row limit".into()}); + } + if read.matching_splits(selected)?.is_empty() || ranges.is_empty() { + return Ok(stream::empty().boxed()); + } + if !read.table.schema().primary_keys().is_empty() && split.data_files().len() != 1 { + return Err(invalid( + "A scored primary-key split must select one physical file", + )); + } + read_positions(read, split, ranges, scores, name) + } +} + +fn read_tracked( + mut read: PaimonTableRead<'_>, + split: &DataSplit, + ranges: &[RowRange], + name: String, +) -> crate::Result { + let count = read.read_type.len(); + let index = read + .read_type + .iter() + .position(|f| f.id() == ROW_ID_FIELD_ID) + .unwrap_or_else(|| { + read.read_type.push(row_id_data_field()); + count + }); + // Each range indexes a contiguous slice of the split's score array. + let mut offset = 0; + let offsets: Vec = ranges + .iter() + .map(|r| { + let start = offset; + offset += (r.to() - r.from() + 1) as usize; + start + }) + .collect(); + let split = split.clone(); + Ok(read + .execute_splits(std::slice::from_ref(&split), 1, true, false)? + .map(move |batch| { + let batch = batch?; + let ids = batch + .column(index) + .as_any() + .downcast_ref::() + .ok_or_else(|| invalid("Expected Int64 row IDs"))?; + let ranges = split.row_ranges().unwrap(); + let scores = split.scores().unwrap(); + let values = ids + .iter() + .map(|id| { + let id = id.ok_or_else(|| invalid("Missing row ID for scored read"))?; + let i = ranges.partition_point(|r| r.to() < id); + let r = ranges + .get(i) + .filter(|r| r.from() <= id) + .ok_or_else(|| invalid("Row is outside scored selection"))?; + Ok(scores[offsets[i] + (id - r.from()) as usize]) + }) + .collect::>>()?; + scored_batch(batch, count, &name, Arc::new(Float32Array::from(values))) + }) + .boxed()) +} + +fn read_positions( + read: &PaimonTableRead<'_>, + split: &DataSplit, + ranges: &[RowRange], + scores: &[f32], + name: String, +) -> crate::Result { + let count = read.read_type.len(); + let reader = PkVectorIndexedSplitRead::new(read.new_data_file_reader()?); + let mut streams = Vec::new(); + let mut base = 0_i64; + let mut consumed = 0; + let mut next_range = 0; + for (file_index, file) in split.data_files().iter().enumerate() { + if file.row_count < 0 { + return Err(invalid("Negative file row count")); + } + if file.row_count == 0 { + continue; + } + let end = base + .checked_add(file.row_count) + .ok_or_else(|| invalid("Split row count overflows"))?; + let mut local = Vec::new(); + let start = consumed; + while let Some(r) = ranges.get(next_range).filter(|r| r.from() < end) { + let low = r.from().max(base); + let high = r.to().min(end - 1); + local.push(RowRange::new(low - base, high - base)); + consumed += (high - low + 1) as usize; + if r.to() >= end { + break; + } + next_range += 1; + } + if !local.is_empty() { + streams.push(reader.read(&PkVectorIndexedSplit { + split: split.for_pk_index_file(file_index), + row_ranges: local, + scores: Some(scores[start..consumed].to_vec()), + })?); + } + base = end; + } + if consumed != scores.len() { + return Err(invalid("Scored positions exceed the split's data files")); + } + Ok(stream::iter(streams) + .flatten() + .map(move |batch| { + let batch = batch?; + // The position reader appends the physical position followed by its score. + let scores = batch.column(count + 1).clone(); + scored_batch(batch, count, &name, scores) + }) + .boxed()) +} diff --git a/crates/paimon/src/table/source.rs b/crates/paimon/src/table/source.rs index 964eadc34..b39661f61 100644 --- a/crates/paimon/src/table/source.rs +++ b/crates/paimon/src/table/source.rs @@ -906,12 +906,18 @@ impl DataSplit { Ok(out) } - /// Reverse of [`DataSplit::serialize`]: parse a raw `DataSplit#serialize` body. + /// Parse a Java DataSplit or IndexedSplit body, or a SplitSerializer v1 frame. /// Both the current version and the legacy v8 layout are accepted. /// Consumes the entire buffer; trailing bytes are an error. pub fn deserialize(data: &[u8]) -> crate::Result { let mut cur = data; - let split = Self::read_body(&mut cur)?; + let split = if data.starts_with(&INDEXED_SPLIT_MAGIC.to_be_bytes()) { + Self::read_indexed_body(&mut cur)? + } else if data.starts_with(&SPLIT_SER_MAGIC.to_be_bytes()) { + return Self::deserialize_split_v1(data); + } else { + Self::read_body(&mut cur)? + }; if !cur.is_empty() { return Err(crate::Error::DataInvalid { message: format!("{} trailing bytes after DataSplit", cur.len()), @@ -1154,59 +1160,7 @@ impl DataSplit { split } SPLIT_SER_TYPE_DATA_SPLIT => Self::read_body(cur)?, - SPLIT_SER_TYPE_INDEXED_SPLIT => { - let im = read_i64(cur)?; - if im != INDEXED_SPLIT_MAGIC { - return Err(crate::Error::DataInvalid { - message: format!("invalid IndexedSplit magic: {im:#018x}"), - source: None, - }); - } - let iv = read_i32(cur)?; - if iv != INDEXED_SPLIT_VERSION { - return Err(crate::Error::Unsupported { - message: format!("IndexedSplit version {iv} not supported"), - }); - } - let body = Self::read_body(cur)?; - let ranges_n = read_i32(cur)?; - if ranges_n < 0 { - return Err(crate::Error::DataInvalid { - message: "negative row_ranges count".into(), - source: None, - }); - } - // Bound the eager reservation by the remaining bytes: each RowRange is - // 16 bytes (two i64), so a crafted huge count cannot over-reserve. - let mut ranges = Vec::with_capacity((ranges_n as usize).min(cur.len() / 16)); - for _ in 0..ranges_n { - let from = read_i64(cur)?; - let to = read_i64(cur)?; - if from > to { - return Err(crate::Error::DataInvalid { - message: format!("row range from {from} > to {to}"), - source: None, - }); - } - ranges.push(RowRange::new(from, to)); - } - let mut body = body; - body.row_ranges = Some(ranges.into()); - if read_u8(cur)? != 0 { - let count = read_i32(cur)?; - if count < 0 || count as usize > cur.len() / 4 { - return Err(crate::Error::DataInvalid { - message: "Invalid IndexedSplit scores count".into(), - source: None, - }); - } - let scores = (0..count) - .map(|_| read_i32(cur).map(|bits| f32::from_bits(bits as u32))) - .collect::>>()?; - body = body.with_scores(scores)?; - } - body - } + SPLIT_SER_TYPE_INDEXED_SPLIT => Self::read_indexed_body(cur)?, other => { return Err(crate::Error::Unsupported { message: format!("unsupported split type id: {other}"), @@ -1215,6 +1169,60 @@ impl DataSplit { }; Ok(split) } + + fn read_indexed_body(cur: &mut &[u8]) -> crate::Result { + let im = read_i64(cur)?; + if im != INDEXED_SPLIT_MAGIC { + return Err(crate::Error::DataInvalid { + message: format!("invalid IndexedSplit magic: {im:#018x}"), + source: None, + }); + } + let iv = read_i32(cur)?; + if iv != INDEXED_SPLIT_VERSION { + return Err(crate::Error::Unsupported { + message: format!("IndexedSplit version {iv} not supported"), + }); + } + let body = Self::read_body(cur)?; + let ranges_n = read_i32(cur)?; + if ranges_n < 0 { + return Err(crate::Error::DataInvalid { + message: "negative row_ranges count".into(), + source: None, + }); + } + // Bound the eager reservation by the remaining bytes: each RowRange is + // 16 bytes (two i64), so a crafted huge count cannot over-reserve. + let mut ranges = Vec::with_capacity((ranges_n as usize).min(cur.len() / 16)); + for _ in 0..ranges_n { + let from = read_i64(cur)?; + let to = read_i64(cur)?; + if from > to { + return Err(crate::Error::DataInvalid { + message: format!("row range from {from} > to {to}"), + source: None, + }); + } + ranges.push(RowRange::new(from, to)); + } + let mut body = body; + body.row_ranges = Some(ranges.into()); + if read_u8(cur)? != 0 { + let count = read_i32(cur)?; + if count < 0 || count as usize > cur.len() / 4 { + return Err(crate::Error::DataInvalid { + message: "Invalid IndexedSplit scores count".into(), + source: None, + }); + } + let scores = (0..count) + .map(|_| read_i32(cur).map(|bits| f32::from_bits(bits as u32))) + .collect::>>()?; + body = body.with_scores(scores)?; + } + Ok(body) + } } fn validate_scores(ranges: Option<&[RowRange]>, scores: &[f32]) -> crate::Result<()> { @@ -2881,6 +2889,30 @@ mod tests { assert_eq!(split.serialize_split_v1().unwrap(), expected); } + #[test] + fn raw_and_framed_indexed_split_decode_the_same_selection() { + // The Java fixture deliberately has three scores for seven positions. + let malformed = include_bytes!("goldens/split_v1_indexed.bin"); + assert!(DataSplit::deserialize(malformed).is_err()); + assert!(DataSplit::deserialize(&malformed[16..]).is_err()); + let expected = v1_data_split_builder() + .with_row_ranges(vec![RowRange::new(1, 3)]) + .build() + .unwrap() + .with_scores(vec![0.2, 0.4, 0.6]) + .unwrap(); + let framed = expected.serialize_split_v1().unwrap(); + for bytes in [framed.as_slice(), &framed[16..]] { + let decoded = DataSplit::deserialize(bytes).unwrap(); + assert_eq!(decoded.row_ranges(), expected.row_ranges()); + assert_eq!(decoded.scores(), expected.scores()); + assert!(DataSplit::deserialize(&bytes[..bytes.len() - 1]).is_err()); + let mut trailing = bytes.to_vec(); + trailing.push(0); + assert!(DataSplit::deserialize(&trailing).is_err()); + } + } + #[test] fn serialize_indexed_scores_match_java_wire_layout() { let split = v1_data_split_builder() diff --git a/crates/paimon/src/table/table_read.rs b/crates/paimon/src/table/table_read.rs index 1db4cc51e..ca4dd1914 100644 --- a/crates/paimon/src/table/table_read.rs +++ b/crates/paimon/src/table/table_read.rs @@ -45,6 +45,9 @@ use std::cmp::Ordering; use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; use std::sync::Arc; +#[path = "scored_split_read.rs"] +mod scored_split; + #[path = "audit_log_table/read.rs"] mod audit; pub use audit::AuditLogRead; diff --git a/docs/src/c-binding.md b/docs/src/c-binding.md index 2ca3b4aa3..d9354e013 100644 --- a/docs/src/c-binding.md +++ b/docs/src/c-binding.md @@ -100,6 +100,16 @@ leave the previous selection intact. `[]` selects zero columns while retaining row counts, and a null pointer clears the projection. Case sensitivity applies to name projections; an explicit read type keeps its supplied field identities. +Use `paimon_plan_from_split_bytes` with a Java DataSplit body, an IndexedSplit +body, or a SplitSerializer v1 frame. To read a split's scores, call +`paimon_read_builder_with_index_score(builder, "similarity")` and select one +indexed split in `paimon_table_read_to_arrow`. The reader appends a nullable +Float32 column with that name to the projected table fields. An unscored split +produces nulls. Passing a null name clears the score request. A projected table +column and the score must have distinct output names. Tracked reads preserve the +scores of surviving rows after filtering. File-position reads apply deletion +vectors and require a predicate-free builder. + ## Opening and Scanning a Table The following program opens `default.my_table` from a filesystem catalog and