MCPcopy
hub / github.com/dgraph-io/badger / ParseFileID

Function ParseFileID

table/table.go:682–695  ·  view source on GitHub ↗

ParseFileID reads the file id out of a filename.

(name string)

Source from the content-addressed store, hash-verified

680
681// ParseFileID reads the file id out of a filename.
682func ParseFileID(name string) (uint64, bool) {
683 name = path.Base(name)
684 if !strings.HasSuffix(name, fileSuffix) {
685 return 0, false
686 }
687 // suffix := name[len(fileSuffix):]
688 name = strings.TrimSuffix(name, fileSuffix)
689 id, err := strconv.Atoi(name)
690 if err != nil {
691 return 0, false
692 }
693 y.AssertTrue(id >= 0)
694 return uint64(id), true
695}
696
697// IDToFilename does the inverse of ParseFileID
698func IDToFilename(id uint64) string {

Callers 2

getIDMapFunction · 0.92
OpenTableFunction · 0.85

Calls 1

AssertTrueFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…