@@ -179,11 +179,17 @@ func newFileCacheTest(
179
179
}
180
180
}
181
181
182
- func (t * fileCacheTest ) fileByIdx (i int ) ( base.DiskFileNum , base. FileType ) {
182
+ func (t * fileCacheTest ) fileByIdx (i int ) base.ObjectInfo {
183
183
if i < fileCacheTestNumTables {
184
- return base .DiskFileNum (i ), base .FileTypeTable
184
+ return base.ObjectInfoLiteral {
185
+ FileType : base .FileTypeTable ,
186
+ DiskFileNum : base .DiskFileNum (i ),
187
+ }
188
+ }
189
+ return base.ObjectInfoLiteral {
190
+ FileType : base .FileTypeBlob ,
191
+ DiskFileNum : base .DiskFileNum (i ),
185
192
}
186
- return base .DiskFileNum (i ), base .FileTypeBlob
187
193
}
188
194
189
195
func (t * fileCacheTest ) cleanup () {
@@ -192,7 +198,7 @@ func (t *fileCacheTest) cleanup() {
192
198
t .blockCache .Unref ()
193
199
}
194
200
195
- func noopCorruptionFn (_ any , err error ) error { return err }
201
+ func noopCorruptionFn (_ base. ObjectInfo , err error ) error { return err }
196
202
197
203
// newTestHandle creates a filesystem with a set of test tables and an
198
204
// associated file cache handle. The caller must close the handle.
@@ -727,9 +733,10 @@ func testFileCacheFrequentlyUsedInternal(t *testing.T, rangeIter bool) {
727
733
728
734
for i := 0 ; i < N ; i ++ {
729
735
for _ , j := range [... ]int {pinned0 , i % fileCacheTestNumFiles , pinned1 } {
730
- fn , typ := fct .fileByIdx (j )
731
- if typ == base .FileTypeBlob {
732
- _ , closeFunc , err := h .GetValueReader (context .Background (), fn )
736
+ obj := fct .fileByIdx (j )
737
+ ftyp , fn := obj .FileInfo ()
738
+ if ftyp == base .FileTypeBlob {
739
+ _ , closeFunc , err := h .GetValueReader (context .Background (), obj )
733
740
if err != nil {
734
741
t .Fatalf ("i=%d, j=%d: get value reader: %v" , i , j , err )
735
742
}
@@ -787,9 +794,10 @@ func TestSharedFileCacheFrequentlyUsed(t *testing.T) {
787
794
788
795
for i := 0 ; i < N ; i ++ {
789
796
for _ , j := range [... ]int {pinned0 , i % fileCacheTestNumFiles , pinned1 } {
790
- fn , typ := fct .fileByIdx (j )
791
- if typ == base .FileTypeBlob {
792
- _ , closeFunc , err := h1 .GetValueReader (context .Background (), fn )
797
+ obj := fct .fileByIdx (j )
798
+ ftyp , fn := obj .FileInfo ()
799
+ if ftyp == base .FileTypeBlob {
800
+ _ , closeFunc , err := h1 .GetValueReader (context .Background (), obj )
793
801
if err != nil {
794
802
t .Fatalf ("i=%d, j=%d: get value reader: %v" , i , j , err )
795
803
}
@@ -847,9 +855,10 @@ func testFileCacheEvictionsInternal(t *testing.T, rangeIter bool) {
847
855
848
856
rng := rand .New (rand .NewPCG (2 , 2 ))
849
857
for i := 0 ; i < N ; i ++ {
850
- fn , typ := fct .fileByIdx (rng .IntN (fileCacheTestNumFiles ))
851
- if typ == base .FileTypeBlob {
852
- _ , closeFunc , err := h .GetValueReader (context .Background (), fn )
858
+ obj := fct .fileByIdx (rng .IntN (fileCacheTestNumFiles ))
859
+ ftyp , fn := obj .FileInfo ()
860
+ if ftyp == base .FileTypeBlob {
861
+ _ , closeFunc , err := h .GetValueReader (context .Background (), obj )
853
862
if err != nil {
854
863
t .Fatalf ("i=%d, fn=%d: get value reader: %v" , i , fn , err )
855
864
}
@@ -873,7 +882,9 @@ func testFileCacheEvictionsInternal(t *testing.T, rangeIter bool) {
873
882
}
874
883
}
875
884
876
- h .Evict (fct .fileByIdx (int (lo + rng .Uint64N (hi - lo ))))
885
+ obj = fct .fileByIdx (int (lo + rng .Uint64N (hi - lo )))
886
+ ftyp , fn = obj .FileInfo ()
887
+ h .Evict (fn , ftyp )
877
888
}
878
889
879
890
sumEvicted , nEvicted := 0 , 0
@@ -923,13 +934,14 @@ func TestSharedFileCacheEvictions(t *testing.T) {
923
934
rng := rand .New (rand .NewPCG (0 , 0 ))
924
935
for i := 0 ; i < N ; i ++ {
925
936
j := rng .IntN (fileCacheTestNumFiles )
926
- fn , typ := fct .fileByIdx (j )
927
- if typ == base .FileTypeBlob {
928
- _ , closeFunc1 , err := h1 .GetValueReader (context .Background (), fn )
937
+ obj := fct .fileByIdx (j )
938
+ ftyp , fn := obj .FileInfo ()
939
+ if ftyp == base .FileTypeBlob {
940
+ _ , closeFunc1 , err := h1 .GetValueReader (context .Background (), obj )
929
941
if err != nil {
930
942
t .Fatalf ("i=%d, fn=%d: get value reader: %v" , i , fn , err )
931
943
}
932
- _ , closeFunc2 , err := h2 .GetValueReader (context .Background (), fn )
944
+ _ , closeFunc2 , err := h2 .GetValueReader (context .Background (), obj )
933
945
if err != nil {
934
946
t .Fatalf ("i=%d, fn=%d: get value reader: %v" , i , fn , err )
935
947
}
@@ -955,8 +967,12 @@ func TestSharedFileCacheEvictions(t *testing.T) {
955
967
}
956
968
}
957
969
958
- h1 .Evict (fct .fileByIdx (int (lo + rng .Uint64N (hi - lo ))))
959
- h2 .Evict (fct .fileByIdx (int (lo + rng .Uint64N (hi - lo ))))
970
+ obj = fct .fileByIdx (int (lo + rng .Uint64N (hi - lo )))
971
+ ftyp , fn = obj .FileInfo ()
972
+ h1 .Evict (fn , ftyp )
973
+ obj = fct .fileByIdx (int (lo + rng .Uint64N (hi - lo )))
974
+ ftyp , fn = obj .FileInfo ()
975
+ h2 .Evict (fn , ftyp )
960
976
}
961
977
962
978
check := func (fs * fileCacheTestFS , h * fileCacheHandle ) (float64 , float64 , float64 ) {
@@ -1089,13 +1105,14 @@ func TestFileCacheRetryAfterFailure(t *testing.T) {
1089
1105
h , fs := fct .newTestHandle ()
1090
1106
1091
1107
fs .setOpenError (true /* enabled */ )
1092
- _ , _ , err := h .GetValueReader (ctx , fileCacheTestNumTables )
1108
+ obj := fct .fileByIdx (fileCacheTestNumTables )
1109
+ _ , _ , err := h .GetValueReader (ctx , obj )
1093
1110
if err == nil {
1094
1111
t .Fatalf ("expected failure, but found success" )
1095
1112
}
1096
1113
require .Equal (t , "pebble: backing file 000200 error: injected error" , err .Error ())
1097
1114
fs .setOpenError (false /* enabled */ )
1098
- _ , closeFunc , err := h .GetValueReader (ctx , fileCacheTestNumTables )
1115
+ _ , closeFunc , err := h .GetValueReader (ctx , obj )
1099
1116
require .NoError (t , err )
1100
1117
closeFunc ()
1101
1118
fs .validateAndCloseHandle (t , h , nil )
0 commit comments