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: support in-memory datasets #1743

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

changhiskhan
Copy link
Contributor

To support in-memory LanceDB tables, we want to be able to keep a reference to the same object store across various dataset operations. This required the following changes:

  1. Expose checkout method in the python lance dataset
  2. Expose a write instance in the dataset for append/overwrite
  3. Add overwrite to the rust dataset (like we have append)
  4. Rename the existing write_data to write_to_uri to disambiguate from the write_data instance methods

Copy link
Contributor

@wjones127 wjones127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we try to reduce the number of API changes here?

@@ -467,28 +468,29 @@ impl Dataset {
/// Returns the newly created [`Dataset`].
/// Or Returns [Error] if the dataset already exists.
///
pub async fn write(
pub async fn write_to_uri(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we have to rename this? It seems like it really blew up the scope of the PR and is still causing CI failures.

Comment on lines +562 to 575
pub async fn overwrite(
&mut self,
batches: impl RecordBatchReader + Send + 'static,
params: Option<WriteParams>,
) -> Result<()> {
// Box it so we don't monomorphize for every one. We take the generic
// parameter for API ergonomics.
let batches = Box::new(batches);
let params = params.unwrap_or_else(|| WriteParams {
mode: WriteMode::Overwrite,
..Default::default()
});
self.write_impl(batches, params).await
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this does more than just overwrite if the user passes WriteParams with mode other than WriteMode::Overwrite, so perhaps this is not a great name? Could do something like write_into().

self,
data_obj: ReaderLike,
schema: Optional[Schema] = None,
mode: str = "append",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can get much better auto-complete if you use Literal.

Suggested change
mode: str = "append",
mode: Literal["append", "overwrite"] = "append",

Comment on lines +97 to +99
def __init__(self, _ds: _Dataset):
self._uri = _ds.uri
self._ds = _ds
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to break so much existing code...

Could we instead just make a classmethod and keep the existing init method:

@classmethod
def _from_inner(cls, ds: _Dataset):
    self = cls.__new__()
    self._uri = _ds.uri
    self._ds = _ds
    return self

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants