MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / getMaxFileIDAndFileIDs

Method getMaxFileIDAndFileIDs

db.go:507–530  ·  view source on GitHub ↗

getMaxFileIDAndFileIds returns max fileId and fileIds.

()

Source from the content-addressed store, hash-verified

505
506// getMaxFileIDAndFileIds returns max fileId and fileIds.
507func (db *DB) getMaxFileIDAndFileIDs() (maxFileID int64, dataFileIds []int64) {
508 userIDs, mergeIDs, err := enumerateDataFileIDs(db.opt.Dir)
509 if err != nil {
510 return 0, nil
511 }
512
513 if len(userIDs) > 0 {
514 maxFileID = userIDs[len(userIDs)-1]
515 }
516
517 dataFileIds = make([]int64, 0, len(userIDs)+len(mergeIDs))
518 dataFileIds = append(dataFileIds, userIDs...)
519 dataFileIds = append(dataFileIds, mergeIDs...)
520
521 if len(dataFileIds) > 1 {
522 sort.Slice(dataFileIds, func(i, j int) bool { return dataFileIds[i] < dataFileIds[j] })
523 }
524
525 if len(dataFileIds) == 0 {
526 return maxFileID, nil
527 }
528
529 return maxFileID, dataFileIds
530}
531
532func (db *DB) parseDataFiles(dataFileIds []int64) (err error) {
533 var (

Callers 3

mergeLegacyMethod · 0.95
buildIndexesMethod · 0.95

Calls 2

enumerateDataFileIDsFunction · 0.85
appendFunction · 0.85

Tested by 1