getDataFileWithMode will return a DataFile Object with specified read-only mode
(path string, capacity int64, readOnly bool)
| 43 | |
| 44 | // getDataFileWithMode will return a DataFile Object with specified read-only mode |
| 45 | func (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 | |
| 69 | func (fm *FileManager) GetDataFileByID(dir string, fileID int64, capacity int64) (*DataFile, error) { |
| 70 | path := getDataPath(fileID, dir) |
no test coverage detected