-
Notifications
You must be signed in to change notification settings - Fork 635
feat: expose branch_identifier in python and java bindings #6360
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
Changes from all commits
681c769
6123bc8
4da58bb
5b8cf09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,27 +14,78 @@ | |
| package org.lance; | ||
|
|
||
| import com.google.common.base.MoreObjects; | ||
| import com.google.common.collect.ImmutableList; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Objects; | ||
| import java.util.Optional; | ||
|
|
||
| /** | ||
| * Branch metadata aligned with Rust's BranchContents. name is the branch name, parentBranch may be | ||
| * null (indicating main), parentVersion is the version on which the branch was created, createAt is | ||
| * the unix timestamp (seconds), and manifestSize is the size of the referenced manifest file in | ||
| * bytes. | ||
| * null (indicating main), branchIdentifier is the lineage chain {@code [(version, uuid), ...]}, | ||
| * parentVersion is the version on which the branch was created, createAt is the unix timestamp | ||
| * (seconds), and manifestSize is the size of the referenced manifest file in bytes. | ||
| */ | ||
| public class Branch { | ||
| /** A single lineage hop in the Rust BranchIdentifier.version_mapping vector. */ | ||
| public static class BranchVersionMapping { | ||
| private final long version; | ||
| private final String uuid; | ||
|
|
||
| public BranchVersionMapping(long version, String uuid) { | ||
| this.version = version; | ||
| this.uuid = Objects.requireNonNull(uuid); | ||
| } | ||
|
|
||
| public long getVersion() { | ||
| return version; | ||
| } | ||
|
|
||
| public String getUuid() { | ||
| return uuid; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return MoreObjects.toStringHelper(this).add("version", version).add("uuid", uuid).toString(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) return true; | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| BranchVersionMapping that = (BranchVersionMapping) o; | ||
| return version == that.version && Objects.equals(uuid, that.uuid); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(version, uuid); | ||
| } | ||
| } | ||
|
|
||
| private final String name; | ||
| private final Optional<String> parentBranch; | ||
| private final ImmutableList<BranchVersionMapping> branchIdentifier; | ||
| private final long parentVersion; | ||
| private final long createAt; | ||
| private final int manifestSize; | ||
|
|
||
| public Branch( | ||
| String name, String parentBranch, long parentVersion, long createAt, int manifestSize) { | ||
| this(name, parentBranch, ImmutableList.of(), parentVersion, createAt, manifestSize); | ||
| } | ||
|
|
||
| public Branch( | ||
| String name, | ||
| String parentBranch, | ||
| List<BranchVersionMapping> branchIdentifier, | ||
| long parentVersion, | ||
| long createAt, | ||
| int manifestSize) { | ||
| this.name = name; | ||
| this.parentBranch = Optional.ofNullable(parentBranch); | ||
| this.branchIdentifier = ImmutableList.copyOf(Objects.requireNonNull(branchIdentifier)); | ||
| this.parentVersion = parentVersion; | ||
| this.createAt = createAt; | ||
| this.manifestSize = manifestSize; | ||
|
|
@@ -48,6 +99,10 @@ public Optional<String> getParentBranch() { | |
| return parentBranch; | ||
| } | ||
|
|
||
| public ImmutableList<BranchVersionMapping> getBranchIdentifier() { | ||
| return branchIdentifier; | ||
| } | ||
|
|
||
| public long getParentVersion() { | ||
| return parentVersion; | ||
| } | ||
|
|
@@ -65,6 +120,7 @@ public String toString() { | |
| return MoreObjects.toStringHelper(this) | ||
| .add("name", name) | ||
| .add("parentBranch", parentBranch) | ||
| .add("branchIdentifier", branchIdentifier) | ||
| .add("parentVersion", parentVersion) | ||
| .add("createAt", createAt) | ||
| .add("manifestSize", manifestSize) | ||
|
|
@@ -80,11 +136,13 @@ public boolean equals(Object o) { | |
| && createAt == branch.createAt | ||
| && manifestSize == branch.manifestSize | ||
| && Objects.equals(name, branch.name) | ||
| && Objects.equals(parentBranch, branch.parentBranch); | ||
| && Objects.equals(parentBranch, branch.parentBranch) | ||
| && Objects.equals(branchIdentifier, branch.branchIdentifier); | ||
|
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.
Including Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(name, parentBranch, parentVersion, createAt, manifestSize); | ||
| return Objects.hash( | ||
| name, parentBranch, branchIdentifier, parentVersion, createAt, manifestSize); | ||
| } | ||
| } | ||
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.
This change removes the only public
Branch(String, String, long, long, int)constructor and replaces it with a new signature that requiresList<BranchVersionMapping>, which is a source/binary incompatible API break for downstream Java users who instantiateBranchdirectly. After upgrading, existing callers will fail to compile (or hitNoSuchMethodErrorwhen artifacts are mixed). Please keep the old constructor as an overload and delegate to the new one with a default lineage list to maintain compatibility.Useful? React with 👍 / 👎.