• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang graph.IsPersistent函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/google/cayley/graph.IsPersistent函数的典型用法代码示例。如果您正苦于以下问题:Golang IsPersistent函数的具体用法?Golang IsPersistent怎么用?Golang IsPersistent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了IsPersistent函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Init

func Init(cfg *config.Config) error {
	if !graph.IsPersistent(cfg.DatabaseType) {
		return fmt.Errorf("ignoring unproductive database initialization request: %v", ErrNotPersistent)
	}

	return graph.InitQuadStore(cfg.DatabaseType, cfg.DatabasePath, cfg.DatabaseOptions)
}
开发者ID:oliverp19,项目名称:cayley,代码行数:7,代码来源:db.go


示例2: prepare

func prepare(t testing.TB) {
	var remote bool
	cfg.DatabaseType = *backend
	switch *backend {
	case "memstore":
		cfg.DatabasePath = "../data/30kmoviedata.nq.gz"
	case "leveldb", "bolt":
		cfg.DatabasePath = "/tmp/cayley_test_" + *backend
		cfg.DatabaseOptions = map[string]interface{}{
			"nosync": true, // It's a test. If we need to load, do it fast.
		}
	case "mongo":
		cfg.DatabasePath = "localhost:27017"
		cfg.DatabaseOptions = map[string]interface{}{
			"database_name": "cayley_test", // provide a default test database
		}
		remote = true
	case "sql":
		cfg.DatabasePath = "postgres://localhost/cayley_test"
		remote = true
	default:
		t.Fatalf("Untestable backend store %s", *backend)
	}
	if *backendPath != "" {
		cfg.DatabasePath = *backendPath
	}

	var err error
	create.Do(func() {
		needsLoad := true
		if graph.IsPersistent(cfg.DatabaseType) && !remote {
			if _, err := os.Stat(cfg.DatabasePath); os.IsNotExist(err) {
				err = db.Init(cfg)
				if err != nil {
					t.Fatalf("Could not initialize database: %v", err)
				}
			} else {
				needsLoad = false
			}
		}

		handle, err = db.Open(cfg)
		if err != nil {
			t.Fatalf("Failed to open %q: %v", cfg.DatabasePath, err)
		}

		if needsLoad && !remote {
			err = internal.Load(handle.QuadWriter, cfg, "../data/30kmoviedata.nq.gz", "cquad")
			if err != nil {
				t.Fatalf("Failed to load %q: %v", cfg.DatabasePath, err)
			}
		}
	})
}
开发者ID:e4x,项目名称:cayley,代码行数:54,代码来源:integration_test.go


示例3: deletePrepare

func deletePrepare(t testing.TB) {
	var err error
	deleteAndRecreate.Do(func() {
		prepare(t)
		if !graph.IsPersistent(cfg.DatabaseType) {
			err = removeAll(handle.QuadWriter, cfg, "", "cquad")
			if err != nil {
				t.Fatalf("Failed to remove %q: %v", cfg.DatabasePath, err)
			}
			err = internal.Load(handle.QuadWriter, cfg, "", "cquad")
			if err != nil {
				t.Fatalf("Failed to load %q: %v", cfg.DatabasePath, err)
			}
		}
	})
}
开发者ID:WZhuo,项目名称:cayley,代码行数:16,代码来源:integration_test.go


示例4: prepare

func prepare(t testing.TB) {
	var err error
	create.Do(func() {
		handle, err = db.Open(cfg)
		if err != nil {
			t.Fatalf("Failed to open %q: %v", cfg.DatabasePath, err)
		}

		if !graph.IsPersistent(cfg.DatabaseType) {
			err = load(handle.QuadWriter, cfg, "", "cquad")
			if err != nil {
				t.Fatalf("Failed to load %q: %v", cfg.DatabasePath, err)
			}
		}
	})
}
开发者ID:kris-lab,项目名称:cayley,代码行数:16,代码来源:cayley_test.go


示例5: prepare

func prepare(t testing.TB) {
	cfg.DatabaseType = *backend
	switch *backend {
	case "memstore":
		cfg.DatabasePath = "30kmoviedata.nq.gz"
	case "leveldb", "bolt":
		cfg.DatabasePath = "/tmp/cayley_test_" + *backend
		cfg.DatabaseOptions = map[string]interface{}{
			"nosync": true, // It's a test. If we need to load, do it fast.
		}
	case "mongo":
		cfg.DatabasePath = "localhost:27017"
	default:
		t.Fatalf("Untestable backend store %s", *backend)
	}

	var err error
	create.Do(func() {
		needsLoad := true
		if graph.IsPersistent(cfg.DatabaseType) {
			if _, err := os.Stat(cfg.DatabasePath); os.IsNotExist(err) {
				err = db.Init(cfg)
				if err != nil {
					t.Fatalf("Could not initialize database: %v", err)
				}
			} else {
				needsLoad = false
			}
		}

		handle, err = db.Open(cfg)
		if err != nil {
			t.Fatalf("Failed to open %q: %v", cfg.DatabasePath, err)
		}

		if needsLoad {
			err = load(handle.QuadWriter, cfg, "30kmoviedata.nq.gz", "cquad")
			if err != nil {
				t.Fatalf("Failed to load %q: %v", cfg.DatabasePath, err)
			}
		}
	})
}
开发者ID:ericcapricorn,项目名称:cayley,代码行数:43,代码来源:cayley_test.go


示例6: main

func main() {
	// No command? It's time for usage.
	if len(os.Args) == 1 {
		fmt.Fprintln(os.Stderr, "Cayley is a graph store and graph query layer.")
		usage()
		os.Exit(1)
	}

	cmd := os.Args[1]
	os.Args = append(os.Args[:1], os.Args[2:]...)
	flag.Parse()

	var buildString string
	if Version != "" {
		buildString = fmt.Sprint("Cayley ", Version, " built ", BuildDate)
		glog.Infoln(buildString)
	}

	cfg := configFrom(*configFile)

	if os.Getenv("GOMAXPROCS") == "" {
		runtime.GOMAXPROCS(runtime.NumCPU())
		glog.Infoln("Setting GOMAXPROCS to", runtime.NumCPU())
	} else {
		glog.Infoln("GOMAXPROCS currently", os.Getenv("GOMAXPROCS"), " -- not adjusting")
	}

	var (
		handle *graph.Handle
		err    error
	)
	switch cmd {
	case "version":
		if Version != "" {
			fmt.Println(buildString)
		} else {
			fmt.Println("Cayley snapshot")
		}
		os.Exit(0)

	case "init":
		err = db.Init(cfg)
		if err != nil {
			break
		}
		if *quadFile != "" {
			handle, err = db.Open(cfg)
			if err != nil {
				break
			}
			err = internal.Load(handle.QuadWriter, cfg, *quadFile, *quadType)
			if err != nil {
				break
			}
			handle.Close()
		}

	case "load":
		handle, err = db.Open(cfg)
		if err != nil {
			break
		}
		err = internal.Load(handle.QuadWriter, cfg, *quadFile, *quadType)
		if err != nil {
			break
		}

		handle.Close()

	case "repl":
		handle, err = db.Open(cfg)
		if err != nil {
			break
		}
		if !graph.IsPersistent(cfg.DatabaseType) {
			err = internal.Load(handle.QuadWriter, cfg, "", *quadType)
			if err != nil {
				break
			}
		}

		err = db.Repl(handle, *queryLanguage, cfg)

		handle.Close()

	case "http":
		handle, err = db.Open(cfg)
		if err != nil {
			break
		}
		if !graph.IsPersistent(cfg.DatabaseType) {
			err = internal.Load(handle.QuadWriter, cfg, "", *quadType)
			if err != nil {
				break
			}
		}

		http.Serve(handle, cfg)

		handle.Close()
//.........这里部分代码省略.........
开发者ID:oliverp19,项目名称:cayley,代码行数:101,代码来源:cayley.go


示例7: main

func main() {
	// No command? It's time for usage.
	if len(os.Args) == 1 {
		Usage()
		os.Exit(1)
	}

	cmd := os.Args[1]
	var newargs []string
	newargs = append(newargs, os.Args[0])
	newargs = append(newargs, os.Args[2:]...)
	os.Args = newargs
	flag.Parse()

	var buildString string
	if VERSION != "" {
		buildString = fmt.Sprint("Cayley ", VERSION, " built ", BUILD_DATE)
		glog.Infoln(buildString)
	}

	cfg := config.ParseConfigFromFlagsAndFile(*configFile)

	if os.Getenv("GOMAXPROCS") == "" {
		runtime.GOMAXPROCS(runtime.NumCPU())
		glog.Infoln("Setting GOMAXPROCS to", runtime.NumCPU())
	} else {
		glog.Infoln("GOMAXPROCS currently", os.Getenv("GOMAXPROCS"), " -- not adjusting")
	}

	var (
		handle *graph.Handle
		err    error
	)
	switch cmd {
	case "version":
		if VERSION != "" {
			fmt.Println(buildString)
		} else {
			fmt.Println("Cayley snapshot")
		}
		os.Exit(0)

	case "init":
		err = db.Init(cfg)
		if err != nil {
			break
		}
		if *tripleFile != "" {
			handle, err = db.Open(cfg)
			if err != nil {
				break
			}
			err = load(handle.QuadWriter, cfg, *tripleFile, *tripleType)
			if err != nil {
				break
			}
			handle.Close()
		}

	case "load":
		handle, err = db.Open(cfg)
		if err != nil {
			break
		}
		err = load(handle.QuadWriter, cfg, *tripleFile, *tripleType)
		if err != nil {
			break
		}

		handle.Close()

	case "repl":
		handle, err = db.Open(cfg)
		if err != nil {
			break
		}
		if !graph.IsPersistent(cfg.DatabaseType) {
			err = load(handle.QuadWriter, cfg, "", *tripleType)
			if err != nil {
				break
			}
		}

		err = db.Repl(handle, *queryLanguage, cfg)

		handle.Close()

	case "http":
		handle, err = db.Open(cfg)
		if err != nil {
			break
		}
		if !graph.IsPersistent(cfg.DatabaseType) {
			err = load(handle.QuadWriter, cfg, "", *tripleType)
			if err != nil {
				break
			}
		}

		http.Serve(handle, cfg)
//.........这里部分代码省略.........
开发者ID:kris-lab,项目名称:cayley,代码行数:101,代码来源:cayley.go



注:本文中的github.com/google/cayley/graph.IsPersistent函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang graph.NewQuadStore函数代码示例发布时间:2022-05-23
下一篇:
Golang graph.ContainsLogOut函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap