@@ -84,13 +84,14 @@ func ForTableWithStore(dataPath string, config Config, clock Clock, ls *store.St
84
84
}
85
85
86
86
logImpl := & logImpl {
87
- dataPath : dataPath ,
88
- logPath : logPath ,
89
- clock : clock ,
90
- store : * logStore ,
91
- deltaLogLock : deltaLogLock ,
92
- history : historyManager ,
93
- snapshotReader : snaptshotManager ,
87
+ dataPath : dataPath ,
88
+ logPath : logPath ,
89
+ clock : clock ,
90
+ store : * logStore ,
91
+ deltaLogLock : deltaLogLock ,
92
+ history : historyManager ,
93
+ snapshotReader : snaptshotManager ,
94
+ checkpointReader : & parquetReader ,
94
95
}
95
96
96
97
return logImpl , nil
@@ -173,13 +174,14 @@ func ForTable(dataPath string, config Config, clock Clock) (Log, error) {
173
174
// }
174
175
175
176
type logImpl struct {
176
- dataPath string
177
- logPath string
178
- clock Clock
179
- store store.Store
180
- deltaLogLock * sync.Mutex
181
- history * historyManager
182
- snapshotReader * SnapshotReader
177
+ dataPath string
178
+ logPath string
179
+ clock Clock
180
+ store store.Store
181
+ deltaLogLock * sync.Mutex
182
+ history * historyManager
183
+ snapshotReader * SnapshotReader
184
+ checkpointReader * checkpointReader
183
185
}
184
186
185
187
// Snapshot the current Snapshot of the Delta table.
@@ -222,23 +224,32 @@ func (l *logImpl) Path() string {
222
224
return l .dataPath
223
225
}
224
226
225
- // Get all actions starting from startVersion (inclusive) in increasing order of committed version.
227
+ // Changes Get all actions starting from startVersion (inclusive) in increasing order of committed version.
226
228
// If startVersion doesn't exist, return an empty Iterator.
227
229
func (l * logImpl ) Changes (startVersion int64 , failOnDataLoss bool ) (iter.Iter [VersionLog ], error ) {
228
230
if startVersion < 0 {
229
231
return nil , eris .Wrap (errno .ErrIllegalArgument , "invalid startVersion" )
230
232
}
231
-
232
- fs , err := l .store .ListFrom (filenames .DeltaFile ("" , startVersion ))
233
+ var fs iter.Iter [* store.FileMeta ]
234
+ checkpointIncluded := true
235
+ fs , err := l .store .ListFrom (filenames .CheckpointFileSingular ("" , startVersion ))
233
236
if err != nil {
234
- return nil , err
237
+ checkpointIncluded = false
238
+ fs , err = l .store .ListFrom (filenames .DeltaFile ("" , startVersion ))
239
+ if err != nil {
240
+ return nil , err
241
+ }
235
242
}
236
243
defer fs .Close ()
237
244
238
245
var deltaPaths []string
239
246
for f , err := fs .Next (); err == nil ; f , err = fs .Next () {
240
- if filenames .IsDeltaFile (f .Path ()) {
241
- deltaPaths = append (deltaPaths , f .Path ())
247
+ p := f .Path ()
248
+ if checkpointIncluded && filenames .IsCheckpointFile (p ) {
249
+ deltaPaths = append (deltaPaths , p )
250
+ checkpointIncluded = false
251
+ } else if filenames .IsDeltaFile (p ) {
252
+ deltaPaths = append (deltaPaths , p )
242
253
}
243
254
}
244
255
if err != nil && err != io .EOF {
@@ -248,6 +259,16 @@ func (l *logImpl) Changes(startVersion int64, failOnDataLoss bool) (iter.Iter[Ve
248
259
lastSeenVersion := startVersion - 1
249
260
versionLogs := make ([]VersionLog , len (deltaPaths ))
250
261
for i , deltaPath := range deltaPaths {
262
+ if filenames .IsCheckpointFile (deltaPath ) {
263
+ version := filenames .CheckpointVersion (deltaPath )
264
+ versionLogs [i ] = & MemOptimizedCheckpoint {
265
+ version : version ,
266
+ path : deltaPath ,
267
+ store : l .store ,
268
+ cr : l .checkpointReader ,
269
+ }
270
+ continue
271
+ }
251
272
version := filenames .DeltaVersion (deltaPath )
252
273
if failOnDataLoss && version > lastSeenVersion + 1 {
253
274
return nil , errno .IllegalStateError ("fail on data loss" )
0 commit comments