Skip to content
Open
Show file tree
Hide file tree
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
58 changes: 28 additions & 30 deletions docs/src/distributed-indexing.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,7 @@ dataset = lance.dataset("path/to/dataset")

# Build distributed index
updated_dataset = lr.create_scalar_index(
uri=dataset.uri,
column="text",
index_type="INVERTED",
num_workers=4
uri=dataset.uri, column="text", index_type="INVERTED", num_workers=4
)

# Verify index creation
Expand All @@ -282,8 +279,7 @@ print(f"Index list: {indices}")

# Use index for search
results = updated_dataset.scanner(
full_text_query="search term",
columns=["id", "text"]
full_text_query="search term", columns=["id", "text"]
).to_table()
print(f"Search results: {results}")
```
Expand All @@ -304,7 +300,9 @@ updated_dataset = lr.create_scalar_index(

# Example queries
updated_dataset.scanner(filter="id = 100", columns=["id", "text"]).to_table()
updated_dataset.scanner(filter="id >= 200 AND id < 800", columns=["id", "text"]).to_table()
updated_dataset.scanner(
filter="id >= 200 AND id < 800", columns=["id", "text"]
).to_table()
```

### Vector Index (IVF_PQ / IVF_RQ / IVF_SQ / IVF_FLAT)
Expand All @@ -321,7 +319,7 @@ updated_dataset = lr.create_index(
num_partitions=256,
num_sub_vectors=16,
sample_rate=64,
metric="l2"
metric="l2",
)

# Build a distributed IVF_SQ index
Expand Down Expand Up @@ -399,11 +397,11 @@ print(plan)

```python
updated_dataset = lr.create_scalar_index(
uri="path/to/dataset",
column="text",
index_type="INVERTED",
num_workers=4,
ray_remote_args={"num_cpus": 2, "resources": {"custom_resource": 1}}
uri="path/to/dataset",
column="text",
index_type="INVERTED",
num_workers=4,
ray_remote_args={"num_cpus": 2, "resources": {"custom_resource": 1}},
)
```

Expand Down Expand Up @@ -444,34 +442,34 @@ The current global Pool integration is limited to `vector_search()`. The same p
```python
# Create index with custom name
updated_dataset = lr.create_scalar_index(
uri="path/to/dataset",
column="text",
index_type="INVERTED",
name="my_text_index",
num_workers=4
uri="path/to/dataset",
column="text",
index_type="INVERTED",
name="my_text_index",
num_workers=4,
)

# Try to create another index with the same name (will replace by default)
updated_dataset = lr.create_scalar_index(
uri="path/to/dataset",
column="text",
index_type="INVERTED",
name="my_text_index", # Same name as before
replace=True, # Explicitly allow replacement (default behavior)
num_workers=4
uri="path/to/dataset",
column="text",
index_type="INVERTED",
name="my_text_index", # Same name as before
replace=True, # Explicitly allow replacement (default behavior)
num_workers=4,
)

# Prevent index replacement
import lance_ray as lr

try:
updated_dataset = lr.create_scalar_index(
uri="path/to/dataset",
column="text",
index_type="INVERTED",
name="my_text_index", # Same name as existing index
replace=False, # Prevent replacement
num_workers=4
uri="path/to/dataset",
column="text",
index_type="INVERTED",
name="my_text_index", # Same name as existing index
replace=False, # Prevent replacement
num_workers=4,
)
except ValueError as e:
print(f"Index creation failed: {e}")
Expand Down
24 changes: 10 additions & 14 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ print(f"Filtered count: {filtered_ds.count()}")

# Read with column selection and filtering
ds_filtered = read_lance(
"sample_dataset.lance",
columns=["user_id", "name", "score"],
filter="score > 75.0"
"sample_dataset.lance", columns=["user_id", "name", "score"], filter="score > 75.0"
)
print(f"Schema: {ds_filtered.schema()}")
```
Expand All @@ -51,16 +49,14 @@ print(f"Schema: {ds_filtered.schema()}")
from lance_ray import add_columns
import pyarrow as pa


def add_computed_column(batch: pa.RecordBatch) -> pa.RecordBatch:
df = batch.to_pandas()
df['computed'] = df['value'] * 2 + df['id']
df["computed"] = df["value"] * 2 + df["id"]
return pa.RecordBatch.from_pandas(df[["computed"]])

add_columns(
uri="sample_dataset.lance",
transform=add_computed_column,
concurrency=4
)

add_columns(uri="sample_dataset.lance", transform=add_computed_column, concurrency=4)
```

## Using Namespace
Expand Down Expand Up @@ -110,7 +106,7 @@ from lance_ray import read_lance, write_lance
# Initialize Ray
ray.init()

# Connect to AWS Glue catalog
# Connect to AWS Glue catalog
# using the default account and region in the current AWS environment
namespace = ln.connect("glue", {})

Expand All @@ -119,10 +115,10 @@ data = ray.data.range(1000).map(lambda row: {"id": row["id"], "value": row["id"]

# Write to Lance format using metadata catalog
write_lance(
data,
uri="s3://my-bucket/my-table",
namespace=namespace,
table_id=["default", "my_table"]
data,
uri="s3://my-bucket/my-table",
namespace=namespace,
table_id=["default", "my_table"],
)

# Read Lance dataset back using metadata catalog
Expand Down
13 changes: 1 addition & 12 deletions lance_ray/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,7 @@ def get_read_tasks(self, parallelism: int, **kwargs) -> list[ReadTask]:
)

read_task = ReadTask(
lambda fids=fragment_ids,
uri=dataset_uri,
version=dataset_version,
storage_options=dataset_storage_options,
manifest=serialized_manifest,
ns_impl=namespace_impl,
ns_props=namespace_properties,
tbl_id=table_id,
base_params=base_store_params,
scanner_options=self._scanner_options,
retry_params=self._retry_params,
with_metadata=self._with_metadata: (
lambda fids=fragment_ids, uri=dataset_uri, version=dataset_version, storage_options=dataset_storage_options, manifest=serialized_manifest, ns_impl=namespace_impl, ns_props=namespace_properties, tbl_id=table_id, base_params=base_store_params, scanner_options=self._scanner_options, retry_params=self._retry_params, with_metadata=self._with_metadata: (
_read_fragments_with_retry(
fids,
uri,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ classifiers = [

dependencies = [
"ray[data]>=2.41.0",
"pylance>=9.0.0",
"pylance>=10.0.0b5",
"lance-namespace",
"packaging",
"pyarrow>=17.0.0",
Expand Down
18 changes: 9 additions & 9 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading