mirror of
https://github.com/lancedb/lancedb.git
synced 2026-06-05 05:10:41 +00:00
Compare commits
1 Commits
python-v0.
...
codex/upda
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3bed9b6db8 |
@@ -1,7 +0,0 @@
|
|||||||
# Agent Skills
|
|
||||||
|
|
||||||
This directory contains repo-scoped code agent skills for the LanceDB project.
|
|
||||||
|
|
||||||
Each skill is a folder that contains a required `SKILL.md` and optional bundled resources.
|
|
||||||
|
|
||||||
Codex discovers skills from `.agents/skills` in the current working directory and parent directories.
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
---
|
|
||||||
name: lancedb-update-lance-dependency
|
|
||||||
description: Update LanceDB to a specific Lance release or tag. Use when bumping Lance dependencies in the lancedb repository, including Rust workspace Lance crates, Java lance-core, validation, branch creation, commit, push, and PR creation when requested.
|
|
||||||
---
|
|
||||||
|
|
||||||
# LanceDB Update Lance Dependency
|
|
||||||
|
|
||||||
## Scope
|
|
||||||
|
|
||||||
Use this skill in the `lancedb/lancedb` repository when updating the Lance dependency to a specific Lance version or tag.
|
|
||||||
|
|
||||||
Inputs can be a version (`7.2.0-beta.1`), a tag (`v7.2.0-beta.1`), a tag ref (`refs/tags/v7.2.0-beta.1`), or `latest`.
|
|
||||||
|
|
||||||
## Workflow
|
|
||||||
|
|
||||||
1. Confirm the worktree status with `git status --short`.
|
|
||||||
2. Resolve the target Lance version:
|
|
||||||
|
|
||||||
- If the input is `latest`, empty, or omitted, run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python3 ci/check_lance_release.py
|
|
||||||
```
|
|
||||||
|
|
||||||
Parse the JSON output. If `needs_update` is not `true`, stop without creating a PR. Otherwise use `latest_tag`.
|
|
||||||
|
|
||||||
- If the input is explicit, use it directly.
|
|
||||||
|
|
||||||
3. Compute update metadata without changing files:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python3 ci/update_lance_dependency.py "$TAG_OR_VERSION" --metadata-only
|
|
||||||
```
|
|
||||||
|
|
||||||
Before making changes, check for an existing open PR with the emitted `pr_title`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
gh pr list --search "\"$PR_TITLE\" in:title" --state open --limit 1 --json number,url,title
|
|
||||||
```
|
|
||||||
|
|
||||||
If a matching open PR exists, stop and report it instead of creating a duplicate.
|
|
||||||
|
|
||||||
4. Run the deterministic update entrypoint:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python3 ci/update_lance_dependency.py "$TAG_OR_VERSION"
|
|
||||||
```
|
|
||||||
|
|
||||||
This updates the Rust workspace Lance dependencies through `ci/set_lance_version.py`, updates `java/pom.xml`, refreshes Cargo metadata, and prints JSON metadata containing `branch_name`, `commit_message`, and `pr_title`.
|
|
||||||
|
|
||||||
5. Run validation:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cargo clippy --quiet --workspace --tests --all-features -- -D warnings
|
|
||||||
cargo fmt --all --quiet
|
|
||||||
```
|
|
||||||
|
|
||||||
Fix real diagnostics and rerun clippy until it succeeds. Do not skip warnings.
|
|
||||||
|
|
||||||
6. Inspect `git status --short` and `git diff` to ensure only the Lance dependency update and required compatibility fixes are present.
|
|
||||||
|
|
||||||
7. If the task only asks to prepare local changes, stop here and report the changed files and validation result.
|
|
||||||
|
|
||||||
8. If the task asks to publish the update, create a branch using the printed `branch_name`, stage all relevant files, and commit using the printed `commit_message`. Do not amend or rewrite existing commits.
|
|
||||||
|
|
||||||
9. Push to `origin`. Before creating the PR, check that the current token has push permission:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
gh api repos/lancedb/lancedb --jq .permissions.push
|
|
||||||
```
|
|
||||||
|
|
||||||
If the remote branch already exists for the same generated branch name, delete the remote ref with `gh api -X DELETE repos/lancedb/lancedb/git/refs/heads/$BRANCH_NAME`, then push. Do not force-push.
|
|
||||||
|
|
||||||
10. Create a PR targeting `main` with the printed `pr_title`. If there is no PR template, keep the body to two or three concise sentences: state the Lance dependency bump, note any required compatibility fixes, and link the triggering Lance tag or release.
|
|
||||||
|
|
||||||
11. Read back the remote PR title after creation. If it is not a Conventional Commit title, fix it immediately.
|
|
||||||
|
|
||||||
12. When running in GitHub Actions after creating the LanceDB PR, trigger the Sophon dependency update:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
gh workflow run codex-bump-lancedb-lance.yml \
|
|
||||||
--repo lancedb/sophon \
|
|
||||||
-f lance_ref="$LANCE_TAG" \
|
|
||||||
-f lancedb_ref="$BRANCH_NAME"
|
|
||||||
gh run list --repo lancedb/sophon --workflow codex-bump-lancedb-lance.yml --limit 1 --json databaseId,url,displayTitle
|
|
||||||
```
|
|
||||||
|
|
||||||
Use the emitted metadata `tag` value as `LANCE_TAG`. Do this only after a new LanceDB PR has been created. If the update was skipped because no update is needed or an open PR already exists, do not trigger Sophon.
|
|
||||||
|
|
||||||
## GitHub Actions
|
|
||||||
|
|
||||||
When this skill is used from GitHub Actions, `TAG`, `GH_TOKEN`, and `GITHUB_TOKEN` may already be set. Resolve `latest` first when `TAG` is empty. Once an explicit tag or version is known, use:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python3 ci/update_lance_dependency.py "$TAG" --github-output "$GITHUB_OUTPUT"
|
|
||||||
```
|
|
||||||
|
|
||||||
Then use the emitted `branch_name`, `commit_message`, and `pr_title` values for branch, commit, and PR creation.
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[tool.bumpversion]
|
[tool.bumpversion]
|
||||||
current_version = "0.30.1-beta.0"
|
current_version = "0.28.0-beta.1"
|
||||||
parse = """(?x)
|
parse = """(?x)
|
||||||
(?P<major>0|[1-9]\\d*)\\.
|
(?P<major>0|[1-9]\\d*)\\.
|
||||||
(?P<minor>0|[1-9]\\d*)\\.
|
(?P<minor>0|[1-9]\\d*)\\.
|
||||||
|
|||||||
2
.github/ISSUE_TEMPLATE/documentation.yml
vendored
2
.github/ISSUE_TEMPLATE/documentation.yml
vendored
@@ -18,6 +18,6 @@ body:
|
|||||||
label: Link
|
label: Link
|
||||||
description: >
|
description: >
|
||||||
Provide a link to the existing documentation, if applicable.
|
Provide a link to the existing documentation, if applicable.
|
||||||
placeholder: ex. https://docs.lancedb.com/tables/...
|
placeholder: ex. https://lancedb.com/docs/tables/...
|
||||||
validations:
|
validations:
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
23
.github/dependabot.yml
vendored
23
.github/dependabot.yml
vendored
@@ -1,23 +0,0 @@
|
|||||||
version: 2
|
|
||||||
|
|
||||||
# Scope: the root Cargo workspace, which produces the Rust binaries we
|
|
||||||
# ship to users (the Node.js and Python native extensions). The
|
|
||||||
# `rust/lancedb` library crate shares the same lockfile; its consumers
|
|
||||||
# pick their own dependency versions, but bumping transitive deps here
|
|
||||||
# keeps the binaries we ship current.
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: cargo
|
|
||||||
directory: /
|
|
||||||
schedule:
|
|
||||||
interval: weekly
|
|
||||||
open-pull-requests-limit: 10
|
|
||||||
# Only update Cargo.lock, never widen/raise the version requirements in
|
|
||||||
# Cargo.toml. The goal is keeping the lockfile (and the binaries we ship)
|
|
||||||
# current on security fixes, not forcing our library's consumers onto
|
|
||||||
# newer minimum versions.
|
|
||||||
versioning-strategy: lockfile-only
|
|
||||||
groups:
|
|
||||||
rust-minor-patch:
|
|
||||||
update-types:
|
|
||||||
- minor
|
|
||||||
- patch
|
|
||||||
@@ -29,3 +29,7 @@ runs:
|
|||||||
args: ${{ inputs.args }}
|
args: ${{ inputs.args }}
|
||||||
docker-options: "-e PIP_EXTRA_INDEX_URL='https://pypi.fury.io/lance-format/ https://pypi.fury.io/lancedb/'"
|
docker-options: "-e PIP_EXTRA_INDEX_URL='https://pypi.fury.io/lance-format/ https://pypi.fury.io/lancedb/'"
|
||||||
working-directory: python
|
working-directory: python
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: windows-wheels
|
||||||
|
path: python\target\wheels
|
||||||
|
|||||||
12
.github/workflows/codex-fix-ci.yml
vendored
12
.github/workflows/codex-fix-ci.yml
vendored
@@ -45,9 +45,7 @@ jobs:
|
|||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
# pnpm 11 (used by the nodejs install step below) requires
|
node-version: 20
|
||||||
# Node >= 22.13; use 24 since 22 hits EOL in October.
|
|
||||||
node-version: 24
|
|
||||||
|
|
||||||
- name: Install Codex CLI
|
- name: Install Codex CLI
|
||||||
run: npm install -g @openai/codex
|
run: npm install -g @openai/codex
|
||||||
@@ -81,14 +79,10 @@ jobs:
|
|||||||
java-version: '11'
|
java-version: '11'
|
||||||
cache: maven
|
cache: maven
|
||||||
|
|
||||||
- name: Setup pnpm
|
|
||||||
uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 11.1.1
|
|
||||||
- name: Install Node.js dependencies for TypeScript bindings
|
- name: Install Node.js dependencies for TypeScript bindings
|
||||||
run: |
|
run: |
|
||||||
cd nodejs
|
cd nodejs
|
||||||
pnpm install --frozen-lockfile
|
npm ci
|
||||||
|
|
||||||
- name: Configure git user
|
- name: Configure git user
|
||||||
run: |
|
run: |
|
||||||
@@ -143,7 +137,7 @@ jobs:
|
|||||||
- For Rust test failures: Run the specific test with "cargo test -p <crate> <test_name>"
|
- For Rust test failures: Run the specific test with "cargo test -p <crate> <test_name>"
|
||||||
- For Python test failures: Build with "cd python && maturin develop" then run "pytest <specific_test_file>::<test_name>"
|
- For Python test failures: Build with "cd python && maturin develop" then run "pytest <specific_test_file>::<test_name>"
|
||||||
- For Java test failures: Run "cd java && mvn test -Dtest=<TestClass>#<testMethod>"
|
- For Java test failures: Run "cd java && mvn test -Dtest=<TestClass>#<testMethod>"
|
||||||
- For TypeScript test failures: Run "cd nodejs && pnpm build && pnpm test -- --testNamePattern='<test_name>'"
|
- For TypeScript test failures: Run "cd nodejs && npm run build && npm test -- --testNamePattern='<test_name>'"
|
||||||
- Do NOT run the full test suite - only run the tests that were failing
|
- Do NOT run the full test suite - only run the tests that were failing
|
||||||
|
|
||||||
7. If the additional guidelines are provided, follow them as well.
|
7. If the additional guidelines are provided, follow them as well.
|
||||||
|
|||||||
@@ -4,16 +4,14 @@ on:
|
|||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
tag:
|
tag:
|
||||||
description: "Tag name from Lance. If omitted, the skill will use the latest Lance release that needs an update."
|
description: "Tag name from Lance"
|
||||||
required: false
|
required: true
|
||||||
default: ""
|
|
||||||
type: string
|
type: string
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
tag:
|
tag:
|
||||||
description: "Tag name from Lance. Leave empty to use the latest Lance release that needs an update."
|
description: "Tag name from Lance"
|
||||||
required: false
|
required: true
|
||||||
default: ""
|
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
@@ -27,7 +25,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Show inputs
|
- name: Show inputs
|
||||||
run: |
|
run: |
|
||||||
echo "tag = ${{ inputs.tag || 'latest' }}"
|
echo "tag = ${{ inputs.tag }}"
|
||||||
|
|
||||||
- name: Checkout Repo LanceDB
|
- name: Checkout Repo LanceDB
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -73,21 +71,65 @@ jobs:
|
|||||||
OPENAI_API_KEY: ${{ secrets.CODEX_TOKEN }}
|
OPENAI_API_KEY: ${{ secrets.CODEX_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
TARGET_TAG="${TAG:-latest}"
|
VERSION="${TAG#refs/tags/}"
|
||||||
|
VERSION="${VERSION#v}"
|
||||||
|
BRANCH_NAME="codex/update-lance-${VERSION//[^a-zA-Z0-9]/-}"
|
||||||
|
|
||||||
|
# Use "chore" for beta/rc versions, "feat" for stable releases
|
||||||
|
if [[ "${VERSION}" == *beta* ]] || [[ "${VERSION}" == *rc* ]]; then
|
||||||
|
COMMIT_TYPE="chore"
|
||||||
|
else
|
||||||
|
COMMIT_TYPE="feat"
|
||||||
|
fi
|
||||||
|
|
||||||
cat <<EOF >/tmp/codex-prompt.txt
|
cat <<EOF >/tmp/codex-prompt.txt
|
||||||
You are running inside the lancedb repository on a GitHub Actions runner.
|
You are running inside the lancedb repository on a GitHub Actions runner. Update the Lance dependency to version ${VERSION} and prepare a pull request for maintainers to review.
|
||||||
|
|
||||||
Use \$lancedb-update-lance-dependency with target "${TARGET_TAG}".
|
Follow these steps exactly:
|
||||||
|
1. Use script "ci/set_lance_version.py" to update Lance Rust dependencies. The script already refreshes Cargo metadata, so allow it to finish even if it takes time.
|
||||||
|
2. Update the Java lance-core dependency version in "java/pom.xml": change the "<lance-core.version>...</lance-core.version>" property to "${VERSION}".
|
||||||
|
3. Run "cargo clippy --workspace --tests --all-features -- -D warnings". If diagnostics appear, fix them yourself and rerun clippy until it exits cleanly. Do not skip any warnings.
|
||||||
|
4. After clippy succeeds, run "cargo fmt --all" to format the workspace.
|
||||||
|
5. Ensure the repository is clean except for intentional changes. Inspect "git status --short" and "git diff" to confirm the dependency update and any required fixes.
|
||||||
|
6. Create and switch to a new branch named "${BRANCH_NAME}" (replace any duplicated hyphens if necessary).
|
||||||
|
7. Stage all relevant files with "git add -A". Commit using the message "${COMMIT_TYPE}: update lance dependency to v${VERSION}".
|
||||||
|
8. Push the branch to origin. If the remote branch already exists, delete it first with "gh api -X DELETE repos/lancedb/lancedb/git/refs/heads/${BRANCH_NAME}" then push with "git push origin ${BRANCH_NAME}". Do NOT use "git push --force" or "git push -f".
|
||||||
|
9. env "GH_TOKEN" is available, use "gh" tools for github related operations like creating pull request.
|
||||||
|
10. Create a pull request targeting "main" with title "${COMMIT_TYPE}: update lance dependency to v${VERSION}". First, write the PR body to /tmp/pr-body.md using a heredoc (cat <<'EOF' > /tmp/pr-body.md). The body should summarize the dependency bump, clippy/fmt verification, and link the triggering tag (${TAG}). Then run "gh pr create --body-file /tmp/pr-body.md".
|
||||||
|
11. After creating the PR, display the PR URL, "git status --short", and a concise summary of the commands run and their results.
|
||||||
|
|
||||||
Constraints:
|
Constraints:
|
||||||
- Use env "GH_TOKEN" for GitHub operations.
|
- Use bash commands; avoid modifying GitHub workflow files other than through the scripted task above.
|
||||||
- Do not merge the pull request.
|
- Do not merge the PR.
|
||||||
- Do not force-push.
|
- If any command fails, diagnose and fix the issue instead of aborting.
|
||||||
- Do not create a duplicate pull request if an open PR already exists for the target Lance version.
|
|
||||||
- If any command fails, diagnose and fix the root cause instead of aborting.
|
|
||||||
- After creating the PR, display the PR URL, "git status --short", and a concise summary of the commands run and their results.
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
printenv OPENAI_API_KEY | codex login --with-api-key
|
printenv OPENAI_API_KEY | codex login --with-api-key
|
||||||
codex --config shell_environment_policy.ignore_default_excludes=true exec --dangerously-bypass-approvals-and-sandbox "$(cat /tmp/codex-prompt.txt)"
|
codex --config shell_environment_policy.ignore_default_excludes=true exec --dangerously-bypass-approvals-and-sandbox "$(cat /tmp/codex-prompt.txt)"
|
||||||
|
|
||||||
|
- name: Trigger sophon dependency update
|
||||||
|
env:
|
||||||
|
TAG: ${{ inputs.tag }}
|
||||||
|
GH_TOKEN: ${{ secrets.ROBOT_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
VERSION="${TAG#refs/tags/}"
|
||||||
|
VERSION="${VERSION#v}"
|
||||||
|
LANCEDB_BRANCH="codex/update-lance-${VERSION//[^a-zA-Z0-9]/-}"
|
||||||
|
|
||||||
|
echo "Triggering sophon workflow with:"
|
||||||
|
echo " lance_ref: ${TAG#refs/tags/}"
|
||||||
|
echo " lancedb_ref: ${LANCEDB_BRANCH}"
|
||||||
|
|
||||||
|
gh workflow run codex-bump-lancedb-lance.yml \
|
||||||
|
--repo lancedb/sophon \
|
||||||
|
-f lance_ref="${TAG#refs/tags/}" \
|
||||||
|
-f lancedb_ref="${LANCEDB_BRANCH}"
|
||||||
|
|
||||||
|
- name: Show latest sophon workflow run
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.ROBOT_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
echo "Latest sophon workflow run:"
|
||||||
|
gh run list --repo lancedb/sophon --workflow codex-bump-lancedb-lance.yml --limit 1 --json databaseId,url,displayTitle
|
||||||
|
|||||||
3
.github/workflows/dev.yml
vendored
3
.github/workflows/dev.yml
vendored
@@ -8,9 +8,6 @@ concurrency:
|
|||||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
labeler:
|
labeler:
|
||||||
permissions:
|
permissions:
|
||||||
|
|||||||
8
.github/workflows/java-publish.yml
vendored
8
.github/workflows/java-publish.yml
vendored
@@ -19,9 +19,6 @@ on:
|
|||||||
paths:
|
paths:
|
||||||
- .github/workflows/java-publish.yml
|
- .github/workflows/java-publish.yml
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
name: Build and Publish
|
name: Build and Publish
|
||||||
@@ -43,7 +40,7 @@ jobs:
|
|||||||
server-username: SONATYPE_USER
|
server-username: SONATYPE_USER
|
||||||
server-password: SONATYPE_TOKEN
|
server-password: SONATYPE_TOKEN
|
||||||
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
|
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE
|
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
|
||||||
- name: Set git config
|
- name: Set git config
|
||||||
run: |
|
run: |
|
||||||
git config --global user.email "dev+gha@lancedb.com"
|
git config --global user.email "dev+gha@lancedb.com"
|
||||||
@@ -58,11 +55,10 @@ jobs:
|
|||||||
echo "use-agent" >> ~/.gnupg/gpg.conf
|
echo "use-agent" >> ~/.gnupg/gpg.conf
|
||||||
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
|
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
|
||||||
export GPG_TTY=$(tty)
|
export GPG_TTY=$(tty)
|
||||||
./mvnw --batch-mode -DskipTests -DpushChanges=false deploy -pl lancedb-core -am -P deploy-to-ossrh
|
./mvnw --batch-mode -DskipTests -DpushChanges=false -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} deploy -pl lancedb-core -am -P deploy-to-ossrh
|
||||||
env:
|
env:
|
||||||
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
|
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
|
||||||
SONATYPE_TOKEN: ${{ secrets.SONATYPE_TOKEN }}
|
SONATYPE_TOKEN: ${{ secrets.SONATYPE_TOKEN }}
|
||||||
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
|
|
||||||
|
|
||||||
report-failure:
|
report-failure:
|
||||||
name: Report Workflow Failure
|
name: Report Workflow Failure
|
||||||
|
|||||||
3
.github/workflows/java.yml
vendored
3
.github/workflows/java.yml
vendored
@@ -24,9 +24,6 @@ on:
|
|||||||
- java/**
|
- java/**
|
||||||
- .github/workflows/java.yml
|
- .github/workflows/java.yml
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-java:
|
build-java:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
|
|||||||
62
.github/workflows/lance-release-timer.yml
vendored
Normal file
62
.github/workflows/lance-release-timer.yml
vendored
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
name: Lance Release Timer
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "*/10 * * * *"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
actions: write
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: lance-release-timer
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
trigger-update:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Check for new Lance tag
|
||||||
|
id: check
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.ROBOT_TOKEN }}
|
||||||
|
run: |
|
||||||
|
python3 ci/check_lance_release.py --github-output "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Look for existing PR
|
||||||
|
if: steps.check.outputs.needs_update == 'true'
|
||||||
|
id: pr
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.ROBOT_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
TITLE="chore: update lance dependency to v${{ steps.check.outputs.latest_version }}"
|
||||||
|
COUNT=$(gh pr list --search "\"$TITLE\" in:title" --state open --limit 1 --json number --jq 'length')
|
||||||
|
if [ "$COUNT" -gt 0 ]; then
|
||||||
|
echo "Open PR already exists for $TITLE"
|
||||||
|
echo "pr_exists=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "No existing PR for $TITLE"
|
||||||
|
echo "pr_exists=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Trigger codex update workflow
|
||||||
|
if: steps.check.outputs.needs_update == 'true' && steps.pr.outputs.pr_exists != 'true'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.ROBOT_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
TAG=${{ steps.check.outputs.latest_tag }}
|
||||||
|
gh workflow run codex-update-lance-dependency.yml -f tag=refs/tags/$TAG
|
||||||
|
|
||||||
|
- name: Show latest codex workflow run
|
||||||
|
if: steps.check.outputs.needs_update == 'true' && steps.pr.outputs.pr_exists != 'true'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.ROBOT_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
gh run list --workflow codex-update-lance-dependency.yml --limit 1 --json databaseId,url,displayTitle
|
||||||
4
.github/workflows/license-header-check.yml
vendored
4
.github/workflows/license-header-check.yml
vendored
@@ -10,10 +10,6 @@ on:
|
|||||||
- nodejs/**
|
- nodejs/**
|
||||||
- java/**
|
- java/**
|
||||||
- .github/workflows/license-header-check.yml
|
- .github/workflows/license-header-check.yml
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-licenses:
|
check-licenses:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
115
.github/workflows/nodejs.yml
vendored
115
.github/workflows/nodejs.yml
vendored
@@ -15,9 +15,6 @@ on:
|
|||||||
- .github/workflows/nodejs.yml
|
- .github/workflows/nodejs.yml
|
||||||
- docker-compose.yml
|
- docker-compose.yml
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
@@ -42,17 +39,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
lfs: true
|
lfs: true
|
||||||
- uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 11.1.1
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
# pnpm 11 requires Node >= 22.13; use 24 since 22 hits EOL
|
node-version: 20
|
||||||
# in October. The library itself still supports Node >= 18
|
cache: 'npm'
|
||||||
# (see test matrix below).
|
cache-dependency-path: nodejs/package-lock.json
|
||||||
node-version: 24
|
|
||||||
cache: 'pnpm'
|
|
||||||
cache-dependency-path: nodejs/pnpm-lock.yaml
|
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
@@ -67,13 +58,11 @@ jobs:
|
|||||||
run: cargo clippy --profile ci --all --all-features -- -D warnings
|
run: cargo clippy --profile ci --all --all-features -- -D warnings
|
||||||
- name: Lint Typescript
|
- name: Lint Typescript
|
||||||
run: |
|
run: |
|
||||||
pnpm install --frozen-lockfile
|
npm ci
|
||||||
pnpm lint-ci
|
npm run lint-ci
|
||||||
- name: Lint examples
|
- name: Lint examples
|
||||||
working-directory: nodejs/examples
|
working-directory: nodejs/examples
|
||||||
# The `@lancedb/lancedb` dep points at file:../dist; pnpm errors if
|
run: npm ci && npm run lint-ci
|
||||||
# that dir is missing, so create an empty one for lint-only runs.
|
|
||||||
run: mkdir -p ../dist && pnpm install --frozen-lockfile && pnpm lint-ci
|
|
||||||
linux:
|
linux:
|
||||||
name: Linux (NodeJS ${{ matrix.node-version }})
|
name: Linux (NodeJS ${{ matrix.node-version }})
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
@@ -90,18 +79,14 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
lfs: true
|
lfs: true
|
||||||
- uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 11.1.1
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
name: Setup Node.js 24 for build
|
name: Setup Node.js 20 for build
|
||||||
with:
|
with:
|
||||||
# pnpm 11 requires Node >= 22.13; use 24 since 22 hits EOL
|
# @napi-rs/cli v3 requires Node >= 20.12 (via @inquirer/prompts@8).
|
||||||
# in October. Build/install runs on Node 24; tests run on the
|
# Build always on Node 20; tests run on the matrix version below.
|
||||||
# matrix version below using direct jest invocation.
|
node-version: 20
|
||||||
node-version: 24
|
cache: 'npm'
|
||||||
cache: 'pnpm'
|
cache-dependency-path: nodejs/package-lock.json
|
||||||
cache-dependency-path: nodejs/pnpm-lock.yaml
|
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
@@ -109,58 +94,48 @@ jobs:
|
|||||||
sudo apt install -y protobuf-compiler libssl-dev
|
sudo apt install -y protobuf-compiler libssl-dev
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
pnpm install --frozen-lockfile
|
npm ci --include=optional
|
||||||
# No `--` separator: pnpm forwards it literally, which would
|
npm run build:debug -- --profile ci
|
||||||
# make napi-rs treat `--profile ci` as a cargo passthrough arg.
|
|
||||||
pnpm build:debug --profile ci
|
|
||||||
pnpm tsc
|
|
||||||
- name: Setup examples
|
|
||||||
working-directory: nodejs/examples
|
|
||||||
run: pnpm install --frozen-lockfile
|
|
||||||
- name: Check docs
|
|
||||||
run: |
|
|
||||||
# We run this as part of the job because the binary needs to be built
|
|
||||||
# first to export the types of the native code.
|
|
||||||
set -e
|
|
||||||
# `pnpm docs` would invoke pnpm's built-in `docs` command, not
|
|
||||||
# the script — use `pnpm run docs`.
|
|
||||||
pnpm run docs
|
|
||||||
if ! git diff --exit-code -- ../ ':(exclude)Cargo.lock'; then
|
|
||||||
echo "Docs need to be updated"
|
|
||||||
echo "Run 'pnpm run docs', fix any warnings, and commit the changes."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
name: Setup Node.js ${{ matrix.node-version }} for test
|
name: Setup Node.js ${{ matrix.node-version }} for test
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- name: Compile TypeScript
|
||||||
|
run: npm run tsc
|
||||||
- name: Setup localstack
|
- name: Setup localstack
|
||||||
working-directory: .
|
working-directory: .
|
||||||
run: docker compose up --detach --wait
|
run: docker compose up --detach --wait
|
||||||
- name: Test
|
- name: Test
|
||||||
env:
|
env:
|
||||||
S3_TEST: "1"
|
S3_TEST: "1"
|
||||||
# Newer @smithy/core uses dynamic ESM imports.
|
run: npm run test
|
||||||
NODE_OPTIONS: "--experimental-vm-modules"
|
- name: Setup examples
|
||||||
# Invoke jest directly because pnpm 11 itself requires Node 22+
|
working-directory: nodejs/examples
|
||||||
# while the matrix tests on older Node versions.
|
run: npm ci
|
||||||
run: npx jest --verbose
|
|
||||||
- name: Test examples
|
- name: Test examples
|
||||||
working-directory: ./
|
working-directory: ./
|
||||||
env:
|
env:
|
||||||
OPENAI_API_KEY: test
|
OPENAI_API_KEY: test
|
||||||
OPENAI_BASE_URL: http://0.0.0.0:8000
|
OPENAI_BASE_URL: http://0.0.0.0:8000
|
||||||
NODE_OPTIONS: "--experimental-vm-modules"
|
|
||||||
run: |
|
run: |
|
||||||
python ci/mock_openai.py &
|
python ci/mock_openai.py &
|
||||||
cd nodejs/examples
|
cd nodejs/examples
|
||||||
npx jest --testEnvironment jest-environment-node-single-context --verbose
|
npm test
|
||||||
|
- name: Check docs
|
||||||
|
run: |
|
||||||
|
# We run this as part of the job because the binary needs to be built
|
||||||
|
# first to export the types of the native code.
|
||||||
|
set -e
|
||||||
|
npm ci
|
||||||
|
npm run docs
|
||||||
|
if ! git diff --exit-code -- ../ ':(exclude)Cargo.lock'; then
|
||||||
|
echo "Docs need to be updated"
|
||||||
|
echo "Run 'npm run docs', fix any warnings, and commit the changes."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
macos:
|
macos:
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
# macos-15 ships a newer linker; the older macos-14 linker fails to insert
|
runs-on: "macos-14"
|
||||||
# branch islands when the debug cdylib's __text section exceeds the 128 MB
|
|
||||||
# AArch64 B/BL branch range.
|
|
||||||
runs-on: "macos-15"
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -170,28 +145,20 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
lfs: true
|
lfs: true
|
||||||
- uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 11.1.1
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
# pnpm 11 requires Node >= 22.13; use 24 since 22 hits EOL
|
node-version: 20
|
||||||
# in October.
|
cache: 'npm'
|
||||||
node-version: 24
|
cache-dependency-path: nodejs/package-lock.json
|
||||||
cache: 'pnpm'
|
|
||||||
cache-dependency-path: nodejs/pnpm-lock.yaml
|
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
brew install protobuf
|
brew install protobuf
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
pnpm install --frozen-lockfile
|
npm ci --include=optional
|
||||||
# No `--` separator: pnpm forwards it literally, which would
|
npm run build:debug -- --profile ci
|
||||||
# make napi-rs treat `--profile ci` as a cargo passthrough arg.
|
npm run tsc
|
||||||
pnpm build:debug --profile ci
|
|
||||||
pnpm tsc
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: |
|
||||||
pnpm test
|
npm run test
|
||||||
|
|||||||
53
.github/workflows/npm-publish.yml
vendored
53
.github/workflows/npm-publish.yml
vendored
@@ -171,18 +171,13 @@ jobs:
|
|||||||
working-directory: nodejs
|
working-directory: nodejs
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup pnpm
|
|
||||||
uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 11.1.1
|
|
||||||
- name: Setup node
|
- name: Setup node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
|
if: ${{ !matrix.settings.docker }}
|
||||||
with:
|
with:
|
||||||
# pnpm 11 requires Node >= 22.13; use 24 since 22 hits EOL
|
node-version: 20
|
||||||
# in October.
|
cache: npm
|
||||||
node-version: 24
|
cache-dependency-path: nodejs/package-lock.json
|
||||||
cache: pnpm
|
|
||||||
cache-dependency-path: nodejs/pnpm-lock.yaml
|
|
||||||
- name: Install
|
- name: Install
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
if: ${{ !matrix.settings.docker }}
|
if: ${{ !matrix.settings.docker }}
|
||||||
@@ -200,7 +195,7 @@ jobs:
|
|||||||
target/
|
target/
|
||||||
key: nodejs-${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
|
key: nodejs-${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: npm ci
|
||||||
- name: Install Zig
|
- name: Install Zig
|
||||||
uses: mlugg/setup-zig@v2
|
uses: mlugg/setup-zig@v2
|
||||||
if: ${{ contains(matrix.settings.target, 'musl') }}
|
if: ${{ contains(matrix.settings.target, 'musl') }}
|
||||||
@@ -253,7 +248,7 @@ jobs:
|
|||||||
# one to do the upload.
|
# one to do the upload.
|
||||||
- name: Make generic artifacts
|
- name: Make generic artifacts
|
||||||
if: ${{ matrix.settings.target == 'aarch64-apple-darwin' }}
|
if: ${{ matrix.settings.target == 'aarch64-apple-darwin' }}
|
||||||
run: pnpm tsc
|
run: npm run tsc
|
||||||
- name: Upload Generic Artifacts
|
- name: Upload Generic Artifacts
|
||||||
if: ${{ matrix.settings.target == 'aarch64-apple-darwin' }}
|
if: ${{ matrix.settings.target == 'aarch64-apple-darwin' }}
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
@@ -288,24 +283,14 @@ jobs:
|
|||||||
working-directory: nodejs
|
working-directory: nodejs
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup pnpm
|
- name: Setup node
|
||||||
uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 11.1.1
|
|
||||||
- name: Setup Node.js 24 for install
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
# pnpm 11 requires Node >= 22.13; use 24 since 22 hits EOL
|
|
||||||
# in October.
|
|
||||||
node-version: 24
|
|
||||||
cache: pnpm
|
|
||||||
cache-dependency-path: nodejs/pnpm-lock.yaml
|
|
||||||
- name: Install dependencies
|
|
||||||
run: pnpm install --frozen-lockfile
|
|
||||||
- name: Setup Node.js ${{ matrix.node }} for test
|
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node }}
|
node-version: ${{ matrix.node }}
|
||||||
|
cache: npm
|
||||||
|
cache-dependency-path: nodejs/package-lock.json
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
@@ -326,9 +311,7 @@ jobs:
|
|||||||
- name: Move built files
|
- name: Move built files
|
||||||
run: cp dist/native.d.ts dist/native.js dist/*.node lancedb/
|
run: cp dist/native.d.ts dist/native.js dist/*.node lancedb/
|
||||||
- name: Test bindings
|
- name: Test bindings
|
||||||
# Invoke jest directly because pnpm 11 itself requires Node 22+
|
run: npm test
|
||||||
# while the matrix tests on older Node versions.
|
|
||||||
run: npx jest --verbose
|
|
||||||
publish:
|
publish:
|
||||||
name: Publish
|
name: Publish
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -340,19 +323,15 @@ jobs:
|
|||||||
- test-lancedb
|
- test-lancedb
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup pnpm
|
|
||||||
uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 11.1.1
|
|
||||||
- name: Setup node
|
- name: Setup node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 24
|
node-version: 24
|
||||||
cache: pnpm
|
cache: npm
|
||||||
cache-dependency-path: nodejs/pnpm-lock.yaml
|
cache-dependency-path: nodejs/package-lock.json
|
||||||
registry-url: "https://registry.npmjs.org"
|
registry-url: "https://registry.npmjs.org"
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: npm ci
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: nodejs-dist
|
name: nodejs-dist
|
||||||
@@ -372,7 +351,7 @@ jobs:
|
|||||||
- name: Display structure of downloaded files
|
- name: Display structure of downloaded files
|
||||||
run: find dist && find nodejs-artifacts
|
run: find dist && find nodejs-artifacts
|
||||||
- name: Move artifacts
|
- name: Move artifacts
|
||||||
run: pnpm exec napi artifacts -d nodejs-artifacts
|
run: npx napi artifacts -d nodejs-artifacts
|
||||||
- name: List packages
|
- name: List packages
|
||||||
run: find npm
|
run: find npm
|
||||||
- name: Publish
|
- name: Publish
|
||||||
|
|||||||
107
.github/workflows/pypi-publish.yml
vendored
107
.github/workflows/pypi-publish.yml
vendored
@@ -8,18 +8,12 @@ on:
|
|||||||
# This should trigger a dry run (we skip the final publish step)
|
# This should trigger a dry run (we skip the final publish step)
|
||||||
paths:
|
paths:
|
||||||
- .github/workflows/pypi-publish.yml
|
- .github/workflows/pypi-publish.yml
|
||||||
- .github/workflows/build_linux_wheel/action.yml
|
|
||||||
- .github/workflows/build_mac_wheel/action.yml
|
|
||||||
- .github/workflows/build_windows_wheel/action.yml
|
|
||||||
- Cargo.toml # Change in dependency frequently breaks builds
|
- Cargo.toml # Change in dependency frequently breaks builds
|
||||||
- Cargo.lock
|
- Cargo.lock
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PIP_EXTRA_INDEX_URL: "https://pypi.fury.io/lance-format/ https://pypi.fury.io/lancedb/"
|
PIP_EXTRA_INDEX_URL: "https://pypi.fury.io/lance-format/ https://pypi.fury.io/lancedb/"
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
linux:
|
linux:
|
||||||
name: Python ${{ matrix.config.platform }} manylinux${{ matrix.config.manylinux }}
|
name: Python ${{ matrix.config.platform }} manylinux${{ matrix.config.manylinux }}
|
||||||
@@ -27,18 +21,26 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
config:
|
config:
|
||||||
|
- platform: x86_64
|
||||||
|
manylinux: "2_17"
|
||||||
|
extra_args: ""
|
||||||
|
runner: ubuntu-22.04
|
||||||
- platform: x86_64
|
- platform: x86_64
|
||||||
manylinux: "2_28"
|
manylinux: "2_28"
|
||||||
extra_args: "--features fp16kernels"
|
extra_args: "--features fp16kernels"
|
||||||
runner: ubuntu-22.04
|
runner: ubuntu-22.04
|
||||||
# For successful fat LTO builds, we need a large runner to avoid OOM errors.
|
- platform: aarch64
|
||||||
|
manylinux: "2_17"
|
||||||
|
extra_args: ""
|
||||||
|
# For successful fat LTO builds, we need a large runner to avoid OOM errors.
|
||||||
|
runner: ubuntu-2404-8x-arm64
|
||||||
- platform: aarch64
|
- platform: aarch64
|
||||||
manylinux: "2_28"
|
manylinux: "2_28"
|
||||||
extra_args: "--features fp16kernels"
|
extra_args: "--features fp16kernels"
|
||||||
runner: ubuntu-2404-8x-arm64
|
runner: ubuntu-2404-8x-arm64
|
||||||
runs-on: ${{ matrix.config.runner }}
|
runs-on: ${{ matrix.config.runner }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
lfs: true
|
lfs: true
|
||||||
@@ -52,12 +54,11 @@ jobs:
|
|||||||
args: "--release --strip ${{ matrix.config.extra_args }}"
|
args: "--release --strip ${{ matrix.config.extra_args }}"
|
||||||
arm-build: ${{ matrix.config.platform == 'aarch64' }}
|
arm-build: ${{ matrix.config.platform == 'aarch64' }}
|
||||||
manylinux: ${{ matrix.config.manylinux }}
|
manylinux: ${{ matrix.config.manylinux }}
|
||||||
- uses: actions/upload-artifact@v7
|
- uses: ./.github/workflows/upload_wheel
|
||||||
if: startsWith(github.ref, 'refs/tags/python-v')
|
if: startsWith(github.ref, 'refs/tags/python-v')
|
||||||
with:
|
with:
|
||||||
name: wheels-linux-${{ matrix.config.platform }}-${{ matrix.config.manylinux }}
|
pypi_token: ${{ secrets.LANCEDB_PYPI_API_TOKEN }}
|
||||||
path: target/wheels/lancedb-*.whl
|
fury_token: ${{ secrets.FURY_TOKEN }}
|
||||||
if-no-files-found: error
|
|
||||||
mac:
|
mac:
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
runs-on: ${{ matrix.config.runner }}
|
runs-on: ${{ matrix.config.runner }}
|
||||||
@@ -69,7 +70,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
MACOSX_DEPLOYMENT_TARGET: 10.15
|
MACOSX_DEPLOYMENT_TARGET: 10.15
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
lfs: true
|
lfs: true
|
||||||
@@ -81,21 +82,16 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-minor-version: 10
|
python-minor-version: 10
|
||||||
args: "--release --strip --target ${{ matrix.config.target }} --features fp16kernels"
|
args: "--release --strip --target ${{ matrix.config.target }} --features fp16kernels"
|
||||||
- uses: actions/upload-artifact@v7
|
- uses: ./.github/workflows/upload_wheel
|
||||||
if: startsWith(github.ref, 'refs/tags/python-v')
|
if: startsWith(github.ref, 'refs/tags/python-v')
|
||||||
with:
|
with:
|
||||||
name: wheels-mac-${{ matrix.config.target }}
|
pypi_token: ${{ secrets.LANCEDB_PYPI_API_TOKEN }}
|
||||||
path: target/wheels/lancedb-*.whl
|
fury_token: ${{ secrets.FURY_TOKEN }}
|
||||||
if-no-files-found: error
|
|
||||||
windows:
|
windows:
|
||||||
timeout-minutes: 90
|
timeout-minutes: 60
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
env:
|
|
||||||
# link.exe is single-threaded and the long pole on Windows builds. Use
|
|
||||||
# rustc's bundled lld-link instead.
|
|
||||||
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: rust-lld
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
lfs: true
|
lfs: true
|
||||||
@@ -107,70 +103,19 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-minor-version: 10
|
python-minor-version: 10
|
||||||
args: "--release --strip"
|
args: "--release --strip"
|
||||||
- uses: actions/upload-artifact@v7
|
vcpkg_token: ${{ secrets.VCPKG_GITHUB_PACKAGES }}
|
||||||
|
- uses: ./.github/workflows/upload_wheel
|
||||||
if: startsWith(github.ref, 'refs/tags/python-v')
|
if: startsWith(github.ref, 'refs/tags/python-v')
|
||||||
with:
|
with:
|
||||||
name: wheels-windows
|
pypi_token: ${{ secrets.LANCEDB_PYPI_API_TOKEN }}
|
||||||
path: target/wheels/lancedb-*.whl
|
fury_token: ${{ secrets.FURY_TOKEN }}
|
||||||
if-no-files-found: error
|
|
||||||
publish:
|
|
||||||
name: Publish wheels
|
|
||||||
if: startsWith(github.ref, 'refs/tags/python-v')
|
|
||||||
needs: [linux, mac, windows]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
id-token: write
|
|
||||||
contents: read
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- name: Download wheel artifacts
|
|
||||||
uses: actions/download-artifact@v8
|
|
||||||
with:
|
|
||||||
pattern: wheels-*
|
|
||||||
path: target/wheels
|
|
||||||
merge-multiple: true
|
|
||||||
- name: List wheels
|
|
||||||
run: ls -la target/wheels
|
|
||||||
- name: Choose repo
|
|
||||||
id: choose_repo
|
|
||||||
run: |
|
|
||||||
if [[ ${{ github.ref }} == *beta* ]]; then
|
|
||||||
echo "repo=fury" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
echo "repo=pypi" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
- name: Publish to Fury
|
|
||||||
if: steps.choose_repo.outputs.repo == 'fury'
|
|
||||||
env:
|
|
||||||
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
|
|
||||||
run: |
|
|
||||||
shopt -s nullglob
|
|
||||||
WHEELS=(target/wheels/lancedb-*.whl)
|
|
||||||
if [[ ${#WHEELS[@]} -eq 0 ]]; then
|
|
||||||
echo "No wheels found in target/wheels/" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
for WHEEL in "${WHEELS[@]}"; do
|
|
||||||
echo "Uploading $WHEEL to Fury"
|
|
||||||
curl -f -F package=@"$WHEEL" "https://$FURY_TOKEN@push.fury.io/lancedb/"
|
|
||||||
done
|
|
||||||
# NOTE: pypa/gh-action-pypi-publish must be invoked directly from a
|
|
||||||
# workflow file, not from inside a composite action. When called from a
|
|
||||||
# composite, `github.action_repository` is empty (actions/runner#2473)
|
|
||||||
# and the action falls back to `github.repository`, producing a bogus
|
|
||||||
# `docker://ghcr.io/<repo>:<ref>` image reference that GHA tries to pull.
|
|
||||||
- name: Publish to PyPI
|
|
||||||
if: steps.choose_repo.outputs.repo == 'pypi'
|
|
||||||
uses: pypa/gh-action-pypi-publish@release/v1
|
|
||||||
with:
|
|
||||||
packages-dir: target/wheels/
|
|
||||||
gh-release:
|
gh-release:
|
||||||
if: startsWith(github.ref, 'refs/tags/python-v')
|
if: startsWith(github.ref, 'refs/tags/python-v')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
lfs: true
|
lfs: true
|
||||||
@@ -233,13 +178,13 @@ jobs:
|
|||||||
report-failure:
|
report-failure:
|
||||||
name: Report Workflow Failure
|
name: Report Workflow Failure
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [linux, mac, windows, publish]
|
needs: [linux, mac, windows]
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
issues: write
|
issues: write
|
||||||
if: always() && failure() && startsWith(github.ref, 'refs/tags/python-v')
|
if: always() && failure() && startsWith(github.ref, 'refs/tags/python-v')
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v4
|
||||||
- uses: ./.github/actions/create-failure-issue
|
- uses: ./.github/actions/create-failure-issue
|
||||||
with:
|
with:
|
||||||
job-results: ${{ toJSON(needs) }}
|
job-results: ${{ toJSON(needs) }}
|
||||||
|
|||||||
7
.github/workflows/python.yml
vendored
7
.github/workflows/python.yml
vendored
@@ -17,9 +17,6 @@ on:
|
|||||||
- .github/workflows/build_windows_wheel/**
|
- .github/workflows/build_windows_wheel/**
|
||||||
- .github/workflows/run_tests/**
|
- .github/workflows/run_tests/**
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
@@ -111,6 +108,7 @@ jobs:
|
|||||||
- name: Install
|
- name: Install
|
||||||
run: |
|
run: |
|
||||||
pip install --extra-index-url https://pypi.fury.io/lance-format/ --extra-index-url https://pypi.fury.io/lancedb/ -e .[tests,dev,embeddings]
|
pip install --extra-index-url https://pypi.fury.io/lance-format/ --extra-index-url https://pypi.fury.io/lancedb/ -e .[tests,dev,embeddings]
|
||||||
|
pip install tantivy
|
||||||
pip install mlx
|
pip install mlx
|
||||||
- name: Doctest
|
- name: Doctest
|
||||||
run: pytest --doctest-modules python/lancedb
|
run: pytest --doctest-modules python/lancedb
|
||||||
@@ -205,7 +203,7 @@ jobs:
|
|||||||
- name: Delete wheels
|
- name: Delete wheels
|
||||||
run: rm -rf target/wheels
|
run: rm -rf target/wheels
|
||||||
pydantic1x:
|
pydantic1x:
|
||||||
timeout-minutes: 60
|
timeout-minutes: 30
|
||||||
runs-on: "ubuntu-24.04"
|
runs-on: "ubuntu-24.04"
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
@@ -229,5 +227,6 @@ jobs:
|
|||||||
pip install "pydantic<2"
|
pip install "pydantic<2"
|
||||||
pip install pyarrow==16
|
pip install pyarrow==16
|
||||||
pip install --extra-index-url https://pypi.fury.io/lance-format/ --extra-index-url https://pypi.fury.io/lancedb/ -e .[tests]
|
pip install --extra-index-url https://pypi.fury.io/lance-format/ --extra-index-url https://pypi.fury.io/lancedb/ -e .[tests]
|
||||||
|
pip install tantivy
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: pytest -m "not slow and not s3_test" -x -v --durations=30 python/tests
|
run: pytest -m "not slow and not s3_test" -x -v --durations=30 python/tests
|
||||||
|
|||||||
37
.github/workflows/rust.yml
vendored
37
.github/workflows/rust.yml
vendored
@@ -9,15 +9,9 @@ on:
|
|||||||
- Cargo.toml
|
- Cargo.toml
|
||||||
- Cargo.lock
|
- Cargo.lock
|
||||||
- rust-toolchain.toml
|
- rust-toolchain.toml
|
||||||
- deny.toml
|
|
||||||
- rust/**
|
- rust/**
|
||||||
- nodejs/Cargo.toml
|
|
||||||
- python/Cargo.toml
|
|
||||||
- .github/workflows/rust.yml
|
- .github/workflows/rust.yml
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
@@ -59,17 +53,6 @@ jobs:
|
|||||||
- name: Run clippy (without remote feature)
|
- name: Run clippy (without remote feature)
|
||||||
run: cargo clippy --profile ci --workspace --tests -- -D warnings
|
run: cargo clippy --profile ci --workspace --tests -- -D warnings
|
||||||
|
|
||||||
deny:
|
|
||||||
# Supply-chain checks: advisories, licenses, banned crates, and source
|
|
||||||
# restrictions. Configuration lives in `deny.toml` at the workspace root.
|
|
||||||
timeout-minutes: 10
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: EmbarkStudios/cargo-deny-action@v2
|
|
||||||
with:
|
|
||||||
command: check advisories bans licenses sources
|
|
||||||
|
|
||||||
build-no-lock:
|
build-no-lock:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
@@ -233,26 +216,6 @@ jobs:
|
|||||||
cargo update -p aws-sdk-sso --precise 1.62.0
|
cargo update -p aws-sdk-sso --precise 1.62.0
|
||||||
cargo update -p aws-sdk-ssooidc --precise 1.63.0
|
cargo update -p aws-sdk-ssooidc --precise 1.63.0
|
||||||
cargo update -p aws-sdk-sts --precise 1.63.0
|
cargo update -p aws-sdk-sts --precise 1.63.0
|
||||||
# aws-runtime/sigv4/credential-types/types and the aws-smithy-*
|
|
||||||
# crates bumped their MSRV to 1.91.1 in late 2026; pin to the last
|
|
||||||
# 1.91.0-compatible versions. The order matters — each downgrade
|
|
||||||
# only succeeds once everything that still pins it at a higher
|
|
||||||
# version has itself been downgraded.
|
|
||||||
cargo update -p aws-runtime --precise 1.5.12
|
|
||||||
cargo update -p aws-types --precise 1.3.9
|
|
||||||
cargo update -p aws-sigv4 --precise 1.3.5
|
|
||||||
cargo update -p aws-credential-types --precise 1.2.8
|
|
||||||
cargo update -p aws-smithy-checksums --precise 0.63.9
|
|
||||||
cargo update -p aws-smithy-runtime --precise 1.9.3
|
|
||||||
cargo update -p aws-smithy-http --precise 0.62.4
|
|
||||||
cargo update -p aws-smithy-eventstream --precise 0.60.12
|
|
||||||
cargo update -p aws-smithy-http-client --precise 1.1.3
|
|
||||||
cargo update -p aws-smithy-observability --precise 0.1.4
|
|
||||||
cargo update -p aws-smithy-query --precise 0.60.8
|
|
||||||
cargo update -p aws-smithy-runtime-api --precise 1.9.1
|
|
||||||
cargo update -p aws-smithy-async --precise 1.2.6
|
|
||||||
cargo update -p aws-smithy-types --precise 1.3.5
|
|
||||||
cargo update -p aws-smithy-xml --precise 0.60.11
|
|
||||||
cargo update -p home --precise 0.5.9
|
cargo update -p home --precise 0.5.9
|
||||||
- name: cargo +${{ matrix.msrv }} check
|
- name: cargo +${{ matrix.msrv }} check
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ name: Update package-lock.json
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ name: Update NodeJs package-lock.json
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
45
.github/workflows/upload_wheel/action.yml
vendored
Normal file
45
.github/workflows/upload_wheel/action.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
name: upload-wheel
|
||||||
|
|
||||||
|
description: "Upload wheels to Pypi"
|
||||||
|
inputs:
|
||||||
|
pypi_token:
|
||||||
|
required: true
|
||||||
|
description: "release token for the repo"
|
||||||
|
fury_token:
|
||||||
|
required: true
|
||||||
|
description: "release token for the fury repo"
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Install dependencies
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install twine
|
||||||
|
python3 -m pip install --upgrade pkginfo
|
||||||
|
- name: Choose repo
|
||||||
|
shell: bash
|
||||||
|
id: choose_repo
|
||||||
|
run: |
|
||||||
|
if [[ ${{ github.ref }} == *beta* ]]; then
|
||||||
|
echo "repo=fury" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "repo=pypi" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
- name: Publish to PyPI
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
FURY_TOKEN: ${{ inputs.fury_token }}
|
||||||
|
PYPI_TOKEN: ${{ inputs.pypi_token }}
|
||||||
|
run: |
|
||||||
|
if [[ ${{ steps.choose_repo.outputs.repo }} == fury ]]; then
|
||||||
|
WHEEL=$(ls target/wheels/lancedb-*.whl 2> /dev/null | head -n 1)
|
||||||
|
echo "Uploading $WHEEL to Fury"
|
||||||
|
curl -f -F package=@$WHEEL https://$FURY_TOKEN@push.fury.io/lancedb/
|
||||||
|
else
|
||||||
|
twine upload --repository ${{ steps.choose_repo.outputs.repo }} \
|
||||||
|
--username __token__ \
|
||||||
|
--password $PYPI_TOKEN \
|
||||||
|
target/wheels/lancedb-*.whl
|
||||||
|
fi
|
||||||
28
AGENTS.md
28
AGENTS.md
@@ -17,33 +17,9 @@ Common commands:
|
|||||||
* Run tests: `cargo test --quiet --features remote --tests`
|
* Run tests: `cargo test --quiet --features remote --tests`
|
||||||
* Run specific test: `cargo test --quiet --features remote -p <package_name> --test <test_name>`
|
* Run specific test: `cargo test --quiet --features remote -p <package_name> --test <test_name>`
|
||||||
* Lint: `cargo clippy --quiet --features remote --tests --examples`
|
* Lint: `cargo clippy --quiet --features remote --tests --examples`
|
||||||
* Format Rust: `cargo fmt --all`
|
* Format: `cargo fmt --all`
|
||||||
* Format Python: `ruff format .`
|
|
||||||
* Lint Python: `ruff check .`
|
|
||||||
* Bootstrap Python dev env: `cd python && uv run --extra tests --extra dev maturin develop --extras tests,dev`
|
|
||||||
* Run Python tests: `cd python && uv run --extra tests pytest python/tests -vv --durations=10 -m "not slow and not s3_test"`
|
|
||||||
* Run specific Python test: `cd python && uv run --extra tests pytest python/tests/<test_file>.py::<test_name> -q`
|
|
||||||
|
|
||||||
For Python validation, prefer the uv-managed environment declared by `python/uv.lock`.
|
Before committing changes, run formatting.
|
||||||
Do not treat system `python`, global `pytest`, or missing editable-install errors as
|
|
||||||
final blockers; bootstrap or enter the uv environment instead. If `lancedb._lancedb`
|
|
||||||
is missing or stale, or if Rust/PyO3 binding code changed, rebuild the Python
|
|
||||||
extension with the bootstrap command above before running tests.
|
|
||||||
|
|
||||||
Before committing changes, run formatting for every language you touched. At minimum:
|
|
||||||
|
|
||||||
* Rust changes: run `cargo fmt --all`.
|
|
||||||
* Python changes: run `ruff format .` and `ruff check .` from the repository root,
|
|
||||||
and run targeted tests through `cd python && uv run ...`.
|
|
||||||
* TypeScript changes: run the relevant `npm`/`pnpm` lint, format, build, and docs commands in `nodejs`.
|
|
||||||
|
|
||||||
Before creating a PR, the exact value passed to `gh pr create --title` must follow
|
|
||||||
Conventional Commits, such as `fix: support nested field paths in native index creation`
|
|
||||||
or `feat(python): add dataset multiprocessing support`. Do not use a plain natural
|
|
||||||
language summary like `Support nested field paths in native index creation` as the PR
|
|
||||||
title. The semantic-release check uses the PR title and body as the merge commit message,
|
|
||||||
so a non-conventional PR title will fail CI. After creating a PR, read the remote PR title
|
|
||||||
back and fix it immediately if it is not conventional.
|
|
||||||
|
|
||||||
## Coding tips
|
## Coding tips
|
||||||
|
|
||||||
|
|||||||
3472
Cargo.lock
generated
3472
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
66
Cargo.toml
66
Cargo.toml
@@ -1,5 +1,7 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = ["rust/lancedb", "nodejs", "python"]
|
members = ["rust/lancedb", "nodejs", "python"]
|
||||||
|
# Python package needs to be built by maturin.
|
||||||
|
exclude = ["python"]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
@@ -13,40 +15,40 @@ categories = ["database-implementations"]
|
|||||||
rust-version = "1.91.0"
|
rust-version = "1.91.0"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
lance = { "version" = "=7.2.0-beta.3", default-features = false, "tag" = "v7.2.0-beta.3", "git" = "https://github.com/lance-format/lance.git" }
|
lance = { "version" = "=5.1.0-beta.1", default-features = false, "tag" = "v5.1.0-beta.1", "git" = "https://github.com/lance-format/lance.git" }
|
||||||
lance-core = { "version" = "=7.2.0-beta.3", "tag" = "v7.2.0-beta.3", "git" = "https://github.com/lance-format/lance.git" }
|
lance-core = { "version" = "=5.1.0-beta.1", "tag" = "v5.1.0-beta.1", "git" = "https://github.com/lance-format/lance.git" }
|
||||||
lance-datagen = { "version" = "=7.2.0-beta.3", "tag" = "v7.2.0-beta.3", "git" = "https://github.com/lance-format/lance.git" }
|
lance-datagen = { "version" = "=5.1.0-beta.1", "tag" = "v5.1.0-beta.1", "git" = "https://github.com/lance-format/lance.git" }
|
||||||
lance-file = { "version" = "=7.2.0-beta.3", "tag" = "v7.2.0-beta.3", "git" = "https://github.com/lance-format/lance.git" }
|
lance-file = { "version" = "=5.1.0-beta.1", "tag" = "v5.1.0-beta.1", "git" = "https://github.com/lance-format/lance.git" }
|
||||||
lance-io = { "version" = "=7.2.0-beta.3", default-features = false, "tag" = "v7.2.0-beta.3", "git" = "https://github.com/lance-format/lance.git" }
|
lance-io = { "version" = "=5.1.0-beta.1", default-features = false, "tag" = "v5.1.0-beta.1", "git" = "https://github.com/lance-format/lance.git" }
|
||||||
lance-index = { "version" = "=7.2.0-beta.3", "tag" = "v7.2.0-beta.3", "git" = "https://github.com/lance-format/lance.git" }
|
lance-index = { "version" = "=5.1.0-beta.1", "tag" = "v5.1.0-beta.1", "git" = "https://github.com/lance-format/lance.git" }
|
||||||
lance-linalg = { "version" = "=7.2.0-beta.3", "tag" = "v7.2.0-beta.3", "git" = "https://github.com/lance-format/lance.git" }
|
lance-linalg = { "version" = "=5.1.0-beta.1", "tag" = "v5.1.0-beta.1", "git" = "https://github.com/lance-format/lance.git" }
|
||||||
lance-namespace = { "version" = "=7.2.0-beta.3", "tag" = "v7.2.0-beta.3", "git" = "https://github.com/lance-format/lance.git" }
|
lance-namespace = { "version" = "=5.1.0-beta.1", "tag" = "v5.1.0-beta.1", "git" = "https://github.com/lance-format/lance.git" }
|
||||||
lance-namespace-impls = { "version" = "=7.2.0-beta.3", default-features = false, "tag" = "v7.2.0-beta.3", "git" = "https://github.com/lance-format/lance.git" }
|
lance-namespace-impls = { "version" = "=5.1.0-beta.1", default-features = false, "tag" = "v5.1.0-beta.1", "git" = "https://github.com/lance-format/lance.git" }
|
||||||
lance-table = { "version" = "=7.2.0-beta.3", "tag" = "v7.2.0-beta.3", "git" = "https://github.com/lance-format/lance.git" }
|
lance-table = { "version" = "=5.1.0-beta.1", "tag" = "v5.1.0-beta.1", "git" = "https://github.com/lance-format/lance.git" }
|
||||||
lance-testing = { "version" = "=7.2.0-beta.3", "tag" = "v7.2.0-beta.3", "git" = "https://github.com/lance-format/lance.git" }
|
lance-testing = { "version" = "=5.1.0-beta.1", "tag" = "v5.1.0-beta.1", "git" = "https://github.com/lance-format/lance.git" }
|
||||||
lance-datafusion = { "version" = "=7.2.0-beta.3", "tag" = "v7.2.0-beta.3", "git" = "https://github.com/lance-format/lance.git" }
|
lance-datafusion = { "version" = "=5.1.0-beta.1", "tag" = "v5.1.0-beta.1", "git" = "https://github.com/lance-format/lance.git" }
|
||||||
lance-encoding = { "version" = "=7.2.0-beta.3", "tag" = "v7.2.0-beta.3", "git" = "https://github.com/lance-format/lance.git" }
|
lance-encoding = { "version" = "=5.1.0-beta.1", "tag" = "v5.1.0-beta.1", "git" = "https://github.com/lance-format/lance.git" }
|
||||||
lance-arrow = { "version" = "=7.2.0-beta.3", "tag" = "v7.2.0-beta.3", "git" = "https://github.com/lance-format/lance.git" }
|
lance-arrow = { "version" = "=5.1.0-beta.1", "tag" = "v5.1.0-beta.1", "git" = "https://github.com/lance-format/lance.git" }
|
||||||
ahash = "0.8"
|
ahash = "0.8"
|
||||||
# Note that this one does not include pyarrow
|
# Note that this one does not include pyarrow
|
||||||
arrow = { version = "58.0.0", optional = false }
|
arrow = { version = "57.2", optional = false }
|
||||||
arrow-array = "58.0.0"
|
arrow-array = "57.2"
|
||||||
arrow-data = "58.0.0"
|
arrow-data = "57.2"
|
||||||
arrow-ipc = "58.0.0"
|
arrow-ipc = "57.2"
|
||||||
arrow-ord = "58.0.0"
|
arrow-ord = "57.2"
|
||||||
arrow-schema = "58.0.0"
|
arrow-schema = "57.2"
|
||||||
arrow-select = "58.0.0"
|
arrow-select = "57.2"
|
||||||
arrow-cast = "58.0.0"
|
arrow-cast = "57.2"
|
||||||
async-trait = "0"
|
async-trait = "0"
|
||||||
datafusion = { version = "53.0.0", default-features = false }
|
datafusion = { version = "52.1", default-features = false }
|
||||||
datafusion-catalog = "53.0.0"
|
datafusion-catalog = "52.1"
|
||||||
datafusion-common = { version = "53.0.0", default-features = false }
|
datafusion-common = { version = "52.1", default-features = false }
|
||||||
datafusion-execution = "53.0.0"
|
datafusion-execution = "52.1"
|
||||||
datafusion-expr = "53.0.0"
|
datafusion-expr = "52.1"
|
||||||
datafusion-functions = "53.0.0"
|
datafusion-functions = "52.1"
|
||||||
datafusion-physical-plan = "53.0.0"
|
datafusion-physical-plan = "52.1"
|
||||||
datafusion-physical-expr = "53.0.0"
|
datafusion-physical-expr = "52.1"
|
||||||
datafusion-sql = "53.0.0"
|
datafusion-sql = "52.1"
|
||||||
env_logger = "0.11"
|
env_logger = "0.11"
|
||||||
half = { "version" = "2.7.1", default-features = false, features = [
|
half = { "version" = "2.7.1", default-features = false, features = [
|
||||||
"num-traits",
|
"num-traits",
|
||||||
@@ -54,7 +56,7 @@ half = { "version" = "2.7.1", default-features = false, features = [
|
|||||||
futures = "0"
|
futures = "0"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
moka = { version = "0.12", features = ["future"] }
|
moka = { version = "0.12", features = ["future"] }
|
||||||
object_store = "0.13.2"
|
object_store = "0.12.0"
|
||||||
pin-project = "1.0.7"
|
pin-project = "1.0.7"
|
||||||
rand = "0.9"
|
rand = "0.9"
|
||||||
snafu = "0.8"
|
snafu = "0.8"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
# **The Multimodal AI Lakehouse**
|
# **The Multimodal AI Lakehouse**
|
||||||
|
|
||||||
[**How to Install** ](#how-to-install) ✦ [**Detailed Documentation**](https://docs.lancedb.com) ✦ [**Tutorials and Recipes**](https://github.com/lancedb/vectordb-recipes/tree/main) ✦ [**Contributors**](#contributors)
|
[**How to Install** ](#how-to-install) ✦ [**Detailed Documentation**](https://lancedb.com/docs) ✦ [**Tutorials and Recipes**](https://github.com/lancedb/vectordb-recipes/tree/main) ✦ [**Contributors**](#contributors)
|
||||||
|
|
||||||
**The ultimate multimodal data platform for AI/ML applications.**
|
**The ultimate multimodal data platform for AI/ML applications.**
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ LanceDB is a central location where developers can build, train and analyze thei
|
|||||||
|
|
||||||
## **How to Install**:
|
## **How to Install**:
|
||||||
|
|
||||||
Follow the [Quickstart](https://docs.lancedb.com/quickstart) doc to set up LanceDB locally.
|
Follow the [Quickstart](https://lancedb.com/docs/quickstart/) doc to set up LanceDB locally.
|
||||||
|
|
||||||
**API & SDK:** We also support Python, Typescript and Rust SDKs
|
**API & SDK:** We also support Python, Typescript and Rust SDKs
|
||||||
|
|
||||||
|
|||||||
@@ -112,25 +112,25 @@ def fetch_remote_tags() -> List[TagInfo]:
|
|||||||
"api",
|
"api",
|
||||||
"-X",
|
"-X",
|
||||||
"GET",
|
"GET",
|
||||||
f"repos/{LANCE_REPO}/releases",
|
f"repos/{LANCE_REPO}/git/refs/tags",
|
||||||
|
"--paginate",
|
||||||
"--jq",
|
"--jq",
|
||||||
".[].tag_name",
|
".[].ref",
|
||||||
"-F",
|
|
||||||
"per_page=20",
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
tags: List[TagInfo] = []
|
tags: List[TagInfo] = []
|
||||||
for line in output.splitlines():
|
for line in output.splitlines():
|
||||||
tag = line.strip()
|
ref = line.strip()
|
||||||
if not tag.startswith("v"):
|
if not ref.startswith("refs/tags/v"):
|
||||||
continue
|
continue
|
||||||
|
tag = ref.split("refs/tags/")[-1]
|
||||||
version = tag.lstrip("v")
|
version = tag.lstrip("v")
|
||||||
try:
|
try:
|
||||||
tags.append(TagInfo(tag=tag, version=version, semver=parse_semver(version)))
|
tags.append(TagInfo(tag=tag, version=version, semver=parse_semver(version)))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
if not tags:
|
if not tags:
|
||||||
raise RuntimeError("No Lance releases could be parsed from GitHub API output")
|
raise RuntimeError("No Lance tags could be parsed from GitHub API output")
|
||||||
return tags
|
return tags
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,126 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""Prepare a Lance dependency update for LanceDB."""
|
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
import json
|
|
||||||
import re
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
|
||||||
from typing import Sequence
|
|
||||||
|
|
||||||
try:
|
|
||||||
from check_lance_release import parse_semver
|
|
||||||
except ModuleNotFoundError:
|
|
||||||
# Supports importing as ci.update_lance_dependency from tests or ad hoc checks.
|
|
||||||
from ci.check_lance_release import parse_semver # type: ignore
|
|
||||||
|
|
||||||
|
|
||||||
def normalize_version(raw: str) -> str:
|
|
||||||
value = raw.strip()
|
|
||||||
value = value.removeprefix("refs/tags/")
|
|
||||||
value = value.removeprefix("v")
|
|
||||||
try:
|
|
||||||
parse_semver(value)
|
|
||||||
except ValueError:
|
|
||||||
raise ValueError(f"Unsupported Lance version or tag: {raw}")
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
def normalized_tag(version: str) -> str:
|
|
||||||
return f"v{version}"
|
|
||||||
|
|
||||||
|
|
||||||
def branch_name(version: str) -> str:
|
|
||||||
suffix = re.sub(r"[^a-zA-Z0-9]+", "-", version).strip("-")
|
|
||||||
suffix = re.sub(r"-+", "-", suffix)
|
|
||||||
return f"codex/update-lance-{suffix}"
|
|
||||||
|
|
||||||
|
|
||||||
def commit_type(version: str) -> str:
|
|
||||||
prerelease = version.split("-", maxsplit=1)[1] if "-" in version else ""
|
|
||||||
return "chore" if "beta" in prerelease or "rc" in prerelease else "feat"
|
|
||||||
|
|
||||||
|
|
||||||
def metadata_for(version: str) -> dict[str, str]:
|
|
||||||
kind = commit_type(version)
|
|
||||||
message = f"{kind}: update lance dependency to v{version}"
|
|
||||||
return {
|
|
||||||
"version": version,
|
|
||||||
"tag": normalized_tag(version),
|
|
||||||
"branch_name": branch_name(version),
|
|
||||||
"commit_type": kind,
|
|
||||||
"commit_message": message,
|
|
||||||
"pr_title": message,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def run_command(cmd: Sequence[str], *, cwd: Path) -> None:
|
|
||||||
subprocess.run(cmd, cwd=cwd, check=True)
|
|
||||||
|
|
||||||
|
|
||||||
def update_java_lance_core_version(repo_root: Path, version: str) -> None:
|
|
||||||
pom_path = repo_root / "java" / "pom.xml"
|
|
||||||
contents = pom_path.read_text(encoding="utf-8")
|
|
||||||
updated, count = re.subn(
|
|
||||||
r"(<lance-core\.version>)[^<]+(</lance-core\.version>)",
|
|
||||||
rf"\g<1>{version}\g<2>",
|
|
||||||
contents,
|
|
||||||
count=1,
|
|
||||||
)
|
|
||||||
if count != 1:
|
|
||||||
raise RuntimeError(
|
|
||||||
"Expected exactly one <lance-core.version> entry in java/pom.xml"
|
|
||||||
)
|
|
||||||
pom_path.write_text(updated, encoding="utf-8")
|
|
||||||
|
|
||||||
|
|
||||||
def write_github_outputs(path: str | None, payload: dict[str, str]) -> None:
|
|
||||||
if not path:
|
|
||||||
return
|
|
||||||
with open(path, "a", encoding="utf-8") as output:
|
|
||||||
for key, value in payload.items():
|
|
||||||
output.write(f"{key}={value}\n")
|
|
||||||
|
|
||||||
|
|
||||||
def main(argv: Sequence[str] | None = None) -> int:
|
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
|
||||||
parser.add_argument(
|
|
||||||
"tag_or_version",
|
|
||||||
help="Lance tag or version, for example refs/tags/v7.2.0-beta.1 or 7.2.0",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--repo-root",
|
|
||||||
type=Path,
|
|
||||||
default=Path(__file__).resolve().parents[1],
|
|
||||||
help="Path to the lancedb repository root",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--github-output",
|
|
||||||
default=None,
|
|
||||||
help="Optional GitHub Actions output file to receive metadata fields",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--metadata-only",
|
|
||||||
action="store_true",
|
|
||||||
help="Only print derived metadata; do not modify dependency files",
|
|
||||||
)
|
|
||||||
args = parser.parse_args(argv)
|
|
||||||
|
|
||||||
repo_root = args.repo_root.resolve()
|
|
||||||
version = normalize_version(args.tag_or_version)
|
|
||||||
payload = metadata_for(version)
|
|
||||||
|
|
||||||
if not args.metadata_only:
|
|
||||||
run_command([sys.executable, "ci/set_lance_version.py", version], cwd=repo_root)
|
|
||||||
update_java_lance_core_version(repo_root, version)
|
|
||||||
|
|
||||||
write_github_outputs(args.github_output, payload)
|
|
||||||
print(json.dumps(payload, sort_keys=True))
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
sys.exit(main())
|
|
||||||
196
deny.toml
196
deny.toml
@@ -1,196 +0,0 @@
|
|||||||
# cargo-deny configuration for LanceDB.
|
|
||||||
#
|
|
||||||
# Run locally with `cargo deny check`. See
|
|
||||||
# https://embarkstudios.github.io/cargo-deny/ for the full reference.
|
|
||||||
|
|
||||||
# The set of target triples we care about. cargo-deny will only consider
|
|
||||||
# dependencies that are used on at least one of these targets. Keeping this
|
|
||||||
# explicit avoids noise from platform-specific crates (e.g. wasm, android,
|
|
||||||
# ios) that we never actually ship.
|
|
||||||
[graph]
|
|
||||||
targets = [
|
|
||||||
"x86_64-unknown-linux-gnu",
|
|
||||||
"aarch64-unknown-linux-gnu",
|
|
||||||
"x86_64-apple-darwin",
|
|
||||||
"aarch64-apple-darwin",
|
|
||||||
"x86_64-pc-windows-msvc",
|
|
||||||
"aarch64-pc-windows-msvc",
|
|
||||||
]
|
|
||||||
all-features = true
|
|
||||||
|
|
||||||
[output]
|
|
||||||
feature-depth = 1
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# Advisories: security vulnerabilities and yanked crates.
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
[advisories]
|
|
||||||
version = 2
|
|
||||||
# Fail the check if any crate in the lockfile has been yanked from crates.io.
|
|
||||||
# Yanked crates are a signal the author retracted the release (often due to
|
|
||||||
# bugs or security issues) and should not be depended on.
|
|
||||||
yanked = "deny"
|
|
||||||
# Advisory IDs we have explicitly reviewed and chosen to accept. Every
|
|
||||||
# entry must include a rationale and, where possible, an upstream issue
|
|
||||||
# pointing to a fix. Revisit this list whenever dependencies are updated.
|
|
||||||
ignore = [
|
|
||||||
# rsa: Marvin Attack timing side-channel in PKCS#1 v1.5 decryption.
|
|
||||||
# Reached only through opendal → reqsign → rsa. We do not use RSA
|
|
||||||
# decryption in LanceDB ourselves; this is dormant in the signing path.
|
|
||||||
# No fixed release exists upstream as of this writing.
|
|
||||||
# https://rustsec.org/advisories/RUSTSEC-2023-0071
|
|
||||||
{ id = "RUSTSEC-2023-0071", reason = "rsa crate via opendal/reqsign; no fixed upstream release" },
|
|
||||||
|
|
||||||
# instant: unmaintained. Pulled in via backoff → instant. Upstream
|
|
||||||
# recommends switching to `web-time`; fix has to come from backoff.
|
|
||||||
# https://rustsec.org/advisories/RUSTSEC-2024-0384
|
|
||||||
{ id = "RUSTSEC-2024-0384", reason = "transitive via backoff; waiting on backoff replacement" },
|
|
||||||
|
|
||||||
# paste: unmaintained (author archived the repo). Used transitively by
|
|
||||||
# datafusion and the arrow ecosystem; widespread, no drop-in replacement.
|
|
||||||
# https://rustsec.org/advisories/RUSTSEC-2024-0436
|
|
||||||
{ id = "RUSTSEC-2024-0436", reason = "transitive via datafusion; awaiting ecosystem migration" },
|
|
||||||
|
|
||||||
# encoding: unmaintained. Reached through lindera-dictionary, which is
|
|
||||||
# required by the native Lindera tokenizer path. Lindera has not migrated
|
|
||||||
# off this crate yet.
|
|
||||||
# https://rustsec.org/advisories/RUSTSEC-2021-0153
|
|
||||||
{ id = "RUSTSEC-2021-0153", reason = "transitive via lindera-dictionary for native Lindera tokenizer" },
|
|
||||||
|
|
||||||
# fast-float: unsound and unmaintained. Reached only through polars-arrow
|
|
||||||
# from the optional Polars integration; replacement requires a Polars
|
|
||||||
# dependency upgrade.
|
|
||||||
# https://rustsec.org/advisories/RUSTSEC-2024-0379
|
|
||||||
{ id = "RUSTSEC-2024-0379", reason = "transitive via polars-arrow; waiting on Polars migration" },
|
|
||||||
|
|
||||||
# tantivy: segfault on malformed input due to missing bounds check.
|
|
||||||
# Pulled in via lance for full-text search. We only feed tantivy
|
|
||||||
# documents we construct ourselves, not attacker-controlled bytes.
|
|
||||||
# Tracked for a lance dependency bump.
|
|
||||||
# https://rustsec.org/advisories/RUSTSEC-2025-0003
|
|
||||||
{ id = "RUSTSEC-2025-0003", reason = "tantivy via lance; inputs are internally produced, not user-supplied bytes" },
|
|
||||||
|
|
||||||
# backoff: unmaintained. Reached only via async-openai. Replacement
|
|
||||||
# requires async-openai to migrate (or us to drop async-openai).
|
|
||||||
# https://rustsec.org/advisories/RUSTSEC-2025-0012
|
|
||||||
{ id = "RUSTSEC-2025-0012", reason = "transitive via async-openai; waiting on upstream migration" },
|
|
||||||
|
|
||||||
# number_prefix: unmaintained. Transitive via indicatif → hf-hub.
|
|
||||||
# No security impact, just maintenance status.
|
|
||||||
# https://rustsec.org/advisories/RUSTSEC-2025-0119
|
|
||||||
{ id = "RUSTSEC-2025-0119", reason = "transitive via hf-hub/indicatif; cosmetic formatting crate" },
|
|
||||||
|
|
||||||
# bincode: unmaintained. Reached through lindera and lindera-dictionary,
|
|
||||||
# which are required by the native Lindera tokenizer path. Lindera has not
|
|
||||||
# migrated to another serialization format yet.
|
|
||||||
# https://rustsec.org/advisories/RUSTSEC-2025-0141
|
|
||||||
{ id = "RUSTSEC-2025-0141", reason = "transitive via lindera/lindera-dictionary for native Lindera tokenizer" },
|
|
||||||
|
|
||||||
# lru: soundness issue in IterMut. Reached only through aws-sdk-s3 in
|
|
||||||
# LanceDB's dev-dependency graph; LanceDB does not use that iterator
|
|
||||||
# directly. Clearing this requires the AWS SDK chain to update lru.
|
|
||||||
# https://rustsec.org/advisories/RUSTSEC-2026-0002
|
|
||||||
{ id = "RUSTSEC-2026-0002", reason = "transitive via aws-sdk-s3 dev-dependency; waiting on AWS SDK lru upgrade" },
|
|
||||||
|
|
||||||
# rustls-webpki 0.101.7 (old major line): name-constraint checks for
|
|
||||||
# URI / wildcard names. Pulled in only via the legacy rustls 0.21 chain
|
|
||||||
# from aws-smithy-http-client. The 0.103 line we actively use is patched.
|
|
||||||
# Clearing the 0.101 copy requires the aws-sdk chain to migrate off
|
|
||||||
# rustls 0.21.
|
|
||||||
# https://rustsec.org/advisories/RUSTSEC-2026-0098
|
|
||||||
# https://rustsec.org/advisories/RUSTSEC-2026-0099
|
|
||||||
{ id = "RUSTSEC-2026-0098", reason = "only affects rustls-webpki 0.101 from legacy aws-smithy/rustls 0.21 chain" },
|
|
||||||
{ id = "RUSTSEC-2026-0099", reason = "only affects rustls-webpki 0.101 from legacy aws-smithy/rustls 0.21 chain" },
|
|
||||||
|
|
||||||
# rustls-webpki 0.101.7: reachable panic in CRL parsing. Same legacy
|
|
||||||
# rustls 0.21 chain from aws-smithy-http-client as above. The 0.103 line
|
|
||||||
# we actively use is upgraded to 0.103.13 which contains the fix.
|
|
||||||
# https://rustsec.org/advisories/RUSTSEC-2026-0104
|
|
||||||
{ id = "RUSTSEC-2026-0104", reason = "only affects rustls-webpki 0.101 from legacy aws-smithy/rustls 0.21 chain" },
|
|
||||||
|
|
||||||
# rand 0.8.5: soundness issue only when ThreadRng reseeds inside a custom
|
|
||||||
# logger. Reached through several transitive chains. LanceDB does not use
|
|
||||||
# rand from a custom logger; upgrade once all pinned chains accept 0.8.6+.
|
|
||||||
# https://rustsec.org/advisories/RUSTSEC-2026-0097
|
|
||||||
{ id = "RUSTSEC-2026-0097", reason = "transitive rand 0.8.5; LanceDB does not call ThreadRng from custom logging" },
|
|
||||||
]
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# Licenses: only allow licenses we've reviewed as compatible with Apache-2.0.
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
[licenses]
|
|
||||||
version = 2
|
|
||||||
# SPDX identifiers for licenses that are compatible with our Apache-2.0
|
|
||||||
# distribution. Additions require legal review.
|
|
||||||
allow = [
|
|
||||||
"Apache-2.0",
|
|
||||||
"Apache-2.0 WITH LLVM-exception",
|
|
||||||
"MIT",
|
|
||||||
"BSD-2-Clause",
|
|
||||||
"BSD-3-Clause",
|
|
||||||
"ISC",
|
|
||||||
"Unicode-3.0",
|
|
||||||
"Unicode-DFS-2016",
|
|
||||||
"Zlib",
|
|
||||||
"CC0-1.0",
|
|
||||||
"MPL-2.0",
|
|
||||||
"BSL-1.0",
|
|
||||||
"OpenSSL",
|
|
||||||
# 0BSD ("BSD Zero Clause") is effectively public domain — no attribution
|
|
||||||
# required. Pulled in by `mock_instant`.
|
|
||||||
"0BSD",
|
|
||||||
# bzip2-1.0.6 is the permissive upstream bzip2 license (BSD-like). Pulled
|
|
||||||
# in by `libbz2-rs-sys`, the pure-Rust bzip2 implementation.
|
|
||||||
"bzip2-1.0.6",
|
|
||||||
# CDLA-Permissive-2.0 is a permissive data license used by `webpki-roots`
|
|
||||||
# for the Mozilla CA root bundle. Data-only, distribution-compatible.
|
|
||||||
"CDLA-Permissive-2.0",
|
|
||||||
]
|
|
||||||
confidence-threshold = 0.8
|
|
||||||
# Crates whose license cannot be determined from Cargo metadata but whose
|
|
||||||
# license we've manually confirmed from upstream. Keep this list minimal.
|
|
||||||
[[licenses.clarify]]
|
|
||||||
# polars-arrow-format omits the `license` field in its Cargo.toml, but the
|
|
||||||
# upstream repo (pola-rs/polars-arrow-format) is dual-licensed Apache-2.0 OR
|
|
||||||
# MIT. See https://github.com/pola-rs/polars-arrow-format/blob/main/LICENSE
|
|
||||||
crate = "polars-arrow-format"
|
|
||||||
expression = "Apache-2.0 OR MIT"
|
|
||||||
license-files = []
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# Bans: disallow specific crates and flag dependency hygiene issues.
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
[bans]
|
|
||||||
# Warn (not deny) on duplicate versions of the same crate. In a large
|
|
||||||
# workspace like this one, duplicates are common and often unavoidable
|
|
||||||
# transitively. We surface them to discourage growth, but don't fail CI.
|
|
||||||
multiple-versions = "warn"
|
|
||||||
# Wildcard version requirements (`foo = "*"`) are a footgun — they let any
|
|
||||||
# future release in without review. Ban them outright.
|
|
||||||
wildcards = "deny"
|
|
||||||
# Internal workspace crates reference each other via `path = "..."`, which
|
|
||||||
# cargo-deny sees as a wildcard version. That's fine for private workspace
|
|
||||||
# members (not published to crates.io), so allow it specifically for paths.
|
|
||||||
allow-wildcard-paths = true
|
|
||||||
# Features that, if enabled, should cause the check to fail.
|
|
||||||
deny = []
|
|
||||||
# Crates to skip when checking for duplicate versions.
|
|
||||||
skip = []
|
|
||||||
# Similar to `skip`, but also skips the entire transitive subtree.
|
|
||||||
skip-tree = []
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# Sources: restrict where crates can come from.
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
[sources]
|
|
||||||
# Deny any registry other than the ones explicitly listed below.
|
|
||||||
unknown-registry = "deny"
|
|
||||||
# Deny any git dependency whose host isn't in the allow-list below. This
|
|
||||||
# prevents accidental pulls from arbitrary forks.
|
|
||||||
unknown-git = "deny"
|
|
||||||
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
|
|
||||||
# Lance is developed in a sibling repo and pulled as a git dependency until
|
|
||||||
# releases are cut to crates.io. Allow that specific host.
|
|
||||||
allow-git = [
|
|
||||||
"https://github.com/lance-format/lance",
|
|
||||||
]
|
|
||||||
@@ -24,4 +24,4 @@ RUN python --version && \
|
|||||||
rustc --version && \
|
rustc --version && \
|
||||||
protoc --version
|
protoc --version
|
||||||
|
|
||||||
RUN pip install --no-cache-dir lancedb
|
RUN pip install --no-cache-dir tantivy lancedb
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# LanceDB Documentation
|
# LanceDB Documentation
|
||||||
|
|
||||||
LanceDB docs are available at [docs.lancedb.com](https://docs.lancedb.com).
|
LanceDB docs are available at [lancedb.com/docs](https://lancedb.com/docs).
|
||||||
|
|
||||||
The SDK docs are built and deployed automatically by [Github Actions](../.github/workflows/docs.yml)
|
The SDK docs are built and deployed automatically by [Github Actions](../.github/workflows/docs.yml)
|
||||||
whenever a commit is pushed to the `main` branch. So it is possible for the docs to show
|
whenever a commit is pushed to the `main` branch. So it is possible for the docs to show
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Add the following dependency to your `pom.xml`:
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.lancedb</groupId>
|
<groupId>com.lancedb</groupId>
|
||||||
<artifactId>lancedb-core</artifactId>
|
<artifactId>lancedb-core</artifactId>
|
||||||
<version>0.30.1-beta.0</version>
|
<version>0.28.0-beta.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const results = await table.vectorSearch([0.1, 0.3]).limit(20).toArray();
|
|||||||
console.log(results);
|
console.log(results);
|
||||||
```
|
```
|
||||||
|
|
||||||
The [quickstart](https://docs.lancedb.com/quickstart/) contains more complete examples.
|
The [quickstart](https://lancedb.com/docs/quickstart/basic-usage/) contains more complete examples.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
|||||||
@@ -12,22 +12,20 @@ Typescript.
|
|||||||
* `src/`: Rust bindings source code
|
* `src/`: Rust bindings source code
|
||||||
* `lancedb/`: Typescript package source code
|
* `lancedb/`: Typescript package source code
|
||||||
* `__test__/`: Unit tests
|
* `__test__/`: Unit tests
|
||||||
* `examples/`: A pnpm package with the examples shown in the documentation
|
* `examples/`: An npm package with the examples shown in the documentation
|
||||||
|
|
||||||
## Development environment
|
## Development environment
|
||||||
|
|
||||||
To set up your development environment, you will need to install the following:
|
To set up your development environment, you will need to install the following:
|
||||||
|
|
||||||
1. Node.js 22 or later (required by pnpm 11)
|
1. Node.js 14 or later
|
||||||
2. [pnpm](https://pnpm.io/installation) 11 or later (or run via `corepack enable`,
|
2. Rust's package manager, Cargo. Use [rustup](https://rustup.rs/) to install.
|
||||||
which uses the `packageManager` field in `package.json`)
|
3. [protoc](https://grpc.io/docs/protoc-installation/) (Protocol Buffers compiler)
|
||||||
3. Rust's package manager, Cargo. Use [rustup](https://rustup.rs/) to install.
|
|
||||||
4. [protoc](https://grpc.io/docs/protoc-installation/) (Protocol Buffers compiler)
|
|
||||||
|
|
||||||
Initial setup:
|
Initial setup:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pnpm install
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
### Commit Hooks
|
### Commit Hooks
|
||||||
@@ -41,38 +39,38 @@ pre-commit install
|
|||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
Most common development commands can be run using the pnpm scripts.
|
Most common development commands can be run using the npm scripts.
|
||||||
|
|
||||||
Build the package
|
Build the package
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pnpm install
|
npm install
|
||||||
pnpm build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
Lint:
|
Lint:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pnpm lint
|
npm run lint
|
||||||
```
|
```
|
||||||
|
|
||||||
Format and fix lints:
|
Format and fix lints:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pnpm lint-fix
|
npm run lint-fix
|
||||||
```
|
```
|
||||||
|
|
||||||
Run tests:
|
Run tests:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pnpm test
|
npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
To run a single test:
|
To run a single test:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Single file: table.test.ts
|
# Single file: table.test.ts
|
||||||
pnpm test -- table.test.ts
|
npm test -- table.test.ts
|
||||||
# Single test: 'merge insert' in table.test.ts
|
# Single test: 'merge insert' in table.test.ts
|
||||||
pnpm test -- table.test.ts --testNamePattern=merge\ insert
|
npm test -- table.test.ts --testNamePattern=merge\ insert
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -148,33 +148,6 @@ Creates a new empty Table
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### createNamespace()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
abstract createNamespace(namespacePath, options?): Promise<CreateNamespaceResponse>
|
|
||||||
```
|
|
||||||
|
|
||||||
Create a new namespace at the given path.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **namespacePath**: `string`[]
|
|
||||||
The namespace path to create.
|
|
||||||
|
|
||||||
* **options?**: `Partial`<[`CreateNamespaceOptions`](../interfaces/CreateNamespaceOptions.md)>
|
|
||||||
Creation `mode`
|
|
||||||
("create" | "exist_ok" | "overwrite") and optional `properties`
|
|
||||||
to attach to the namespace.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<[`CreateNamespaceResponse`](../interfaces/CreateNamespaceResponse.md)>
|
|
||||||
|
|
||||||
The properties of the
|
|
||||||
created namespace and an optional transaction id.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### createTable()
|
### createTable()
|
||||||
|
|
||||||
#### createTable(options, namespacePath)
|
#### createTable(options, namespacePath)
|
||||||
@@ -257,29 +230,6 @@ Creates a new Table and initialize it with new data.
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### describeNamespace()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
abstract describeNamespace(namespacePath): Promise<DescribeNamespaceResponse>
|
|
||||||
```
|
|
||||||
|
|
||||||
Describe a namespace, returning its properties.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **namespacePath**: `string`[]
|
|
||||||
The namespace path to describe, in
|
|
||||||
parent → child order, e.g. `["analytics", "sales"]`.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<[`DescribeNamespaceResponse`](../interfaces/DescribeNamespaceResponse.md)>
|
|
||||||
|
|
||||||
The namespace's properties
|
|
||||||
(may be undefined if the namespace has none).
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### display()
|
### display()
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
@@ -313,36 +263,6 @@ Drop all tables in the database.
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### dropNamespace()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
abstract dropNamespace(namespacePath, options?): Promise<DropNamespaceResponse>
|
|
||||||
```
|
|
||||||
|
|
||||||
Drop a namespace.
|
|
||||||
|
|
||||||
Use `behavior: "cascade"` to also drop everything contained in the
|
|
||||||
namespace (sub-namespaces and tables). The default `"restrict"`
|
|
||||||
behavior refuses to drop a non-empty namespace.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **namespacePath**: `string`[]
|
|
||||||
The namespace path to drop.
|
|
||||||
|
|
||||||
* **options?**: `Partial`<[`DropNamespaceOptions`](../interfaces/DropNamespaceOptions.md)>
|
|
||||||
`mode` ("skip" | "fail"
|
|
||||||
for missing-namespace handling) and `behavior` ("restrict" | "cascade").
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<[`DropNamespaceResponse`](../interfaces/DropNamespaceResponse.md)>
|
|
||||||
|
|
||||||
Any properties returned by
|
|
||||||
the server and an optional transaction id.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### dropTable()
|
### dropTable()
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
@@ -379,36 +299,6 @@ Return true if the connection has not been closed
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### listNamespaces()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
abstract listNamespaces(namespacePath?, options?): Promise<ListNamespacesResponse>
|
|
||||||
```
|
|
||||||
|
|
||||||
List the immediate child namespaces under the given parent.
|
|
||||||
|
|
||||||
Results may be paginated. To retrieve subsequent pages, pass the
|
|
||||||
`pageToken` returned by a previous call.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **namespacePath?**: `string`[]
|
|
||||||
The parent namespace path. Defaults
|
|
||||||
to the root namespace if omitted.
|
|
||||||
|
|
||||||
* **options?**: `Partial`<[`ListNamespacesOptions`](../interfaces/ListNamespacesOptions.md)>
|
|
||||||
Pagination options
|
|
||||||
(`pageToken`, `limit`).
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<[`ListNamespacesResponse`](../interfaces/ListNamespacesResponse.md)>
|
|
||||||
|
|
||||||
Child namespace names and
|
|
||||||
an optional token for fetching the next page.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### openTable()
|
### openTable()
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
@@ -437,39 +327,6 @@ Open a table in the database.
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### renameTable()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
abstract renameTable(
|
|
||||||
currentName,
|
|
||||||
newName,
|
|
||||||
options?): Promise<void>
|
|
||||||
```
|
|
||||||
|
|
||||||
Rename a table.
|
|
||||||
|
|
||||||
Currently only supported by LanceDB Cloud. Local OSS connections and
|
|
||||||
namespace-backed connections (via [connectNamespace](../functions/connectNamespace.md)) reject with
|
|
||||||
a "not supported" error.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **currentName**: `string`
|
|
||||||
The current name of the table.
|
|
||||||
|
|
||||||
* **newName**: `string`
|
|
||||||
The new name for the table.
|
|
||||||
|
|
||||||
* **options?**: [`RenameTableOptions`](../interfaces/RenameTableOptions.md)
|
|
||||||
Optional namespace paths. When
|
|
||||||
`newNamespacePath` is omitted the table stays in `namespacePath`.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<`void`>
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### tableNames()
|
### tableNames()
|
||||||
|
|
||||||
#### tableNames(options)
|
#### tableNames(options)
|
||||||
|
|||||||
@@ -76,57 +76,6 @@ the query optimizer chooses a suboptimal path.
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### useLsmWrite()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
useLsmWrite(useLsmWrite): MergeInsertBuilder
|
|
||||||
```
|
|
||||||
|
|
||||||
Controls whether the merge uses the MemWAL LSM write path.
|
|
||||||
|
|
||||||
By default (unset), a `mergeInsert` on a table with an LSM write spec is
|
|
||||||
routed through Lance's MemWAL shard writer, and a table without one uses
|
|
||||||
the standard path. Pass `false` to force the standard path even when a
|
|
||||||
spec is set. Pass `true` to require a spec — `mergeInsert` rejects if none
|
|
||||||
is installed.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **useLsmWrite**: `boolean`
|
|
||||||
Whether to use the LSM write path.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
[`MergeInsertBuilder`](MergeInsertBuilder.md)
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### validateSingleShard()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
validateSingleShard(validateSingleShard): MergeInsertBuilder
|
|
||||||
```
|
|
||||||
|
|
||||||
Controls how an LSM merge checks that its input targets a single shard.
|
|
||||||
|
|
||||||
When a table has an LSM write spec, every row in a `mergeInsert` call must
|
|
||||||
route to the same shard. When `true` (the default), every row is inspected
|
|
||||||
to verify this. When `false`, only the first row is inspected and the
|
|
||||||
shard it routes to is used for the whole input — a faster path for callers
|
|
||||||
that have already pre-sharded their input. Has no effect on tables without
|
|
||||||
an LSM write spec.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **validateSingleShard**: `boolean`
|
|
||||||
Whether to check every row routes to one shard. Defaults to `true`.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
[`MergeInsertBuilder`](MergeInsertBuilder.md)
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### whenMatchedUpdateAll()
|
### whenMatchedUpdateAll()
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
|
|||||||
@@ -343,30 +343,6 @@ This is useful for pagination.
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### orderBy()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
orderBy(ordering): this
|
|
||||||
```
|
|
||||||
|
|
||||||
Sort the results by the specified column(s).
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **ordering**: [`ColumnOrdering`](../interfaces/ColumnOrdering.md) \| [`ColumnOrdering`](../interfaces/ColumnOrdering.md)[]
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`this`
|
|
||||||
|
|
||||||
This query builder.
|
|
||||||
|
|
||||||
#### Inherited from
|
|
||||||
|
|
||||||
`StandardQueryBase.orderBy`
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### outputSchema()
|
### outputSchema()
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
|
|||||||
@@ -1,173 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / Scannable
|
|
||||||
|
|
||||||
# Class: Scannable
|
|
||||||
|
|
||||||
A data source that can be scanned as a stream of Arrow `RecordBatch`es.
|
|
||||||
|
|
||||||
`Scannable` wraps the schema + optional row count + rescannable flag and
|
|
||||||
a callback that yields batches one at a time. It is passed to consumers
|
|
||||||
(e.g. `Table.add`, `createTable`, `mergeInsert` — follow-up work) that
|
|
||||||
need to pull data without materializing the full dataset in JS memory.
|
|
||||||
|
|
||||||
Batches cross the JS↔Rust boundary as Arrow IPC Stream messages; a fresh
|
|
||||||
writer serializes each batch, and the Rust side decodes it with
|
|
||||||
`arrow_ipc::reader::StreamReader`. One batch is in flight at a time.
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### numRows
|
|
||||||
|
|
||||||
```ts
|
|
||||||
readonly numRows: null | number;
|
|
||||||
```
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### rescannable
|
|
||||||
|
|
||||||
```ts
|
|
||||||
readonly rescannable: boolean;
|
|
||||||
```
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### schema
|
|
||||||
|
|
||||||
```ts
|
|
||||||
readonly schema: Schema<any>;
|
|
||||||
```
|
|
||||||
|
|
||||||
## Methods
|
|
||||||
|
|
||||||
### fromFactory()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
static fromFactory(
|
|
||||||
schema,
|
|
||||||
factory,
|
|
||||||
opts): Promise<Scannable>
|
|
||||||
```
|
|
||||||
|
|
||||||
Build a Scannable from an explicit schema and a factory that returns a
|
|
||||||
fresh batch iterator on each call.
|
|
||||||
|
|
||||||
The factory is invoked once per scan. Each iterator yields
|
|
||||||
`RecordBatch`es matching the declared schema. Use this when you need
|
|
||||||
direct control over the pull loop — for example, to wrap a streaming
|
|
||||||
source whose batches are produced lazily.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **schema**: `Schema`<`any`>
|
|
||||||
The Arrow schema of the produced batches.
|
|
||||||
|
|
||||||
* **factory**
|
|
||||||
Called at the start of each scan to produce a batch
|
|
||||||
iterator. Must be idempotent when `rescannable` is true.
|
|
||||||
|
|
||||||
* **opts**: [`ScannableOptions`](../interfaces/ScannableOptions.md) = `{}`
|
|
||||||
Optional hints. `rescannable` defaults to `true`; set to
|
|
||||||
`false` if calling `factory()` twice would not reproduce the same data.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<[`Scannable`](Scannable.md)>
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### fromIterable()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
static fromIterable(
|
|
||||||
schema,
|
|
||||||
iter,
|
|
||||||
opts): Promise<Scannable>
|
|
||||||
```
|
|
||||||
|
|
||||||
Build a Scannable from an iterable of `RecordBatch`es. `rescannable`
|
|
||||||
defaults to `false`. Pass an explicit schema so the consumer can
|
|
||||||
validate before any batch is pulled.
|
|
||||||
|
|
||||||
`opts.rescannable: true` is honest for replayable iterables (Arrays,
|
|
||||||
Sets, or custom iterables whose `[Symbol.iterator]()` returns a fresh
|
|
||||||
iterator each call). It is rejected for one-shot iterables (generators,
|
|
||||||
async generators, or already-an-iterator inputs) because their
|
|
||||||
`[Symbol.iterator]()` returns the same exhausted object on the second
|
|
||||||
scan. For replayable sources outside this shape, use
|
|
||||||
`fromFactory(schema, () => createIter(), { rescannable: true })`.
|
|
||||||
|
|
||||||
Note: when `opts.rescannable` is `true`, the constructor calls
|
|
||||||
`[Symbol.iterator]()` once on the input to perform the structural check.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **schema**: `Schema`<`any`>
|
|
||||||
|
|
||||||
* **iter**: `Iterable`<`RecordBatch`<`any`>> \| `AsyncIterable`<`RecordBatch`<`any`>>
|
|
||||||
|
|
||||||
* **opts**: [`ScannableOptions`](../interfaces/ScannableOptions.md) = `{}`
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<[`Scannable`](Scannable.md)>
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### fromRecordBatchReader()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
static fromRecordBatchReader(reader, opts): Promise<Scannable>
|
|
||||||
```
|
|
||||||
|
|
||||||
Build a Scannable from an Arrow `RecordBatchReader`. A reader can only
|
|
||||||
be consumed once; `rescannable` defaults to `false`.
|
|
||||||
|
|
||||||
The reader must already be opened (via `.open()`) so its `.schema` is
|
|
||||||
populated. `RecordBatchReader.from(...)` returns an unopened reader.
|
|
||||||
|
|
||||||
`opts.rescannable: true` is rejected because `RecordBatchReader` is a
|
|
||||||
self-iterator (its `[Symbol.iterator]()` returns itself), and this
|
|
||||||
constructor does not call `reader.reset()` between scans, so a second
|
|
||||||
scan would always see an exhausted reader. For genuinely replayable
|
|
||||||
sources, use
|
|
||||||
`fromFactory(schema, () => openReader(), { rescannable: true })`,
|
|
||||||
which mints a fresh reader on each scan.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **reader**: `RecordBatchReader`<`any`>
|
|
||||||
|
|
||||||
* **opts**: [`ScannableOptions`](../interfaces/ScannableOptions.md) = `{}`
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<[`Scannable`](Scannable.md)>
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### fromTable()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
static fromTable(table, opts): Promise<Scannable>
|
|
||||||
```
|
|
||||||
|
|
||||||
Build a Scannable from an in-memory Arrow `Table`. Always rescannable;
|
|
||||||
the table's batches are replayed on each scan.
|
|
||||||
|
|
||||||
The table's row count is authoritative: `opts.numRows` must either be
|
|
||||||
omitted or equal to `table.numRows`. `opts.rescannable` of `false` is
|
|
||||||
rejected because in-memory Tables are always rescannable.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **table**: `Table`<`any`>
|
|
||||||
|
|
||||||
* **opts**: [`ScannableOptions`](../interfaces/ScannableOptions.md) = `{}`
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<[`Scannable`](Scannable.md)>
|
|
||||||
@@ -187,25 +187,6 @@ Any attempt to use the table after it is closed will result in an error.
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### closeLsmWriters()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
abstract closeLsmWriters(): Promise<void>
|
|
||||||
```
|
|
||||||
|
|
||||||
Drain and close any cached MemWAL shard writers held for this table.
|
|
||||||
|
|
||||||
When an [LsmWriteSpec](../interfaces/LsmWriteSpec.md) is installed, `mergeInsert` opens MemWAL
|
|
||||||
shard writers and caches them for reuse across calls. This closes them,
|
|
||||||
flushing pending data; writers reopen lazily on the next `mergeInsert`.
|
|
||||||
It is a no-op when no writers are cached.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<`void`>
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### countRows()
|
### countRows()
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
@@ -520,34 +501,6 @@ Modeled after ``VACUUM`` in PostgreSQL.
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### prewarmData()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
abstract prewarmData(columns?): Promise<void>
|
|
||||||
```
|
|
||||||
|
|
||||||
Prewarm one or more columns of data in the table.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **columns?**: `string`[]
|
|
||||||
The columns to prewarm. If undefined, all columns are prewarmed.
|
|
||||||
This will load the column data into the page cache so that future queries that
|
|
||||||
read those columns avoid the initial cold-start latency. This call initiates
|
|
||||||
prewarming and returns once the request is accepted; the warming itself may
|
|
||||||
continue in the background. Calling it on already-prewarmed columns is a
|
|
||||||
no-op on the server.
|
|
||||||
Prewarming is generally useful for columns used in filters or projections.
|
|
||||||
Large columns (e.g. high-dimensional vectors or binary data) may not be
|
|
||||||
practical to prewarm.
|
|
||||||
This feature is currently only supported on remote tables.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<`void`>
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### prewarmIndex()
|
### prewarmIndex()
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
@@ -709,74 +662,6 @@ of the given query
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### setLsmWriteSpec()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
abstract setLsmWriteSpec(spec): Promise<void>
|
|
||||||
```
|
|
||||||
|
|
||||||
Install an [LsmWriteSpec](../interfaces/LsmWriteSpec.md) on this table, selecting Lance's MemWAL
|
|
||||||
LSM-style write path for future `mergeInsert` calls.
|
|
||||||
|
|
||||||
`LsmWriteSpec` chooses one of three sharding strategies via `specType`:
|
|
||||||
|
|
||||||
- `"bucket"` — hash-bucket writes by the single-column unenforced primary
|
|
||||||
key (`column` and `numBuckets` required).
|
|
||||||
- `"identity"` — shard by the raw value of a scalar `column`.
|
|
||||||
- `"unsharded"` — route every write to a single shard.
|
|
||||||
|
|
||||||
All variants require the table to have an unenforced primary key
|
|
||||||
([Table#setUnenforcedPrimaryKey](Table.md#setunenforcedprimarykey)); bucket sharding additionally
|
|
||||||
requires it to be the single column being bucketed.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **spec**: [`LsmWriteSpec`](../interfaces/LsmWriteSpec.md)
|
|
||||||
The sharding spec to install.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<`void`>
|
|
||||||
|
|
||||||
#### Example
|
|
||||||
|
|
||||||
```ts
|
|
||||||
await table.setUnenforcedPrimaryKey("id");
|
|
||||||
await table.setLsmWriteSpec({
|
|
||||||
specType: "bucket",
|
|
||||||
column: "id",
|
|
||||||
numBuckets: 16,
|
|
||||||
maintainedIndexes: ["id_idx"],
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### setUnenforcedPrimaryKey()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
abstract setUnenforcedPrimaryKey(columns): Promise<void>
|
|
||||||
```
|
|
||||||
|
|
||||||
Set the unenforced primary key for this table to a single column.
|
|
||||||
|
|
||||||
"Unenforced" means LanceDB does not check uniqueness on writes; the
|
|
||||||
column is recorded in the schema as the primary key for use by features
|
|
||||||
such as `merge_insert`. Only single-column primary keys are supported,
|
|
||||||
and the key cannot be changed once set.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **columns**: `string` \| `string`[]
|
|
||||||
The primary key column. A one-element
|
|
||||||
array is also accepted; passing more than one column is rejected.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<`void`>
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### stats()
|
### stats()
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
@@ -880,23 +765,6 @@ Return the table as an arrow table
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### unsetLsmWriteSpec()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
abstract unsetLsmWriteSpec(): Promise<void>
|
|
||||||
```
|
|
||||||
|
|
||||||
Remove the [LsmWriteSpec](../interfaces/LsmWriteSpec.md) from this table, reverting to the standard
|
|
||||||
`mergeInsert` write path.
|
|
||||||
|
|
||||||
Errors if no spec is currently set.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<`void`>
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### update()
|
### update()
|
||||||
|
|
||||||
#### update(opts)
|
#### update(opts)
|
||||||
@@ -994,29 +862,6 @@ based on the row being updated (e.g. "my_col + 1")
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### updateFieldMetadata()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
abstract updateFieldMetadata(updates): Promise<UpdateFieldMetadataResult>
|
|
||||||
```
|
|
||||||
|
|
||||||
Update per-field (column) metadata.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **updates**: [`FieldMetadataUpdate`](../interfaces/FieldMetadataUpdate.md)[]
|
|
||||||
One or more per-field updates. Each
|
|
||||||
update's metadata is merged into the field's existing metadata by default;
|
|
||||||
a value of `null` deletes that key, and `replace: true` swaps the whole map.
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`Promise`<[`UpdateFieldMetadataResult`](../interfaces/UpdateFieldMetadataResult.md)>
|
|
||||||
|
|
||||||
resolves to the new table version.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### vectorSearch()
|
### vectorSearch()
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
|
|||||||
@@ -498,30 +498,6 @@ This is useful for pagination.
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### orderBy()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
orderBy(ordering): this
|
|
||||||
```
|
|
||||||
|
|
||||||
Sort the results by the specified column(s).
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **ordering**: [`ColumnOrdering`](../interfaces/ColumnOrdering.md) \| [`ColumnOrdering`](../interfaces/ColumnOrdering.md)[]
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`this`
|
|
||||||
|
|
||||||
This query builder.
|
|
||||||
|
|
||||||
#### Inherited from
|
|
||||||
|
|
||||||
`StandardQueryBase.orderBy`
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### outputSchema()
|
### outputSchema()
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
|
|||||||
@@ -1,131 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / connectNamespace
|
|
||||||
|
|
||||||
# Function: connectNamespace()
|
|
||||||
|
|
||||||
## connectNamespace(implName, config, options)
|
|
||||||
|
|
||||||
```ts
|
|
||||||
function connectNamespace(
|
|
||||||
implName,
|
|
||||||
config,
|
|
||||||
options?): Promise<Connection>
|
|
||||||
```
|
|
||||||
|
|
||||||
Connect to a LanceDB database through a namespace.
|
|
||||||
|
|
||||||
Unlike [connect](connect.md), which routes by URI scheme (local path vs.
|
|
||||||
`db://` cloud), `connectNamespace` always returns a namespace-backed
|
|
||||||
connection. The `implName` selects the namespace implementation:
|
|
||||||
|
|
||||||
- `"dir"` — directory namespace, configured with [DirNamespaceConfig](../interfaces/DirNamespaceConfig.md).
|
|
||||||
- `"rest"` — remote REST catalog, configured with [RestNamespaceConfig](../interfaces/RestNamespaceConfig.md).
|
|
||||||
- Any other string — full module path for a custom implementation,
|
|
||||||
configured with a free-form string-keyed `properties` map.
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
* **implName**: `"dir"`
|
|
||||||
|
|
||||||
* **config**: [`DirNamespaceConfig`](../interfaces/DirNamespaceConfig.md)
|
|
||||||
|
|
||||||
* **options?**: `Partial`<[`ConnectNamespaceOptions`](../interfaces/ConnectNamespaceOptions.md)>
|
|
||||||
|
|
||||||
### Returns
|
|
||||||
|
|
||||||
`Promise`<[`Connection`](../classes/Connection.md)>
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
```ts
|
|
||||||
const db = await connectNamespace("dir", { root: "/path/to/db" });
|
|
||||||
await db.createTable("users", [{ id: 1 }]);
|
|
||||||
```
|
|
||||||
|
|
||||||
```ts
|
|
||||||
const db = await connectNamespace("rest", {
|
|
||||||
uri: "https://catalog.example.com",
|
|
||||||
headers: { "x-api-key": process.env.CATALOG_KEY ?? "" },
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
```ts
|
|
||||||
const db = await connectNamespace("my.custom.Namespace", {
|
|
||||||
endpoint: "...",
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## connectNamespace(implName, config, options)
|
|
||||||
|
|
||||||
```ts
|
|
||||||
function connectNamespace(
|
|
||||||
implName,
|
|
||||||
config,
|
|
||||||
options?): Promise<Connection>
|
|
||||||
```
|
|
||||||
|
|
||||||
Connect through the built-in REST namespace.
|
|
||||||
|
|
||||||
Configured with [RestNamespaceConfig](../interfaces/RestNamespaceConfig.md). See the function-level
|
|
||||||
documentation above for the full surface, examples, and how this
|
|
||||||
relates to [connect](connect.md).
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
* **implName**: `"rest"`
|
|
||||||
|
|
||||||
* **config**: [`RestNamespaceConfig`](../interfaces/RestNamespaceConfig.md)
|
|
||||||
|
|
||||||
* **options?**: `Partial`<[`ConnectNamespaceOptions`](../interfaces/ConnectNamespaceOptions.md)>
|
|
||||||
|
|
||||||
### Returns
|
|
||||||
|
|
||||||
`Promise`<[`Connection`](../classes/Connection.md)>
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
```ts
|
|
||||||
const db = await connectNamespace("rest", {
|
|
||||||
uri: "https://catalog.example.com",
|
|
||||||
headers: { "x-api-key": process.env.CATALOG_KEY ?? "" },
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## connectNamespace(implName, properties, options)
|
|
||||||
|
|
||||||
```ts
|
|
||||||
function connectNamespace(
|
|
||||||
implName,
|
|
||||||
properties,
|
|
||||||
options?): Promise<Connection>
|
|
||||||
```
|
|
||||||
|
|
||||||
Connect through a custom namespace implementation by full module path,
|
|
||||||
configured with a free-form string-keyed `properties` map. Use the
|
|
||||||
typed overloads above for the built-in `"dir"` and `"rest"` impls.
|
|
||||||
|
|
||||||
See the function-level documentation above for examples and how this
|
|
||||||
relates to [connect](connect.md).
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
* **implName**: `string`
|
|
||||||
|
|
||||||
* **properties**: `Record`<`string`, `string`>
|
|
||||||
|
|
||||||
* **options?**: `Partial`<[`ConnectNamespaceOptions`](../interfaces/ConnectNamespaceOptions.md)>
|
|
||||||
|
|
||||||
### Returns
|
|
||||||
|
|
||||||
`Promise`<[`Connection`](../classes/Connection.md)>
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
```ts
|
|
||||||
const db = await connectNamespace("my.custom.Namespace", {
|
|
||||||
endpoint: "...",
|
|
||||||
});
|
|
||||||
```
|
|
||||||
@@ -32,7 +32,6 @@
|
|||||||
- [PhraseQuery](classes/PhraseQuery.md)
|
- [PhraseQuery](classes/PhraseQuery.md)
|
||||||
- [Query](classes/Query.md)
|
- [Query](classes/Query.md)
|
||||||
- [QueryBase](classes/QueryBase.md)
|
- [QueryBase](classes/QueryBase.md)
|
||||||
- [Scannable](classes/Scannable.md)
|
|
||||||
- [Session](classes/Session.md)
|
- [Session](classes/Session.md)
|
||||||
- [StaticHeaderProvider](classes/StaticHeaderProvider.md)
|
- [StaticHeaderProvider](classes/StaticHeaderProvider.md)
|
||||||
- [Table](classes/Table.md)
|
- [Table](classes/Table.md)
|
||||||
@@ -51,21 +50,12 @@
|
|||||||
- [AlterColumnsResult](interfaces/AlterColumnsResult.md)
|
- [AlterColumnsResult](interfaces/AlterColumnsResult.md)
|
||||||
- [ClientConfig](interfaces/ClientConfig.md)
|
- [ClientConfig](interfaces/ClientConfig.md)
|
||||||
- [ColumnAlteration](interfaces/ColumnAlteration.md)
|
- [ColumnAlteration](interfaces/ColumnAlteration.md)
|
||||||
- [ColumnOrdering](interfaces/ColumnOrdering.md)
|
|
||||||
- [CompactionStats](interfaces/CompactionStats.md)
|
- [CompactionStats](interfaces/CompactionStats.md)
|
||||||
- [ConnectNamespaceOptions](interfaces/ConnectNamespaceOptions.md)
|
|
||||||
- [ConnectionOptions](interfaces/ConnectionOptions.md)
|
- [ConnectionOptions](interfaces/ConnectionOptions.md)
|
||||||
- [CreateNamespaceOptions](interfaces/CreateNamespaceOptions.md)
|
|
||||||
- [CreateNamespaceResponse](interfaces/CreateNamespaceResponse.md)
|
|
||||||
- [CreateTableOptions](interfaces/CreateTableOptions.md)
|
- [CreateTableOptions](interfaces/CreateTableOptions.md)
|
||||||
- [DeleteResult](interfaces/DeleteResult.md)
|
- [DeleteResult](interfaces/DeleteResult.md)
|
||||||
- [DescribeNamespaceResponse](interfaces/DescribeNamespaceResponse.md)
|
|
||||||
- [DirNamespaceConfig](interfaces/DirNamespaceConfig.md)
|
|
||||||
- [DropColumnsResult](interfaces/DropColumnsResult.md)
|
- [DropColumnsResult](interfaces/DropColumnsResult.md)
|
||||||
- [DropNamespaceOptions](interfaces/DropNamespaceOptions.md)
|
|
||||||
- [DropNamespaceResponse](interfaces/DropNamespaceResponse.md)
|
|
||||||
- [ExecutableQuery](interfaces/ExecutableQuery.md)
|
- [ExecutableQuery](interfaces/ExecutableQuery.md)
|
||||||
- [FieldMetadataUpdate](interfaces/FieldMetadataUpdate.md)
|
|
||||||
- [FragmentStatistics](interfaces/FragmentStatistics.md)
|
- [FragmentStatistics](interfaces/FragmentStatistics.md)
|
||||||
- [FragmentSummaryStats](interfaces/FragmentSummaryStats.md)
|
- [FragmentSummaryStats](interfaces/FragmentSummaryStats.md)
|
||||||
- [FtsOptions](interfaces/FtsOptions.md)
|
- [FtsOptions](interfaces/FtsOptions.md)
|
||||||
@@ -79,19 +69,13 @@
|
|||||||
- [IvfFlatOptions](interfaces/IvfFlatOptions.md)
|
- [IvfFlatOptions](interfaces/IvfFlatOptions.md)
|
||||||
- [IvfPqOptions](interfaces/IvfPqOptions.md)
|
- [IvfPqOptions](interfaces/IvfPqOptions.md)
|
||||||
- [IvfRqOptions](interfaces/IvfRqOptions.md)
|
- [IvfRqOptions](interfaces/IvfRqOptions.md)
|
||||||
- [ListNamespacesOptions](interfaces/ListNamespacesOptions.md)
|
|
||||||
- [ListNamespacesResponse](interfaces/ListNamespacesResponse.md)
|
|
||||||
- [LsmWriteSpec](interfaces/LsmWriteSpec.md)
|
|
||||||
- [MergeResult](interfaces/MergeResult.md)
|
- [MergeResult](interfaces/MergeResult.md)
|
||||||
- [OpenTableOptions](interfaces/OpenTableOptions.md)
|
- [OpenTableOptions](interfaces/OpenTableOptions.md)
|
||||||
- [OptimizeOptions](interfaces/OptimizeOptions.md)
|
- [OptimizeOptions](interfaces/OptimizeOptions.md)
|
||||||
- [OptimizeStats](interfaces/OptimizeStats.md)
|
- [OptimizeStats](interfaces/OptimizeStats.md)
|
||||||
- [QueryExecutionOptions](interfaces/QueryExecutionOptions.md)
|
- [QueryExecutionOptions](interfaces/QueryExecutionOptions.md)
|
||||||
- [RemovalStats](interfaces/RemovalStats.md)
|
- [RemovalStats](interfaces/RemovalStats.md)
|
||||||
- [RenameTableOptions](interfaces/RenameTableOptions.md)
|
|
||||||
- [RestNamespaceConfig](interfaces/RestNamespaceConfig.md)
|
|
||||||
- [RetryConfig](interfaces/RetryConfig.md)
|
- [RetryConfig](interfaces/RetryConfig.md)
|
||||||
- [ScannableOptions](interfaces/ScannableOptions.md)
|
|
||||||
- [ShuffleOptions](interfaces/ShuffleOptions.md)
|
- [ShuffleOptions](interfaces/ShuffleOptions.md)
|
||||||
- [SplitCalculatedOptions](interfaces/SplitCalculatedOptions.md)
|
- [SplitCalculatedOptions](interfaces/SplitCalculatedOptions.md)
|
||||||
- [SplitHashOptions](interfaces/SplitHashOptions.md)
|
- [SplitHashOptions](interfaces/SplitHashOptions.md)
|
||||||
@@ -102,12 +86,10 @@
|
|||||||
- [TimeoutConfig](interfaces/TimeoutConfig.md)
|
- [TimeoutConfig](interfaces/TimeoutConfig.md)
|
||||||
- [TlsConfig](interfaces/TlsConfig.md)
|
- [TlsConfig](interfaces/TlsConfig.md)
|
||||||
- [TokenResponse](interfaces/TokenResponse.md)
|
- [TokenResponse](interfaces/TokenResponse.md)
|
||||||
- [UpdateFieldMetadataResult](interfaces/UpdateFieldMetadataResult.md)
|
|
||||||
- [UpdateOptions](interfaces/UpdateOptions.md)
|
- [UpdateOptions](interfaces/UpdateOptions.md)
|
||||||
- [UpdateResult](interfaces/UpdateResult.md)
|
- [UpdateResult](interfaces/UpdateResult.md)
|
||||||
- [Version](interfaces/Version.md)
|
- [Version](interfaces/Version.md)
|
||||||
- [WriteExecutionOptions](interfaces/WriteExecutionOptions.md)
|
- [WriteExecutionOptions](interfaces/WriteExecutionOptions.md)
|
||||||
- [WriteProgress](interfaces/WriteProgress.md)
|
|
||||||
|
|
||||||
## Type Aliases
|
## Type Aliases
|
||||||
|
|
||||||
@@ -125,7 +107,6 @@
|
|||||||
|
|
||||||
- [RecordBatchIterator](functions/RecordBatchIterator.md)
|
- [RecordBatchIterator](functions/RecordBatchIterator.md)
|
||||||
- [connect](functions/connect.md)
|
- [connect](functions/connect.md)
|
||||||
- [connectNamespace](functions/connectNamespace.md)
|
|
||||||
- [makeArrowTable](functions/makeArrowTable.md)
|
- [makeArrowTable](functions/makeArrowTable.md)
|
||||||
- [packBits](functions/packBits.md)
|
- [packBits](functions/packBits.md)
|
||||||
- [permutationBuilder](functions/permutationBuilder.md)
|
- [permutationBuilder](functions/permutationBuilder.md)
|
||||||
|
|||||||
@@ -19,39 +19,3 @@ mode: "append" | "overwrite";
|
|||||||
If "append" (the default) then the new data will be added to the table
|
If "append" (the default) then the new data will be added to the table
|
||||||
|
|
||||||
If "overwrite" then the new data will replace the existing data in the table.
|
If "overwrite" then the new data will replace the existing data in the table.
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### progress()
|
|
||||||
|
|
||||||
```ts
|
|
||||||
progress: (progress) => void;
|
|
||||||
```
|
|
||||||
|
|
||||||
Optional callback invoked periodically with write progress.
|
|
||||||
|
|
||||||
The callback is fired once per batch written and once more with
|
|
||||||
`done: true` when the write completes. Calls are dispatched
|
|
||||||
asynchronously to the JS event loop and never block the write — a slow
|
|
||||||
callback will queue events rather than back-pressure the writer.
|
|
||||||
|
|
||||||
Errors thrown from the callback are logged with `console.warn` and
|
|
||||||
swallowed — they do not abort the write.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
* **progress**: [`WriteProgress`](WriteProgress.md)
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`void`
|
|
||||||
|
|
||||||
#### Example
|
|
||||||
|
|
||||||
```ts
|
|
||||||
await table.add(data, {
|
|
||||||
progress: (p) => {
|
|
||||||
console.log(`${p.outputRows}/${p.totalRows ?? "?"} rows`);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / ColumnOrdering
|
|
||||||
|
|
||||||
# Interface: ColumnOrdering
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### ascending?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional ascending: boolean;
|
|
||||||
```
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### columnName
|
|
||||||
|
|
||||||
```ts
|
|
||||||
columnName: string;
|
|
||||||
```
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### nullsFirst?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional nullsFirst: boolean;
|
|
||||||
```
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / ConnectNamespaceOptions
|
|
||||||
|
|
||||||
# Interface: ConnectNamespaceOptions
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### namespaceClientProperties?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional namespaceClientProperties: Record<string, string>;
|
|
||||||
```
|
|
||||||
|
|
||||||
Extra properties for the backing namespace client.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### readConsistencyInterval?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional readConsistencyInterval: number;
|
|
||||||
```
|
|
||||||
|
|
||||||
The interval, in seconds, at which to check for updates to the table
|
|
||||||
from other processes. If None, then consistency is not checked. For
|
|
||||||
performance reasons, this is the default. For strong consistency, set
|
|
||||||
this to zero seconds. Then every read will check for updates from other
|
|
||||||
processes. As a compromise, you can set this to a non-zero value for
|
|
||||||
eventual consistency.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### session?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional session: Session;
|
|
||||||
```
|
|
||||||
|
|
||||||
The session to use for this connection. Holds shared caches and other
|
|
||||||
session-specific state.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### storageOptions?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional storageOptions: Record<string, string>;
|
|
||||||
```
|
|
||||||
|
|
||||||
Configuration for object storage. The available options are described
|
|
||||||
at https://docs.lancedb.com/storage/
|
|
||||||
@@ -41,49 +41,22 @@ for testing purposes.
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### manifestEnabled?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional manifestEnabled: boolean;
|
|
||||||
```
|
|
||||||
|
|
||||||
(For LanceDB OSS only): use directory namespace manifests as the source
|
|
||||||
of truth for table metadata. Existing directory-listed root tables are
|
|
||||||
migrated into the manifest on access.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### namespaceClientProperties?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional namespaceClientProperties: Record<string, string>;
|
|
||||||
```
|
|
||||||
|
|
||||||
(For LanceDB OSS only): extra properties for the backing namespace
|
|
||||||
client used by manifest-enabled native connections.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### readConsistencyInterval?
|
### readConsistencyInterval?
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
optional readConsistencyInterval: number;
|
optional readConsistencyInterval: number;
|
||||||
```
|
```
|
||||||
|
|
||||||
The interval, in seconds, at which to check for updates to the table
|
(For LanceDB OSS only): The interval, in seconds, at which to check for
|
||||||
from other processes. If None, then consistency is not checked. For
|
updates to the table from other processes. If None, then consistency is not
|
||||||
performance reasons, this is the default. For strong consistency, set
|
checked. For performance reasons, this is the default. For strong
|
||||||
this to zero seconds. Then every read will check for updates from other
|
consistency, set this to zero seconds. Then every read will check for
|
||||||
processes. As a compromise, you can set this to a non-zero value for
|
updates from other processes. As a compromise, you can set this to a
|
||||||
eventual consistency. If more than that interval has passed since the
|
non-zero value for eventual consistency. If more than that interval
|
||||||
last check, then the table will be checked for updates. Note: this
|
has passed since the last check, then the table will be checked for updates.
|
||||||
consistency only applies to read operations. Write operations are
|
Note: this consistency only applies to read operations. Write operations are
|
||||||
always consistent.
|
always consistent.
|
||||||
|
|
||||||
Stronger consistency is not free. The smaller the interval, the more
|
|
||||||
often each read pays the cost of checking for updates against object
|
|
||||||
storage, raising per-read latency and cost.
|
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### region?
|
### region?
|
||||||
@@ -116,4 +89,4 @@ optional storageOptions: Record<string, string>;
|
|||||||
|
|
||||||
(For LanceDB OSS only): configuration for object storage.
|
(For LanceDB OSS only): configuration for object storage.
|
||||||
|
|
||||||
The available options are described at https://docs.lancedb.com/storage/
|
The available options are described at https://lancedb.com/docs/storage/
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / CreateNamespaceOptions
|
|
||||||
|
|
||||||
# Interface: CreateNamespaceOptions
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### mode?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional mode: "overwrite" | "create" | "exist_ok";
|
|
||||||
```
|
|
||||||
|
|
||||||
Creation mode.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### properties?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional properties: Record<string, string>;
|
|
||||||
```
|
|
||||||
|
|
||||||
Properties to set on the new namespace.
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / CreateNamespaceResponse
|
|
||||||
|
|
||||||
# Interface: CreateNamespaceResponse
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### properties?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional properties: Record<string, string>;
|
|
||||||
```
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### transactionId?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional transactionId: string;
|
|
||||||
```
|
|
||||||
@@ -97,4 +97,4 @@ Configuration for object storage.
|
|||||||
Options already set on the connection will be inherited by the table,
|
Options already set on the connection will be inherited by the table,
|
||||||
but can be overridden here.
|
but can be overridden here.
|
||||||
|
|
||||||
The available options are described at https://docs.lancedb.com/storage/
|
The available options are described at https://lancedb.com/docs/storage/
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / DescribeNamespaceResponse
|
|
||||||
|
|
||||||
# Interface: DescribeNamespaceResponse
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### properties?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional properties: Record<string, string>;
|
|
||||||
```
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / DirNamespaceConfig
|
|
||||||
|
|
||||||
# Interface: DirNamespaceConfig
|
|
||||||
|
|
||||||
Configuration for the built-in directory namespace (`"dir"`).
|
|
||||||
|
|
||||||
The directory namespace stores tables under a single root path (local
|
|
||||||
filesystem or object storage URI). See
|
|
||||||
[https://docs.lancedb.com/namespaces](https://docs.lancedb.com/namespaces) for the documented surface;
|
|
||||||
less-common knobs live under [DirNamespaceConfig.extraProperties](DirNamespaceConfig.md#extraproperties).
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### extraProperties?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional extraProperties: Record<string, string>;
|
|
||||||
```
|
|
||||||
|
|
||||||
Additional raw properties passed verbatim to the namespace
|
|
||||||
implementation (e.g. `storage.*`, `credential_vendor.*`). Typed
|
|
||||||
fields above take precedence on key collision.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### manifestEnabled?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional manifestEnabled: boolean;
|
|
||||||
```
|
|
||||||
|
|
||||||
Whether to maintain a namespace manifest at the root. Required for
|
|
||||||
child namespaces. Defaults to true on the impl side.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### root
|
|
||||||
|
|
||||||
```ts
|
|
||||||
root: string;
|
|
||||||
```
|
|
||||||
|
|
||||||
Root path or URI containing the LanceDB tables.
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / DropNamespaceOptions
|
|
||||||
|
|
||||||
# Interface: DropNamespaceOptions
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### behavior?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional behavior: "restrict" | "cascade";
|
|
||||||
```
|
|
||||||
|
|
||||||
Refuse to drop if non-empty (restrict) or drop recursively (cascade).
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### mode?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional mode: "fail" | "skip";
|
|
||||||
```
|
|
||||||
|
|
||||||
Whether to skip if the namespace doesn't exist, or fail.
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / DropNamespaceResponse
|
|
||||||
|
|
||||||
# Interface: DropNamespaceResponse
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### properties?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional properties: Record<string, string>;
|
|
||||||
```
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### transactionId?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional transactionId: string[];
|
|
||||||
```
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / FieldMetadataUpdate
|
|
||||||
|
|
||||||
# Interface: FieldMetadataUpdate
|
|
||||||
|
|
||||||
A per-field metadata update, addressed by dot-path.
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### metadata
|
|
||||||
|
|
||||||
```ts
|
|
||||||
metadata: Record<string, null | string>;
|
|
||||||
```
|
|
||||||
|
|
||||||
Metadata key/value pairs. Merged into the field's existing metadata by
|
|
||||||
default; a value of `null` deletes that key.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### path
|
|
||||||
|
|
||||||
```ts
|
|
||||||
path: string;
|
|
||||||
```
|
|
||||||
|
|
||||||
Dot-separated path to the field. For a top-level column this is just its
|
|
||||||
name; for a nested field it's the path, e.g. "a.b.c".
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### replace?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional replace: boolean;
|
|
||||||
```
|
|
||||||
|
|
||||||
If true, replace the field's entire metadata map instead of merging.
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / ListNamespacesOptions
|
|
||||||
|
|
||||||
# Interface: ListNamespacesOptions
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### limit?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional limit: number;
|
|
||||||
```
|
|
||||||
|
|
||||||
An optional limit to the number of results to return.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### pageToken?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional pageToken: string;
|
|
||||||
```
|
|
||||||
|
|
||||||
Token from a previous response for pagination.
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / ListNamespacesResponse
|
|
||||||
|
|
||||||
# Interface: ListNamespacesResponse
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### namespaces
|
|
||||||
|
|
||||||
```ts
|
|
||||||
namespaces: string[];
|
|
||||||
```
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### pageToken?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional pageToken: string;
|
|
||||||
```
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / LsmWriteSpec
|
|
||||||
|
|
||||||
# Interface: LsmWriteSpec
|
|
||||||
|
|
||||||
Specification selecting Lance's MemWAL LSM-style write path for
|
|
||||||
`mergeInsert`.
|
|
||||||
|
|
||||||
`specType` is `"bucket"`, `"identity"`, or `"unsharded"`. For `"bucket"`,
|
|
||||||
`column` and `numBuckets` are required; for `"identity"`, `column` is
|
|
||||||
required and must be a deterministic function of the unenforced primary
|
|
||||||
key (every row with a given primary key must always produce the same
|
|
||||||
`column` value, or upserts of that key can land in different shards and a
|
|
||||||
stale version can win).
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### column?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional column: string;
|
|
||||||
```
|
|
||||||
|
|
||||||
Bucket and identity variants: the sharding column.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### maintainedIndexes?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional maintainedIndexes: string[];
|
|
||||||
```
|
|
||||||
|
|
||||||
Names of indexes the MemWAL should keep up to date during writes.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### numBuckets?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional numBuckets: number;
|
|
||||||
```
|
|
||||||
|
|
||||||
Bucket variant: the number of buckets, in `[1, 1024]`.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### specType
|
|
||||||
|
|
||||||
```ts
|
|
||||||
specType: "bucket" | "identity" | "unsharded";
|
|
||||||
```
|
|
||||||
|
|
||||||
One of `"bucket"`, `"identity"`, or `"unsharded"`.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### writerConfigDefaults?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional writerConfigDefaults: Record<string, string>;
|
|
||||||
```
|
|
||||||
|
|
||||||
Default `ShardWriter` configuration recorded in the MemWAL index.
|
|
||||||
@@ -32,14 +32,6 @@ numInsertedRows: number;
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### numRows
|
|
||||||
|
|
||||||
```ts
|
|
||||||
numRows: number;
|
|
||||||
```
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### numUpdatedRows
|
### numUpdatedRows
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
|
|||||||
@@ -42,4 +42,4 @@ Configuration for object storage.
|
|||||||
Options already set on the connection will be inherited by the table,
|
Options already set on the connection will be inherited by the table,
|
||||||
but can be overridden here.
|
but can be overridden here.
|
||||||
|
|
||||||
The available options are described at https://docs.lancedb.com/storage/
|
The available options are described at https://lancedb.com/docs/storage/
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / RenameTableOptions
|
|
||||||
|
|
||||||
# Interface: RenameTableOptions
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### namespacePath?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional namespacePath: string[];
|
|
||||||
```
|
|
||||||
|
|
||||||
The namespace path of the table being renamed. Defaults to the root
|
|
||||||
namespace (`[]`) when omitted.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### newNamespacePath?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional newNamespacePath: string[];
|
|
||||||
```
|
|
||||||
|
|
||||||
The namespace path to move the table to as part of the rename. When
|
|
||||||
omitted the table stays in `namespacePath`.
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / RestNamespaceConfig
|
|
||||||
|
|
||||||
# Interface: RestNamespaceConfig
|
|
||||||
|
|
||||||
Configuration for the built-in REST namespace (`"rest"`).
|
|
||||||
|
|
||||||
The REST namespace talks to a remote catalog server over HTTP. See
|
|
||||||
[https://docs.lancedb.com/namespaces](https://docs.lancedb.com/namespaces) for the documented surface;
|
|
||||||
less-common knobs (TLS, metrics) live under
|
|
||||||
[RestNamespaceConfig.extraProperties](RestNamespaceConfig.md#extraproperties).
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### extraProperties?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional extraProperties: Record<string, string>;
|
|
||||||
```
|
|
||||||
|
|
||||||
Additional raw properties passed verbatim to the namespace
|
|
||||||
implementation (e.g. `tls.*`, `ops_metrics_enabled`, `delimiter`).
|
|
||||||
Typed fields above take precedence on key collision.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### headers?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional headers: Record<string, string>;
|
|
||||||
```
|
|
||||||
|
|
||||||
HTTP headers forwarded with each request. Keys are passed through
|
|
||||||
as-is (e.g. `"x-api-key"`, `"Authorization"`).
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### uri
|
|
||||||
|
|
||||||
```ts
|
|
||||||
uri: string;
|
|
||||||
```
|
|
||||||
|
|
||||||
Catalog endpoint URL.
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / ScannableOptions
|
|
||||||
|
|
||||||
# Interface: ScannableOptions
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### numRows?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional numRows: number;
|
|
||||||
```
|
|
||||||
|
|
||||||
Hint about the number of rows. Not validated against the stream.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### rescannable?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional rescannable: boolean;
|
|
||||||
```
|
|
||||||
|
|
||||||
Whether the source can be scanned more than once. Defaults to `true` for
|
|
||||||
`fromTable` / `fromFactory` and `false` for `fromIterable` /
|
|
||||||
`fromRecordBatchReader`.
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / UpdateFieldMetadataResult
|
|
||||||
|
|
||||||
# Interface: UpdateFieldMetadataResult
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### version
|
|
||||||
|
|
||||||
```ts
|
|
||||||
version: number;
|
|
||||||
```
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
[@lancedb/lancedb](../globals.md) / WriteProgress
|
|
||||||
|
|
||||||
# Interface: WriteProgress
|
|
||||||
|
|
||||||
Progress snapshot for a write operation, delivered to the `progress`
|
|
||||||
callback passed to [Table.add](../classes/Table.md#add).
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
### activeTasks
|
|
||||||
|
|
||||||
```ts
|
|
||||||
activeTasks: number;
|
|
||||||
```
|
|
||||||
|
|
||||||
Number of parallel write tasks currently in flight.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### done
|
|
||||||
|
|
||||||
```ts
|
|
||||||
done: boolean;
|
|
||||||
```
|
|
||||||
|
|
||||||
`true` for the final callback; `false` otherwise.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### elapsedSeconds
|
|
||||||
|
|
||||||
```ts
|
|
||||||
elapsedSeconds: number;
|
|
||||||
```
|
|
||||||
|
|
||||||
Wall-clock seconds since the write started.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### outputBytes
|
|
||||||
|
|
||||||
```ts
|
|
||||||
outputBytes: number;
|
|
||||||
```
|
|
||||||
|
|
||||||
Number of bytes written so far.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### outputRows
|
|
||||||
|
|
||||||
```ts
|
|
||||||
outputRows: number;
|
|
||||||
```
|
|
||||||
|
|
||||||
Number of rows written so far.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### totalRows?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
optional totalRows: number;
|
|
||||||
```
|
|
||||||
|
|
||||||
Total rows expected, when the input source reports it.
|
|
||||||
|
|
||||||
Always set on the final callback (the one with `done: true`), falling
|
|
||||||
back to the actual number of rows written when the source could not
|
|
||||||
report a row count up front.
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
### totalTasks
|
|
||||||
|
|
||||||
```ts
|
|
||||||
totalTasks: number;
|
|
||||||
```
|
|
||||||
|
|
||||||
Total number of parallel write tasks (the write parallelism).
|
|
||||||
@@ -94,11 +94,11 @@ of raw SQL strings with [where][lancedb.query.LanceQueryBuilder.where] and
|
|||||||
|
|
||||||
## Full text search
|
## Full text search
|
||||||
|
|
||||||
Use [lancedb.table.Table.create_fts_index][] for the synchronous API or
|
::: lancedb.fts.create_index
|
||||||
[lancedb.table.AsyncTable.create_index][] with [lancedb.index.FTS][] for the
|
|
||||||
asynchronous API.
|
|
||||||
|
|
||||||
::: lancedb.index.FTS
|
::: lancedb.fts.populate_index
|
||||||
|
|
||||||
|
::: lancedb.fts.search_index
|
||||||
|
|
||||||
## Utilities
|
## Utilities
|
||||||
|
|
||||||
@@ -166,12 +166,6 @@ lists the indices that LanceDb supports.
|
|||||||
|
|
||||||
::: lancedb.index.IvfFlat
|
::: lancedb.index.IvfFlat
|
||||||
|
|
||||||
::: lancedb.index.IvfSq
|
|
||||||
|
|
||||||
::: lancedb.index.IvfRq
|
|
||||||
|
|
||||||
::: lancedb.index.HnswFlat
|
|
||||||
|
|
||||||
::: lancedb.table.IndexStatistics
|
::: lancedb.table.IndexStatistics
|
||||||
|
|
||||||
## Querying (Asynchronous)
|
## Querying (Asynchronous)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.lancedb</groupId>
|
<groupId>com.lancedb</groupId>
|
||||||
<artifactId>lancedb-parent</artifactId>
|
<artifactId>lancedb-parent</artifactId>
|
||||||
<version>0.30.1-beta.0</version>
|
<version>0.28.0-beta.1</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.lancedb</groupId>
|
<groupId>com.lancedb</groupId>
|
||||||
<artifactId>lancedb-parent</artifactId>
|
<artifactId>lancedb-parent</artifactId>
|
||||||
<version>0.30.1-beta.0</version>
|
<version>0.28.0-beta.1</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>${project.artifactId}</name>
|
<name>${project.artifactId}</name>
|
||||||
<description>LanceDB Java SDK Parent POM</description>
|
<description>LanceDB Java SDK Parent POM</description>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<arrow.version>15.0.0</arrow.version>
|
<arrow.version>15.0.0</arrow.version>
|
||||||
<lance-core.version>7.2.0-beta.1</lance-core.version>
|
<lance-core.version>5.1.0-beta.1</lance-core.version>
|
||||||
<spotless.skip>false</spotless.skip>
|
<spotless.skip>false</spotless.skip>
|
||||||
<spotless.version>2.30.0</spotless.version>
|
<spotless.version>2.30.0</spotless.version>
|
||||||
<spotless.java.googlejavaformat.version>1.7</spotless.java.googlejavaformat.version>
|
<spotless.java.googlejavaformat.version>1.7</spotless.java.googlejavaformat.version>
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ The core Rust library is in the `../rust/lancedb` directory, the rust binding
|
|||||||
code is in the `src/` directory and the typescript bindings are in
|
code is in the `src/` directory and the typescript bindings are in
|
||||||
the `lancedb/` directory.
|
the `lancedb/` directory.
|
||||||
|
|
||||||
Whenever you change the Rust code, you will need to recompile: `pnpm build`.
|
Whenever you change the Rust code, you will need to recompile: `npm run build`.
|
||||||
|
|
||||||
Common commands:
|
Common commands:
|
||||||
* Build: `pnpm build`
|
* Build: `npm run build`
|
||||||
* Lint: `pnpm lint`
|
* Lint: `npm run lint`
|
||||||
* Fix lints: `pnpm lint-fix`
|
* Fix lints: `npm run lint-fix`
|
||||||
* Test: `pnpm test`
|
* Test: `npm test`
|
||||||
* Run single test file: `pnpm test __test__/arrow.test.ts`
|
* Run single test file: `npm test __test__/arrow.test.ts`
|
||||||
|
|||||||
@@ -12,22 +12,20 @@ Typescript.
|
|||||||
* `src/`: Rust bindings source code
|
* `src/`: Rust bindings source code
|
||||||
* `lancedb/`: Typescript package source code
|
* `lancedb/`: Typescript package source code
|
||||||
* `__test__/`: Unit tests
|
* `__test__/`: Unit tests
|
||||||
* `examples/`: A pnpm package with the examples shown in the documentation
|
* `examples/`: An npm package with the examples shown in the documentation
|
||||||
|
|
||||||
## Development environment
|
## Development environment
|
||||||
|
|
||||||
To set up your development environment, you will need to install the following:
|
To set up your development environment, you will need to install the following:
|
||||||
|
|
||||||
1. Node.js 22 or later (required by pnpm 11)
|
1. Node.js 14 or later
|
||||||
2. [pnpm](https://pnpm.io/installation) 11 or later (or run via `corepack enable`,
|
2. Rust's package manager, Cargo. Use [rustup](https://rustup.rs/) to install.
|
||||||
which uses the `packageManager` field in `package.json`)
|
3. [protoc](https://grpc.io/docs/protoc-installation/) (Protocol Buffers compiler)
|
||||||
3. Rust's package manager, Cargo. Use [rustup](https://rustup.rs/) to install.
|
|
||||||
4. [protoc](https://grpc.io/docs/protoc-installation/) (Protocol Buffers compiler)
|
|
||||||
|
|
||||||
Initial setup:
|
Initial setup:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pnpm install
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
### Commit Hooks
|
### Commit Hooks
|
||||||
@@ -41,38 +39,38 @@ pre-commit install
|
|||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
Most common development commands can be run using the pnpm scripts.
|
Most common development commands can be run using the npm scripts.
|
||||||
|
|
||||||
Build the package
|
Build the package
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pnpm install
|
npm install
|
||||||
pnpm build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
Lint:
|
Lint:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pnpm lint
|
npm run lint
|
||||||
```
|
```
|
||||||
|
|
||||||
Format and fix lints:
|
Format and fix lints:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pnpm lint-fix
|
npm run lint-fix
|
||||||
```
|
```
|
||||||
|
|
||||||
Run tests:
|
Run tests:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pnpm test
|
npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
To run a single test:
|
To run a single test:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Single file: table.test.ts
|
# Single file: table.test.ts
|
||||||
pnpm test -- table.test.ts
|
npm test -- table.test.ts
|
||||||
# Single test: 'merge insert' in table.test.ts
|
# Single test: 'merge insert' in table.test.ts
|
||||||
pnpm test -- table.test.ts --testNamePattern=merge\ insert
|
npm test -- table.test.ts --testNamePattern=merge\ insert
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "lancedb-nodejs"
|
name = "lancedb-nodejs"
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
version = "0.30.1-beta.0"
|
version = "0.28.0-beta.1"
|
||||||
publish = false
|
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
@@ -16,13 +15,12 @@ crate-type = ["cdylib"]
|
|||||||
async-trait.workspace = true
|
async-trait.workspace = true
|
||||||
arrow-ipc.workspace = true
|
arrow-ipc.workspace = true
|
||||||
arrow-array.workspace = true
|
arrow-array.workspace = true
|
||||||
arrow-buffer = "58.0.0"
|
arrow-buffer = "57.2"
|
||||||
half.workspace = true
|
half.workspace = true
|
||||||
arrow-schema.workspace = true
|
arrow-schema.workspace = true
|
||||||
env_logger.workspace = true
|
env_logger.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
lancedb = { path = "../rust/lancedb", default-features = false }
|
lancedb = { path = "../rust/lancedb", default-features = false }
|
||||||
lance-namespace.workspace = true
|
|
||||||
napi = { version = "3.8.3", default-features = false, features = [
|
napi = { version = "3.8.3", default-features = false, features = [
|
||||||
"napi9",
|
"napi9",
|
||||||
"async"
|
"async"
|
||||||
@@ -33,8 +31,8 @@ lzma-sys = { version = "0.1", features = ["static"] }
|
|||||||
log.workspace = true
|
log.workspace = true
|
||||||
|
|
||||||
# Pin to resolve build failures; update periodically for security patches.
|
# Pin to resolve build failures; update periodically for security patches.
|
||||||
aws-lc-sys = "=0.40.0"
|
aws-lc-sys = "=0.38.0"
|
||||||
aws-lc-rs = "=1.16.3"
|
aws-lc-rs = "=1.16.1"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
napi-build = "2.3.1"
|
napi-build = "2.3.1"
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const results = await table.vectorSearch([0.1, 0.3]).limit(20).toArray();
|
|||||||
console.log(results);
|
console.log(results);
|
||||||
```
|
```
|
||||||
|
|
||||||
The [quickstart](https://docs.lancedb.com/quickstart/) contains more complete examples.
|
The [quickstart](https://lancedb.com/docs/quickstart/basic-usage/) contains more complete examples.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import { readdirSync } from "fs";
|
import { readdirSync } from "fs";
|
||||||
import { Field, Float64, Schema } from "apache-arrow";
|
import { Field, Float64, Schema } from "apache-arrow";
|
||||||
import * as tmp from "tmp";
|
import * as tmp from "tmp";
|
||||||
import { Connection, Table, connect, connectNamespace } from "../lancedb";
|
import { Connection, Table, connect } from "../lancedb";
|
||||||
import { LocalTable } from "../lancedb/table";
|
import { LocalTable } from "../lancedb/table";
|
||||||
|
|
||||||
describe("when connecting", () => {
|
describe("when connecting", () => {
|
||||||
@@ -47,14 +47,6 @@ describe("given a connection", () => {
|
|||||||
await db.close();
|
await db.close();
|
||||||
expect(db.isOpen()).toBe(false);
|
expect(db.isOpen()).toBe(false);
|
||||||
await expect(db.tableNames()).rejects.toThrow("Connection is closed");
|
await expect(db.tableNames()).rejects.toThrow("Connection is closed");
|
||||||
await expect(db.renameTable("a", "b")).rejects.toThrow(
|
|
||||||
"Connection is closed",
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should report renameTable as unsupported on an OSS connection", async () => {
|
|
||||||
await db.createTable("a", [{ id: 1 }]);
|
|
||||||
await expect(db.renameTable("a", "b")).rejects.toThrow(/not supported/);
|
|
||||||
});
|
});
|
||||||
it("should be able to create a table from an object arg `createTable(options)`, or args `createTable(name, data, options)`", async () => {
|
it("should be able to create a table from an object arg `createTable(options)`, or args `createTable(name, data, options)`", async () => {
|
||||||
let tbl = await db.createTable("test", [{ id: 1 }, { id: 2 }]);
|
let tbl = await db.createTable("test", [{ id: 1 }, { id: 2 }]);
|
||||||
@@ -171,22 +163,18 @@ describe("given a connection", () => {
|
|||||||
|
|
||||||
let manifestDir =
|
let manifestDir =
|
||||||
tmpDir.name + "/test_manifest_paths_v2_empty.lance/_versions";
|
tmpDir.name + "/test_manifest_paths_v2_empty.lance/_versions";
|
||||||
readdirSync(manifestDir)
|
readdirSync(manifestDir).forEach((file) => {
|
||||||
.filter((f) => f.endsWith(".manifest"))
|
expect(file).toMatch(/^\d{20}\.manifest$/);
|
||||||
.forEach((file) => {
|
});
|
||||||
expect(file).toMatch(/^\d{20}\.manifest$/);
|
|
||||||
});
|
|
||||||
|
|
||||||
table = (await db.createTable("test_manifest_paths_v2", [{ id: 1 }], {
|
table = (await db.createTable("test_manifest_paths_v2", [{ id: 1 }], {
|
||||||
enableV2ManifestPaths: true,
|
enableV2ManifestPaths: true,
|
||||||
})) as LocalTable;
|
})) as LocalTable;
|
||||||
expect(await table.usesV2ManifestPaths()).toBe(true);
|
expect(await table.usesV2ManifestPaths()).toBe(true);
|
||||||
manifestDir = tmpDir.name + "/test_manifest_paths_v2.lance/_versions";
|
manifestDir = tmpDir.name + "/test_manifest_paths_v2.lance/_versions";
|
||||||
readdirSync(manifestDir)
|
readdirSync(manifestDir).forEach((file) => {
|
||||||
.filter((f) => f.endsWith(".manifest"))
|
expect(file).toMatch(/^\d{20}\.manifest$/);
|
||||||
.forEach((file) => {
|
});
|
||||||
expect(file).toMatch(/^\d{20}\.manifest$/);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to migrate tables to the V2 manifest paths", async () => {
|
it("should be able to migrate tables to the V2 manifest paths", async () => {
|
||||||
@@ -203,20 +191,16 @@ describe("given a connection", () => {
|
|||||||
|
|
||||||
const manifestDir =
|
const manifestDir =
|
||||||
tmpDir.name + "/test_manifest_path_migration.lance/_versions";
|
tmpDir.name + "/test_manifest_path_migration.lance/_versions";
|
||||||
readdirSync(manifestDir)
|
readdirSync(manifestDir).forEach((file) => {
|
||||||
.filter((f) => f.endsWith(".manifest"))
|
expect(file).toMatch(/^\d\.manifest$/);
|
||||||
.forEach((file) => {
|
});
|
||||||
expect(file).toMatch(/^\d\.manifest$/);
|
|
||||||
});
|
|
||||||
|
|
||||||
await table.migrateManifestPathsV2();
|
await table.migrateManifestPathsV2();
|
||||||
expect(await table.usesV2ManifestPaths()).toBe(true);
|
expect(await table.usesV2ManifestPaths()).toBe(true);
|
||||||
|
|
||||||
readdirSync(manifestDir)
|
readdirSync(manifestDir).forEach((file) => {
|
||||||
.filter((f) => f.endsWith(".manifest"))
|
expect(file).toMatch(/^\d{20}\.manifest$/);
|
||||||
.forEach((file) => {
|
});
|
||||||
expect(file).toMatch(/^\d{20}\.manifest$/);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -322,186 +306,3 @@ describe("clone table functionality", () => {
|
|||||||
).rejects.toThrow("Deep clone is not yet implemented");
|
).rejects.toThrow("Deep clone is not yet implemented");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("namespaces", () => {
|
|
||||||
let tmpDir: tmp.DirResult;
|
|
||||||
let db: Connection;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
tmpDir = tmp.dirSync({ unsafeCleanup: true });
|
|
||||||
// The local DirectoryNamespace backend only supports child namespaces
|
|
||||||
// when manifest mode is enabled (see lance-namespace-impls/src/dir.rs).
|
|
||||||
db = await connect(tmpDir.name, {
|
|
||||||
// biome-ignore lint/style/useNamingConvention: opaque backend property key, must match Rust
|
|
||||||
namespaceClientProperties: { manifest_enabled: "true" },
|
|
||||||
});
|
|
||||||
});
|
|
||||||
afterEach(() => tmpDir.removeCallback());
|
|
||||||
|
|
||||||
it("should create and describe a namespace", async () => {
|
|
||||||
await db.createNamespace(["myns"]);
|
|
||||||
const desc = await db.describeNamespace(["myns"]);
|
|
||||||
expect(desc).toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should list namespaces created at the root", async () => {
|
|
||||||
await db.createNamespace(["alpha"]);
|
|
||||||
await db.createNamespace(["beta"]);
|
|
||||||
const list = await db.listNamespaces();
|
|
||||||
expect(list.namespaces).toEqual(expect.arrayContaining(["alpha", "beta"]));
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should list child namespaces under a parent", async () => {
|
|
||||||
await db.createNamespace(["parent"]);
|
|
||||||
await db.createNamespace(["parent", "child"]);
|
|
||||||
const list = await db.listNamespaces(["parent"]);
|
|
||||||
expect(list.namespaces).toContain("child");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should drop a namespace", async () => {
|
|
||||||
await db.createNamespace(["ephemeral"]);
|
|
||||||
await db.dropNamespace(["ephemeral"]);
|
|
||||||
const list = await db.listNamespaces();
|
|
||||||
expect(list.namespaces).not.toContain("ephemeral");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should raise an error on any namespace op after close", async () => {
|
|
||||||
await db.close();
|
|
||||||
await expect(db.describeNamespace(["foo"])).rejects.toThrow(
|
|
||||||
"Connection is closed",
|
|
||||||
);
|
|
||||||
await expect(db.listNamespaces()).rejects.toThrow("Connection is closed");
|
|
||||||
await expect(db.createNamespace(["foo"])).rejects.toThrow(
|
|
||||||
"Connection is closed",
|
|
||||||
);
|
|
||||||
await expect(db.dropNamespace(["foo"])).rejects.toThrow(
|
|
||||||
"Connection is closed",
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should raise an understandable error when describing a non-existent namespace", async () => {
|
|
||||||
await expect(db.describeNamespace(["does-not-exist"])).rejects.toThrow(
|
|
||||||
/not found/i,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should raise an error when creating a namespace that already exists", async () => {
|
|
||||||
await db.createNamespace(["dup"]);
|
|
||||||
await expect(db.createNamespace(["dup"])).rejects.toThrow();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should reject an unrecognized createNamespace mode with a clear error", async () => {
|
|
||||||
await expect(
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: deliberately bypass TS to test runtime validation
|
|
||||||
db.createNamespace(["x"], { mode: "frobnicate" as any }),
|
|
||||||
).rejects.toThrow(/Invalid mode 'frobnicate'/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should reject an unrecognized dropNamespace mode with a clear error", async () => {
|
|
||||||
await db.createNamespace(["x"]);
|
|
||||||
await expect(
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: deliberately bypass TS to test runtime validation
|
|
||||||
db.dropNamespace(["x"], { mode: "frobnicate" as any }),
|
|
||||||
).rejects.toThrow(/Invalid mode 'frobnicate'/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should reject an unrecognized dropNamespace behavior with a clear error", async () => {
|
|
||||||
await db.createNamespace(["x"]);
|
|
||||||
await expect(
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: deliberately bypass TS to test runtime validation
|
|
||||||
db.dropNamespace(["x"], { behavior: "frobnicate" as any }),
|
|
||||||
).rejects.toThrow(/Invalid behavior 'frobnicate'/);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("connectNamespace", () => {
|
|
||||||
let tmpDir: tmp.DirResult;
|
|
||||||
beforeEach(() => {
|
|
||||||
tmpDir = tmp.dirSync({ unsafeCleanup: true });
|
|
||||||
});
|
|
||||||
afterEach(() => tmpDir.removeCallback());
|
|
||||||
|
|
||||||
it("connects via the dir implementation and supports table ops", async () => {
|
|
||||||
const db = await connectNamespace("dir", { root: tmpDir.name });
|
|
||||||
await db.createTable("users", [{ id: 1 }, { id: 2 }]);
|
|
||||||
await expect(db.tableNames()).resolves.toContain("users");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("throws a clear error when implName is empty", async () => {
|
|
||||||
await expect(connectNamespace("", {})).rejects.toThrow(
|
|
||||||
"implName must be a non-empty string",
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("throws when the namespace implementation is unknown", async () => {
|
|
||||||
await expect(connectNamespace("not-a-real-impl", {})).rejects.toThrow();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("passes storage options through to the namespace", async () => {
|
|
||||||
const db = await connectNamespace(
|
|
||||||
"dir",
|
|
||||||
{ root: tmpDir.name },
|
|
||||||
{ storageOptions: { newTableDataStorageVersion: "stable" } },
|
|
||||||
);
|
|
||||||
await db.createTable("plumbing", [{ id: 1 }]);
|
|
||||||
await expect(db.tableNames()).resolves.toContain("plumbing");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("supports child namespaces when manifestEnabled is true on the dir config", async () => {
|
|
||||||
const writer = await connectNamespace("dir", {
|
|
||||||
root: tmpDir.name,
|
|
||||||
manifestEnabled: true,
|
|
||||||
});
|
|
||||||
await writer.createNamespace(["analytics"]);
|
|
||||||
await writer.createTable("orders", [{ id: 1 }, { id: 2 }], ["analytics"]);
|
|
||||||
await writer.close();
|
|
||||||
|
|
||||||
const reader = await connectNamespace("dir", {
|
|
||||||
root: tmpDir.name,
|
|
||||||
manifestEnabled: true,
|
|
||||||
});
|
|
||||||
await expect(reader.tableNames(["analytics"])).resolves.toContain("orders");
|
|
||||||
const orders = await reader.openTable("orders", ["analytics"]);
|
|
||||||
await expect(orders.countRows()).resolves.toBe(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("merges extraProperties into the dir config and is overridden by typed fields", async () => {
|
|
||||||
// Two observable assertions:
|
|
||||||
// - Typed `root` overrides extraProperties.root: createTable would fail
|
|
||||||
// under the bogus path if the override didn't happen.
|
|
||||||
// - extraProperties.manifest_enabled="false" is honored end-to-end. Child
|
|
||||||
// namespaces require manifest mode (default true), so explicitly
|
|
||||||
// disabling it via extraProperties must make createNamespace reject. If
|
|
||||||
// extraProperties pass-through were silently broken, the default would
|
|
||||||
// let createNamespace succeed.
|
|
||||||
const db = await connectNamespace("dir", {
|
|
||||||
root: tmpDir.name,
|
|
||||||
extraProperties: {
|
|
||||||
root: "/should/be/overridden",
|
|
||||||
// biome-ignore lint/style/useNamingConvention: backend property key
|
|
||||||
manifest_enabled: "false",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
await db.createTable("base", [{ id: 1 }]);
|
|
||||||
await expect(db.tableNames()).resolves.toContain("base");
|
|
||||||
await expect(db.createNamespace(["analytics"])).rejects.toThrow();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("flows unknown top-level keys through when implName is dynamic (no silent drop)", async () => {
|
|
||||||
// Routes via the third overload because `impl` is `string`, not the
|
|
||||||
// literal `"dir"`. The dispatcher still notices the runtime value is
|
|
||||||
// "dir", but unknown keys like `manifest_enabled` must not be silently
|
|
||||||
// dropped during the conversion.
|
|
||||||
//
|
|
||||||
// Asserting a *negative* outcome (manifest disabled -> createNamespace
|
|
||||||
// rejects) is required for observability, since the backend default for
|
|
||||||
// `manifest_enabled` is true.
|
|
||||||
const impl: string = "dir";
|
|
||||||
const db = await connectNamespace(impl, {
|
|
||||||
root: tmpDir.name,
|
|
||||||
// biome-ignore lint/style/useNamingConvention: backend property key
|
|
||||||
manifest_enabled: "false",
|
|
||||||
});
|
|
||||||
await expect(db.createNamespace(["mixed"])).rejects.toThrow();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -109,209 +109,3 @@ describe("Query outputSchema", () => {
|
|||||||
expect(schema.fields.length).toBe(3);
|
expect(schema.fields.length).toBe(3);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Query orderBy", () => {
|
|
||||||
let tmpDir: tmp.DirResult;
|
|
||||||
let table: Table;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
tmpDir = tmp.dirSync({ unsafeCleanup: true });
|
|
||||||
const db = await connect(tmpDir.name);
|
|
||||||
|
|
||||||
// Create table with numeric data for sorting
|
|
||||||
const schema = new Schema([
|
|
||||||
new Field("id", new Int64(), true),
|
|
||||||
new Field("score", new Float32(), true),
|
|
||||||
new Field("name", new Utf8(), true),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const data = makeArrowTable(
|
|
||||||
[
|
|
||||||
{ id: 1n, score: 3.5, name: "charlie" },
|
|
||||||
{ id: 2n, score: 1.2, name: "alice" },
|
|
||||||
{ id: 3n, score: 2.8, name: "bob" },
|
|
||||||
{ id: 4n, score: 0.5, name: "david" },
|
|
||||||
{ id: 5n, score: 4.1, name: "eve" },
|
|
||||||
],
|
|
||||||
{ schema },
|
|
||||||
);
|
|
||||||
table = await db.createTable("test", data);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
tmpDir.removeCallback();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should sort by single column ascending", async () => {
|
|
||||||
const results = await table
|
|
||||||
.query()
|
|
||||||
.orderBy({ columnName: "score", ascending: true, nullsFirst: false })
|
|
||||||
.toArray();
|
|
||||||
|
|
||||||
expect(results.length).toBe(5);
|
|
||||||
// Verify ascending order
|
|
||||||
expect(results[0].score).toBeCloseTo(0.5, 0.001);
|
|
||||||
expect(results[1].score).toBeCloseTo(1.2, 0.001);
|
|
||||||
expect(results[2].score).toBeCloseTo(2.8, 0.001);
|
|
||||||
expect(results[3].score).toBeCloseTo(3.5, 0.001);
|
|
||||||
expect(results[4].score).toBeCloseTo(4.1, 0.001);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should sort by single column descending", async () => {
|
|
||||||
const results = await table
|
|
||||||
.query()
|
|
||||||
.orderBy({ columnName: "score", ascending: false, nullsFirst: false })
|
|
||||||
.toArray();
|
|
||||||
|
|
||||||
expect(results.length).toBe(5);
|
|
||||||
// Verify descending order
|
|
||||||
expect(results[0].score).toBeCloseTo(4.1, 0.001);
|
|
||||||
expect(results[1].score).toBeCloseTo(3.5, 0.001);
|
|
||||||
expect(results[2].score).toBeCloseTo(2.8, 0.001);
|
|
||||||
expect(results[3].score).toBeCloseTo(1.2, 0.001);
|
|
||||||
expect(results[4].score).toBeCloseTo(0.5, 0.001);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should use ascending as default direction", async () => {
|
|
||||||
const results = await table
|
|
||||||
.query()
|
|
||||||
.orderBy({ columnName: "score" })
|
|
||||||
.toArray();
|
|
||||||
|
|
||||||
expect(results.length).toBe(5);
|
|
||||||
// Verify ascending order (default)
|
|
||||||
expect(results[0].score).toBeCloseTo(0.5, 0.001);
|
|
||||||
expect(results[1].score).toBeCloseTo(1.2, 0.001);
|
|
||||||
expect(results[2].score).toBeCloseTo(2.8, 0.001);
|
|
||||||
expect(results[3].score).toBeCloseTo(3.5, 0.001);
|
|
||||||
expect(results[4].score).toBeCloseTo(4.1, 0.001);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should sort by string column", async () => {
|
|
||||||
const results = await table
|
|
||||||
.query()
|
|
||||||
.orderBy({ columnName: "name" })
|
|
||||||
.toArray();
|
|
||||||
|
|
||||||
expect(results.length).toBe(5);
|
|
||||||
// Verify alphabetical order
|
|
||||||
expect(results[0].name).toBe("alice");
|
|
||||||
expect(results[1].name).toBe("bob");
|
|
||||||
expect(results[2].name).toBe("charlie");
|
|
||||||
expect(results[3].name).toBe("david");
|
|
||||||
expect(results[4].name).toBe("eve");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should support method chaining with where", async () => {
|
|
||||||
const results = await table
|
|
||||||
.query()
|
|
||||||
.where("score > 2.0")
|
|
||||||
.orderBy({ columnName: "score" })
|
|
||||||
.toArray();
|
|
||||||
expect(results.length).toBe(3);
|
|
||||||
// Verify filtered and sorted
|
|
||||||
expect(results[0].score).toBeCloseTo(2.8, 0.001);
|
|
||||||
expect(results[1].score).toBeCloseTo(3.5, 0.001);
|
|
||||||
expect(results[2].score).toBeCloseTo(4.1, 0.001);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should support method chaining with limit", async () => {
|
|
||||||
const results = await table
|
|
||||||
.query()
|
|
||||||
.orderBy({ columnName: "score", ascending: false })
|
|
||||||
.limit(3)
|
|
||||||
.toArray();
|
|
||||||
|
|
||||||
expect(results.length).toBe(3);
|
|
||||||
// Verify top 3 in descending order
|
|
||||||
expect(results[0].score).toBeCloseTo(4.1, 0.001);
|
|
||||||
expect(results[1].score).toBeCloseTo(3.5, 0.001);
|
|
||||||
expect(results[2].score).toBeCloseTo(2.8, 0.001);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should support method chaining with offset", async () => {
|
|
||||||
const results = await table
|
|
||||||
.query()
|
|
||||||
.orderBy({ columnName: "score" })
|
|
||||||
.offset(2)
|
|
||||||
.limit(2)
|
|
||||||
.toArray();
|
|
||||||
|
|
||||||
expect(results.length).toBe(2);
|
|
||||||
// Verify results skip first 2 and take next 2
|
|
||||||
expect(results[0].score).toBeCloseTo(2.8, 0.001);
|
|
||||||
expect(results[1].score).toBeCloseTo(3.5, 0.001);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should support method chaining with select", async () => {
|
|
||||||
const results = await table
|
|
||||||
.query()
|
|
||||||
.orderBy({ columnName: "name" })
|
|
||||||
.select(["name", "score"])
|
|
||||||
.toArray();
|
|
||||||
|
|
||||||
expect(results.length).toBe(5);
|
|
||||||
// Verify only selected columns are present
|
|
||||||
expect(Object.keys(results[0])).toEqual(["name", "score"]);
|
|
||||||
expect(Object.keys(results[4])).toEqual(["name", "score"]);
|
|
||||||
// Verify sorted by name
|
|
||||||
expect(results[0].name).toBe("alice");
|
|
||||||
expect(results[4].name).toBe("eve");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should support complex method chaining", async () => {
|
|
||||||
const results = await table
|
|
||||||
.query()
|
|
||||||
.where("score > 1.0")
|
|
||||||
.orderBy({ columnName: "score", ascending: false })
|
|
||||||
.limit(3)
|
|
||||||
.select(["id", "score", "name"])
|
|
||||||
.toArray();
|
|
||||||
|
|
||||||
expect(results.length).toBe(3);
|
|
||||||
// Verify filtered, sorted, limited, and projected
|
|
||||||
expect(results[0].score).toBeCloseTo(4.1, 0.001);
|
|
||||||
expect(results[1].score).toBeCloseTo(3.5, 0.001);
|
|
||||||
expect(results[2].score).toBeCloseTo(2.8, 0.001);
|
|
||||||
expect(Object.keys(results[0])).toEqual(["id", "score", "name"]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should support multi-column ordering and null placement", async () => {
|
|
||||||
const schema = new Schema([
|
|
||||||
new Field("group", new Int64(), true),
|
|
||||||
new Field("score", new Float32(), true),
|
|
||||||
new Field("name", new Utf8(), true),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const data = makeArrowTable(
|
|
||||||
[
|
|
||||||
{ group: 1n, score: null, name: "z" },
|
|
||||||
{ group: 1n, score: 1.0, name: "b" },
|
|
||||||
{ group: 1n, score: 1.0, name: "a" },
|
|
||||||
{ group: 2n, score: 0.5, name: "c" },
|
|
||||||
],
|
|
||||||
{ schema },
|
|
||||||
);
|
|
||||||
const nullTable = await (await connect(tmpDir.name)).createTable(
|
|
||||||
"test_multi_order",
|
|
||||||
data,
|
|
||||||
{ mode: "overwrite" },
|
|
||||||
);
|
|
||||||
|
|
||||||
const results = await nullTable
|
|
||||||
.query()
|
|
||||||
.orderBy([
|
|
||||||
{ columnName: "group", ascending: true, nullsFirst: false },
|
|
||||||
{ columnName: "score", ascending: true, nullsFirst: true },
|
|
||||||
{ columnName: "name", ascending: true, nullsFirst: false },
|
|
||||||
])
|
|
||||||
.toArray();
|
|
||||||
|
|
||||||
expect(results.map((r) => [r.group, r.score, r.name])).toEqual([
|
|
||||||
[1n, null, "z"],
|
|
||||||
[1n, 1.0, "a"],
|
|
||||||
[1n, 1.0, "b"],
|
|
||||||
[2n, 0.5, "c"],
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -617,68 +617,4 @@ describe("remote connection", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("renameTable", () => {
|
|
||||||
async function captureRenameRequest(
|
|
||||||
call: (db: Connection) => Promise<void>,
|
|
||||||
): Promise<{ url: string; body: Record<string, unknown> }> {
|
|
||||||
let captured: { url: string; body: Record<string, unknown> } | undefined;
|
|
||||||
await withMockDatabase((req, res) => {
|
|
||||||
let raw = "";
|
|
||||||
req.on("data", (chunk) => {
|
|
||||||
raw += chunk;
|
|
||||||
});
|
|
||||||
req.on("end", () => {
|
|
||||||
captured = {
|
|
||||||
url: req.url ?? "",
|
|
||||||
body: raw ? JSON.parse(raw) : {},
|
|
||||||
};
|
|
||||||
res.writeHead(200, { "Content-Type": "application/json" }).end("");
|
|
||||||
});
|
|
||||||
}, call);
|
|
||||||
if (!captured) {
|
|
||||||
throw new Error("mock server never saw a request");
|
|
||||||
}
|
|
||||||
return captured;
|
|
||||||
}
|
|
||||||
|
|
||||||
it("sends rename request for a table in the root namespace", async () => {
|
|
||||||
const { url, body } = await captureRenameRequest(async (db) => {
|
|
||||||
await db.renameTable("table1", "table2");
|
|
||||||
});
|
|
||||||
expect(url).toBe("/v1/table/table1/rename/");
|
|
||||||
// biome-ignore lint/style/useNamingConvention: snake_case mandated by the server wire format
|
|
||||||
expect(body).toEqual({ new_table_name: "table2" });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("omits new_namespace when only the current namespace is supplied", async () => {
|
|
||||||
// Safe-default check: passing namespacePath alone must not send
|
|
||||||
// `new_namespace`, so the server keeps the table in its current
|
|
||||||
// namespace instead of silently moving it to root.
|
|
||||||
const { url, body } = await captureRenameRequest(async (db) => {
|
|
||||||
await db.renameTable("table1", "table2", {
|
|
||||||
namespacePath: ["ns1"],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
expect(url).toBe("/v1/table/ns1$table1/rename/");
|
|
||||||
// biome-ignore lint/style/useNamingConvention: snake_case mandated by the server wire format
|
|
||||||
expect(body).toEqual({ new_table_name: "table2" });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("includes new_namespace in the body for a cross-namespace rename", async () => {
|
|
||||||
const { url, body } = await captureRenameRequest(async (db) => {
|
|
||||||
await db.renameTable("table1", "table2", {
|
|
||||||
namespacePath: ["ns1"],
|
|
||||||
newNamespacePath: ["ns2"],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
expect(url).toBe("/v1/table/ns1$table1/rename/");
|
|
||||||
expect(body).toEqual({
|
|
||||||
// biome-ignore lint/style/useNamingConvention: snake_case mandated by the server wire format
|
|
||||||
new_table_name: "table2",
|
|
||||||
// biome-ignore lint/style/useNamingConvention: snake_case mandated by the server wire format
|
|
||||||
new_namespace: ["ns2"],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
||||||
|
|
||||||
import { spawn } from "node:child_process";
|
|
||||||
import * as path from "node:path";
|
|
||||||
import { RecordBatch } from "apache-arrow";
|
import { RecordBatch } from "apache-arrow";
|
||||||
import * as tmp from "tmp";
|
import * as tmp from "tmp";
|
||||||
import { Connection, Index, Table, connect, makeArrowTable } from "../lancedb";
|
import { Connection, Index, Table, connect, makeArrowTable } from "../lancedb";
|
||||||
@@ -78,91 +76,4 @@ describe("rerankers", function () {
|
|||||||
|
|
||||||
expect(result).toHaveLength(2);
|
expect(result).toHaveLength(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not keep process alive after rerank query", async function () {
|
|
||||||
const script = `
|
|
||||||
import * as lancedb from "./dist/index.js";
|
|
||||||
import * as os from "node:os";
|
|
||||||
import * as path from "node:path";
|
|
||||||
import * as fs from "node:fs/promises";
|
|
||||||
|
|
||||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "lancedb-rerank-exit-"));
|
|
||||||
const db = await lancedb.connect(dir);
|
|
||||||
const table = await db.createTable("test", [{ text: "hello", vector: [1, 2, 3] }], {
|
|
||||||
mode: "overwrite",
|
|
||||||
});
|
|
||||||
await table.createIndex("text", { config: lancedb.Index.fts() });
|
|
||||||
await table.waitForIndex(["text_idx"], 30);
|
|
||||||
|
|
||||||
const reranker = await lancedb.rerankers.RRFReranker.create();
|
|
||||||
await table
|
|
||||||
.query()
|
|
||||||
.nearestTo([1, 2, 3])
|
|
||||||
.fullTextSearch("hello")
|
|
||||||
.rerank(reranker)
|
|
||||||
.toArray();
|
|
||||||
|
|
||||||
table.close();
|
|
||||||
db.close();
|
|
||||||
`;
|
|
||||||
|
|
||||||
await new Promise<void>((resolve, reject) => {
|
|
||||||
const child = spawn(
|
|
||||||
process.execPath,
|
|
||||||
["--input-type=module", "-e", script],
|
|
||||||
{
|
|
||||||
cwd: path.resolve(__dirname, ".."),
|
|
||||||
stdio: ["ignore", "pipe", "pipe"],
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
let stdout = "";
|
|
||||||
let stderr = "";
|
|
||||||
|
|
||||||
child.stdout.on("data", (chunk) => {
|
|
||||||
stdout += chunk.toString();
|
|
||||||
});
|
|
||||||
|
|
||||||
child.stderr.on("data", (chunk) => {
|
|
||||||
stderr += chunk.toString();
|
|
||||||
});
|
|
||||||
|
|
||||||
const timeout = setTimeout(() => {
|
|
||||||
child.kill();
|
|
||||||
reject(
|
|
||||||
new Error(
|
|
||||||
`child process did not exit in time\nstdout:\n${stdout}\nstderr:\n${stderr}`,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}, 20_000);
|
|
||||||
|
|
||||||
child.on("error", (err) => {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
|
|
||||||
child.on("exit", (code, signal) => {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
if (signal !== null) {
|
|
||||||
reject(
|
|
||||||
new Error(
|
|
||||||
`child process exited with signal ${signal}\nstdout:\n${stdout}\nstderr:\n${stderr}`,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (code !== 0) {
|
|
||||||
reject(
|
|
||||||
new Error(
|
|
||||||
`child process exited with code ${code}\nstdout:\n${stdout}\nstderr:\n${stderr}`,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,438 +0,0 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
||||||
|
|
||||||
import {
|
|
||||||
Field,
|
|
||||||
Float16,
|
|
||||||
Int32,
|
|
||||||
type RecordBatch,
|
|
||||||
RecordBatchReader,
|
|
||||||
Schema,
|
|
||||||
tableToIPC,
|
|
||||||
} from "apache-arrow";
|
|
||||||
import { makeArrowTable, makeEmptyTable } from "../lancedb/arrow";
|
|
||||||
import { Scannable } from "../lancedb/scannable";
|
|
||||||
|
|
||||||
function makeTable() {
|
|
||||||
return makeArrowTable(
|
|
||||||
[
|
|
||||||
{ id: 1, name: "a" },
|
|
||||||
{ id: 2, name: "b" },
|
|
||||||
{ id: 3, name: "c" },
|
|
||||||
],
|
|
||||||
{ vectorColumns: {} },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function makeReader(): Promise<RecordBatchReader> {
|
|
||||||
// `RecordBatchReader.from()` returns an unopened reader; `.schema` is only
|
|
||||||
// populated after `.open()`. Opening sync readers is synchronous.
|
|
||||||
const reader = RecordBatchReader.from(tableToIPC(makeTable()));
|
|
||||||
return reader.open() as RecordBatchReader;
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("Scannable", () => {
|
|
||||||
describe("fromTable", () => {
|
|
||||||
test("reflects schema, numRows, and defaults rescannable=true", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
const scannable = await Scannable.fromTable(table);
|
|
||||||
|
|
||||||
expect(scannable.schema).toBe(table.schema);
|
|
||||||
expect(scannable.numRows).toBe(table.numRows);
|
|
||||||
expect(scannable.rescannable).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("throws when opts.numRows does not match table.numRows", async () => {
|
|
||||||
await expect(
|
|
||||||
Scannable.fromTable(makeTable(), { numRows: 42 }),
|
|
||||||
).rejects.toThrow(/does not match table\.numRows/);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("throws when opts.rescannable is false", async () => {
|
|
||||||
await expect(
|
|
||||||
Scannable.fromTable(makeTable(), { rescannable: false }),
|
|
||||||
).rejects.toThrow(/always rescannable/);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("fromRecordBatchReader", () => {
|
|
||||||
test("reflects schema and defaults numRows=null, rescannable=false", async () => {
|
|
||||||
const reader = await makeReader();
|
|
||||||
const scannable = await Scannable.fromRecordBatchReader(reader);
|
|
||||||
|
|
||||||
expect(scannable.schema).toBe(reader.schema);
|
|
||||||
expect(scannable.numRows).toBeNull();
|
|
||||||
expect(scannable.rescannable).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("honors numRows override", async () => {
|
|
||||||
const scannable = await Scannable.fromRecordBatchReader(
|
|
||||||
await makeReader(),
|
|
||||||
{ numRows: 3 },
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(scannable.numRows).toBe(3);
|
|
||||||
expect(scannable.rescannable).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("rescannable: false explicit does not throw", async () => {
|
|
||||||
const reader = await makeReader();
|
|
||||||
const scannable = await Scannable.fromRecordBatchReader(reader, {
|
|
||||||
rescannable: false,
|
|
||||||
});
|
|
||||||
expect(scannable.rescannable).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("throws when opts.rescannable is true", async () => {
|
|
||||||
const reader = await makeReader();
|
|
||||||
await expect(
|
|
||||||
Scannable.fromRecordBatchReader(reader, { rescannable: true }),
|
|
||||||
).rejects.toThrow(/does not accept rescannable/);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("throws when opts.rescannable is true even alongside numRows", async () => {
|
|
||||||
const reader = await makeReader();
|
|
||||||
await expect(
|
|
||||||
Scannable.fromRecordBatchReader(reader, {
|
|
||||||
numRows: 3,
|
|
||||||
rescannable: true,
|
|
||||||
}),
|
|
||||||
).rejects.toThrow(/does not accept rescannable/);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("fromIterable", () => {
|
|
||||||
test("accepts a sync iterable of batches", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
const scannable = await Scannable.fromIterable(
|
|
||||||
table.schema,
|
|
||||||
table.batches,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(scannable.schema).toBe(table.schema);
|
|
||||||
expect(scannable.numRows).toBeNull();
|
|
||||||
expect(scannable.rescannable).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("accepts an async iterable of batches", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
async function* generator(): AsyncGenerator<RecordBatch> {
|
|
||||||
for (const batch of table.batches) {
|
|
||||||
yield batch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const scannable = await Scannable.fromIterable(table.schema, generator());
|
|
||||||
expect(scannable.schema).toBe(table.schema);
|
|
||||||
expect(scannable.rescannable).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("rescannable: true detection", () => {
|
|
||||||
// Replayable inputs: [Symbol.iterator]() / [Symbol.asyncIterator]()
|
|
||||||
// returns a fresh iterator each call. Must NOT throw.
|
|
||||||
|
|
||||||
test("Array passes (fresh ArrayIterator each call)", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
const scannable = await Scannable.fromIterable(
|
|
||||||
table.schema,
|
|
||||||
table.batches,
|
|
||||||
{ rescannable: true },
|
|
||||||
);
|
|
||||||
expect(scannable.rescannable).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Set passes (fresh SetIterator each call)", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
const set = new Set<RecordBatch>(table.batches);
|
|
||||||
const scannable = await Scannable.fromIterable(table.schema, set, {
|
|
||||||
rescannable: true,
|
|
||||||
});
|
|
||||||
expect(scannable.rescannable).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("custom Iterable returning a fresh iterator passes", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
const replayable: Iterable<RecordBatch> = {
|
|
||||||
[Symbol.iterator]() {
|
|
||||||
return table.batches[Symbol.iterator]();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const scannable = await Scannable.fromIterable(
|
|
||||||
table.schema,
|
|
||||||
replayable,
|
|
||||||
{ rescannable: true },
|
|
||||||
);
|
|
||||||
expect(scannable.rescannable).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("object with generator method passes (fresh generator each call)", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
const replayable: Iterable<RecordBatch> = {
|
|
||||||
*[Symbol.iterator]() {
|
|
||||||
for (const batch of table.batches) yield batch;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const scannable = await Scannable.fromIterable(
|
|
||||||
table.schema,
|
|
||||||
replayable,
|
|
||||||
{ rescannable: true },
|
|
||||||
);
|
|
||||||
expect(scannable.rescannable).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("empty Array passes (replayable degenerate case)", async () => {
|
|
||||||
const schema = makeTable().schema;
|
|
||||||
const scannable = await Scannable.fromIterable(
|
|
||||||
schema,
|
|
||||||
[] as RecordBatch[],
|
|
||||||
{ rescannable: true },
|
|
||||||
);
|
|
||||||
expect(scannable.rescannable).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
// One-shot inputs: [Symbol.iterator]() / [Symbol.asyncIterator]()
|
|
||||||
// returns the same object, or the input is already-an-iterator.
|
|
||||||
// Must throw with a /one-shot/ message.
|
|
||||||
|
|
||||||
test("sync generator throws", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
function* generator(): Generator<RecordBatch> {
|
|
||||||
for (const batch of table.batches) yield batch;
|
|
||||||
}
|
|
||||||
await expect(
|
|
||||||
Scannable.fromIterable(table.schema, generator(), {
|
|
||||||
rescannable: true,
|
|
||||||
}),
|
|
||||||
).rejects.toThrow(/one-shot/);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("async generator throws", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
async function* generator(): AsyncGenerator<RecordBatch> {
|
|
||||||
for (const batch of table.batches) yield batch;
|
|
||||||
}
|
|
||||||
await expect(
|
|
||||||
Scannable.fromIterable(table.schema, generator(), {
|
|
||||||
rescannable: true,
|
|
||||||
}),
|
|
||||||
).rejects.toThrow(/one-shot/);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("empty generator throws (one-shot degenerate case)", async () => {
|
|
||||||
const schema = makeTable().schema;
|
|
||||||
function* generator(): Generator<RecordBatch> {
|
|
||||||
// intentionally empty; yields nothing.
|
|
||||||
}
|
|
||||||
await expect(
|
|
||||||
Scannable.fromIterable(schema, generator(), { rescannable: true }),
|
|
||||||
).rejects.toThrow(/one-shot/);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("custom self-iterator throws", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
const batches = table.batches;
|
|
||||||
let i = 0;
|
|
||||||
const oneShot: Iterable<RecordBatch> & Iterator<RecordBatch> = {
|
|
||||||
[Symbol.iterator]() {
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
next() {
|
|
||||||
if (i >= batches.length) {
|
|
||||||
return { done: true, value: undefined };
|
|
||||||
}
|
|
||||||
return { done: false, value: batches[i++] };
|
|
||||||
},
|
|
||||||
};
|
|
||||||
await expect(
|
|
||||||
Scannable.fromIterable(table.schema, oneShot, { rescannable: true }),
|
|
||||||
).rejects.toThrow(/one-shot/);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Array.values() (IterableIterator) throws", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
const iter = table.batches.values();
|
|
||||||
await expect(
|
|
||||||
Scannable.fromIterable(table.schema, iter, { rescannable: true }),
|
|
||||||
).rejects.toThrow(/one-shot/);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("raw iterator (only `.next`) throws", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
const batches = table.batches;
|
|
||||||
let i = 0;
|
|
||||||
const rawIter = {
|
|
||||||
next(): IteratorResult<RecordBatch> {
|
|
||||||
if (i >= batches.length) {
|
|
||||||
return { done: true, value: undefined };
|
|
||||||
}
|
|
||||||
return { done: false, value: batches[i++] };
|
|
||||||
},
|
|
||||||
};
|
|
||||||
await expect(
|
|
||||||
Scannable.fromIterable(
|
|
||||||
table.schema,
|
|
||||||
rawIter as unknown as Iterable<RecordBatch>,
|
|
||||||
{ rescannable: true },
|
|
||||||
),
|
|
||||||
).rejects.toThrow(/one-shot/);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Edge: null/undefined must not crash the detection helper. The
|
|
||||||
// null check belongs to `normalizeIterator` and only fires when a
|
|
||||||
// scan starts.
|
|
||||||
|
|
||||||
test("null input does not crash detection at construction", async () => {
|
|
||||||
const schema = makeTable().schema;
|
|
||||||
await expect(
|
|
||||||
Scannable.fromIterable(
|
|
||||||
schema,
|
|
||||||
null as unknown as Iterable<RecordBatch>,
|
|
||||||
{
|
|
||||||
rescannable: true,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
).resolves.toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("undefined input does not crash detection at construction", async () => {
|
|
||||||
const schema = makeTable().schema;
|
|
||||||
await expect(
|
|
||||||
Scannable.fromIterable(
|
|
||||||
schema,
|
|
||||||
undefined as unknown as Iterable<RecordBatch>,
|
|
||||||
{ rescannable: true },
|
|
||||||
),
|
|
||||||
).resolves.toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Default (rescannable omitted) skips the check entirely, so even
|
|
||||||
// pathological inputs construct without throwing here.
|
|
||||||
|
|
||||||
test("rescannable omitted skips detection entirely (generator passes)", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
function* generator(): Generator<RecordBatch> {
|
|
||||||
for (const batch of table.batches) yield batch;
|
|
||||||
}
|
|
||||||
const scannable = await Scannable.fromIterable(
|
|
||||||
table.schema,
|
|
||||||
generator(),
|
|
||||||
);
|
|
||||||
expect(scannable.rescannable).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("rescannable: false explicit skips detection entirely (generator passes)", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
function* generator(): Generator<RecordBatch> {
|
|
||||||
for (const batch of table.batches) yield batch;
|
|
||||||
}
|
|
||||||
const scannable = await Scannable.fromIterable(
|
|
||||||
table.schema,
|
|
||||||
generator(),
|
|
||||||
{ rescannable: false },
|
|
||||||
);
|
|
||||||
expect(scannable.rescannable).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("fromFactory", () => {
|
|
||||||
test("defaults rescannable=true and does not invoke the factory eagerly", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
const factory = jest.fn(() => table.batches);
|
|
||||||
|
|
||||||
const scannable = await Scannable.fromFactory(table.schema, factory);
|
|
||||||
|
|
||||||
expect(scannable.schema).toBe(table.schema);
|
|
||||||
expect(scannable.rescannable).toBe(true);
|
|
||||||
expect(factory).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("honors rescannable and numRows overrides", async () => {
|
|
||||||
const table = makeTable();
|
|
||||||
const scannable = await Scannable.fromFactory(
|
|
||||||
table.schema,
|
|
||||||
() => table.batches,
|
|
||||||
{ numRows: 7, rescannable: false },
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(scannable.numRows).toBe(7);
|
|
||||||
expect(scannable.rescannable).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("validation", () => {
|
|
||||||
test("throws when numRows is negative", async () => {
|
|
||||||
await expect(
|
|
||||||
Scannable.fromFactory(makeTable().schema, () => [], { numRows: -1 }),
|
|
||||||
).rejects.toThrow(/non-negative/);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("throws when numRows is not an integer", async () => {
|
|
||||||
await expect(
|
|
||||||
Scannable.fromFactory(makeTable().schema, () => [], { numRows: 3.5 }),
|
|
||||||
).rejects.toThrow(/integer/);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("native handle", () => {
|
|
||||||
test("exposes a native handle via inner", async () => {
|
|
||||||
const scannable = await Scannable.fromTable(makeTable());
|
|
||||||
expect(scannable.inner).toBeDefined();
|
|
||||||
expect(typeof scannable.inner).toBe("object");
|
|
||||||
expect(scannable.inner).not.toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Schema-variety construction tests. Each asserts that construction
|
|
||||||
// succeeds against a richer Arrow schema, which transitively exercises
|
|
||||||
// schema serialization and the Rust-side `ipc_file_to_schema` for types
|
|
||||||
// beyond flat primitives.
|
|
||||||
describe("schema variety", () => {
|
|
||||||
test("accepts an empty table", async () => {
|
|
||||||
const schema = new Schema([new Field("id", new Int32(), true)]);
|
|
||||||
const table = makeEmptyTable(schema);
|
|
||||||
const scannable = await Scannable.fromTable(table);
|
|
||||||
|
|
||||||
expect(scannable.numRows).toBe(0);
|
|
||||||
expect(scannable.schema).toBe(table.schema);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("accepts nested struct and list columns", async () => {
|
|
||||||
const table = makeArrowTable(
|
|
||||||
[
|
|
||||||
{ id: 1, point: { x: 0, y: 0 }, tags: ["a", "b"] },
|
|
||||||
{ id: 2, point: { x: 1, y: 2 }, tags: ["c"] },
|
|
||||||
],
|
|
||||||
{ vectorColumns: {} },
|
|
||||||
);
|
|
||||||
const scannable = await Scannable.fromTable(table);
|
|
||||||
|
|
||||||
expect(scannable.schema).toBe(table.schema);
|
|
||||||
expect(scannable.numRows).toBe(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("accepts a FixedSizeList (vector) column", async () => {
|
|
||||||
const table = makeArrowTable(
|
|
||||||
[
|
|
||||||
{ id: 1, vec: [1, 2, 3] },
|
|
||||||
{ id: 2, vec: [4, 5, 6] },
|
|
||||||
],
|
|
||||||
{ vectorColumns: { vec: { type: new Float16() } } },
|
|
||||||
);
|
|
||||||
const scannable = await Scannable.fromTable(table);
|
|
||||||
|
|
||||||
expect(scannable.schema).toBe(table.schema);
|
|
||||||
expect(scannable.numRows).toBe(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("accepts a table with many columns", async () => {
|
|
||||||
const row: Record<string, number> = {};
|
|
||||||
for (let i = 0; i < 50; i++) row[`c${i}`] = i;
|
|
||||||
const table = makeArrowTable([row, row], { vectorColumns: {} });
|
|
||||||
const scannable = await Scannable.fromTable(table);
|
|
||||||
|
|
||||||
expect(scannable.schema.fields.length).toBe(50);
|
|
||||||
expect(scannable.numRows).toBe(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -28,7 +28,6 @@ import {
|
|||||||
List,
|
List,
|
||||||
Schema,
|
Schema,
|
||||||
SchemaLike,
|
SchemaLike,
|
||||||
Struct,
|
|
||||||
Type,
|
Type,
|
||||||
Uint8,
|
Uint8,
|
||||||
Utf8,
|
Utf8,
|
||||||
@@ -116,48 +115,6 @@ describe.each([arrow15, arrow16, arrow17, arrow18])(
|
|||||||
await expect(table.countRows()).resolves.toBe(1);
|
await expect(table.countRows()).resolves.toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should invoke the progress callback", async () => {
|
|
||||||
const events: import("../lancedb").WriteProgress[] = [];
|
|
||||||
await table.add([{ id: 1 }, { id: 2 }, { id: 3 }], {
|
|
||||||
progress: (p) => events.push(p),
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(events.length).toBeGreaterThan(0);
|
|
||||||
const last = events[events.length - 1];
|
|
||||||
expect(last.done).toBe(true);
|
|
||||||
// Earlier callbacks must have done=false.
|
|
||||||
for (const ev of events.slice(0, -1)) {
|
|
||||||
expect(ev.done).toBe(false);
|
|
||||||
}
|
|
||||||
// outputRows reflects the rows added in this call, not table size.
|
|
||||||
expect(last.outputRows).toBe(3);
|
|
||||||
// The input source (an array) reports a row count, so totalRows is set.
|
|
||||||
expect(last.totalRows).toBe(3);
|
|
||||||
// outputRows is monotonic.
|
|
||||||
for (let i = 1; i < events.length; i++) {
|
|
||||||
expect(events[i].outputRows).toBeGreaterThanOrEqual(
|
|
||||||
events[i - 1].outputRows,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should swallow errors thrown from the progress callback", async () => {
|
|
||||||
const warn = jest
|
|
||||||
.spyOn(console, "warn")
|
|
||||||
.mockImplementation(() => undefined);
|
|
||||||
try {
|
|
||||||
const res = await table.add([{ id: 1 }, { id: 2 }], {
|
|
||||||
progress: () => {
|
|
||||||
throw new Error("callback bomb");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
expect(res.version).toBeGreaterThan(0);
|
|
||||||
expect(warn).toHaveBeenCalled();
|
|
||||||
} finally {
|
|
||||||
warn.mockRestore();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should let me close the table", async () => {
|
it("should let me close the table", async () => {
|
||||||
expect(table.isOpen()).toBe(true);
|
expect(table.isOpen()).toBe(true);
|
||||||
table.close();
|
table.close();
|
||||||
@@ -781,113 +738,6 @@ describe("When creating an index", () => {
|
|||||||
expect(indices2.length).toBe(0);
|
expect(indices2.length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create and search a nested vector index", async () => {
|
|
||||||
const db = await connect(tmpDir.name);
|
|
||||||
const nestedSchema = new Schema([
|
|
||||||
new Field("id", new Int32(), true),
|
|
||||||
new Field(
|
|
||||||
"image",
|
|
||||||
new Struct([
|
|
||||||
new Field(
|
|
||||||
"embedding",
|
|
||||||
new FixedSizeList(2, new Field("item", new Float32(), true)),
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
const nestedTable = await db.createTable(
|
|
||||||
"nested_vector",
|
|
||||||
makeArrowTable(
|
|
||||||
Array.from({ length: 300 }, (_, id) => ({
|
|
||||||
id,
|
|
||||||
image: { embedding: [id, id + 1] },
|
|
||||||
})),
|
|
||||||
{ schema: nestedSchema },
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
await nestedTable.createIndex("image.embedding", {
|
|
||||||
name: "image_embedding_idx",
|
|
||||||
});
|
|
||||||
const indices = await nestedTable.listIndices();
|
|
||||||
expect(indices).toContainEqual({
|
|
||||||
name: "image_embedding_idx",
|
|
||||||
indexType: "IvfPq",
|
|
||||||
columns: ["image.embedding"],
|
|
||||||
});
|
|
||||||
|
|
||||||
const explicit = await nestedTable
|
|
||||||
.query()
|
|
||||||
.nearestTo([0.0, 1.0])
|
|
||||||
.column("image.embedding")
|
|
||||||
.limit(1)
|
|
||||||
.toArray();
|
|
||||||
const inferred = await nestedTable
|
|
||||||
.query()
|
|
||||||
.nearestTo([0.0, 1.0])
|
|
||||||
.limit(1)
|
|
||||||
.toArray();
|
|
||||||
expect(inferred[0].id).toEqual(explicit[0].id);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should report multiple nested vector candidates", async () => {
|
|
||||||
const db = await connect(tmpDir.name);
|
|
||||||
const nestedSchema = new Schema([
|
|
||||||
new Field(
|
|
||||||
"image",
|
|
||||||
new Struct([
|
|
||||||
new Field(
|
|
||||||
"embedding",
|
|
||||||
new FixedSizeList(2, new Field("item", new Float32(), true)),
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
new Field(
|
|
||||||
"text",
|
|
||||||
new Struct([
|
|
||||||
new Field(
|
|
||||||
"embedding",
|
|
||||||
new FixedSizeList(2, new Field("item", new Float32(), true)),
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
const nestedTable = await db.createTable(
|
|
||||||
"multiple_nested_vectors",
|
|
||||||
makeArrowTable(
|
|
||||||
[
|
|
||||||
{
|
|
||||||
image: { embedding: [0.0, 1.0] },
|
|
||||||
text: { embedding: [2.0, 3.0] },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
{ schema: nestedSchema },
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
nestedTable.query().nearestTo([0.0, 1.0]).limit(1).toArray(),
|
|
||||||
).rejects.toThrow(/image\.embedding.*text\.embedding/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should report when no default vector column exists", async () => {
|
|
||||||
const db = await connect(tmpDir.name);
|
|
||||||
const noVectorTable = await db.createTable(
|
|
||||||
"no_vector",
|
|
||||||
makeArrowTable([{ id: 0, label: "cat" }]),
|
|
||||||
);
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
noVectorTable.query().nearestTo([0.0, 1.0]).limit(1).toArray(),
|
|
||||||
).rejects.toThrow(/No vector column/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should wait for index readiness", async () => {
|
it("should wait for index readiness", async () => {
|
||||||
// Create an index and then wait for it to be ready
|
// Create an index and then wait for it to be ready
|
||||||
await tbl.createIndex("vec");
|
await tbl.createIndex("vec");
|
||||||
@@ -1571,33 +1421,6 @@ describe("schema evolution", function () {
|
|||||||
expect(await table.schema()).toEqual(expectedSchema3);
|
expect(await table.schema()).toEqual(expectedSchema3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can update field metadata", async function () {
|
|
||||||
const con = await connect(tmpDir.name);
|
|
||||||
const table = await con.createTable("fm", [
|
|
||||||
{ id: 1, category: "a" },
|
|
||||||
{ id: 2, category: "b" },
|
|
||||||
]);
|
|
||||||
|
|
||||||
const res = await table.updateFieldMetadata([
|
|
||||||
{ path: "category", metadata: { unit: "label", pii: "false" } },
|
|
||||||
]);
|
|
||||||
expect(res).toHaveProperty("version");
|
|
||||||
expect(res.version).toBe(2);
|
|
||||||
|
|
||||||
let cat = (await table.schema()).fields.find((f) => f.name === "category");
|
|
||||||
expect(cat?.metadata.get("unit")).toBe("label");
|
|
||||||
expect(cat?.metadata.get("pii")).toBe("false");
|
|
||||||
|
|
||||||
// merge: add a key, delete one via null, keep the rest
|
|
||||||
await table.updateFieldMetadata([
|
|
||||||
{ path: "category", metadata: { source: "import", pii: null } },
|
|
||||||
]);
|
|
||||||
cat = (await table.schema()).fields.find((f) => f.name === "category");
|
|
||||||
expect(cat?.metadata.get("unit")).toBe("label"); // preserved
|
|
||||||
expect(cat?.metadata.get("source")).toBe("import"); // added
|
|
||||||
expect(cat?.metadata.has("pii")).toBe(false); // deleted
|
|
||||||
});
|
|
||||||
|
|
||||||
it("can cast to various types", async function () {
|
it("can cast to various types", async function () {
|
||||||
const con = await connect(tmpDir.name);
|
const con = await connect(tmpDir.name);
|
||||||
|
|
||||||
@@ -2047,25 +1870,6 @@ describe.each([arrow15, arrow16, arrow17, arrow18])(
|
|||||||
expect(results.length).toBe(3);
|
expect(results.length).toBe(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("prewarmData errors on local tables", async () => {
|
|
||||||
const db = await connect(tmpDir.name);
|
|
||||||
const data = [
|
|
||||||
{ text: "alpha", vector: [0.1, 0.2, 0.3] },
|
|
||||||
{ text: "beta", vector: [0.4, 0.5, 0.6] },
|
|
||||||
];
|
|
||||||
const table = await db.createTable("prewarm_data_test", data);
|
|
||||||
|
|
||||||
// prewarmData is only supported on remote tables. We verify the call
|
|
||||||
// is wired through napi and surfaces the expected error for both
|
|
||||||
// arg shapes (undefined and string[]).
|
|
||||||
await expect(table.prewarmData()).rejects.toThrow(
|
|
||||||
"prewarm_data is currently only supported on remote tables",
|
|
||||||
);
|
|
||||||
await expect(table.prewarmData(["text"])).rejects.toThrow(
|
|
||||||
"prewarm_data is currently only supported on remote tables",
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("full text index on list", async () => {
|
test("full text index on list", async () => {
|
||||||
const db = await connect(tmpDir.name);
|
const db = await connect(tmpDir.name);
|
||||||
const data = [
|
const data = [
|
||||||
@@ -2525,224 +2329,3 @@ describe("when creating a table with Float32Array vectors", () => {
|
|||||||
expect((fsl.children[0].type as Float32).precision).toBe(1);
|
expect((fsl.children[0].type as Float32).precision).toBe(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("setUnenforcedPrimaryKey", () => {
|
|
||||||
let tmpDir: tmp.DirResult;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
tmpDir = tmp.dirSync({ unsafeCleanup: true });
|
|
||||||
});
|
|
||||||
afterEach(() => tmpDir.removeCallback());
|
|
||||||
|
|
||||||
it("sets a single-column primary key (string or one-element array)", async () => {
|
|
||||||
const conn = await connect(tmpDir.name);
|
|
||||||
const schema = new arrow.Schema([
|
|
||||||
new arrow.Field("id", new arrow.Int64(), false),
|
|
||||||
]);
|
|
||||||
const t1 = await conn.createEmptyTable("t1", schema);
|
|
||||||
await t1.setUnenforcedPrimaryKey("id");
|
|
||||||
|
|
||||||
const t2 = await conn.createEmptyTable("t2", schema);
|
|
||||||
await t2.setUnenforcedPrimaryKey(["id"]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("rejects a compound primary key", async () => {
|
|
||||||
const conn = await connect(tmpDir.name);
|
|
||||||
const table = await conn.createEmptyTable(
|
|
||||||
"t",
|
|
||||||
new arrow.Schema([
|
|
||||||
new arrow.Field("id", new arrow.Int64(), false),
|
|
||||||
new arrow.Field("name", new arrow.Utf8(), false),
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
await expect(
|
|
||||||
table.setUnenforcedPrimaryKey(["id", "name"]),
|
|
||||||
).rejects.toThrow();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("rejects changing the primary key once set", async () => {
|
|
||||||
const conn = await connect(tmpDir.name);
|
|
||||||
const table = await conn.createEmptyTable(
|
|
||||||
"t",
|
|
||||||
new arrow.Schema([
|
|
||||||
new arrow.Field("id", new arrow.Int64(), false),
|
|
||||||
new arrow.Field("name", new arrow.Utf8(), false),
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
await table.setUnenforcedPrimaryKey("id");
|
|
||||||
await expect(table.setUnenforcedPrimaryKey("name")).rejects.toThrow();
|
|
||||||
await expect(table.setUnenforcedPrimaryKey("id")).rejects.toThrow();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("setLsmWriteSpec / unsetLsmWriteSpec", () => {
|
|
||||||
let tmpDir: tmp.DirResult;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
tmpDir = tmp.dirSync({ unsafeCleanup: true });
|
|
||||||
});
|
|
||||||
afterEach(() => tmpDir.removeCallback());
|
|
||||||
|
|
||||||
async function makeTable(conn: Connection): Promise<Table> {
|
|
||||||
return await conn.createEmptyTable(
|
|
||||||
"t",
|
|
||||||
new arrow.Schema([new arrow.Field("id", new arrow.Int64(), false)]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
it("installs and removes a bucket spec", async () => {
|
|
||||||
const conn = await connect(tmpDir.name);
|
|
||||||
const table = await makeTable(conn);
|
|
||||||
|
|
||||||
await table.setUnenforcedPrimaryKey("id");
|
|
||||||
await table.setLsmWriteSpec({
|
|
||||||
specType: "bucket",
|
|
||||||
column: "id",
|
|
||||||
numBuckets: 4,
|
|
||||||
});
|
|
||||||
await table.unsetLsmWriteSpec();
|
|
||||||
// A second unset errors — there is no spec left to remove.
|
|
||||||
await expect(table.unsetLsmWriteSpec()).rejects.toThrow();
|
|
||||||
// A fresh spec can be installed after unset.
|
|
||||||
await table.setLsmWriteSpec({
|
|
||||||
specType: "bucket",
|
|
||||||
column: "id",
|
|
||||||
numBuckets: 8,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("installs an unsharded spec", async () => {
|
|
||||||
const conn = await connect(tmpDir.name);
|
|
||||||
const table = await makeTable(conn);
|
|
||||||
|
|
||||||
await table.setUnenforcedPrimaryKey("id");
|
|
||||||
await table.setLsmWriteSpec({ specType: "unsharded" });
|
|
||||||
await table.unsetLsmWriteSpec();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("installs an identity spec", async () => {
|
|
||||||
const conn = await connect(tmpDir.name);
|
|
||||||
const table = await makeTable(conn);
|
|
||||||
|
|
||||||
await table.setUnenforcedPrimaryKey("id");
|
|
||||||
await table.setLsmWriteSpec({ specType: "identity", column: "id" });
|
|
||||||
await table.unsetLsmWriteSpec();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("rejects an invalid spec", async () => {
|
|
||||||
const conn = await connect(tmpDir.name);
|
|
||||||
const table = await makeTable(conn);
|
|
||||||
|
|
||||||
await table.setUnenforcedPrimaryKey("id");
|
|
||||||
// num_buckets out of range.
|
|
||||||
await expect(
|
|
||||||
table.setLsmWriteSpec({
|
|
||||||
specType: "bucket",
|
|
||||||
column: "id",
|
|
||||||
numBuckets: 0,
|
|
||||||
}),
|
|
||||||
).rejects.toThrow();
|
|
||||||
// Column mismatch.
|
|
||||||
await expect(
|
|
||||||
table.setLsmWriteSpec({
|
|
||||||
specType: "bucket",
|
|
||||||
column: "missing",
|
|
||||||
numBuckets: 4,
|
|
||||||
}),
|
|
||||||
).rejects.toThrow();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("LSM merge insert", () => {
|
|
||||||
let tmpDir: tmp.DirResult;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
tmpDir = tmp.dirSync({ unsafeCleanup: true });
|
|
||||||
});
|
|
||||||
afterEach(() => tmpDir.removeCallback());
|
|
||||||
|
|
||||||
async function bucketTable(conn: Connection): Promise<Table> {
|
|
||||||
// The primary key column must be non-nullable.
|
|
||||||
const table = await conn.createEmptyTable(
|
|
||||||
"t",
|
|
||||||
new arrow.Schema([
|
|
||||||
new arrow.Field("id", new arrow.Utf8(), false),
|
|
||||||
new arrow.Field("value", new arrow.Float64(), true),
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
await table.add([
|
|
||||||
{ id: "a", value: 1 },
|
|
||||||
{ id: "b", value: 2 },
|
|
||||||
]);
|
|
||||||
await table.setUnenforcedPrimaryKey("id");
|
|
||||||
// numBuckets = 1: every row routes to the single bucket.
|
|
||||||
await table.setLsmWriteSpec({
|
|
||||||
specType: "bucket",
|
|
||||||
column: "id",
|
|
||||||
numBuckets: 1,
|
|
||||||
});
|
|
||||||
return table;
|
|
||||||
}
|
|
||||||
|
|
||||||
it("routes merge_insert through the shard writer", async () => {
|
|
||||||
const conn = await connect(tmpDir.name);
|
|
||||||
const table = await bucketTable(conn);
|
|
||||||
|
|
||||||
const res = await table
|
|
||||||
.mergeInsert("id")
|
|
||||||
.whenMatchedUpdateAll()
|
|
||||||
.whenNotMatchedInsertAll()
|
|
||||||
.execute([
|
|
||||||
{ id: "c", value: 3 },
|
|
||||||
{ id: "d", value: 4 },
|
|
||||||
]);
|
|
||||||
// LSM path: rows go to the MemWAL, so only numRows is populated.
|
|
||||||
expect(res.numRows).toBe(2);
|
|
||||||
expect(res.version).toBe(0);
|
|
||||||
expect(res.numInsertedRows).toBe(0);
|
|
||||||
|
|
||||||
await table.closeLsmWriters();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("falls back to the standard path with useLsmWrite(false)", async () => {
|
|
||||||
const conn = await connect(tmpDir.name);
|
|
||||||
const table = await bucketTable(conn);
|
|
||||||
|
|
||||||
const res = await table
|
|
||||||
.mergeInsert("id")
|
|
||||||
.whenNotMatchedInsertAll()
|
|
||||||
.useLsmWrite(false)
|
|
||||||
.execute([
|
|
||||||
{ id: "b", value: 9 },
|
|
||||||
{ id: "e", value: 5 },
|
|
||||||
]);
|
|
||||||
// Standard path commits: id="e" inserted ("b" already exists).
|
|
||||||
expect(res.numInsertedRows).toBe(1);
|
|
||||||
expect(await table.countRows()).toBe(3);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("supports validateSingleShard(false)", async () => {
|
|
||||||
const conn = await connect(tmpDir.name);
|
|
||||||
const table = await bucketTable(conn);
|
|
||||||
|
|
||||||
const res = await table
|
|
||||||
.mergeInsert("id")
|
|
||||||
.whenMatchedUpdateAll()
|
|
||||||
.whenNotMatchedInsertAll()
|
|
||||||
.validateSingleShard(false)
|
|
||||||
.execute([{ id: "f", value: 6 }]);
|
|
||||||
expect(res.numRows).toBe(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("rejects a non-upsert merge under an LSM spec", async () => {
|
|
||||||
const conn = await connect(tmpDir.name);
|
|
||||||
const table = await bucketTable(conn);
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
table
|
|
||||||
.mergeInsert("id")
|
|
||||||
.whenNotMatchedInsertAll()
|
|
||||||
.execute([{ id: "g", value: 7 }]),
|
|
||||||
).rejects.toThrow();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -38,14 +38,5 @@ test("filtering examples", async () => {
|
|||||||
// --8<-- [start:sql_search]
|
// --8<-- [start:sql_search]
|
||||||
await tbl.query().where("id = 10").limit(10).toArray();
|
await tbl.query().where("id = 10").limit(10).toArray();
|
||||||
// --8<-- [end:sql_search]
|
// --8<-- [end:sql_search]
|
||||||
|
|
||||||
// --8<-- [start:orderby_search]
|
|
||||||
await tbl
|
|
||||||
.query()
|
|
||||||
.where("id > 10")
|
|
||||||
.orderBy({ columnName: "id", ascending: false })
|
|
||||||
.limit(5)
|
|
||||||
.toArray();
|
|
||||||
// --8<-- [end:orderby_search]
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
4810
nodejs/examples/package-lock.json
generated
Normal file
4810
nodejs/examples/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -11,17 +11,16 @@
|
|||||||
"test": "node --experimental-vm-modules node_modules/.bin/jest --testEnvironment jest-environment-node-single-context --verbose",
|
"test": "node --experimental-vm-modules node_modules/.bin/jest --testEnvironment jest-environment-node-single-context --verbose",
|
||||||
"lint": "biome check *.ts && biome format *.ts",
|
"lint": "biome check *.ts && biome format *.ts",
|
||||||
"lint-ci": "biome ci .",
|
"lint-ci": "biome ci .",
|
||||||
"lint-fix": "biome check --write *.ts && pnpm format",
|
"lint-fix": "biome check --write *.ts && npm run format",
|
||||||
"format": "biome format --write *.ts"
|
"format": "biome format --write *.ts"
|
||||||
},
|
},
|
||||||
"author": "Lance Devs",
|
"author": "Lance Devs",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"packageManager": "pnpm@11.1.1",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@huggingface/transformers": "3.0.2",
|
"@huggingface/transformers": "^3.0.2",
|
||||||
"@lancedb/lancedb": "file:../dist",
|
"@lancedb/lancedb": "file:../dist",
|
||||||
"openai": "4.29.2",
|
"openai": "^4.29.2",
|
||||||
"sharp": "0.33.5"
|
"sharp": "^0.33.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "^1.7.3",
|
"@biomejs/biome": "^1.7.3",
|
||||||
|
|||||||
3466
nodejs/examples/pnpm-lock.yaml
generated
3466
nodejs/examples/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
|||||||
# Block resolution of versions less than 24h old (Shai-Hulud window).
|
|
||||||
# This is the pnpm 11 default but pinned here so it's visible to
|
|
||||||
# reviewers and survives a future pnpm major flipping the default.
|
|
||||||
minimumReleaseAge: 1440
|
|
||||||
|
|
||||||
# Fail install if a transitive dep tries to run an unapproved script.
|
|
||||||
strictDepBuilds: true
|
|
||||||
|
|
||||||
allowBuilds:
|
|
||||||
'@biomejs/biome': true
|
|
||||||
onnxruntime-node: true
|
|
||||||
protobufjs: true
|
|
||||||
sharp: true
|
|
||||||
@@ -1291,18 +1291,6 @@ export async function fromRecordBatchToBuffer(
|
|||||||
return Buffer.from(await writer.toUint8Array());
|
return Buffer.from(await writer.toUint8Array());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a buffer containing a single record batch using the Arrow IPC Stream
|
|
||||||
* serialization. Each call produces a self-contained Stream message (schema +
|
|
||||||
* batch + EOS) suitable for incremental decode by `arrow_ipc::reader::StreamReader`.
|
|
||||||
*/
|
|
||||||
export async function fromRecordBatchToStreamBuffer(
|
|
||||||
batch: RecordBatch,
|
|
||||||
): Promise<Buffer> {
|
|
||||||
const writer = RecordBatchStreamWriter.writeAll([batch]);
|
|
||||||
return Buffer.from(await writer.toUint8Array());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize an Arrow Table into a buffer using the Arrow IPC Stream serialization
|
* Serialize an Arrow Table into a buffer using the Arrow IPC Stream serialization
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -16,18 +16,6 @@ import {
|
|||||||
} from "./arrow";
|
} from "./arrow";
|
||||||
import { EmbeddingFunctionConfig, getRegistry } from "./embedding/registry";
|
import { EmbeddingFunctionConfig, getRegistry } from "./embedding/registry";
|
||||||
import { Connection as LanceDbConnection } from "./native";
|
import { Connection as LanceDbConnection } from "./native";
|
||||||
import type {
|
|
||||||
CreateNamespaceResponse,
|
|
||||||
DescribeNamespaceResponse,
|
|
||||||
DropNamespaceResponse,
|
|
||||||
ListNamespacesResponse,
|
|
||||||
} from "./native";
|
|
||||||
export type {
|
|
||||||
CreateNamespaceResponse,
|
|
||||||
DescribeNamespaceResponse,
|
|
||||||
DropNamespaceResponse,
|
|
||||||
ListNamespacesResponse,
|
|
||||||
};
|
|
||||||
import { sanitizeTable } from "./sanitize";
|
import { sanitizeTable } from "./sanitize";
|
||||||
import { LocalTable, Table } from "./table";
|
import { LocalTable, Table } from "./table";
|
||||||
|
|
||||||
@@ -54,7 +42,7 @@ export interface CreateTableOptions {
|
|||||||
* Options already set on the connection will be inherited by the table,
|
* Options already set on the connection will be inherited by the table,
|
||||||
* but can be overridden here.
|
* but can be overridden here.
|
||||||
*
|
*
|
||||||
* The available options are described at https://docs.lancedb.com/storage/
|
* The available options are described at https://lancedb.com/docs/storage/
|
||||||
*/
|
*/
|
||||||
storageOptions?: Record<string, string>;
|
storageOptions?: Record<string, string>;
|
||||||
|
|
||||||
@@ -90,7 +78,7 @@ export interface OpenTableOptions {
|
|||||||
* Options already set on the connection will be inherited by the table,
|
* Options already set on the connection will be inherited by the table,
|
||||||
* but can be overridden here.
|
* but can be overridden here.
|
||||||
*
|
*
|
||||||
* The available options are described at https://docs.lancedb.com/storage/
|
* The available options are described at https://lancedb.com/docs/storage/
|
||||||
*/
|
*/
|
||||||
storageOptions?: Record<string, string>;
|
storageOptions?: Record<string, string>;
|
||||||
/**
|
/**
|
||||||
@@ -122,41 +110,6 @@ export interface TableNamesOptions {
|
|||||||
/** An optional limit to the number of results to return. */
|
/** An optional limit to the number of results to return. */
|
||||||
limit?: number;
|
limit?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListNamespacesOptions {
|
|
||||||
/** Token from a previous response for pagination. */
|
|
||||||
pageToken?: string;
|
|
||||||
/** An optional limit to the number of results to return. */
|
|
||||||
limit?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CreateNamespaceOptions {
|
|
||||||
/** Creation mode. */
|
|
||||||
mode?: "create" | "exist_ok" | "overwrite";
|
|
||||||
/** Properties to set on the new namespace. */
|
|
||||||
properties?: Record<string, string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DropNamespaceOptions {
|
|
||||||
/** Whether to skip if the namespace doesn't exist, or fail. */
|
|
||||||
mode?: "skip" | "fail";
|
|
||||||
/** Refuse to drop if non-empty (restrict) or drop recursively (cascade). */
|
|
||||||
behavior?: "restrict" | "cascade";
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RenameTableOptions {
|
|
||||||
/**
|
|
||||||
* The namespace path of the table being renamed. Defaults to the root
|
|
||||||
* namespace (`[]`) when omitted.
|
|
||||||
*/
|
|
||||||
namespacePath?: string[];
|
|
||||||
/**
|
|
||||||
* The namespace path to move the table to as part of the rename. When
|
|
||||||
* omitted the table stays in `namespacePath`.
|
|
||||||
*/
|
|
||||||
newNamespacePath?: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A LanceDB Connection that allows you to open tables and create new ones.
|
* A LanceDB Connection that allows you to open tables and create new ones.
|
||||||
*
|
*
|
||||||
@@ -315,69 +268,6 @@ export abstract class Connection {
|
|||||||
*/
|
*/
|
||||||
abstract dropAllTables(namespacePath?: string[]): Promise<void>;
|
abstract dropAllTables(namespacePath?: string[]): Promise<void>;
|
||||||
|
|
||||||
/**
|
|
||||||
* Describe a namespace, returning its properties.
|
|
||||||
*
|
|
||||||
* @param {string[]} namespacePath - The namespace path to describe, in
|
|
||||||
* parent → child order, e.g. `["analytics", "sales"]`.
|
|
||||||
* @returns {Promise<DescribeNamespaceResponse>} The namespace's properties
|
|
||||||
* (may be undefined if the namespace has none).
|
|
||||||
*/
|
|
||||||
abstract describeNamespace(
|
|
||||||
namespacePath: string[],
|
|
||||||
): Promise<DescribeNamespaceResponse>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List the immediate child namespaces under the given parent.
|
|
||||||
*
|
|
||||||
* Results may be paginated. To retrieve subsequent pages, pass the
|
|
||||||
* `pageToken` returned by a previous call.
|
|
||||||
*
|
|
||||||
* @param {string[]} namespacePath - The parent namespace path. Defaults
|
|
||||||
* to the root namespace if omitted.
|
|
||||||
* @param {Partial<ListNamespacesOptions>} options - Pagination options
|
|
||||||
* (`pageToken`, `limit`).
|
|
||||||
* @returns {Promise<ListNamespacesResponse>} Child namespace names and
|
|
||||||
* an optional token for fetching the next page.
|
|
||||||
*/
|
|
||||||
abstract listNamespaces(
|
|
||||||
namespacePath?: string[],
|
|
||||||
options?: Partial<ListNamespacesOptions>,
|
|
||||||
): Promise<ListNamespacesResponse>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new namespace at the given path.
|
|
||||||
*
|
|
||||||
* @param {string[]} namespacePath - The namespace path to create.
|
|
||||||
* @param {Partial<CreateNamespaceOptions>} options - Creation `mode`
|
|
||||||
* ("create" | "exist_ok" | "overwrite") and optional `properties`
|
|
||||||
* to attach to the namespace.
|
|
||||||
* @returns {Promise<CreateNamespaceResponse>} The properties of the
|
|
||||||
* created namespace and an optional transaction id.
|
|
||||||
*/
|
|
||||||
abstract createNamespace(
|
|
||||||
namespacePath: string[],
|
|
||||||
options?: Partial<CreateNamespaceOptions>,
|
|
||||||
): Promise<CreateNamespaceResponse>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Drop a namespace.
|
|
||||||
*
|
|
||||||
* Use `behavior: "cascade"` to also drop everything contained in the
|
|
||||||
* namespace (sub-namespaces and tables). The default `"restrict"`
|
|
||||||
* behavior refuses to drop a non-empty namespace.
|
|
||||||
*
|
|
||||||
* @param {string[]} namespacePath - The namespace path to drop.
|
|
||||||
* @param {Partial<DropNamespaceOptions>} options - `mode` ("skip" | "fail"
|
|
||||||
* for missing-namespace handling) and `behavior` ("restrict" | "cascade").
|
|
||||||
* @returns {Promise<DropNamespaceResponse>} Any properties returned by
|
|
||||||
* the server and an optional transaction id.
|
|
||||||
*/
|
|
||||||
abstract dropNamespace(
|
|
||||||
namespacePath: string[],
|
|
||||||
options?: Partial<DropNamespaceOptions>,
|
|
||||||
): Promise<DropNamespaceResponse>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone a table from a source table.
|
* Clone a table from a source table.
|
||||||
*
|
*
|
||||||
@@ -404,24 +294,6 @@ export abstract class Connection {
|
|||||||
isShallow?: boolean;
|
isShallow?: boolean;
|
||||||
},
|
},
|
||||||
): Promise<Table>;
|
): Promise<Table>;
|
||||||
|
|
||||||
/**
|
|
||||||
* Rename a table.
|
|
||||||
*
|
|
||||||
* Currently only supported by LanceDB Cloud. Local OSS connections and
|
|
||||||
* namespace-backed connections (via {@link connectNamespace}) reject with
|
|
||||||
* a "not supported" error.
|
|
||||||
*
|
|
||||||
* @param {string} currentName - The current name of the table.
|
|
||||||
* @param {string} newName - The new name for the table.
|
|
||||||
* @param {RenameTableOptions} options - Optional namespace paths. When
|
|
||||||
* `newNamespacePath` is omitted the table stays in `namespacePath`.
|
|
||||||
*/
|
|
||||||
abstract renameTable(
|
|
||||||
currentName: string,
|
|
||||||
newName: string,
|
|
||||||
options?: RenameTableOptions,
|
|
||||||
): Promise<void>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hideconstructor */
|
/** @hideconstructor */
|
||||||
@@ -643,58 +515,6 @@ export class LocalConnection extends Connection {
|
|||||||
async dropAllTables(namespacePath?: string[]): Promise<void> {
|
async dropAllTables(namespacePath?: string[]): Promise<void> {
|
||||||
return this.inner.dropAllTables(namespacePath ?? []);
|
return this.inner.dropAllTables(namespacePath ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
describeNamespace(
|
|
||||||
namespacePath: string[],
|
|
||||||
): Promise<DescribeNamespaceResponse> {
|
|
||||||
return this.inner.describeNamespace(namespacePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
listNamespaces(
|
|
||||||
namespacePath?: string[],
|
|
||||||
options?: Partial<ListNamespacesOptions>,
|
|
||||||
): Promise<ListNamespacesResponse> {
|
|
||||||
return this.inner.listNamespaces(
|
|
||||||
namespacePath ?? [],
|
|
||||||
options?.pageToken,
|
|
||||||
options?.limit,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
createNamespace(
|
|
||||||
namespacePath: string[],
|
|
||||||
options?: Partial<CreateNamespaceOptions>,
|
|
||||||
): Promise<CreateNamespaceResponse> {
|
|
||||||
return this.inner.createNamespace(
|
|
||||||
namespacePath,
|
|
||||||
options?.mode,
|
|
||||||
options?.properties,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
dropNamespace(
|
|
||||||
namespacePath: string[],
|
|
||||||
options?: Partial<DropNamespaceOptions>,
|
|
||||||
): Promise<DropNamespaceResponse> {
|
|
||||||
return this.inner.dropNamespace(
|
|
||||||
namespacePath,
|
|
||||||
options?.mode,
|
|
||||||
options?.behavior,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async renameTable(
|
|
||||||
currentName: string,
|
|
||||||
newName: string,
|
|
||||||
options?: RenameTableOptions,
|
|
||||||
): Promise<void> {
|
|
||||||
return this.inner.renameTable(
|
|
||||||
currentName,
|
|
||||||
newName,
|
|
||||||
options?.namespacePath ?? [],
|
|
||||||
options?.newNamespacePath,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import {
|
|||||||
} from "./connection";
|
} from "./connection";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ConnectNamespaceOptions,
|
|
||||||
ConnectionOptions,
|
ConnectionOptions,
|
||||||
Connection as LanceDbConnection,
|
Connection as LanceDbConnection,
|
||||||
JsHeaderProvider as NativeJsHeaderProvider,
|
JsHeaderProvider as NativeJsHeaderProvider,
|
||||||
@@ -23,7 +22,6 @@ export { JsHeaderProvider as NativeJsHeaderProvider } from "./native.js";
|
|||||||
export {
|
export {
|
||||||
AddColumnsSql,
|
AddColumnsSql,
|
||||||
ConnectionOptions,
|
ConnectionOptions,
|
||||||
ConnectNamespaceOptions,
|
|
||||||
IndexStatistics,
|
IndexStatistics,
|
||||||
IndexConfig,
|
IndexConfig,
|
||||||
ClientConfig,
|
ClientConfig,
|
||||||
@@ -42,7 +40,6 @@ export {
|
|||||||
AddResult,
|
AddResult,
|
||||||
AddColumnsResult,
|
AddColumnsResult,
|
||||||
AlterColumnsResult,
|
AlterColumnsResult,
|
||||||
UpdateFieldMetadataResult,
|
|
||||||
DeleteResult,
|
DeleteResult,
|
||||||
DropColumnsResult,
|
DropColumnsResult,
|
||||||
UpdateResult,
|
UpdateResult,
|
||||||
@@ -65,14 +62,6 @@ export {
|
|||||||
CreateTableOptions,
|
CreateTableOptions,
|
||||||
TableNamesOptions,
|
TableNamesOptions,
|
||||||
OpenTableOptions,
|
OpenTableOptions,
|
||||||
ListNamespacesOptions,
|
|
||||||
CreateNamespaceOptions,
|
|
||||||
DropNamespaceOptions,
|
|
||||||
ListNamespacesResponse,
|
|
||||||
CreateNamespaceResponse,
|
|
||||||
DropNamespaceResponse,
|
|
||||||
DescribeNamespaceResponse,
|
|
||||||
RenameTableOptions,
|
|
||||||
} from "./connection";
|
} from "./connection";
|
||||||
|
|
||||||
export { Session } from "./native.js";
|
export { Session } from "./native.js";
|
||||||
@@ -84,7 +73,6 @@ export {
|
|||||||
VectorQuery,
|
VectorQuery,
|
||||||
TakeQuery,
|
TakeQuery,
|
||||||
QueryExecutionOptions,
|
QueryExecutionOptions,
|
||||||
ColumnOrdering,
|
|
||||||
FullTextSearchOptions,
|
FullTextSearchOptions,
|
||||||
RecordBatchIterator,
|
RecordBatchIterator,
|
||||||
FullTextQuery,
|
FullTextQuery,
|
||||||
@@ -115,10 +103,7 @@ export {
|
|||||||
UpdateOptions,
|
UpdateOptions,
|
||||||
OptimizeOptions,
|
OptimizeOptions,
|
||||||
Version,
|
Version,
|
||||||
WriteProgress,
|
|
||||||
LsmWriteSpec,
|
|
||||||
ColumnAlteration,
|
ColumnAlteration,
|
||||||
FieldMetadataUpdate,
|
|
||||||
} from "./table";
|
} from "./table";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@@ -132,7 +117,6 @@ export { MergeInsertBuilder, WriteExecutionOptions } from "./merge";
|
|||||||
|
|
||||||
export * as embedding from "./embedding";
|
export * as embedding from "./embedding";
|
||||||
export { permutationBuilder, PermutationBuilder } from "./permutation";
|
export { permutationBuilder, PermutationBuilder } from "./permutation";
|
||||||
export { Scannable, ScannableOptions } from "./scannable";
|
|
||||||
export * as rerankers from "./rerankers";
|
export * as rerankers from "./rerankers";
|
||||||
export {
|
export {
|
||||||
SchemaLike,
|
SchemaLike,
|
||||||
@@ -309,197 +293,3 @@ export async function connect(
|
|||||||
);
|
);
|
||||||
return new LocalConnection(nativeConn);
|
return new LocalConnection(nativeConn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration for the built-in directory namespace (`"dir"`).
|
|
||||||
*
|
|
||||||
* The directory namespace stores tables under a single root path (local
|
|
||||||
* filesystem or object storage URI). See
|
|
||||||
* {@link https://docs.lancedb.com/namespaces} for the documented surface;
|
|
||||||
* less-common knobs live under {@link DirNamespaceConfig.extraProperties}.
|
|
||||||
*/
|
|
||||||
export interface DirNamespaceConfig {
|
|
||||||
/** Root path or URI containing the LanceDB tables. */
|
|
||||||
root: string;
|
|
||||||
/**
|
|
||||||
* Whether to maintain a namespace manifest at the root. Required for
|
|
||||||
* child namespaces. Defaults to true on the impl side.
|
|
||||||
*/
|
|
||||||
manifestEnabled?: boolean;
|
|
||||||
/**
|
|
||||||
* Additional raw properties passed verbatim to the namespace
|
|
||||||
* implementation (e.g. `storage.*`, `credential_vendor.*`). Typed
|
|
||||||
* fields above take precedence on key collision.
|
|
||||||
*/
|
|
||||||
extraProperties?: Record<string, string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration for the built-in REST namespace (`"rest"`).
|
|
||||||
*
|
|
||||||
* The REST namespace talks to a remote catalog server over HTTP. See
|
|
||||||
* {@link https://docs.lancedb.com/namespaces} for the documented surface;
|
|
||||||
* less-common knobs (TLS, metrics) live under
|
|
||||||
* {@link RestNamespaceConfig.extraProperties}.
|
|
||||||
*/
|
|
||||||
export interface RestNamespaceConfig {
|
|
||||||
/** Catalog endpoint URL. */
|
|
||||||
uri: string;
|
|
||||||
/**
|
|
||||||
* HTTP headers forwarded with each request. Keys are passed through
|
|
||||||
* as-is (e.g. `"x-api-key"`, `"Authorization"`).
|
|
||||||
*/
|
|
||||||
headers?: Record<string, string>;
|
|
||||||
/**
|
|
||||||
* Additional raw properties passed verbatim to the namespace
|
|
||||||
* implementation (e.g. `tls.*`, `ops_metrics_enabled`, `delimiter`).
|
|
||||||
* Typed fields above take precedence on key collision.
|
|
||||||
*/
|
|
||||||
extraProperties?: Record<string, string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
function dirConfigToProperties(
|
|
||||||
config: DirNamespaceConfig,
|
|
||||||
): Record<string, string> {
|
|
||||||
// Spread the whole input so that unknown keys (e.g. a raw `manifest_enabled`
|
|
||||||
// passed via the dynamic-impl path) flow through instead of being dropped.
|
|
||||||
// Typed transformations layer on top.
|
|
||||||
const { manifestEnabled, extraProperties, ...rest } = config;
|
|
||||||
const properties: Record<string, string> = {
|
|
||||||
...(extraProperties ?? {}),
|
|
||||||
...(rest as Record<string, string>),
|
|
||||||
};
|
|
||||||
if (manifestEnabled !== undefined) {
|
|
||||||
properties.manifest_enabled = String(manifestEnabled);
|
|
||||||
}
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
function restConfigToProperties(
|
|
||||||
config: RestNamespaceConfig,
|
|
||||||
): Record<string, string> {
|
|
||||||
const { headers, extraProperties, ...rest } = config;
|
|
||||||
const properties: Record<string, string> = {
|
|
||||||
...(extraProperties ?? {}),
|
|
||||||
...(rest as Record<string, string>),
|
|
||||||
};
|
|
||||||
if (headers) {
|
|
||||||
for (const [name, value] of Object.entries(headers)) {
|
|
||||||
properties[`headers.${name}`] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connect to a LanceDB database through a namespace.
|
|
||||||
*
|
|
||||||
* Unlike {@link connect}, which routes by URI scheme (local path vs.
|
|
||||||
* `db://` cloud), `connectNamespace` always returns a namespace-backed
|
|
||||||
* connection. The `implName` selects the namespace implementation:
|
|
||||||
*
|
|
||||||
* - `"dir"` — directory namespace, configured with {@link DirNamespaceConfig}.
|
|
||||||
* - `"rest"` — remote REST catalog, configured with {@link RestNamespaceConfig}.
|
|
||||||
* - Any other string — full module path for a custom implementation,
|
|
||||||
* configured with a free-form string-keyed `properties` map.
|
|
||||||
*
|
|
||||||
* @example Typed dir namespace
|
|
||||||
* ```ts
|
|
||||||
* const db = await connectNamespace("dir", { root: "/path/to/db" });
|
|
||||||
* await db.createTable("users", [{ id: 1 }]);
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @example Typed REST namespace with auth headers
|
|
||||||
* ```ts
|
|
||||||
* const db = await connectNamespace("rest", {
|
|
||||||
* uri: "https://catalog.example.com",
|
|
||||||
* headers: { "x-api-key": process.env.CATALOG_KEY ?? "" },
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @example Custom implementation with raw properties
|
|
||||||
* ```ts
|
|
||||||
* const db = await connectNamespace("my.custom.Namespace", {
|
|
||||||
* endpoint: "...",
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function connectNamespace(
|
|
||||||
implName: "dir",
|
|
||||||
config: DirNamespaceConfig,
|
|
||||||
options?: Partial<ConnectNamespaceOptions>,
|
|
||||||
): Promise<Connection>;
|
|
||||||
/**
|
|
||||||
* Connect through the built-in REST namespace.
|
|
||||||
*
|
|
||||||
* Configured with {@link RestNamespaceConfig}. See the function-level
|
|
||||||
* documentation above for the full surface, examples, and how this
|
|
||||||
* relates to {@link connect}.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const db = await connectNamespace("rest", {
|
|
||||||
* uri: "https://catalog.example.com",
|
|
||||||
* headers: { "x-api-key": process.env.CATALOG_KEY ?? "" },
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function connectNamespace(
|
|
||||||
implName: "rest",
|
|
||||||
config: RestNamespaceConfig,
|
|
||||||
options?: Partial<ConnectNamespaceOptions>,
|
|
||||||
): Promise<Connection>;
|
|
||||||
/**
|
|
||||||
* Connect through a custom namespace implementation by full module path,
|
|
||||||
* configured with a free-form string-keyed `properties` map. Use the
|
|
||||||
* typed overloads above for the built-in `"dir"` and `"rest"` impls.
|
|
||||||
*
|
|
||||||
* See the function-level documentation above for examples and how this
|
|
||||||
* relates to {@link connect}.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const db = await connectNamespace("my.custom.Namespace", {
|
|
||||||
* endpoint: "...",
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function connectNamespace(
|
|
||||||
implName: string,
|
|
||||||
properties: Record<string, string>,
|
|
||||||
options?: Partial<ConnectNamespaceOptions>,
|
|
||||||
): Promise<Connection>;
|
|
||||||
export async function connectNamespace(
|
|
||||||
implName: string,
|
|
||||||
configOrProperties:
|
|
||||||
| DirNamespaceConfig
|
|
||||||
| RestNamespaceConfig
|
|
||||||
| Record<string, string>,
|
|
||||||
options?: Partial<ConnectNamespaceOptions>,
|
|
||||||
): Promise<Connection> {
|
|
||||||
let properties: Record<string, string>;
|
|
||||||
if (implName === "dir") {
|
|
||||||
properties = dirConfigToProperties(
|
|
||||||
configOrProperties as DirNamespaceConfig,
|
|
||||||
);
|
|
||||||
} else if (implName === "rest") {
|
|
||||||
properties = restConfigToProperties(
|
|
||||||
configOrProperties as RestNamespaceConfig,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
properties = configOrProperties as Record<string, string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const finalOptions: ConnectNamespaceOptions = (options ??
|
|
||||||
{}) as ConnectNamespaceOptions;
|
|
||||||
finalOptions.storageOptions = cleanseStorageOptions(
|
|
||||||
finalOptions.storageOptions,
|
|
||||||
);
|
|
||||||
|
|
||||||
const nativeConn = await LanceDbConnection.newWithNamespace(
|
|
||||||
implName,
|
|
||||||
properties,
|
|
||||||
finalOptions,
|
|
||||||
);
|
|
||||||
return new LocalConnection(nativeConn);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -87,41 +87,6 @@ export class MergeInsertBuilder {
|
|||||||
this.#schema,
|
this.#schema,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether the merge uses the MemWAL LSM write path.
|
|
||||||
*
|
|
||||||
* By default (unset), a `mergeInsert` on a table with an LSM write spec is
|
|
||||||
* routed through Lance's MemWAL shard writer, and a table without one uses
|
|
||||||
* the standard path. Pass `false` to force the standard path even when a
|
|
||||||
* spec is set. Pass `true` to require a spec — `mergeInsert` rejects if none
|
|
||||||
* is installed.
|
|
||||||
*
|
|
||||||
* @param useLsmWrite - Whether to use the LSM write path.
|
|
||||||
*/
|
|
||||||
useLsmWrite(useLsmWrite: boolean): MergeInsertBuilder {
|
|
||||||
return new MergeInsertBuilder(
|
|
||||||
this.#native.useLsmWrite(useLsmWrite),
|
|
||||||
this.#schema,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Controls how an LSM merge checks that its input targets a single shard.
|
|
||||||
*
|
|
||||||
* When a table has an LSM write spec, every row in a `mergeInsert` call must
|
|
||||||
* route to the same shard. When `true` (the default), every row is inspected
|
|
||||||
* to verify this. When `false`, only the first row is inspected and the
|
|
||||||
* shard it routes to is used for the whole input — a faster path for callers
|
|
||||||
* that have already pre-sharded their input. Has no effect on tables without
|
|
||||||
* an LSM write spec.
|
|
||||||
*
|
|
||||||
* @param validateSingleShard - Whether to check every row routes to one shard. Defaults to `true`.
|
|
||||||
*/
|
|
||||||
validateSingleShard(validateSingleShard: boolean): MergeInsertBuilder {
|
|
||||||
return new MergeInsertBuilder(
|
|
||||||
this.#native.validateSingleShard(validateSingleShard),
|
|
||||||
this.#schema,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Executes the merge insert operation
|
* Executes the merge insert operation
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -79,12 +79,6 @@ export interface QueryExecutionOptions {
|
|||||||
timeoutMs?: number;
|
timeoutMs?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ColumnOrdering {
|
|
||||||
columnName: string;
|
|
||||||
ascending?: boolean;
|
|
||||||
nullsFirst?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options that control the behavior of a full text search
|
* Options that control the behavior of a full text search
|
||||||
*/
|
*/
|
||||||
@@ -423,21 +417,6 @@ export class StandardQueryBase<
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sort the results by the specified column(s).
|
|
||||||
* @returns This query builder.
|
|
||||||
*/
|
|
||||||
orderBy(ordering: ColumnOrdering | ColumnOrdering[]): this {
|
|
||||||
const orderings = Array.isArray(ordering) ? ordering : [ordering];
|
|
||||||
const normalized = orderings.map((o) => ({
|
|
||||||
columnName: o.columnName,
|
|
||||||
ascending: o.ascending ?? true,
|
|
||||||
nullsFirst: o.nullsFirst ?? false,
|
|
||||||
}));
|
|
||||||
this.doCall((inner) => inner.orderBy(normalized));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Skip searching un-indexed data. This can make search faster, but will miss
|
* Skip searching un-indexed data. This can make search faster, but will miss
|
||||||
* any data that is not yet indexed.
|
* any data that is not yet indexed.
|
||||||
|
|||||||
@@ -1,274 +0,0 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
||||||
|
|
||||||
import {
|
|
||||||
Table as ArrowTable,
|
|
||||||
RecordBatch,
|
|
||||||
RecordBatchReader,
|
|
||||||
Schema,
|
|
||||||
} from "apache-arrow";
|
|
||||||
import {
|
|
||||||
fromRecordBatchToStreamBuffer,
|
|
||||||
fromTableToBuffer,
|
|
||||||
makeEmptyTable,
|
|
||||||
} from "./arrow";
|
|
||||||
import { NapiScannable } from "./native.js";
|
|
||||||
|
|
||||||
export interface ScannableOptions {
|
|
||||||
/** Hint about the number of rows. Not validated against the stream. */
|
|
||||||
numRows?: number;
|
|
||||||
/**
|
|
||||||
* Whether the source can be scanned more than once. Defaults to `true` for
|
|
||||||
* `fromTable` / `fromFactory` and `false` for `fromIterable` /
|
|
||||||
* `fromRecordBatchReader`.
|
|
||||||
*/
|
|
||||||
rescannable?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A data source that can be scanned as a stream of Arrow `RecordBatch`es.
|
|
||||||
*
|
|
||||||
* `Scannable` wraps the schema + optional row count + rescannable flag and
|
|
||||||
* a callback that yields batches one at a time. It is passed to consumers
|
|
||||||
* (e.g. `Table.add`, `createTable`, `mergeInsert` — follow-up work) that
|
|
||||||
* need to pull data without materializing the full dataset in JS memory.
|
|
||||||
*
|
|
||||||
* Batches cross the JS↔Rust boundary as Arrow IPC Stream messages; a fresh
|
|
||||||
* writer serializes each batch, and the Rust side decodes it with
|
|
||||||
* `arrow_ipc::reader::StreamReader`. One batch is in flight at a time.
|
|
||||||
*/
|
|
||||||
export class Scannable {
|
|
||||||
readonly schema: Schema;
|
|
||||||
readonly numRows: number | null;
|
|
||||||
readonly rescannable: boolean;
|
|
||||||
|
|
||||||
/** @hidden */
|
|
||||||
private readonly native: NapiScannable;
|
|
||||||
|
|
||||||
private constructor(
|
|
||||||
native: NapiScannable,
|
|
||||||
schema: Schema,
|
|
||||||
numRows: number | null,
|
|
||||||
rescannable: boolean,
|
|
||||||
) {
|
|
||||||
this.native = native;
|
|
||||||
this.schema = schema;
|
|
||||||
this.numRows = numRows;
|
|
||||||
this.rescannable = rescannable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @hidden Access the native handle for passing through to Rust consumers. */
|
|
||||||
get inner(): NapiScannable {
|
|
||||||
return this.native;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build a Scannable from an explicit schema and a factory that returns a
|
|
||||||
* fresh batch iterator on each call.
|
|
||||||
*
|
|
||||||
* The factory is invoked once per scan. Each iterator yields
|
|
||||||
* `RecordBatch`es matching the declared schema. Use this when you need
|
|
||||||
* direct control over the pull loop — for example, to wrap a streaming
|
|
||||||
* source whose batches are produced lazily.
|
|
||||||
*
|
|
||||||
* @param schema - The Arrow schema of the produced batches.
|
|
||||||
* @param factory - Called at the start of each scan to produce a batch
|
|
||||||
* iterator. Must be idempotent when `rescannable` is true.
|
|
||||||
* @param opts - Optional hints. `rescannable` defaults to `true`; set to
|
|
||||||
* `false` if calling `factory()` twice would not reproduce the same data.
|
|
||||||
*/
|
|
||||||
static async fromFactory(
|
|
||||||
schema: Schema,
|
|
||||||
factory: () =>
|
|
||||||
| AsyncIterable<RecordBatch>
|
|
||||||
| Iterable<RecordBatch>
|
|
||||||
| AsyncIterator<RecordBatch>
|
|
||||||
| Iterator<RecordBatch>,
|
|
||||||
opts: ScannableOptions = {},
|
|
||||||
): Promise<Scannable> {
|
|
||||||
const numRows = opts.numRows ?? null;
|
|
||||||
if (numRows != null && !Number.isInteger(numRows)) {
|
|
||||||
throw new TypeError("numRows must be an integer");
|
|
||||||
}
|
|
||||||
const rescannable = opts.rescannable ?? true;
|
|
||||||
|
|
||||||
let iter: AsyncIterator<RecordBatch> | Iterator<RecordBatch> | null = null;
|
|
||||||
const getNextBatch = async (isStart: boolean): Promise<Buffer | null> => {
|
|
||||||
// `isStart` is true on the first pull of every new scan_as_stream.
|
|
||||||
// Drop any cached iterator so factory() is re-invoked for the next scan
|
|
||||||
if (isStart) {
|
|
||||||
iter = null;
|
|
||||||
}
|
|
||||||
if (iter === null) {
|
|
||||||
iter = normalizeIterator(factory());
|
|
||||||
}
|
|
||||||
const result = await iter.next();
|
|
||||||
if (result.done) {
|
|
||||||
iter = null;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return fromRecordBatchToStreamBuffer(result.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const schemaBuf = await fromTableToBuffer(makeEmptyTable(schema));
|
|
||||||
const native = new NapiScannable(
|
|
||||||
schemaBuf,
|
|
||||||
numRows,
|
|
||||||
rescannable,
|
|
||||||
getNextBatch,
|
|
||||||
);
|
|
||||||
return new Scannable(native, schema, numRows, rescannable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build a Scannable from an in-memory Arrow `Table`. Always rescannable;
|
|
||||||
* the table's batches are replayed on each scan.
|
|
||||||
*
|
|
||||||
* The table's row count is authoritative: `opts.numRows` must either be
|
|
||||||
* omitted or equal to `table.numRows`. `opts.rescannable` of `false` is
|
|
||||||
* rejected because in-memory Tables are always rescannable.
|
|
||||||
*/
|
|
||||||
static async fromTable(
|
|
||||||
table: ArrowTable,
|
|
||||||
opts: ScannableOptions = {},
|
|
||||||
): Promise<Scannable> {
|
|
||||||
if (opts.numRows != null && opts.numRows !== table.numRows) {
|
|
||||||
throw new TypeError(
|
|
||||||
`opts.numRows (${opts.numRows}) does not match table.numRows (${table.numRows}). ` +
|
|
||||||
`The table's row count is authoritative; omit numRows or pass the matching value.`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (opts.rescannable === false) {
|
|
||||||
throw new TypeError(
|
|
||||||
`fromTable does not accept rescannable: false. ` +
|
|
||||||
`In-memory Arrow Tables are always rescannable; omit the option or pass true.`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Scannable.fromFactory(table.schema, () => table.batches, {
|
|
||||||
numRows: table.numRows,
|
|
||||||
rescannable: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build a Scannable from an iterable of `RecordBatch`es. `rescannable`
|
|
||||||
* defaults to `false`. Pass an explicit schema so the consumer can
|
|
||||||
* validate before any batch is pulled.
|
|
||||||
*
|
|
||||||
* `opts.rescannable: true` is honest for replayable iterables (Arrays,
|
|
||||||
* Sets, or custom iterables whose `[Symbol.iterator]()` returns a fresh
|
|
||||||
* iterator each call). It is rejected for one-shot iterables (generators,
|
|
||||||
* async generators, or already-an-iterator inputs) because their
|
|
||||||
* `[Symbol.iterator]()` returns the same exhausted object on the second
|
|
||||||
* scan. For replayable sources outside this shape, use
|
|
||||||
* `fromFactory(schema, () => createIter(), { rescannable: true })`.
|
|
||||||
*
|
|
||||||
* Note: when `opts.rescannable` is `true`, the constructor calls
|
|
||||||
* `[Symbol.iterator]()` once on the input to perform the structural check.
|
|
||||||
*/
|
|
||||||
static async fromIterable(
|
|
||||||
schema: Schema,
|
|
||||||
iter: AsyncIterable<RecordBatch> | Iterable<RecordBatch>,
|
|
||||||
opts: ScannableOptions = {},
|
|
||||||
): Promise<Scannable> {
|
|
||||||
if (opts.rescannable === true && isOneShotIterable(iter)) {
|
|
||||||
throw new TypeError(
|
|
||||||
`fromIterable: rescannable: true is not honest for one-shot iterables ` +
|
|
||||||
`(generators, async generators, or iterators where [Symbol.iterator]() ` +
|
|
||||||
`returns the same object). The source would be exhausted after the first scan. ` +
|
|
||||||
`Use fromFactory(schema, () => createIter(), { rescannable: true }) for sources ` +
|
|
||||||
`where each call mints a fresh iterator.`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Scannable.fromFactory(schema, () => iter, {
|
|
||||||
numRows: opts.numRows,
|
|
||||||
rescannable: opts.rescannable ?? false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build a Scannable from an Arrow `RecordBatchReader`. A reader can only
|
|
||||||
* be consumed once; `rescannable` defaults to `false`.
|
|
||||||
*
|
|
||||||
* The reader must already be opened (via `.open()`) so its `.schema` is
|
|
||||||
* populated. `RecordBatchReader.from(...)` returns an unopened reader.
|
|
||||||
*
|
|
||||||
* `opts.rescannable: true` is rejected because `RecordBatchReader` is a
|
|
||||||
* self-iterator (its `[Symbol.iterator]()` returns itself), and this
|
|
||||||
* constructor does not call `reader.reset()` between scans, so a second
|
|
||||||
* scan would always see an exhausted reader. For genuinely replayable
|
|
||||||
* sources, use
|
|
||||||
* `fromFactory(schema, () => openReader(), { rescannable: true })`,
|
|
||||||
* which mints a fresh reader on each scan.
|
|
||||||
*/
|
|
||||||
static async fromRecordBatchReader(
|
|
||||||
reader: RecordBatchReader,
|
|
||||||
opts: ScannableOptions = {},
|
|
||||||
): Promise<Scannable> {
|
|
||||||
if (opts.rescannable === true) {
|
|
||||||
throw new TypeError(
|
|
||||||
`fromRecordBatchReader does not accept rescannable: true. ` +
|
|
||||||
`RecordBatchReader is a self-iterator (its [Symbol.iterator]() ` +
|
|
||||||
`returns itself) and would be exhausted after the first scan. ` +
|
|
||||||
`Use fromFactory(schema, () => openReader(), { rescannable: true }) ` +
|
|
||||||
`for sources where each call mints a fresh reader.`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Scannable.fromFactory(reader.schema, () => reader, {
|
|
||||||
numRows: opts.numRows,
|
|
||||||
rescannable: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeIterator<T>(
|
|
||||||
source: AsyncIterable<T> | Iterable<T> | AsyncIterator<T> | Iterator<T>,
|
|
||||||
): AsyncIterator<T> | Iterator<T> {
|
|
||||||
if (source == null) {
|
|
||||||
throw new TypeError("Scannable factory returned null/undefined");
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
typeof (source as AsyncIterable<T>)[Symbol.asyncIterator] === "function"
|
|
||||||
) {
|
|
||||||
return (source as AsyncIterable<T>)[Symbol.asyncIterator]();
|
|
||||||
}
|
|
||||||
if (typeof (source as Iterable<T>)[Symbol.iterator] === "function") {
|
|
||||||
return (source as Iterable<T>)[Symbol.iterator]();
|
|
||||||
}
|
|
||||||
// Already an iterator (has `.next`).
|
|
||||||
if (typeof (source as Iterator<T>).next === "function") {
|
|
||||||
return source as Iterator<T>;
|
|
||||||
}
|
|
||||||
throw new TypeError("Scannable factory returned a non-iterable value");
|
|
||||||
}
|
|
||||||
|
|
||||||
// A "self-iterator" returns the same object from `[Symbol.iterator]()` /
|
|
||||||
// `[Symbol.asyncIterator]()`. Generators behave this way, so they exhaust
|
|
||||||
// after one pass. Replayable iterables (Array, Set, custom) return a fresh
|
|
||||||
// iterator each call. Detection mirrors `normalizeIterator`'s ordering so
|
|
||||||
// classification matches scan-time behavior.
|
|
||||||
function isOneShotIterable(
|
|
||||||
source: AsyncIterable<unknown> | Iterable<unknown>,
|
|
||||||
): boolean {
|
|
||||||
// null/undefined are not one-shot in any meaningful sense; let
|
|
||||||
// `normalizeIterator` raise the actual error at scan time.
|
|
||||||
if (source == null) return false;
|
|
||||||
const ref = source as unknown;
|
|
||||||
if (
|
|
||||||
typeof (source as AsyncIterable<unknown>)[Symbol.asyncIterator] ===
|
|
||||||
"function"
|
|
||||||
) {
|
|
||||||
const it = (source as AsyncIterable<unknown>)[
|
|
||||||
Symbol.asyncIterator
|
|
||||||
]() as unknown;
|
|
||||||
return it === ref;
|
|
||||||
}
|
|
||||||
if (typeof (source as Iterable<unknown>)[Symbol.iterator] === "function") {
|
|
||||||
const it = (source as Iterable<unknown>)[Symbol.iterator]() as unknown;
|
|
||||||
return it === ref;
|
|
||||||
}
|
|
||||||
// Already-an-iterator (has `.next` but no `Symbol.iterator`) is by
|
|
||||||
// definition one-shot.
|
|
||||||
if (typeof (source as { next?: unknown }).next === "function") return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@@ -32,7 +32,6 @@ import {
|
|||||||
OptimizeStats,
|
OptimizeStats,
|
||||||
TableStatistics,
|
TableStatistics,
|
||||||
Tags,
|
Tags,
|
||||||
UpdateFieldMetadataResult,
|
|
||||||
UpdateResult,
|
UpdateResult,
|
||||||
Table as _NativeTable,
|
Table as _NativeTable,
|
||||||
} from "./native";
|
} from "./native";
|
||||||
@@ -47,33 +46,6 @@ import { sanitizeType } from "./sanitize";
|
|||||||
import { IntoSql, toSQL } from "./util";
|
import { IntoSql, toSQL } from "./util";
|
||||||
export { IndexConfig } from "./native";
|
export { IndexConfig } from "./native";
|
||||||
|
|
||||||
/**
|
|
||||||
* Progress snapshot for a write operation, delivered to the `progress`
|
|
||||||
* callback passed to {@link Table.add}.
|
|
||||||
*/
|
|
||||||
export interface WriteProgress {
|
|
||||||
/** Number of rows written so far. */
|
|
||||||
outputRows: number;
|
|
||||||
/** Number of bytes written so far. */
|
|
||||||
outputBytes: number;
|
|
||||||
/**
|
|
||||||
* Total rows expected, when the input source reports it.
|
|
||||||
*
|
|
||||||
* Always set on the final callback (the one with `done: true`), falling
|
|
||||||
* back to the actual number of rows written when the source could not
|
|
||||||
* report a row count up front.
|
|
||||||
*/
|
|
||||||
totalRows?: number;
|
|
||||||
/** Wall-clock seconds since the write started. */
|
|
||||||
elapsedSeconds: number;
|
|
||||||
/** Number of parallel write tasks currently in flight. */
|
|
||||||
activeTasks: number;
|
|
||||||
/** Total number of parallel write tasks (the write parallelism). */
|
|
||||||
totalTasks: number;
|
|
||||||
/** `true` for the final callback; `false` otherwise. */
|
|
||||||
done: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for adding data to a table.
|
* Options for adding data to a table.
|
||||||
*/
|
*/
|
||||||
@@ -84,28 +56,6 @@ export interface AddDataOptions {
|
|||||||
* If "overwrite" then the new data will replace the existing data in the table.
|
* If "overwrite" then the new data will replace the existing data in the table.
|
||||||
*/
|
*/
|
||||||
mode: "append" | "overwrite";
|
mode: "append" | "overwrite";
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional callback invoked periodically with write progress.
|
|
||||||
*
|
|
||||||
* The callback is fired once per batch written and once more with
|
|
||||||
* `done: true` when the write completes. Calls are dispatched
|
|
||||||
* asynchronously to the JS event loop and never block the write — a slow
|
|
||||||
* callback will queue events rather than back-pressure the writer.
|
|
||||||
*
|
|
||||||
* Errors thrown from the callback are logged with `console.warn` and
|
|
||||||
* swallowed — they do not abort the write.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* await table.add(data, {
|
|
||||||
* progress: (p) => {
|
|
||||||
* console.log(`${p.outputRows}/${p.totalRows ?? "?"} rows`);
|
|
||||||
* },
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
progress: (progress: WriteProgress) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateOptions {
|
export interface UpdateOptions {
|
||||||
@@ -156,30 +106,6 @@ export interface Version {
|
|||||||
metadata: Record<string, string>;
|
metadata: Record<string, string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Specification selecting Lance's MemWAL LSM-style write path for
|
|
||||||
* `mergeInsert`.
|
|
||||||
*
|
|
||||||
* `specType` is `"bucket"`, `"identity"`, or `"unsharded"`. For `"bucket"`,
|
|
||||||
* `column` and `numBuckets` are required; for `"identity"`, `column` is
|
|
||||||
* required and must be a deterministic function of the unenforced primary
|
|
||||||
* key (every row with a given primary key must always produce the same
|
|
||||||
* `column` value, or upserts of that key can land in different shards and a
|
|
||||||
* stale version can win).
|
|
||||||
*/
|
|
||||||
export interface LsmWriteSpec {
|
|
||||||
/** One of `"bucket"`, `"identity"`, or `"unsharded"`. */
|
|
||||||
specType: "bucket" | "identity" | "unsharded";
|
|
||||||
/** Bucket and identity variants: the sharding column. */
|
|
||||||
column?: string;
|
|
||||||
/** Bucket variant: the number of buckets, in `[1, 1024]`. */
|
|
||||||
numBuckets?: number;
|
|
||||||
/** Names of indexes the MemWAL should keep up to date during writes. */
|
|
||||||
maintainedIndexes?: string[];
|
|
||||||
/** Default `ShardWriter` configuration recorded in the MemWAL index. */
|
|
||||||
writerConfigDefaults?: Record<string, string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Table is a collection of Records in a LanceDB Database.
|
* A Table is a collection of Records in a LanceDB Database.
|
||||||
*
|
*
|
||||||
@@ -359,25 +285,6 @@ export abstract class Table {
|
|||||||
*/
|
*/
|
||||||
abstract prewarmIndex(name: string): Promise<void>;
|
abstract prewarmIndex(name: string): Promise<void>;
|
||||||
|
|
||||||
/**
|
|
||||||
* Prewarm one or more columns of data in the table.
|
|
||||||
*
|
|
||||||
* @param columns The columns to prewarm. If undefined, all columns are prewarmed.
|
|
||||||
*
|
|
||||||
* This will load the column data into the page cache so that future queries that
|
|
||||||
* read those columns avoid the initial cold-start latency. This call initiates
|
|
||||||
* prewarming and returns once the request is accepted; the warming itself may
|
|
||||||
* continue in the background. Calling it on already-prewarmed columns is a
|
|
||||||
* no-op on the server.
|
|
||||||
*
|
|
||||||
* Prewarming is generally useful for columns used in filters or projections.
|
|
||||||
* Large columns (e.g. high-dimensional vectors or binary data) may not be
|
|
||||||
* practical to prewarm.
|
|
||||||
*
|
|
||||||
* This feature is currently only supported on remote tables.
|
|
||||||
*/
|
|
||||||
abstract prewarmData(columns?: string[]): Promise<void>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits for asynchronous indexing to complete on the table.
|
* Waits for asynchronous indexing to complete on the table.
|
||||||
*
|
*
|
||||||
@@ -509,18 +416,6 @@ export abstract class Table {
|
|||||||
abstract alterColumns(
|
abstract alterColumns(
|
||||||
columnAlterations: ColumnAlteration[],
|
columnAlterations: ColumnAlteration[],
|
||||||
): Promise<AlterColumnsResult>;
|
): Promise<AlterColumnsResult>;
|
||||||
|
|
||||||
/**
|
|
||||||
* Update per-field (column) metadata.
|
|
||||||
* @param {FieldMetadataUpdate[]} updates One or more per-field updates. Each
|
|
||||||
* update's metadata is merged into the field's existing metadata by default;
|
|
||||||
* a value of `null` deletes that key, and `replace: true` swaps the whole map.
|
|
||||||
* @returns {Promise<UpdateFieldMetadataResult>} resolves to the new table version.
|
|
||||||
*/
|
|
||||||
abstract updateFieldMetadata(
|
|
||||||
updates: FieldMetadataUpdate[],
|
|
||||||
): Promise<UpdateFieldMetadataResult>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Drop one or more columns from the dataset
|
* Drop one or more columns from the dataset
|
||||||
*
|
*
|
||||||
@@ -535,64 +430,6 @@ export abstract class Table {
|
|||||||
* containing the new version number of the table after dropping the columns.
|
* containing the new version number of the table after dropping the columns.
|
||||||
*/
|
*/
|
||||||
abstract dropColumns(columnNames: string[]): Promise<DropColumnsResult>;
|
abstract dropColumns(columnNames: string[]): Promise<DropColumnsResult>;
|
||||||
/**
|
|
||||||
* Set the unenforced primary key for this table to a single column.
|
|
||||||
*
|
|
||||||
* "Unenforced" means LanceDB does not check uniqueness on writes; the
|
|
||||||
* column is recorded in the schema as the primary key for use by features
|
|
||||||
* such as `merge_insert`. Only single-column primary keys are supported,
|
|
||||||
* and the key cannot be changed once set.
|
|
||||||
* @param {string | string[]} columns The primary key column. A one-element
|
|
||||||
* array is also accepted; passing more than one column is rejected.
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
abstract setUnenforcedPrimaryKey(columns: string | string[]): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Install an {@link LsmWriteSpec} on this table, selecting Lance's MemWAL
|
|
||||||
* LSM-style write path for future `mergeInsert` calls.
|
|
||||||
*
|
|
||||||
* `LsmWriteSpec` chooses one of three sharding strategies via `specType`:
|
|
||||||
*
|
|
||||||
* - `"bucket"` — hash-bucket writes by the single-column unenforced primary
|
|
||||||
* key (`column` and `numBuckets` required).
|
|
||||||
* - `"identity"` — shard by the raw value of a scalar `column`.
|
|
||||||
* - `"unsharded"` — route every write to a single shard.
|
|
||||||
*
|
|
||||||
* All variants require the table to have an unenforced primary key
|
|
||||||
* ({@link Table#setUnenforcedPrimaryKey}); bucket sharding additionally
|
|
||||||
* requires it to be the single column being bucketed.
|
|
||||||
* @param {LsmWriteSpec} spec The sharding spec to install.
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* await table.setUnenforcedPrimaryKey("id");
|
|
||||||
* await table.setLsmWriteSpec({
|
|
||||||
* specType: "bucket",
|
|
||||||
* column: "id",
|
|
||||||
* numBuckets: 16,
|
|
||||||
* maintainedIndexes: ["id_idx"],
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
abstract setLsmWriteSpec(spec: LsmWriteSpec): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Remove the {@link LsmWriteSpec} from this table, reverting to the standard
|
|
||||||
* `mergeInsert` write path.
|
|
||||||
*
|
|
||||||
* Errors if no spec is currently set.
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
abstract unsetLsmWriteSpec(): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Drain and close any cached MemWAL shard writers held for this table.
|
|
||||||
*
|
|
||||||
* When an {@link LsmWriteSpec} is installed, `mergeInsert` opens MemWAL
|
|
||||||
* shard writers and caches them for reuse across calls. This closes them,
|
|
||||||
* flushing pending data; writers reopen lazily on the next `mergeInsert`.
|
|
||||||
* It is a no-op when no writers are cached.
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
abstract closeLsmWriters(): Promise<void>;
|
|
||||||
/** Retrieve the version of the table */
|
/** Retrieve the version of the table */
|
||||||
|
|
||||||
abstract version(): Promise<number>;
|
abstract version(): Promise<number>;
|
||||||
@@ -780,20 +617,7 @@ export class LocalTable extends Table {
|
|||||||
const schema = await this.schema();
|
const schema = await this.schema();
|
||||||
|
|
||||||
const buffer = await fromDataToBuffer(data, undefined, schema);
|
const buffer = await fromDataToBuffer(data, undefined, schema);
|
||||||
// Wrap the user callback so a thrown error doesn't surface as an
|
return await this.inner.add(buffer, mode);
|
||||||
// unhandled exception (the callback fires from a napi threadsafe
|
|
||||||
// function — exceptions there crash the process).
|
|
||||||
const userProgress = options?.progress;
|
|
||||||
const progress = userProgress
|
|
||||||
? (p: WriteProgress) => {
|
|
||||||
try {
|
|
||||||
userProgress(p);
|
|
||||||
} catch (e) {
|
|
||||||
console.warn("Table.add progress callback threw:", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
: undefined;
|
|
||||||
return await this.inner.add(buffer, mode, progress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(
|
async update(
|
||||||
@@ -886,10 +710,6 @@ export class LocalTable extends Table {
|
|||||||
await this.inner.prewarmIndex(name);
|
await this.inner.prewarmIndex(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
async prewarmData(columns?: string[]): Promise<void> {
|
|
||||||
await this.inner.prewarmData(columns);
|
|
||||||
}
|
|
||||||
|
|
||||||
async waitForIndex(
|
async waitForIndex(
|
||||||
indexNames: string[],
|
indexNames: string[],
|
||||||
timeoutSeconds: number,
|
timeoutSeconds: number,
|
||||||
@@ -1050,33 +870,10 @@ export class LocalTable extends Table {
|
|||||||
return await this.inner.alterColumns(processedAlterations);
|
return await this.inner.alterColumns(processedAlterations);
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateFieldMetadata(
|
|
||||||
updates: FieldMetadataUpdate[],
|
|
||||||
): Promise<UpdateFieldMetadataResult> {
|
|
||||||
return await this.inner.updateFieldMetadata(updates);
|
|
||||||
}
|
|
||||||
|
|
||||||
async dropColumns(columnNames: string[]): Promise<DropColumnsResult> {
|
async dropColumns(columnNames: string[]): Promise<DropColumnsResult> {
|
||||||
return await this.inner.dropColumns(columnNames);
|
return await this.inner.dropColumns(columnNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setUnenforcedPrimaryKey(columns: string | string[]): Promise<void> {
|
|
||||||
const cols = typeof columns === "string" ? [columns] : columns;
|
|
||||||
return await this.inner.setUnenforcedPrimaryKey(cols);
|
|
||||||
}
|
|
||||||
|
|
||||||
async setLsmWriteSpec(spec: LsmWriteSpec): Promise<void> {
|
|
||||||
return await this.inner.setLsmWriteSpec(spec);
|
|
||||||
}
|
|
||||||
|
|
||||||
async unsetLsmWriteSpec(): Promise<void> {
|
|
||||||
return await this.inner.unsetLsmWriteSpec();
|
|
||||||
}
|
|
||||||
|
|
||||||
async closeLsmWriters(): Promise<void> {
|
|
||||||
return await this.inner.closeLsmWriters();
|
|
||||||
}
|
|
||||||
|
|
||||||
async version(): Promise<number> {
|
async version(): Promise<number> {
|
||||||
return await this.inner.version();
|
return await this.inner.version();
|
||||||
}
|
}
|
||||||
@@ -1222,19 +1019,3 @@ export interface ColumnAlteration {
|
|||||||
/** Set the new nullability. Note that a nullable column cannot be made non-nullable. */
|
/** Set the new nullability. Note that a nullable column cannot be made non-nullable. */
|
||||||
nullable?: boolean;
|
nullable?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A per-field metadata update, addressed by dot-path. */
|
|
||||||
export interface FieldMetadataUpdate {
|
|
||||||
/**
|
|
||||||
* Dot-separated path to the field. For a top-level column this is just its
|
|
||||||
* name; for a nested field it's the path, e.g. "a.b.c".
|
|
||||||
*/
|
|
||||||
path: string;
|
|
||||||
/**
|
|
||||||
* Metadata key/value pairs. Merged into the field's existing metadata by
|
|
||||||
* default; a value of `null` deletes that key.
|
|
||||||
*/
|
|
||||||
metadata: Record<string, string | null>;
|
|
||||||
/** If true, replace the field's entire metadata map instead of merging. */
|
|
||||||
replace?: boolean;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@lancedb/lancedb-darwin-arm64",
|
"name": "@lancedb/lancedb-darwin-arm64",
|
||||||
"version": "0.30.1-beta.0",
|
"version": "0.28.0-beta.1",
|
||||||
"os": ["darwin"],
|
"os": ["darwin"],
|
||||||
"cpu": ["arm64"],
|
"cpu": ["arm64"],
|
||||||
"main": "lancedb.darwin-arm64.node",
|
"main": "lancedb.darwin-arm64.node",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@lancedb/lancedb-linux-arm64-gnu",
|
"name": "@lancedb/lancedb-linux-arm64-gnu",
|
||||||
"version": "0.30.1-beta.0",
|
"version": "0.28.0-beta.1",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["arm64"],
|
"cpu": ["arm64"],
|
||||||
"main": "lancedb.linux-arm64-gnu.node",
|
"main": "lancedb.linux-arm64-gnu.node",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@lancedb/lancedb-linux-arm64-musl",
|
"name": "@lancedb/lancedb-linux-arm64-musl",
|
||||||
"version": "0.30.1-beta.0",
|
"version": "0.28.0-beta.1",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["arm64"],
|
"cpu": ["arm64"],
|
||||||
"main": "lancedb.linux-arm64-musl.node",
|
"main": "lancedb.linux-arm64-musl.node",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@lancedb/lancedb-linux-x64-gnu",
|
"name": "@lancedb/lancedb-linux-x64-gnu",
|
||||||
"version": "0.30.1-beta.0",
|
"version": "0.28.0-beta.1",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["x64"],
|
"cpu": ["x64"],
|
||||||
"main": "lancedb.linux-x64-gnu.node",
|
"main": "lancedb.linux-x64-gnu.node",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@lancedb/lancedb-linux-x64-musl",
|
"name": "@lancedb/lancedb-linux-x64-musl",
|
||||||
"version": "0.30.1-beta.0",
|
"version": "0.28.0-beta.1",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["x64"],
|
"cpu": ["x64"],
|
||||||
"main": "lancedb.linux-x64-musl.node",
|
"main": "lancedb.linux-x64-musl.node",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@lancedb/lancedb-win32-arm64-msvc",
|
"name": "@lancedb/lancedb-win32-arm64-msvc",
|
||||||
"version": "0.30.1-beta.0",
|
"version": "0.28.0-beta.1",
|
||||||
"os": [
|
"os": [
|
||||||
"win32"
|
"win32"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@lancedb/lancedb-win32-x64-msvc",
|
"name": "@lancedb/lancedb-win32-x64-msvc",
|
||||||
"version": "0.30.1-beta.0",
|
"version": "0.28.0-beta.1",
|
||||||
"os": ["win32"],
|
"os": ["win32"],
|
||||||
"cpu": ["x64"],
|
"cpu": ["x64"],
|
||||||
"main": "lancedb.win32-x64-msvc.node",
|
"main": "lancedb.win32-x64-msvc.node",
|
||||||
|
|||||||
4703
nodejs/package-lock.json
generated
4703
nodejs/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@
|
|||||||
"ann"
|
"ann"
|
||||||
],
|
],
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "0.30.1-beta.0",
|
"version": "0.28.0-beta.1",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./dist/index.js",
|
".": "./dist/index.js",
|
||||||
@@ -38,15 +38,15 @@
|
|||||||
"url": "https://github.com/lancedb/lancedb"
|
"url": "https://github.com/lancedb/lancedb"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@aws-sdk/client-dynamodb": "3.1003.0",
|
"@aws-sdk/client-dynamodb": "^3.33.0",
|
||||||
"@aws-sdk/client-kms": "3.1003.0",
|
"@aws-sdk/client-kms": "^3.33.0",
|
||||||
"@aws-sdk/client-s3": "3.1003.0",
|
"@aws-sdk/client-s3": "^3.33.0",
|
||||||
"@biomejs/biome": "^1.7.3",
|
"@biomejs/biome": "^1.7.3",
|
||||||
"@jest/globals": "^29.7.0",
|
"@jest/globals": "^29.7.0",
|
||||||
"@napi-rs/cli": "3.5.1",
|
"@napi-rs/cli": "^3.5.1",
|
||||||
"@types/axios": "^0.14.0",
|
"@types/axios": "^0.14.0",
|
||||||
"@types/jest": "^29.1.2",
|
"@types/jest": "^29.1.2",
|
||||||
"@types/node": "22.7.4",
|
"@types/node": "^22.7.4",
|
||||||
"@types/tmp": "^0.2.6",
|
"@types/tmp": "^0.2.6",
|
||||||
"apache-arrow-15": "npm:apache-arrow@15.0.0",
|
"apache-arrow-15": "npm:apache-arrow@15.0.0",
|
||||||
"apache-arrow-16": "npm:apache-arrow@16.0.0",
|
"apache-arrow-16": "npm:apache-arrow@16.0.0",
|
||||||
@@ -57,9 +57,9 @@
|
|||||||
"shx": "^0.3.4",
|
"shx": "^0.3.4",
|
||||||
"tmp": "^0.2.3",
|
"tmp": "^0.2.3",
|
||||||
"ts-jest": "^29.1.2",
|
"ts-jest": "^29.1.2",
|
||||||
"typedoc": "0.26.4",
|
"typedoc": "^0.26.4",
|
||||||
"typedoc-plugin-markdown": "4.2.1",
|
"typedoc-plugin-markdown": "^4.2.1",
|
||||||
"typescript": "5.5.4",
|
"typescript": "^5.5.4",
|
||||||
"typescript-eslint": "^7.1.0"
|
"typescript-eslint": "^7.1.0"
|
||||||
},
|
},
|
||||||
"ava": {
|
"ava": {
|
||||||
@@ -68,16 +68,16 @@
|
|||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 18"
|
"node": ">= 18"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@11.1.1",
|
|
||||||
"cpu": ["x64", "arm64"],
|
"cpu": ["x64", "arm64"],
|
||||||
"os": ["darwin", "linux", "win32"],
|
"os": ["darwin", "linux", "win32"],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"artifacts": "napi artifacts",
|
"artifacts": "napi artifacts",
|
||||||
"build:debug": "napi build --platform --dts ../lancedb/native.d.ts --js ../lancedb/native.js --output-dir lancedb",
|
"build:debug": "napi build --platform --dts ../lancedb/native.d.ts --js ../lancedb/native.js --output-dir lancedb",
|
||||||
"postbuild:debug": "shx mkdir -p dist && shx cp lancedb/*.node dist/ && node -e \"require('fs').writeFileSync('dist/package.json', JSON.stringify({name:'@lancedb/lancedb',type:'commonjs'}))\"",
|
"postbuild:debug": "shx mkdir -p dist && shx cp lancedb/*.node dist/",
|
||||||
"build:release": "napi build --platform --release --dts ../lancedb/native.d.ts --js ../lancedb/native.js --output-dir dist",
|
"build:release": "napi build --platform --release --dts ../lancedb/native.d.ts --js ../lancedb/native.js --output-dir dist",
|
||||||
"build": "pnpm build:debug && pnpm tsc",
|
"postbuild:release": "shx mkdir -p dist && shx cp lancedb/*.node dist/",
|
||||||
"build-release": "pnpm build:release && pnpm tsc",
|
"build": "npm run build:debug && npm run tsc",
|
||||||
|
"build-release": "npm run build:release && npm run tsc",
|
||||||
"tsc": "tsc -b",
|
"tsc": "tsc -b",
|
||||||
"posttsc": "shx cp lancedb/native.d.ts dist/native.d.ts",
|
"posttsc": "shx cp lancedb/native.d.ts dist/native.d.ts",
|
||||||
"lint-ci": "biome ci .",
|
"lint-ci": "biome ci .",
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
"lint-fix": "biome check --write . && biome format --write .",
|
"lint-fix": "biome check --write . && biome format --write .",
|
||||||
"prepublishOnly": "napi prepublish -t npm",
|
"prepublishOnly": "napi prepublish -t npm",
|
||||||
"test": "jest --verbose",
|
"test": "jest --verbose",
|
||||||
"integration": "S3_TEST=1 pnpm test",
|
"integration": "S3_TEST=1 npm run test",
|
||||||
"universal": "napi universalize",
|
"universal": "napi universalize",
|
||||||
"version": "napi version"
|
"version": "napi version"
|
||||||
},
|
},
|
||||||
@@ -95,8 +95,8 @@
|
|||||||
"reflect-metadata": "^0.2.2"
|
"reflect-metadata": "^0.2.2"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@huggingface/transformers": "3.0.2",
|
"@huggingface/transformers": "^3.0.2",
|
||||||
"openai": "4.29.2"
|
"openai": "^4.29.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"apache-arrow": ">=15.0.0 <=18.1.0"
|
"apache-arrow": ">=15.0.0 <=18.1.0"
|
||||||
|
|||||||
7317
nodejs/pnpm-lock.yaml
generated
7317
nodejs/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,18 +0,0 @@
|
|||||||
# Flat node_modules layout. The @napi-rs/cli build step fails to locate
|
|
||||||
# the cdylib artifact under pnpm's isolated layout; the hoisted linker
|
|
||||||
# mirrors npm's structure and unblocks the native build.
|
|
||||||
nodeLinker: hoisted
|
|
||||||
|
|
||||||
# Block resolution of versions less than 24h old (Shai-Hulud window).
|
|
||||||
# This is the pnpm 11 default but pinned here so it's visible to
|
|
||||||
# reviewers and survives a future pnpm major flipping the default.
|
|
||||||
minimumReleaseAge: 1440
|
|
||||||
|
|
||||||
# Fail install if a transitive dep tries to run an unapproved script.
|
|
||||||
strictDepBuilds: true
|
|
||||||
|
|
||||||
allowBuilds:
|
|
||||||
'@biomejs/biome': true
|
|
||||||
onnxruntime-node: true
|
|
||||||
protobufjs: true
|
|
||||||
sharp: true
|
|
||||||
@@ -8,16 +8,12 @@ use lancedb::database::{CreateTableMode, Database};
|
|||||||
use napi::bindgen_prelude::*;
|
use napi::bindgen_prelude::*;
|
||||||
use napi_derive::*;
|
use napi_derive::*;
|
||||||
|
|
||||||
use crate::ConnectNamespaceOptions;
|
|
||||||
use crate::ConnectionOptions;
|
use crate::ConnectionOptions;
|
||||||
use crate::error::NapiErrorExt;
|
use crate::error::NapiErrorExt;
|
||||||
use crate::header::JsHeaderProvider;
|
use crate::header::JsHeaderProvider;
|
||||||
use crate::table::Table;
|
use crate::table::Table;
|
||||||
use lancedb::connection::{ConnectBuilder, Connection as LanceDBConnection, connect_namespace};
|
use lancedb::connection::{ConnectBuilder, Connection as LanceDBConnection};
|
||||||
|
|
||||||
use lance_namespace::models::{
|
|
||||||
CreateNamespaceRequest, DescribeNamespaceRequest, DropNamespaceRequest, ListNamespacesRequest,
|
|
||||||
};
|
|
||||||
use lancedb::ipc::{ipc_file_to_batches, ipc_file_to_schema};
|
use lancedb::ipc::{ipc_file_to_batches, ipc_file_to_schema};
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
@@ -25,29 +21,6 @@ pub struct Connection {
|
|||||||
inner: Option<LanceDBConnection>,
|
inner: Option<LanceDBConnection>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[napi(object)]
|
|
||||||
pub struct DescribeNamespaceResponse {
|
|
||||||
pub properties: Option<HashMap<String, String>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[napi(object)]
|
|
||||||
pub struct ListNamespacesResponse {
|
|
||||||
pub namespaces: Vec<String>,
|
|
||||||
pub page_token: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[napi(object)]
|
|
||||||
pub struct CreateNamespaceResponse {
|
|
||||||
pub properties: Option<HashMap<String, String>>,
|
|
||||||
pub transaction_id: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[napi(object)]
|
|
||||||
pub struct DropNamespaceResponse {
|
|
||||||
pub properties: Option<HashMap<String, String>>,
|
|
||||||
pub transaction_id: Option<Vec<String>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
pub(crate) fn inner_new(inner: LanceDBConnection) -> Self {
|
pub(crate) fn inner_new(inner: LanceDBConnection) -> Self {
|
||||||
Self { inner: Some(inner) }
|
Self { inner: Some(inner) }
|
||||||
@@ -94,12 +67,6 @@ impl Connection {
|
|||||||
builder = builder.storage_option(key, value);
|
builder = builder.storage_option(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(manifest_enabled) = options.manifest_enabled {
|
|
||||||
builder = builder.manifest_enabled(manifest_enabled);
|
|
||||||
}
|
|
||||||
if let Some(namespace_client_properties) = options.namespace_client_properties {
|
|
||||||
builder = builder.namespace_client_properties(namespace_client_properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create client config, optionally with header provider
|
// Create client config, optionally with header provider
|
||||||
let client_config = options.client_config.unwrap_or_default();
|
let client_config = options.client_config.unwrap_or_default();
|
||||||
@@ -133,39 +100,6 @@ impl Connection {
|
|||||||
Ok(Self::inner_new(builder.execute().await.default_error()?))
|
Ok(Self::inner_new(builder.execute().await.default_error()?))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new Connection instance backed by a namespace implementation.
|
|
||||||
#[napi(factory)]
|
|
||||||
pub async fn new_with_namespace(
|
|
||||||
impl_name: String,
|
|
||||||
properties: HashMap<String, String>,
|
|
||||||
options: ConnectNamespaceOptions,
|
|
||||||
) -> napi::Result<Self> {
|
|
||||||
if impl_name.is_empty() {
|
|
||||||
return Err(napi::Error::from_reason(
|
|
||||||
"implName must be a non-empty string",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut builder = connect_namespace(&impl_name, properties);
|
|
||||||
if let Some(interval) = options.read_consistency_interval {
|
|
||||||
builder =
|
|
||||||
builder.read_consistency_interval(std::time::Duration::from_secs_f64(interval));
|
|
||||||
}
|
|
||||||
if let Some(storage_options) = options.storage_options {
|
|
||||||
for (key, value) in storage_options {
|
|
||||||
builder = builder.storage_option(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Some(namespace_client_properties) = options.namespace_client_properties {
|
|
||||||
builder = builder.namespace_client_properties(namespace_client_properties);
|
|
||||||
}
|
|
||||||
if let Some(session) = options.session {
|
|
||||||
builder = builder.session(session.inner.clone());
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Self::inner_new(builder.execute().await.default_error()?))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
pub fn display(&self) -> napi::Result<String> {
|
pub fn display(&self) -> napi::Result<String> {
|
||||||
Ok(self.get_inner()?.to_string())
|
Ok(self.get_inner()?.to_string())
|
||||||
@@ -333,149 +267,4 @@ impl Connection {
|
|||||||
let ns = namespace_path.unwrap_or_default();
|
let ns = namespace_path.unwrap_or_default();
|
||||||
self.get_inner()?.drop_all_tables(&ns).await.default_error()
|
self.get_inner()?.drop_all_tables(&ns).await.default_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[napi(catch_unwind)]
|
|
||||||
/// Describe a namespace and return its properties.
|
|
||||||
pub async fn describe_namespace(
|
|
||||||
&self,
|
|
||||||
namespace_path: Vec<String>,
|
|
||||||
) -> napi::Result<DescribeNamespaceResponse> {
|
|
||||||
let req = DescribeNamespaceRequest {
|
|
||||||
id: Some(namespace_path),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let resp = self
|
|
||||||
.get_inner()?
|
|
||||||
.describe_namespace(req)
|
|
||||||
.await
|
|
||||||
.default_error()?;
|
|
||||||
Ok(DescribeNamespaceResponse {
|
|
||||||
properties: resp.properties,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[napi(catch_unwind)]
|
|
||||||
/// List child namespaces under the given namespace path
|
|
||||||
pub async fn list_namespaces(
|
|
||||||
&self,
|
|
||||||
namespace_path: Option<Vec<String>>,
|
|
||||||
page_token: Option<String>,
|
|
||||||
limit: Option<u32>,
|
|
||||||
) -> napi::Result<ListNamespacesResponse> {
|
|
||||||
let req = ListNamespacesRequest {
|
|
||||||
id: namespace_path,
|
|
||||||
page_token,
|
|
||||||
limit: limit.map(|l| l as i32),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let resp = self
|
|
||||||
.get_inner()?
|
|
||||||
.list_namespaces(req)
|
|
||||||
.await
|
|
||||||
.default_error()?;
|
|
||||||
Ok(ListNamespacesResponse {
|
|
||||||
namespaces: resp.namespaces,
|
|
||||||
page_token: resp.page_token,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[napi(catch_unwind)]
|
|
||||||
/// Create a new namespace with optional properties.
|
|
||||||
pub async fn create_namespace(
|
|
||||||
&self,
|
|
||||||
namespace_path: Vec<String>,
|
|
||||||
mode: Option<String>,
|
|
||||||
properties: Option<HashMap<String, String>>,
|
|
||||||
) -> napi::Result<CreateNamespaceResponse> {
|
|
||||||
let mode_str = mode
|
|
||||||
.map(|m| match m.to_lowercase().as_str() {
|
|
||||||
"create" => Ok("Create".to_string()),
|
|
||||||
"exist_ok" => Ok("ExistOk".to_string()),
|
|
||||||
"overwrite" => Ok("Overwrite".to_string()),
|
|
||||||
_ => Err(napi::Error::from_reason(format!(
|
|
||||||
"Invalid mode '{}': expected one of 'create', 'exist_ok', 'overwrite'",
|
|
||||||
m
|
|
||||||
))),
|
|
||||||
})
|
|
||||||
.transpose()?;
|
|
||||||
let req = CreateNamespaceRequest {
|
|
||||||
id: Some(namespace_path),
|
|
||||||
mode: mode_str,
|
|
||||||
properties,
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let resp = self
|
|
||||||
.get_inner()?
|
|
||||||
.create_namespace(req)
|
|
||||||
.await
|
|
||||||
.default_error()?;
|
|
||||||
Ok(CreateNamespaceResponse {
|
|
||||||
properties: resp.properties,
|
|
||||||
transaction_id: resp.transaction_id,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[napi(catch_unwind)]
|
|
||||||
/// Drop a namespace.
|
|
||||||
pub async fn drop_namespace(
|
|
||||||
&self,
|
|
||||||
namespace_path: Vec<String>,
|
|
||||||
mode: Option<String>,
|
|
||||||
behavior: Option<String>,
|
|
||||||
) -> napi::Result<DropNamespaceResponse> {
|
|
||||||
let mode_str = mode
|
|
||||||
.map(|m| match m.to_lowercase().as_str() {
|
|
||||||
"skip" => Ok("Skip".to_string()),
|
|
||||||
"fail" => Ok("Fail".to_string()),
|
|
||||||
_ => Err(napi::Error::from_reason(format!(
|
|
||||||
"Invalid mode '{}': expected one of 'skip', 'fail'",
|
|
||||||
m
|
|
||||||
))),
|
|
||||||
})
|
|
||||||
.transpose()?;
|
|
||||||
let behavior_str = behavior
|
|
||||||
.map(|b| match b.to_lowercase().as_str() {
|
|
||||||
"restrict" => Ok("Restrict".to_string()),
|
|
||||||
"cascade" => Ok("Cascade".to_string()),
|
|
||||||
_ => Err(napi::Error::from_reason(format!(
|
|
||||||
"Invalid behavior '{}': expected one of 'restrict', 'cascade'",
|
|
||||||
b
|
|
||||||
))),
|
|
||||||
})
|
|
||||||
.transpose()?;
|
|
||||||
let req = DropNamespaceRequest {
|
|
||||||
id: Some(namespace_path),
|
|
||||||
mode: mode_str,
|
|
||||||
behavior: behavior_str,
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let resp = self
|
|
||||||
.get_inner()?
|
|
||||||
.drop_namespace(req)
|
|
||||||
.await
|
|
||||||
.default_error()?;
|
|
||||||
Ok(DropNamespaceResponse {
|
|
||||||
properties: resp.properties,
|
|
||||||
transaction_id: resp.transaction_id,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Rename a table. `current_namespace_path` and `new_namespace_path` default to
|
|
||||||
/// the root namespace when omitted; the caller is expected to either pass both
|
|
||||||
/// or pass neither.
|
|
||||||
#[napi(catch_unwind)]
|
|
||||||
pub async fn rename_table(
|
|
||||||
&self,
|
|
||||||
current_name: String,
|
|
||||||
new_name: String,
|
|
||||||
current_namespace_path: Option<Vec<String>>,
|
|
||||||
new_namespace_path: Option<Vec<String>>,
|
|
||||||
) -> napi::Result<()> {
|
|
||||||
let cur_ns = current_namespace_path.unwrap_or_default();
|
|
||||||
let new_ns = new_namespace_path.unwrap_or_default();
|
|
||||||
self.get_inner()?
|
|
||||||
.rename_table(¤t_name, &new_name, &cur_ns, &new_ns)
|
|
||||||
.await
|
|
||||||
.default_error()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user