-
Couldn't load subscription status.
- Fork 3.4k
Add Lance connector #26987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
luohao
wants to merge
3
commits into
trinodb:master
Choose a base branch
from
luohao:hluo/lance-init-pr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Lance connector #26987
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Lance connector | ||
|
|
||
| ## General configuration | ||
|
|
||
| To configure the Lance connector, create a catalog properties file `etc/catalog/example.properties` with the following content | ||
|
|
||
| ```text | ||
| connector.name=lance | ||
| ``` | ||
|
|
||
| You must configure a [namespace](https://lancedb.github.io/lance/format/namespace/) type. | ||
| Currently only [directory namespace](https://lancedb.github.io/lance/format/namespace/impls/dir/) is supported. | ||
|
|
||
| ```text | ||
| lance.namespace.type=directory | ||
| ``` | ||
|
|
||
| ## Lance Namespace configuration | ||
| ### Directory namespace | ||
| Lance directory namespace is a lightweight and simple single-level Lance namespace that contains only a list of tables. All tables reside in the default namespace. | ||
|
|
||
| The following configuration properties are available: | ||
|
|
||
| :::{list-table} | ||
| :widths: 30, 10, 60 | ||
| :header-rows: 1 | ||
|
|
||
| * - Property name | ||
| - Required | ||
| - Description | ||
| * - `lance.namespace.directory.warehouse.location` | ||
| - Yes | ||
| - The root directory URI of the namespace where tables are stored. | ||
| ::: | ||
|
|
||
|
|
||
| ## File system access configuration | ||
|
|
||
| The connector supports accessing the following file systems: | ||
|
|
||
| * [](/object-storage/file-system-azure) | ||
| * [](/object-storage/file-system-gcs) | ||
| * [](/object-storage/file-system-s3) | ||
| * [](/object-storage/file-system-hdfs) | ||
|
|
||
| You must enable and configure the specific file system access. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-root</artifactId> | ||
| <version>478-SNAPSHOT</version> | ||
| <relativePath>../../pom.xml</relativePath> | ||
| </parent> | ||
|
|
||
| <artifactId>trino-lance-file</artifactId> | ||
| <description>Trino - Lance file format</description> | ||
|
|
||
| <properties> | ||
| <air.compiler.fail-warnings>true</air.compiler.fail-warnings> | ||
| <air.test.jvm.additional-arguments>${air.test.jvm.additional-arguments.default} | ||
| --add-opens=java.base/java.nio=ALL-UNNAMED | ||
| --sun-misc-unsafe-memory-access=allow</air.test.jvm.additional-arguments> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>build.buf.gen</groupId> | ||
| <artifactId>lancedb_lance_protocolbuffers_java</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.google.errorprone</groupId> | ||
| <artifactId>error_prone_annotations</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.google.guava</groupId> | ||
| <artifactId>guava</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.google.protobuf</groupId> | ||
| <artifactId>protobuf-java</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.github.luohao</groupId> | ||
| <artifactId>fastlanes-java</artifactId> | ||
| <version>1</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-filesystem</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-memory-context</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-plugin-toolkit</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>it.unimi.dsi</groupId> | ||
| <artifactId>fastutil</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>jakarta.annotation</groupId> | ||
| <artifactId>jakarta.annotation-api</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.airlift</groupId> | ||
| <artifactId>slice</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-spi</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.openjdk.jol</groupId> | ||
| <artifactId>jol-core</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.lancedb</groupId> | ||
| <artifactId>lance-core</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.airlift</groupId> | ||
| <artifactId>junit-extensions</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-main</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-testing-services</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.apache.arrow</groupId> | ||
| <artifactId>arrow-memory-core</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.apache.arrow</groupId> | ||
| <artifactId>arrow-vector</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.apache.calcite.avatica</groupId> | ||
| <artifactId>avatica-core</artifactId> | ||
| <version>1.25.0</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.assertj</groupId> | ||
| <artifactId>assertj-core</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-api</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-engine</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.openjdk.jmh</groupId> | ||
| <artifactId>jmh-core</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.openjdk.jmh</groupId> | ||
| <artifactId>jmh-generator-annprocess</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <repositories> | ||
| <repository> | ||
| <releases> | ||
| <enabled>true</enabled> | ||
| </releases> | ||
| <snapshots> | ||
| <enabled>false</enabled> | ||
| </snapshots> | ||
| <id>buf</id> | ||
| <name>Buf Maven Repository</name> | ||
| <url>https://buf.build/gen/maven</url> | ||
| </repository> | ||
| </repositories> | ||
| </project> | ||
118 changes: 118 additions & 0 deletions
118
lib/trino-lance-file/src/main/java/io/trino/lance/file/AbstractLanceDataSource.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.trino.lance.file; | ||
|
|
||
| import io.airlift.slice.Slice; | ||
| import io.airlift.slice.Slices; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| import static java.lang.Math.min; | ||
| import static java.lang.Math.toIntExact; | ||
| import static java.util.Objects.requireNonNull; | ||
|
|
||
| public abstract class AbstractLanceDataSource | ||
| implements LanceDataSource | ||
| { | ||
| private final LanceDataSourceId id; | ||
| private final long estimatedSize; | ||
| private long readTimeNanos; | ||
| private long readBytes; | ||
|
|
||
| public AbstractLanceDataSource(LanceDataSourceId id, long estimatedSize) | ||
| { | ||
| this.id = requireNonNull(id, "id is null"); | ||
| this.estimatedSize = estimatedSize; | ||
| } | ||
|
|
||
| @Override | ||
| public LanceDataSourceId getId() | ||
| { | ||
| return id; | ||
| } | ||
|
|
||
| @Override | ||
| public long getReadBytes() | ||
| { | ||
| return readBytes; | ||
| } | ||
|
|
||
| @Override | ||
| public long getReadTimeNanos() | ||
| { | ||
| return readTimeNanos; | ||
| } | ||
|
|
||
| @Override | ||
| public long getEstimatedSize() | ||
| { | ||
| return estimatedSize; | ||
| } | ||
|
|
||
| @Override | ||
| public Slice readTail(int length) | ||
| throws IOException | ||
| { | ||
| long start = System.nanoTime(); | ||
|
|
||
| Slice tailSlice = readTailInternal(length); | ||
|
|
||
| readTimeNanos += System.nanoTime() - start; | ||
| readBytes += tailSlice.length(); | ||
|
|
||
| return tailSlice; | ||
| } | ||
|
|
||
| protected Slice readTailInternal(int length) | ||
| throws IOException | ||
| { | ||
| int readSize = toIntExact(min(estimatedSize, length)); | ||
| return readFully(estimatedSize - readSize, readSize); | ||
| } | ||
|
|
||
| @Override | ||
| public long getRetainedSize() | ||
| { | ||
| return 0; | ||
| } | ||
|
|
||
| @Override | ||
| public final Slice readFully(long position, int length) | ||
| throws IOException | ||
| { | ||
| byte[] buffer = new byte[length]; | ||
| readFully(position, buffer, 0, length); | ||
| return Slices.wrappedBuffer(buffer); | ||
| } | ||
|
|
||
| protected abstract void readInternal(long position, byte[] buffer, int bufferOffset, int bufferLength) | ||
| throws IOException; | ||
|
|
||
| private void readFully(long position, byte[] buffer, int bufferOffset, int bufferLength) | ||
| throws IOException | ||
| { | ||
| long start = System.nanoTime(); | ||
|
|
||
| readInternal(position, buffer, bufferOffset, bufferLength); | ||
|
|
||
| readTimeNanos += System.nanoTime() - start; | ||
| readBytes += bufferLength; | ||
| } | ||
|
|
||
| @Override | ||
| public final String toString() | ||
| { | ||
| return id.toString(); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.