-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
486 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright (c) 2023. Lance Developers | ||
# | ||
# 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. | ||
|
||
from typing import Optional, TypedDict | ||
|
||
# Re-exported from native module. See src/dataset/optimize.rs for implementation. | ||
from .lance import Compaction as Compaction | ||
from .lance import CompactionMetrics as CompactionMetrics | ||
from .lance import CompactionTask as CompactionTask | ||
from .lance import RewriteResult as RewriteResult | ||
|
||
|
||
class CompactionOptions(TypedDict): | ||
"""Options for compaction.""" | ||
|
||
target_rows_per_fragment: Optional[int] | ||
""" | ||
The target number of rows per fragment. This is the number of rows | ||
that will be in each fragment after compaction. (default: 1024*1024) | ||
""" | ||
max_rows_per_group: Optional[int] | ||
""" | ||
Max number of rows per group. This does not affect which fragments | ||
need compaction, but does affect how they are re-written if selected. | ||
(default: 1024) | ||
""" | ||
materialize_deletions: Optional[bool] | ||
""" | ||
Whether to compact fragments with soft deleted rows so they are no | ||
longer present in the file. (default: True) | ||
""" | ||
materialize_deletions_threadhold: Optional[float] | ||
""" | ||
The fraction of original rows that are soft deleted in a fragment | ||
before the fragment is a candidate for compaction. | ||
(default: 0.1 = 10%) | ||
""" | ||
num_threads: Optional[int] | ||
""" | ||
The number of threads to use when performing compaction. If not | ||
specified, defaults to the number of cores on the machine. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from typing import List | ||
|
||
from lance import Dataset | ||
from lance.fragment import FragmentMetadata | ||
from lance.optimize import CompactionOptions | ||
|
||
class CompactionMetrics: | ||
fragments_removed: int | ||
fragments_added: int | ||
files_removed: int | ||
files_added: int | ||
|
||
class RewriteResult: | ||
read_version: int | ||
metrics: CompactionMetrics | ||
old_fragments: List["FragmentMetadata"] | ||
new_fragments: List["FragmentMetadata"] | ||
|
||
class CompactionTask: | ||
read_version: int | ||
fragments: List["FragmentMetadata"] | ||
|
||
def execute(self, dataset: "Dataset") -> RewriteResult: ... | ||
|
||
class CompactionPlan: | ||
read_version: int | ||
tasks: List[CompactionTask] | ||
|
||
def num_tasks(self) -> int: ... | ||
|
||
class Compaction: | ||
@staticmethod | ||
def execute( | ||
dataset: "Dataset", options: CompactionOptions | ||
) -> CompactionMetrics: ... | ||
@staticmethod | ||
def plan(dataset: "Dataset", options: CompactionOptions) -> CompactionPlan: ... | ||
@staticmethod | ||
def commit( | ||
dataset: "Dataset", rewrites: List[RewriteResult] | ||
) -> CompactionMetrics: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.