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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
124,900 | m3db/m3x | time/ranges.go | Overlaps | func (tr Ranges) Overlaps(r Range) bool {
if r.IsEmpty() {
return false
}
e := tr.findFirstNotBefore(r)
if e == nil {
return false
}
lr := e.Value.(Range)
return lr.Overlaps(r)
} | go | func (tr Ranges) Overlaps(r Range) bool {
if r.IsEmpty() {
return false
}
e := tr.findFirstNotBefore(r)
if e == nil {
return false
}
lr := e.Value.(Range)
return lr.Overlaps(r)
} | [
"func",
"(",
"tr",
"Ranges",
")",
"Overlaps",
"(",
"r",
"Range",
")",
"bool",
"{",
"if",
"r",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"e",
":=",
"tr",
".",
"findFirstNotBefore",
"(",
"r",
")",
"\n",
"if",
"e",
"==",
"... | // Overlaps checks if the range overlaps with any of the ranges in the collection. | [
"Overlaps",
"checks",
"if",
"the",
"range",
"overlaps",
"with",
"any",
"of",
"the",
"ranges",
"in",
"the",
"collection",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/ranges.go#L56-L66 |
124,901 | m3db/m3x | time/ranges.go | AddRange | func (tr Ranges) AddRange(r Range) Ranges {
res := tr.clone()
res.addRangeInPlace(r)
return res
} | go | func (tr Ranges) AddRange(r Range) Ranges {
res := tr.clone()
res.addRangeInPlace(r)
return res
} | [
"func",
"(",
"tr",
"Ranges",
")",
"AddRange",
"(",
"r",
"Range",
")",
"Ranges",
"{",
"res",
":=",
"tr",
".",
"clone",
"(",
")",
"\n",
"res",
".",
"addRangeInPlace",
"(",
"r",
")",
"\n",
"return",
"res",
"\n",
"}"
] | // AddRange adds the time range to the collection of ranges. | [
"AddRange",
"adds",
"the",
"time",
"range",
"to",
"the",
"collection",
"of",
"ranges",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/ranges.go#L69-L73 |
124,902 | m3db/m3x | time/ranges.go | AddRanges | func (tr Ranges) AddRanges(other Ranges) Ranges {
res := tr.clone()
it := other.Iter()
for it.Next() {
res.addRangeInPlace(it.Value())
}
return res
} | go | func (tr Ranges) AddRanges(other Ranges) Ranges {
res := tr.clone()
it := other.Iter()
for it.Next() {
res.addRangeInPlace(it.Value())
}
return res
} | [
"func",
"(",
"tr",
"Ranges",
")",
"AddRanges",
"(",
"other",
"Ranges",
")",
"Ranges",
"{",
"res",
":=",
"tr",
".",
"clone",
"(",
")",
"\n",
"it",
":=",
"other",
".",
"Iter",
"(",
")",
"\n",
"for",
"it",
".",
"Next",
"(",
")",
"{",
"res",
".",
... | // AddRanges adds the time ranges. | [
"AddRanges",
"adds",
"the",
"time",
"ranges",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/ranges.go#L76-L83 |
124,903 | m3db/m3x | time/ranges.go | RemoveRange | func (tr Ranges) RemoveRange(r Range) Ranges {
res := tr.clone()
res.removeRangeInPlace(r)
return res
} | go | func (tr Ranges) RemoveRange(r Range) Ranges {
res := tr.clone()
res.removeRangeInPlace(r)
return res
} | [
"func",
"(",
"tr",
"Ranges",
")",
"RemoveRange",
"(",
"r",
"Range",
")",
"Ranges",
"{",
"res",
":=",
"tr",
".",
"clone",
"(",
")",
"\n",
"res",
".",
"removeRangeInPlace",
"(",
"r",
")",
"\n",
"return",
"res",
"\n",
"}"
] | // RemoveRange removes the time range from the collection of ranges. | [
"RemoveRange",
"removes",
"the",
"time",
"range",
"from",
"the",
"collection",
"of",
"ranges",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/ranges.go#L86-L90 |
124,904 | m3db/m3x | time/ranges.go | RemoveRanges | func (tr Ranges) RemoveRanges(other Ranges) Ranges {
res := tr.clone()
it := other.Iter()
for it.Next() {
res.removeRangeInPlace(it.Value())
}
return res
} | go | func (tr Ranges) RemoveRanges(other Ranges) Ranges {
res := tr.clone()
it := other.Iter()
for it.Next() {
res.removeRangeInPlace(it.Value())
}
return res
} | [
"func",
"(",
"tr",
"Ranges",
")",
"RemoveRanges",
"(",
"other",
"Ranges",
")",
"Ranges",
"{",
"res",
":=",
"tr",
".",
"clone",
"(",
")",
"\n",
"it",
":=",
"other",
".",
"Iter",
"(",
")",
"\n",
"for",
"it",
".",
"Next",
"(",
")",
"{",
"res",
"."... | // RemoveRanges removes the given time ranges from the current one. | [
"RemoveRanges",
"removes",
"the",
"given",
"time",
"ranges",
"from",
"the",
"current",
"one",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/ranges.go#L93-L100 |
124,905 | m3db/m3x | time/ranges.go | addRangeInPlace | func (tr Ranges) addRangeInPlace(r Range) {
if r.IsEmpty() {
return
}
e := tr.findFirstNotBefore(r)
for e != nil {
lr := e.Value.(Range)
ne := e.Next()
if !lr.Overlaps(r) {
break
}
r = r.Merge(lr)
tr.sortedRanges.Remove(e)
e = ne
}
if e == nil {
tr.sortedRanges.PushBack(r)
return
}
tr.so... | go | func (tr Ranges) addRangeInPlace(r Range) {
if r.IsEmpty() {
return
}
e := tr.findFirstNotBefore(r)
for e != nil {
lr := e.Value.(Range)
ne := e.Next()
if !lr.Overlaps(r) {
break
}
r = r.Merge(lr)
tr.sortedRanges.Remove(e)
e = ne
}
if e == nil {
tr.sortedRanges.PushBack(r)
return
}
tr.so... | [
"func",
"(",
"tr",
"Ranges",
")",
"addRangeInPlace",
"(",
"r",
"Range",
")",
"{",
"if",
"r",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"e",
":=",
"tr",
".",
"findFirstNotBefore",
"(",
"r",
")",
"\n",
"for",
"e",
"!=",
"nil",
"{"... | // addRangeInPlace adds r to tr in place without creating a new copy. | [
"addRangeInPlace",
"adds",
"r",
"to",
"tr",
"in",
"place",
"without",
"creating",
"a",
"new",
"copy",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/ranges.go#L124-L145 |
124,906 | m3db/m3x | time/ranges.go | findFirstNotBefore | func (tr Ranges) findFirstNotBefore(r Range) *list.Element {
if tr.sortedRanges == nil {
return nil
}
for e := tr.sortedRanges.Front(); e != nil; e = e.Next() {
if !e.Value.(Range).Before(r) {
return e
}
}
return nil
} | go | func (tr Ranges) findFirstNotBefore(r Range) *list.Element {
if tr.sortedRanges == nil {
return nil
}
for e := tr.sortedRanges.Front(); e != nil; e = e.Next() {
if !e.Value.(Range).Before(r) {
return e
}
}
return nil
} | [
"func",
"(",
"tr",
"Ranges",
")",
"findFirstNotBefore",
"(",
"r",
"Range",
")",
"*",
"list",
".",
"Element",
"{",
"if",
"tr",
".",
"sortedRanges",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"for",
"e",
":=",
"tr",
".",
"sortedRanges",
".",
... | // findFirstNotBefore finds the first interval that's not before r. | [
"findFirstNotBefore",
"finds",
"the",
"first",
"interval",
"that",
"s",
"not",
"before",
"r",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/ranges.go#L172-L182 |
124,907 | m3db/m3x | time/ranges.go | clone | func (tr Ranges) clone() Ranges {
res := Ranges{sortedRanges: list.New()}
if tr.sortedRanges == nil {
return res
}
for e := tr.sortedRanges.Front(); e != nil; e = e.Next() {
res.sortedRanges.PushBack(e.Value.(Range))
}
return res
} | go | func (tr Ranges) clone() Ranges {
res := Ranges{sortedRanges: list.New()}
if tr.sortedRanges == nil {
return res
}
for e := tr.sortedRanges.Front(); e != nil; e = e.Next() {
res.sortedRanges.PushBack(e.Value.(Range))
}
return res
} | [
"func",
"(",
"tr",
"Ranges",
")",
"clone",
"(",
")",
"Ranges",
"{",
"res",
":=",
"Ranges",
"{",
"sortedRanges",
":",
"list",
".",
"New",
"(",
")",
"}",
"\n",
"if",
"tr",
".",
"sortedRanges",
"==",
"nil",
"{",
"return",
"res",
"\n",
"}",
"\n",
"fo... | // clone returns a copy of the time ranges. | [
"clone",
"returns",
"a",
"copy",
"of",
"the",
"time",
"ranges",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/ranges.go#L185-L194 |
124,908 | m3db/m3x | checked/ref.go | IncRef | func (c *RefCount) IncRef() {
n := atomic.AddInt32(&c.ref, 1)
tracebackEvent(c, int(n), incRefEvent)
} | go | func (c *RefCount) IncRef() {
n := atomic.AddInt32(&c.ref, 1)
tracebackEvent(c, int(n), incRefEvent)
} | [
"func",
"(",
"c",
"*",
"RefCount",
")",
"IncRef",
"(",
")",
"{",
"n",
":=",
"atomic",
".",
"AddInt32",
"(",
"&",
"c",
".",
"ref",
",",
"1",
")",
"\n",
"tracebackEvent",
"(",
"c",
",",
"int",
"(",
"n",
")",
",",
"incRefEvent",
")",
"\n",
"}"
] | // IncRef increments the reference count to this entity. | [
"IncRef",
"increments",
"the",
"reference",
"count",
"to",
"this",
"entity",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/checked/ref.go#L42-L45 |
124,909 | m3db/m3x | checked/ref.go | DecRef | func (c *RefCount) DecRef() {
n := atomic.AddInt32(&c.ref, -1)
tracebackEvent(c, int(n), decRefEvent)
if n < 0 {
err := fmt.Errorf("negative ref count, ref=%d", n)
panicRef(c, err)
}
} | go | func (c *RefCount) DecRef() {
n := atomic.AddInt32(&c.ref, -1)
tracebackEvent(c, int(n), decRefEvent)
if n < 0 {
err := fmt.Errorf("negative ref count, ref=%d", n)
panicRef(c, err)
}
} | [
"func",
"(",
"c",
"*",
"RefCount",
")",
"DecRef",
"(",
")",
"{",
"n",
":=",
"atomic",
".",
"AddInt32",
"(",
"&",
"c",
".",
"ref",
",",
"-",
"1",
")",
"\n",
"tracebackEvent",
"(",
"c",
",",
"int",
"(",
"n",
")",
",",
"decRefEvent",
")",
"\n\n",
... | // DecRef decrements the reference count to this entity. | [
"DecRef",
"decrements",
"the",
"reference",
"count",
"to",
"this",
"entity",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/checked/ref.go#L48-L56 |
124,910 | m3db/m3x | checked/ref.go | Finalize | func (c *RefCount) Finalize() {
n := c.NumRef()
tracebackEvent(c, n, finalizeEvent)
if n != 0 {
err := fmt.Errorf("finalize before zero ref count, ref=%d", n)
panicRef(c, err)
}
if f := c.Finalizer(); f != nil {
f.Finalize()
}
} | go | func (c *RefCount) Finalize() {
n := c.NumRef()
tracebackEvent(c, n, finalizeEvent)
if n != 0 {
err := fmt.Errorf("finalize before zero ref count, ref=%d", n)
panicRef(c, err)
}
if f := c.Finalizer(); f != nil {
f.Finalize()
}
} | [
"func",
"(",
"c",
"*",
"RefCount",
")",
"Finalize",
"(",
")",
"{",
"n",
":=",
"c",
".",
"NumRef",
"(",
")",
"\n",
"tracebackEvent",
"(",
"c",
",",
"n",
",",
"finalizeEvent",
")",
"\n\n",
"if",
"n",
"!=",
"0",
"{",
"err",
":=",
"fmt",
".",
"Erro... | // Finalize will call the finalizer if any, ref count must be zero. | [
"Finalize",
"will",
"call",
"the",
"finalizer",
"if",
"any",
"ref",
"count",
"must",
"be",
"zero",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/checked/ref.go#L69-L81 |
124,911 | m3db/m3x | checked/ref.go | Finalizer | func (c *RefCount) Finalizer() resource.Finalizer {
finalizerPtr := (*resource.Finalizer)(atomic.LoadPointer(&c.finalizer))
if finalizerPtr == nil {
return nil
}
return *finalizerPtr
} | go | func (c *RefCount) Finalizer() resource.Finalizer {
finalizerPtr := (*resource.Finalizer)(atomic.LoadPointer(&c.finalizer))
if finalizerPtr == nil {
return nil
}
return *finalizerPtr
} | [
"func",
"(",
"c",
"*",
"RefCount",
")",
"Finalizer",
"(",
")",
"resource",
".",
"Finalizer",
"{",
"finalizerPtr",
":=",
"(",
"*",
"resource",
".",
"Finalizer",
")",
"(",
"atomic",
".",
"LoadPointer",
"(",
"&",
"c",
".",
"finalizer",
")",
")",
"\n",
"... | // Finalizer returns the finalizer if any or nil otherwise. | [
"Finalizer",
"returns",
"the",
"finalizer",
"if",
"any",
"or",
"nil",
"otherwise",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/checked/ref.go#L84-L90 |
124,912 | m3db/m3x | checked/ref.go | SetFinalizer | func (c *RefCount) SetFinalizer(f resource.Finalizer) {
atomic.StorePointer(&c.finalizer, unsafe.Pointer(&f))
} | go | func (c *RefCount) SetFinalizer(f resource.Finalizer) {
atomic.StorePointer(&c.finalizer, unsafe.Pointer(&f))
} | [
"func",
"(",
"c",
"*",
"RefCount",
")",
"SetFinalizer",
"(",
"f",
"resource",
".",
"Finalizer",
")",
"{",
"atomic",
".",
"StorePointer",
"(",
"&",
"c",
".",
"finalizer",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"f",
")",
")",
"\n",
"}"
] | // SetFinalizer sets the finalizer. | [
"SetFinalizer",
"sets",
"the",
"finalizer",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/checked/ref.go#L93-L95 |
124,913 | m3db/m3x | checked/ref.go | IncReads | func (c *RefCount) IncReads() {
tracebackEvent(c, c.NumRef(), incReadsEvent)
n := atomic.AddInt32(&c.reads, 1)
if ref := c.NumRef(); n > 0 && ref < 1 {
err := fmt.Errorf("read after free: reads=%d, ref=%d", n, ref)
panicRef(c, err)
}
} | go | func (c *RefCount) IncReads() {
tracebackEvent(c, c.NumRef(), incReadsEvent)
n := atomic.AddInt32(&c.reads, 1)
if ref := c.NumRef(); n > 0 && ref < 1 {
err := fmt.Errorf("read after free: reads=%d, ref=%d", n, ref)
panicRef(c, err)
}
} | [
"func",
"(",
"c",
"*",
"RefCount",
")",
"IncReads",
"(",
")",
"{",
"tracebackEvent",
"(",
"c",
",",
"c",
".",
"NumRef",
"(",
")",
",",
"incReadsEvent",
")",
"\n",
"n",
":=",
"atomic",
".",
"AddInt32",
"(",
"&",
"c",
".",
"reads",
",",
"1",
")",
... | // IncReads increments the reads count to this entity. | [
"IncReads",
"increments",
"the",
"reads",
"count",
"to",
"this",
"entity",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/checked/ref.go#L98-L106 |
124,914 | m3db/m3x | checked/ref.go | DecReads | func (c *RefCount) DecReads() {
tracebackEvent(c, c.NumRef(), decReadsEvent)
n := atomic.AddInt32(&c.reads, -1)
if ref := c.NumRef(); ref < 1 {
err := fmt.Errorf("read finish after free: reads=%d, ref=%d", n, ref)
panicRef(c, err)
}
} | go | func (c *RefCount) DecReads() {
tracebackEvent(c, c.NumRef(), decReadsEvent)
n := atomic.AddInt32(&c.reads, -1)
if ref := c.NumRef(); ref < 1 {
err := fmt.Errorf("read finish after free: reads=%d, ref=%d", n, ref)
panicRef(c, err)
}
} | [
"func",
"(",
"c",
"*",
"RefCount",
")",
"DecReads",
"(",
")",
"{",
"tracebackEvent",
"(",
"c",
",",
"c",
".",
"NumRef",
"(",
")",
",",
"decReadsEvent",
")",
"\n",
"n",
":=",
"atomic",
".",
"AddInt32",
"(",
"&",
"c",
".",
"reads",
",",
"-",
"1",
... | // DecReads decrements the reads count to this entity. | [
"DecReads",
"decrements",
"the",
"reads",
"count",
"to",
"this",
"entity",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/checked/ref.go#L109-L117 |
124,915 | m3db/m3x | checked/ref.go | IncWrites | func (c *RefCount) IncWrites() {
tracebackEvent(c, c.NumRef(), incWritesEvent)
n := atomic.AddInt32(&c.writes, 1)
ref := c.NumRef()
if n > 0 && ref < 1 {
err := fmt.Errorf("write after free: writes=%d, ref=%d", n, ref)
panicRef(c, err)
}
if n > 1 {
err := fmt.Errorf("double write: writes=%d, ref=%d", n, r... | go | func (c *RefCount) IncWrites() {
tracebackEvent(c, c.NumRef(), incWritesEvent)
n := atomic.AddInt32(&c.writes, 1)
ref := c.NumRef()
if n > 0 && ref < 1 {
err := fmt.Errorf("write after free: writes=%d, ref=%d", n, ref)
panicRef(c, err)
}
if n > 1 {
err := fmt.Errorf("double write: writes=%d, ref=%d", n, r... | [
"func",
"(",
"c",
"*",
"RefCount",
")",
"IncWrites",
"(",
")",
"{",
"tracebackEvent",
"(",
"c",
",",
"c",
".",
"NumRef",
"(",
")",
",",
"incWritesEvent",
")",
"\n",
"n",
":=",
"atomic",
".",
"AddInt32",
"(",
"&",
"c",
".",
"writes",
",",
"1",
")"... | // IncWrites increments the writes count to this entity. | [
"IncWrites",
"increments",
"the",
"writes",
"count",
"to",
"this",
"entity",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/checked/ref.go#L125-L139 |
124,916 | m3db/m3x | checked/ref.go | DecWrites | func (c *RefCount) DecWrites() {
tracebackEvent(c, c.NumRef(), decWritesEvent)
n := atomic.AddInt32(&c.writes, -1)
if ref := c.NumRef(); ref < 1 {
err := fmt.Errorf("write finish after free: writes=%d, ref=%d", n, ref)
panicRef(c, err)
}
} | go | func (c *RefCount) DecWrites() {
tracebackEvent(c, c.NumRef(), decWritesEvent)
n := atomic.AddInt32(&c.writes, -1)
if ref := c.NumRef(); ref < 1 {
err := fmt.Errorf("write finish after free: writes=%d, ref=%d", n, ref)
panicRef(c, err)
}
} | [
"func",
"(",
"c",
"*",
"RefCount",
")",
"DecWrites",
"(",
")",
"{",
"tracebackEvent",
"(",
"c",
",",
"c",
".",
"NumRef",
"(",
")",
",",
"decWritesEvent",
")",
"\n",
"n",
":=",
"atomic",
".",
"AddInt32",
"(",
"&",
"c",
".",
"writes",
",",
"-",
"1"... | // DecWrites decrements the writes count to this entity. | [
"DecWrites",
"decrements",
"the",
"writes",
"count",
"to",
"this",
"entity",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/checked/ref.go#L142-L150 |
124,917 | m3db/m3x | checked/ref.go | TrackObject | func (c *RefCount) TrackObject(v interface{}) {
if !leakDetectionFlag {
return
}
var size int
switch v := reflect.ValueOf(v); v.Kind() {
case reflect.Ptr:
size = int(v.Type().Elem().Size())
case reflect.Array, reflect.Slice, reflect.Chan:
size = int(v.Type().Elem().Size()) * v.Cap()
case reflect.String:
... | go | func (c *RefCount) TrackObject(v interface{}) {
if !leakDetectionFlag {
return
}
var size int
switch v := reflect.ValueOf(v); v.Kind() {
case reflect.Ptr:
size = int(v.Type().Elem().Size())
case reflect.Array, reflect.Slice, reflect.Chan:
size = int(v.Type().Elem().Size()) * v.Cap()
case reflect.String:
... | [
"func",
"(",
"c",
"*",
"RefCount",
")",
"TrackObject",
"(",
"v",
"interface",
"{",
"}",
")",
"{",
"if",
"!",
"leakDetectionFlag",
"{",
"return",
"\n",
"}",
"\n\n",
"var",
"size",
"int",
"\n\n",
"switch",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"v"... | // TrackObject sets up the initial internal state of the Ref for
// leak detection. | [
"TrackObject",
"sets",
"up",
"the",
"initial",
"internal",
"state",
"of",
"the",
"Ref",
"for",
"leak",
"detection",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/checked/ref.go#L159-L189 |
124,918 | m3db/m3x | config/listenaddress/listenaddress.go | Resolve | func (c Configuration) Resolve() (string, error) {
listenAddrType := c.ListenAddressType
var listenAddress string
switch listenAddrType {
case ConfigResolver:
if c.Value == nil {
err := fmt.Errorf("missing listen address value using: resolver=%s",
string(listenAddrType))
return "", err
}
listenAddr... | go | func (c Configuration) Resolve() (string, error) {
listenAddrType := c.ListenAddressType
var listenAddress string
switch listenAddrType {
case ConfigResolver:
if c.Value == nil {
err := fmt.Errorf("missing listen address value using: resolver=%s",
string(listenAddrType))
return "", err
}
listenAddr... | [
"func",
"(",
"c",
"Configuration",
")",
"Resolve",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"listenAddrType",
":=",
"c",
".",
"ListenAddressType",
"\n\n",
"var",
"listenAddress",
"string",
"\n",
"switch",
"listenAddrType",
"{",
"case",
"ConfigResolver"... | // Resolve returns the resolved listen address given the configuration. | [
"Resolve",
"returns",
"the",
"resolved",
"listen",
"address",
"given",
"the",
"configuration",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/config/listenaddress/listenaddress.go#L62-L103 |
124,919 | m3db/m3x | log/config.go | BuildLogger | func (cfg Configuration) BuildLogger() (Logger, error) {
writer := io.Writer(os.Stdout)
if cfg.File != "" {
fd, err := os.OpenFile(cfg.File, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
return nil, err
}
writer = io.MultiWriter(writer, fd)
}
logger := NewLogger(writer)
if len(cfg.Level... | go | func (cfg Configuration) BuildLogger() (Logger, error) {
writer := io.Writer(os.Stdout)
if cfg.File != "" {
fd, err := os.OpenFile(cfg.File, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
return nil, err
}
writer = io.MultiWriter(writer, fd)
}
logger := NewLogger(writer)
if len(cfg.Level... | [
"func",
"(",
"cfg",
"Configuration",
")",
"BuildLogger",
"(",
")",
"(",
"Logger",
",",
"error",
")",
"{",
"writer",
":=",
"io",
".",
"Writer",
"(",
"os",
".",
"Stdout",
")",
"\n\n",
"if",
"cfg",
".",
"File",
"!=",
"\"",
"\"",
"{",
"fd",
",",
"err... | // BuildLogger builds a new Logger based on the configuration. | [
"BuildLogger",
"builds",
"a",
"new",
"Logger",
"based",
"on",
"the",
"configuration",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/log/config.go#L36-L68 |
124,920 | m3db/m3x | watch/value.go | NewValue | func NewValue(
opts Options,
) Value {
v := &value{
opts: opts,
log: opts.InstrumentOptions().Logger(),
newUpdatableFn: opts.NewUpdatableFn(),
getUpdateFn: opts.GetUpdateFn(),
processFn: opts.ProcessFn(),
}
v.processWithLockFn = v.processWithLock
return v
} | go | func NewValue(
opts Options,
) Value {
v := &value{
opts: opts,
log: opts.InstrumentOptions().Logger(),
newUpdatableFn: opts.NewUpdatableFn(),
getUpdateFn: opts.GetUpdateFn(),
processFn: opts.ProcessFn(),
}
v.processWithLockFn = v.processWithLock
return v
} | [
"func",
"NewValue",
"(",
"opts",
"Options",
",",
")",
"Value",
"{",
"v",
":=",
"&",
"value",
"{",
"opts",
":",
"opts",
",",
"log",
":",
"opts",
".",
"InstrumentOptions",
"(",
")",
".",
"Logger",
"(",
")",
",",
"newUpdatableFn",
":",
"opts",
".",
"N... | // NewValue creates a new value. | [
"NewValue",
"creates",
"a",
"new",
"value",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/watch/value.go#L80-L92 |
124,921 | m3db/m3x | ident/tag_matcher.go | NewTagMatcher | func NewTagMatcher(name string, value string) TagMatcher {
return &tagMatcher{tag: StringTag(name, value)}
} | go | func NewTagMatcher(name string, value string) TagMatcher {
return &tagMatcher{tag: StringTag(name, value)}
} | [
"func",
"NewTagMatcher",
"(",
"name",
"string",
",",
"value",
"string",
")",
"TagMatcher",
"{",
"return",
"&",
"tagMatcher",
"{",
"tag",
":",
"StringTag",
"(",
"name",
",",
"value",
")",
"}",
"\n",
"}"
] | // NewTagMatcher returns a new TagMatcher | [
"NewTagMatcher",
"returns",
"a",
"new",
"TagMatcher"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/ident/tag_matcher.go#L35-L37 |
124,922 | m3db/m3x | sampler/sampler.go | NewSampler | func NewSampler(sampleRate float64) (*Sampler, error) {
if sampleRate <= 0.0 || sampleRate >= 1.0 {
return nil, fmt.Errorf("invalid sample rate %f", sampleRate)
}
return &Sampler{numTried: atomic.NewInt32(0), sampleEvery: int32(1.0 / sampleRate)}, nil
} | go | func NewSampler(sampleRate float64) (*Sampler, error) {
if sampleRate <= 0.0 || sampleRate >= 1.0 {
return nil, fmt.Errorf("invalid sample rate %f", sampleRate)
}
return &Sampler{numTried: atomic.NewInt32(0), sampleEvery: int32(1.0 / sampleRate)}, nil
} | [
"func",
"NewSampler",
"(",
"sampleRate",
"float64",
")",
"(",
"*",
"Sampler",
",",
"error",
")",
"{",
"if",
"sampleRate",
"<=",
"0.0",
"||",
"sampleRate",
">=",
"1.0",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"sampleRate",... | // NewSampler creates a new sampler with a sample rate. | [
"NewSampler",
"creates",
"a",
"new",
"sampler",
"with",
"a",
"sample",
"rate",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/sampler/sampler.go#L37-L42 |
124,923 | m3db/m3x | pool/object.go | NewObjectPool | func NewObjectPool(opts ObjectPoolOptions) ObjectPool {
if opts == nil {
opts = NewObjectPoolOptions()
}
m := opts.InstrumentOptions().MetricsScope()
p := &objectPool{
opts: opts,
values: make(chan interface{}, opts.Size()),
size: opts.Size(),
refillLowWatermark: int(math.Ceil(
opts.RefillLowWate... | go | func NewObjectPool(opts ObjectPoolOptions) ObjectPool {
if opts == nil {
opts = NewObjectPoolOptions()
}
m := opts.InstrumentOptions().MetricsScope()
p := &objectPool{
opts: opts,
values: make(chan interface{}, opts.Size()),
size: opts.Size(),
refillLowWatermark: int(math.Ceil(
opts.RefillLowWate... | [
"func",
"NewObjectPool",
"(",
"opts",
"ObjectPoolOptions",
")",
"ObjectPool",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"NewObjectPoolOptions",
"(",
")",
"\n",
"}",
"\n\n",
"m",
":=",
"opts",
".",
"InstrumentOptions",
"(",
")",
".",
"MetricsScope",
... | // NewObjectPool creates a new pool | [
"NewObjectPool",
"creates",
"a",
"new",
"pool"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/pool/object.go#L63-L89 |
124,924 | m3db/m3x | time/range.go | Equal | func (r Range) Equal(other Range) bool {
return r.Start.Equal(other.Start) && r.End.Equal(other.End)
} | go | func (r Range) Equal(other Range) bool {
return r.Start.Equal(other.Start) && r.End.Equal(other.End)
} | [
"func",
"(",
"r",
"Range",
")",
"Equal",
"(",
"other",
"Range",
")",
"bool",
"{",
"return",
"r",
".",
"Start",
".",
"Equal",
"(",
"other",
".",
"Start",
")",
"&&",
"r",
".",
"End",
".",
"Equal",
"(",
"other",
".",
"End",
")",
"\n",
"}"
] | // Equal returns whether two time ranges are equal. | [
"Equal",
"returns",
"whether",
"two",
"time",
"ranges",
"are",
"equal",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/range.go#L40-L42 |
124,925 | m3db/m3x | time/range.go | Before | func (r Range) Before(other Range) bool {
return !r.End.After(other.Start)
} | go | func (r Range) Before(other Range) bool {
return !r.End.After(other.Start)
} | [
"func",
"(",
"r",
"Range",
")",
"Before",
"(",
"other",
"Range",
")",
"bool",
"{",
"return",
"!",
"r",
".",
"End",
".",
"After",
"(",
"other",
".",
"Start",
")",
"\n",
"}"
] | // Before determines whether r is before other. | [
"Before",
"determines",
"whether",
"r",
"is",
"before",
"other",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/range.go#L45-L47 |
124,926 | m3db/m3x | time/range.go | Contains | func (r Range) Contains(other Range) bool {
return !r.Start.After(other.Start) && !r.End.Before(other.End)
} | go | func (r Range) Contains(other Range) bool {
return !r.Start.After(other.Start) && !r.End.Before(other.End)
} | [
"func",
"(",
"r",
"Range",
")",
"Contains",
"(",
"other",
"Range",
")",
"bool",
"{",
"return",
"!",
"r",
".",
"Start",
".",
"After",
"(",
"other",
".",
"Start",
")",
"&&",
"!",
"r",
".",
"End",
".",
"Before",
"(",
"other",
".",
"End",
")",
"\n"... | // Contains determines whether r contains other. | [
"Contains",
"determines",
"whether",
"r",
"contains",
"other",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/range.go#L55-L57 |
124,927 | m3db/m3x | time/range.go | Duration | func (r Range) Duration() time.Duration {
return r.End.Sub(r.Start)
} | go | func (r Range) Duration() time.Duration {
return r.End.Sub(r.Start)
} | [
"func",
"(",
"r",
"Range",
")",
"Duration",
"(",
")",
"time",
".",
"Duration",
"{",
"return",
"r",
".",
"End",
".",
"Sub",
"(",
"r",
".",
"Start",
")",
"\n",
"}"
] | // Duration returns the duration of the range. | [
"Duration",
"returns",
"the",
"duration",
"of",
"the",
"range",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/range.go#L65-L67 |
124,928 | m3db/m3x | time/range.go | Intersect | func (r Range) Intersect(other Range) (Range, bool) {
if !r.Overlaps(other) {
return Range{}, false
}
newRange := r
if newRange.Start.Before(other.Start) {
newRange.Start = other.Start
}
if newRange.End.After(other.End) {
newRange.End = other.End
}
return newRange, true
} | go | func (r Range) Intersect(other Range) (Range, bool) {
if !r.Overlaps(other) {
return Range{}, false
}
newRange := r
if newRange.Start.Before(other.Start) {
newRange.Start = other.Start
}
if newRange.End.After(other.End) {
newRange.End = other.End
}
return newRange, true
} | [
"func",
"(",
"r",
"Range",
")",
"Intersect",
"(",
"other",
"Range",
")",
"(",
"Range",
",",
"bool",
")",
"{",
"if",
"!",
"r",
".",
"Overlaps",
"(",
"other",
")",
"{",
"return",
"Range",
"{",
"}",
",",
"false",
"\n",
"}",
"\n",
"newRange",
":=",
... | // Intersect calculates the intersection of the receiver range against the
// provided argument range iff there is an overlap between the two. It also
// returns a bool indicating if there was a valid intersection. | [
"Intersect",
"calculates",
"the",
"intersection",
"of",
"the",
"receiver",
"range",
"against",
"the",
"provided",
"argument",
"range",
"iff",
"there",
"is",
"an",
"overlap",
"between",
"the",
"two",
".",
"It",
"also",
"returns",
"a",
"bool",
"indicating",
"if"... | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/range.go#L72-L84 |
124,929 | m3db/m3x | time/range.go | Since | func (r Range) Since(t time.Time) Range {
if t.Before(r.Start) {
return r
}
if t.After(r.End) {
return Range{}
}
return Range{Start: t, End: r.End}
} | go | func (r Range) Since(t time.Time) Range {
if t.Before(r.Start) {
return r
}
if t.After(r.End) {
return Range{}
}
return Range{Start: t, End: r.End}
} | [
"func",
"(",
"r",
"Range",
")",
"Since",
"(",
"t",
"time",
".",
"Time",
")",
"Range",
"{",
"if",
"t",
".",
"Before",
"(",
"r",
".",
"Start",
")",
"{",
"return",
"r",
"\n",
"}",
"\n",
"if",
"t",
".",
"After",
"(",
"r",
".",
"End",
")",
"{",
... | // Since returns the time range since a given point in time. | [
"Since",
"returns",
"the",
"time",
"range",
"since",
"a",
"given",
"point",
"in",
"time",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/range.go#L87-L95 |
124,930 | m3db/m3x | time/range.go | Merge | func (r Range) Merge(other Range) Range {
start := MinTime(r.Start, other.Start)
end := MaxTime(r.End, other.End)
return Range{Start: start, End: end}
} | go | func (r Range) Merge(other Range) Range {
start := MinTime(r.Start, other.Start)
end := MaxTime(r.End, other.End)
return Range{Start: start, End: end}
} | [
"func",
"(",
"r",
"Range",
")",
"Merge",
"(",
"other",
"Range",
")",
"Range",
"{",
"start",
":=",
"MinTime",
"(",
"r",
".",
"Start",
",",
"other",
".",
"Start",
")",
"\n",
"end",
":=",
"MaxTime",
"(",
"r",
".",
"End",
",",
"other",
".",
"End",
... | // Merge merges the two ranges if they overlap. Otherwise,
// the gap between them is included. | [
"Merge",
"merges",
"the",
"two",
"ranges",
"if",
"they",
"overlap",
".",
"Otherwise",
"the",
"gap",
"between",
"them",
"is",
"included",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/range.go#L99-L103 |
124,931 | m3db/m3x | time/range.go | Subtract | func (r Range) Subtract(other Range) []Range {
if !r.Overlaps(other) {
return []Range{r}
}
if other.Contains(r) {
return nil
}
var res []Range
left := Range{r.Start, other.Start}
right := Range{other.End, r.End}
if r.Contains(other) {
if !left.IsEmpty() {
res = append(res, left)
}
if !right.IsEmpty... | go | func (r Range) Subtract(other Range) []Range {
if !r.Overlaps(other) {
return []Range{r}
}
if other.Contains(r) {
return nil
}
var res []Range
left := Range{r.Start, other.Start}
right := Range{other.End, r.End}
if r.Contains(other) {
if !left.IsEmpty() {
res = append(res, left)
}
if !right.IsEmpty... | [
"func",
"(",
"r",
"Range",
")",
"Subtract",
"(",
"other",
"Range",
")",
"[",
"]",
"Range",
"{",
"if",
"!",
"r",
".",
"Overlaps",
"(",
"other",
")",
"{",
"return",
"[",
"]",
"Range",
"{",
"r",
"}",
"\n",
"}",
"\n",
"if",
"other",
".",
"Contains"... | // Subtract removes the intersection between r and other
// from r, possibly splitting r into two smaller ranges. | [
"Subtract",
"removes",
"the",
"intersection",
"between",
"r",
"and",
"other",
"from",
"r",
"possibly",
"splitting",
"r",
"into",
"two",
"smaller",
"ranges",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/range.go#L107-L136 |
124,932 | m3db/m3x | instrument/invariant.go | EmitAndLogInvariantViolation | func EmitAndLogInvariantViolation(opts Options, f func(l log.Logger)) {
EmitInvariantViolation(opts)
logger := opts.Logger().WithFields(
log.NewField(InvariantViolatedLogFieldName, InvariantViolatedLogFieldValue))
f(logger)
panicIfEnvSet()
} | go | func EmitAndLogInvariantViolation(opts Options, f func(l log.Logger)) {
EmitInvariantViolation(opts)
logger := opts.Logger().WithFields(
log.NewField(InvariantViolatedLogFieldName, InvariantViolatedLogFieldValue))
f(logger)
panicIfEnvSet()
} | [
"func",
"EmitAndLogInvariantViolation",
"(",
"opts",
"Options",
",",
"f",
"func",
"(",
"l",
"log",
".",
"Logger",
")",
")",
"{",
"EmitInvariantViolation",
"(",
"opts",
")",
"\n\n",
"logger",
":=",
"opts",
".",
"Logger",
"(",
")",
".",
"WithFields",
"(",
... | // EmitAndLogInvariantViolation calls EmitInvariantViolation and then calls the provided function
// with a supplied logger that is pre-configured with an invariant violated field. Optionally panics
// if the ShouldPanicEnvironmentVariableName is set to "true". | [
"EmitAndLogInvariantViolation",
"calls",
"EmitInvariantViolation",
"and",
"then",
"calls",
"the",
"provided",
"function",
"with",
"a",
"supplied",
"logger",
"that",
"is",
"pre",
"-",
"configured",
"with",
"an",
"invariant",
"violated",
"field",
".",
"Optionally",
"p... | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/instrument/invariant.go#L71-L79 |
124,933 | m3db/m3x | instrument/invariant.go | InvariantErrorf | func InvariantErrorf(format string, a ...interface{}) error {
var (
invariantFormat = InvariantViolatedMetricName + ": " + format
err = fmt.Errorf(invariantFormat, a...)
)
panicIfEnvSetWithMessage(err.Error())
return err
} | go | func InvariantErrorf(format string, a ...interface{}) error {
var (
invariantFormat = InvariantViolatedMetricName + ": " + format
err = fmt.Errorf(invariantFormat, a...)
)
panicIfEnvSetWithMessage(err.Error())
return err
} | [
"func",
"InvariantErrorf",
"(",
"format",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"(",
"invariantFormat",
"=",
"InvariantViolatedMetricName",
"+",
"\"",
"\"",
"+",
"format",
"\n",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
... | // InvariantErrorf constructs a new error, prefixed with a string indicating that an invariant
// violation occurred. Optionally panics if the ShouldPanicEnvironmentVariableName is set to "true". | [
"InvariantErrorf",
"constructs",
"a",
"new",
"error",
"prefixed",
"with",
"a",
"string",
"indicating",
"that",
"an",
"invariant",
"violation",
"occurred",
".",
"Optionally",
"panics",
"if",
"the",
"ShouldPanicEnvironmentVariableName",
"is",
"set",
"to",
"true",
"."
... | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/instrument/invariant.go#L83-L91 |
124,934 | m3db/m3x | time/time.go | ToNormalizedTime | func ToNormalizedTime(t time.Time, u time.Duration) int64 {
return t.UnixNano() / u.Nanoseconds()
} | go | func ToNormalizedTime(t time.Time, u time.Duration) int64 {
return t.UnixNano() / u.Nanoseconds()
} | [
"func",
"ToNormalizedTime",
"(",
"t",
"time",
".",
"Time",
",",
"u",
"time",
".",
"Duration",
")",
"int64",
"{",
"return",
"t",
".",
"UnixNano",
"(",
")",
"/",
"u",
".",
"Nanoseconds",
"(",
")",
"\n",
"}"
] | // ToNormalizedTime returns the normalized units of time given a time unit. | [
"ToNormalizedTime",
"returns",
"the",
"normalized",
"units",
"of",
"time",
"given",
"a",
"time",
"unit",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/time.go#L31-L33 |
124,935 | m3db/m3x | time/time.go | FromNormalizedTime | func FromNormalizedTime(nt int64, u time.Duration) time.Time {
return time.Unix(0, int64(u/time.Nanosecond)*nt)
} | go | func FromNormalizedTime(nt int64, u time.Duration) time.Time {
return time.Unix(0, int64(u/time.Nanosecond)*nt)
} | [
"func",
"FromNormalizedTime",
"(",
"nt",
"int64",
",",
"u",
"time",
".",
"Duration",
")",
"time",
".",
"Time",
"{",
"return",
"time",
".",
"Unix",
"(",
"0",
",",
"int64",
"(",
"u",
"/",
"time",
".",
"Nanosecond",
")",
"*",
"nt",
")",
"\n",
"}"
] | // FromNormalizedTime returns the time given the normalized time units and the time unit. | [
"FromNormalizedTime",
"returns",
"the",
"time",
"given",
"the",
"normalized",
"time",
"units",
"and",
"the",
"time",
"unit",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/time.go#L36-L38 |
124,936 | m3db/m3x | time/time.go | ToNormalizedDuration | func ToNormalizedDuration(d time.Duration, u time.Duration) int64 {
return int64(d / u)
} | go | func ToNormalizedDuration(d time.Duration, u time.Duration) int64 {
return int64(d / u)
} | [
"func",
"ToNormalizedDuration",
"(",
"d",
"time",
".",
"Duration",
",",
"u",
"time",
".",
"Duration",
")",
"int64",
"{",
"return",
"int64",
"(",
"d",
"/",
"u",
")",
"\n",
"}"
] | // ToNormalizedDuration returns the normalized units of duration given a time unit. | [
"ToNormalizedDuration",
"returns",
"the",
"normalized",
"units",
"of",
"duration",
"given",
"a",
"time",
"unit",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/time.go#L41-L43 |
124,937 | m3db/m3x | time/time.go | FromNormalizedDuration | func FromNormalizedDuration(nd int64, u time.Duration) time.Duration {
return time.Duration(nd) * u
} | go | func FromNormalizedDuration(nd int64, u time.Duration) time.Duration {
return time.Duration(nd) * u
} | [
"func",
"FromNormalizedDuration",
"(",
"nd",
"int64",
",",
"u",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Duration",
"(",
"nd",
")",
"*",
"u",
"\n",
"}"
] | // FromNormalizedDuration returns the duration given the normalized time duration and a time unit. | [
"FromNormalizedDuration",
"returns",
"the",
"duration",
"given",
"the",
"normalized",
"time",
"duration",
"and",
"a",
"time",
"unit",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/time.go#L46-L48 |
124,938 | m3db/m3x | time/time.go | Ceil | func Ceil(t time.Time, d time.Duration) time.Time {
res := t.Truncate(d)
if res.Before(t) {
res = res.Add(d)
}
return res
} | go | func Ceil(t time.Time, d time.Duration) time.Time {
res := t.Truncate(d)
if res.Before(t) {
res = res.Add(d)
}
return res
} | [
"func",
"Ceil",
"(",
"t",
"time",
".",
"Time",
",",
"d",
"time",
".",
"Duration",
")",
"time",
".",
"Time",
"{",
"res",
":=",
"t",
".",
"Truncate",
"(",
"d",
")",
"\n",
"if",
"res",
".",
"Before",
"(",
"t",
")",
"{",
"res",
"=",
"res",
".",
... | // Ceil returns the result of rounding t up to a multiple of d since
// the zero time. | [
"Ceil",
"returns",
"the",
"result",
"of",
"rounding",
"t",
"up",
"to",
"a",
"multiple",
"of",
"d",
"since",
"the",
"zero",
"time",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/time.go#L72-L78 |
124,939 | m3db/m3x | time/time.go | MinTime | func MinTime(t1, t2 time.Time) time.Time {
if t1.Before(t2) {
return t1
}
return t2
} | go | func MinTime(t1, t2 time.Time) time.Time {
if t1.Before(t2) {
return t1
}
return t2
} | [
"func",
"MinTime",
"(",
"t1",
",",
"t2",
"time",
".",
"Time",
")",
"time",
".",
"Time",
"{",
"if",
"t1",
".",
"Before",
"(",
"t2",
")",
"{",
"return",
"t1",
"\n",
"}",
"\n",
"return",
"t2",
"\n",
"}"
] | // MinTime returns the earlier one of t1 and t2. | [
"MinTime",
"returns",
"the",
"earlier",
"one",
"of",
"t1",
"and",
"t2",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/time.go#L81-L86 |
124,940 | m3db/m3x | time/time.go | MaxTime | func MaxTime(t1, t2 time.Time) time.Time {
if t1.After(t2) {
return t1
}
return t2
} | go | func MaxTime(t1, t2 time.Time) time.Time {
if t1.After(t2) {
return t1
}
return t2
} | [
"func",
"MaxTime",
"(",
"t1",
",",
"t2",
"time",
".",
"Time",
")",
"time",
".",
"Time",
"{",
"if",
"t1",
".",
"After",
"(",
"t2",
")",
"{",
"return",
"t1",
"\n",
"}",
"\n",
"return",
"t2",
"\n",
"}"
] | // MaxTime returns the later one of t1 and t2. | [
"MaxTime",
"returns",
"the",
"later",
"one",
"of",
"t1",
"and",
"t2",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/time.go#L89-L94 |
124,941 | m3db/m3x | pool/bucketized.go | NewBucketizedObjectPool | func NewBucketizedObjectPool(sizes []Bucket, opts ObjectPoolOptions) BucketizedObjectPool {
if opts == nil {
opts = NewObjectPoolOptions()
}
sizesAsc := make([]Bucket, len(sizes))
copy(sizesAsc, sizes)
sort.Sort(BucketByCapacity(sizesAsc))
var maxBucketCapacity int
if len(sizesAsc) != 0 {
maxBucketCapacity... | go | func NewBucketizedObjectPool(sizes []Bucket, opts ObjectPoolOptions) BucketizedObjectPool {
if opts == nil {
opts = NewObjectPoolOptions()
}
sizesAsc := make([]Bucket, len(sizes))
copy(sizesAsc, sizes)
sort.Sort(BucketByCapacity(sizesAsc))
var maxBucketCapacity int
if len(sizesAsc) != 0 {
maxBucketCapacity... | [
"func",
"NewBucketizedObjectPool",
"(",
"sizes",
"[",
"]",
"Bucket",
",",
"opts",
"ObjectPoolOptions",
")",
"BucketizedObjectPool",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"NewObjectPoolOptions",
"(",
")",
"\n",
"}",
"\n\n",
"sizesAsc",
":=",
"make",... | // NewBucketizedObjectPool creates a bucketized object pool | [
"NewBucketizedObjectPool",
"creates",
"a",
"bucketized",
"object",
"pool"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/pool/bucketized.go#L45-L67 |
124,942 | m3db/m3x | config/config.go | LoadFile | func LoadFile(config interface{}, file string, opts Options) error {
return LoadFiles(config, []string{file}, opts)
} | go | func LoadFile(config interface{}, file string, opts Options) error {
return LoadFiles(config, []string{file}, opts)
} | [
"func",
"LoadFile",
"(",
"config",
"interface",
"{",
"}",
",",
"file",
"string",
",",
"opts",
"Options",
")",
"error",
"{",
"return",
"LoadFiles",
"(",
"config",
",",
"[",
"]",
"string",
"{",
"file",
"}",
",",
"opts",
")",
"\n",
"}"
] | // LoadFile loads a config from a file. | [
"LoadFile",
"loads",
"a",
"config",
"from",
"a",
"file",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/config/config.go#L41-L43 |
124,943 | m3db/m3x | config/config.go | LoadFiles | func LoadFiles(config interface{}, files []string, opts Options) error {
if len(files) == 0 {
return errNoFilesToLoad
}
for _, name := range files {
data, err := ioutil.ReadFile(name)
if err != nil {
return err
}
unmarshal := yaml.UnmarshalStrict
if opts.DisableUnmarshalStrict {
unmarshal = yaml.Un... | go | func LoadFiles(config interface{}, files []string, opts Options) error {
if len(files) == 0 {
return errNoFilesToLoad
}
for _, name := range files {
data, err := ioutil.ReadFile(name)
if err != nil {
return err
}
unmarshal := yaml.UnmarshalStrict
if opts.DisableUnmarshalStrict {
unmarshal = yaml.Un... | [
"func",
"LoadFiles",
"(",
"config",
"interface",
"{",
"}",
",",
"files",
"[",
"]",
"string",
",",
"opts",
"Options",
")",
"error",
"{",
"if",
"len",
"(",
"files",
")",
"==",
"0",
"{",
"return",
"errNoFilesToLoad",
"\n",
"}",
"\n",
"for",
"_",
",",
... | // LoadFiles loads a config from list of files. If value for a property is
// present in multiple files, the value from the last file will be applied.
// Validation is done after merging all values. | [
"LoadFiles",
"loads",
"a",
"config",
"from",
"list",
"of",
"files",
".",
"If",
"value",
"for",
"a",
"property",
"is",
"present",
"in",
"multiple",
"files",
"the",
"value",
"from",
"the",
"last",
"file",
"will",
"be",
"applied",
".",
"Validation",
"is",
"... | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/config/config.go#L48-L69 |
124,944 | m3db/m3x | retry/retry.go | NewRetrier | func NewRetrier(opts Options) Retrier {
scope := opts.MetricsScope()
errorTags := struct {
retryable map[string]string
notRetryable map[string]string
}{
map[string]string{
"type": "retryable",
},
map[string]string{
"type": "not-retryable",
},
}
return &retrier{
initialBackoff: opts.InitialBa... | go | func NewRetrier(opts Options) Retrier {
scope := opts.MetricsScope()
errorTags := struct {
retryable map[string]string
notRetryable map[string]string
}{
map[string]string{
"type": "retryable",
},
map[string]string{
"type": "not-retryable",
},
}
return &retrier{
initialBackoff: opts.InitialBa... | [
"func",
"NewRetrier",
"(",
"opts",
"Options",
")",
"Retrier",
"{",
"scope",
":=",
"opts",
".",
"MetricsScope",
"(",
")",
"\n",
"errorTags",
":=",
"struct",
"{",
"retryable",
"map",
"[",
"string",
"]",
"string",
"\n",
"notRetryable",
"map",
"[",
"string",
... | // NewRetrier creates a new retrier. | [
"NewRetrier",
"creates",
"a",
"new",
"retrier",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/retry/retry.go#L62-L94 |
124,945 | m3db/m3x | retry/retry.go | BackoffNanos | func BackoffNanos(
retry int,
jitter bool,
backoffFactor float64,
initialBackoff time.Duration,
maxBackoff time.Duration,
rngFn RngFn,
) int64 {
backoff := initialBackoff.Nanoseconds()
if retry >= 1 {
backoffFloat64 := float64(backoff) * math.Pow(backoffFactor, float64(retry-1))
// math.Inf is also larger t... | go | func BackoffNanos(
retry int,
jitter bool,
backoffFactor float64,
initialBackoff time.Duration,
maxBackoff time.Duration,
rngFn RngFn,
) int64 {
backoff := initialBackoff.Nanoseconds()
if retry >= 1 {
backoffFloat64 := float64(backoff) * math.Pow(backoffFactor, float64(retry-1))
// math.Inf is also larger t... | [
"func",
"BackoffNanos",
"(",
"retry",
"int",
",",
"jitter",
"bool",
",",
"backoffFactor",
"float64",
",",
"initialBackoff",
"time",
".",
"Duration",
",",
"maxBackoff",
"time",
".",
"Duration",
",",
"rngFn",
"RngFn",
",",
")",
"int64",
"{",
"backoff",
":=",
... | // BackoffNanos calculates the backoff for a retry in nanoseconds. | [
"BackoffNanos",
"calculates",
"the",
"backoff",
"for",
"a",
"retry",
"in",
"nanoseconds",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/retry/retry.go#L164-L190 |
124,946 | m3db/m3x | time/range_iter.go | Next | func (it *RangeIter) Next() bool {
if it.ranges == nil {
return false
}
if it.cur == nil {
it.cur = it.ranges.Front()
} else {
it.cur = it.cur.Next()
}
return it.cur != nil
} | go | func (it *RangeIter) Next() bool {
if it.ranges == nil {
return false
}
if it.cur == nil {
it.cur = it.ranges.Front()
} else {
it.cur = it.cur.Next()
}
return it.cur != nil
} | [
"func",
"(",
"it",
"*",
"RangeIter",
")",
"Next",
"(",
")",
"bool",
"{",
"if",
"it",
".",
"ranges",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"it",
".",
"cur",
"==",
"nil",
"{",
"it",
".",
"cur",
"=",
"it",
".",
"ranges",
".... | // Next moves to the next item. | [
"Next",
"moves",
"to",
"the",
"next",
"item",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/range_iter.go#L36-L46 |
124,947 | m3db/m3x | time/range_iter.go | Value | func (it *RangeIter) Value() Range {
if it.cur == nil {
return Range{}
}
return it.cur.Value.(Range)
} | go | func (it *RangeIter) Value() Range {
if it.cur == nil {
return Range{}
}
return it.cur.Value.(Range)
} | [
"func",
"(",
"it",
"*",
"RangeIter",
")",
"Value",
"(",
")",
"Range",
"{",
"if",
"it",
".",
"cur",
"==",
"nil",
"{",
"return",
"Range",
"{",
"}",
"\n",
"}",
"\n",
"return",
"it",
".",
"cur",
".",
"Value",
".",
"(",
"Range",
")",
"\n",
"}"
] | // Value returns the current time range. | [
"Value",
"returns",
"the",
"current",
"time",
"range",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/time/range_iter.go#L49-L54 |
124,948 | m3db/m3x | instrument/methods.go | NewSampledTimer | func NewSampledTimer(base tally.Timer, rate float64) (tally.Timer, error) {
if rate <= 0.0 || rate > 1.0 {
return nil, fmt.Errorf("sampling rate %f must be between 0.0 and 1.0", rate)
}
return &sampledTimer{
Timer: base,
rate: uint64(1.0 / rate),
}, nil
} | go | func NewSampledTimer(base tally.Timer, rate float64) (tally.Timer, error) {
if rate <= 0.0 || rate > 1.0 {
return nil, fmt.Errorf("sampling rate %f must be between 0.0 and 1.0", rate)
}
return &sampledTimer{
Timer: base,
rate: uint64(1.0 / rate),
}, nil
} | [
"func",
"NewSampledTimer",
"(",
"base",
"tally",
".",
"Timer",
",",
"rate",
"float64",
")",
"(",
"tally",
".",
"Timer",
",",
"error",
")",
"{",
"if",
"rate",
"<=",
"0.0",
"||",
"rate",
">",
"1.0",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(... | // NewSampledTimer creates a new sampled timer. | [
"NewSampledTimer",
"creates",
"a",
"new",
"sampled",
"timer",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/instrument/methods.go#L45-L53 |
124,949 | m3db/m3x | instrument/methods.go | MustCreateSampledTimer | func MustCreateSampledTimer(base tally.Timer, rate float64) tally.Timer {
t, err := NewSampledTimer(base, rate)
if err != nil {
panic(err)
}
return t
} | go | func MustCreateSampledTimer(base tally.Timer, rate float64) tally.Timer {
t, err := NewSampledTimer(base, rate)
if err != nil {
panic(err)
}
return t
} | [
"func",
"MustCreateSampledTimer",
"(",
"base",
"tally",
".",
"Timer",
",",
"rate",
"float64",
")",
"tally",
".",
"Timer",
"{",
"t",
",",
"err",
":=",
"NewSampledTimer",
"(",
"base",
",",
"rate",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
... | // MustCreateSampledTimer creates a new sampled timer, and panics if an error
// is encountered. | [
"MustCreateSampledTimer",
"creates",
"a",
"new",
"sampled",
"timer",
"and",
"panics",
"if",
"an",
"error",
"is",
"encountered",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/instrument/methods.go#L57-L63 |
124,950 | m3db/m3x | instrument/methods.go | ReportSuccess | func (m *MethodMetrics) ReportSuccess(d time.Duration) {
m.Success.Inc(1)
m.SuccessLatency.Record(d)
} | go | func (m *MethodMetrics) ReportSuccess(d time.Duration) {
m.Success.Inc(1)
m.SuccessLatency.Record(d)
} | [
"func",
"(",
"m",
"*",
"MethodMetrics",
")",
"ReportSuccess",
"(",
"d",
"time",
".",
"Duration",
")",
"{",
"m",
".",
"Success",
".",
"Inc",
"(",
"1",
")",
"\n",
"m",
".",
"SuccessLatency",
".",
"Record",
"(",
"d",
")",
"\n",
"}"
] | // ReportSuccess reports a success. | [
"ReportSuccess",
"reports",
"a",
"success",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/instrument/methods.go#L100-L103 |
124,951 | m3db/m3x | instrument/methods.go | ReportError | func (m *MethodMetrics) ReportError(d time.Duration) {
m.Errors.Inc(1)
m.ErrorsLatency.Record(d)
} | go | func (m *MethodMetrics) ReportError(d time.Duration) {
m.Errors.Inc(1)
m.ErrorsLatency.Record(d)
} | [
"func",
"(",
"m",
"*",
"MethodMetrics",
")",
"ReportError",
"(",
"d",
"time",
".",
"Duration",
")",
"{",
"m",
".",
"Errors",
".",
"Inc",
"(",
"1",
")",
"\n",
"m",
".",
"ErrorsLatency",
".",
"Record",
"(",
"d",
")",
"\n",
"}"
] | // ReportError reports an error. | [
"ReportError",
"reports",
"an",
"error",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/instrument/methods.go#L106-L109 |
124,952 | m3db/m3x | instrument/methods.go | NewMethodMetrics | func NewMethodMetrics(scope tally.Scope, methodName string, samplingRate float64) MethodMetrics {
return MethodMetrics{
Errors: scope.Counter(methodName + ".errors"),
Success: scope.Counter(methodName + ".success"),
ErrorsLatency: MustCreateSampledTimer(scope.Timer(methodName+".errors-latency"), ... | go | func NewMethodMetrics(scope tally.Scope, methodName string, samplingRate float64) MethodMetrics {
return MethodMetrics{
Errors: scope.Counter(methodName + ".errors"),
Success: scope.Counter(methodName + ".success"),
ErrorsLatency: MustCreateSampledTimer(scope.Timer(methodName+".errors-latency"), ... | [
"func",
"NewMethodMetrics",
"(",
"scope",
"tally",
".",
"Scope",
",",
"methodName",
"string",
",",
"samplingRate",
"float64",
")",
"MethodMetrics",
"{",
"return",
"MethodMetrics",
"{",
"Errors",
":",
"scope",
".",
"Counter",
"(",
"methodName",
"+",
"\"",
"\"",... | // NewMethodMetrics returns a new Method metrics for the given method name. | [
"NewMethodMetrics",
"returns",
"a",
"new",
"Method",
"metrics",
"for",
"the",
"given",
"method",
"name",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/instrument/methods.go#L121-L128 |
124,953 | m3db/m3x | instrument/methods.go | NewBatchMethodMetrics | func NewBatchMethodMetrics(
scope tally.Scope,
methodName string,
samplingRate float64,
) BatchMethodMetrics {
return BatchMethodMetrics{
RetryableErrors: scope.Counter(methodName + ".retryable-errors"),
NonRetryableErrors: scope.Counter(methodName + ".non-retryable-errors"),
Errors: scope.Coun... | go | func NewBatchMethodMetrics(
scope tally.Scope,
methodName string,
samplingRate float64,
) BatchMethodMetrics {
return BatchMethodMetrics{
RetryableErrors: scope.Counter(methodName + ".retryable-errors"),
NonRetryableErrors: scope.Counter(methodName + ".non-retryable-errors"),
Errors: scope.Coun... | [
"func",
"NewBatchMethodMetrics",
"(",
"scope",
"tally",
".",
"Scope",
",",
"methodName",
"string",
",",
"samplingRate",
"float64",
",",
")",
"BatchMethodMetrics",
"{",
"return",
"BatchMethodMetrics",
"{",
"RetryableErrors",
":",
"scope",
".",
"Counter",
"(",
"meth... | // NewBatchMethodMetrics creates new batch method metrics. | [
"NewBatchMethodMetrics",
"creates",
"new",
"batch",
"method",
"metrics",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/instrument/methods.go#L140-L152 |
124,954 | m3db/m3x | instrument/methods.go | ReportSuccess | func (m *BatchMethodMetrics) ReportSuccess(n int) {
m.Success.Inc(int64(n))
} | go | func (m *BatchMethodMetrics) ReportSuccess(n int) {
m.Success.Inc(int64(n))
} | [
"func",
"(",
"m",
"*",
"BatchMethodMetrics",
")",
"ReportSuccess",
"(",
"n",
"int",
")",
"{",
"m",
".",
"Success",
".",
"Inc",
"(",
"int64",
"(",
"n",
")",
")",
"\n",
"}"
] | // ReportSuccess reports successess. | [
"ReportSuccess",
"reports",
"successess",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/instrument/methods.go#L155-L157 |
124,955 | m3db/m3x | instrument/methods.go | ReportRetryableErrors | func (m *BatchMethodMetrics) ReportRetryableErrors(n int) {
m.RetryableErrors.Inc(int64(n))
m.Errors.Inc(int64(n))
} | go | func (m *BatchMethodMetrics) ReportRetryableErrors(n int) {
m.RetryableErrors.Inc(int64(n))
m.Errors.Inc(int64(n))
} | [
"func",
"(",
"m",
"*",
"BatchMethodMetrics",
")",
"ReportRetryableErrors",
"(",
"n",
"int",
")",
"{",
"m",
".",
"RetryableErrors",
".",
"Inc",
"(",
"int64",
"(",
"n",
")",
")",
"\n",
"m",
".",
"Errors",
".",
"Inc",
"(",
"int64",
"(",
"n",
")",
")",... | // ReportRetryableErrors reports retryable errors. | [
"ReportRetryableErrors",
"reports",
"retryable",
"errors",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/instrument/methods.go#L160-L163 |
124,956 | m3db/m3x | instrument/methods.go | ReportNonRetryableErrors | func (m *BatchMethodMetrics) ReportNonRetryableErrors(n int) {
m.NonRetryableErrors.Inc(int64(n))
m.Errors.Inc(int64(n))
} | go | func (m *BatchMethodMetrics) ReportNonRetryableErrors(n int) {
m.NonRetryableErrors.Inc(int64(n))
m.Errors.Inc(int64(n))
} | [
"func",
"(",
"m",
"*",
"BatchMethodMetrics",
")",
"ReportNonRetryableErrors",
"(",
"n",
"int",
")",
"{",
"m",
".",
"NonRetryableErrors",
".",
"Inc",
"(",
"int64",
"(",
"n",
")",
")",
"\n",
"m",
".",
"Errors",
".",
"Inc",
"(",
"int64",
"(",
"n",
")",
... | // ReportNonRetryableErrors reports non-retryable errors. | [
"ReportNonRetryableErrors",
"reports",
"non",
"-",
"retryable",
"errors",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/instrument/methods.go#L166-L169 |
124,957 | m3db/m3x | instrument/methods.go | ReportLatency | func (m *BatchMethodMetrics) ReportLatency(d time.Duration) {
m.Latency.Record(d)
} | go | func (m *BatchMethodMetrics) ReportLatency(d time.Duration) {
m.Latency.Record(d)
} | [
"func",
"(",
"m",
"*",
"BatchMethodMetrics",
")",
"ReportLatency",
"(",
"d",
"time",
".",
"Duration",
")",
"{",
"m",
".",
"Latency",
".",
"Record",
"(",
"d",
")",
"\n",
"}"
] | // ReportLatency reports latency. | [
"ReportLatency",
"reports",
"latency",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/instrument/methods.go#L172-L174 |
124,958 | m3db/m3x | watch/source.go | NewSource | func NewSource(input SourceInput, logger log.Logger) Source {
s := &source{
input: input,
w: NewWatchable(),
logger: logger,
}
go s.run()
return s
} | go | func NewSource(input SourceInput, logger log.Logger) Source {
s := &source{
input: input,
w: NewWatchable(),
logger: logger,
}
go s.run()
return s
} | [
"func",
"NewSource",
"(",
"input",
"SourceInput",
",",
"logger",
"log",
".",
"Logger",
")",
"Source",
"{",
"s",
":=",
"&",
"source",
"{",
"input",
":",
"input",
",",
"w",
":",
"NewWatchable",
"(",
")",
",",
"logger",
":",
"logger",
",",
"}",
"\n\n",
... | // NewSource returns a new Source. | [
"NewSource",
"returns",
"a",
"new",
"Source",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/watch/source.go#L53-L62 |
124,959 | m3db/m3x | log/logger.go | NewLogger | func NewLogger(writer io.Writer, fields ...Field) Logger {
return &writerLogger{writer, Fields(fields)}
} | go | func NewLogger(writer io.Writer, fields ...Field) Logger {
return &writerLogger{writer, Fields(fields)}
} | [
"func",
"NewLogger",
"(",
"writer",
"io",
".",
"Writer",
",",
"fields",
"...",
"Field",
")",
"Logger",
"{",
"return",
"&",
"writerLogger",
"{",
"writer",
",",
"Fields",
"(",
"fields",
")",
"}",
"\n",
"}"
] | // NewLogger returns a Logger that writes to the given writer. | [
"NewLogger",
"returns",
"a",
"Logger",
"that",
"writes",
"to",
"the",
"given",
"writer",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/log/logger.go#L155-L157 |
124,960 | m3db/m3x | log/logger.go | ParseLevel | func ParseLevel(level string) (Level, error) {
level = strings.ToLower(level)
for _, l := range levels {
if strings.ToLower(l.String()) == level {
return l, nil
}
}
return Level(0), fmt.Errorf("unrecognized log level: %s", level)
} | go | func ParseLevel(level string) (Level, error) {
level = strings.ToLower(level)
for _, l := range levels {
if strings.ToLower(l.String()) == level {
return l, nil
}
}
return Level(0), fmt.Errorf("unrecognized log level: %s", level)
} | [
"func",
"ParseLevel",
"(",
"level",
"string",
")",
"(",
"Level",
",",
"error",
")",
"{",
"level",
"=",
"strings",
".",
"ToLower",
"(",
"level",
")",
"\n",
"for",
"_",
",",
"l",
":=",
"range",
"levels",
"{",
"if",
"strings",
".",
"ToLower",
"(",
"l"... | // ParseLevel parses a log level string to log level. | [
"ParseLevel",
"parses",
"a",
"log",
"level",
"string",
"to",
"log",
"level",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/log/logger.go#L243-L251 |
124,961 | m3db/m3x | clock/types.go | WaitUntil | func WaitUntil(fn ConditionFn, timeout time.Duration) bool {
deadline := time.Now().Add(timeout)
for time.Now().Before(deadline) {
if fn() {
return true
}
time.Sleep(100 * time.Millisecond)
}
return false
} | go | func WaitUntil(fn ConditionFn, timeout time.Duration) bool {
deadline := time.Now().Add(timeout)
for time.Now().Before(deadline) {
if fn() {
return true
}
time.Sleep(100 * time.Millisecond)
}
return false
} | [
"func",
"WaitUntil",
"(",
"fn",
"ConditionFn",
",",
"timeout",
"time",
".",
"Duration",
")",
"bool",
"{",
"deadline",
":=",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"timeout",
")",
"\n",
"for",
"time",
".",
"Now",
"(",
")",
".",
"Before",
"("... | // WaitUntil returns true if the condition specified evaluated to
// true before the timeout, false otherwise. | [
"WaitUntil",
"returns",
"true",
"if",
"the",
"condition",
"specified",
"evaluated",
"to",
"true",
"before",
"the",
"timeout",
"false",
"otherwise",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/clock/types.go#L61-L70 |
124,962 | m3db/m3x | net/server.go | StartAcceptLoop | func StartAcceptLoop(l net.Listener, rOpts retry.Options) (<-chan net.Conn, <-chan error) {
var (
connCh = make(chan net.Conn)
errCh = make(chan error)
retrier = retry.NewRetrier(rOpts)
)
go func() {
defer l.Close()
for {
var conn net.Conn
if err := retrier.Attempt(func() error {
var connErr... | go | func StartAcceptLoop(l net.Listener, rOpts retry.Options) (<-chan net.Conn, <-chan error) {
var (
connCh = make(chan net.Conn)
errCh = make(chan error)
retrier = retry.NewRetrier(rOpts)
)
go func() {
defer l.Close()
for {
var conn net.Conn
if err := retrier.Attempt(func() error {
var connErr... | [
"func",
"StartAcceptLoop",
"(",
"l",
"net",
".",
"Listener",
",",
"rOpts",
"retry",
".",
"Options",
")",
"(",
"<-",
"chan",
"net",
".",
"Conn",
",",
"<-",
"chan",
"error",
")",
"{",
"var",
"(",
"connCh",
"=",
"make",
"(",
"chan",
"net",
".",
"Conn"... | // StartAcceptLoop starts an accept loop for the given listener,
// returning accepted connections via a channel while handling
// temporary network errors. Fatal errors are returned via the
// error channel with the listener closed on return. | [
"StartAcceptLoop",
"starts",
"an",
"accept",
"loop",
"for",
"the",
"given",
"listener",
"returning",
"accepted",
"connections",
"via",
"a",
"channel",
"while",
"handling",
"temporary",
"network",
"errors",
".",
"Fatal",
"errors",
"are",
"returned",
"via",
"the",
... | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/net/server.go#L35-L70 |
124,963 | m3db/m3x | net/server.go | StartForeverAcceptLoop | func StartForeverAcceptLoop(l net.Listener, rOpts retry.Options) (<-chan net.Conn, <-chan error) {
return StartAcceptLoop(l, rOpts.SetForever(true))
} | go | func StartForeverAcceptLoop(l net.Listener, rOpts retry.Options) (<-chan net.Conn, <-chan error) {
return StartAcceptLoop(l, rOpts.SetForever(true))
} | [
"func",
"StartForeverAcceptLoop",
"(",
"l",
"net",
".",
"Listener",
",",
"rOpts",
"retry",
".",
"Options",
")",
"(",
"<-",
"chan",
"net",
".",
"Conn",
",",
"<-",
"chan",
"error",
")",
"{",
"return",
"StartAcceptLoop",
"(",
"l",
",",
"rOpts",
".",
"SetF... | // StartForeverAcceptLoop starts an accept loop for the
// given listener that retries forever, returning
// accepted connections via a channel while handling
// temporary network errors. Fatal errors are returned via the
// error channel with the listener closed on return. | [
"StartForeverAcceptLoop",
"starts",
"an",
"accept",
"loop",
"for",
"the",
"given",
"listener",
"that",
"retries",
"forever",
"returning",
"accepted",
"connections",
"via",
"a",
"channel",
"while",
"handling",
"temporary",
"network",
"errors",
".",
"Fatal",
"errors",... | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/net/server.go#L77-L79 |
124,964 | m3db/m3x | pool/options.go | NewObjectPoolOptions | func NewObjectPoolOptions() ObjectPoolOptions {
return &objectPoolOptions{
size: defaultSize,
refillLowWatermark: defaultRefillLowWatermark,
refillHighWatermark: defaultRefillHighWatermark,
instrumentOpts: instrument.NewOptions(),
onPoolAccessErrorFn: func(err error) { panic(err) },
}
} | go | func NewObjectPoolOptions() ObjectPoolOptions {
return &objectPoolOptions{
size: defaultSize,
refillLowWatermark: defaultRefillLowWatermark,
refillHighWatermark: defaultRefillHighWatermark,
instrumentOpts: instrument.NewOptions(),
onPoolAccessErrorFn: func(err error) { panic(err) },
}
} | [
"func",
"NewObjectPoolOptions",
"(",
")",
"ObjectPoolOptions",
"{",
"return",
"&",
"objectPoolOptions",
"{",
"size",
":",
"defaultSize",
",",
"refillLowWatermark",
":",
"defaultRefillLowWatermark",
",",
"refillHighWatermark",
":",
"defaultRefillHighWatermark",
",",
"instr... | // NewObjectPoolOptions creates a new set of object pool options | [
"NewObjectPoolOptions",
"creates",
"a",
"new",
"set",
"of",
"object",
"pool",
"options"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/pool/options.go#L40-L48 |
124,965 | m3db/m3x | ident/ident_mock.go | NewMockID | func NewMockID(ctrl *gomock.Controller) *MockID {
mock := &MockID{ctrl: ctrl}
mock.recorder = &MockIDMockRecorder{mock}
return mock
} | go | func NewMockID(ctrl *gomock.Controller) *MockID {
mock := &MockID{ctrl: ctrl}
mock.recorder = &MockIDMockRecorder{mock}
return mock
} | [
"func",
"NewMockID",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockID",
"{",
"mock",
":=",
"&",
"MockID",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockIDMockRecorder",
"{",
"mock",
"}",
"\n",
"return",
... | // NewMockID creates a new mock instance | [
"NewMockID",
"creates",
"a",
"new",
"mock",
"instance"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/ident/ident_mock.go#L45-L49 |
124,966 | m3db/m3x | ident/ident_mock.go | Bytes | func (mr *MockIDMockRecorder) Bytes() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Bytes", reflect.TypeOf((*MockID)(nil).Bytes))
} | go | func (mr *MockIDMockRecorder) Bytes() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Bytes", reflect.TypeOf((*MockID)(nil).Bytes))
} | [
"func",
"(",
"mr",
"*",
"MockIDMockRecorder",
")",
"Bytes",
"(",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
".",
"TypeOf",
... | // Bytes indicates an expected call of Bytes | [
"Bytes",
"indicates",
"an",
"expected",
"call",
"of",
"Bytes"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/ident/ident_mock.go#L64-L66 |
124,967 | m3db/m3x | ident/ident_mock.go | Equal | func (m *MockID) Equal(arg0 ID) bool {
ret := m.ctrl.Call(m, "Equal", arg0)
ret0, _ := ret[0].(bool)
return ret0
} | go | func (m *MockID) Equal(arg0 ID) bool {
ret := m.ctrl.Call(m, "Equal", arg0)
ret0, _ := ret[0].(bool)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockID",
")",
"Equal",
"(",
"arg0",
"ID",
")",
"bool",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"bo... | // Equal mocks base method | [
"Equal",
"mocks",
"base",
"method"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/ident/ident_mock.go#L69-L73 |
124,968 | m3db/m3x | ident/ident_mock.go | Equal | func (mr *MockIDMockRecorder) Equal(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Equal", reflect.TypeOf((*MockID)(nil).Equal), arg0)
} | go | func (mr *MockIDMockRecorder) Equal(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Equal", reflect.TypeOf((*MockID)(nil).Equal), arg0)
} | [
"func",
"(",
"mr",
"*",
"MockIDMockRecorder",
")",
"Equal",
"(",
"arg0",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
... | // Equal indicates an expected call of Equal | [
"Equal",
"indicates",
"an",
"expected",
"call",
"of",
"Equal"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/ident/ident_mock.go#L76-L78 |
124,969 | m3db/m3x | ident/ident_mock.go | IsNoFinalize | func (m *MockID) IsNoFinalize() bool {
ret := m.ctrl.Call(m, "IsNoFinalize")
ret0, _ := ret[0].(bool)
return ret0
} | go | func (m *MockID) IsNoFinalize() bool {
ret := m.ctrl.Call(m, "IsNoFinalize")
ret0, _ := ret[0].(bool)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockID",
")",
"IsNoFinalize",
"(",
")",
"bool",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"bool",
")",
"\n",
"retur... | // IsNoFinalize mocks base method | [
"IsNoFinalize",
"mocks",
"base",
"method"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/ident/ident_mock.go#L91-L95 |
124,970 | m3db/m3x | ident/ident_mock.go | NewMockTagIterator | func NewMockTagIterator(ctrl *gomock.Controller) *MockTagIterator {
mock := &MockTagIterator{ctrl: ctrl}
mock.recorder = &MockTagIteratorMockRecorder{mock}
return mock
} | go | func NewMockTagIterator(ctrl *gomock.Controller) *MockTagIterator {
mock := &MockTagIterator{ctrl: ctrl}
mock.recorder = &MockTagIteratorMockRecorder{mock}
return mock
} | [
"func",
"NewMockTagIterator",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockTagIterator",
"{",
"mock",
":=",
"&",
"MockTagIterator",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockTagIteratorMockRecorder",
"{",
"... | // NewMockTagIterator creates a new mock instance | [
"NewMockTagIterator",
"creates",
"a",
"new",
"mock",
"instance"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/ident/ident_mock.go#L136-L140 |
124,971 | m3db/m3x | ident/ident_mock.go | Current | func (m *MockTagIterator) Current() Tag {
ret := m.ctrl.Call(m, "Current")
ret0, _ := ret[0].(Tag)
return ret0
} | go | func (m *MockTagIterator) Current() Tag {
ret := m.ctrl.Call(m, "Current")
ret0, _ := ret[0].(Tag)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockTagIterator",
")",
"Current",
"(",
")",
"Tag",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"Tag",
")",
"\n",
"ret... | // Current mocks base method | [
"Current",
"mocks",
"base",
"method"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/ident/ident_mock.go#L158-L162 |
124,972 | m3db/m3x | ident/ident_mock.go | Duplicate | func (m *MockTagIterator) Duplicate() TagIterator {
ret := m.ctrl.Call(m, "Duplicate")
ret0, _ := ret[0].(TagIterator)
return ret0
} | go | func (m *MockTagIterator) Duplicate() TagIterator {
ret := m.ctrl.Call(m, "Duplicate")
ret0, _ := ret[0].(TagIterator)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockTagIterator",
")",
"Duplicate",
"(",
")",
"TagIterator",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"TagIterator",
"... | // Duplicate mocks base method | [
"Duplicate",
"mocks",
"base",
"method"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/ident/ident_mock.go#L182-L186 |
124,973 | m3db/m3x | ident/ident_mock.go | Len | func (mr *MockTagIteratorMockRecorder) Len() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Len", reflect.TypeOf((*MockTagIterator)(nil).Len))
} | go | func (mr *MockTagIteratorMockRecorder) Len() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Len", reflect.TypeOf((*MockTagIterator)(nil).Len))
} | [
"func",
"(",
"mr",
"*",
"MockTagIteratorMockRecorder",
")",
"Len",
"(",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
".",
"Type... | // Len indicates an expected call of Len | [
"Len",
"indicates",
"an",
"expected",
"call",
"of",
"Len"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/ident/ident_mock.go#L213-L215 |
124,974 | m3db/m3x | ident/ident_mock.go | Next | func (m *MockTagIterator) Next() bool {
ret := m.ctrl.Call(m, "Next")
ret0, _ := ret[0].(bool)
return ret0
} | go | func (m *MockTagIterator) Next() bool {
ret := m.ctrl.Call(m, "Next")
ret0, _ := ret[0].(bool)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockTagIterator",
")",
"Next",
"(",
")",
"bool",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"bool",
")",
"\n",
"retu... | // Next mocks base method | [
"Next",
"mocks",
"base",
"method"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/ident/ident_mock.go#L218-L222 |
124,975 | m3db/m3x | ident/ident_mock.go | Remaining | func (m *MockTagIterator) Remaining() int {
ret := m.ctrl.Call(m, "Remaining")
ret0, _ := ret[0].(int)
return ret0
} | go | func (m *MockTagIterator) Remaining() int {
ret := m.ctrl.Call(m, "Remaining")
ret0, _ := ret[0].(int)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockTagIterator",
")",
"Remaining",
"(",
")",
"int",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"int",
")",
"\n",
"r... | // Remaining mocks base method | [
"Remaining",
"mocks",
"base",
"method"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/ident/ident_mock.go#L230-L234 |
124,976 | m3db/m3x | checked/bytes.go | NewBytes | func NewBytes(value []byte, opts BytesOptions) Bytes {
if opts == nil {
opts = defaultBytesOptions
}
b := &bytesRef{
opts: opts,
value: value,
}
b.SetFinalizer(b)
// NB(r): Tracking objects causes interface allocation
// so avoid if we are not performing any leak detection.
if leakDetectionEnabled() {
... | go | func NewBytes(value []byte, opts BytesOptions) Bytes {
if opts == nil {
opts = defaultBytesOptions
}
b := &bytesRef{
opts: opts,
value: value,
}
b.SetFinalizer(b)
// NB(r): Tracking objects causes interface allocation
// so avoid if we are not performing any leak detection.
if leakDetectionEnabled() {
... | [
"func",
"NewBytes",
"(",
"value",
"[",
"]",
"byte",
",",
"opts",
"BytesOptions",
")",
"Bytes",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"defaultBytesOptions",
"\n",
"}",
"\n",
"b",
":=",
"&",
"bytesRef",
"{",
"opts",
":",
"opts",
",",
"value... | // NewBytes returns a new checked byte slice. | [
"NewBytes",
"returns",
"a",
"new",
"checked",
"byte",
"slice",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/checked/bytes.go#L65-L80 |
124,977 | m3db/m3x | server/options.go | NewOptions | func NewOptions() Options {
return &options{
instrumentOpts: instrument.NewOptions(),
retryOpts: retry.NewOptions(),
tcpConnectionKeepAlive: defaultTCPConnectionKeepAlive,
tcpConnectionKeepAlivePeriod: defaultTCPConnectionKeepAlivePeriod,
}
} | go | func NewOptions() Options {
return &options{
instrumentOpts: instrument.NewOptions(),
retryOpts: retry.NewOptions(),
tcpConnectionKeepAlive: defaultTCPConnectionKeepAlive,
tcpConnectionKeepAlivePeriod: defaultTCPConnectionKeepAlivePeriod,
}
} | [
"func",
"NewOptions",
"(",
")",
"Options",
"{",
"return",
"&",
"options",
"{",
"instrumentOpts",
":",
"instrument",
".",
"NewOptions",
"(",
")",
",",
"retryOpts",
":",
"retry",
".",
"NewOptions",
"(",
")",
",",
"tcpConnectionKeepAlive",
":",
"defaultTCPConnect... | // NewOptions creates a new set of server options | [
"NewOptions",
"creates",
"a",
"new",
"set",
"of",
"server",
"options"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/server/options.go#L77-L84 |
124,978 | m3db/m3x | pool/pool_mock.go | NewMockCheckedBytesPool | func NewMockCheckedBytesPool(ctrl *gomock.Controller) *MockCheckedBytesPool {
mock := &MockCheckedBytesPool{ctrl: ctrl}
mock.recorder = &MockCheckedBytesPoolMockRecorder{mock}
return mock
} | go | func NewMockCheckedBytesPool(ctrl *gomock.Controller) *MockCheckedBytesPool {
mock := &MockCheckedBytesPool{ctrl: ctrl}
mock.recorder = &MockCheckedBytesPoolMockRecorder{mock}
return mock
} | [
"func",
"NewMockCheckedBytesPool",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockCheckedBytesPool",
"{",
"mock",
":=",
"&",
"MockCheckedBytesPool",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockCheckedBytesPoolMockR... | // NewMockCheckedBytesPool creates a new mock instance | [
"NewMockCheckedBytesPool",
"creates",
"a",
"new",
"mock",
"instance"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/pool/pool_mock.go#L47-L51 |
124,979 | m3db/m3x | pool/pool_mock.go | BytesPool | func (m *MockCheckedBytesPool) BytesPool() BytesPool {
ret := m.ctrl.Call(m, "BytesPool")
ret0, _ := ret[0].(BytesPool)
return ret0
} | go | func (m *MockCheckedBytesPool) BytesPool() BytesPool {
ret := m.ctrl.Call(m, "BytesPool")
ret0, _ := ret[0].(BytesPool)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockCheckedBytesPool",
")",
"BytesPool",
"(",
")",
"BytesPool",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"BytesPool",
... | // BytesPool mocks base method | [
"BytesPool",
"mocks",
"base",
"method"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/pool/pool_mock.go#L59-L63 |
124,980 | m3db/m3x | pool/pool_mock.go | BytesPool | func (mr *MockCheckedBytesPoolMockRecorder) BytesPool() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BytesPool", reflect.TypeOf((*MockCheckedBytesPool)(nil).BytesPool))
} | go | func (mr *MockCheckedBytesPoolMockRecorder) BytesPool() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BytesPool", reflect.TypeOf((*MockCheckedBytesPool)(nil).BytesPool))
} | [
"func",
"(",
"mr",
"*",
"MockCheckedBytesPoolMockRecorder",
")",
"BytesPool",
"(",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
"... | // BytesPool indicates an expected call of BytesPool | [
"BytesPool",
"indicates",
"an",
"expected",
"call",
"of",
"BytesPool"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/pool/pool_mock.go#L66-L68 |
124,981 | m3db/m3x | pool/pool_mock.go | NewMockBytesPool | func NewMockBytesPool(ctrl *gomock.Controller) *MockBytesPool {
mock := &MockBytesPool{ctrl: ctrl}
mock.recorder = &MockBytesPoolMockRecorder{mock}
return mock
} | go | func NewMockBytesPool(ctrl *gomock.Controller) *MockBytesPool {
mock := &MockBytesPool{ctrl: ctrl}
mock.recorder = &MockBytesPoolMockRecorder{mock}
return mock
} | [
"func",
"NewMockBytesPool",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockBytesPool",
"{",
"mock",
":=",
"&",
"MockBytesPool",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockBytesPoolMockRecorder",
"{",
"mock",
... | // NewMockBytesPool creates a new mock instance | [
"NewMockBytesPool",
"creates",
"a",
"new",
"mock",
"instance"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/pool/pool_mock.go#L104-L108 |
124,982 | m3db/m3x | ident/identifier.go | BinaryID | func BinaryID(v checked.Bytes) ID {
v.IncRef()
return &id{data: v}
} | go | func BinaryID(v checked.Bytes) ID {
v.IncRef()
return &id{data: v}
} | [
"func",
"BinaryID",
"(",
"v",
"checked",
".",
"Bytes",
")",
"ID",
"{",
"v",
".",
"IncRef",
"(",
")",
"\n",
"return",
"&",
"id",
"{",
"data",
":",
"v",
"}",
"\n",
"}"
] | // BinaryID constructs a new ID based on a binary value. | [
"BinaryID",
"constructs",
"a",
"new",
"ID",
"based",
"on",
"a",
"binary",
"value",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/ident/identifier.go#L30-L33 |
124,983 | m3db/m3x | ident/identifier.go | Bytes | func (v *id) Bytes() []byte {
if v.data == nil {
return nil
}
return v.data.Bytes()
} | go | func (v *id) Bytes() []byte {
if v.data == nil {
return nil
}
return v.data.Bytes()
} | [
"func",
"(",
"v",
"*",
"id",
")",
"Bytes",
"(",
")",
"[",
"]",
"byte",
"{",
"if",
"v",
".",
"data",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"v",
".",
"data",
".",
"Bytes",
"(",
")",
"\n",
"}"
] | // Bytes directly returns the underlying bytes of an ID, it is not safe
// to hold a reference to this slice and is only valid during the lifetime
// of the the ID itself. | [
"Bytes",
"directly",
"returns",
"the",
"underlying",
"bytes",
"of",
"an",
"ID",
"it",
"is",
"not",
"safe",
"to",
"hold",
"a",
"reference",
"to",
"this",
"slice",
"and",
"is",
"only",
"valid",
"during",
"the",
"lifetime",
"of",
"the",
"the",
"ID",
"itself... | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/ident/identifier.go#L49-L54 |
124,984 | m3db/m3x | close/close.go | TryClose | func TryClose(r interface{}) error {
if r, ok := r.(Closer); ok {
return r.Close()
}
if r, ok := r.(SimpleCloser); ok {
r.Close()
return nil
}
return ErrNotCloseable
} | go | func TryClose(r interface{}) error {
if r, ok := r.(Closer); ok {
return r.Close()
}
if r, ok := r.(SimpleCloser); ok {
r.Close()
return nil
}
return ErrNotCloseable
} | [
"func",
"TryClose",
"(",
"r",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"r",
",",
"ok",
":=",
"r",
".",
"(",
"Closer",
")",
";",
"ok",
"{",
"return",
"r",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"if",
"r",
",",
"ok",
":=",
"r",
".",
... | // TryClose attempts to close a resource, the resource is expected to
// implement either Closeable or CloseableResult. | [
"TryClose",
"attempts",
"to",
"close",
"a",
"resource",
"the",
"resource",
"is",
"expected",
"to",
"implement",
"either",
"Closeable",
"or",
"CloseableResult",
"."
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/close/close.go#L47-L56 |
124,985 | m3db/m3x | pool/floats.go | NewFloatsPool | func NewFloatsPool(sizes []Bucket, opts ObjectPoolOptions) FloatsPool {
return &floatsPool{pool: NewBucketizedObjectPool(sizes, opts)}
} | go | func NewFloatsPool(sizes []Bucket, opts ObjectPoolOptions) FloatsPool {
return &floatsPool{pool: NewBucketizedObjectPool(sizes, opts)}
} | [
"func",
"NewFloatsPool",
"(",
"sizes",
"[",
"]",
"Bucket",
",",
"opts",
"ObjectPoolOptions",
")",
"FloatsPool",
"{",
"return",
"&",
"floatsPool",
"{",
"pool",
":",
"NewBucketizedObjectPool",
"(",
"sizes",
",",
"opts",
")",
"}",
"\n",
"}"
] | // NewFloatsPool creates a new floats pool | [
"NewFloatsPool",
"creates",
"a",
"new",
"floats",
"pool"
] | ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e | https://github.com/m3db/m3x/blob/ebf3c7b94afd62bad2aaa3ad20bb2d4142aa342e/pool/floats.go#L28-L30 |
124,986 | apcera/util | restclient/restclient.go | NewDisableKeepAlives | func NewDisableKeepAlives(baseurl string) (*Client, error) {
base, err := url.ParseRequestURI(baseurl)
if err != nil {
return nil, err
} else if !base.IsAbs() || base.Host == "" {
return nil, fmt.Errorf("URL is not absolute: %s", baseurl)
}
transport := http.DefaultTransport.(*http.Transport)
transport.Disab... | go | func NewDisableKeepAlives(baseurl string) (*Client, error) {
base, err := url.ParseRequestURI(baseurl)
if err != nil {
return nil, err
} else if !base.IsAbs() || base.Host == "" {
return nil, fmt.Errorf("URL is not absolute: %s", baseurl)
}
transport := http.DefaultTransport.(*http.Transport)
transport.Disab... | [
"func",
"NewDisableKeepAlives",
"(",
"baseurl",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"base",
",",
"err",
":=",
"url",
".",
"ParseRequestURI",
"(",
"baseurl",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
... | // NewWithoutKeepAlives returns a new client with keepalives disabled. | [
"NewWithoutKeepAlives",
"returns",
"a",
"new",
"client",
"with",
"keepalives",
"disabled",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/restclient/restclient.go#L81-L103 |
124,987 | apcera/util | restclient/restclient.go | SetAccessToken | func (c *Client) SetAccessToken(token string) {
c.Headers.Set(http.CanonicalHeaderKey("Authorization"), "Bearer "+token)
} | go | func (c *Client) SetAccessToken(token string) {
c.Headers.Set(http.CanonicalHeaderKey("Authorization"), "Bearer "+token)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetAccessToken",
"(",
"token",
"string",
")",
"{",
"c",
".",
"Headers",
".",
"Set",
"(",
"http",
".",
"CanonicalHeaderKey",
"(",
"\"",
"\"",
")",
",",
"\"",
"\"",
"+",
"token",
")",
"\n",
"}"
] | // Set the access Token | [
"Set",
"the",
"access",
"Token"
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/restclient/restclient.go#L112-L114 |
124,988 | apcera/util | restclient/restclient.go | SetTimeout | func (c *Client) SetTimeout(duration time.Duration) {
c.Driver.Timeout = duration
} | go | func (c *Client) SetTimeout(duration time.Duration) {
c.Driver.Timeout = duration
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetTimeout",
"(",
"duration",
"time",
".",
"Duration",
")",
"{",
"c",
".",
"Driver",
".",
"Timeout",
"=",
"duration",
"\n",
"}"
] | // SetTimeout sets the timeout of a client to the given duration. | [
"SetTimeout",
"sets",
"the",
"timeout",
"of",
"a",
"client",
"to",
"the",
"given",
"duration",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/restclient/restclient.go#L117-L119 |
124,989 | apcera/util | restclient/restclient.go | Result | func (c *Client) Result(req *Request, resp interface{}) error {
result, err := c.Do(req)
if err != nil {
return err
}
return unmarshal(result, resp)
} | go | func (c *Client) Result(req *Request, resp interface{}) error {
result, err := c.Do(req)
if err != nil {
return err
}
return unmarshal(result, resp)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Result",
"(",
"req",
"*",
"Request",
",",
"resp",
"interface",
"{",
"}",
")",
"error",
"{",
"result",
",",
"err",
":=",
"c",
".",
"Do",
"(",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err"... | // Result performs the request described by req and unmarshals a successful
// HTTP response into resp. If resp is nil, the response is discarded. | [
"Result",
"performs",
"the",
"request",
"described",
"by",
"req",
"and",
"unmarshals",
"a",
"successful",
"HTTP",
"response",
"into",
"resp",
".",
"If",
"resp",
"is",
"nil",
"the",
"response",
"is",
"discarded",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/restclient/restclient.go#L155-L161 |
124,990 | apcera/util | restclient/restclient.go | NewRequest | func (c *Client) NewRequest(method Method, endpoint string, ctype string, body io.Reader) (req *Request) {
req = c.newRequest(method, endpoint)
if body == nil {
return
}
req.prepare = func(hr *http.Request) error {
rc, ok := body.(io.ReadCloser)
if !ok {
rc = ioutil.NopCloser(body)
}
hr.Body = rc
hr... | go | func (c *Client) NewRequest(method Method, endpoint string, ctype string, body io.Reader) (req *Request) {
req = c.newRequest(method, endpoint)
if body == nil {
return
}
req.prepare = func(hr *http.Request) error {
rc, ok := body.(io.ReadCloser)
if !ok {
rc = ioutil.NopCloser(body)
}
hr.Body = rc
hr... | [
"func",
"(",
"c",
"*",
"Client",
")",
"NewRequest",
"(",
"method",
"Method",
",",
"endpoint",
"string",
",",
"ctype",
"string",
",",
"body",
"io",
".",
"Reader",
")",
"(",
"req",
"*",
"Request",
")",
"{",
"req",
"=",
"c",
".",
"newRequest",
"(",
"m... | // NewRequest generates a new Request object that will send bytes read from body
// to the endpoint. | [
"NewRequest",
"generates",
"a",
"new",
"Request",
"object",
"that",
"will",
"send",
"bytes",
"read",
"from",
"body",
"to",
"the",
"endpoint",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/restclient/restclient.go#L194-L210 |
124,991 | apcera/util | restclient/restclient.go | NewJsonRequest | func (c *Client) NewJsonRequest(method Method, endpoint string, obj interface{}) (req *Request) {
req = c.newRequest(method, endpoint)
if obj == nil {
return
}
req.prepare = func(httpReq *http.Request) error {
var buffer bytes.Buffer
encoder := json.NewEncoder(&buffer)
if err := encoder.Encode(obj); err !=... | go | func (c *Client) NewJsonRequest(method Method, endpoint string, obj interface{}) (req *Request) {
req = c.newRequest(method, endpoint)
if obj == nil {
return
}
req.prepare = func(httpReq *http.Request) error {
var buffer bytes.Buffer
encoder := json.NewEncoder(&buffer)
if err := encoder.Encode(obj); err !=... | [
"func",
"(",
"c",
"*",
"Client",
")",
"NewJsonRequest",
"(",
"method",
"Method",
",",
"endpoint",
"string",
",",
"obj",
"interface",
"{",
"}",
")",
"(",
"req",
"*",
"Request",
")",
"{",
"req",
"=",
"c",
".",
"newRequest",
"(",
"method",
",",
"endpoin... | // NewJsonRequest generates a new Request object and JSON encodes the provided
// obj. The JSON object will be set as the body and included in the request. | [
"NewJsonRequest",
"generates",
"a",
"new",
"Request",
"object",
"and",
"JSON",
"encodes",
"the",
"provided",
"obj",
".",
"The",
"JSON",
"object",
"will",
"be",
"set",
"as",
"the",
"body",
"and",
"included",
"in",
"the",
"request",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/restclient/restclient.go#L214-L235 |
124,992 | apcera/util | restclient/restclient.go | NewFormRequest | func (c *Client) NewFormRequest(method Method, endpoint string, params map[string]string) *Request {
req := c.newRequest(method, endpoint)
// set how to generate the body
req.prepare = func(httpReq *http.Request) error {
form := url.Values{}
for k, v := range params {
form.Set(k, v)
}
encoded := form.Enc... | go | func (c *Client) NewFormRequest(method Method, endpoint string, params map[string]string) *Request {
req := c.newRequest(method, endpoint)
// set how to generate the body
req.prepare = func(httpReq *http.Request) error {
form := url.Values{}
for k, v := range params {
form.Set(k, v)
}
encoded := form.Enc... | [
"func",
"(",
"c",
"*",
"Client",
")",
"NewFormRequest",
"(",
"method",
"Method",
",",
"endpoint",
"string",
",",
"params",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"Request",
"{",
"req",
":=",
"c",
".",
"newRequest",
"(",
"method",
",",
"endpoint... | // NewFormRequest generates a new Request object with a form encoded body based
// on the params map. | [
"NewFormRequest",
"generates",
"a",
"new",
"Request",
"object",
"with",
"a",
"form",
"encoded",
"body",
"based",
"on",
"the",
"params",
"map",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/restclient/restclient.go#L239-L258 |
124,993 | apcera/util | hashutil/sha1util.go | NewSha1 | func NewSha1(r io.Reader) *Sha1Reader {
s := new(Sha1Reader)
s.hashReader = newHashReader(sha1.New(), r)
return s
} | go | func NewSha1(r io.Reader) *Sha1Reader {
s := new(Sha1Reader)
s.hashReader = newHashReader(sha1.New(), r)
return s
} | [
"func",
"NewSha1",
"(",
"r",
"io",
".",
"Reader",
")",
"*",
"Sha1Reader",
"{",
"s",
":=",
"new",
"(",
"Sha1Reader",
")",
"\n",
"s",
".",
"hashReader",
"=",
"newHashReader",
"(",
"sha1",
".",
"New",
"(",
")",
",",
"r",
")",
"\n",
"return",
"s",
"\... | // Returns a new Sha1Reader. | [
"Returns",
"a",
"new",
"Sha1Reader",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/hashutil/sha1util.go#L34-L38 |
124,994 | apcera/util | hashutil/sha1util.go | Sha1 | func (s *Sha1Reader) Sha1() string {
return hex.EncodeToString(s.hash.Sum(nil))
} | go | func (s *Sha1Reader) Sha1() string {
return hex.EncodeToString(s.hash.Sum(nil))
} | [
"func",
"(",
"s",
"*",
"Sha1Reader",
")",
"Sha1",
"(",
")",
"string",
"{",
"return",
"hex",
".",
"EncodeToString",
"(",
"s",
".",
"hash",
".",
"Sum",
"(",
"nil",
")",
")",
"\n",
"}"
] | // Returns the SHA1 for all data that has been passed through this Reader
// already. This should ideally be called after the Reader is Closed, but
// otherwise its safe to call any time. | [
"Returns",
"the",
"SHA1",
"for",
"all",
"data",
"that",
"has",
"been",
"passed",
"through",
"this",
"Reader",
"already",
".",
"This",
"should",
"ideally",
"be",
"called",
"after",
"the",
"Reader",
"is",
"Closed",
"but",
"otherwise",
"its",
"safe",
"to",
"c... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/hashutil/sha1util.go#L43-L45 |
124,995 | apcera/util | iprange/allocator.go | NewAllocator | func NewAllocator(ipr *IPRange) *IPRangeAllocator {
a := &IPRangeAllocator{
ipRange: ipr,
reserved: make(map[int64]bool),
startIsIPv4: bytes.Compare(ipr.Start.To16()[0:12], ipv6in4) == 0,
}
// calculate the size of the range
a.startBig = big.NewInt(0)
a.startBig.SetBytes(a.ipRange.Start)
endBig := b... | go | func NewAllocator(ipr *IPRange) *IPRangeAllocator {
a := &IPRangeAllocator{
ipRange: ipr,
reserved: make(map[int64]bool),
startIsIPv4: bytes.Compare(ipr.Start.To16()[0:12], ipv6in4) == 0,
}
// calculate the size of the range
a.startBig = big.NewInt(0)
a.startBig.SetBytes(a.ipRange.Start)
endBig := b... | [
"func",
"NewAllocator",
"(",
"ipr",
"*",
"IPRange",
")",
"*",
"IPRangeAllocator",
"{",
"a",
":=",
"&",
"IPRangeAllocator",
"{",
"ipRange",
":",
"ipr",
",",
"reserved",
":",
"make",
"(",
"map",
"[",
"int64",
"]",
"bool",
")",
",",
"startIsIPv4",
":",
"b... | // NewAllocator creates a new IPRangeAllocator for the provided IPRange. | [
"NewAllocator",
"creates",
"a",
"new",
"IPRangeAllocator",
"for",
"the",
"provided",
"IPRange",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/iprange/allocator.go#L29-L48 |
124,996 | apcera/util | iprange/allocator.go | Allocate | func (a *IPRangeAllocator) Allocate() net.IP {
a.mutex.Lock()
defer a.mutex.Unlock()
// ensure we have some IPs first
if a.remaining <= 0 {
return nil
}
// get a random number within the size to start with
idx := rand.Int63n(a.size)
// find the next available index after the random number that is available... | go | func (a *IPRangeAllocator) Allocate() net.IP {
a.mutex.Lock()
defer a.mutex.Unlock()
// ensure we have some IPs first
if a.remaining <= 0 {
return nil
}
// get a random number within the size to start with
idx := rand.Int63n(a.size)
// find the next available index after the random number that is available... | [
"func",
"(",
"a",
"*",
"IPRangeAllocator",
")",
"Allocate",
"(",
")",
"net",
".",
"IP",
"{",
"a",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"// ensure we have some IPs first",
"if",
"a",
"... | // Allocate can be used to allocate a new IP address within the provided
// range. It will ensure that it is unique. If the allocator has no additional
// IP addresses available, then it will return nil. | [
"Allocate",
"can",
"be",
"used",
"to",
"allocate",
"a",
"new",
"IP",
"address",
"within",
"the",
"provided",
"range",
".",
"It",
"will",
"ensure",
"that",
"it",
"is",
"unique",
".",
"If",
"the",
"allocator",
"has",
"no",
"additional",
"IP",
"addresses",
... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/iprange/allocator.go#L53-L82 |
124,997 | apcera/util | iprange/allocator.go | Reserve | func (a *IPRangeAllocator) Reserve(ip net.IP) {
a.mutex.Lock()
defer a.mutex.Unlock()
// ensure the specified IP is within the range
if !a.ipRange.Contains(ip) {
return
}
// calculate the idx from the start
ipBig := big.NewInt(0)
ipBig.SetBytes(ip)
idx := ipBig.Sub(ipBig, a.startBig).Int64()
// if it isn... | go | func (a *IPRangeAllocator) Reserve(ip net.IP) {
a.mutex.Lock()
defer a.mutex.Unlock()
// ensure the specified IP is within the range
if !a.ipRange.Contains(ip) {
return
}
// calculate the idx from the start
ipBig := big.NewInt(0)
ipBig.SetBytes(ip)
idx := ipBig.Sub(ipBig, a.startBig).Int64()
// if it isn... | [
"func",
"(",
"a",
"*",
"IPRangeAllocator",
")",
"Reserve",
"(",
"ip",
"net",
".",
"IP",
")",
"{",
"a",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"// ensure the specified IP is within the range... | // Reserve allows reserving a specific IP address within the specified range to
// ensure it is not allocated. | [
"Reserve",
"allows",
"reserving",
"a",
"specific",
"IP",
"address",
"within",
"the",
"specified",
"range",
"to",
"ensure",
"it",
"is",
"not",
"allocated",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/iprange/allocator.go#L86-L106 |
124,998 | apcera/util | iprange/allocator.go | Release | func (a *IPRangeAllocator) Release(ip net.IP) {
a.mutex.Lock()
defer a.mutex.Unlock()
// calculate the idx from the start
ipBig := big.NewInt(0)
ipBig.SetBytes(ip)
idx := ipBig.Sub(ipBig, a.startBig).Int64()
// check if the idx is reserved
if a.reserved[idx] {
delete(a.reserved, idx)
a.remaining++
}
} | go | func (a *IPRangeAllocator) Release(ip net.IP) {
a.mutex.Lock()
defer a.mutex.Unlock()
// calculate the idx from the start
ipBig := big.NewInt(0)
ipBig.SetBytes(ip)
idx := ipBig.Sub(ipBig, a.startBig).Int64()
// check if the idx is reserved
if a.reserved[idx] {
delete(a.reserved, idx)
a.remaining++
}
} | [
"func",
"(",
"a",
"*",
"IPRangeAllocator",
")",
"Release",
"(",
"ip",
"net",
".",
"IP",
")",
"{",
"a",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"// calculate the idx from the start",
"ipBig... | // Release can be used to release an IP address that had previously been
// allocated or reserved. | [
"Release",
"can",
"be",
"used",
"to",
"release",
"an",
"IP",
"address",
"that",
"had",
"previously",
"been",
"allocated",
"or",
"reserved",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/iprange/allocator.go#L110-L124 |
124,999 | apcera/util | iprange/allocator.go | Subtract | func (a *IPRangeAllocator) Subtract(iprange *IPRange) {
curBig := big.NewInt(0)
curBig.SetBytes(iprange.Start)
endBig := big.NewInt(0)
endBig.SetBytes(iprange.End)
for ; curBig.Cmp(endBig) < 1; curBig = curBig.Add(big.NewInt(1), curBig) {
ip := a.bigIntToIP(curBig)
if a.ipRange.Contains(ip) {
a.Reserve(ip)... | go | func (a *IPRangeAllocator) Subtract(iprange *IPRange) {
curBig := big.NewInt(0)
curBig.SetBytes(iprange.Start)
endBig := big.NewInt(0)
endBig.SetBytes(iprange.End)
for ; curBig.Cmp(endBig) < 1; curBig = curBig.Add(big.NewInt(1), curBig) {
ip := a.bigIntToIP(curBig)
if a.ipRange.Contains(ip) {
a.Reserve(ip)... | [
"func",
"(",
"a",
"*",
"IPRangeAllocator",
")",
"Subtract",
"(",
"iprange",
"*",
"IPRange",
")",
"{",
"curBig",
":=",
"big",
".",
"NewInt",
"(",
"0",
")",
"\n",
"curBig",
".",
"SetBytes",
"(",
"iprange",
".",
"Start",
")",
"\n",
"endBig",
":=",
"big"... | // Subtract marks all of the IPs from another IPRange as reserved in the current
// allocator. | [
"Subtract",
"marks",
"all",
"of",
"the",
"IPs",
"from",
"another",
"IPRange",
"as",
"reserved",
"in",
"the",
"current",
"allocator",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/iprange/allocator.go#L128-L140 |
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.