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.sizes = lru.New(1024) qs.ids = lru.New(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 }
func newQuadStore(addr string, options graph.Options) (graph.QuadStore, error) { var qs QuadStore conn, err := mgo.Dial(addr) if err != nil { return nil, err } conn.SetSafe(&mgo.Safe{}) dbName := DefaultDBName val, ok, err := options.StringKey("database_name") if err != nil { return nil, err } else if ok { dbName = val } qs.db = conn.DB(dbName) if err := ensureIndexes(qs.db); err != nil { conn.Close() return nil, err } qs.session = conn qs.ids = lru.New(1 << 16) qs.sizes = lru.New(1 << 16) return &qs, nil }