1
1
// SPDX-License-Identifier: Apache-2.0
2
2
// SPDX-FileCopyrightText: Copyright The Lance Authors
3
3
4
- use std:: collections:: { BTreeMap , HashMap } ;
5
- use std:: ops:: Range ;
6
- use std:: sync:: Arc ;
7
-
8
4
use async_trait:: async_trait;
9
5
use chrono:: prelude:: * ;
10
6
use deepsize:: DeepSizeOf ;
@@ -15,6 +11,9 @@ use lance_io::traits::{ProtoStruct, Reader};
15
11
use object_store:: path:: Path ;
16
12
use prost:: Message ;
17
13
use prost_types:: Timestamp ;
14
+ use std:: collections:: { BTreeMap , HashMap } ;
15
+ use std:: ops:: Range ;
16
+ use std:: sync:: Arc ;
18
17
19
18
use super :: Fragment ;
20
19
use crate :: feature_flags:: { has_deprecated_v2_feature_flag, FLAG_STABLE_ROW_IDS } ;
@@ -43,6 +42,9 @@ pub struct Manifest {
43
42
/// Dataset version
44
43
pub version : u64 ,
45
44
45
+ /// Branch name, None if the dataset is the main branch.
46
+ pub branch : Option < String > ,
47
+
46
48
/// Version of the writer library that wrote this manifest.
47
49
pub writer_version : Option < WriterVersion > ,
48
50
@@ -70,7 +72,7 @@ pub struct Manifest {
70
72
/// The writer flags
71
73
pub writer_feature_flags : u64 ,
72
74
73
- /// The max fragment id used so far
75
+ /// The max fragment id used so far
74
76
/// None means never set, Some(0) means max ID used so far is 0
75
77
pub max_fragment_id : Option < u32 > ,
76
78
@@ -185,6 +187,7 @@ impl Manifest {
185
187
schema,
186
188
local_schema,
187
189
version : 1 ,
190
+ branch : None ,
188
191
writer_version : Some ( WriterVersion :: default ( ) ) ,
189
192
fragments,
190
193
version_aux_data : 0 ,
@@ -221,6 +224,7 @@ impl Manifest {
221
224
schema,
222
225
local_schema,
223
226
version : previous. version + 1 ,
227
+ branch : previous. branch . clone ( ) ,
224
228
writer_version : Some ( WriterVersion :: default ( ) ) ,
225
229
fragments,
226
230
version_aux_data : 0 ,
@@ -245,11 +249,13 @@ impl Manifest {
245
249
/// Performs a shallow_clone of the manifest entirely in memory without:
246
250
/// - Any persistent storage operations
247
251
/// - Modifications to the original data
252
+ /// - If the shallow clone is for branch, ref_name is the source branch
248
253
pub fn shallow_clone (
249
254
& self ,
250
255
ref_name : Option < String > ,
251
256
ref_path : String ,
252
257
ref_base_id : u32 ,
258
+ branch_name : Option < String > ,
253
259
transaction_file : String ,
254
260
) -> Self {
255
261
let cloned_fragments = self
@@ -277,6 +283,7 @@ impl Manifest {
277
283
schema : self . schema . clone ( ) ,
278
284
local_schema : self . local_schema . clone ( ) ,
279
285
version : self . version ,
286
+ branch : branch_name,
280
287
writer_version : self . writer_version . clone ( ) ,
281
288
fragments : Arc :: new ( cloned_fragments) ,
282
289
version_aux_data : self . version_aux_data ,
@@ -770,6 +777,7 @@ impl TryFrom<pb::Manifest> for Manifest {
770
777
schema,
771
778
local_schema,
772
779
version : p. version ,
780
+ branch : p. branch ,
773
781
writer_version,
774
782
version_aux_data : p. version_aux_data as usize ,
775
783
index_section : p. index_section . map ( |i| i as usize ) ,
@@ -826,6 +834,7 @@ impl From<&Manifest> for pb::Manifest {
826
834
. map ( |( k, v) | ( k. clone ( ) , v. as_bytes ( ) . to_vec ( ) ) )
827
835
. collect ( ) ,
828
836
version : m. version ,
837
+ branch : m. branch . clone ( ) ,
829
838
writer_version : m
830
839
. writer_version
831
840
. as_ref ( )
0 commit comments