lance_core/
traits.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright The Lance Authors
3
4//! Dataset Traits
5
6use std::fmt::Debug;
7
8use arrow_array::RecordBatch;
9
10use crate::{datatypes::Schema, Result};
11
12/// `TakeRow` trait.
13///
14/// It offers a lightweight trait to use `take_rows()` over a dataset, without
15/// depending on the `lance` trait.
16///
17/// <section class="warning">
18/// Internal API
19/// </section>
20#[async_trait::async_trait]
21pub trait DatasetTakeRows: Debug + Send + Sync {
22    /// The schema of the dataset.
23    fn schema(&self) -> &Schema;
24
25    /// Take rows by the internal ROW ids.
26    async fn take_rows(&self, row_ids: &[u64], projection: &Schema) -> Result<RecordBatch>;
27}