@@ -26,8 +26,8 @@ import (
26
26
type Values struct {
27
27
References References
28
28
29
- mostRecentFileNum base.DiskFileNum
30
- mostRecentHandles map [base.DiskFileNum ]blob.Handle
29
+ mostRecentBlobFileID base.BlobFileID
30
+ mostRecentHandles map [base.BlobFileID ]blob.Handle
31
31
// trackedHandles maps from a blob handle to its value. The value may be nil
32
32
// if the value was not specified (in which case Fetch will
33
33
// deterministically derive a random value from the handle itself.)
@@ -36,18 +36,18 @@ type Values struct {
36
36
37
37
// Fetch returns the value corresponding to the given handle.
38
38
func (bv * Values ) Fetch (
39
- ctx context.Context , handleSuffix []byte , blobFileNum base.DiskFileNum , valLen uint32 , _ []byte ,
39
+ ctx context.Context , handleSuffix []byte , blobFileID base.BlobFileID , valLen uint32 , _ []byte ,
40
40
) (val []byte , callerOwned bool , err error ) {
41
41
if bv .trackedHandles == nil {
42
42
return nil , false , errors .New ("no tracked handles" )
43
43
}
44
44
45
45
decodedHandleSuffix := blob .DecodeHandleSuffix (handleSuffix )
46
46
decodedHandle := blob.Handle {
47
- FileNum : blobFileNum ,
48
- ValueLen : valLen ,
49
- BlockID : decodedHandleSuffix .BlockID ,
50
- ValueID : decodedHandleSuffix .ValueID ,
47
+ BlobFileID : blobFileID ,
48
+ ValueLen : valLen ,
49
+ BlockID : decodedHandleSuffix .BlockID ,
50
+ ValueID : decodedHandleSuffix .ValueID ,
51
51
}
52
52
53
53
value , ok := bv .trackedHandles [decodedHandle ]
@@ -64,7 +64,7 @@ func (bv *Values) Fetch(
64
64
}
65
65
66
66
func deriveValueFromHandle (handle blob.Handle ) []byte {
67
- rng := rand .New (rand .NewPCG ((uint64 (handle .FileNum )<< 32 )| uint64 (handle .BlockID ), uint64 (handle .ValueID )))
67
+ rng := rand .New (rand .NewPCG ((uint64 (handle .BlobFileID )<< 32 )| uint64 (handle .BlockID ), uint64 (handle .ValueID )))
68
68
b := make ([]byte , handle .ValueLen )
69
69
for i := range b {
70
70
b [i ] = 'a' + byte (rng .IntN (26 ))
@@ -97,7 +97,7 @@ func (bv *Values) ParseInternalValue(input string) (base.InternalValue, error) {
97
97
// TODO(jackson): Support user-specified short attributes.
98
98
ShortAttribute : base .ShortAttribute (h .ValueLen & 0x07 ),
99
99
},
100
- BlobFileNum : h .FileNum ,
100
+ BlobFileID : h .BlobFileID ,
101
101
},
102
102
}), nil
103
103
}
@@ -113,7 +113,7 @@ func IsBlobHandle(input string) bool {
113
113
func (bv * Values ) Parse (input string ) (h blob.Handle , remaining string , err error ) {
114
114
if bv .trackedHandles == nil {
115
115
bv .trackedHandles = make (map [blob.Handle ]string )
116
- bv .mostRecentHandles = make (map [base.DiskFileNum ]blob.Handle )
116
+ bv .mostRecentHandles = make (map [base.BlobFileID ]blob.Handle )
117
117
}
118
118
119
119
defer func () {
@@ -136,7 +136,7 @@ func (bv *Values) Parse(input string) (h blob.Handle, remaining string, err erro
136
136
done = true
137
137
case "fileNum" :
138
138
p .Expect ("=" )
139
- h .FileNum = p . DiskFileNum ( )
139
+ h .BlobFileID = base . BlobFileID ( p . Uint64 () )
140
140
fileNumSet = true
141
141
case "blockID" :
142
142
p .Expect ("=" )
@@ -162,13 +162,13 @@ func (bv *Values) Parse(input string) (h blob.Handle, remaining string, err erro
162
162
}
163
163
164
164
if ! fileNumSet {
165
- h .FileNum = bv .mostRecentFileNum
165
+ h .BlobFileID = bv .mostRecentBlobFileID
166
166
}
167
167
if ! blockIDSet {
168
- h .BlockID = bv .mostRecentHandles [h .FileNum ].BlockID
168
+ h .BlockID = bv .mostRecentHandles [h .BlobFileID ].BlockID
169
169
}
170
170
if ! valueIDSet {
171
- if recentHandle , ok := bv .mostRecentHandles [h .FileNum ]; ok {
171
+ if recentHandle , ok := bv .mostRecentHandles [h .BlobFileID ]; ok {
172
172
h .ValueID = recentHandle .ValueID + 1
173
173
} else {
174
174
h .ValueID = 0
@@ -181,8 +181,8 @@ func (bv *Values) Parse(input string) (h blob.Handle, remaining string, err erro
181
181
h .ValueLen = 12
182
182
}
183
183
}
184
- bv .mostRecentFileNum = h .FileNum
185
- bv .mostRecentHandles [h .FileNum ] = h
184
+ bv .mostRecentBlobFileID = h .BlobFileID
185
+ bv .mostRecentHandles [h .BlobFileID ] = h
186
186
bv .trackedHandles [h ] = value
187
187
return h , p .Remaining (), nil
188
188
}
@@ -201,7 +201,7 @@ func (bv *Values) ParseInlineHandle(
201
201
}
202
202
h = blob.InlineHandle {
203
203
InlineHandlePreface : blob.InlineHandlePreface {
204
- ReferenceID : bv .References .MapToReferenceID (fullHandle .FileNum ),
204
+ ReferenceID : bv .References .MapToReferenceID (fullHandle .BlobFileID ),
205
205
ValueLen : fullHandle .ValueLen ,
206
206
},
207
207
HandleSuffix : blob.HandleSuffix {
@@ -223,7 +223,8 @@ func (bv *Values) WriteFiles(
223
223
// Organize the handles by file number.
224
224
files := make (map [base.DiskFileNum ][]blob.Handle )
225
225
for handle := range bv .trackedHandles {
226
- files [handle .FileNum ] = append (files [handle .FileNum ], handle )
226
+ diskFileNum := base .DiskFileNum (handle .BlobFileID )
227
+ files [diskFileNum ] = append (files [diskFileNum ], handle )
227
228
}
228
229
229
230
stats := make (map [base.DiskFileNum ]blob.FileWriterStats )
@@ -251,10 +252,10 @@ func (bv *Values) WriteFiles(
251
252
prevID ++
252
253
for prevID < int (handle .ValueID ) {
253
254
writer .AddValue (deriveValueFromHandle (blob.Handle {
254
- FileNum : fileNum ,
255
- BlockID : handle .BlockID ,
256
- ValueID : blob .BlockValueID (prevID ),
257
- ValueLen : 12 ,
255
+ BlobFileID : base . BlobFileID ( fileNum ) ,
256
+ BlockID : handle .BlockID ,
257
+ ValueID : blob .BlockValueID (prevID ),
258
+ ValueLen : 12 ,
258
259
}))
259
260
prevID ++
260
261
}
@@ -287,17 +288,17 @@ func errFromPanic(r any) error {
287
288
// each file number to a reference index (encoded within the
288
289
// blob.InlineHandlePreface).
289
290
type References struct {
290
- fileNums []base.DiskFileNum
291
+ fileIDs []base.BlobFileID
291
292
}
292
293
293
294
// MapToReferenceID maps the given file number to a reference ID.
294
- func (b * References ) MapToReferenceID (fileNum base.DiskFileNum ) blob.ReferenceID {
295
- for i , fn := range b .fileNums {
296
- if fn == fileNum {
295
+ func (b * References ) MapToReferenceID (fileID base.BlobFileID ) blob.ReferenceID {
296
+ for i , fn := range b .fileIDs {
297
+ if fn == fileID {
297
298
return blob .ReferenceID (i )
298
299
}
299
300
}
300
- i := uint32 (len (b .fileNums ))
301
- b .fileNums = append (b .fileNums , fileNum )
301
+ i := uint32 (len (b .fileIDs ))
302
+ b .fileIDs = append (b .fileIDs , fileID )
302
303
return blob .ReferenceID (i )
303
304
}
0 commit comments