Skip to content
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

feat: log the number of rows we were able to sample #3367

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions rust/lance/src/index/vector/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::sync::Arc;

use arrow_array::{cast::AsArray, FixedSizeListArray};
use lance_core::datatypes::Schema;
use log::info;
use snafu::{location, Location};
use tokio::sync::Mutex;

Expand Down Expand Up @@ -86,11 +87,21 @@ pub async fn maybe_sample_training_data(
let num_rows = dataset.count_rows(None).await?;
let batch = if num_rows > sample_size_hint {
let projection = dataset.schema().project(&[column])?;
dataset.sample(sample_size_hint, &projection).await?
let batch = dataset.sample(sample_size_hint, &projection).await?;
info!(
"Sample training data: retrieved {} rows by sampling",
batch.num_rows()
);
batch
} else {
let mut scanner = dataset.scan();
scanner.project(&[column])?;
scanner.try_into_batch().await?
let batch = scanner.try_into_batch().await?;
info!(
"Sample training data: retrieved {} rows scanning full datasets",
batch.num_rows()
);
batch
};

let array = batch.column_by_name(column).ok_or(Error::Index {
Expand Down
Loading