Skip to content

Commit fd702f2

Browse files
authored
Add helper function annotations for Rust snippets (#192)
1 parent 6758938 commit fd702f2

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

docs/quickstart.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ The vector column holds 3-dimensional embeddings representing each character.
145145
To ingest the data into LanceDB, obtain data of the required shape
146146
and pass in the data object to the `create_table` method as shown below.
147147
Note that LanceDB tables require a schema. If you don't provide one, LanceDB
148-
will infer it from the data.
148+
will infer it from the data. For the Rust snippet, you can find the helper functions in the
149+
[code](https://github.com/lancedb/docs/blob/main/tests/rs/quickstart.rs).
149150

150151
<CodeGroup >
151152
<CodeBlock filename="Python (sync)" language="Python" icon="python">
@@ -210,11 +211,10 @@ to be used downstream in your application.
210211
</CodeBlock>
211212
</Accordion>
212213

213-
214214
<Info>
215215
See the full code for these examples (including helper functions) in the
216216
`quickstart` file for the appropriate client language in the
217-
[docs repo](https://github.com/lancedb/docs/tree/main/tests).
217+
[files provided here](https://github.com/lancedb/docs/tree/main/tests).
218218
</Info>
219219

220220

docs/snippets/quickstart.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const RsQuickstartCreateTable = "// Define an arrow schema named adventur
4040

4141
export const RsQuickstartCreateTableNoOverwrite = "table = db\n .create_table(\"adventurers\", adventurers_to_reader(schema.clone(), &data))\n .execute()\n .await\n .unwrap();\n";
4242

43-
export const RsQuickstartDefineStruct = "// Define a struct representing the data schema\n#[derive(Debug, Clone, Serialize, Deserialize)]\nstruct Adventurer {\n id: String,\n text: String,\n vector: [f32; 3],\n}\n";
43+
export const RsQuickstartDefineStruct = "// Define a struct representing the data schema\n#[derive(Debug, Clone, Serialize, Deserialize)]\nstruct Adventurer {\n id: String,\n text: String,\n vector: [f32; 3],\n}\n\nfn adventurers_schema() -> Arc<Schema> {\n Arc::new(Schema::new(vec![\n Field::new(\"id\", DataType::LargeUtf8, false),\n Field::new(\"text\", DataType::LargeUtf8, false),\n Field::new(\n \"vector\",\n DataType::FixedSizeList(Arc::new(Field::new(\"item\", DataType::Float32, true)), 3),\n false,\n ),\n ]))\n}\n";
4444

4545
export const RsQuickstartOpenTable = "let table: Table = db.open_table(\"adventurers\").execute().await.unwrap();\n";
4646

docs/tables/index.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ existing table named `camelot`.
353353
</CodeGroup>
354354

355355
Prepare the new records to add. Here, we add two new magical characters
356-
via the `add` method.
356+
via the `add` method. For the Rust snippet, you can find the helper functions in the
357+
[code](https://github.com/lancedb/docs/blob/main/tests/rs/basic_usage.rs).
357358

358359
<CodeGroup >
359360
<CodeBlock filename="Python" language="Python" icon="Python">

tests/rs/quickstart.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ struct Adventurer {
2121
text: String,
2222
vector: [f32; 3],
2323
}
24-
// --8<-- [end:quickstart_define_struct]
2524

2625
fn adventurers_schema() -> Arc<Schema> {
2726
Arc::new(Schema::new(vec![
@@ -34,6 +33,7 @@ fn adventurers_schema() -> Arc<Schema> {
3433
),
3534
]))
3635
}
36+
// --8<-- [end:quickstart_define_struct]
3737

3838
type BatchIter = RecordBatchIterator<
3939
std::vec::IntoIter<std::result::Result<RecordBatch, arrow_schema::ArrowError>>,

0 commit comments

Comments
 (0)