add gzip support
This commit is contained in:
parent
99587c2f24
commit
19f5b090e6
1 changed files with 10 additions and 3 deletions
|
|
@ -3,6 +3,8 @@ package internal
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"compress/gzip"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/google/cayley/graph"
|
"github.com/google/cayley/graph"
|
||||||
"github.com/google/cayley/exporter"
|
"github.com/google/cayley/exporter"
|
||||||
|
|
@ -24,11 +26,16 @@ func Dump(qs graph.QuadStore, outFile, typ string) error {
|
||||||
fmt.Printf("dumping db to file %q\n", outFile)
|
fmt.Printf("dumping db to file %q\n", outFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
export := exporter.NewExporter(f, qs)
|
var export *exporter.Exporter
|
||||||
if export.Err() != nil {
|
if filepath.Ext(outFile) == ".gz" {
|
||||||
return export.Err()
|
gzip := gzip.NewWriter(f)
|
||||||
|
defer gzip.Close()
|
||||||
|
export = exporter.NewExporter(gzip, qs)
|
||||||
|
} else {
|
||||||
|
export = exporter.NewExporter(f, qs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: add possible support for exporting specific queries only
|
||||||
switch typ {
|
switch typ {
|
||||||
case "nquad":
|
case "nquad":
|
||||||
export.ExportNquad()
|
export.ExportNquad()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue