MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / WriteGroupIdFile

Function WriteGroupIdFile

x/file.go:145–162  ·  view source on GitHub ↗

WriteGroupIdFile writes the given group ID to the group_id file inside the given postings directory.

(pdir string, group_id uint32)

Source from the content-addressed store, hash-verified

143// WriteGroupIdFile writes the given group ID to the group_id file inside the given
144// postings directory.
145func WriteGroupIdFile(pdir string, group_id uint32) error {
146 if group_id == 0 {
147 return errors.Errorf("ID written to group_id file must be a positive number")
148 }
149
150 groupFile := filepath.Join(pdir, GroupIdFileName)
151 f, err := os.OpenFile(groupFile, os.O_CREATE|os.O_WRONLY, 0600)
152 if err != nil {
153 return nil
154 }
155 if _, err := f.WriteString(strconv.Itoa(int(group_id))); err != nil {
156 return err
157 }
158 if _, err := f.WriteString("\n"); err != nil {
159 return err
160 }
161 return f.Close()
162}
163
164// ReadGroupIdFile reads the file at the given path and attempts to retrieve the
165// group ID stored in it.

Callers 2

RunBulkLoaderFunction · 0.92
RunOfflineRestoreFunction · 0.92

Calls 3

OpenFileMethod · 0.65
CloseMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected