-
Notifications
You must be signed in to change notification settings - Fork 525
feat!: make v2 manifest default #5656
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
wjones127
merged 3 commits into
lance-format:main
from
wojiaodoubao:v2-manifest-default
Jan 14, 2026
Merged
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,115 @@ | ||
| /* | ||
| * 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 org.lance; | ||
|
|
||
| import org.apache.arrow.memory.RootAllocator; | ||
| import org.apache.arrow.vector.types.pojo.ArrowType; | ||
| import org.apache.arrow.vector.types.pojo.Field; | ||
| import org.apache.arrow.vector.types.pojo.Schema; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.io.TempDir; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.regex.Pattern; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| public class ManifestPathsV2Test { | ||
| private static final Pattern V2_MANIFEST_PATTERN = Pattern.compile("\\d{20}\\.manifest"); | ||
|
|
||
| @Test | ||
| void testMigrateManifestPathsFromV1ToV2(@TempDir Path tempDir) throws IOException { | ||
| String datasetPath = tempDir.resolve("testMigrateManifestPathsFromV1ToV2").toString(); | ||
| try (RootAllocator allocator = new RootAllocator(Long.MAX_VALUE)) { | ||
| TestUtils.SimpleTestDataset testDataset = | ||
| new TestUtils.SimpleTestDataset(allocator, datasetPath); | ||
| // Create v1 test. | ||
| try (Dataset dataset = testDataset.createEmptyDataset(false)) { | ||
| Path versionsDir = Paths.get(datasetPath).resolve("_versions"); | ||
| assertTrue(Files.isDirectory(versionsDir), "_versions directory should exist"); | ||
| List<Path> manifestsBefore; | ||
| try (Stream<Path> stream = Files.list(versionsDir)) { | ||
| manifestsBefore = | ||
| stream | ||
| .filter( | ||
| p -> | ||
| Files.isRegularFile(p) | ||
| && p.getFileName().toString().endsWith(".manifest")) | ||
| .collect(Collectors.toList()); | ||
| } | ||
| assertEquals(1, manifestsBefore.size(), "Expected single manifest before migration"); | ||
| assertEquals("1.manifest", manifestsBefore.get(0).getFileName().toString()); | ||
|
|
||
| // Migrate to v2. | ||
| dataset.migrateManifestPathsV2(); | ||
|
|
||
| List<Path> manifestsAfter; | ||
| try (Stream<Path> stream = Files.list(versionsDir)) { | ||
| manifestsAfter = | ||
| stream | ||
| .filter( | ||
| p -> | ||
| Files.isRegularFile(p) | ||
| && p.getFileName().toString().endsWith(".manifest")) | ||
| .collect(Collectors.toList()); | ||
| } | ||
| assertEquals(1, manifestsAfter.size(), "Expected single manifest after migration"); | ||
| String fileName = manifestsAfter.get(0).getFileName().toString(); | ||
| assertTrue( | ||
| V2_MANIFEST_PATTERN.matcher(fileName).matches(), | ||
| "Manifest should use V2 naming scheme"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void testCreateDatasetUsesV2ManifestByDefault(@TempDir Path tempDir) throws IOException { | ||
| String datasetPath = tempDir.resolve("testCreateDatasetUsesV2ManifestByDefault").toString(); | ||
| try (RootAllocator allocator = new RootAllocator(Long.MAX_VALUE)) { | ||
| Schema schema = | ||
| new Schema( | ||
| Arrays.asList( | ||
| Field.nullable("id", new ArrowType.Int(32, true)), | ||
| Field.nullable("name", new ArrowType.Utf8()))); | ||
| WriteParams params = new WriteParams.Builder().withMode(WriteParams.WriteMode.CREATE).build(); | ||
| try (Dataset dataset = Dataset.create(allocator, datasetPath, schema, params)) { | ||
| Path versionsDir = Paths.get(datasetPath).resolve("_versions"); | ||
| assertTrue(Files.isDirectory(versionsDir), "_versions directory should exist"); | ||
| List<Path> manifests; | ||
| try (Stream<Path> stream = Files.list(versionsDir)) { | ||
| manifests = | ||
| stream | ||
| .filter( | ||
| p -> | ||
| Files.isRegularFile(p) | ||
| && p.getFileName().toString().endsWith(".manifest")) | ||
| .collect(Collectors.toList()); | ||
| } | ||
| assertEquals(1, manifests.size(), "Expected single manifest file"); | ||
| String fileName = manifests.get(0).getFileName().toString(); | ||
| assertTrue( | ||
| V2_MANIFEST_PATTERN.matcher(fileName).matches(), | ||
| "Manifest should use V2 naming scheme"); | ||
| } | ||
| } | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
wojiaodoubao marked this conversation as resolved.
Show resolved
Hide resolved
|
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
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.