本文整理汇总了Golang中github.com/cayleygraph/cayley/clog.Infof函数的典型用法代码示例。如果您正苦于以下问题:Golang Infof函数的具体用法?Golang Infof怎么用?Golang Infof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Infof函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NextPath
// Get the next result that matches this branch.
func (it *HasA) NextPath() bool {
// Order here is important. If the subiterator has a NextPath, then we
// need do nothing -- there is a next result, and we shouldn't move forward.
// However, we then need to get the next result from our last Contains().
//
// The upshot is, the end of NextPath() bubbles up from the bottom of the
// iterator tree up, and we need to respect that.
if clog.V(4) {
clog.Infof("HASA %v NextPath", it.UID())
}
if it.primaryIt.NextPath() {
return true
}
it.err = it.primaryIt.Err()
if it.err != nil {
return false
}
result := it.NextContains() // Sets it.err if there's an error
if it.err != nil {
return false
}
if clog.V(4) {
clog.Infof("HASA %v NextPath Returns %v", it.UID(), result)
}
return result
}
示例2: Execute
func (s *Session) Execute(input string, c chan interface{}, _ int) {
defer close(c)
var mqlQuery interface{}
err := json.Unmarshal([]byte(input), &mqlQuery)
if err != nil {
return
}
s.currentQuery = NewQuery(s)
s.currentQuery.BuildIteratorTree(mqlQuery)
if s.currentQuery.isError() {
return
}
it, _ := s.currentQuery.it.Optimize()
if clog.V(2) {
b, err := json.MarshalIndent(it.Describe(), "", " ")
if err != nil {
clog.Infof("failed to format description: %v", err)
} else {
clog.Infof("%s", b)
}
}
for graph.Next(it) {
tags := make(map[string]graph.Value)
it.TagResults(tags)
c <- tags
for it.NextPath() == true {
tags := make(map[string]graph.Value)
it.TagResults(tags)
c <- tags
}
}
}
示例3: Load
func Load(qw graph.QuadWriter, cfg *config.Config, dec quad.Unmarshaler) error {
block := make([]quad.Quad, 0, cfg.LoadSize)
count := 0
for {
t, err := dec.Unmarshal()
if err != nil {
if err == io.EOF {
break
}
return err
}
block = append(block, t)
if len(block) == cap(block) {
count += len(block)
err := qw.AddQuadSet(block)
if err != nil {
return fmt.Errorf("db: failed to load data: %v", err)
}
block = block[:0]
if clog.V(2) {
clog.Infof("Wrote %d quads.", count)
}
}
}
count += len(block)
err := qw.AddQuadSet(block)
if err != nil {
return fmt.Errorf("db: failed to load data: %v", err)
}
if clog.V(2) {
clog.Infof("Wrote %d quads.", count)
}
return nil
}
示例4: makeCursor
func (it *AllIterator) makeCursor() {
var cursor *sql.Rows
var err error
if it.cursor != nil {
it.cursor.Close()
}
if it.table == "quads" {
cursor, err = it.qs.db.Query(`SELECT
subject_hash,
predicate_hash,
object_hash,
label_hash
FROM quads;`)
if err != nil {
clog.Errorf("Couldn't get cursor from SQL database: %v", err)
cursor = nil
}
} else {
if clog.V(4) {
clog.Infof("sql: getting node query")
}
cursor, err = it.qs.db.Query(`SELECT hash FROM nodes;`)
if err != nil {
clog.Errorf("Couldn't get cursor from SQL database: %v", err)
cursor = nil
}
if clog.V(4) {
clog.Infof("sql: got node query")
}
}
it.cursor = cursor
}
示例5: NextLogOut
func NextLogOut(it Iterator, val Value, ok bool) bool {
if clog.V(4) {
if ok {
clog.Infof("%s %d NEXT IS %v", strings.ToUpper(it.Type().String()), it.UID(), val)
} else {
clog.Infof("%s %d NEXT DONE", strings.ToUpper(it.Type().String()), it.UID())
}
}
return ok
}
示例6: ContainsLogOut
func ContainsLogOut(it Iterator, val Value, good bool) bool {
if clog.V(4) {
if good {
clog.Infof("%s %d CHECK CONTAINS %v GOOD", strings.ToUpper(it.Type().String()), it.UID(), val)
} else {
clog.Infof("%s %d CHECK CONTAINS %v BAD", strings.ToUpper(it.Type().String()), it.UID(), val)
}
}
return good
}
示例7: NextLogOut
func NextLogOut(it Iterator, ok bool) bool {
if clog.V(4) {
if ok {
val := it.Result()
clog.Infof("%s %d NEXT IS %v (%T)", strings.ToUpper(it.Type().String()), it.UID(), val, val)
} else {
clog.Infof("%s %d NEXT DONE", strings.ToUpper(it.Type().String()), it.UID())
}
}
return ok
}
示例8: end
func (c *IterateChain) end() {
c.it.Close()
if !clog.V(2) {
return
}
if b, err := json.MarshalIndent(DumpStats(c.it), "", " "); err != nil {
clog.Infof("failed to format stats: %v", err)
} else {
clog.Infof("%s", b)
}
}
示例9: Size
// Size is the number of values stored, if we've got them all.
// Otherwise, guess based on the size of the subiterator.
func (it *Materialize) Size() (int64, bool) {
if it.hasRun && !it.aborted {
if clog.V(2) {
clog.Infof("returning size %v", it.actualSize)
}
return it.actualSize, true
}
if clog.V(2) {
clog.Infof("bailing size %v", it.actualSize)
}
return it.subIt.Size()
}
示例10: sizeForIterator
func (qs *QuadStore) sizeForIterator(isAll bool, dir quad.Direction, hash NodeHash) int64 {
var err error
if isAll {
return qs.Size()
}
if qs.noSizes {
if dir == quad.Predicate {
return (qs.Size() / 100) + 1
}
return (qs.Size() / 1000) + 1
}
if val, ok := qs.sizes.Get(hash.String() + string(dir.Prefix())); ok {
return val.(int64)
}
var size int64
if clog.V(4) {
clog.Infof("sql: getting size for select %s, %v", dir.String(), hash)
}
err = qs.db.QueryRow(
fmt.Sprintf("SELECT count(*) FROM quads WHERE %s_hash = $1;", dir.String()), hash.toSQL()).Scan(&size)
if err != nil {
clog.Errorf("Error getting size from SQL database: %v", err)
return 0
}
qs.sizes.Put(hash.String()+string(dir.Prefix()), size)
return size
}
示例11: start
func (c *IterateChain) start() {
if c.optimize {
c.it, _ = c.it.Optimize()
if c.qs != nil {
c.it, _ = c.qs.OptimizeIterator(c.it)
}
}
if !clog.V(2) {
return
}
if b, err := json.MarshalIndent(c.it.Describe(), "", " "); err != nil {
clog.Infof("failed to format description: %v", err)
} else {
clog.Infof("%s", b)
}
}
示例12: NameOf
func (qs *QuadStore) NameOf(k graph.Value) string {
if k == nil {
clog.Infof("k was nil")
return ""
}
return qs.valueData(k.(Token)).Name
}
示例13: LogRequest
func LogRequest(handler ResponseHandler) httprouter.Handle {
return func(w http.ResponseWriter, req *http.Request, params httprouter.Params) {
start := time.Now()
addr := req.Header.Get("X-Real-IP")
if addr == "" {
addr = req.Header.Get("X-Forwarded-For")
if addr == "" {
addr = req.RemoteAddr
}
}
clog.Infof("Started %s %s for %s", req.Method, req.URL.Path, addr)
code := handler(w, req, params)
clog.Infof("Completed %v %s %s in %v", code, http.StatusText(code), req.URL.Path, time.Since(start))
}
}
示例14: configFrom
func configFrom(file string) *config.Config {
// Find the file...
if file != "" {
if _, err := os.Stat(file); os.IsNotExist(err) {
clog.Fatalf("Cannot find specified configuration file '%s', aborting.", file)
}
} else if _, err := os.Stat(os.Getenv("CAYLEY_CFG")); err == nil {
file = os.Getenv("CAYLEY_CFG")
} else if _, err := os.Stat("/etc/cayley.cfg"); err == nil {
file = "/etc/cayley.cfg"
}
if file == "" {
clog.Infof("Couldn't find a config file in either $CAYLEY_CFG or /etc/cayley.cfg. Going by flag defaults only.")
}
cfg, err := config.Load(file)
if err != nil {
clog.Fatalf("%v", err)
}
if cfg.DatabasePath == "" {
cfg.DatabasePath = *databasePath
}
if cfg.DatabaseType == "" {
cfg.DatabaseType = *databaseBackend
}
return cfg
}
示例15: runIterator
func (wk *worker) runIterator(it graph.Iterator) {
if wk.wantShape() {
iterator.OutputQueryShapeForIterator(it, wk.qs, wk.shape)
return
}
it, _ = it.Optimize()
if clog.V(2) {
b, err := json.MarshalIndent(it.Describe(), "", " ")
if err != nil {
clog.Infof("failed to format description: %v", err)
} else {
clog.Infof("%s", b)
}
}
for {
select {
case <-wk.kill:
return
default:
}
if !graph.Next(it) {
break
}
tags := make(map[string]graph.Value)
it.TagResults(tags)
if !wk.send(&Result{actualResults: tags}) {
break
}
for it.NextPath() {
select {
case <-wk.kill:
return
default:
}
tags := make(map[string]graph.Value)
it.TagResults(tags)
if !wk.send(&Result{actualResults: tags}) {
break
}
}
}
if clog.V(2) {
bytes, _ := json.MarshalIndent(graph.DumpStats(it), "", " ")
clog.Infof(string(bytes))
}
it.Close()
}