當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Options.BoolKey方法代碼示例

本文整理匯總了Golang中github.com/google/cayley/graph.Options.BoolKey方法的典型用法代碼示例。如果您正苦於以下問題:Golang Options.BoolKey方法的具體用法?Golang Options.BoolKey怎麽用?Golang Options.BoolKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/google/cayley/graph.Options的用法示例。


在下文中一共展示了Options.BoolKey方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: newQuadStore

func newQuadStore(addr string, options graph.Options) (graph.QuadStore, error) {
	var qs QuadStore
	conn, err := connectSQLTables(addr, options)
	if err != nil {
		return nil, err
	}
	localOpt, localOptOk, err := options.BoolKey("local_optimize")
	if err != nil {
		return nil, err
	}
	qs.db = conn
	qs.sqlFlavor = "postgres"
	qs.size = -1
	qs.lru = newCache(1024)

	// Skip size checking by default.
	qs.noSizes = true
	if localOptOk {
		if localOpt {
			qs.noSizes = false
		}
	}
	qs.useEstimates, _, err = options.BoolKey("use_estimates")
	if err != nil {
		return nil, err
	}

	return &qs, nil
}
開發者ID:WeiZhang555,項目名稱:clair,代碼行數:29,代碼來源:quadstore.go

示例2: newQuadStore

func newQuadStore(path string, options graph.Options) (graph.QuadStore, error) {
	var qs QuadStore
	var err error
	db, err := bolt.Open(path, 0600, nil)
	if err != nil {
		glog.Errorln("Error, couldn't open! ", err)
		return nil, err
	}
	qs.db = db
	// BoolKey returns false on non-existence. IE, Sync by default.
	qs.db.NoSync, _, err = options.BoolKey("nosync")
	if err != nil {
		return nil, err
	}
	err = qs.getMetadata()
	if err == errNoBucket {
		return nil, errors.New("bolt: quadstore has not been initialised")
	} else if err != nil {
		return nil, err
	}
	if qs.version != latestDataVersion {
		return nil, errors.New("bolt: data version is out of date. Run cayleyupgrade for your config to update the data.")
	}
	return &qs, nil
}
開發者ID:dennwc,項目名稱:cayley,代碼行數:25,代碼來源:quadstore.go

示例3: NewSingleReplication

func NewSingleReplication(qs graph.QuadStore, opts graph.Options) (graph.QuadWriter, error) {
	var (
		ignoreMissing   bool
		ignoreDuplicate bool
		err             error
	)

	if *graph.IgnoreMissing {
		ignoreMissing = true
	} else {
		ignoreMissing, _, err = opts.BoolKey("ignore_missing")
		if err != nil {
			return nil, err
		}
	}

	if *graph.IgnoreDup {
		ignoreDuplicate = true
	} else {
		ignoreDuplicate, _, err = opts.BoolKey("ignore_duplicate")
		if err != nil {
			return nil, err
		}
	}

	return &Single{
		currentID: qs.Horizon(),
		qs:        qs,
		ignoreOpts: graph.IgnoreOpts{
			IgnoreDup:     ignoreDuplicate,
			IgnoreMissing: ignoreMissing,
		},
	}, nil
}
開發者ID:e4x,項目名稱:cayley,代碼行數:34,代碼來源:single.go

示例4: newQuadStore

func newQuadStore(path string, options graph.Options) (graph.QuadStore, error) {
	var qs QuadStore
	var err error
	db, err := bolt.Open(path, 0600, nil)
	if err != nil {
		glog.Errorln("Error, couldn't open! ", err)
		return nil, err
	}
	qs.db = db
	// BoolKey returns false on non-existence. IE, Sync by default.
	qs.db.NoSync, _ = options.BoolKey("nosync")
	err = qs.getMetadata()
	if err != nil {
		return nil, err
	}
	return &qs, nil
}
開發者ID:ericcapricorn,項目名稱:cayley,代碼行數:17,代碼來源:quadstore.go

示例5: newQuadStore

func newQuadStore(path string, options graph.Options) (graph.QuadStore, error) {
	var qs QuadStore
	var err error
	db, err := bolt.Open(path, 0600, nil)
	if err != nil {
		glog.Errorln("Error, couldn't open! ", err)
		return nil, err
	}
	qs.db = db
	// BoolKey returns false on non-existence. IE, Sync by default.
	qs.db.NoSync, _, err = options.BoolKey("nosync")
	if err != nil {
		return nil, err
	}
	err = qs.getMetadata()
	if err == errNoBucket {
		panic("bolt: quadstore has not been initialised")
	} else if err != nil {
		return nil, err
	}
	return &qs, nil
}
開發者ID:oliverp19,項目名稱:cayley,代碼行數:22,代碼來源:quadstore.go

示例6: createLMDB

func createLMDB(path string, opt graph.Options) (env *lmdb.Env, err error) {
	err = os.Mkdir(path, 0700)
	if err != nil && !os.IsExist(err) {
		return nil, err
	}

	env, err = lmdb.NewEnv()
	if err != nil {
		return env, err
	}
	defer func() {
		if err != nil {
			env.Close()
			env = nil
		}
	}()

	maxreaders, _, err := opt.IntKey("maxreaders")
	if err != nil {
		return nil, err
	}
	if maxreaders > 0 {
		err = env.SetMaxReaders(maxreaders)
		if err != nil {
			return nil, err
		}
	}

	maxdbs, _, err := opt.IntKey("maxdbs")
	if err != nil {
		return nil, err
	}
	if maxdbs == 0 {
		maxdbs = 7
	}
	err = env.SetMaxDBs(maxdbs)
	if err != nil {
		return nil, err
	}

	mapsize, _, err := opt.IntKey("mapsize")
	if err != nil {
		return nil, err
	}
	err = env.SetMapSize(int64(mapsize))
	if err != nil {
		return nil, err
	}

	var flags uint
	dbnosync, _, err := opt.BoolKey("nosync")
	if err != nil {
		return nil, err
	}
	if dbnosync {
		flags |= lmdb.NoSync
	}
	err = env.Open(path, flags, 0600)
	if err != nil {
		return nil, err
	}

	return env, nil
}
開發者ID:bmatsuo,項目名稱:cayley,代碼行數:64,代碼來源:quadstore.go


注:本文中的github.com/google/cayley/graph.Options.BoolKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。