id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
144,300 | Netflix/rend | handlers/memcached/std/handler.go | NewHandler | func NewHandler(conn io.ReadWriteCloser) Handler {
rw := bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn))
return Handler{
rw: rw,
conn: conn,
}
} | go | func NewHandler(conn io.ReadWriteCloser) Handler {
rw := bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn))
return Handler{
rw: rw,
conn: conn,
}
} | [
"func",
"NewHandler",
"(",
"conn",
"io",
".",
"ReadWriteCloser",
")",
"Handler",
"{",
"rw",
":=",
"bufio",
".",
"NewReadWriter",
"(",
"bufio",
".",
"NewReader",
"(",
"conn",
")",
",",
"bufio",
".",
"NewWriter",
"(",
"conn",
")",
")",
"\n",
"return",
"H... | // NewHandler returns an implementation of handlers.Handler that implements a straightforward
// request-response like normal memcached usage. | [
"NewHandler",
"returns",
"an",
"implementation",
"of",
"handlers",
".",
"Handler",
"that",
"implements",
"a",
"straightforward",
"request",
"-",
"response",
"like",
"normal",
"memcached",
"usage",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/std/handler.go#L49-L55 |
144,301 | Netflix/rend | metrics/callbackgauges.go | RegisterIntGaugeCallback | func RegisterIntGaugeCallback(name string, tgs Tags, cb IntGaugeCallback) {
id := atomic.AddUint32(curIntCbID, 1) - 1
if id >= maxNumCallbacks {
panic("Too many callbacks")
}
intcallbacks[id] = cb
intcbnames[id] = name
tgs = copyTags(tgs)
tgs[TagMetricType] = MetricTypeGauge
intcbtags[id] = tgs
} | go | func RegisterIntGaugeCallback(name string, tgs Tags, cb IntGaugeCallback) {
id := atomic.AddUint32(curIntCbID, 1) - 1
if id >= maxNumCallbacks {
panic("Too many callbacks")
}
intcallbacks[id] = cb
intcbnames[id] = name
tgs = copyTags(tgs)
tgs[TagMetricType] = MetricTypeGauge
intcbtags[id] = tgs
} | [
"func",
"RegisterIntGaugeCallback",
"(",
"name",
"string",
",",
"tgs",
"Tags",
",",
"cb",
"IntGaugeCallback",
")",
"{",
"id",
":=",
"atomic",
".",
"AddUint32",
"(",
"curIntCbID",
",",
"1",
")",
"-",
"1",
"\n\n",
"if",
"id",
">=",
"maxNumCallbacks",
"{",
... | // RegisterIntGaugeCallback registers a gauge callback which will be called every
// time metrics are requested.
// There is a maximum of 10240 int callbacks, after which adding a new one will panic. | [
"RegisterIntGaugeCallback",
"registers",
"a",
"gauge",
"callback",
"which",
"will",
"be",
"called",
"every",
"time",
"metrics",
"are",
"requested",
".",
"There",
"is",
"a",
"maximum",
"of",
"10240",
"int",
"callbacks",
"after",
"which",
"adding",
"a",
"new",
"... | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/callbackgauges.go#L44-L57 |
144,302 | Netflix/rend | metrics/callbackgauges.go | RegisterFloatGaugeCallback | func RegisterFloatGaugeCallback(name string, tgs Tags, cb FloatGaugeCallback) {
id := atomic.AddUint32(curFloatCbID, 1) - 1
if id >= maxNumCallbacks {
panic("Too many callbacks")
}
floatcallbacks[id] = cb
floatcbnames[id] = name
tgs = copyTags(tgs)
tgs[TagMetricType] = MetricTypeGauge
floatcbtags[id] = tgs... | go | func RegisterFloatGaugeCallback(name string, tgs Tags, cb FloatGaugeCallback) {
id := atomic.AddUint32(curFloatCbID, 1) - 1
if id >= maxNumCallbacks {
panic("Too many callbacks")
}
floatcallbacks[id] = cb
floatcbnames[id] = name
tgs = copyTags(tgs)
tgs[TagMetricType] = MetricTypeGauge
floatcbtags[id] = tgs... | [
"func",
"RegisterFloatGaugeCallback",
"(",
"name",
"string",
",",
"tgs",
"Tags",
",",
"cb",
"FloatGaugeCallback",
")",
"{",
"id",
":=",
"atomic",
".",
"AddUint32",
"(",
"curFloatCbID",
",",
"1",
")",
"-",
"1",
"\n\n",
"if",
"id",
">=",
"maxNumCallbacks",
"... | // RegisterFloatGaugeCallback registers a gauge callback which will be called every
// time metrics are requested.
// There is a maximum of 10240 float callbacks, after which adding a new one will panic. | [
"RegisterFloatGaugeCallback",
"registers",
"a",
"gauge",
"callback",
"which",
"will",
"be",
"called",
"every",
"time",
"metrics",
"are",
"requested",
".",
"There",
"is",
"a",
"maximum",
"of",
"10240",
"float",
"callbacks",
"after",
"which",
"adding",
"a",
"new",... | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/callbackgauges.go#L62-L75 |
144,303 | Netflix/rend | client/stats/stats.go | Get | func Get(data []int) Stats {
if len(data) == 0 {
return Stats{}
}
min, max := minmax(data)
return Stats{
Avg: avg(data) / msFactor,
Min: min / msFactor,
Max: max / msFactor,
P50: p(data, 0.5) / msFactor,
P75: p(data, 0.75) / msFactor,
P90: p(data, 0.9) / msFactor,
P95: p(data, 0.95) / msFactor,
P... | go | func Get(data []int) Stats {
if len(data) == 0 {
return Stats{}
}
min, max := minmax(data)
return Stats{
Avg: avg(data) / msFactor,
Min: min / msFactor,
Max: max / msFactor,
P50: p(data, 0.5) / msFactor,
P75: p(data, 0.75) / msFactor,
P90: p(data, 0.9) / msFactor,
P95: p(data, 0.95) / msFactor,
P... | [
"func",
"Get",
"(",
"data",
"[",
"]",
"int",
")",
"Stats",
"{",
"if",
"len",
"(",
"data",
")",
"==",
"0",
"{",
"return",
"Stats",
"{",
"}",
"\n",
"}",
"\n",
"min",
",",
"max",
":=",
"minmax",
"(",
"data",
")",
"\n\n",
"return",
"Stats",
"{",
... | // Accepts a sorted slice of durations in nanoseconds
// Returns a Stats struct of millisecond statistics | [
"Accepts",
"a",
"sorted",
"slice",
"of",
"durations",
"in",
"nanoseconds",
"Returns",
"a",
"Stats",
"struct",
"of",
"millisecond",
"statistics"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/client/stats/stats.go#L35-L51 |
144,304 | Netflix/rend | handlers/memcached/chunked/chunkedLimitedReader.go | Read | func (c chunkedLimitedReader) Read(p []byte) (n int, err error) {
// If we've already read all our chunks and the remainders are <= 0, we're done
if c.d.doneChunks >= c.d.numChunks || (c.d.remaining <= 0 && c.d.chunkRem <= 0) {
return 0, io.EOF
}
// Data is done, returning only buffer bytes now
if c.d.remaining... | go | func (c chunkedLimitedReader) Read(p []byte) (n int, err error) {
// If we've already read all our chunks and the remainders are <= 0, we're done
if c.d.doneChunks >= c.d.numChunks || (c.d.remaining <= 0 && c.d.chunkRem <= 0) {
return 0, io.EOF
}
// Data is done, returning only buffer bytes now
if c.d.remaining... | [
"func",
"(",
"c",
"chunkedLimitedReader",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"// If we've already read all our chunks and the remainders are <= 0, we're done",
"if",
"c",
".",
"d",
".",
"doneChunks",
">=... | // io.Reader's interface implements this as a value method, not a pointer method. | [
"io",
".",
"Reader",
"s",
"interface",
"implements",
"this",
"as",
"a",
"value",
"method",
"not",
"a",
"pointer",
"method",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/chunkedLimitedReader.go#L53-L89 |
144,305 | Netflix/rend | handlers/memcached/chunked/handler.go | Add | func (h Handler) Add(cmd common.SetRequest) error {
return h.handleSetCommon(cmd, common.RequestAdd)
} | go | func (h Handler) Add(cmd common.SetRequest) error {
return h.handleSetCommon(cmd, common.RequestAdd)
} | [
"func",
"(",
"h",
"Handler",
")",
"Add",
"(",
"cmd",
"common",
".",
"SetRequest",
")",
"error",
"{",
"return",
"h",
".",
"handleSetCommon",
"(",
"cmd",
",",
"common",
".",
"RequestAdd",
")",
"\n",
"}"
] | // Add performs an add request on the remote backend | [
"Add",
"performs",
"an",
"add",
"request",
"on",
"the",
"remote",
"backend"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/handler.go#L148-L150 |
144,306 | Netflix/rend | handlers/memcached/chunked/handler.go | Replace | func (h Handler) Replace(cmd common.SetRequest) error {
return h.handleSetCommon(cmd, common.RequestReplace)
} | go | func (h Handler) Replace(cmd common.SetRequest) error {
return h.handleSetCommon(cmd, common.RequestReplace)
} | [
"func",
"(",
"h",
"Handler",
")",
"Replace",
"(",
"cmd",
"common",
".",
"SetRequest",
")",
"error",
"{",
"return",
"h",
".",
"handleSetCommon",
"(",
"cmd",
",",
"common",
".",
"RequestReplace",
")",
"\n",
"}"
] | // Replace performs a replace request on the remote backend | [
"Replace",
"performs",
"a",
"replace",
"request",
"on",
"the",
"remote",
"backend"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/handler.go#L153-L155 |
144,307 | Netflix/rend | handlers/memcached/chunked/handler.go | exptime | func exptime(ttl uint32) (exp uint32, expired bool) {
// zero is the special forever case
if ttl == 0 {
return 0, false
}
now := uint32(time.Now().Unix())
// The memcached protocol has a... "quirk" where any expiration time over 30
// days is considered to be a unix timestamp.
if ttl > realTimeMaxDelta {
r... | go | func exptime(ttl uint32) (exp uint32, expired bool) {
// zero is the special forever case
if ttl == 0 {
return 0, false
}
now := uint32(time.Now().Unix())
// The memcached protocol has a... "quirk" where any expiration time over 30
// days is considered to be a unix timestamp.
if ttl > realTimeMaxDelta {
r... | [
"func",
"exptime",
"(",
"ttl",
"uint32",
")",
"(",
"exp",
"uint32",
",",
"expired",
"bool",
")",
"{",
"// zero is the special forever case",
"if",
"ttl",
"==",
"0",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n\n",
"now",
":=",
"uint32",
"(",
"time",
... | // Takes a TTL in seconds and returns the unix time in seconds when the item will expire. | [
"Takes",
"a",
"TTL",
"in",
"seconds",
"and",
"returns",
"the",
"unix",
"time",
"in",
"seconds",
"when",
"the",
"item",
"will",
"expire",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/handler.go#L191-L207 |
144,308 | Netflix/rend | handlers/memcached/chunked/handler.go | Append | func (h Handler) Append(cmd common.SetRequest) error {
return h.handleAppendPrependCommon(cmd, common.RequestAppend)
} | go | func (h Handler) Append(cmd common.SetRequest) error {
return h.handleAppendPrependCommon(cmd, common.RequestAppend)
} | [
"func",
"(",
"h",
"Handler",
")",
"Append",
"(",
"cmd",
"common",
".",
"SetRequest",
")",
"error",
"{",
"return",
"h",
".",
"handleAppendPrependCommon",
"(",
"cmd",
",",
"common",
".",
"RequestAppend",
")",
"\n",
"}"
] | // Append performs an append request on the remote backend | [
"Append",
"performs",
"an",
"append",
"request",
"on",
"the",
"remote",
"backend"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/handler.go#L338-L340 |
144,309 | Netflix/rend | handlers/memcached/chunked/handler.go | Prepend | func (h Handler) Prepend(cmd common.SetRequest) error {
return h.handleAppendPrependCommon(cmd, common.RequestPrepend)
} | go | func (h Handler) Prepend(cmd common.SetRequest) error {
return h.handleAppendPrependCommon(cmd, common.RequestPrepend)
} | [
"func",
"(",
"h",
"Handler",
")",
"Prepend",
"(",
"cmd",
"common",
".",
"SetRequest",
")",
"error",
"{",
"return",
"h",
".",
"handleAppendPrependCommon",
"(",
"cmd",
",",
"common",
".",
"RequestPrepend",
")",
"\n",
"}"
] | // Prepend performs a prepend request on the remote backend | [
"Prepend",
"performs",
"a",
"prepend",
"request",
"on",
"the",
"remote",
"backend"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/handler.go#L343-L345 |
144,310 | Netflix/rend | handlers/memcached/chunked/handler.go | Get | func (h Handler) Get(cmd common.GetRequest) (<-chan common.GetResponse, <-chan error) {
// No buffering here so there's not multiple gets in memory
dataOut := make(chan common.GetResponse)
errorOut := make(chan error)
go realHandleGet(cmd, dataOut, errorOut, h.rw)
return dataOut, errorOut
} | go | func (h Handler) Get(cmd common.GetRequest) (<-chan common.GetResponse, <-chan error) {
// No buffering here so there's not multiple gets in memory
dataOut := make(chan common.GetResponse)
errorOut := make(chan error)
go realHandleGet(cmd, dataOut, errorOut, h.rw)
return dataOut, errorOut
} | [
"func",
"(",
"h",
"Handler",
")",
"Get",
"(",
"cmd",
"common",
".",
"GetRequest",
")",
"(",
"<-",
"chan",
"common",
".",
"GetResponse",
",",
"<-",
"chan",
"error",
")",
"{",
"// No buffering here so there's not multiple gets in memory",
"dataOut",
":=",
"make",
... | // Get performs a batched get request on the remote backend. The channels returned
// are expected to be read from until either a single error is received or the
// response channel is exhausted. | [
"Get",
"performs",
"a",
"batched",
"get",
"request",
"on",
"the",
"remote",
"backend",
".",
"The",
"channels",
"returned",
"are",
"expected",
"to",
"be",
"read",
"from",
"until",
"either",
"a",
"single",
"error",
"is",
"received",
"or",
"the",
"response",
... | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/handler.go#L468-L474 |
144,311 | Netflix/rend | handlers/memcached/chunked/handler.go | GetE | func (h Handler) GetE(cmd common.GetRequest) (<-chan common.GetEResponse, <-chan error) {
// Being minimalist, not lazy. The chunked handler is not meant to be used with a
// backing store that supports the GetE protocol extension. It would be a waste of
// time and effort to support it here if it would "never" be u... | go | func (h Handler) GetE(cmd common.GetRequest) (<-chan common.GetEResponse, <-chan error) {
// Being minimalist, not lazy. The chunked handler is not meant to be used with a
// backing store that supports the GetE protocol extension. It would be a waste of
// time and effort to support it here if it would "never" be u... | [
"func",
"(",
"h",
"Handler",
")",
"GetE",
"(",
"cmd",
"common",
".",
"GetRequest",
")",
"(",
"<-",
"chan",
"common",
".",
"GetEResponse",
",",
"<-",
"chan",
"error",
")",
"{",
"// Being minimalist, not lazy. The chunked handler is not meant to be used with a",
"// b... | // GetE performs a batched gete request on the remote backend. The channels returned
// are expected to be read from until either a single error is received or the
// response channel is exhausted. | [
"GetE",
"performs",
"a",
"batched",
"gete",
"request",
"on",
"the",
"remote",
"backend",
".",
"The",
"channels",
"returned",
"are",
"expected",
"to",
"be",
"read",
"from",
"until",
"either",
"a",
"single",
"error",
"is",
"received",
"or",
"the",
"response",
... | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/handler.go#L606-L618 |
144,312 | Netflix/rend | metrics/counters.go | IncCounterBy | func IncCounterBy(id uint32, amount uint64) {
atomic.AddUint64(&counters[id], amount)
} | go | func IncCounterBy(id uint32, amount uint64) {
atomic.AddUint64(&counters[id], amount)
} | [
"func",
"IncCounterBy",
"(",
"id",
"uint32",
",",
"amount",
"uint64",
")",
"{",
"atomic",
".",
"AddUint64",
"(",
"&",
"counters",
"[",
"id",
"]",
",",
"amount",
")",
"\n",
"}"
] | // IncCounterBy increments the specified counter by the given amount. This is for situations
// where the count is not a one by one thing, like counting bytes in and out of a system. | [
"IncCounterBy",
"increments",
"the",
"specified",
"counter",
"by",
"the",
"given",
"amount",
".",
"This",
"is",
"for",
"situations",
"where",
"the",
"count",
"is",
"not",
"a",
"one",
"by",
"one",
"thing",
"like",
"counting",
"bytes",
"in",
"and",
"out",
"o... | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/counters.go#L66-L68 |
144,313 | Netflix/rend | orcas/locked.go | getlock | func (l *LockedOrca) getlock(key []byte, read bool) sync.Locker {
h := l.hpool.Get().(hash.Hash32)
defer l.hpool.Put(h)
h.Reset()
// Calculate bucket using hash and mod. hash.Hash.Write() never returns an error.
h.Write(key)
bucket := int(h.Sum32())
bucket &= len(l.locks) - 1
//atomic.AddUint32(&l.counts[buck... | go | func (l *LockedOrca) getlock(key []byte, read bool) sync.Locker {
h := l.hpool.Get().(hash.Hash32)
defer l.hpool.Put(h)
h.Reset()
// Calculate bucket using hash and mod. hash.Hash.Write() never returns an error.
h.Write(key)
bucket := int(h.Sum32())
bucket &= len(l.locks) - 1
//atomic.AddUint32(&l.counts[buck... | [
"func",
"(",
"l",
"*",
"LockedOrca",
")",
"getlock",
"(",
"key",
"[",
"]",
"byte",
",",
"read",
"bool",
")",
"sync",
".",
"Locker",
"{",
"h",
":=",
"l",
".",
"hpool",
".",
"Get",
"(",
")",
".",
"(",
"hash",
".",
"Hash32",
")",
"\n",
"defer",
... | //var numops uint64 = 0 | [
"var",
"numops",
"uint64",
"=",
"0"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/orcas/locked.go#L126-L149 |
144,314 | Netflix/rend | handlers/memcached/batched/relay.go | getRelay | func getRelay(sock string, opts Opts) *relay {
relayLock.RLock()
if r, ok := relays[sock]; ok {
relayLock.RUnlock()
return r
}
relayLock.RUnlock()
// Lock here because we are creating a new relay for the given socket path
// The rest of the new connections will block here and then pick it up on
// the doubl... | go | func getRelay(sock string, opts Opts) *relay {
relayLock.RLock()
if r, ok := relays[sock]; ok {
relayLock.RUnlock()
return r
}
relayLock.RUnlock()
// Lock here because we are creating a new relay for the given socket path
// The rest of the new connections will block here and then pick it up on
// the doubl... | [
"func",
"getRelay",
"(",
"sock",
"string",
",",
"opts",
"Opts",
")",
"*",
"relay",
"{",
"relayLock",
".",
"RLock",
"(",
")",
"\n",
"if",
"r",
",",
"ok",
":=",
"relays",
"[",
"sock",
"]",
";",
"ok",
"{",
"relayLock",
".",
"RUnlock",
"(",
")",
"\n"... | // Creates a new relay with one connection or returns an existing relay for the
// given socket. | [
"Creates",
"a",
"new",
"relay",
"with",
"one",
"connection",
"or",
"returns",
"an",
"existing",
"relay",
"for",
"the",
"given",
"socket",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/relay.go#L53-L95 |
144,315 | Netflix/rend | handlers/memcached/batched/relay.go | addConn | func (r *relay) addConn() {
// Ensure there's no races when adding a connection
r.addConnLock.Lock()
defer r.addConnLock.Unlock()
temp := r.conns.Load().([]*conn)
connID := uint32(len(temp))
batchDelay := time.Duration(r.opts.BatchDelayMicros) * time.Microsecond
poolconn := newConn(r.sock, connID, batchDelay, ... | go | func (r *relay) addConn() {
// Ensure there's no races when adding a connection
r.addConnLock.Lock()
defer r.addConnLock.Unlock()
temp := r.conns.Load().([]*conn)
connID := uint32(len(temp))
batchDelay := time.Duration(r.opts.BatchDelayMicros) * time.Microsecond
poolconn := newConn(r.sock, connID, batchDelay, ... | [
"func",
"(",
"r",
"*",
"relay",
")",
"addConn",
"(",
")",
"{",
"// Ensure there's no races when adding a connection",
"r",
".",
"addConnLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"addConnLock",
".",
"Unlock",
"(",
")",
"\n\n",
"temp",
":=",
"r"... | // Adds a connection to the pool. This is one way only, making this effectively
// a high-water-mark pool with no connections being torn down. | [
"Adds",
"a",
"connection",
"to",
"the",
"pool",
".",
"This",
"is",
"one",
"way",
"only",
"making",
"this",
"effectively",
"a",
"high",
"-",
"water",
"-",
"mark",
"pool",
"with",
"no",
"connections",
"being",
"torn",
"down",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/relay.go#L99-L115 |
144,316 | Netflix/rend | handlers/memcached/batched/relay.go | submit | func (r *relay) submit(rand *rand.Rand, req request) {
// use rand to select a connection to submit to
// the connection should notify the frontend by the channel
// in the request struct
cs := r.conns.Load().([]*conn)
idx := rand.Intn(len(cs))
c := cs[idx]
c.reqchan <- req
} | go | func (r *relay) submit(rand *rand.Rand, req request) {
// use rand to select a connection to submit to
// the connection should notify the frontend by the channel
// in the request struct
cs := r.conns.Load().([]*conn)
idx := rand.Intn(len(cs))
c := cs[idx]
c.reqchan <- req
} | [
"func",
"(",
"r",
"*",
"relay",
")",
"submit",
"(",
"rand",
"*",
"rand",
".",
"Rand",
",",
"req",
"request",
")",
"{",
"// use rand to select a connection to submit to",
"// the connection should notify the frontend by the channel",
"// in the request struct",
"cs",
":=",... | // Submits a request to a random connection in the pool. The random number generator
// is passed in so there is no sharing between external connections. | [
"Submits",
"a",
"request",
"to",
"a",
"random",
"connection",
"in",
"the",
"pool",
".",
"The",
"random",
"number",
"generator",
"is",
"passed",
"in",
"so",
"there",
"is",
"no",
"sharing",
"between",
"external",
"connections",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/relay.go#L119-L127 |
144,317 | Netflix/rend | handlers/memcached/batched/handler.go | Set | func (h Handler) Set(cmd common.SetRequest) error {
_, err := h.doRequest(cmd, common.RequestSet)
return err
} | go | func (h Handler) Set(cmd common.SetRequest) error {
_, err := h.doRequest(cmd, common.RequestSet)
return err
} | [
"func",
"(",
"h",
"Handler",
")",
"Set",
"(",
"cmd",
"common",
".",
"SetRequest",
")",
"error",
"{",
"_",
",",
"err",
":=",
"h",
".",
"doRequest",
"(",
"cmd",
",",
"common",
".",
"RequestSet",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Set performs a set operation on the backend. It unconditionally sets a key to a value. | [
"Set",
"performs",
"a",
"set",
"operation",
"on",
"the",
"backend",
".",
"It",
"unconditionally",
"sets",
"a",
"key",
"to",
"a",
"value",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/handler.go#L177-L180 |
144,318 | Netflix/rend | handlers/memcached/batched/handler.go | Add | func (h Handler) Add(cmd common.SetRequest) error {
_, err := h.doRequest(cmd, common.RequestAdd)
return err
} | go | func (h Handler) Add(cmd common.SetRequest) error {
_, err := h.doRequest(cmd, common.RequestAdd)
return err
} | [
"func",
"(",
"h",
"Handler",
")",
"Add",
"(",
"cmd",
"common",
".",
"SetRequest",
")",
"error",
"{",
"_",
",",
"err",
":=",
"h",
".",
"doRequest",
"(",
"cmd",
",",
"common",
".",
"RequestAdd",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Add performs an add operation on the backend. It only sets the value if it does not already exist. | [
"Add",
"performs",
"an",
"add",
"operation",
"on",
"the",
"backend",
".",
"It",
"only",
"sets",
"the",
"value",
"if",
"it",
"does",
"not",
"already",
"exist",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/handler.go#L183-L186 |
144,319 | Netflix/rend | handlers/memcached/batched/handler.go | Replace | func (h Handler) Replace(cmd common.SetRequest) error {
_, err := h.doRequest(cmd, common.RequestReplace)
return err
} | go | func (h Handler) Replace(cmd common.SetRequest) error {
_, err := h.doRequest(cmd, common.RequestReplace)
return err
} | [
"func",
"(",
"h",
"Handler",
")",
"Replace",
"(",
"cmd",
"common",
".",
"SetRequest",
")",
"error",
"{",
"_",
",",
"err",
":=",
"h",
".",
"doRequest",
"(",
"cmd",
",",
"common",
".",
"RequestReplace",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Replace performs a replace operation on the backend. It only sets the value if it already exists. | [
"Replace",
"performs",
"a",
"replace",
"operation",
"on",
"the",
"backend",
".",
"It",
"only",
"sets",
"the",
"value",
"if",
"it",
"already",
"exists",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/handler.go#L189-L192 |
144,320 | Netflix/rend | handlers/memcached/batched/handler.go | Append | func (h Handler) Append(cmd common.SetRequest) error {
_, err := h.doRequest(cmd, common.RequestAppend)
return err
} | go | func (h Handler) Append(cmd common.SetRequest) error {
_, err := h.doRequest(cmd, common.RequestAppend)
return err
} | [
"func",
"(",
"h",
"Handler",
")",
"Append",
"(",
"cmd",
"common",
".",
"SetRequest",
")",
"error",
"{",
"_",
",",
"err",
":=",
"h",
".",
"doRequest",
"(",
"cmd",
",",
"common",
".",
"RequestAppend",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Append performs an append operation on the backend. It will append the data to the value only if it already exists. | [
"Append",
"performs",
"an",
"append",
"operation",
"on",
"the",
"backend",
".",
"It",
"will",
"append",
"the",
"data",
"to",
"the",
"value",
"only",
"if",
"it",
"already",
"exists",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/handler.go#L195-L198 |
144,321 | Netflix/rend | handlers/memcached/batched/handler.go | Prepend | func (h Handler) Prepend(cmd common.SetRequest) error {
_, err := h.doRequest(cmd, common.RequestPrepend)
return err
} | go | func (h Handler) Prepend(cmd common.SetRequest) error {
_, err := h.doRequest(cmd, common.RequestPrepend)
return err
} | [
"func",
"(",
"h",
"Handler",
")",
"Prepend",
"(",
"cmd",
"common",
".",
"SetRequest",
")",
"error",
"{",
"_",
",",
"err",
":=",
"h",
".",
"doRequest",
"(",
"cmd",
",",
"common",
".",
"RequestPrepend",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Prepend performs a prepend operation on the backend. It will prepend the data to the value only if it already exists. | [
"Prepend",
"performs",
"a",
"prepend",
"operation",
"on",
"the",
"backend",
".",
"It",
"will",
"prepend",
"the",
"data",
"to",
"the",
"value",
"only",
"if",
"it",
"already",
"exists",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/handler.go#L201-L204 |
144,322 | Netflix/rend | handlers/memcached/batched/handler.go | Delete | func (h Handler) Delete(cmd common.DeleteRequest) error {
_, err := h.doRequest(cmd, common.RequestDelete)
return err
} | go | func (h Handler) Delete(cmd common.DeleteRequest) error {
_, err := h.doRequest(cmd, common.RequestDelete)
return err
} | [
"func",
"(",
"h",
"Handler",
")",
"Delete",
"(",
"cmd",
"common",
".",
"DeleteRequest",
")",
"error",
"{",
"_",
",",
"err",
":=",
"h",
".",
"doRequest",
"(",
"cmd",
",",
"common",
".",
"RequestDelete",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Delete performs a delete operation on the backend. It will unconditionally remove the value. | [
"Delete",
"performs",
"a",
"delete",
"operation",
"on",
"the",
"backend",
".",
"It",
"will",
"unconditionally",
"remove",
"the",
"value",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/handler.go#L207-L210 |
144,323 | Netflix/rend | handlers/memcached/batched/handler.go | Touch | func (h Handler) Touch(cmd common.TouchRequest) error {
_, err := h.doRequest(cmd, common.RequestTouch)
return err
} | go | func (h Handler) Touch(cmd common.TouchRequest) error {
_, err := h.doRequest(cmd, common.RequestTouch)
return err
} | [
"func",
"(",
"h",
"Handler",
")",
"Touch",
"(",
"cmd",
"common",
".",
"TouchRequest",
")",
"error",
"{",
"_",
",",
"err",
":=",
"h",
".",
"doRequest",
"(",
"cmd",
",",
"common",
".",
"RequestTouch",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Touch performs a touch operation on the backend. It will overwrite the expiration time with a new one. | [
"Touch",
"performs",
"a",
"touch",
"operation",
"on",
"the",
"backend",
".",
"It",
"will",
"overwrite",
"the",
"expiration",
"time",
"with",
"a",
"new",
"one",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/handler.go#L213-L216 |
144,324 | Netflix/rend | handlers/memcached/batched/handler.go | GAT | func (h Handler) GAT(cmd common.GATRequest) (common.GetResponse, error) {
gr, err := h.doRequest(cmd, common.RequestGat)
return getEResponseToGetResponse(gr), err
} | go | func (h Handler) GAT(cmd common.GATRequest) (common.GetResponse, error) {
gr, err := h.doRequest(cmd, common.RequestGat)
return getEResponseToGetResponse(gr), err
} | [
"func",
"(",
"h",
"Handler",
")",
"GAT",
"(",
"cmd",
"common",
".",
"GATRequest",
")",
"(",
"common",
".",
"GetResponse",
",",
"error",
")",
"{",
"gr",
",",
"err",
":=",
"h",
".",
"doRequest",
"(",
"cmd",
",",
"common",
".",
"RequestGat",
")",
"\n"... | // GAT performs a get-and-touch on the backend for the given key. It will retrieve the value while updating the TTL to
// the one supplied. | [
"GAT",
"performs",
"a",
"get",
"-",
"and",
"-",
"touch",
"on",
"the",
"backend",
"for",
"the",
"given",
"key",
".",
"It",
"will",
"retrieve",
"the",
"value",
"while",
"updating",
"the",
"TTL",
"to",
"the",
"one",
"supplied",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/handler.go#L231-L234 |
144,325 | Netflix/rend | handlers/memcached/batched/handler.go | getRequestToTrackerMap | func getRequestToTrackerMap(cmd common.GetRequest) trackermap {
tm := make(trackermap)
for i := range cmd.Keys {
key := keyAttrs{
key: string(cmd.Keys[i]),
opaque: cmd.Opaques[i],
quiet: cmd.Quiet[i],
}
// we get the 0 value when the map doesn't contain the data so this
// i correct even for va... | go | func getRequestToTrackerMap(cmd common.GetRequest) trackermap {
tm := make(trackermap)
for i := range cmd.Keys {
key := keyAttrs{
key: string(cmd.Keys[i]),
opaque: cmd.Opaques[i],
quiet: cmd.Quiet[i],
}
// we get the 0 value when the map doesn't contain the data so this
// i correct even for va... | [
"func",
"getRequestToTrackerMap",
"(",
"cmd",
"common",
".",
"GetRequest",
")",
"trackermap",
"{",
"tm",
":=",
"make",
"(",
"trackermap",
")",
"\n\n",
"for",
"i",
":=",
"range",
"cmd",
".",
"Keys",
"{",
"key",
":=",
"keyAttrs",
"{",
"key",
":",
"string",... | // There may be more than one request with the same key and a different opaque
// We may also get "malicious" input where multiple requests have the same
// key and opaque. If the quiet value is the same | [
"There",
"may",
"be",
"more",
"than",
"one",
"request",
"with",
"the",
"same",
"key",
"and",
"a",
"different",
"opaque",
"We",
"may",
"also",
"get",
"malicious",
"input",
"where",
"multiple",
"requests",
"have",
"the",
"same",
"key",
"and",
"opaque",
".",
... | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/handler.go#L247-L264 |
144,326 | Netflix/rend | handlers/memcached/batched/handler.go | GetE | func (h Handler) GetE(cmd common.GetRequest) (<-chan common.GetEResponse, <-chan error) {
dataOut := make(chan common.GetEResponse)
errorOut := make(chan error)
go realHandleGetE(h, cmd, dataOut, errorOut)
return dataOut, errorOut
} | go | func (h Handler) GetE(cmd common.GetRequest) (<-chan common.GetEResponse, <-chan error) {
dataOut := make(chan common.GetEResponse)
errorOut := make(chan error)
go realHandleGetE(h, cmd, dataOut, errorOut)
return dataOut, errorOut
} | [
"func",
"(",
"h",
"Handler",
")",
"GetE",
"(",
"cmd",
"common",
".",
"GetRequest",
")",
"(",
"<-",
"chan",
"common",
".",
"GetEResponse",
",",
"<-",
"chan",
"error",
")",
"{",
"dataOut",
":=",
"make",
"(",
"chan",
"common",
".",
"GetEResponse",
")",
... | // GetE performs a get-with-expiration on the backend. It is a custom command only implemented in Rend. It retrieves the
// whole batch of keys given as a group and returns them one at a time over the request channel. | [
"GetE",
"performs",
"a",
"get",
"-",
"with",
"-",
"expiration",
"on",
"the",
"backend",
".",
"It",
"is",
"a",
"custom",
"command",
"only",
"implemented",
"in",
"Rend",
".",
"It",
"retrieves",
"the",
"whole",
"batch",
"of",
"keys",
"given",
"as",
"a",
"... | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/handler.go#L383-L388 |
144,327 | Netflix/rend | memproxy.go | main | func main() {
var l server.ListenConst
if useDomainSocket {
l = server.UnixListener(sockPath)
} else {
l = server.TCPListener(port)
}
protocols := []protocol.Components{binprot.Components, textprot.Components}
var o orcas.OrcaConst
var h2 handlers.HandlerConst
var h1 handlers.HandlerConst
// Choose the... | go | func main() {
var l server.ListenConst
if useDomainSocket {
l = server.UnixListener(sockPath)
} else {
l = server.TCPListener(port)
}
protocols := []protocol.Components{binprot.Components, textprot.Components}
var o orcas.OrcaConst
var h2 handlers.HandlerConst
var h1 handlers.HandlerConst
// Choose the... | [
"func",
"main",
"(",
")",
"{",
"var",
"l",
"server",
".",
"ListenConst",
"\n\n",
"if",
"useDomainSocket",
"{",
"l",
"=",
"server",
".",
"UnixListener",
"(",
"sockPath",
")",
"\n",
"}",
"else",
"{",
"l",
"=",
"server",
".",
"TCPListener",
"(",
"port",
... | // And away we go | [
"And",
"away",
"we",
"go"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/memproxy.go#L167-L232 |
144,328 | Netflix/rend | handlers/memcached/constructors.go | Regular | func Regular(sock string) handlers.HandlerConst {
return func() (handlers.Handler, error) {
conn, err := net.Dial("unix", sock)
if err != nil {
if conn != nil {
conn.Close()
}
return nil, err
}
return std.NewHandler(conn), nil
}
} | go | func Regular(sock string) handlers.HandlerConst {
return func() (handlers.Handler, error) {
conn, err := net.Dial("unix", sock)
if err != nil {
if conn != nil {
conn.Close()
}
return nil, err
}
return std.NewHandler(conn), nil
}
} | [
"func",
"Regular",
"(",
"sock",
"string",
")",
"handlers",
".",
"HandlerConst",
"{",
"return",
"func",
"(",
")",
"(",
"handlers",
".",
"Handler",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"net",
".",
"Dial",
"(",
"\"",
"\"",
",",
"sock",
")... | // Regular returns an implementation of the Handler interface that does standard,
// direct interactions with the external memcached backend which is listening on
// the specified unix domain socket. | [
"Regular",
"returns",
"an",
"implementation",
"of",
"the",
"Handler",
"interface",
"that",
"does",
"standard",
"direct",
"interactions",
"with",
"the",
"external",
"memcached",
"backend",
"which",
"is",
"listening",
"on",
"the",
"specified",
"unix",
"domain",
"soc... | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/constructors.go#L30-L41 |
144,329 | Netflix/rend | handlers/memcached/constructors.go | Chunked | func Chunked(sock string) handlers.HandlerConst {
return func() (handlers.Handler, error) {
conn, err := net.Dial("unix", sock)
if err != nil {
log.Println("Error opening connection:", err.Error())
if conn != nil {
conn.Close()
}
return nil, err
}
return chunked.NewHandler(conn), nil
}
} | go | func Chunked(sock string) handlers.HandlerConst {
return func() (handlers.Handler, error) {
conn, err := net.Dial("unix", sock)
if err != nil {
log.Println("Error opening connection:", err.Error())
if conn != nil {
conn.Close()
}
return nil, err
}
return chunked.NewHandler(conn), nil
}
} | [
"func",
"Chunked",
"(",
"sock",
"string",
")",
"handlers",
".",
"HandlerConst",
"{",
"return",
"func",
"(",
")",
"(",
"handlers",
".",
"Handler",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"net",
".",
"Dial",
"(",
"\"",
"\"",
",",
"sock",
")... | // Chunked returns an implementation of the Handler interface that implements an
// interaction model which splits data to set size chunks before inserting. the
// external memcached backend is expected to be listening on the specified unix
// domain socket. | [
"Chunked",
"returns",
"an",
"implementation",
"of",
"the",
"Handler",
"interface",
"that",
"implements",
"an",
"interaction",
"model",
"which",
"splits",
"data",
"to",
"set",
"size",
"chunks",
"before",
"inserting",
".",
"the",
"external",
"memcached",
"backend",
... | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/constructors.go#L47-L59 |
144,330 | Netflix/rend | handlers/memcached/constructors.go | Batched | func Batched(sock string, opts batched.Opts) handlers.HandlerConst {
return func() (handlers.Handler, error) {
return batched.NewHandler(sock, opts), nil
}
} | go | func Batched(sock string, opts batched.Opts) handlers.HandlerConst {
return func() (handlers.Handler, error) {
return batched.NewHandler(sock, opts), nil
}
} | [
"func",
"Batched",
"(",
"sock",
"string",
",",
"opts",
"batched",
".",
"Opts",
")",
"handlers",
".",
"HandlerConst",
"{",
"return",
"func",
"(",
")",
"(",
"handlers",
".",
"Handler",
",",
"error",
")",
"{",
"return",
"batched",
".",
"NewHandler",
"(",
... | // Batched returns an implementation of the Handler interface that multiplexes
// requests on to a connection pool in order to reduce the overhead per request. | [
"Batched",
"returns",
"an",
"implementation",
"of",
"the",
"Handler",
"interface",
"that",
"multiplexes",
"requests",
"on",
"to",
"a",
"connection",
"pool",
"in",
"order",
"to",
"reduce",
"the",
"overhead",
"per",
"request",
"."
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/constructors.go#L63-L67 |
144,331 | Netflix/rend | protocol/binprot/commands.go | writeDataCmdCommon | func writeDataCmdCommon(w io.Writer, opcode uint8, key []byte, flags, exptime, dataSize, opaque uint32) error {
// opcode, keyLength, extraLength, totalBodyLength
// key + extras + body
extrasLen := 8
totalBodyLength := len(key) + extrasLen + int(dataSize)
header := makeRequestHeader(opcode, len(key), extrasLen, t... | go | func writeDataCmdCommon(w io.Writer, opcode uint8, key []byte, flags, exptime, dataSize, opaque uint32) error {
// opcode, keyLength, extraLength, totalBodyLength
// key + extras + body
extrasLen := 8
totalBodyLength := len(key) + extrasLen + int(dataSize)
header := makeRequestHeader(opcode, len(key), extrasLen, t... | [
"func",
"writeDataCmdCommon",
"(",
"w",
"io",
".",
"Writer",
",",
"opcode",
"uint8",
",",
"key",
"[",
"]",
"byte",
",",
"flags",
",",
"exptime",
",",
"dataSize",
",",
"opaque",
"uint32",
")",
"error",
"{",
"// opcode, keyLength, extraLength, totalBodyLength",
... | // Data commands are those that send a header, key, exptime, and data | [
"Data",
"commands",
"are",
"those",
"that",
"send",
"a",
"header",
"key",
"exptime",
"and",
"data"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L26-L46 |
144,332 | Netflix/rend | protocol/binprot/commands.go | WriteSetCmd | func WriteSetCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error {
//fmt.Printf("Set: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLength: %v\n",
//string(key), flags, exptime, dataSize, totalBodyLength)
return writeDataCmdCommon(w, OpcodeSet, key, flags, exptime, dataSize, opa... | go | func WriteSetCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error {
//fmt.Printf("Set: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLength: %v\n",
//string(key), flags, exptime, dataSize, totalBodyLength)
return writeDataCmdCommon(w, OpcodeSet, key, flags, exptime, dataSize, opa... | [
"func",
"WriteSetCmd",
"(",
"w",
"io",
".",
"Writer",
",",
"key",
"[",
"]",
"byte",
",",
"flags",
",",
"exptime",
",",
"dataSize",
",",
"opaque",
"uint32",
")",
"error",
"{",
"//fmt.Printf(\"Set: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLength: %v\\... | // WriteSetCmd writes out the binary representation of a set request header to the given io.Writer | [
"WriteSetCmd",
"writes",
"out",
"the",
"binary",
"representation",
"of",
"a",
"set",
"request",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L49-L53 |
144,333 | Netflix/rend | protocol/binprot/commands.go | WriteAddCmd | func WriteAddCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error {
//fmt.Printf("Add: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLength: %v\n",
//string(key), flags, exptime, dataSize, totalBodyLength)
return writeDataCmdCommon(w, OpcodeAdd, key, flags, exptime, dataSize, opa... | go | func WriteAddCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error {
//fmt.Printf("Add: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLength: %v\n",
//string(key), flags, exptime, dataSize, totalBodyLength)
return writeDataCmdCommon(w, OpcodeAdd, key, flags, exptime, dataSize, opa... | [
"func",
"WriteAddCmd",
"(",
"w",
"io",
".",
"Writer",
",",
"key",
"[",
"]",
"byte",
",",
"flags",
",",
"exptime",
",",
"dataSize",
",",
"opaque",
"uint32",
")",
"error",
"{",
"//fmt.Printf(\"Add: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLength: %v\\... | // WriteAddCmd writes out the binary representation of an add request header to the given io.Writer | [
"WriteAddCmd",
"writes",
"out",
"the",
"binary",
"representation",
"of",
"an",
"add",
"request",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L56-L60 |
144,334 | Netflix/rend | protocol/binprot/commands.go | WriteReplaceCmd | func WriteReplaceCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error {
//fmt.Printf("Replace: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLength: %v\n",
//string(key), flags, exptime, dataSize, totalBodyLength)
return writeDataCmdCommon(w, OpcodeReplace, key, flags, exptime, d... | go | func WriteReplaceCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error {
//fmt.Printf("Replace: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLength: %v\n",
//string(key), flags, exptime, dataSize, totalBodyLength)
return writeDataCmdCommon(w, OpcodeReplace, key, flags, exptime, d... | [
"func",
"WriteReplaceCmd",
"(",
"w",
"io",
".",
"Writer",
",",
"key",
"[",
"]",
"byte",
",",
"flags",
",",
"exptime",
",",
"dataSize",
",",
"opaque",
"uint32",
")",
"error",
"{",
"//fmt.Printf(\"Replace: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLeng... | // WriteReplaceCmd writes out the binary representation of a replace request header to the given io.Writer | [
"WriteReplaceCmd",
"writes",
"out",
"the",
"binary",
"representation",
"of",
"a",
"replace",
"request",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L63-L67 |
144,335 | Netflix/rend | protocol/binprot/commands.go | WriteAppendCmd | func WriteAppendCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error {
//fmt.Printf("Append: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLength: %v\n",
//string(key), flags, exptime, dataSize, totalBodyLength)
return writeAppendPrependCmdCommon(w, OpcodeAppend, key, flags, expt... | go | func WriteAppendCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error {
//fmt.Printf("Append: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLength: %v\n",
//string(key), flags, exptime, dataSize, totalBodyLength)
return writeAppendPrependCmdCommon(w, OpcodeAppend, key, flags, expt... | [
"func",
"WriteAppendCmd",
"(",
"w",
"io",
".",
"Writer",
",",
"key",
"[",
"]",
"byte",
",",
"flags",
",",
"exptime",
",",
"dataSize",
",",
"opaque",
"uint32",
")",
"error",
"{",
"//fmt.Printf(\"Append: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLength... | // WriteAppendCmd writes out the binary representation of an append request header to the given io.Writer | [
"WriteAppendCmd",
"writes",
"out",
"the",
"binary",
"representation",
"of",
"an",
"append",
"request",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L86-L90 |
144,336 | Netflix/rend | protocol/binprot/commands.go | WritePrependCmd | func WritePrependCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error {
//fmt.Printf("Prepend: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLength: %v\n",
//string(key), flags, exptime, dataSize, totalBodyLength)
return writeAppendPrependCmdCommon(w, OpcodePrepend, key, flags, e... | go | func WritePrependCmd(w io.Writer, key []byte, flags, exptime, dataSize, opaque uint32) error {
//fmt.Printf("Prepend: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLength: %v\n",
//string(key), flags, exptime, dataSize, totalBodyLength)
return writeAppendPrependCmdCommon(w, OpcodePrepend, key, flags, e... | [
"func",
"WritePrependCmd",
"(",
"w",
"io",
".",
"Writer",
",",
"key",
"[",
"]",
"byte",
",",
"flags",
",",
"exptime",
",",
"dataSize",
",",
"opaque",
"uint32",
")",
"error",
"{",
"//fmt.Printf(\"Prepend: key: %v | flags: %v | exptime: %v | dataSize: %v | totalBodyLeng... | // WritePrependCmd writes out the binary representation of a prepend request header to the given io.Writer | [
"WritePrependCmd",
"writes",
"out",
"the",
"binary",
"representation",
"of",
"a",
"prepend",
"request",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L93-L97 |
144,337 | Netflix/rend | protocol/binprot/commands.go | writeKeyCmd | func writeKeyCmd(w io.Writer, opcode uint8, key []byte, opaque uint32) error {
// opcode, keyLength, extraLength, totalBodyLength
header := makeRequestHeader(opcode, len(key), 0, len(key), opaque)
writeRequestHeader(w, header)
n, err := w.Write(key)
metrics.IncCounterBy(common.MetricBytesWrittenLocal, uint64(Req... | go | func writeKeyCmd(w io.Writer, opcode uint8, key []byte, opaque uint32) error {
// opcode, keyLength, extraLength, totalBodyLength
header := makeRequestHeader(opcode, len(key), 0, len(key), opaque)
writeRequestHeader(w, header)
n, err := w.Write(key)
metrics.IncCounterBy(common.MetricBytesWrittenLocal, uint64(Req... | [
"func",
"writeKeyCmd",
"(",
"w",
"io",
".",
"Writer",
",",
"opcode",
"uint8",
",",
"key",
"[",
"]",
"byte",
",",
"opaque",
"uint32",
")",
"error",
"{",
"// opcode, keyLength, extraLength, totalBodyLength",
"header",
":=",
"makeRequestHeader",
"(",
"opcode",
",",... | // Key commands send the header and key only | [
"Key",
"commands",
"send",
"the",
"header",
"and",
"key",
"only"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L100-L111 |
144,338 | Netflix/rend | protocol/binprot/commands.go | WriteGetCmd | func WriteGetCmd(w io.Writer, key []byte, opaque uint32) error {
//fmt.Printf("Get: key: %v | totalBodyLength: %v\n", string(key), len(key))
return writeKeyCmd(w, OpcodeGet, key, opaque)
} | go | func WriteGetCmd(w io.Writer, key []byte, opaque uint32) error {
//fmt.Printf("Get: key: %v | totalBodyLength: %v\n", string(key), len(key))
return writeKeyCmd(w, OpcodeGet, key, opaque)
} | [
"func",
"WriteGetCmd",
"(",
"w",
"io",
".",
"Writer",
",",
"key",
"[",
"]",
"byte",
",",
"opaque",
"uint32",
")",
"error",
"{",
"//fmt.Printf(\"Get: key: %v | totalBodyLength: %v\\n\", string(key), len(key))",
"return",
"writeKeyCmd",
"(",
"w",
",",
"OpcodeGet",
","... | // WriteGetCmd writes out the binary representation of a get request header to the given io.Writer | [
"WriteGetCmd",
"writes",
"out",
"the",
"binary",
"representation",
"of",
"a",
"get",
"request",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L114-L117 |
144,339 | Netflix/rend | protocol/binprot/commands.go | WriteGetQCmd | func WriteGetQCmd(w io.Writer, key []byte, opaque uint32) error {
//fmt.Printf("GetQ: key: %v | totalBodyLength: %v\n", string(key), len(key))
return writeKeyCmd(w, OpcodeGetQ, key, opaque)
} | go | func WriteGetQCmd(w io.Writer, key []byte, opaque uint32) error {
//fmt.Printf("GetQ: key: %v | totalBodyLength: %v\n", string(key), len(key))
return writeKeyCmd(w, OpcodeGetQ, key, opaque)
} | [
"func",
"WriteGetQCmd",
"(",
"w",
"io",
".",
"Writer",
",",
"key",
"[",
"]",
"byte",
",",
"opaque",
"uint32",
")",
"error",
"{",
"//fmt.Printf(\"GetQ: key: %v | totalBodyLength: %v\\n\", string(key), len(key))",
"return",
"writeKeyCmd",
"(",
"w",
",",
"OpcodeGetQ",
... | // WriteGetQCmd writes out the binary representation of a getq request header to the given io.Writer | [
"WriteGetQCmd",
"writes",
"out",
"the",
"binary",
"representation",
"of",
"a",
"getq",
"request",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L120-L123 |
144,340 | Netflix/rend | protocol/binprot/commands.go | WriteGetECmd | func WriteGetECmd(w io.Writer, key []byte, opaque uint32) error {
//fmt.Printf("GetE: key: %v | totalBodyLength: %v\n", string(key), len(key))
return writeKeyCmd(w, OpcodeGetE, key, opaque)
} | go | func WriteGetECmd(w io.Writer, key []byte, opaque uint32) error {
//fmt.Printf("GetE: key: %v | totalBodyLength: %v\n", string(key), len(key))
return writeKeyCmd(w, OpcodeGetE, key, opaque)
} | [
"func",
"WriteGetECmd",
"(",
"w",
"io",
".",
"Writer",
",",
"key",
"[",
"]",
"byte",
",",
"opaque",
"uint32",
")",
"error",
"{",
"//fmt.Printf(\"GetE: key: %v | totalBodyLength: %v\\n\", string(key), len(key))",
"return",
"writeKeyCmd",
"(",
"w",
",",
"OpcodeGetE",
... | // WriteGetECmd writes out the binary representation of a gete request header to the given io.Writer | [
"WriteGetECmd",
"writes",
"out",
"the",
"binary",
"representation",
"of",
"a",
"gete",
"request",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L126-L129 |
144,341 | Netflix/rend | protocol/binprot/commands.go | WriteGetEQCmd | func WriteGetEQCmd(w io.Writer, key []byte, opaque uint32) error {
//fmt.Printf("GetEQ: key: %v | totalBodyLength: %v\n", string(key), len(key))
return writeKeyCmd(w, OpcodeGetEQ, key, opaque)
} | go | func WriteGetEQCmd(w io.Writer, key []byte, opaque uint32) error {
//fmt.Printf("GetEQ: key: %v | totalBodyLength: %v\n", string(key), len(key))
return writeKeyCmd(w, OpcodeGetEQ, key, opaque)
} | [
"func",
"WriteGetEQCmd",
"(",
"w",
"io",
".",
"Writer",
",",
"key",
"[",
"]",
"byte",
",",
"opaque",
"uint32",
")",
"error",
"{",
"//fmt.Printf(\"GetEQ: key: %v | totalBodyLength: %v\\n\", string(key), len(key))",
"return",
"writeKeyCmd",
"(",
"w",
",",
"OpcodeGetEQ",... | // WriteGetEQCmd writes out the binary representation of a geteq request header to the given io.Writer | [
"WriteGetEQCmd",
"writes",
"out",
"the",
"binary",
"representation",
"of",
"a",
"geteq",
"request",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L132-L135 |
144,342 | Netflix/rend | protocol/binprot/commands.go | WriteDeleteCmd | func WriteDeleteCmd(w io.Writer, key []byte, opaque uint32) error {
//fmt.Printf("Delete: key: %v | totalBodyLength: %v\n", string(key), len(key))
return writeKeyCmd(w, OpcodeDelete, key, opaque)
} | go | func WriteDeleteCmd(w io.Writer, key []byte, opaque uint32) error {
//fmt.Printf("Delete: key: %v | totalBodyLength: %v\n", string(key), len(key))
return writeKeyCmd(w, OpcodeDelete, key, opaque)
} | [
"func",
"WriteDeleteCmd",
"(",
"w",
"io",
".",
"Writer",
",",
"key",
"[",
"]",
"byte",
",",
"opaque",
"uint32",
")",
"error",
"{",
"//fmt.Printf(\"Delete: key: %v | totalBodyLength: %v\\n\", string(key), len(key))",
"return",
"writeKeyCmd",
"(",
"w",
",",
"OpcodeDelet... | // WriteDeleteCmd writes out the binary representation of a delete request header to the given io.Writer | [
"WriteDeleteCmd",
"writes",
"out",
"the",
"binary",
"representation",
"of",
"a",
"delete",
"request",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L138-L141 |
144,343 | Netflix/rend | protocol/binprot/commands.go | WriteTouchCmd | func WriteTouchCmd(w io.Writer, key []byte, exptime, opaque uint32) error {
//fmt.Printf("Touch: key: %v | exptime: %v | totalBodyLength: %v\n", string(key),
//exptime, totalBodyLength)
return writeKeyExptimeCmd(w, OpcodeTouch, key, exptime, opaque)
} | go | func WriteTouchCmd(w io.Writer, key []byte, exptime, opaque uint32) error {
//fmt.Printf("Touch: key: %v | exptime: %v | totalBodyLength: %v\n", string(key),
//exptime, totalBodyLength)
return writeKeyExptimeCmd(w, OpcodeTouch, key, exptime, opaque)
} | [
"func",
"WriteTouchCmd",
"(",
"w",
"io",
".",
"Writer",
",",
"key",
"[",
"]",
"byte",
",",
"exptime",
",",
"opaque",
"uint32",
")",
"error",
"{",
"//fmt.Printf(\"Touch: key: %v | exptime: %v | totalBodyLength: %v\\n\", string(key),",
"//exptime, totalBodyLength)",
"return... | // WriteTouchCmd writes out the binary representation of a touch request header to the given io.Writer | [
"WriteTouchCmd",
"writes",
"out",
"the",
"binary",
"representation",
"of",
"a",
"touch",
"request",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L166-L170 |
144,344 | Netflix/rend | protocol/binprot/commands.go | WriteGATCmd | func WriteGATCmd(w io.Writer, key []byte, exptime, opaque uint32) error {
//fmt.Printf("GAT: key: %v | exptime: %v | totalBodyLength: %v\n", string(key),
//exptime, len(key))
return writeKeyExptimeCmd(w, OpcodeGat, key, exptime, opaque)
} | go | func WriteGATCmd(w io.Writer, key []byte, exptime, opaque uint32) error {
//fmt.Printf("GAT: key: %v | exptime: %v | totalBodyLength: %v\n", string(key),
//exptime, len(key))
return writeKeyExptimeCmd(w, OpcodeGat, key, exptime, opaque)
} | [
"func",
"WriteGATCmd",
"(",
"w",
"io",
".",
"Writer",
",",
"key",
"[",
"]",
"byte",
",",
"exptime",
",",
"opaque",
"uint32",
")",
"error",
"{",
"//fmt.Printf(\"GAT: key: %v | exptime: %v | totalBodyLength: %v\\n\", string(key),",
"//exptime, len(key))",
"return",
"write... | // WriteGATCmd writes out the binary representation of a get-and-touch request header to the given io.Writer | [
"WriteGATCmd",
"writes",
"out",
"the",
"binary",
"representation",
"of",
"a",
"get",
"-",
"and",
"-",
"touch",
"request",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L173-L177 |
144,345 | Netflix/rend | protocol/binprot/commands.go | WriteGATQCmd | func WriteGATQCmd(w io.Writer, key []byte, exptime, opaque uint32) error {
//fmt.Printf("GATQ: key: %v | exptime: %v | totalBodyLength: %v\n", string(key),
//exptime, len(key))
return writeKeyExptimeCmd(w, OpcodeGatQ, key, exptime, opaque)
} | go | func WriteGATQCmd(w io.Writer, key []byte, exptime, opaque uint32) error {
//fmt.Printf("GATQ: key: %v | exptime: %v | totalBodyLength: %v\n", string(key),
//exptime, len(key))
return writeKeyExptimeCmd(w, OpcodeGatQ, key, exptime, opaque)
} | [
"func",
"WriteGATQCmd",
"(",
"w",
"io",
".",
"Writer",
",",
"key",
"[",
"]",
"byte",
",",
"exptime",
",",
"opaque",
"uint32",
")",
"error",
"{",
"//fmt.Printf(\"GATQ: key: %v | exptime: %v | totalBodyLength: %v\\n\", string(key),",
"//exptime, len(key))",
"return",
"wri... | // WriteGATQCmd writes out the binary representation of a get-and-touch quiet request header to the given io.Writer | [
"WriteGATQCmd",
"writes",
"out",
"the",
"binary",
"representation",
"of",
"a",
"get",
"-",
"and",
"-",
"touch",
"quiet",
"request",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L180-L184 |
144,346 | Netflix/rend | protocol/binprot/commands.go | WriteNoopCmd | func WriteNoopCmd(w io.Writer, opaque uint32) error {
// opcode, keyLength, extraLength, totalBodyLength
header := makeRequestHeader(OpcodeNoop, 0, 0, 0, opaque)
//fmt.Printf("Delete: key: %v | totalBodyLength: %v\n", string(key), len(key))
err := writeRequestHeader(w, header)
metrics.IncCounterBy(common.MetricB... | go | func WriteNoopCmd(w io.Writer, opaque uint32) error {
// opcode, keyLength, extraLength, totalBodyLength
header := makeRequestHeader(OpcodeNoop, 0, 0, 0, opaque)
//fmt.Printf("Delete: key: %v | totalBodyLength: %v\n", string(key), len(key))
err := writeRequestHeader(w, header)
metrics.IncCounterBy(common.MetricB... | [
"func",
"WriteNoopCmd",
"(",
"w",
"io",
".",
"Writer",
",",
"opaque",
"uint32",
")",
"error",
"{",
"// opcode, keyLength, extraLength, totalBodyLength",
"header",
":=",
"makeRequestHeader",
"(",
"OpcodeNoop",
",",
"0",
",",
"0",
",",
"0",
",",
"opaque",
")",
"... | // WriteNoopCmd writes out the binary representation of a noop request header to the given io.Writer | [
"WriteNoopCmd",
"writes",
"out",
"the",
"binary",
"representation",
"of",
"a",
"noop",
"request",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/protocol/binprot/commands.go#L187-L199 |
144,347 | Netflix/rend | metrics/histograms.go | ObserveHist | func ObserveHist(id uint32, value uint64) {
h := &hists[id]
// We lock here to ensure that the min and max values are true to this time
// period, meaning extractAndReset won't pull the data out from under us
// while the current observation is being compared. Otherwise, min and max
// could come from the previou... | go | func ObserveHist(id uint32, value uint64) {
h := &hists[id]
// We lock here to ensure that the min and max values are true to this time
// period, meaning extractAndReset won't pull the data out from under us
// while the current observation is being compared. Otherwise, min and max
// could come from the previou... | [
"func",
"ObserveHist",
"(",
"id",
"uint32",
",",
"value",
"uint64",
")",
"{",
"h",
":=",
"&",
"hists",
"[",
"id",
"]",
"\n\n",
"// We lock here to ensure that the min and max values are true to this time",
"// period, meaning extractAndReset won't pull the data out from under u... | // ObserveHist adds an observation to the given histogram. The id parameter is a handle
// returned by the AddHistogram method. Using numbers not returned by AddHistogram is
// undefined behavior and may cause a panic. | [
"ObserveHist",
"adds",
"an",
"observation",
"to",
"the",
"given",
"histogram",
".",
"The",
"id",
"parameter",
"is",
"a",
"handle",
"returned",
"by",
"the",
"AddHistogram",
"method",
".",
"Using",
"numbers",
"not",
"returned",
"by",
"AddHistogram",
"is",
"undef... | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/histograms.go#L252-L300 |
144,348 | Netflix/rend | metrics/endpoint.go | pausePercentiles | func pausePercentiles(pauses []uint64, ngc uint32) []uint64 {
if ngc < uint32(len(pauses)) {
pauses = pauses[:ngc]
}
sort.Sort(uint64slice(pauses))
pctls := make([]uint64, 22)
// Take care of 0th and 100th specially
pctls[0] = pauses[0]
pctls[20] = pauses[len(pauses)-1]
// 5th - 95th
for i := 1; i < 20; ... | go | func pausePercentiles(pauses []uint64, ngc uint32) []uint64 {
if ngc < uint32(len(pauses)) {
pauses = pauses[:ngc]
}
sort.Sort(uint64slice(pauses))
pctls := make([]uint64, 22)
// Take care of 0th and 100th specially
pctls[0] = pauses[0]
pctls[20] = pauses[len(pauses)-1]
// 5th - 95th
for i := 1; i < 20; ... | [
"func",
"pausePercentiles",
"(",
"pauses",
"[",
"]",
"uint64",
",",
"ngc",
"uint32",
")",
"[",
"]",
"uint64",
"{",
"if",
"ngc",
"<",
"uint32",
"(",
"len",
"(",
"pauses",
")",
")",
"{",
"pauses",
"=",
"pauses",
"[",
":",
"ngc",
"]",
"\n",
"}",
"\n... | // the first 21 positions are the percentiles by 5's from 0 to 100
// the 22nd position is the bonus 99th percentile
// this makes looping over the values easier | [
"the",
"first",
"21",
"positions",
"are",
"the",
"percentiles",
"by",
"5",
"s",
"from",
"0",
"to",
"100",
"the",
"22nd",
"position",
"is",
"the",
"bonus",
"99th",
"percentile",
"this",
"makes",
"looping",
"over",
"the",
"values",
"easier"
] | d3db570668d3ecd97cbdf0988c92145a9040e235 | https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/endpoint.go#L223-L247 |
144,349 | ipfs/go-datastore | keytransform/transforms.go | ConvertKey | func (p PrefixTransform) ConvertKey(k ds.Key) ds.Key {
return p.Prefix.Child(k)
} | go | func (p PrefixTransform) ConvertKey(k ds.Key) ds.Key {
return p.Prefix.Child(k)
} | [
"func",
"(",
"p",
"PrefixTransform",
")",
"ConvertKey",
"(",
"k",
"ds",
".",
"Key",
")",
"ds",
".",
"Key",
"{",
"return",
"p",
".",
"Prefix",
".",
"Child",
"(",
"k",
")",
"\n",
"}"
] | // ConvertKey adds the prefix. | [
"ConvertKey",
"adds",
"the",
"prefix",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/keytransform/transforms.go#L31-L33 |
144,350 | ipfs/go-datastore | keytransform/transforms.go | InvertKey | func (p PrefixTransform) InvertKey(k ds.Key) ds.Key {
if p.Prefix.String() == "/" {
return k
}
if !p.Prefix.IsAncestorOf(k) {
panic("expected prefix not found")
}
s := k.String()[len(p.Prefix.String()):]
return ds.RawKey(s)
} | go | func (p PrefixTransform) InvertKey(k ds.Key) ds.Key {
if p.Prefix.String() == "/" {
return k
}
if !p.Prefix.IsAncestorOf(k) {
panic("expected prefix not found")
}
s := k.String()[len(p.Prefix.String()):]
return ds.RawKey(s)
} | [
"func",
"(",
"p",
"PrefixTransform",
")",
"InvertKey",
"(",
"k",
"ds",
".",
"Key",
")",
"ds",
".",
"Key",
"{",
"if",
"p",
".",
"Prefix",
".",
"String",
"(",
")",
"==",
"\"",
"\"",
"{",
"return",
"k",
"\n",
"}",
"\n\n",
"if",
"!",
"p",
".",
"P... | // InvertKey removes the prefix. panics if prefix not found. | [
"InvertKey",
"removes",
"the",
"prefix",
".",
"panics",
"if",
"prefix",
"not",
"found",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/keytransform/transforms.go#L36-L47 |
144,351 | ipfs/go-datastore | basic_ds.go | GetSize | func (d *NullDatastore) GetSize(key Key) (size int, err error) {
return -1, ErrNotFound
} | go | func (d *NullDatastore) GetSize(key Key) (size int, err error) {
return -1, ErrNotFound
} | [
"func",
"(",
"d",
"*",
"NullDatastore",
")",
"GetSize",
"(",
"key",
"Key",
")",
"(",
"size",
"int",
",",
"err",
"error",
")",
"{",
"return",
"-",
"1",
",",
"ErrNotFound",
"\n",
"}"
] | // Has implements Datastore.GetSize | [
"Has",
"implements",
"Datastore",
".",
"GetSize"
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/basic_ds.go#L112-L114 |
144,352 | ipfs/go-datastore | basic_ds.go | NewLogDatastore | func NewLogDatastore(ds Datastore, name string) *LogDatastore {
if len(name) < 1 {
name = "LogDatastore"
}
return &LogDatastore{Name: name, child: ds}
} | go | func NewLogDatastore(ds Datastore, name string) *LogDatastore {
if len(name) < 1 {
name = "LogDatastore"
}
return &LogDatastore{Name: name, child: ds}
} | [
"func",
"NewLogDatastore",
"(",
"ds",
"Datastore",
",",
"name",
"string",
")",
"*",
"LogDatastore",
"{",
"if",
"len",
"(",
"name",
")",
"<",
"1",
"{",
"name",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"&",
"LogDatastore",
"{",
"Name",
":",
"name",
... | // NewLogDatastore constructs a log datastore. | [
"NewLogDatastore",
"constructs",
"a",
"log",
"datastore",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/basic_ds.go#L148-L153 |
144,353 | ipfs/go-datastore | basic_ds.go | Delete | func (d *LogBatch) Delete(key Key) (err error) {
log.Printf("%s: BatchDelete %s\n", d.Name, key)
return d.child.Delete(key)
} | go | func (d *LogBatch) Delete(key Key) (err error) {
log.Printf("%s: BatchDelete %s\n", d.Name, key)
return d.child.Delete(key)
} | [
"func",
"(",
"d",
"*",
"LogBatch",
")",
"Delete",
"(",
"key",
"Key",
")",
"(",
"err",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"d",
".",
"Name",
",",
"key",
")",
"\n",
"return",
"d",
".",
"child",
".",
"Delete",
"... | // Delete implements Batch.Delete | [
"Delete",
"implements",
"Batch",
".",
"Delete"
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/basic_ds.go#L239-L242 |
144,354 | ipfs/go-datastore | basic_ds.go | Commit | func (d *LogBatch) Commit() (err error) {
log.Printf("%s: BatchCommit\n", d.Name)
return d.child.Commit()
} | go | func (d *LogBatch) Commit() (err error) {
log.Printf("%s: BatchCommit\n", d.Name)
return d.child.Commit()
} | [
"func",
"(",
"d",
"*",
"LogBatch",
")",
"Commit",
"(",
")",
"(",
"err",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"d",
".",
"Name",
")",
"\n",
"return",
"d",
".",
"child",
".",
"Commit",
"(",
")",
"\n",
"}"
] | // Commit implements Batch.Commit | [
"Commit",
"implements",
"Batch",
".",
"Commit"
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/basic_ds.go#L245-L248 |
144,355 | ipfs/go-datastore | examples/fs.go | NewDatastore | func NewDatastore(path string) (ds.Datastore, error) {
if !isDir(path) {
return nil, fmt.Errorf("Failed to find directory at: %v (file? perms?)", path)
}
return &Datastore{path: path}, nil
} | go | func NewDatastore(path string) (ds.Datastore, error) {
if !isDir(path) {
return nil, fmt.Errorf("Failed to find directory at: %v (file? perms?)", path)
}
return &Datastore{path: path}, nil
} | [
"func",
"NewDatastore",
"(",
"path",
"string",
")",
"(",
"ds",
".",
"Datastore",
",",
"error",
")",
"{",
"if",
"!",
"isDir",
"(",
"path",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"path",
")",
"\n",
"}",
"\n\n",
... | // NewDatastore returns a new fs Datastore at given `path` | [
"NewDatastore",
"returns",
"a",
"new",
"fs",
"Datastore",
"at",
"given",
"path"
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/examples/fs.go#L40-L46 |
144,356 | ipfs/go-datastore | examples/fs.go | KeyFilename | func (d *Datastore) KeyFilename(key ds.Key) string {
return filepath.Join(d.path, key.String(), ObjectKeySuffix)
} | go | func (d *Datastore) KeyFilename(key ds.Key) string {
return filepath.Join(d.path, key.String(), ObjectKeySuffix)
} | [
"func",
"(",
"d",
"*",
"Datastore",
")",
"KeyFilename",
"(",
"key",
"ds",
".",
"Key",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"d",
".",
"path",
",",
"key",
".",
"String",
"(",
")",
",",
"ObjectKeySuffix",
")",
"\n",
"}"
] | // KeyFilename returns the filename associated with `key` | [
"KeyFilename",
"returns",
"the",
"filename",
"associated",
"with",
"key"
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/examples/fs.go#L49-L51 |
144,357 | ipfs/go-datastore | examples/fs.go | Put | func (d *Datastore) Put(key ds.Key, value []byte) (err error) {
fn := d.KeyFilename(key)
// mkdirall above.
err = os.MkdirAll(filepath.Dir(fn), 0755)
if err != nil {
return err
}
return ioutil.WriteFile(fn, value, 0666)
} | go | func (d *Datastore) Put(key ds.Key, value []byte) (err error) {
fn := d.KeyFilename(key)
// mkdirall above.
err = os.MkdirAll(filepath.Dir(fn), 0755)
if err != nil {
return err
}
return ioutil.WriteFile(fn, value, 0666)
} | [
"func",
"(",
"d",
"*",
"Datastore",
")",
"Put",
"(",
"key",
"ds",
".",
"Key",
",",
"value",
"[",
"]",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"fn",
":=",
"d",
".",
"KeyFilename",
"(",
"key",
")",
"\n\n",
"// mkdirall above.",
"err",
"=",
"os"... | // Put stores the given value. | [
"Put",
"stores",
"the",
"given",
"value",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/examples/fs.go#L54-L64 |
144,358 | ipfs/go-datastore | examples/fs.go | Get | func (d *Datastore) Get(key ds.Key) (value []byte, err error) {
fn := d.KeyFilename(key)
if !isFile(fn) {
return nil, ds.ErrNotFound
}
return ioutil.ReadFile(fn)
} | go | func (d *Datastore) Get(key ds.Key) (value []byte, err error) {
fn := d.KeyFilename(key)
if !isFile(fn) {
return nil, ds.ErrNotFound
}
return ioutil.ReadFile(fn)
} | [
"func",
"(",
"d",
"*",
"Datastore",
")",
"Get",
"(",
"key",
"ds",
".",
"Key",
")",
"(",
"value",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"fn",
":=",
"d",
".",
"KeyFilename",
"(",
"key",
")",
"\n",
"if",
"!",
"isFile",
"(",
"fn",
")",... | // Get returns the value for given key | [
"Get",
"returns",
"the",
"value",
"for",
"given",
"key"
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/examples/fs.go#L67-L74 |
144,359 | ipfs/go-datastore | examples/fs.go | Has | func (d *Datastore) Has(key ds.Key) (exists bool, err error) {
return ds.GetBackedHas(d, key)
} | go | func (d *Datastore) Has(key ds.Key) (exists bool, err error) {
return ds.GetBackedHas(d, key)
} | [
"func",
"(",
"d",
"*",
"Datastore",
")",
"Has",
"(",
"key",
"ds",
".",
"Key",
")",
"(",
"exists",
"bool",
",",
"err",
"error",
")",
"{",
"return",
"ds",
".",
"GetBackedHas",
"(",
"d",
",",
"key",
")",
"\n",
"}"
] | // Has returns whether the datastore has a value for a given key | [
"Has",
"returns",
"whether",
"the",
"datastore",
"has",
"a",
"value",
"for",
"a",
"given",
"key"
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/examples/fs.go#L77-L79 |
144,360 | ipfs/go-datastore | examples/fs.go | DiskUsage | func (d *Datastore) DiskUsage() (uint64, error) {
var du uint64
err := filepath.Walk(d.path, func(p string, f os.FileInfo, err error) error {
if err != nil {
log.Println(err)
return err
}
if f != nil {
du += uint64(f.Size())
}
return nil
})
return du, err
} | go | func (d *Datastore) DiskUsage() (uint64, error) {
var du uint64
err := filepath.Walk(d.path, func(p string, f os.FileInfo, err error) error {
if err != nil {
log.Println(err)
return err
}
if f != nil {
du += uint64(f.Size())
}
return nil
})
return du, err
} | [
"func",
"(",
"d",
"*",
"Datastore",
")",
"DiskUsage",
"(",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"var",
"du",
"uint64",
"\n",
"err",
":=",
"filepath",
".",
"Walk",
"(",
"d",
".",
"path",
",",
"func",
"(",
"p",
"string",
",",
"f",
"os",
".... | // DiskUsage returns the disk size used by the datastore in bytes. | [
"DiskUsage",
"returns",
"the",
"disk",
"size",
"used",
"by",
"the",
"datastore",
"in",
"bytes",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/examples/fs.go#L159-L172 |
144,361 | ipfs/go-datastore | key.go | NewKey | func NewKey(s string) Key {
k := Key{s}
k.Clean()
return k
} | go | func NewKey(s string) Key {
k := Key{s}
k.Clean()
return k
} | [
"func",
"NewKey",
"(",
"s",
"string",
")",
"Key",
"{",
"k",
":=",
"Key",
"{",
"s",
"}",
"\n",
"k",
".",
"Clean",
"(",
")",
"\n",
"return",
"k",
"\n",
"}"
] | // NewKey constructs a key from string. it will clean the value. | [
"NewKey",
"constructs",
"a",
"key",
"from",
"string",
".",
"it",
"will",
"clean",
"the",
"value",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/key.go#L38-L42 |
144,362 | ipfs/go-datastore | key.go | RawKey | func RawKey(s string) Key {
// accept an empty string and fix it to avoid special cases
// elsewhere
if len(s) == 0 {
return Key{"/"}
}
// perform a quick sanity check that the key is in the correct
// format, if it is not then it is a programmer error and it is
// okay to panic
if len(s) == 0 || s[0] != '/'... | go | func RawKey(s string) Key {
// accept an empty string and fix it to avoid special cases
// elsewhere
if len(s) == 0 {
return Key{"/"}
}
// perform a quick sanity check that the key is in the correct
// format, if it is not then it is a programmer error and it is
// okay to panic
if len(s) == 0 || s[0] != '/'... | [
"func",
"RawKey",
"(",
"s",
"string",
")",
"Key",
"{",
"// accept an empty string and fix it to avoid special cases",
"// elsewhere",
"if",
"len",
"(",
"s",
")",
"==",
"0",
"{",
"return",
"Key",
"{",
"\"",
"\"",
"}",
"\n",
"}",
"\n\n",
"// perform a quick sanity... | // RawKey creates a new Key without safety checking the input. Use with care. | [
"RawKey",
"creates",
"a",
"new",
"Key",
"without",
"safety",
"checking",
"the",
"input",
".",
"Use",
"with",
"care",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/key.go#L45-L60 |
144,363 | ipfs/go-datastore | key.go | Clean | func (k *Key) Clean() {
switch {
case len(k.string) == 0:
k.string = "/"
case k.string[0] == '/':
k.string = path.Clean(k.string)
default:
k.string = path.Clean("/" + k.string)
}
} | go | func (k *Key) Clean() {
switch {
case len(k.string) == 0:
k.string = "/"
case k.string[0] == '/':
k.string = path.Clean(k.string)
default:
k.string = path.Clean("/" + k.string)
}
} | [
"func",
"(",
"k",
"*",
"Key",
")",
"Clean",
"(",
")",
"{",
"switch",
"{",
"case",
"len",
"(",
"k",
".",
"string",
")",
"==",
"0",
":",
"k",
".",
"string",
"=",
"\"",
"\"",
"\n",
"case",
"k",
".",
"string",
"[",
"0",
"]",
"==",
"'/'",
":",
... | // Clean up a Key, using path.Clean. | [
"Clean",
"up",
"a",
"Key",
"using",
"path",
".",
"Clean",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/key.go#L68-L77 |
144,364 | ipfs/go-datastore | key.go | Equal | func (k Key) Equal(k2 Key) bool {
return k.string == k2.string
} | go | func (k Key) Equal(k2 Key) bool {
return k.string == k2.string
} | [
"func",
"(",
"k",
"Key",
")",
"Equal",
"(",
"k2",
"Key",
")",
"bool",
"{",
"return",
"k",
".",
"string",
"==",
"k2",
".",
"string",
"\n",
"}"
] | // Equal checks equality of two keys | [
"Equal",
"checks",
"equality",
"of",
"two",
"keys"
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/key.go#L90-L92 |
144,365 | ipfs/go-datastore | key.go | Less | func (k Key) Less(k2 Key) bool {
list1 := k.List()
list2 := k2.List()
for i, c1 := range list1 {
if len(list2) < (i + 1) {
return false
}
c2 := list2[i]
if c1 < c2 {
return true
} else if c1 > c2 {
return false
}
// c1 == c2, continue
}
// list1 is shorter or exactly the same.
return len(... | go | func (k Key) Less(k2 Key) bool {
list1 := k.List()
list2 := k2.List()
for i, c1 := range list1 {
if len(list2) < (i + 1) {
return false
}
c2 := list2[i]
if c1 < c2 {
return true
} else if c1 > c2 {
return false
}
// c1 == c2, continue
}
// list1 is shorter or exactly the same.
return len(... | [
"func",
"(",
"k",
"Key",
")",
"Less",
"(",
"k2",
"Key",
")",
"bool",
"{",
"list1",
":=",
"k",
".",
"List",
"(",
")",
"\n",
"list2",
":=",
"k2",
".",
"List",
"(",
")",
"\n",
"for",
"i",
",",
"c1",
":=",
"range",
"list1",
"{",
"if",
"len",
"(... | // Less checks whether this key is sorted lower than another. | [
"Less",
"checks",
"whether",
"this",
"key",
"is",
"sorted",
"lower",
"than",
"another",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/key.go#L95-L114 |
144,366 | ipfs/go-datastore | key.go | UnmarshalJSON | func (k *Key) UnmarshalJSON(data []byte) error {
var key string
if err := json.Unmarshal(data, &key); err != nil {
return err
}
*k = NewKey(key)
return nil
} | go | func (k *Key) UnmarshalJSON(data []byte) error {
var key string
if err := json.Unmarshal(data, &key); err != nil {
return err
}
*k = NewKey(key)
return nil
} | [
"func",
"(",
"k",
"*",
"Key",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"key",
"string",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"key",
")",
";",
"err",
"!=",
"nil",
"{",
"r... | // UnmarshalJSON implements the json.Unmarshaler interface,
// keys will parse any value specified as a key to a string | [
"UnmarshalJSON",
"implements",
"the",
"json",
".",
"Unmarshaler",
"interface",
"keys",
"will",
"parse",
"any",
"value",
"specified",
"as",
"a",
"key",
"to",
"a",
"string"
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/key.go#L244-L251 |
144,367 | ipfs/go-datastore | query/query_impl.go | NaiveFilter | func NaiveFilter(qr Results, filter Filter) Results {
return ResultsFromIterator(qr.Query(), Iterator{
Next: func() (Result, bool) {
for {
e, ok := qr.NextSync()
if !ok {
return Result{}, false
}
if e.Error != nil || filter.Filter(e.Entry) {
return e, true
}
}
},
Close: func()... | go | func NaiveFilter(qr Results, filter Filter) Results {
return ResultsFromIterator(qr.Query(), Iterator{
Next: func() (Result, bool) {
for {
e, ok := qr.NextSync()
if !ok {
return Result{}, false
}
if e.Error != nil || filter.Filter(e.Entry) {
return e, true
}
}
},
Close: func()... | [
"func",
"NaiveFilter",
"(",
"qr",
"Results",
",",
"filter",
"Filter",
")",
"Results",
"{",
"return",
"ResultsFromIterator",
"(",
"qr",
".",
"Query",
"(",
")",
",",
"Iterator",
"{",
"Next",
":",
"func",
"(",
")",
"(",
"Result",
",",
"bool",
")",
"{",
... | // NaiveFilter applies a filter to the results. | [
"NaiveFilter",
"applies",
"a",
"filter",
"to",
"the",
"results",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/query/query_impl.go#L8-L25 |
144,368 | ipfs/go-datastore | query/query_impl.go | NaiveLimit | func NaiveLimit(qr Results, limit int) Results {
if limit == 0 {
// 0 means no limit
return qr
}
closed := false
return ResultsFromIterator(qr.Query(), Iterator{
Next: func() (Result, bool) {
if limit == 0 {
if !closed {
closed = true
err := qr.Close()
if err != nil {
return Result... | go | func NaiveLimit(qr Results, limit int) Results {
if limit == 0 {
// 0 means no limit
return qr
}
closed := false
return ResultsFromIterator(qr.Query(), Iterator{
Next: func() (Result, bool) {
if limit == 0 {
if !closed {
closed = true
err := qr.Close()
if err != nil {
return Result... | [
"func",
"NaiveLimit",
"(",
"qr",
"Results",
",",
"limit",
"int",
")",
"Results",
"{",
"if",
"limit",
"==",
"0",
"{",
"// 0 means no limit",
"return",
"qr",
"\n",
"}",
"\n",
"closed",
":=",
"false",
"\n",
"return",
"ResultsFromIterator",
"(",
"qr",
".",
"... | // NaiveLimit truncates the results to a given int limit | [
"NaiveLimit",
"truncates",
"the",
"results",
"to",
"a",
"given",
"int",
"limit"
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/query/query_impl.go#L28-L57 |
144,369 | ipfs/go-datastore | query/query_impl.go | NaiveOffset | func NaiveOffset(qr Results, offset int) Results {
return ResultsFromIterator(qr.Query(), Iterator{
Next: func() (Result, bool) {
for ; offset > 0; offset-- {
res, ok := qr.NextSync()
if !ok || res.Error != nil {
return res, ok
}
}
return qr.NextSync()
},
Close: func() error {
return... | go | func NaiveOffset(qr Results, offset int) Results {
return ResultsFromIterator(qr.Query(), Iterator{
Next: func() (Result, bool) {
for ; offset > 0; offset-- {
res, ok := qr.NextSync()
if !ok || res.Error != nil {
return res, ok
}
}
return qr.NextSync()
},
Close: func() error {
return... | [
"func",
"NaiveOffset",
"(",
"qr",
"Results",
",",
"offset",
"int",
")",
"Results",
"{",
"return",
"ResultsFromIterator",
"(",
"qr",
".",
"Query",
"(",
")",
",",
"Iterator",
"{",
"Next",
":",
"func",
"(",
")",
"(",
"Result",
",",
"bool",
")",
"{",
"fo... | // NaiveOffset skips a given number of results | [
"NaiveOffset",
"skips",
"a",
"given",
"number",
"of",
"results"
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/query/query_impl.go#L60-L75 |
144,370 | ipfs/go-datastore | query/order.go | Less | func Less(orders []Order, a, b Entry) bool {
for _, cmp := range orders {
switch cmp.Compare(a, b) {
case 0:
case -1:
return true
case 1:
return false
}
}
// This gives us a *stable* sort for free. We don't care
// preserving the order from the underlying datastore
// because it's undefined.
retu... | go | func Less(orders []Order, a, b Entry) bool {
for _, cmp := range orders {
switch cmp.Compare(a, b) {
case 0:
case -1:
return true
case 1:
return false
}
}
// This gives us a *stable* sort for free. We don't care
// preserving the order from the underlying datastore
// because it's undefined.
retu... | [
"func",
"Less",
"(",
"orders",
"[",
"]",
"Order",
",",
"a",
",",
"b",
"Entry",
")",
"bool",
"{",
"for",
"_",
",",
"cmp",
":=",
"range",
"orders",
"{",
"switch",
"cmp",
".",
"Compare",
"(",
"a",
",",
"b",
")",
"{",
"case",
"0",
":",
"case",
"-... | // Less returns true if a comes before b with the requested orderings. | [
"Less",
"returns",
"true",
"if",
"a",
"comes",
"before",
"b",
"with",
"the",
"requested",
"orderings",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/query/order.go#L52-L67 |
144,371 | ipfs/go-datastore | query/order.go | Sort | func Sort(orders []Order, entries []Entry) {
sort.Slice(entries, func(i int, j int) bool {
return Less(orders, entries[i], entries[j])
})
} | go | func Sort(orders []Order, entries []Entry) {
sort.Slice(entries, func(i int, j int) bool {
return Less(orders, entries[i], entries[j])
})
} | [
"func",
"Sort",
"(",
"orders",
"[",
"]",
"Order",
",",
"entries",
"[",
"]",
"Entry",
")",
"{",
"sort",
".",
"Slice",
"(",
"entries",
",",
"func",
"(",
"i",
"int",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"Less",
"(",
"orders",
",",
"entries",... | // Sort sorts the given entries using the given orders. | [
"Sort",
"sorts",
"the",
"given",
"entries",
"using",
"the",
"given",
"orders",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/query/order.go#L70-L74 |
144,372 | ipfs/go-datastore | delayed/delayed.go | New | func New(ds ds.Datastore, delay delay.D) *Delayed {
return &Delayed{ds: ds, delay: delay}
} | go | func New(ds ds.Datastore, delay delay.D) *Delayed {
return &Delayed{ds: ds, delay: delay}
} | [
"func",
"New",
"(",
"ds",
"ds",
".",
"Datastore",
",",
"delay",
"delay",
".",
"D",
")",
"*",
"Delayed",
"{",
"return",
"&",
"Delayed",
"{",
"ds",
":",
"ds",
",",
"delay",
":",
"delay",
"}",
"\n",
"}"
] | // New returns a new delayed datastore. | [
"New",
"returns",
"a",
"new",
"delayed",
"datastore",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/delayed/delayed.go#L14-L16 |
144,373 | ipfs/go-datastore | delayed/delayed.go | Put | func (dds *Delayed) Put(key ds.Key, value []byte) (err error) {
dds.delay.Wait()
return dds.ds.Put(key, value)
} | go | func (dds *Delayed) Put(key ds.Key, value []byte) (err error) {
dds.delay.Wait()
return dds.ds.Put(key, value)
} | [
"func",
"(",
"dds",
"*",
"Delayed",
")",
"Put",
"(",
"key",
"ds",
".",
"Key",
",",
"value",
"[",
"]",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"dds",
".",
"delay",
".",
"Wait",
"(",
")",
"\n",
"return",
"dds",
".",
"ds",
".",
"Put",
"(",
... | // Put implements the ds.Datastore interface. | [
"Put",
"implements",
"the",
"ds",
".",
"Datastore",
"interface",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/delayed/delayed.go#L28-L31 |
144,374 | ipfs/go-datastore | delayed/delayed.go | Has | func (dds *Delayed) Has(key ds.Key) (exists bool, err error) {
dds.delay.Wait()
return dds.ds.Has(key)
} | go | func (dds *Delayed) Has(key ds.Key) (exists bool, err error) {
dds.delay.Wait()
return dds.ds.Has(key)
} | [
"func",
"(",
"dds",
"*",
"Delayed",
")",
"Has",
"(",
"key",
"ds",
".",
"Key",
")",
"(",
"exists",
"bool",
",",
"err",
"error",
")",
"{",
"dds",
".",
"delay",
".",
"Wait",
"(",
")",
"\n",
"return",
"dds",
".",
"ds",
".",
"Has",
"(",
"key",
")"... | // Has implements the ds.Datastore interface. | [
"Has",
"implements",
"the",
"ds",
".",
"Datastore",
"interface",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/delayed/delayed.go#L40-L43 |
144,375 | ipfs/go-datastore | delayed/delayed.go | GetSize | func (dds *Delayed) GetSize(key ds.Key) (size int, err error) {
dds.delay.Wait()
return dds.ds.GetSize(key)
} | go | func (dds *Delayed) GetSize(key ds.Key) (size int, err error) {
dds.delay.Wait()
return dds.ds.GetSize(key)
} | [
"func",
"(",
"dds",
"*",
"Delayed",
")",
"GetSize",
"(",
"key",
"ds",
".",
"Key",
")",
"(",
"size",
"int",
",",
"err",
"error",
")",
"{",
"dds",
".",
"delay",
".",
"Wait",
"(",
")",
"\n",
"return",
"dds",
".",
"ds",
".",
"GetSize",
"(",
"key",
... | // GetSize implements the ds.Datastore interface. | [
"GetSize",
"implements",
"the",
"ds",
".",
"Datastore",
"interface",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/delayed/delayed.go#L46-L49 |
144,376 | ipfs/go-datastore | delayed/delayed.go | Delete | func (dds *Delayed) Delete(key ds.Key) (err error) {
dds.delay.Wait()
return dds.ds.Delete(key)
} | go | func (dds *Delayed) Delete(key ds.Key) (err error) {
dds.delay.Wait()
return dds.ds.Delete(key)
} | [
"func",
"(",
"dds",
"*",
"Delayed",
")",
"Delete",
"(",
"key",
"ds",
".",
"Key",
")",
"(",
"err",
"error",
")",
"{",
"dds",
".",
"delay",
".",
"Wait",
"(",
")",
"\n",
"return",
"dds",
".",
"ds",
".",
"Delete",
"(",
"key",
")",
"\n",
"}"
] | // Delete implements the ds.Datastore interface. | [
"Delete",
"implements",
"the",
"ds",
".",
"Datastore",
"interface",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/delayed/delayed.go#L52-L55 |
144,377 | ipfs/go-datastore | delayed/delayed.go | Query | func (dds *Delayed) Query(q dsq.Query) (dsq.Results, error) {
dds.delay.Wait()
return dds.ds.Query(q)
} | go | func (dds *Delayed) Query(q dsq.Query) (dsq.Results, error) {
dds.delay.Wait()
return dds.ds.Query(q)
} | [
"func",
"(",
"dds",
"*",
"Delayed",
")",
"Query",
"(",
"q",
"dsq",
".",
"Query",
")",
"(",
"dsq",
".",
"Results",
",",
"error",
")",
"{",
"dds",
".",
"delay",
".",
"Wait",
"(",
")",
"\n",
"return",
"dds",
".",
"ds",
".",
"Query",
"(",
"q",
")... | // Query implements the ds.Datastore interface. | [
"Query",
"implements",
"the",
"ds",
".",
"Datastore",
"interface",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/delayed/delayed.go#L58-L61 |
144,378 | ipfs/go-datastore | delayed/delayed.go | Batch | func (dds *Delayed) Batch() (ds.Batch, error) {
return ds.NewBasicBatch(dds), nil
} | go | func (dds *Delayed) Batch() (ds.Batch, error) {
return ds.NewBasicBatch(dds), nil
} | [
"func",
"(",
"dds",
"*",
"Delayed",
")",
"Batch",
"(",
")",
"(",
"ds",
".",
"Batch",
",",
"error",
")",
"{",
"return",
"ds",
".",
"NewBasicBatch",
"(",
"dds",
")",
",",
"nil",
"\n",
"}"
] | // Batch implements the ds.Batching interface. | [
"Batch",
"implements",
"the",
"ds",
".",
"Batching",
"interface",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/delayed/delayed.go#L64-L66 |
144,379 | ipfs/go-datastore | delayed/delayed.go | DiskUsage | func (dds *Delayed) DiskUsage() (uint64, error) {
dds.delay.Wait()
return ds.DiskUsage(dds.ds)
} | go | func (dds *Delayed) DiskUsage() (uint64, error) {
dds.delay.Wait()
return ds.DiskUsage(dds.ds)
} | [
"func",
"(",
"dds",
"*",
"Delayed",
")",
"DiskUsage",
"(",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"dds",
".",
"delay",
".",
"Wait",
"(",
")",
"\n",
"return",
"ds",
".",
"DiskUsage",
"(",
"dds",
".",
"ds",
")",
"\n",
"}"
] | // DiskUsage implements the ds.PersistentDatastore interface. | [
"DiskUsage",
"implements",
"the",
"ds",
".",
"PersistentDatastore",
"interface",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/delayed/delayed.go#L69-L72 |
144,380 | ipfs/go-datastore | query/query.go | Results | func (rb *ResultBuilder) Results() Results {
return &results{
query: rb.Query,
proc: rb.Process,
res: rb.Output,
}
} | go | func (rb *ResultBuilder) Results() Results {
return &results{
query: rb.Query,
proc: rb.Process,
res: rb.Output,
}
} | [
"func",
"(",
"rb",
"*",
"ResultBuilder",
")",
"Results",
"(",
")",
"Results",
"{",
"return",
"&",
"results",
"{",
"query",
":",
"rb",
".",
"Query",
",",
"proc",
":",
"rb",
".",
"Process",
",",
"res",
":",
"rb",
".",
"Output",
",",
"}",
"\n",
"}"
... | // Results returns a Results to to this builder. | [
"Results",
"returns",
"a",
"Results",
"to",
"to",
"this",
"builder",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/query/query.go#L179-L185 |
144,381 | ipfs/go-datastore | query/query.go | ResultsWithProcess | func ResultsWithProcess(q Query, proc func(goprocess.Process, chan<- Result)) Results {
b := NewResultBuilder(q)
// go consume all the entries and add them to the results.
b.Process.Go(func(worker goprocess.Process) {
proc(worker, b.Output)
})
go b.Process.CloseAfterChildren()
return b.Results()
} | go | func ResultsWithProcess(q Query, proc func(goprocess.Process, chan<- Result)) Results {
b := NewResultBuilder(q)
// go consume all the entries and add them to the results.
b.Process.Go(func(worker goprocess.Process) {
proc(worker, b.Output)
})
go b.Process.CloseAfterChildren()
return b.Results()
} | [
"func",
"ResultsWithProcess",
"(",
"q",
"Query",
",",
"proc",
"func",
"(",
"goprocess",
".",
"Process",
",",
"chan",
"<-",
"Result",
")",
")",
"Results",
"{",
"b",
":=",
"NewResultBuilder",
"(",
"q",
")",
"\n\n",
"// go consume all the entries and add them to th... | // ResultsWithProcess returns a Results object with the results generated by the
// passed subprocess. | [
"ResultsWithProcess",
"returns",
"a",
"Results",
"object",
"with",
"the",
"results",
"generated",
"by",
"the",
"passed",
"subprocess",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/query/query.go#L234-L244 |
144,382 | ipfs/go-datastore | query/query.go | ResultsWithEntries | func ResultsWithEntries(q Query, res []Entry) Results {
i := 0
return ResultsFromIterator(q, Iterator{
Next: func() (Result, bool) {
if i >= len(res) {
return Result{}, false
}
next := res[i]
i++
return Result{Entry: next}, true
},
})
} | go | func ResultsWithEntries(q Query, res []Entry) Results {
i := 0
return ResultsFromIterator(q, Iterator{
Next: func() (Result, bool) {
if i >= len(res) {
return Result{}, false
}
next := res[i]
i++
return Result{Entry: next}, true
},
})
} | [
"func",
"ResultsWithEntries",
"(",
"q",
"Query",
",",
"res",
"[",
"]",
"Entry",
")",
"Results",
"{",
"i",
":=",
"0",
"\n",
"return",
"ResultsFromIterator",
"(",
"q",
",",
"Iterator",
"{",
"Next",
":",
"func",
"(",
")",
"(",
"Result",
",",
"bool",
")"... | // ResultsWithEntries returns a Results object from a list of entries | [
"ResultsWithEntries",
"returns",
"a",
"Results",
"object",
"from",
"a",
"list",
"of",
"entries"
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/query/query.go#L247-L259 |
144,383 | ipfs/go-datastore | query/query.go | ResultsFromIterator | func ResultsFromIterator(q Query, iter Iterator) Results {
if iter.Close == nil {
iter.Close = noopClose
}
return &resultsIter{
query: q,
next: iter.Next,
close: iter.Close,
}
} | go | func ResultsFromIterator(q Query, iter Iterator) Results {
if iter.Close == nil {
iter.Close = noopClose
}
return &resultsIter{
query: q,
next: iter.Next,
close: iter.Close,
}
} | [
"func",
"ResultsFromIterator",
"(",
"q",
"Query",
",",
"iter",
"Iterator",
")",
"Results",
"{",
"if",
"iter",
".",
"Close",
"==",
"nil",
"{",
"iter",
".",
"Close",
"=",
"noopClose",
"\n",
"}",
"\n",
"return",
"&",
"resultsIter",
"{",
"query",
":",
"q",... | //
// ResultFromIterator provides an alternative way to to construct
// results without the use of channels.
// | [
"ResultFromIterator",
"provides",
"an",
"alternative",
"way",
"to",
"to",
"construct",
"results",
"without",
"the",
"use",
"of",
"channels",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/query/query.go#L283-L292 |
144,384 | ipfs/go-datastore | keytransform/keytransform.go | Wrap | func Wrap(child ds.Datastore, t KeyTransform) *Datastore {
if t == nil {
panic("t (KeyTransform) is nil")
}
if child == nil {
panic("child (ds.Datastore) is nil")
}
return &Datastore{child: child, KeyTransform: t}
} | go | func Wrap(child ds.Datastore, t KeyTransform) *Datastore {
if t == nil {
panic("t (KeyTransform) is nil")
}
if child == nil {
panic("child (ds.Datastore) is nil")
}
return &Datastore{child: child, KeyTransform: t}
} | [
"func",
"Wrap",
"(",
"child",
"ds",
".",
"Datastore",
",",
"t",
"KeyTransform",
")",
"*",
"Datastore",
"{",
"if",
"t",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"child",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
... | // Wrap wraps a given datastore with a KeyTransform function.
// The resulting wrapped datastore will use the transform on all Datastore
// operations. | [
"Wrap",
"wraps",
"a",
"given",
"datastore",
"with",
"a",
"KeyTransform",
"function",
".",
"The",
"resulting",
"wrapped",
"datastore",
"will",
"use",
"the",
"transform",
"on",
"all",
"Datastore",
"operations",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/keytransform/keytransform.go#L11-L21 |
144,385 | ipfs/go-datastore | keytransform/keytransform.go | Put | func (d *Datastore) Put(key ds.Key, value []byte) (err error) {
return d.child.Put(d.ConvertKey(key), value)
} | go | func (d *Datastore) Put(key ds.Key, value []byte) (err error) {
return d.child.Put(d.ConvertKey(key), value)
} | [
"func",
"(",
"d",
"*",
"Datastore",
")",
"Put",
"(",
"key",
"ds",
".",
"Key",
",",
"value",
"[",
"]",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"return",
"d",
".",
"child",
".",
"Put",
"(",
"d",
".",
"ConvertKey",
"(",
"key",
")",
",",
"val... | // Put stores the given value, transforming the key first. | [
"Put",
"stores",
"the",
"given",
"value",
"transforming",
"the",
"key",
"first",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/keytransform/keytransform.go#L36-L38 |
144,386 | ipfs/go-datastore | keytransform/keytransform.go | Has | func (d *Datastore) Has(key ds.Key) (exists bool, err error) {
return d.child.Has(d.ConvertKey(key))
} | go | func (d *Datastore) Has(key ds.Key) (exists bool, err error) {
return d.child.Has(d.ConvertKey(key))
} | [
"func",
"(",
"d",
"*",
"Datastore",
")",
"Has",
"(",
"key",
"ds",
".",
"Key",
")",
"(",
"exists",
"bool",
",",
"err",
"error",
")",
"{",
"return",
"d",
".",
"child",
".",
"Has",
"(",
"d",
".",
"ConvertKey",
"(",
"key",
")",
")",
"\n",
"}"
] | // Has returns whether the datastore has a value for a given key, transforming
// the key first. | [
"Has",
"returns",
"whether",
"the",
"datastore",
"has",
"a",
"value",
"for",
"a",
"given",
"key",
"transforming",
"the",
"key",
"first",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/keytransform/keytransform.go#L47-L49 |
144,387 | ipfs/go-datastore | keytransform/keytransform.go | GetSize | func (d *Datastore) GetSize(key ds.Key) (size int, err error) {
return d.child.GetSize(d.ConvertKey(key))
} | go | func (d *Datastore) GetSize(key ds.Key) (size int, err error) {
return d.child.GetSize(d.ConvertKey(key))
} | [
"func",
"(",
"d",
"*",
"Datastore",
")",
"GetSize",
"(",
"key",
"ds",
".",
"Key",
")",
"(",
"size",
"int",
",",
"err",
"error",
")",
"{",
"return",
"d",
".",
"child",
".",
"GetSize",
"(",
"d",
".",
"ConvertKey",
"(",
"key",
")",
")",
"\n",
"}"
... | // GetSize returns the size of the value named by the given key, transforming
// the key first. | [
"GetSize",
"returns",
"the",
"size",
"of",
"the",
"value",
"named",
"by",
"the",
"given",
"key",
"transforming",
"the",
"key",
"first",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/keytransform/keytransform.go#L53-L55 |
144,388 | ipfs/go-datastore | keytransform/keytransform.go | Query | func (d *Datastore) Query(q dsq.Query) (dsq.Results, error) {
nq, cq := d.prepareQuery(q)
cqr, err := d.child.Query(cq)
if err != nil {
return nil, err
}
qr := dsq.ResultsFromIterator(q, dsq.Iterator{
Next: func() (dsq.Result, bool) {
r, ok := cqr.NextSync()
if !ok {
return r, false
}
if r.Er... | go | func (d *Datastore) Query(q dsq.Query) (dsq.Results, error) {
nq, cq := d.prepareQuery(q)
cqr, err := d.child.Query(cq)
if err != nil {
return nil, err
}
qr := dsq.ResultsFromIterator(q, dsq.Iterator{
Next: func() (dsq.Result, bool) {
r, ok := cqr.NextSync()
if !ok {
return r, false
}
if r.Er... | [
"func",
"(",
"d",
"*",
"Datastore",
")",
"Query",
"(",
"q",
"dsq",
".",
"Query",
")",
"(",
"dsq",
".",
"Results",
",",
"error",
")",
"{",
"nq",
",",
"cq",
":=",
"d",
".",
"prepareQuery",
"(",
"q",
")",
"\n\n",
"cqr",
",",
"err",
":=",
"d",
".... | // Query implements Query, inverting keys on the way back out. | [
"Query",
"implements",
"Query",
"inverting",
"keys",
"on",
"the",
"way",
"back",
"out",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/keytransform/keytransform.go#L63-L87 |
144,389 | ipfs/go-datastore | keytransform/keytransform.go | prepareQuery | func (d *Datastore) prepareQuery(q dsq.Query) (naive, child dsq.Query) {
// First, put everything in the child query. Then, start taking things
// out.
child = q
// Always let the child handle the key prefix.
child.Prefix = d.ConvertKey(ds.NewKey(child.Prefix)).String()
// Check if the key transform is order-p... | go | func (d *Datastore) prepareQuery(q dsq.Query) (naive, child dsq.Query) {
// First, put everything in the child query. Then, start taking things
// out.
child = q
// Always let the child handle the key prefix.
child.Prefix = d.ConvertKey(ds.NewKey(child.Prefix)).String()
// Check if the key transform is order-p... | [
"func",
"(",
"d",
"*",
"Datastore",
")",
"prepareQuery",
"(",
"q",
"dsq",
".",
"Query",
")",
"(",
"naive",
",",
"child",
"dsq",
".",
"Query",
")",
"{",
"// First, put everything in the child query. Then, start taking things",
"// out.",
"child",
"=",
"q",
"\n\n"... | // Split the query into a child query and a naive query. That way, we can make
// the child datastore do as much work as possible. | [
"Split",
"the",
"query",
"into",
"a",
"child",
"query",
"and",
"a",
"naive",
"query",
".",
"That",
"way",
"we",
"can",
"make",
"the",
"child",
"datastore",
"do",
"as",
"much",
"work",
"as",
"possible",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/keytransform/keytransform.go#L91-L185 |
144,390 | ipfs/go-datastore | mount/mount.go | DiskUsage | func (d *Datastore) DiskUsage() (uint64, error) {
var duTotal uint64 = 0
for _, d := range d.mounts {
du, err := ds.DiskUsage(d.Datastore)
duTotal += du
if err != nil {
return duTotal, err
}
}
return duTotal, nil
} | go | func (d *Datastore) DiskUsage() (uint64, error) {
var duTotal uint64 = 0
for _, d := range d.mounts {
du, err := ds.DiskUsage(d.Datastore)
duTotal += du
if err != nil {
return duTotal, err
}
}
return duTotal, nil
} | [
"func",
"(",
"d",
"*",
"Datastore",
")",
"DiskUsage",
"(",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"var",
"duTotal",
"uint64",
"=",
"0",
"\n",
"for",
"_",
",",
"d",
":=",
"range",
"d",
".",
"mounts",
"{",
"du",
",",
"err",
":=",
"ds",
".",
... | // DiskUsage returns the sum of DiskUsages for the mounted datastores.
// Non PersistentDatastores will not be accounted. | [
"DiskUsage",
"returns",
"the",
"sum",
"of",
"DiskUsages",
"for",
"the",
"mounted",
"datastores",
".",
"Non",
"PersistentDatastores",
"will",
"not",
"be",
"accounted",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/mount/mount.go#L291-L301 |
144,391 | ipfs/go-datastore | namespace/namespace.go | Wrap | func Wrap(child ds.Datastore, prefix ds.Key) *ktds.Datastore {
if child == nil {
panic("child (ds.Datastore) is nil")
}
return ktds.Wrap(child, PrefixTransform(prefix))
} | go | func Wrap(child ds.Datastore, prefix ds.Key) *ktds.Datastore {
if child == nil {
panic("child (ds.Datastore) is nil")
}
return ktds.Wrap(child, PrefixTransform(prefix))
} | [
"func",
"Wrap",
"(",
"child",
"ds",
".",
"Datastore",
",",
"prefix",
"ds",
".",
"Key",
")",
"*",
"ktds",
".",
"Datastore",
"{",
"if",
"child",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"ktds",
".",
"Wrap",
"(",... | // Wrap wraps a given datastore with a key-prefix. | [
"Wrap",
"wraps",
"a",
"given",
"datastore",
"with",
"a",
"key",
"-",
"prefix",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/namespace/namespace.go#L20-L26 |
144,392 | ipfs/go-datastore | failstore/failstore.go | Get | func (d *Failstore) Get(k ds.Key) ([]byte, error) {
err := d.errfunc("get")
if err != nil {
return nil, err
}
return d.child.Get(k)
} | go | func (d *Failstore) Get(k ds.Key) ([]byte, error) {
err := d.errfunc("get")
if err != nil {
return nil, err
}
return d.child.Get(k)
} | [
"func",
"(",
"d",
"*",
"Failstore",
")",
"Get",
"(",
"k",
"ds",
".",
"Key",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"err",
":=",
"d",
".",
"errfunc",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",... | // Get retrieves a value from the datastore. | [
"Get",
"retrieves",
"a",
"value",
"from",
"the",
"datastore",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/failstore/failstore.go#L40-L47 |
144,393 | ipfs/go-datastore | failstore/failstore.go | Query | func (d *Failstore) Query(q dsq.Query) (dsq.Results, error) {
err := d.errfunc("query")
if err != nil {
return nil, err
}
return d.child.Query(q)
} | go | func (d *Failstore) Query(q dsq.Query) (dsq.Results, error) {
err := d.errfunc("query")
if err != nil {
return nil, err
}
return d.child.Query(q)
} | [
"func",
"(",
"d",
"*",
"Failstore",
")",
"Query",
"(",
"q",
"dsq",
".",
"Query",
")",
"(",
"dsq",
".",
"Results",
",",
"error",
")",
"{",
"err",
":=",
"d",
".",
"errfunc",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"... | // Query performs a query on the datastore. | [
"Query",
"performs",
"a",
"query",
"on",
"the",
"datastore",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/failstore/failstore.go#L80-L87 |
144,394 | ipfs/go-datastore | failstore/failstore.go | Batch | func (d *Failstore) Batch() (ds.Batch, error) {
if err := d.errfunc("batch"); err != nil {
return nil, err
}
b, err := d.child.(ds.Batching).Batch()
if err != nil {
return nil, err
}
return &FailBatch{
cb: b,
dstore: d,
}, nil
} | go | func (d *Failstore) Batch() (ds.Batch, error) {
if err := d.errfunc("batch"); err != nil {
return nil, err
}
b, err := d.child.(ds.Batching).Batch()
if err != nil {
return nil, err
}
return &FailBatch{
cb: b,
dstore: d,
}, nil
} | [
"func",
"(",
"d",
"*",
"Failstore",
")",
"Batch",
"(",
")",
"(",
"ds",
".",
"Batch",
",",
"error",
")",
"{",
"if",
"err",
":=",
"d",
".",
"errfunc",
"(",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
... | // Batch returns a new Batch Failstore. | [
"Batch",
"returns",
"a",
"new",
"Batch",
"Failstore",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/failstore/failstore.go#L109-L123 |
144,395 | ipfs/go-datastore | failstore/failstore.go | Put | func (b *FailBatch) Put(k ds.Key, val []byte) error {
if err := b.dstore.errfunc("batch-put"); err != nil {
return err
}
return b.cb.Put(k, val)
} | go | func (b *FailBatch) Put(k ds.Key, val []byte) error {
if err := b.dstore.errfunc("batch-put"); err != nil {
return err
}
return b.cb.Put(k, val)
} | [
"func",
"(",
"b",
"*",
"FailBatch",
")",
"Put",
"(",
"k",
"ds",
".",
"Key",
",",
"val",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"err",
":=",
"b",
".",
"dstore",
".",
"errfunc",
"(",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
... | // Put does a batch put. | [
"Put",
"does",
"a",
"batch",
"put",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/failstore/failstore.go#L126-L132 |
144,396 | ipfs/go-datastore | failstore/failstore.go | Delete | func (b *FailBatch) Delete(k ds.Key) error {
if err := b.dstore.errfunc("batch-delete"); err != nil {
return err
}
return b.cb.Delete(k)
} | go | func (b *FailBatch) Delete(k ds.Key) error {
if err := b.dstore.errfunc("batch-delete"); err != nil {
return err
}
return b.cb.Delete(k)
} | [
"func",
"(",
"b",
"*",
"FailBatch",
")",
"Delete",
"(",
"k",
"ds",
".",
"Key",
")",
"error",
"{",
"if",
"err",
":=",
"b",
".",
"dstore",
".",
"errfunc",
"(",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"... | // Delete does a batch delete. | [
"Delete",
"does",
"a",
"batch",
"delete",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/failstore/failstore.go#L135-L141 |
144,397 | ipfs/go-datastore | failstore/failstore.go | Commit | func (b *FailBatch) Commit() error {
if err := b.dstore.errfunc("batch-commit"); err != nil {
return err
}
return b.cb.Commit()
} | go | func (b *FailBatch) Commit() error {
if err := b.dstore.errfunc("batch-commit"); err != nil {
return err
}
return b.cb.Commit()
} | [
"func",
"(",
"b",
"*",
"FailBatch",
")",
"Commit",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"b",
".",
"dstore",
".",
"errfunc",
"(",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"b",
".",
"cb",
... | // Commit commits all operations in the batch. | [
"Commit",
"commits",
"all",
"operations",
"in",
"the",
"batch",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/failstore/failstore.go#L144-L150 |
144,398 | ipfs/go-datastore | autobatch/autobatch.go | NewAutoBatching | func NewAutoBatching(d ds.Batching, size int) *Datastore {
return &Datastore{
child: d,
buffer: make(map[ds.Key]op, size),
maxBufferEntries: size,
}
} | go | func NewAutoBatching(d ds.Batching, size int) *Datastore {
return &Datastore{
child: d,
buffer: make(map[ds.Key]op, size),
maxBufferEntries: size,
}
} | [
"func",
"NewAutoBatching",
"(",
"d",
"ds",
".",
"Batching",
",",
"size",
"int",
")",
"*",
"Datastore",
"{",
"return",
"&",
"Datastore",
"{",
"child",
":",
"d",
",",
"buffer",
":",
"make",
"(",
"map",
"[",
"ds",
".",
"Key",
"]",
"op",
",",
"size",
... | // NewAutoBatching returns a new datastore that automatically
// batches writes using the given Batching datastore. The size
// of the memory pool is given by size. | [
"NewAutoBatching",
"returns",
"a",
"new",
"datastore",
"that",
"automatically",
"batches",
"writes",
"using",
"the",
"given",
"Batching",
"datastore",
".",
"The",
"size",
"of",
"the",
"memory",
"pool",
"is",
"given",
"by",
"size",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/autobatch/autobatch.go#L28-L34 |
144,399 | ipfs/go-datastore | autobatch/autobatch.go | Flush | func (d *Datastore) Flush() error {
b, err := d.child.Batch()
if err != nil {
return err
}
for k, o := range d.buffer {
var err error
if o.delete {
err = b.Delete(k)
if err == ds.ErrNotFound {
// Ignore these, let delete be idempotent.
err = nil
}
} else {
err = b.Put(k, o.value)
}
... | go | func (d *Datastore) Flush() error {
b, err := d.child.Batch()
if err != nil {
return err
}
for k, o := range d.buffer {
var err error
if o.delete {
err = b.Delete(k)
if err == ds.ErrNotFound {
// Ignore these, let delete be idempotent.
err = nil
}
} else {
err = b.Put(k, o.value)
}
... | [
"func",
"(",
"d",
"*",
"Datastore",
")",
"Flush",
"(",
")",
"error",
"{",
"b",
",",
"err",
":=",
"d",
".",
"child",
".",
"Batch",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
"k",
",",
"o",
":=",
... | // Flush flushes the current batch to the underlying datastore. | [
"Flush",
"flushes",
"the",
"current",
"batch",
"to",
"the",
"underlying",
"datastore",
"."
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/autobatch/autobatch.go#L68-L93 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.