Merge pull request #292 from ds--/master

Adds exporting capabilities
This commit is contained in:
Barak Michener 2015-10-05 17:26:10 -04:00
commit 0274e9f73c
3 changed files with 268 additions and 0 deletions

View file

@ -51,6 +51,8 @@ var (
configFile = flag.String("config", "", "Path to an explicit configuration file.")
databasePath = flag.String("dbpath", "/tmp/testdb", "Path to the database.")
databaseBackend = flag.String("db", "memstore", "Database Backend.")
dumpFile = flag.String("dump", "dbdump.nq", `Quad file to dump the database to (".gz" supported, "-" for stdout).`)
dumpType = flag.String("dump_type", "quad", `Quad file format ("json", "quad", "gml", "graphml").`)
replicationBackend = flag.String("replication", "single", "Replication method.")
host = flag.String("host", "127.0.0.1", "Host to listen on (defaults to all).")
loadSize = flag.Int("load_size", 10000, "Size of quadsets to load")
@ -74,6 +76,7 @@ Commands:
init Create an empty database.
load Bulk-load a quad file into the database.
http Serve an HTTP endpoint on the given host and port.
dump Bulk-dump the database into a quad file.
repl Drop into a REPL of the given query language.
version Version information.
@ -215,6 +218,25 @@ func main() {
handle.Close()
case "dump":
handle, err = db.Open(cfg)
if err != nil {
break
}
if !graph.IsPersistent(cfg.DatabaseType) {
err = internal.Load(handle.QuadWriter, cfg, *quadFile, *quadType)
if err != nil {
break
}
}
err = internal.Dump(handle.QuadStore, *dumpFile, *dumpType)
if err != nil {
break
}
handle.Close()
case "repl":
handle, err = db.Open(cfg)
if err != nil {