Skip to content

Commit 55559ee

Browse files
committed
fix(bindings): stabilize refs listing and branch metadata
1 parent 3413362 commit 55559ee

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

java/lance-jni/src/blocking_dataset.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,14 +2374,15 @@ fn inner_list_tags<'local>(
23742374
env: &mut JNIEnv<'local>,
23752375
java_dataset: JObject,
23762376
) -> Result<JObject<'local>> {
2377-
let tag_map = {
2377+
let mut tags: Vec<_> = {
23782378
let dataset_guard =
23792379
unsafe { env.get_rust_field::<_, _, BlockingDataset>(java_dataset, NATIVE_DATASET) }?;
2380-
dataset_guard.list_tags()?
2380+
dataset_guard.list_tags()?.into_iter().collect()
23812381
};
2382+
tags.sort_unstable_by(|(left_name, _), (right_name, _)| left_name.cmp(right_name));
23822383
let array_list = env.new_object("java/util/ArrayList", "()V", &[])?;
23832384

2384-
for (tag_name, tag_contents) in tag_map {
2385+
for (tag_name, tag_contents) in tags {
23852386
let branch_name: JObject = if let Some(branch_name) = tag_contents.branch.as_ref() {
23862387
env.new_string(branch_name)?.into()
23872388
} else {
@@ -2544,11 +2545,12 @@ fn inner_list_branches<'local>(
25442545
env: &mut JNIEnv<'local>,
25452546
java_dataset: JObject,
25462547
) -> Result<JObject<'local>> {
2547-
let branches = {
2548+
let mut branches: Vec<_> = {
25482549
let dataset_guard =
25492550
unsafe { env.get_rust_field::<_, _, BlockingDataset>(java_dataset, NATIVE_DATASET) }?;
2550-
dataset_guard.list_branches()?
2551+
dataset_guard.list_branches()?.into_iter().collect()
25512552
};
2553+
branches.sort_unstable_by(|(left_name, _), (right_name, _)| left_name.cmp(right_name));
25522554
let array_list = env.new_object("java/util/ArrayList", "()V", &[])?;
25532555

25542556
for (name, contents) in branches {

python/python/tests/test_dataset.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5278,6 +5278,9 @@ def test_branches(tmp_path: Path):
52785278
assert b1_meta["manifest_size"] > 0
52795279
assert "create_at" in b1_meta
52805280
assert b1_meta["metadata"] == "branch one"
5281+
ordered_branches = dict(ds_main.branches.list_ordered())
5282+
assert ordered_branches["branch1"]["metadata"] == "branch one"
5283+
assert "metadata" in ordered_branches["branch2"]
52815284

52825285
try:
52835286
ds_main.checkout_version("branch_not_exists")

python/src/dataset.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,6 +1881,7 @@ impl Dataset {
18811881
dict.set_item("parent_version", meta.parent_version)?;
18821882
dict.set_item("create_at", meta.create_at)?;
18831883
dict.set_item("manifest_size", meta.manifest_size)?;
1884+
dict.set_item("metadata", meta.metadata.clone())?;
18841885
out.push((name, dict.into_py_any(py)?));
18851886
}
18861887
Ok(out)

0 commit comments

Comments
 (0)