MCPcopy
hub / github.com/dgraph-io/dgraph / writeToFile

Function writeToFile

dgraph/cmd/conv/conv.go:25–55  ·  view source on GitHub ↗

TODO: Reconsider if we need this binary.

(fpath string, ch chan []byte)

Source from the content-addressed store, hash-verified

23
24// TODO: Reconsider if we need this binary.
25func writeToFile(fpath string, ch chan []byte) error {
26 f, err := os.Create(fpath)
27 if err != nil {
28 return err
29 }
30
31 defer func() {
32 if err := f.Close(); err != nil {
33 glog.Warningf("error while closing fd: %v", err)
34 }
35 }()
36 x.Check(err)
37 w := bufio.NewWriterSize(f, 1e6)
38 gw, err := gzip.NewWriterLevel(w, gzip.BestCompression)
39 if err != nil {
40 return err
41 }
42
43 for buf := range ch {
44 if _, err := gw.Write(buf); err != nil {
45 return err
46 }
47 }
48 if err := gw.Flush(); err != nil {
49 return err
50 }
51 if err := gw.Close(); err != nil {
52 return err
53 }
54 return w.Flush()
55}
56
57func convertGeoFile(input string, output string) error {
58 fmt.Printf("\nProcessing %s\n\n", input)

Callers 1

convertGeoFileFunction · 0.85

Calls 6

CheckFunction · 0.92
WarningfMethod · 0.80
CreateMethod · 0.65
CloseMethod · 0.65
WriteMethod · 0.65
FlushMethod · 0.65

Tested by

no test coverage detected