-
Notifications
You must be signed in to change notification settings - Fork 82
fix: name the index on uncommitted segment builds #793
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
Merged
geruh
merged 3 commits into
lance-format:main
from
ivscheianu:fix/name-index-on-uncommitted-segment-builds
Sep 3, 2026
Merged
Changes from 2 commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -335,6 +335,7 @@ class RangeBasedBTreeIndexJob( | |
|
|
||
| val indexBuilder = RangeBTreeIndexBuilder( | ||
| encode(readOptions), | ||
| addIndexExec.indexName, | ||
| columns, | ||
| zoneSize, | ||
| nsImpl, | ||
|
|
@@ -364,6 +365,7 @@ class RangeBasedBTreeIndexJob( | |
| * This class is serialized and sent to executors to build the index for a specific range of data. | ||
| * | ||
| * @param encodedReadOptions Serialized configuration for Lance dataset access. | ||
| * @param indexName Name of the logical index the segment will belong to. | ||
| * @param columns The names of the columns to be indexed. | ||
| * @param zoneSize Optional size of zones within the B-tree index. | ||
| * @param namespaceImpl Optional implementation class for namespace operations, used for credential vending. | ||
|
|
@@ -374,6 +376,7 @@ class RangeBasedBTreeIndexJob( | |
| */ | ||
| case class RangeBTreeIndexBuilder( | ||
| encodedReadOptions: String, | ||
| indexName: String, | ||
| columns: List[String], | ||
| zoneSize: Option[Long], | ||
| namespaceImpl: Option[String], | ||
|
|
@@ -438,9 +441,10 @@ case class RangeBTreeIndexBuilder( | |
| Data.exportArrayStream(allocator, reader, stream) | ||
|
|
||
| // Build an uncommitted BTree segment for this fragment group from the | ||
| // pre-sorted data. No index name or UUID is set: Lance generates the | ||
| // segment UUID, and the fragment ids declare the segment's coverage so | ||
| // the per-partition segments stay disjoint. | ||
| // pre-sorted data. No UUID is set: Lance generates the segment UUID, and | ||
| // the fragment ids declare the segment's coverage so the per-partition | ||
| // segments stay disjoint. Named and replace-flagged to suppress Lance's | ||
| // collision pre-check against the existing index. | ||
| val btreeParamsBuilder = BTreeIndexParams.builder() | ||
| if (zoneSize.isDefined) { | ||
| btreeParamsBuilder.zoneSize(zoneSize.get) | ||
|
|
@@ -451,7 +455,8 @@ case class RangeBTreeIndexBuilder( | |
|
|
||
| val indexOptions = IndexOptions | ||
| .builder(columns.asJava, IndexType.BTREE, indexParams) | ||
| .replace(false) | ||
| .withIndexName(indexName) | ||
| .replace(true) | ||
| .withFragmentIds(fragmentIds.toList.asJava) | ||
| .withPreprocessedData(stream) | ||
| .build() | ||
|
|
@@ -498,6 +503,7 @@ class ScalarSegmentIndexJob( | |
| val tasks = fragmentBatches.map { batch => | ||
| ScalarSegmentIndexTask( | ||
| encodedReadOptions, | ||
| addIndexExec.indexName, | ||
| columns, | ||
| addIndexExec.method, | ||
| argsJson, | ||
|
|
@@ -519,10 +525,13 @@ class ScalarSegmentIndexJob( | |
| final private[v2] case class FragmentWorkload(fragmentId: Integer, numRows: Long) | ||
|
|
||
| /** | ||
| * A task to create a scalar index segment on a batch of fragments. | ||
| * A task to create a scalar index segment on a batch of fragments. Named after the logical index | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we can drop the change here. the comment is enough for me to follow |
||
| * and replace-flagged to suppress Lance's collision pre-check against the existing index; actual | ||
| * replacement is handled by the driver's {@code commitExistingIndexSegments} transaction. | ||
| */ | ||
| case class ScalarSegmentIndexTask( | ||
| encodedReadOptions: String, | ||
| indexName: String, | ||
| columns: List[String], | ||
| method: String, | ||
| argsJson: String, | ||
|
|
@@ -545,8 +554,9 @@ case class ScalarSegmentIndexTask( | |
|
|
||
| val indexOptions = IndexOptions | ||
| .builder(java.util.Arrays.asList(columns: _*), indexType, params) | ||
| .withIndexName(indexName) | ||
| .withFragmentIds(fragmentIds.asJava) | ||
| .replace(false) | ||
| .replace(true) | ||
| .build() | ||
|
|
||
| val dataset = Utils.openDatasetBuilder(readOptions) | ||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we clean this comment up while we are here we don't have to leave the story there. wdyt just something like:
// replace is for Lance's name check, and the driver commit still publishes.