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

Method getDataFileWithMode

file_manager.go:45–67  ·  view source on GitHub ↗

getDataFileWithMode will return a DataFile Object with specified read-only mode

(path string, capacity int64, readOnly bool)

Source from the content-addressed store, hash-verified

43
44// getDataFileWithMode will return a DataFile Object with specified read-only mode
45func (fm *FileManager) getDataFileWithMode(path string, capacity int64, readOnly bool) (datafile *DataFile, err error) {
46 if capacity <= 0 {
47 return nil, ErrCapacity
48 }
49
50 var rwManager fileio.RWManager
51
52 if fm.rwMode == FileIO {
53 rwManager, err = fm.GetFileRWManager(path, capacity, fm.segmentSize, readOnly)
54 if err != nil {
55 return nil, err
56 }
57 }
58
59 if fm.rwMode == MMap {
60 rwManager, err = fm.GetMMapRWManager(path, capacity, fm.segmentSize, readOnly)
61 if err != nil {
62 return nil, err
63 }
64 }
65
66 return NewDataFile(path, rwManager), nil
67}
68
69func (fm *FileManager) GetDataFileByID(dir string, fileID int64, capacity int64) (*DataFile, error) {
70 path := getDataPath(fileID, dir)

Callers 2

GetDataFileMethod · 0.95
GetDataFileReadOnlyMethod · 0.95

Calls 3

GetFileRWManagerMethod · 0.95
GetMMapRWManagerMethod · 0.95
NewDataFileFunction · 0.85

Tested by

no test coverage detected