Files
lancedb/docs/web/snippets/ingestion_progress.mdx
Brendan Clement 758f738b8c docs: complete ingestion, search and integration examples (#4533)
This PR is part of the documentation revamp. Once the full set of PRs is
merged, we’ll publish the combined site to staging for review before
updating docs.lancedb.com.

Ingestion, search and integration examples are incomplete or
inconsistent across languages, and some guidance misstates SDK behavior.

This brings the guides and their example sources together. It includes
complete Python, TypeScript and Rust workflows, isolated provider and
reranker examples, the Superlinked corrections, and guidance on retries
that can duplicate writes.

Stacked on #4491. Each MDX file has one PR owner. Rebase onto main after
#4491 is squash-merged.

Local assembly, Mint validation and link checks pass. Example code is
unchanged from the previously validated package. Publication stays held
through integration.
2026-10-15 14:54:08 -07:00

5 lines
2.0 KiB
Plaintext

{/* Auto-generated by scripts/mdx_snippets_gen.py. Do not edit manually. */}
export const RsExample = "use std::sync::Arc;\n\nuse arrow_array::{Int64Array, RecordBatch, RecordBatchIterator, RecordBatchReader, StringArray};\nuse arrow_schema::{DataType, Field, Schema};\nuse futures::TryStreamExt;\nuse lancedb::query::ExecutableQuery;\n\nfn make_users_reader(rows: &[(i64, &str)]) -> Box<dyn RecordBatchReader + Send> {\n let schema = Arc::new(Schema::new(vec![\n Field::new(\"id\", DataType::Int64, false),\n Field::new(\"name\", DataType::Utf8, false),\n ]));\n let batch = RecordBatch::try_new(\n schema.clone(),\n vec![\n Arc::new(Int64Array::from_iter_values(rows.iter().map(|r| r.0))),\n Arc::new(StringArray::from_iter_values(rows.iter().map(|r| r.1))),\n ],\n )\n .unwrap();\n Box::new(RecordBatchIterator::new(\n vec![Ok(batch)].into_iter(),\n schema,\n ))\n}\n\n#[tokio::main]\nasync fn main() -> Result<(), Box<dyn std::error::Error>> {\n let directory = tempfile::tempdir()?;\n let db = lancedb::connect(directory.path().to_str().unwrap())\n .execute()\n .await?;\n let table = db\n .create_table(\"users\", make_users_reader(&[(1, \"Alice\")]))\n .execute()\n .await?;\n table\n .add(make_users_reader(&[(2, \"Bob\"), (3, \"Charlie\")]))\n .progress(|progress| println!(\"Rows written: {}\", progress.output_rows()))\n .execute()\n .await?;\n let rows: Vec<RecordBatch> = table.query().execute().await?.try_collect().await?;\n println!(\"After insertion: {rows:?}\");\n assert_eq!(table.count_rows(None).await?, 3);\n assert_eq!(\n table\n .count_rows(Some(\"id = 1 AND name = 'Alice'\".into()))\n .await?,\n 1\n );\n assert_eq!(\n table\n .count_rows(Some(\"id = 2 AND name = 'Bob'\".into()))\n .await?,\n 1\n );\n assert_eq!(table.count_rows(Some(\"id = 3\".into())).await?, 1);\n Ok(())\n}\n";