Simplify names in cmd source

This commit is contained in:
kortschak 2014-06-28 12:38:51 +09:30
parent 47c9752e5e
commit c4a19a4e35
6 changed files with 17 additions and 17 deletions

View file

@ -69,18 +69,18 @@ func main() {
}
switch cmd {
case "init":
db.CayleyInit(cfg, *tripleFile)
db.Init(cfg, *tripleFile)
case "load":
ts = db.OpenTSFromConfig(cfg)
db.CayleyLoad(ts, cfg, *tripleFile, false)
ts = db.OpenTSFrom(cfg)
db.Load(ts, cfg, *tripleFile, false)
ts.Close()
case "repl":
ts = db.OpenTSFromConfig(cfg)
db.CayleyRepl(ts, *queryLanguage, cfg)
ts = db.OpenTSFrom(cfg)
db.Repl(ts, *queryLanguage, cfg)
ts.Close()
case "http":
ts = db.OpenTSFromConfig(cfg)
http.CayleyHTTP(ts, cfg)
ts = db.OpenTSFrom(cfg)
http.Serve(ts, cfg)
ts.Close()
default:
fmt.Println("No command", cmd)

View file

@ -20,7 +20,7 @@ import (
"github.com/google/cayley/graph/mongo"
)
func CayleyInit(cfg *config.CayleyConfig, triplePath string) bool {
func Init(cfg *config.CayleyConfig, triplePath string) bool {
created := false
dbpath := cfg.DatabasePath
switch cfg.DatabaseType {
@ -32,8 +32,8 @@ func CayleyInit(cfg *config.CayleyConfig, triplePath string) bool {
return true
}
if created && triplePath != "" {
ts := OpenTSFromConfig(cfg)
CayleyLoad(ts, cfg, triplePath, true)
ts := OpenTSFrom(cfg)
Load(ts, cfg, triplePath, true)
ts.Close()
}
return created

View file

@ -25,7 +25,7 @@ import (
"github.com/google/cayley/nquads"
)
func CayleyLoad(ts graph.TripleStore, cfg *config.CayleyConfig, triplePath string, firstTime bool) {
func Load(ts graph.TripleStore, cfg *config.CayleyConfig, triplePath string, firstTime bool) {
switch cfg.DatabaseType {
case "mongo", "mongodb":
if firstTime {

View file

@ -24,7 +24,7 @@ import (
"github.com/google/cayley/graph/mongo"
)
func OpenTSFromConfig(cfg *config.CayleyConfig) graph.TripleStore {
func OpenTSFrom(cfg *config.CayleyConfig) graph.TripleStore {
glog.Infof("Opening database \"%s\" at %s", cfg.DatabaseType, cfg.DatabasePath)
switch cfg.DatabaseType {
case "mongo", "mongodb":
@ -33,7 +33,7 @@ func OpenTSFromConfig(cfg *config.CayleyConfig) graph.TripleStore {
return leveldb.NewDefaultLevelDBTripleStore(cfg.DatabasePath, cfg.DatabaseOptions)
case "mem":
ts := memstore.NewMemTripleStore()
CayleyLoad(ts, cfg, cfg.DatabasePath, true)
Load(ts, cfg, cfg.DatabasePath, true)
return ts
}
panic("Unsupported database backend " + cfg.DatabaseType)

View file

@ -40,7 +40,7 @@ func un(s string, startTime time.Time) {
fmt.Printf(s, float64(endTime.UnixNano()-startTime.UnixNano())/float64(1E6))
}
func RunQuery(query string, ses graph.Session) {
func Run(query string, ses graph.Session) {
nResults := 0
startTrace, startTime := trace("Elapsed time: %g ms\n\n")
defer func() {
@ -60,7 +60,7 @@ func RunQuery(query string, ses graph.Session) {
}
}
func CayleyRepl(ts graph.TripleStore, queryLanguage string, cfg *config.CayleyConfig) {
func Repl(ts graph.TripleStore, queryLanguage string, cfg *config.CayleyConfig) {
var ses graph.Session
switch queryLanguage {
case "sexp":
@ -131,7 +131,7 @@ func CayleyRepl(ts graph.TripleStore, queryLanguage string, cfg *config.CayleyCo
result, err := ses.InputParses(line)
switch result {
case graph.Parsed:
RunQuery(line, ses)
Run(line, ses)
line = ""
case graph.ParseFail:
fmt.Println("Error: ", err)

View file

@ -141,7 +141,7 @@ func SetupRoutes(ts graph.TripleStore, cfg *config.CayleyConfig) {
http.Handle("/", r)
}
func CayleyHTTP(ts graph.TripleStore, cfg *config.CayleyConfig) {
func Serve(ts graph.TripleStore, cfg *config.CayleyConfig) {
SetupRoutes(ts, cfg)
glog.Infof("Cayley now listening on %s:%s\n", cfg.ListenHost, cfg.ListenPort)
fmt.Printf("Cayley now listening on %s:%s\n", cfg.ListenHost, cfg.ListenPort)