本文整理匯總了Golang中github.com/google/stenographer/indexfile.IndexFile類的典型用法代碼示例。如果您正苦於以下問題:Golang IndexFile類的具體用法?Golang IndexFile怎麽用?Golang IndexFile使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了IndexFile類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: log
func log(q Query, i *indexfile.IndexFile, bp *base.Positions, err *error) func() {
start := time.Now()
if q.base() {
indexBaseLookupsStarted.Increment()
} else {
indexSetLookupsStarted.Increment()
}
return func() {
duration := time.Since(start)
if q.base() {
indexBaseLookupsFinished.Increment()
indexBaseLookupNanos.IncrementBy(duration.Nanoseconds())
} else {
indexSetLookupsFinished.Increment()
indexSetLookupNanos.IncrementBy(duration.Nanoseconds())
}
v(3, "Query %q in %q took %v, found %d %v", q, i.Name(), duration, len(*bp), *err)
}
}
示例2: LookupIn
func (a timeQuery) LookupIn(ctx context.Context, index *indexfile.IndexFile) (bp base.Positions, err error) {
defer log(a, index, &bp, &err)()
last := filepath.Base(index.Name())
intval, err := strconv.ParseInt(last, 10, 64)
if err != nil {
return nil, fmt.Errorf("could not parse basename %q: %v", last, err)
}
t := time.Unix(0, intval*1000) // converts micros -> nanos
// Note, we add a minute when doing 'before' queries and subtract a minute
// when doing 'after' queries, to make sure we actually get the time
// specified.
if !a[0].IsZero() && t.Before(a[0].Add(time.Minute)) {
v(2, "time query skipping %q", index.Name())
return base.NoPositions, nil
}
if !a[1].IsZero() && t.After(a[1].Add(-time.Minute)) {
v(2, "time query skipping %q", index.Name())
return base.NoPositions, nil
}
v(2, "time query using %q", index.Name())
return base.AllPositions, nil
}