-
Notifications
You must be signed in to change notification settings - Fork 3k
API, Core: Introduce foundational types for V4 manifest support #15049
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
anoopj
wants to merge
4
commits into
apache:main
Choose a base branch
from
anoopj:v4-foundational-types
base: main
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.
+555
−2
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a198a12
Introduces foundational types for V4 manifest support
anoopj cf2958c
Change asDataFile/asDeleteFile to no-argument API
anoopj 3ab0b30
Incorporate feedback from Ryan
anoopj 67c20b6
Update TrackedFile.contentStats() to return ContentStats
anoopj 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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.apache.iceberg; | ||
|
|
||
| import org.apache.iceberg.types.Types; | ||
|
|
||
| /** | ||
| * Metadata about externally stored content such as deletion vectors. | ||
| * | ||
| * <p>The deletion vector content is stored at the specified offset and size within the file | ||
| * referenced by {@link TrackedFile#location()}. | ||
| * | ||
| * <p>This struct must be defined when content_type is POSITION_DELETES, and must be null otherwise. | ||
| * | ||
| * <p>Note: For manifest-level deletion vectors (marking entries in a manifest as deleted), see | ||
| * {@link TrackedFile#manifestDV()} which stores the DV inline as a binary field. | ||
| */ | ||
| interface ContentInfo { | ||
| Types.NestedField OFFSET = | ||
| Types.NestedField.required( | ||
| 144, "offset", Types.LongType.get(), "Offset in the file where the content starts"); | ||
| Types.NestedField SIZE_IN_BYTES = | ||
| Types.NestedField.required( | ||
| 145, | ||
| "size_in_bytes", | ||
| Types.LongType.get(), | ||
| "Length of the referenced content stored in the file"); | ||
|
|
||
| static Types.StructType schema() { | ||
| return Types.StructType.of(OFFSET, SIZE_IN_BYTES); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the offset in the file where the deletion vector content starts. | ||
| * | ||
| * <p>The file location is specified in the {@link TrackedFile#location()} field. | ||
| */ | ||
| long offset(); | ||
|
|
||
| /** Returns the size in bytes of the deletion vector content. */ | ||
| long sizeInBytes(); | ||
| } |
41 changes: 41 additions & 0 deletions
41
core/src/main/java/org/apache/iceberg/ManifestEntryStatus.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,41 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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.apache.iceberg; | ||
|
|
||
| /** | ||
| * Status of an entry in a manifest file. | ||
| * | ||
| * <p>This is a top-level enum to avoid duplication across manifest entry types (V3 ManifestEntry | ||
| * and V4 TrackingInfo). | ||
| */ | ||
| public enum ManifestEntryStatus { | ||
| EXISTING(0), | ||
| ADDED(1), | ||
| DELETED(2); | ||
|
|
||
| private final int id; | ||
|
|
||
| ManifestEntryStatus(int id) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public int id() { | ||
| return id; | ||
| } | ||
| } |
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,86 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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.apache.iceberg; | ||
|
|
||
| import org.apache.iceberg.types.Types; | ||
|
|
||
| /** | ||
| * Statistics for manifest entries in a V4 tracked file. | ||
| * | ||
| * <p>This encapsulates added/removed/existing files/row counts and min_sequence_number for a | ||
| * manifest. This must be defined when the content_type is a manifest (3 or 4), and null otherwise. | ||
| */ | ||
| interface ManifestStats { | ||
| Types.NestedField ADDED_FILES_COUNT = | ||
| Types.NestedField.required( | ||
| 504, "added_files_count", Types.IntegerType.get(), "Number of files added"); | ||
| Types.NestedField EXISTING_FILES_COUNT = | ||
| Types.NestedField.required( | ||
| 505, "existing_files_count", Types.IntegerType.get(), "Number of existing files"); | ||
| Types.NestedField DELETED_FILES_COUNT = | ||
| Types.NestedField.required( | ||
| 506, "deleted_files_count", Types.IntegerType.get(), "Number of deleted files"); | ||
| Types.NestedField ADDED_ROWS_COUNT = | ||
| Types.NestedField.required( | ||
| 512, "added_rows_count", Types.LongType.get(), "Number of rows in added files"); | ||
| Types.NestedField EXISTING_ROWS_COUNT = | ||
| Types.NestedField.required( | ||
| 513, "existing_rows_count", Types.LongType.get(), "Number of rows in existing files"); | ||
| Types.NestedField DELETED_ROWS_COUNT = | ||
| Types.NestedField.required( | ||
| 514, "deleted_rows_count", Types.LongType.get(), "Number of rows in deleted files"); | ||
| Types.NestedField MIN_SEQUENCE_NUMBER = | ||
| Types.NestedField.required( | ||
| 516, | ||
| "min_sequence_number", | ||
| Types.LongType.get(), | ||
| "Minimum sequence number of files in this manifest"); | ||
|
|
||
| static Types.StructType schema() { | ||
| return Types.StructType.of( | ||
| ADDED_FILES_COUNT, | ||
| EXISTING_FILES_COUNT, | ||
| DELETED_FILES_COUNT, | ||
| ADDED_ROWS_COUNT, | ||
| EXISTING_ROWS_COUNT, | ||
| DELETED_ROWS_COUNT, | ||
| MIN_SEQUENCE_NUMBER); | ||
| } | ||
|
|
||
| /** Returns the number of files added by this manifest. */ | ||
| int addedFilesCount(); | ||
|
|
||
| /** Returns the number of existing files referenced by this manifest. */ | ||
| int existingFilesCount(); | ||
|
|
||
| /** Returns the number of deleted files in this manifest. */ | ||
| int deletedFilesCount(); | ||
|
|
||
| /** Returns the number of rows in added files. */ | ||
| long addedRowsCount(); | ||
|
|
||
| /** Returns the number of rows in existing files. */ | ||
| long existingRowsCount(); | ||
|
|
||
| /** Returns the number of rows in deleted files. */ | ||
| long deletedRowsCount(); | ||
|
|
||
| /** Returns the minimum sequence number of files in this manifest. */ | ||
| long minSequenceNumber(); | ||
| } |
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.
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.
I had to make this API change so that TrackingInfo can return the contentType. This is backward compatible since this is a new enum value. If we don't want to make any API changes, I will need to change
TrackingInfo.contentType()to return anintinstead.