-
Notifications
You must be signed in to change notification settings - Fork 784
feat(tools): add table manifest command #7970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,15 +27,25 @@ use crate::format::{DataStorageFormat, IndexMetadata, MAGIC, Manifest, Transacti | |
|
|
||
| use super::commit::ManifestLocation; | ||
|
|
||
| /// Read Manifest on URI. | ||
| /// Read the raw Manifest protobuf from a URI. | ||
| /// | ||
| /// This only reads manifest files. It does not read data files. | ||
| /// This only reads manifest files. It does not read data files or translate the | ||
| /// protobuf into the semantic [`Manifest`] type. | ||
| #[instrument(level = "debug", skip(object_store))] | ||
| pub async fn read_manifest( | ||
| pub async fn read_manifest_proto( | ||
| object_store: &ObjectStore, | ||
| path: &Path, | ||
| known_size: Option<u64>, | ||
| ) -> Result<Manifest> { | ||
| ) -> Result<pb::Manifest> { | ||
| let buf = read_manifest_bytes(object_store, path, known_size).await?; | ||
| Ok(pb::Manifest::decode(buf)?) | ||
|
Comment on lines
+35
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win Add direct coverage for the new raw-protobuf API.
As per coding guidelines, “Every bugfix and feature must have corresponding tests.” 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| } | ||
|
|
||
| async fn read_manifest_bytes( | ||
| object_store: &ObjectStore, | ||
| path: &Path, | ||
| known_size: Option<u64>, | ||
| ) -> Result<Bytes> { | ||
| let file_size = if let Some(known_size) = known_size { | ||
| known_size | ||
| } else { | ||
|
|
@@ -52,7 +62,7 @@ pub async fn read_manifest( | |
| // In case of corruption, the known_size might be wrong. We can retry without | ||
| // the size to be more robust. | ||
| if (buf.len() < 16 || !buf.ends_with(MAGIC)) && known_size.is_some() { | ||
| return Box::pin(read_manifest(object_store, path, None)).await; | ||
| return Box::pin(read_manifest_bytes(object_store, path, None)).await; | ||
| } | ||
|
|
||
| if buf.len() < 16 { | ||
|
|
@@ -104,39 +114,20 @@ pub async fn read_manifest( | |
| ))); | ||
| } | ||
|
|
||
| let proto = pb::Manifest::decode(buf)?; | ||
| Manifest::try_from(proto) | ||
| Ok(buf) | ||
| } | ||
|
|
||
| #[instrument(level = "debug", skip(object_store, manifest))] | ||
| pub async fn read_manifest_indexes( | ||
| /// Read Manifest on URI. | ||
| /// | ||
| /// This only reads manifest files. It does not read data files. | ||
| #[instrument(level = "debug", skip(object_store))] | ||
| pub async fn read_manifest( | ||
| object_store: &ObjectStore, | ||
| location: &ManifestLocation, | ||
| manifest: &Manifest, | ||
| ) -> Result<Vec<IndexMetadata>> { | ||
| if let Some(pos) = manifest.index_section.as_ref() { | ||
| let result = read_index_section(object_store, &location.path, location.size, *pos).await; | ||
| // A stale cached size makes the index offset fall outside the sized view, | ||
| // so the read fails as "file size is too small". Retry once with the true | ||
| // size; surface any other error unchanged. | ||
| let section = match result { | ||
| Err(e) | ||
| if location.size.is_some() && e.to_string().contains("file size is too small") => | ||
| { | ||
| read_index_section(object_store, &location.path, None, *pos).await? | ||
| } | ||
| other => other?, | ||
| }; | ||
|
|
||
| let indices = section | ||
| .indices | ||
| .into_iter() | ||
| .map(IndexMetadata::try_from) | ||
| .collect::<Result<Vec<_>>>()?; | ||
| Ok(indices) | ||
| } else { | ||
| Ok(vec![]) | ||
| } | ||
| path: &Path, | ||
| known_size: Option<u64>, | ||
| ) -> Result<Manifest> { | ||
| let proto = read_manifest_proto(object_store, path, known_size).await?; | ||
| Manifest::try_from(proto) | ||
| } | ||
|
|
||
| /// Read the index section message at `pos`, opening the manifest with a known | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,17 @@ | ||
| # lance-tools | ||
|
|
||
| `lance-tools` is a command-line tool for interacting with Lance files and tables. | ||
|
|
||
| ## Commands | ||
|
|
||
| Display Lance file footer metadata: | ||
|
|
||
| ```bash | ||
| lance-tools file meta --source path/to/file.lance | ||
| ``` | ||
|
|
||
| Display a Lance table manifest: | ||
|
|
||
| ```bash | ||
| lance-tools table manifest --source path/to/table/_versions/1.manifest | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,6 @@ | |
| // SPDX-FileCopyrightText: Copyright The Lance Authors | ||
|
|
||
| pub mod cli; | ||
| pub mod manifest; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Files:"
git ls-files | rg '(^|/)lib\.rs$|(^|/)cli\.rs$|(^|/)manifest\.rs$|Cargo\.toml$'
echo
echo "lib.rs:"
sed -n '1,80p' rust/lance-tools/src/lib.rs
echo
echo "manifest.rs outline:"
ast-grep outline rust/lance-tools/src/manifest.rs --view compact || true
echo
echo "manifest.rs relevant entries:"
rg -n "^(pub )?|show_table_manifest|TableManifest|struct |enum " rust/lance-tools/src/manifest.rs
echo
echo "cli.rs manifest usages:"
rg -n "crate::manifest|manifest::|show_table_manifest|lance_tools::manifest" rust/lance-tools/src/cli.rs
echo
echo "workspace/crate config relevant:"
sed -n '1,160p' rust/lance-tools/Cargo.tomlRepository: lance-format/lance Length of output: 50374 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "lance-tools package metadata:"
python3 - <<'PY'
import configparser, re, json
p='rust/lance-tools/Cargo.toml'
text=open(p).read()
print(text)
PY
echo
echo "manifest struct visibility and internal call path:"
rg -n -C 3 '^(pub )?(struct LanceToolManifest|enum OptionalSection|struct IndexView|struct TransactionView|struct TransactionSource|struct ManifestSource|async fn open|impl LanceToolManifest|pub\(crate\) async fn show_table_manifest)' rust/lance-tools/src/manifest.rs
rg -n -C 2 'LanceTableManifestArgs|show_table_manifest|crate::manifest::manifest_path|manifest::show_table_manifest' rust/lance-tools/src/cli.rs rust/lance-tools/src/*.rs
echo
echo "all external references to lance_tools::manifest / crate::manifest outside lance-tools:"
rg -n 'lance_tools::manifest|lance-tools::manifest|lance_tools::util|crate::manifest|manifest::show_table_manifest' --glob '!rust/lance-tools/**' .
echo
echo "all references to public types in manifest.rs (excluding tests/internal helpers if apparent):"
rg -n 'LanceToolManifest|OptionalSection|IndexView|TransactionView|TransactionSource|ManifestSource' rust/lance-tools/src/manifest.rsRepository: lance-format/lance Length of output: 5693 Keep the manifest module crate-private.
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| pub mod meta; | ||
| pub mod util; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Document both public manifest readers with synchronized examples.
rust/lance-table/src/io/manifest.rs#L30-L33: add a compiling example forread_manifest_protoand link its protobuf/semantic output types.rust/lance-table/src/io/manifest.rs#L120-L122: add a compiling example forread_manifestand link relevant types or methods.As per coding guidelines, “Document all public APIs with examples and links to relevant structs and methods; keep examples synchronized with actual signatures.”
📍 Affects 1 file
rust/lance-table/src/io/manifest.rs#L30-L33(this comment)rust/lance-table/src/io/manifest.rs#L120-L122🤖 Prompt for AI Agents
Source: Coding guidelines