id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c12100
== atomic.LoadUint64(q.read.processing) }
c12101
} for n := depth; n <= maxDepth; n++ { shortTypeName := strings.Join(pathTokens[len(pathTokens)-n:], ".") + "." + typeName registry.namedType[shortTypeName] = structType } }
c12102
exists { return reflect.PtrTo(structType) } return nil }
c12103
string) bool { _, exists := registry.namedType[typeName] return exists }
c12104
if strings.HasPrefix(key, packageName) { result = append(result, key) } } return result }
c12105
ResetColors, c, b, text, ResetColors.String()) }
c12106
= append([]interface{}{ResetColors, c, b}, args...) args = append(args, ResetColors) return fmt.Sprintf("%s%s%s"+format+"%s", args...) }
c12107
new(int32), priority: priority, } }
c12108
mic.CompareAndSwapInt32(m.state, mutexUnlocked, mutexLocked) }
c12109
return len(message), nil }
c12110
|= v >> 1 v |= v >> 2 v |= v >> 4 v |= v >> 8 v++ return v }
c12111
>> 1 v |= v >> 2 v |= v >> 4 v |= v >> 8 v |= v >> 16 v++ return v }
c12112
v |= v >> 16 v |= v >> 32 v++ return v }
c12113
NewStackWithSpinnerAndGrowSize(size, grow, NewSpinner(SpinPriorityMedium)) }
c12114
NewStackWithSpinnerAndGrowSize(size, size, spin) }
c12115
growBy: tmath.MinI(grow, 1), head: new(uint32), spin: spin, } }
c12116
int(atomic.LoadUint32(s.head) & unlockMask) }
c12117
if unlockedHead == 0 { return nil, LimitError{"Stack is empty"} } if atomic.CompareAndSwapUint32(s.head, unlockedHead, lockedHead) { data := s.data[unlockedHead-1] // copy data atomic.StoreUint32(s.head, unlockedHead-1) // unlock return data, nil // ### return ###...
c12118
s.data = make([]interface{}, len(s.data)+s.growBy) copy(s.data, old) } s.data[unlockedHead] = v // write to new head atomic.StoreUint32(s.head, unlockedHead+1) // unlock return nil // ### return ### } spin.Yield() } }
c12119
return int(math.Log10(float64(number)) + 1) } }
c12120
numberLen - 1; i >= 0; i-- { buffer[i] = '0' + byte(number%10) number /= 10 } return nil }
c12121
written, too if number == 0 { return nil } } return fmt.Errorf("Number too large for buffer") }
c12122
{ parsed := uint64(buffer[index] - '0') number = number*10 + parsed index++ } return number, index }
c12123
if nextIdx == -1 { return -1 // ### return, not found ### } sepIdx += nextIdx + 1 } return sepIdx - 1 }
c12124
if sepIdx == -1 { return -1 // ### return, not found ### } } return sepIdx }
c12125
'-' || i != 0) { return false } } return true }
c12126
:= json.Unmarshal(data, delayedResult) return err == nil, err, delayedResult }
c12127
stringHeader.Len, Cap: stringHeader.Len, } return *(*ByteRef)(unsafe.Pointer(sliceHeader)) }
c12128
Len: sliceHeader.Len, } return *(*StringRef)(unsafe.Pointer(stringHeader)) }
c12129
1 { return a[0].String() } str := make([]string, len(a)) for i, s := range a { str[i] = s.String() } return strings.Join(str, sep) }
c12130
return num[2:], 16 } return num[1:], 8 } return num, 10 }
c12131
n, b := GetNumBase(num) return strconv.ParseInt(n, b, 64) }
c12132
n, b := GetNumBase(num) return strconv.ParseUint(n, b, 64) }
c12133
to JSON: %v", k) fmt.Printf("redistore.JSONSerializer.serialize() Error: %v", err) return nil, err } m[ks] = v } return json.Marshal(m) }
c12134
enc := gob.NewEncoder(buf) err := enc.Encode(ss.Values) if err == nil { return buf.Bytes(), nil } return nil, err }
c12135
nil || data == nil { return false, err } return (data == "PONG"), nil }
c12136
err = conn.Err(); err != nil { return err } age := session.Options.MaxAge if age == 0 { age = s.DefaultMaxAge } _, err = conn.Do("SETEX", s.keyPrefix+session.ID, age, b) return err }
c12137
nil { return false, nil // no data was associated with this key } b, err := redis.Bytes(data, err) if err != nil { return false, err } return true, s.serializer.Deserialize(b, session) }
c12138
s.keyPrefix+session.ID); err != nil { return err } return nil }
c12139
bool) { m.lock.RLock() elem, found = m.data[key] m.lock.RUnlock() return }
c12140
m.data[key] = elem m.lock.Unlock() }
c12141
runtime.Goexit() to quit if recovered != nil { if executor.HandlePanic == nil { HandlePanic(recovered, funcName) } else { executor.HandlePanic(recovered, funcName) } } executor.activeGoroutinesMutex.Lock() executor.activeGoroutines[startFrom] -= 1 executor.activeGoroutinesMutex.Unl...
c12142
* 100) select { case <-oneHundredMilliseconds.C: if executor.checkNoActiveGoroutines() { return } case <-ctx.Done(): return } } }
c12143
b = strconv.AppendUint(b, v.Uint(), 10) case stats.Float: b = strconv.AppendFloat(b, v.Float(), 'g', -1, 64) case stats.Duration: b = strconv.AppendFloat(b, v.Duration().Seconds(), 'g', -1, 64) } } b = append(b, ' ') b = strconv.AppendInt(b, t.UnixNano(), 10) return append(b, '\n') }
c12144
Prefix: prefix, Tags: SortTags(copyTags(tags)), } }
c12145
{ eng.Handler = MultiHandler(eng.Handler, handler) } }
c12146
eng.makeName(prefix), Tags: eng.makeTags(tags), } }
c12147
eng.ClockAt(name, time.Now(), tags...) }
c12148
tags) return &Clock{ name: name, first: start, last: start, tags: cpy, eng: eng, } }
c12149
mb.measures = appendMeasures(mb.measures[:0], &eng.cache, eng.Prefix, reflect.ValueOf(metrics), tags...) ms := mb.measures eng.Handler.HandleMeasures(time, ms...) for i := range ms { ms[i].reset() } if tb != nil { tb.reset() tagsPool.Put(tb) } measurePool.Put(mb) }
c12150
DefaultEngine.WithPrefix(prefix, tags...) }
c12151
DefaultEngine.IncrAt(time, name, tags...) }
c12152
DefaultEngine.ObserveAt(time, name, value, tags...) }
c12153
DefaultEngine.ReportAt(time, metrics, tags...) }
c12154
AppendMeasureFiltered(b, m, nil) }
c12155
500: return statusCodeWithTable(code-400, statusCode400[:]) case code < 600: return statusCodeWithTable(code-500, statusCode500[:]) } } return strconv.Itoa(code) }
c12156
} b = appendFloat(b, valueOf(v)) } return *(*string)(unsafe.Pointer(&reflect.StringHeader{ Data: uintptr(unsafe.Pointer(&b[0])), Len: len(b), })) }
c12157
we unfortunately have to overflow the configured buffer // size, but the Serializer documentation mentions that this corner // case has to be handled. length = buffer.len() } buffer.flush(b.Serializer, length) } buffer.release() }
c12158
buffer.flush(b.Serializer, buffer.len()) buffer.release() } } }
c12159
res SearchResponse, req *SearchRequest) error { return f(ctx, res, req) }
c12160
Field { f := Field{Name: name, Value: ValueOf(value)} f.setType(ftype) return f }
c12161
{ return NewTransportWith(stats.DefaultEngine, t) }
c12162
&transport{ transport: t, eng: eng, } }
c12163
contextKeyReqTags, tags) return req.WithContext(ctx) }
c12164
m := &metrics{} req.Body = &requestBody{ eng: eng, req: req, metrics: m, body: req.Body, op: "write", } res, err = rtrip.RoundTrip(req) // safe guard, the transport should have done it already req.Body.Close() // nolint if err != nil { m.observeError(time.Now().Sub(start)) eng.Re...
c12165
res QueryResponse, req *QueryRequest) error { return f(ctx, res, req) }
c12166
Column{Text: text, Type: colType} }
c12167
Column{Text: text, Type: colType, Sort: true} }
c12168
text, Type: colType, Sort: true, Desc: true} }
c12169
buckets { v[i] = ValueOf(b) } b[makeKey(key)] = v }
c12170
p.memory.pagefault.minor.typ = "minor" p.threads.switches.voluntary.typ = "voluntary" p.threads.switches.involuntary.typ = "involuntary" return p }
c12171
http.NewServeMux() Handle(mux, prefix, handler) return mux }
c12172
datadog.ClientConfig{Address: addr}}) }
c12173
datadog.ClientConfig{Address: addr}, GlobalOnly: true}) }
c12174
tags = append(tags, stats.Tag{Name: LocalOnly}) } for _, t := range config.SinksOnly { tags = append(tags, stats.Tag{Name: SinkOnly, Value: t}) } return &Client{ Client: datadog.NewClientWith(datadog.ClientConfig{ Address: config.Address, BufferSize: config.BufferSize, Filters: config.Filters,...
c12175
{ return NewHandlerWith(stats.DefaultEngine, h) }
c12176
&handler{ handler: h, eng: eng, } }
c12177
!= nil { return } err = Serve(conn, handler) return }
c12178
done) } for i := 0; i != concurrency; i++ { switch e := <-done; e { case nil, io.EOF, io.ErrClosedPipe, io.ErrUnexpectedEOF: default: err = e } conn.Close() } return }
c12179
{ tags = append(tags, T(k, v)) } return tags }
c12180
return false } min = tag.Name } } return true }
c12181
20 { sort.Sort(tagsByName(tags)) } else { for i := 0; i < len(tags); i++ { for j := i; j > 0 && tags[j-1].Name > tags[j].Name; j-- { tags[j], tags[j-1] = tags[j-1], tags[j] } } } return tags }
c12182
conn, bufferSize, err := dial(config.Address, config.BufferSize) if err != nil { log.Printf("stats/datadog: %s", err) } c.conn, c.err, c.bufferSize = conn, err, bufferSize c.buffer.BufferSize = bufferSize c.buffer.Serializer = &c.serializer log.Printf("stats/datadog: sending metrics with a buffer of size %d B...
c12183
res AnnotationsResponse, req *AnnotationsRequest) error { return f(ctx, res, req) }
c12184
...Measure) { f(time, measures...) }
c12185
} else { multi = append(multi, h) } } } if len(multi) == 1 { return multi[0] } return &multiHandler{handlers: multi} }
c12186
Handler { return &handler{ handler: hdl, eng: eng, } }
c12187
if acceptEncoding(req.Header.Get("Accept-Encoding"), "gzip") { res.Header().Set("Content-Encoding", "gzip") zw := gzip.NewWriter(w) defer zw.Close() w = zw } h.WriteStats(w) }
c12188
make(chan struct{}), http: http.Client{ Timeout: config.Timeout, Transport: config.Transport, }, }, } c.buffer.BufferSize = config.BufferSize c.buffer.Serializer = &c.serializer return c }
c12189
fmt.Sprintf("q=CREATE DATABASE %q", db), )) if err != nil { return err } return readResponse(r) }
c12190
c.observe("total", now.Sub(c.first)) }
c12191
return &DelayMetrics{engine: eng, pid: pid} }
c12192
"mspan" g.memstats.mcache.memtype = "mcache" g.memstats.buckhash.memtype = "bucket_hash_table" g.memstats.gc.memtype = "gc" g.memstats.other.memtype = "other" return g }
c12193
{ return NewConnWith(stats.DefaultEngine, c) }
c12194
nc.w.metrics.protocol = proto eng.Incr("conn.open:count", stats.T("protocol", proto)) return nc }
c12195
if err != nil { return nil, err } return strings.Split(products, "\n"), nil }
c12196
err } if _, err := godelw.run("dist", product); err != nil { return "", err } return godelw.run("artifacts", "dist", "--absolute", product) }
c12197
!= nil { panic(errors.Wrapf(err, "failed to create plugin info")) } return cmd }
c12198
{ return fmt.Sprintf("%v-%v", o.OS, o.Arch) }
c12199
len(mapSlice) != 0 { return nil, errors.Errorf("%s does not currently support configuration", name) } return cfgBytes, nil }