-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #3160
- Loading branch information
Showing
7 changed files
with
158 additions
and
28 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ APIs | |
.. toctree:: | ||
|
||
Rust <https://docs.rs/crate/lance/latest> | ||
Python <./python/modules> | ||
Python <./python.rst> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
Python APIs | ||
=========== | ||
|
||
``Lance`` is a columnar format that is specifically designed for efficient | ||
multi-modal data processing. | ||
|
||
Lance Dataset | ||
------------- | ||
|
||
The core of Lance is the ``LanceDataset`` class. User can open a dataset by using | ||
:py:meth:`lance.dataset`. | ||
|
||
.. autofunction:: lance.dataset | ||
:noindex: | ||
|
||
Basic IOs | ||
~~~~~~~~~ | ||
|
||
The following functions are used to read and write data in Lance format. | ||
|
||
.. automethod:: lance.dataset.LanceDataset.insert | ||
:noindex: | ||
.. automethod:: lance.dataset.LanceDataset.scanner | ||
:noindex: | ||
.. automethod:: lance.dataset.LanceDataset.to_batches | ||
:noindex: | ||
.. automethod:: lance.dataset.LanceDataset.to_table | ||
:noindex: | ||
|
||
Random Access | ||
~~~~~~~~~~~~~ | ||
|
||
Lance stands out with its super fast random access, unlike other columnar formats. | ||
|
||
.. automethod:: lance.dataset.LanceDataset.take | ||
:noindex: | ||
.. automethod:: lance.dataset.LanceDataset.take_blobs | ||
:noindex: | ||
|
||
|
||
Schema Evolution | ||
~~~~~~~~~~~~~~~~ | ||
|
||
Lance supports schema evolution, which means that you can add new columns to the dataset | ||
cheaply. | ||
|
||
.. automethod:: lance.dataset.LanceDataset.add_columns | ||
:noindex: | ||
.. automethod:: lance.dataset.LanceDataset.drop_columns | ||
:noindex: | ||
|
||
|
||
Indexing and Searching | ||
~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. automethod:: lance.dataset.LanceDataset.create_index | ||
:noindex: | ||
.. automethod:: lance.dataset.LanceDataset.scanner | ||
:noindex: | ||
|
||
API Reference | ||
~~~~~~~~~~~~~ | ||
|
||
More information can be found in the :doc:`API reference <python/modules>`. | ||
|
||
.. _Lance Python API documentation: ./python/modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Blob As Files | ||
============= | ||
|
||
Unlike other data formats, large multimodal data is a first-class citizen in the Lance columnar format. | ||
Lance provides a high-level API to store and retrieve large binary objects (blobs) in Lance datasets. | ||
|
||
.. image:: _static/blob.png | ||
:scale: 50% | ||
|
||
Lance serves large binary data using :py:class:`lance.BlobFile`, which | ||
is a file-like object that lazily reads large binary objects. | ||
|
||
.. autoclass:: lance.BlobFile | ||
:members: | ||
:show-inheritance: | ||
:noindex: | ||
|
||
To fetch blobs from a Lance dataset, you can use :py:meth:`lance.dataset.LanceDataset.take_blobs`. | ||
|
||
For example, it's easy to use `BlobFile` to extract frames from a video file without | ||
loading the entire video into memory. | ||
|
||
.. code-block:: python | ||
# pip install av pylance | ||
import av | ||
import lance | ||
ds = lance.dataset("./youtube.lance") | ||
start_time, end_time = 500, 1000 | ||
blobs = ds.take_blobs([5], "video") | ||
with av.open(blobs[0]) as container: | ||
stream = container.streams.video[0] | ||
stream.codec_context.skip_frame = "NONKEY" | ||
start_time = start_time / stream.time_base | ||
start_time = start_time.as_integer_ratio()[0] | ||
end_time = end_time / stream.time_base | ||
container.seek(start_time, stream=stream) | ||
for frame in container.decode(stream): | ||
if frame.time > end_time: | ||
break | ||
display(frame.to_image()) | ||
clear_output(wait=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters