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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
123,800 | influxdata/influxdb | task/options/options.go | MustParseDuration | func MustParseDuration(s string) (dur *Duration) {
dur = &Duration{}
if err := dur.Parse(s); err != nil {
panic(err)
}
return dur
} | go | func MustParseDuration(s string) (dur *Duration) {
dur = &Duration{}
if err := dur.Parse(s); err != nil {
panic(err)
}
return dur
} | [
"func",
"MustParseDuration",
"(",
"s",
"string",
")",
"(",
"dur",
"*",
"Duration",
")",
"{",
"dur",
"=",
"&",
"Duration",
"{",
"}",
"\n",
"if",
"err",
":=",
"dur",
".",
"Parse",
"(",
"s",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
... | // MustParseDuration parses a string and returns a duration. It panics if there is an error. | [
"MustParseDuration",
"parses",
"a",
"string",
"and",
"returns",
"a",
"duration",
".",
"It",
"panics",
"if",
"there",
"is",
"an",
"error",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/task/options/options.go#L78-L84 |
123,801 | influxdata/influxdb | task/options/options.go | parseSignedDuration | func parseSignedDuration(text string) (*ast.DurationLiteral, error) {
q, err := parser.ParseSignedDuration(text)
if err != nil {
return nil, err
}
q.BaseNode = ast.BaseNode{}
return q, err
} | go | func parseSignedDuration(text string) (*ast.DurationLiteral, error) {
q, err := parser.ParseSignedDuration(text)
if err != nil {
return nil, err
}
q.BaseNode = ast.BaseNode{}
return q, err
} | [
"func",
"parseSignedDuration",
"(",
"text",
"string",
")",
"(",
"*",
"ast",
".",
"DurationLiteral",
",",
"error",
")",
"{",
"q",
",",
"err",
":=",
"parser",
".",
"ParseSignedDuration",
"(",
"text",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"n... | // parseSignedDuration is a helper wrapper around parser.ParseSignedDuration.
// We use it because we need to clear the basenode, but flux does not. | [
"parseSignedDuration",
"is",
"a",
"helper",
"wrapper",
"around",
"parser",
".",
"ParseSignedDuration",
".",
"We",
"use",
"it",
"because",
"we",
"need",
"to",
"clear",
"the",
"basenode",
"but",
"flux",
"does",
"not",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/task/options/options.go#L88-L95 |
123,802 | influxdata/influxdb | task/options/options.go | UnmarshalText | func (a *Duration) UnmarshalText(text []byte) error {
q, err := parseSignedDuration(string(text))
if err != nil {
return err
}
a.Node = *q
return nil
} | go | func (a *Duration) UnmarshalText(text []byte) error {
q, err := parseSignedDuration(string(text))
if err != nil {
return err
}
a.Node = *q
return nil
} | [
"func",
"(",
"a",
"*",
"Duration",
")",
"UnmarshalText",
"(",
"text",
"[",
"]",
"byte",
")",
"error",
"{",
"q",
",",
"err",
":=",
"parseSignedDuration",
"(",
"string",
"(",
"text",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n... | // UnmarshalText unmarshals text into a Duration. | [
"UnmarshalText",
"unmarshals",
"text",
"into",
"a",
"Duration",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/task/options/options.go#L98-L105 |
123,803 | influxdata/influxdb | task/options/options.go | IsZero | func (a *Duration) IsZero() bool {
for i := range a.Node.Values {
if a.Node.Values[i].Magnitude != 0 {
return false
}
}
return true
} | go | func (a *Duration) IsZero() bool {
for i := range a.Node.Values {
if a.Node.Values[i].Magnitude != 0 {
return false
}
}
return true
} | [
"func",
"(",
"a",
"*",
"Duration",
")",
"IsZero",
"(",
")",
"bool",
"{",
"for",
"i",
":=",
"range",
"a",
".",
"Node",
".",
"Values",
"{",
"if",
"a",
".",
"Node",
".",
"Values",
"[",
"i",
"]",
".",
"Magnitude",
"!=",
"0",
"{",
"return",
"false",... | // IsZero checks if each segment of the duration is zero, it doesn't check if the Duration sums to zero, just if each internal duration is zero. | [
"IsZero",
"checks",
"if",
"each",
"segment",
"of",
"the",
"duration",
"is",
"zero",
"it",
"doesn",
"t",
"check",
"if",
"the",
"Duration",
"sums",
"to",
"zero",
"just",
"if",
"each",
"internal",
"duration",
"is",
"zero",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/task/options/options.go#L113-L120 |
123,804 | influxdata/influxdb | task/options/options.go | DurationFrom | func (a *Duration) DurationFrom(t time.Time) (time.Duration, error) {
return ast.DurationFrom(&a.Node, t)
} | go | func (a *Duration) DurationFrom(t time.Time) (time.Duration, error) {
return ast.DurationFrom(&a.Node, t)
} | [
"func",
"(",
"a",
"*",
"Duration",
")",
"DurationFrom",
"(",
"t",
"time",
".",
"Time",
")",
"(",
"time",
".",
"Duration",
",",
"error",
")",
"{",
"return",
"ast",
".",
"DurationFrom",
"(",
"&",
"a",
".",
"Node",
",",
"t",
")",
"\n",
"}"
] | // DurationFrom gives us a time.Duration from a time.
// Currently because of how flux works, this is just an approfimation for any time unit larger than hours. | [
"DurationFrom",
"gives",
"us",
"a",
"time",
".",
"Duration",
"from",
"a",
"time",
".",
"Currently",
"because",
"of",
"how",
"flux",
"works",
"this",
"is",
"just",
"an",
"approfimation",
"for",
"any",
"time",
"unit",
"larger",
"than",
"hours",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/task/options/options.go#L124-L126 |
123,805 | influxdata/influxdb | task/options/options.go | Add | func (a *Duration) Add(t time.Time) (time.Time, error) {
d, err := ast.DurationFrom(&a.Node, t)
if err != nil {
return time.Time{}, err
}
return t.Add(d), nil
} | go | func (a *Duration) Add(t time.Time) (time.Time, error) {
d, err := ast.DurationFrom(&a.Node, t)
if err != nil {
return time.Time{}, err
}
return t.Add(d), nil
} | [
"func",
"(",
"a",
"*",
"Duration",
")",
"Add",
"(",
"t",
"time",
".",
"Time",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"d",
",",
"err",
":=",
"ast",
".",
"DurationFrom",
"(",
"&",
"a",
".",
"Node",
",",
"t",
")",
"\n",
"if",
"... | // Add adds the duration to a time. | [
"Add",
"adds",
"the",
"duration",
"to",
"a",
"time",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/task/options/options.go#L129-L135 |
123,806 | influxdata/influxdb | task/options/options.go | Clear | func (o *Options) Clear() {
o.Name = ""
o.Cron = ""
o.Every = Duration{}
o.Offset = nil
o.Concurrency = nil
o.Retry = nil
} | go | func (o *Options) Clear() {
o.Name = ""
o.Cron = ""
o.Every = Duration{}
o.Offset = nil
o.Concurrency = nil
o.Retry = nil
} | [
"func",
"(",
"o",
"*",
"Options",
")",
"Clear",
"(",
")",
"{",
"o",
".",
"Name",
"=",
"\"",
"\"",
"\n",
"o",
".",
"Cron",
"=",
"\"",
"\"",
"\n",
"o",
".",
"Every",
"=",
"Duration",
"{",
"}",
"\n",
"o",
".",
"Offset",
"=",
"nil",
"\n",
"o",
... | // Clear clears out all options in the options struct, it us useful if you wish to reuse it. | [
"Clear",
"clears",
"out",
"all",
"options",
"in",
"the",
"options",
"struct",
"it",
"us",
"useful",
"if",
"you",
"wish",
"to",
"reuse",
"it",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/task/options/options.go#L138-L145 |
123,807 | influxdata/influxdb | task/options/options.go | IsZero | func (o *Options) IsZero() bool {
return o.Name == "" &&
o.Cron == "" &&
o.Every.IsZero() &&
o.Offset == nil &&
o.Concurrency == nil &&
o.Retry == nil
} | go | func (o *Options) IsZero() bool {
return o.Name == "" &&
o.Cron == "" &&
o.Every.IsZero() &&
o.Offset == nil &&
o.Concurrency == nil &&
o.Retry == nil
} | [
"func",
"(",
"o",
"*",
"Options",
")",
"IsZero",
"(",
")",
"bool",
"{",
"return",
"o",
".",
"Name",
"==",
"\"",
"\"",
"&&",
"o",
".",
"Cron",
"==",
"\"",
"\"",
"&&",
"o",
".",
"Every",
".",
"IsZero",
"(",
")",
"&&",
"o",
".",
"Offset",
"==",
... | // IsZero tells us if the options has been zeroed out. | [
"IsZero",
"tells",
"us",
"if",
"the",
"options",
"has",
"been",
"zeroed",
"out",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/task/options/options.go#L148-L155 |
123,808 | influxdata/influxdb | task/options/options.go | contains | func contains(s []string, e string) bool {
for i := range s {
if s[i] == e {
return true
}
}
return false
} | go | func contains(s []string, e string) bool {
for i := range s {
if s[i] == e {
return true
}
}
return false
} | [
"func",
"contains",
"(",
"s",
"[",
"]",
"string",
",",
"e",
"string",
")",
"bool",
"{",
"for",
"i",
":=",
"range",
"s",
"{",
"if",
"s",
"[",
"i",
"]",
"==",
"e",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
... | // contains is a helper function to see if an array of strings contains a string | [
"contains",
"is",
"a",
"helper",
"function",
"to",
"see",
"if",
"an",
"array",
"of",
"strings",
"contains",
"a",
"string"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/task/options/options.go#L168-L175 |
123,809 | influxdata/influxdb | task/options/options.go | Validate | func (o *Options) Validate() error {
now := time.Now()
var errs []string
if o.Name == "" {
errs = append(errs, "name required")
}
cronPresent := o.Cron != ""
everyPresent := !o.Every.IsZero()
if cronPresent == everyPresent {
// They're both present or both missing.
errs = append(errs, "must specify exactl... | go | func (o *Options) Validate() error {
now := time.Now()
var errs []string
if o.Name == "" {
errs = append(errs, "name required")
}
cronPresent := o.Cron != ""
everyPresent := !o.Every.IsZero()
if cronPresent == everyPresent {
// They're both present or both missing.
errs = append(errs, "must specify exactl... | [
"func",
"(",
"o",
"*",
"Options",
")",
"Validate",
"(",
")",
"error",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"var",
"errs",
"[",
"]",
"string",
"\n",
"if",
"o",
".",
"Name",
"==",
"\"",
"\"",
"{",
"errs",
"=",
"append",
"(",
"e... | // Validate returns an error if the options aren't valid. | [
"Validate",
"returns",
"an",
"error",
"if",
"the",
"options",
"aren",
"t",
"valid",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/task/options/options.go#L341-L399 |
123,810 | influxdata/influxdb | task/options/options.go | checkNature | func checkNature(got, exp semantic.Nature) error {
if got != exp {
return fmt.Errorf("unexpected kind: got %q expected %q", got, exp)
}
return nil
} | go | func checkNature(got, exp semantic.Nature) error {
if got != exp {
return fmt.Errorf("unexpected kind: got %q expected %q", got, exp)
}
return nil
} | [
"func",
"checkNature",
"(",
"got",
",",
"exp",
"semantic",
".",
"Nature",
")",
"error",
"{",
"if",
"got",
"!=",
"exp",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"got",
",",
"exp",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
... | // checkNature returns a clean error of got and expected dont match. | [
"checkNature",
"returns",
"a",
"clean",
"error",
"of",
"got",
"and",
"expected",
"dont",
"match",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/task/options/options.go#L421-L426 |
123,811 | influxdata/influxdb | task/options/options.go | validateOptionNames | func validateOptionNames(o values.Object) error {
var unexpected []string
o.Range(func(name string, _ values.Value) {
switch name {
case optName, optCron, optEvery, optOffset, optConcurrency, optRetry:
// Known option. Nothing to do.
default:
unexpected = append(unexpected, name)
}
})
if len(unexpect... | go | func validateOptionNames(o values.Object) error {
var unexpected []string
o.Range(func(name string, _ values.Value) {
switch name {
case optName, optCron, optEvery, optOffset, optConcurrency, optRetry:
// Known option. Nothing to do.
default:
unexpected = append(unexpected, name)
}
})
if len(unexpect... | [
"func",
"validateOptionNames",
"(",
"o",
"values",
".",
"Object",
")",
"error",
"{",
"var",
"unexpected",
"[",
"]",
"string",
"\n",
"o",
".",
"Range",
"(",
"func",
"(",
"name",
"string",
",",
"_",
"values",
".",
"Value",
")",
"{",
"switch",
"name",
"... | // validateOptionNames returns an error if any keys in the option object o
// do not match an expected option name. | [
"validateOptionNames",
"returns",
"an",
"error",
"if",
"any",
"keys",
"in",
"the",
"option",
"object",
"o",
"do",
"not",
"match",
"an",
"expected",
"option",
"name",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/task/options/options.go#L430-L448 |
123,812 | influxdata/influxdb | mock/write_service.go | Write | func (s *WriteService) Write(ctx context.Context, org, bucket platform.ID, r io.Reader) error {
return s.WriteF(ctx, org, bucket, r)
} | go | func (s *WriteService) Write(ctx context.Context, org, bucket platform.ID, r io.Reader) error {
return s.WriteF(ctx, org, bucket, r)
} | [
"func",
"(",
"s",
"*",
"WriteService",
")",
"Write",
"(",
"ctx",
"context",
".",
"Context",
",",
"org",
",",
"bucket",
"platform",
".",
"ID",
",",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"return",
"s",
".",
"WriteF",
"(",
"ctx",
",",
"org",
... | // Write calls the mocked WriteF function with arguments. | [
"Write",
"calls",
"the",
"mocked",
"WriteF",
"function",
"with",
"arguments",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/mock/write_service.go#L16-L18 |
123,813 | influxdata/influxdb | chronograf/server/permissions.go | Permissions | func (s *Service) Permissions(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
srcID, err := paramID("id", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
return
}
src, err := s.Store.Sources(ctx).Get(ctx, srcID)
if err != nil {
notFound(w, srcID, s.Logger)
... | go | func (s *Service) Permissions(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
srcID, err := paramID("id", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
return
}
src, err := s.Store.Sources(ctx).Get(ctx, srcID)
if err != nil {
notFound(w, srcID, s.Logger)
... | [
"func",
"(",
"s",
"*",
"Service",
")",
"Permissions",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"ctx",
":=",
"r",
".",
"Context",
"(",
")",
"\n",
"srcID",
",",
"err",
":=",
"paramID",
"(",
"\"",
"\"... | // Permissions returns all possible permissions for this source. | [
"Permissions",
"returns",
"all",
"possible",
"permissions",
"for",
"this",
"source",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/server/permissions.go#L11-L55 |
123,814 | influxdata/influxdb | chronograf/server/annotations.go | Annotations | func (s *Service) Annotations(w http.ResponseWriter, r *http.Request) {
id, err := paramID("id", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
return
}
start, stop, err := validAnnotationQuery(r.URL.Query())
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Er... | go | func (s *Service) Annotations(w http.ResponseWriter, r *http.Request) {
id, err := paramID("id", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
return
}
start, stop, err := validAnnotationQuery(r.URL.Query())
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Er... | [
"func",
"(",
"s",
"*",
"Service",
")",
"Annotations",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"id",
",",
"err",
":=",
"paramID",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"... | // Annotations returns all annotations within the annotations store | [
"Annotations",
"returns",
"all",
"annotations",
"within",
"the",
"annotations",
"store"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/server/annotations.go#L94-L137 |
123,815 | influxdata/influxdb | chronograf/server/annotations.go | Annotation | func (s *Service) Annotation(w http.ResponseWriter, r *http.Request) {
id, err := paramID("id", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
return
}
annoID, err := paramStr("aid", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
retur... | go | func (s *Service) Annotation(w http.ResponseWriter, r *http.Request) {
id, err := paramID("id", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
return
}
annoID, err := paramStr("aid", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
retur... | [
"func",
"(",
"s",
"*",
"Service",
")",
"Annotation",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"id",
",",
"err",
":=",
"paramID",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{... | // Annotation returns a specified annotation id within the annotations store | [
"Annotation",
"returns",
"a",
"specified",
"annotation",
"id",
"within",
"the",
"annotations",
"store"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/server/annotations.go#L140-L186 |
123,816 | influxdata/influxdb | chronograf/server/annotations.go | NewAnnotation | func (s *Service) NewAnnotation(w http.ResponseWriter, r *http.Request) {
id, err := paramID("id", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
return
}
ctx := r.Context()
src, err := s.Store.Sources(ctx).Get(ctx, id)
if err != nil {
notFound(w, id, s.Logger)
return
... | go | func (s *Service) NewAnnotation(w http.ResponseWriter, r *http.Request) {
id, err := paramID("id", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
return
}
ctx := r.Context()
src, err := s.Store.Sources(ctx).Get(ctx, id)
if err != nil {
notFound(w, id, s.Logger)
return
... | [
"func",
"(",
"s",
"*",
"Service",
")",
"NewAnnotation",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"id",
",",
"err",
":=",
"paramID",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // NewAnnotation adds the annotation from a POST body to the annotations store | [
"NewAnnotation",
"adds",
"the",
"annotation",
"from",
"a",
"POST",
"body",
"to",
"the",
"annotations",
"store"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/server/annotations.go#L236-L284 |
123,817 | influxdata/influxdb | chronograf/server/annotations.go | RemoveAnnotation | func (s *Service) RemoveAnnotation(w http.ResponseWriter, r *http.Request) {
id, err := paramID("id", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
return
}
annoID, err := paramStr("aid", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
... | go | func (s *Service) RemoveAnnotation(w http.ResponseWriter, r *http.Request) {
id, err := paramID("id", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
return
}
annoID, err := paramStr("aid", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
... | [
"func",
"(",
"s",
"*",
"Service",
")",
"RemoveAnnotation",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"id",
",",
"err",
":=",
"paramID",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil"... | // RemoveAnnotation removes the annotation from the time series source | [
"RemoveAnnotation",
"removes",
"the",
"annotation",
"from",
"the",
"time",
"series",
"source"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/server/annotations.go#L287-L332 |
123,818 | influxdata/influxdb | chronograf/server/annotations.go | UpdateAnnotation | func (s *Service) UpdateAnnotation(w http.ResponseWriter, r *http.Request) {
id, err := paramID("id", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
return
}
annoID, err := paramStr("aid", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
... | go | func (s *Service) UpdateAnnotation(w http.ResponseWriter, r *http.Request) {
id, err := paramID("id", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
return
}
annoID, err := paramStr("aid", r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
... | [
"func",
"(",
"s",
"*",
"Service",
")",
"UpdateAnnotation",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"id",
",",
"err",
":=",
"paramID",
"(",
"\"",
"\"",
",",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil"... | // UpdateAnnotation overwrite an existing annotation | [
"UpdateAnnotation",
"overwrite",
"an",
"existing",
"annotation"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/server/annotations.go#L380-L452 |
123,819 | influxdata/influxdb | chronograf/filestore/organizations.go | NewOrganizations | func NewOrganizations(dir string, logger chronograf.Logger) chronograf.OrganizationsStore {
return &Organizations{
Dir: dir,
Load: load,
ReadDir: ioutil.ReadDir,
Logger: logger,
}
} | go | func NewOrganizations(dir string, logger chronograf.Logger) chronograf.OrganizationsStore {
return &Organizations{
Dir: dir,
Load: load,
ReadDir: ioutil.ReadDir,
Logger: logger,
}
} | [
"func",
"NewOrganizations",
"(",
"dir",
"string",
",",
"logger",
"chronograf",
".",
"Logger",
")",
"chronograf",
".",
"OrganizationsStore",
"{",
"return",
"&",
"Organizations",
"{",
"Dir",
":",
"dir",
",",
"Load",
":",
"load",
",",
"ReadDir",
":",
"ioutil",
... | // NewOrganizations constructs a org store wrapping a file system directory | [
"NewOrganizations",
"constructs",
"a",
"org",
"store",
"wrapping",
"a",
"file",
"system",
"directory"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/filestore/organizations.go#L27-L34 |
123,820 | influxdata/influxdb | chronograf/filestore/organizations.go | All | func (o *Organizations) All(ctx context.Context) ([]chronograf.Organization, error) {
files, err := o.ReadDir(o.Dir)
if err != nil {
return nil, err
}
orgs := []chronograf.Organization{}
for _, file := range files {
if path.Ext(file.Name()) != OrgExt {
continue
}
var org chronograf.Organization
if er... | go | func (o *Organizations) All(ctx context.Context) ([]chronograf.Organization, error) {
files, err := o.ReadDir(o.Dir)
if err != nil {
return nil, err
}
orgs := []chronograf.Organization{}
for _, file := range files {
if path.Ext(file.Name()) != OrgExt {
continue
}
var org chronograf.Organization
if er... | [
"func",
"(",
"o",
"*",
"Organizations",
")",
"All",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"chronograf",
".",
"Organization",
",",
"error",
")",
"{",
"files",
",",
"err",
":=",
"o",
".",
"ReadDir",
"(",
"o",
".",
"Dir",
")",
"... | // All returns all orgs from the directory | [
"All",
"returns",
"all",
"orgs",
"from",
"the",
"directory"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/filestore/organizations.go#L37-L56 |
123,821 | influxdata/influxdb | chronograf/filestore/organizations.go | Get | func (o *Organizations) Get(ctx context.Context, query chronograf.OrganizationQuery) (*chronograf.Organization, error) {
org, _, err := o.findOrg(query)
return org, err
} | go | func (o *Organizations) Get(ctx context.Context, query chronograf.OrganizationQuery) (*chronograf.Organization, error) {
org, _, err := o.findOrg(query)
return org, err
} | [
"func",
"(",
"o",
"*",
"Organizations",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"chronograf",
".",
"OrganizationQuery",
")",
"(",
"*",
"chronograf",
".",
"Organization",
",",
"error",
")",
"{",
"org",
",",
"_",
",",
"err",
":="... | // Get returns a org file from the org directory | [
"Get",
"returns",
"a",
"org",
"file",
"from",
"the",
"org",
"directory"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/filestore/organizations.go#L59-L62 |
123,822 | influxdata/influxdb | chronograf/filestore/organizations.go | Add | func (o *Organizations) Add(ctx context.Context, org *chronograf.Organization) (*chronograf.Organization, error) {
return nil, fmt.Errorf("unable to add organizations to the filesystem")
} | go | func (o *Organizations) Add(ctx context.Context, org *chronograf.Organization) (*chronograf.Organization, error) {
return nil, fmt.Errorf("unable to add organizations to the filesystem")
} | [
"func",
"(",
"o",
"*",
"Organizations",
")",
"Add",
"(",
"ctx",
"context",
".",
"Context",
",",
"org",
"*",
"chronograf",
".",
"Organization",
")",
"(",
"*",
"chronograf",
".",
"Organization",
",",
"error",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
... | // Add is not allowed for the filesystem organization store | [
"Add",
"is",
"not",
"allowed",
"for",
"the",
"filesystem",
"organization",
"store"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/filestore/organizations.go#L65-L67 |
123,823 | influxdata/influxdb | chronograf/filestore/organizations.go | Delete | func (o *Organizations) Delete(ctx context.Context, org *chronograf.Organization) error {
return fmt.Errorf("unable to delete an organization from the filesystem")
} | go | func (o *Organizations) Delete(ctx context.Context, org *chronograf.Organization) error {
return fmt.Errorf("unable to delete an organization from the filesystem")
} | [
"func",
"(",
"o",
"*",
"Organizations",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"org",
"*",
"chronograf",
".",
"Organization",
")",
"error",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // Delete is not allowed for the filesystem organization store | [
"Delete",
"is",
"not",
"allowed",
"for",
"the",
"filesystem",
"organization",
"store"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/filestore/organizations.go#L70-L72 |
123,824 | influxdata/influxdb | chronograf/filestore/organizations.go | DefaultOrganization | func (o *Organizations) DefaultOrganization(ctx context.Context) (*chronograf.Organization, error) {
return nil, fmt.Errorf("unable to get default organizations from the filestore")
} | go | func (o *Organizations) DefaultOrganization(ctx context.Context) (*chronograf.Organization, error) {
return nil, fmt.Errorf("unable to get default organizations from the filestore")
} | [
"func",
"(",
"o",
"*",
"Organizations",
")",
"DefaultOrganization",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"chronograf",
".",
"Organization",
",",
"error",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",... | // DefaultOrganization is not allowed for the filesystem organization store | [
"DefaultOrganization",
"is",
"not",
"allowed",
"for",
"the",
"filesystem",
"organization",
"store"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/filestore/organizations.go#L85-L87 |
123,825 | influxdata/influxdb | chronograf/filestore/organizations.go | findOrg | func (o *Organizations) findOrg(query chronograf.OrganizationQuery) (*chronograf.Organization, string, error) {
// Because the entire org information is not known at this point, we need
// to try to find the name of the file through matching the ID or name in the org
// content with the ID passed.
files, err := o.R... | go | func (o *Organizations) findOrg(query chronograf.OrganizationQuery) (*chronograf.Organization, string, error) {
// Because the entire org information is not known at this point, we need
// to try to find the name of the file through matching the ID or name in the org
// content with the ID passed.
files, err := o.R... | [
"func",
"(",
"o",
"*",
"Organizations",
")",
"findOrg",
"(",
"query",
"chronograf",
".",
"OrganizationQuery",
")",
"(",
"*",
"chronograf",
".",
"Organization",
",",
"string",
",",
"error",
")",
"{",
"// Because the entire org information is not known at this point, we... | // findOrg takes an OrganizationQuery and finds the associated filename | [
"findOrg",
"takes",
"an",
"OrganizationQuery",
"and",
"finds",
"the",
"associated",
"filename"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/filestore/organizations.go#L90-L117 |
123,826 | influxdata/influxdb | vault/secret.go | loadSecrets | func (s *SecretService) loadSecrets(ctx context.Context, orgID platform.ID) (map[string]string, int, error) {
// TODO(desa): update url construction
sec, err := s.Client.Logical().Read(fmt.Sprintf("/secret/data/%s", orgID))
if err != nil {
return nil, -1, err
}
m := map[string]string{}
if sec == nil {
return... | go | func (s *SecretService) loadSecrets(ctx context.Context, orgID platform.ID) (map[string]string, int, error) {
// TODO(desa): update url construction
sec, err := s.Client.Logical().Read(fmt.Sprintf("/secret/data/%s", orgID))
if err != nil {
return nil, -1, err
}
m := map[string]string{}
if sec == nil {
return... | [
"func",
"(",
"s",
"*",
"SecretService",
")",
"loadSecrets",
"(",
"ctx",
"context",
".",
"Context",
",",
"orgID",
"platform",
".",
"ID",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"int",
",",
"error",
")",
"{",
"// TODO(desa): update url constructi... | // loadSecrets retrieves a map of secrets for an organization and the version of the secrets retrieved.
// The version is used to ensure that concurrent updates will not overwrite one another. | [
"loadSecrets",
"retrieves",
"a",
"map",
"of",
"secrets",
"for",
"an",
"organization",
"and",
"the",
"version",
"of",
"the",
"secrets",
"retrieved",
".",
"The",
"version",
"is",
"used",
"to",
"ensure",
"that",
"concurrent",
"updates",
"will",
"not",
"overwrite"... | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/vault/secret.go#L55-L106 |
123,827 | influxdata/influxdb | vault/secret.go | putSecrets | func (s *SecretService) putSecrets(ctx context.Context, orgID platform.ID, data map[string]string, version int) error {
m := map[string]interface{}{"data": data}
if version >= 0 {
m["options"] = map[string]interface{}{"cas": version}
}
if _, err := s.Client.Logical().Write(fmt.Sprintf("/secret/data/%s", orgID),... | go | func (s *SecretService) putSecrets(ctx context.Context, orgID platform.ID, data map[string]string, version int) error {
m := map[string]interface{}{"data": data}
if version >= 0 {
m["options"] = map[string]interface{}{"cas": version}
}
if _, err := s.Client.Logical().Write(fmt.Sprintf("/secret/data/%s", orgID),... | [
"func",
"(",
"s",
"*",
"SecretService",
")",
"putSecrets",
"(",
"ctx",
"context",
".",
"Context",
",",
"orgID",
"platform",
".",
"ID",
",",
"data",
"map",
"[",
"string",
"]",
"string",
",",
"version",
"int",
")",
"error",
"{",
"m",
":=",
"map",
"[",
... | // putSecrets will set all provided data values for the organization orgID.
// If version is negative, the write will overwrite all specified values.
// If version is 0, the write will only be allowed if the keys do not exists.
// If version is non-zero, the write will only be allowed if the keys current
// version in ... | [
"putSecrets",
"will",
"set",
"all",
"provided",
"data",
"values",
"for",
"the",
"organization",
"orgID",
".",
"If",
"version",
"is",
"negative",
"the",
"write",
"will",
"overwrite",
"all",
"specified",
"values",
".",
"If",
"version",
"is",
"0",
"the",
"write... | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/vault/secret.go#L140-L152 |
123,828 | influxdata/influxdb | gather/prometheus.go | makeLabels | func makeLabels(m *dto.Metric) map[string]string {
result := map[string]string{}
for _, lp := range m.Label {
result[lp.GetName()] = lp.GetValue()
}
return result
} | go | func makeLabels(m *dto.Metric) map[string]string {
result := map[string]string{}
for _, lp := range m.Label {
result[lp.GetName()] = lp.GetValue()
}
return result
} | [
"func",
"makeLabels",
"(",
"m",
"*",
"dto",
".",
"Metric",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"result",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"lp",
":=",
"range",
"m",
".",
"Label",
"{",
"result",... | // Get labels from metric | [
"Get",
"labels",
"from",
"metric"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/gather/prometheus.go#L115-L121 |
123,829 | influxdata/influxdb | gather/prometheus.go | makeBuckets | func makeBuckets(m *dto.Metric) map[string]interface{} {
fields := make(map[string]interface{})
for _, b := range m.GetHistogram().Bucket {
fields[fmt.Sprint(b.GetUpperBound())] = float64(b.GetCumulativeCount())
}
return fields
} | go | func makeBuckets(m *dto.Metric) map[string]interface{} {
fields := make(map[string]interface{})
for _, b := range m.GetHistogram().Bucket {
fields[fmt.Sprint(b.GetUpperBound())] = float64(b.GetCumulativeCount())
}
return fields
} | [
"func",
"makeBuckets",
"(",
"m",
"*",
"dto",
".",
"Metric",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"fields",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"for",
"_",
",",
"b",
":=",
"range",... | // Get Buckets from histogram metric | [
"Get",
"Buckets",
"from",
"histogram",
"metric"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/gather/prometheus.go#L124-L130 |
123,830 | influxdata/influxdb | gather/prometheus.go | getNameAndValue | func getNameAndValue(m *dto.Metric) map[string]interface{} {
fields := make(map[string]interface{})
if m.Gauge != nil {
if !math.IsNaN(m.GetGauge().GetValue()) {
fields["gauge"] = float64(m.GetGauge().GetValue())
}
} else if m.Counter != nil {
if !math.IsNaN(m.GetCounter().GetValue()) {
fields["counter"]... | go | func getNameAndValue(m *dto.Metric) map[string]interface{} {
fields := make(map[string]interface{})
if m.Gauge != nil {
if !math.IsNaN(m.GetGauge().GetValue()) {
fields["gauge"] = float64(m.GetGauge().GetValue())
}
} else if m.Counter != nil {
if !math.IsNaN(m.GetCounter().GetValue()) {
fields["counter"]... | [
"func",
"getNameAndValue",
"(",
"m",
"*",
"dto",
".",
"Metric",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"fields",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"if",
"m",
".",
"Gauge",
"!=",
"... | // Get name and value from metric | [
"Get",
"name",
"and",
"value",
"from",
"metric"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/gather/prometheus.go#L133-L149 |
123,831 | influxdata/influxdb | gather/prometheus.go | makeQuantiles | func makeQuantiles(m *dto.Metric) map[string]interface{} {
fields := make(map[string]interface{})
for _, q := range m.GetSummary().Quantile {
if !math.IsNaN(q.GetValue()) {
fields[fmt.Sprint(q.GetQuantile())] = float64(q.GetValue())
}
}
return fields
} | go | func makeQuantiles(m *dto.Metric) map[string]interface{} {
fields := make(map[string]interface{})
for _, q := range m.GetSummary().Quantile {
if !math.IsNaN(q.GetValue()) {
fields[fmt.Sprint(q.GetQuantile())] = float64(q.GetValue())
}
}
return fields
} | [
"func",
"makeQuantiles",
"(",
"m",
"*",
"dto",
".",
"Metric",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"fields",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"for",
"_",
",",
"q",
":=",
"range... | // Get Quantiles from summary metric | [
"Get",
"Quantiles",
"from",
"summary",
"metric"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/gather/prometheus.go#L152-L160 |
123,832 | influxdata/influxdb | chronograf/canned/bin.go | Add | func (s *BinLayoutsStore) Add(ctx context.Context, layout chronograf.Layout) (chronograf.Layout, error) {
return chronograf.Layout{}, fmt.Errorf("add to BinLayoutsStore not supported")
} | go | func (s *BinLayoutsStore) Add(ctx context.Context, layout chronograf.Layout) (chronograf.Layout, error) {
return chronograf.Layout{}, fmt.Errorf("add to BinLayoutsStore not supported")
} | [
"func",
"(",
"s",
"*",
"BinLayoutsStore",
")",
"Add",
"(",
"ctx",
"context",
".",
"Context",
",",
"layout",
"chronograf",
".",
"Layout",
")",
"(",
"chronograf",
".",
"Layout",
",",
"error",
")",
"{",
"return",
"chronograf",
".",
"Layout",
"{",
"}",
","... | // Add is not support by BinLayoutsStore | [
"Add",
"is",
"not",
"support",
"by",
"BinLayoutsStore"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/canned/bin.go#L47-L49 |
123,833 | influxdata/influxdb | chronograf/canned/bin.go | Get | func (s *BinLayoutsStore) Get(ctx context.Context, ID string) (chronograf.Layout, error) {
layouts, err := s.All(ctx)
if err != nil {
s.Logger.
WithField("component", "apps").
WithField("name", ID).
Error("Invalid Layout: ", err)
return chronograf.Layout{}, chronograf.ErrLayoutInvalid
}
for _, layout ... | go | func (s *BinLayoutsStore) Get(ctx context.Context, ID string) (chronograf.Layout, error) {
layouts, err := s.All(ctx)
if err != nil {
s.Logger.
WithField("component", "apps").
WithField("name", ID).
Error("Invalid Layout: ", err)
return chronograf.Layout{}, chronograf.ErrLayoutInvalid
}
for _, layout ... | [
"func",
"(",
"s",
"*",
"BinLayoutsStore",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"ID",
"string",
")",
"(",
"chronograf",
".",
"Layout",
",",
"error",
")",
"{",
"layouts",
",",
"err",
":=",
"s",
".",
"All",
"(",
"ctx",
")",
"\n",
... | // Get retrieves Layout if `ID` exists. | [
"Get",
"retrieves",
"Layout",
"if",
"ID",
"exists",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/canned/bin.go#L57-L78 |
123,834 | influxdata/influxdb | chronograf/canned/bin.go | Update | func (s *BinLayoutsStore) Update(ctx context.Context, layout chronograf.Layout) error {
return fmt.Errorf("update to BinLayoutsStore not supported")
} | go | func (s *BinLayoutsStore) Update(ctx context.Context, layout chronograf.Layout) error {
return fmt.Errorf("update to BinLayoutsStore not supported")
} | [
"func",
"(",
"s",
"*",
"BinLayoutsStore",
")",
"Update",
"(",
"ctx",
"context",
".",
"Context",
",",
"layout",
"chronograf",
".",
"Layout",
")",
"error",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // Update not supported | [
"Update",
"not",
"supported"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/canned/bin.go#L81-L83 |
123,835 | influxdata/influxdb | query/logger.go | Redact | func (q *Log) Redact() {
if q.ProxyRequest != nil && q.ProxyRequest.Request.Authorization != nil {
// Make shallow copy of request
request := new(ProxyRequest)
*request = *q.ProxyRequest
// Make shallow copy of authorization
auth := new(platform.Authorization)
*auth = *q.ProxyRequest.Request.Authorization... | go | func (q *Log) Redact() {
if q.ProxyRequest != nil && q.ProxyRequest.Request.Authorization != nil {
// Make shallow copy of request
request := new(ProxyRequest)
*request = *q.ProxyRequest
// Make shallow copy of authorization
auth := new(platform.Authorization)
*auth = *q.ProxyRequest.Request.Authorization... | [
"func",
"(",
"q",
"*",
"Log",
")",
"Redact",
"(",
")",
"{",
"if",
"q",
".",
"ProxyRequest",
"!=",
"nil",
"&&",
"q",
".",
"ProxyRequest",
".",
"Request",
".",
"Authorization",
"!=",
"nil",
"{",
"// Make shallow copy of request",
"request",
":=",
"new",
"(... | // Redact removes any sensitive information before logging | [
"Redact",
"removes",
"any",
"sensitive",
"information",
"before",
"logging"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/query/logger.go#L33-L51 |
123,836 | influxdata/influxdb | chronograf/bolt/client.go | NewClient | func NewClient() *Client {
c := &Client{Now: time.Now}
c.BuildStore = &BuildStore{client: c}
c.SourcesStore = &SourcesStore{client: c}
c.ServersStore = &ServersStore{client: c}
c.LayoutsStore = &LayoutsStore{
client: c,
IDs: &id.UUID{},
}
c.DashboardsStore = &DashboardsStore{
client: c,
IDs: &id.UU... | go | func NewClient() *Client {
c := &Client{Now: time.Now}
c.BuildStore = &BuildStore{client: c}
c.SourcesStore = &SourcesStore{client: c}
c.ServersStore = &ServersStore{client: c}
c.LayoutsStore = &LayoutsStore{
client: c,
IDs: &id.UUID{},
}
c.DashboardsStore = &DashboardsStore{
client: c,
IDs: &id.UU... | [
"func",
"NewClient",
"(",
")",
"*",
"Client",
"{",
"c",
":=",
"&",
"Client",
"{",
"Now",
":",
"time",
".",
"Now",
"}",
"\n",
"c",
".",
"BuildStore",
"=",
"&",
"BuildStore",
"{",
"client",
":",
"c",
"}",
"\n",
"c",
".",
"SourcesStore",
"=",
"&",
... | // NewClient initializes all stores | [
"NewClient",
"initializes",
"all",
"stores"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/bolt/client.go#L38-L57 |
123,837 | influxdata/influxdb | chronograf/bolt/client.go | migrate | func (c *Client) migrate(ctx context.Context, build chronograf.BuildInfo) error {
if c.db != nil {
// Runtime migrations
if err := c.OrganizationsStore.Migrate(ctx); err != nil {
return err
}
if err := c.SourcesStore.Migrate(ctx); err != nil {
return err
}
if err := c.ServersStore.Migrate(ctx); err !... | go | func (c *Client) migrate(ctx context.Context, build chronograf.BuildInfo) error {
if c.db != nil {
// Runtime migrations
if err := c.OrganizationsStore.Migrate(ctx); err != nil {
return err
}
if err := c.SourcesStore.Migrate(ctx); err != nil {
return err
}
if err := c.ServersStore.Migrate(ctx); err !... | [
"func",
"(",
"c",
"*",
"Client",
")",
"migrate",
"(",
"ctx",
"context",
".",
"Context",
",",
"build",
"chronograf",
".",
"BuildInfo",
")",
"error",
"{",
"if",
"c",
".",
"db",
"!=",
"nil",
"{",
"// Runtime migrations",
"if",
"err",
":=",
"c",
".",
"Or... | // migrate moves data from an old schema to a new schema in each Store | [
"migrate",
"moves",
"data",
"from",
"an",
"old",
"schema",
"to",
"a",
"new",
"schema",
"in",
"each",
"Store"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/bolt/client.go#L176-L210 |
123,838 | influxdata/influxdb | chronograf/bolt/client.go | copy | func (c *Client) copy(ctx context.Context, version string) error {
backupDir := path.Join(path.Dir(c.Path), "backup")
if _, err := os.Stat(backupDir); os.IsNotExist(err) {
if err = os.Mkdir(backupDir, 0700); err != nil {
return err
}
} else if err != nil {
return err
}
fromFile, err := os.Open(c.Path)
i... | go | func (c *Client) copy(ctx context.Context, version string) error {
backupDir := path.Join(path.Dir(c.Path), "backup")
if _, err := os.Stat(backupDir); os.IsNotExist(err) {
if err = os.Mkdir(backupDir, 0700); err != nil {
return err
}
} else if err != nil {
return err
}
fromFile, err := os.Open(c.Path)
i... | [
"func",
"(",
"c",
"*",
"Client",
")",
"copy",
"(",
"ctx",
"context",
".",
"Context",
",",
"version",
"string",
")",
"error",
"{",
"backupDir",
":=",
"path",
".",
"Join",
"(",
"path",
".",
"Dir",
"(",
"c",
".",
"Path",
")",
",",
"\"",
"\"",
")",
... | // copy creates a copy of the database in toFile | [
"copy",
"creates",
"a",
"copy",
"of",
"the",
"database",
"in",
"toFile"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/bolt/client.go#L221-L253 |
123,839 | influxdata/influxdb | chronograf/oauth2/cookies.go | NewCookieJWT | func NewCookieJWT(secret string, lifespan time.Duration) Authenticator {
inactivity := DefaultInactivityDuration
// Server interprets a token duration longer than the cookie lifespan as
// a token that was issued by a server with a longer auth-duration and is
// thus invalid, as a security precaution. So, inactivit... | go | func NewCookieJWT(secret string, lifespan time.Duration) Authenticator {
inactivity := DefaultInactivityDuration
// Server interprets a token duration longer than the cookie lifespan as
// a token that was issued by a server with a longer auth-duration and is
// thus invalid, as a security precaution. So, inactivit... | [
"func",
"NewCookieJWT",
"(",
"secret",
"string",
",",
"lifespan",
"time",
".",
"Duration",
")",
"Authenticator",
"{",
"inactivity",
":=",
"DefaultInactivityDuration",
"\n",
"// Server interprets a token duration longer than the cookie lifespan as",
"// a token that was issued by ... | // NewCookieJWT creates an Authenticator that uses cookies for auth | [
"NewCookieJWT",
"creates",
"an",
"Authenticator",
"that",
"uses",
"cookies",
"for",
"auth"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/oauth2/cookies.go#L28-L47 |
123,840 | influxdata/influxdb | chronograf/oauth2/cookies.go | Validate | func (c *cookie) Validate(ctx context.Context, r *http.Request) (Principal, error) {
cookie, err := r.Cookie(c.Name)
if err != nil {
return Principal{}, ErrAuthentication
}
return c.Tokens.ValidPrincipal(ctx, Token(cookie.Value), c.Lifespan)
} | go | func (c *cookie) Validate(ctx context.Context, r *http.Request) (Principal, error) {
cookie, err := r.Cookie(c.Name)
if err != nil {
return Principal{}, ErrAuthentication
}
return c.Tokens.ValidPrincipal(ctx, Token(cookie.Value), c.Lifespan)
} | [
"func",
"(",
"c",
"*",
"cookie",
")",
"Validate",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"Principal",
",",
"error",
")",
"{",
"cookie",
",",
"err",
":=",
"r",
".",
"Cookie",
"(",
"c",
".",
"Name",
... | // Validate returns Principal of the Cookie if the Token is valid. | [
"Validate",
"returns",
"Principal",
"of",
"the",
"Cookie",
"if",
"the",
"Token",
"is",
"valid",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/oauth2/cookies.go#L50-L57 |
123,841 | influxdata/influxdb | chronograf/oauth2/cookies.go | Extend | func (c *cookie) Extend(ctx context.Context, w http.ResponseWriter, p Principal) (Principal, error) {
// Refresh the token by extending its life another Inactivity duration
p, err := c.Tokens.ExtendedPrincipal(ctx, p, c.Inactivity)
if err != nil {
return Principal{}, ErrAuthentication
}
// Creating a new token ... | go | func (c *cookie) Extend(ctx context.Context, w http.ResponseWriter, p Principal) (Principal, error) {
// Refresh the token by extending its life another Inactivity duration
p, err := c.Tokens.ExtendedPrincipal(ctx, p, c.Inactivity)
if err != nil {
return Principal{}, ErrAuthentication
}
// Creating a new token ... | [
"func",
"(",
"c",
"*",
"cookie",
")",
"Extend",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"p",
"Principal",
")",
"(",
"Principal",
",",
"error",
")",
"{",
"// Refresh the token by extending its life another Inactivity d... | // Extend will extend the lifetime of the Token by the Inactivity time. Assumes
// Principal is already valid. | [
"Extend",
"will",
"extend",
"the",
"lifetime",
"of",
"the",
"Token",
"by",
"the",
"Inactivity",
"time",
".",
"Assumes",
"Principal",
"is",
"already",
"valid",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/oauth2/cookies.go#L61-L82 |
123,842 | influxdata/influxdb | chronograf/oauth2/cookies.go | Authorize | func (c *cookie) Authorize(ctx context.Context, w http.ResponseWriter, p Principal) error {
// Principal will be issued at Now() and will expire
// c.Inactivity into the future
now := c.Now()
p.IssuedAt = now
p.ExpiresAt = now.Add(c.Inactivity)
token, err := c.Tokens.Create(ctx, p)
if err != nil {
return err
... | go | func (c *cookie) Authorize(ctx context.Context, w http.ResponseWriter, p Principal) error {
// Principal will be issued at Now() and will expire
// c.Inactivity into the future
now := c.Now()
p.IssuedAt = now
p.ExpiresAt = now.Add(c.Inactivity)
token, err := c.Tokens.Create(ctx, p)
if err != nil {
return err
... | [
"func",
"(",
"c",
"*",
"cookie",
")",
"Authorize",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"p",
"Principal",
")",
"error",
"{",
"// Principal will be issued at Now() and will expire",
"// c.Inactivity into the future",
"n... | // Authorize will create cookies containing token information. It'll create
// a token with cookie.Duration of life to be stored as the cookie's value. | [
"Authorize",
"will",
"create",
"cookies",
"containing",
"token",
"information",
".",
"It",
"ll",
"create",
"a",
"token",
"with",
"cookie",
".",
"Duration",
"of",
"life",
"to",
"be",
"stored",
"as",
"the",
"cookie",
"s",
"value",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/oauth2/cookies.go#L86-L103 |
123,843 | influxdata/influxdb | chronograf/oauth2/cookies.go | setCookie | func (c *cookie) setCookie(w http.ResponseWriter, value string, exp time.Time) {
// Cookie has a Token baked into it
cookie := http.Cookie{
Name: DefaultCookieName,
Value: value,
HttpOnly: true,
Path: "/",
}
// Only set a cookie to be persistent (endure beyond the browser session)
// if auth du... | go | func (c *cookie) setCookie(w http.ResponseWriter, value string, exp time.Time) {
// Cookie has a Token baked into it
cookie := http.Cookie{
Name: DefaultCookieName,
Value: value,
HttpOnly: true,
Path: "/",
}
// Only set a cookie to be persistent (endure beyond the browser session)
// if auth du... | [
"func",
"(",
"c",
"*",
"cookie",
")",
"setCookie",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"value",
"string",
",",
"exp",
"time",
".",
"Time",
")",
"{",
"// Cookie has a Token baked into it",
"cookie",
":=",
"http",
".",
"Cookie",
"{",
"Name",
":",
... | // setCookie creates a cookie with value expiring at exp and writes it as a cookie into the response | [
"setCookie",
"creates",
"a",
"cookie",
"with",
"value",
"expiring",
"at",
"exp",
"and",
"writes",
"it",
"as",
"a",
"cookie",
"into",
"the",
"response"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/oauth2/cookies.go#L106-L121 |
123,844 | influxdata/influxdb | chronograf/oauth2/cookies.go | Expire | func (c *cookie) Expire(w http.ResponseWriter) {
// to expire cookie set the time in the past
cookie := http.Cookie{
Name: DefaultCookieName,
Value: "none",
HttpOnly: true,
Path: "/",
Expires: c.Now().Add(-1 * time.Hour),
}
http.SetCookie(w, &cookie)
} | go | func (c *cookie) Expire(w http.ResponseWriter) {
// to expire cookie set the time in the past
cookie := http.Cookie{
Name: DefaultCookieName,
Value: "none",
HttpOnly: true,
Path: "/",
Expires: c.Now().Add(-1 * time.Hour),
}
http.SetCookie(w, &cookie)
} | [
"func",
"(",
"c",
"*",
"cookie",
")",
"Expire",
"(",
"w",
"http",
".",
"ResponseWriter",
")",
"{",
"// to expire cookie set the time in the past",
"cookie",
":=",
"http",
".",
"Cookie",
"{",
"Name",
":",
"DefaultCookieName",
",",
"Value",
":",
"\"",
"\"",
",... | // Expire returns a cookie that will expire an existing cookie | [
"Expire",
"returns",
"a",
"cookie",
"that",
"will",
"expire",
"an",
"existing",
"cookie"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/oauth2/cookies.go#L124-L135 |
123,845 | influxdata/influxdb | http/assets.go | ServeHTTP | func (h *AssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
var assets chronograf.Assets
if h.Path != "" {
assets = &dist.DebugAssets{
Dir: h.Path,
Default: filepath.Join(h.Path, DebugDefault),
}
} else {
assets = &dist.BindataAssets{
Prefix: Dir,
Default: ... | go | func (h *AssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
var assets chronograf.Assets
if h.Path != "" {
assets = &dist.DebugAssets{
Dir: h.Path,
Default: filepath.Join(h.Path, DebugDefault),
}
} else {
assets = &dist.BindataAssets{
Prefix: Dir,
Default: ... | [
"func",
"(",
"h",
"*",
"AssetHandler",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"var",
"assets",
"chronograf",
".",
"Assets",
"\n",
"if",
"h",
".",
"Path",
"!=",
"\"",
"\"",
"{",
"a... | // ServeHTTP implements the http handler interface for serving assets. | [
"ServeHTTP",
"implements",
"the",
"http",
"handler",
"interface",
"for",
"serving",
"assets",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/http/assets.go#L34-L50 |
123,846 | influxdata/influxdb | storage/config.go | GetSeriesFilePath | func (c Config) GetSeriesFilePath(base string) string {
if c.SeriesFilePath != "" {
return c.SeriesFilePath
}
return filepath.Join(base, DefaultSeriesFileDirectoryName)
} | go | func (c Config) GetSeriesFilePath(base string) string {
if c.SeriesFilePath != "" {
return c.SeriesFilePath
}
return filepath.Join(base, DefaultSeriesFileDirectoryName)
} | [
"func",
"(",
"c",
"Config",
")",
"GetSeriesFilePath",
"(",
"base",
"string",
")",
"string",
"{",
"if",
"c",
".",
"SeriesFilePath",
"!=",
"\"",
"\"",
"{",
"return",
"c",
".",
"SeriesFilePath",
"\n",
"}",
"\n",
"return",
"filepath",
".",
"Join",
"(",
"ba... | // GetSeriesFilePath returns the path to the series file. | [
"GetSeriesFilePath",
"returns",
"the",
"path",
"to",
"the",
"series",
"file",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/storage/config.go#L58-L63 |
123,847 | influxdata/influxdb | storage/config.go | GetIndexPath | func (c Config) GetIndexPath(base string) string {
if c.IndexPath != "" {
return c.IndexPath
}
return filepath.Join(base, DefaultIndexDirectoryName)
} | go | func (c Config) GetIndexPath(base string) string {
if c.IndexPath != "" {
return c.IndexPath
}
return filepath.Join(base, DefaultIndexDirectoryName)
} | [
"func",
"(",
"c",
"Config",
")",
"GetIndexPath",
"(",
"base",
"string",
")",
"string",
"{",
"if",
"c",
".",
"IndexPath",
"!=",
"\"",
"\"",
"{",
"return",
"c",
".",
"IndexPath",
"\n",
"}",
"\n",
"return",
"filepath",
".",
"Join",
"(",
"base",
",",
"... | // GetIndexPath returns the path to the index. | [
"GetIndexPath",
"returns",
"the",
"path",
"to",
"the",
"index",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/storage/config.go#L66-L71 |
123,848 | influxdata/influxdb | storage/config.go | GetWALPath | func (c Config) GetWALPath(base string) string {
if c.WALPath != "" {
return c.WALPath
}
return filepath.Join(base, DefaultWALDirectoryName)
} | go | func (c Config) GetWALPath(base string) string {
if c.WALPath != "" {
return c.WALPath
}
return filepath.Join(base, DefaultWALDirectoryName)
} | [
"func",
"(",
"c",
"Config",
")",
"GetWALPath",
"(",
"base",
"string",
")",
"string",
"{",
"if",
"c",
".",
"WALPath",
"!=",
"\"",
"\"",
"{",
"return",
"c",
".",
"WALPath",
"\n",
"}",
"\n",
"return",
"filepath",
".",
"Join",
"(",
"base",
",",
"Defaul... | // GetWALPath returns the path to the WAL. | [
"GetWALPath",
"returns",
"the",
"path",
"to",
"the",
"WAL",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/storage/config.go#L74-L79 |
123,849 | influxdata/influxdb | storage/config.go | GetEnginePath | func (c Config) GetEnginePath(base string) string {
if c.EnginePath != "" {
return c.EnginePath
}
return filepath.Join(base, DefaultEngineDirectoryName)
} | go | func (c Config) GetEnginePath(base string) string {
if c.EnginePath != "" {
return c.EnginePath
}
return filepath.Join(base, DefaultEngineDirectoryName)
} | [
"func",
"(",
"c",
"Config",
")",
"GetEnginePath",
"(",
"base",
"string",
")",
"string",
"{",
"if",
"c",
".",
"EnginePath",
"!=",
"\"",
"\"",
"{",
"return",
"c",
".",
"EnginePath",
"\n",
"}",
"\n",
"return",
"filepath",
".",
"Join",
"(",
"base",
",",
... | // GetEnginePath returns the path to the engine. | [
"GetEnginePath",
"returns",
"the",
"path",
"to",
"the",
"engine",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/storage/config.go#L82-L87 |
123,850 | influxdata/influxdb | tsdb/tsm1/string.go | Write | func (e *StringEncoder) Write(s string) {
b := make([]byte, 10)
// Append the length of the string using variable byte encoding
i := binary.PutUvarint(b, uint64(len(s)))
e.bytes = append(e.bytes, b[:i]...)
// Append the string bytes
e.bytes = append(e.bytes, s...)
} | go | func (e *StringEncoder) Write(s string) {
b := make([]byte, 10)
// Append the length of the string using variable byte encoding
i := binary.PutUvarint(b, uint64(len(s)))
e.bytes = append(e.bytes, b[:i]...)
// Append the string bytes
e.bytes = append(e.bytes, s...)
} | [
"func",
"(",
"e",
"*",
"StringEncoder",
")",
"Write",
"(",
"s",
"string",
")",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"10",
")",
"\n",
"// Append the length of the string using variable byte encoding",
"i",
":=",
"binary",
".",
"PutUvarint",
"("... | // Write encodes s to the underlying buffer. | [
"Write",
"encodes",
"s",
"to",
"the",
"underlying",
"buffer",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/string.go#L42-L50 |
123,851 | influxdata/influxdb | tsdb/tsm1/string.go | SetBytes | func (e *StringDecoder) SetBytes(b []byte) error {
// First byte stores the encoding type, only have snappy format
// currently so ignore for now.
var data []byte
if len(b) > 0 {
var err error
data, err = snappy.Decode(nil, b[1:])
if err != nil {
return fmt.Errorf("failed to decode string block: %v", err.E... | go | func (e *StringDecoder) SetBytes(b []byte) error {
// First byte stores the encoding type, only have snappy format
// currently so ignore for now.
var data []byte
if len(b) > 0 {
var err error
data, err = snappy.Decode(nil, b[1:])
if err != nil {
return fmt.Errorf("failed to decode string block: %v", err.E... | [
"func",
"(",
"e",
"*",
"StringDecoder",
")",
"SetBytes",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"// First byte stores the encoding type, only have snappy format",
"// currently so ignore for now.",
"var",
"data",
"[",
"]",
"byte",
"\n",
"if",
"len",
"(",
"... | // SetBytes initializes the decoder with bytes to read from.
// This must be called before calling any other method. | [
"SetBytes",
"initializes",
"the",
"decoder",
"with",
"bytes",
"to",
"read",
"from",
".",
"This",
"must",
"be",
"called",
"before",
"calling",
"any",
"other",
"method",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/string.go#L70-L88 |
123,852 | influxdata/influxdb | bolt/organization.go | forEachOrganization | func forEachOrganization(ctx context.Context, tx *bolt.Tx, fn func(*influxdb.Organization) bool) error {
cur := tx.Bucket(organizationBucket).Cursor()
for k, v := cur.First(); k != nil; k, v = cur.Next() {
o := &influxdb.Organization{}
if err := json.Unmarshal(v, o); err != nil {
return err
}
if !fn(o) {
... | go | func forEachOrganization(ctx context.Context, tx *bolt.Tx, fn func(*influxdb.Organization) bool) error {
cur := tx.Bucket(organizationBucket).Cursor()
for k, v := cur.First(); k != nil; k, v = cur.Next() {
o := &influxdb.Organization{}
if err := json.Unmarshal(v, o); err != nil {
return err
}
if !fn(o) {
... | [
"func",
"forEachOrganization",
"(",
"ctx",
"context",
".",
"Context",
",",
"tx",
"*",
"bolt",
".",
"Tx",
",",
"fn",
"func",
"(",
"*",
"influxdb",
".",
"Organization",
")",
"bool",
")",
"error",
"{",
"cur",
":=",
"tx",
".",
"Bucket",
"(",
"organizationB... | // forEachOrganization will iterate through all organizations while fn returns true. | [
"forEachOrganization",
"will",
"iterate",
"through",
"all",
"organizations",
"while",
"fn",
"returns",
"true",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/bolt/organization.go#L296-L309 |
123,853 | influxdata/influxdb | tsdb/series_id.go | WithType | func (s SeriesID) WithType(typ models.FieldType) SeriesIDTyped {
return NewSeriesIDTyped(s.ID | seriesIDTypeFlag | (uint64(typ&0xFF) << seriesIDTypeShift))
} | go | func (s SeriesID) WithType(typ models.FieldType) SeriesIDTyped {
return NewSeriesIDTyped(s.ID | seriesIDTypeFlag | (uint64(typ&0xFF) << seriesIDTypeShift))
} | [
"func",
"(",
"s",
"SeriesID",
")",
"WithType",
"(",
"typ",
"models",
".",
"FieldType",
")",
"SeriesIDTyped",
"{",
"return",
"NewSeriesIDTyped",
"(",
"s",
".",
"ID",
"|",
"seriesIDTypeFlag",
"|",
"(",
"uint64",
"(",
"typ",
"&",
"0xFF",
")",
"<<",
"seriesI... | // WithType constructs a SeriesIDTyped with the given type. | [
"WithType",
"constructs",
"a",
"SeriesIDTyped",
"with",
"the",
"given",
"type",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/series_id.go#L34-L36 |
123,854 | influxdata/influxdb | tsdb/series_id.go | Type | func (s SeriesIDTyped) Type() models.FieldType {
return models.FieldType((s.ID & seriesIDTypeMask) >> seriesIDTypeShift)
} | go | func (s SeriesIDTyped) Type() models.FieldType {
return models.FieldType((s.ID & seriesIDTypeMask) >> seriesIDTypeShift)
} | [
"func",
"(",
"s",
"SeriesIDTyped",
")",
"Type",
"(",
")",
"models",
".",
"FieldType",
"{",
"return",
"models",
".",
"FieldType",
"(",
"(",
"s",
".",
"ID",
"&",
"seriesIDTypeMask",
")",
">>",
"seriesIDTypeShift",
")",
"\n",
"}"
] | // Type returns the associated type. | [
"Type",
"returns",
"the",
"associated",
"type",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/series_id.go#L66-L68 |
123,855 | influxdata/influxdb | mock/dashboard_service.go | NewDashboardService | func NewDashboardService() *DashboardService {
return &DashboardService{
CreateDashboardF: func(context.Context, *platform.Dashboard) error { return nil },
FindDashboardByIDF: func(context.Context, platform.ID) (*platform.Dashboard, error) { return nil, nil },
FindDashboardsF: func(context.Context, platform.Da... | go | func NewDashboardService() *DashboardService {
return &DashboardService{
CreateDashboardF: func(context.Context, *platform.Dashboard) error { return nil },
FindDashboardByIDF: func(context.Context, platform.ID) (*platform.Dashboard, error) { return nil, nil },
FindDashboardsF: func(context.Context, platform.Da... | [
"func",
"NewDashboardService",
"(",
")",
"*",
"DashboardService",
"{",
"return",
"&",
"DashboardService",
"{",
"CreateDashboardF",
":",
"func",
"(",
"context",
".",
"Context",
",",
"*",
"platform",
".",
"Dashboard",
")",
"error",
"{",
"return",
"nil",
"}",
"... | // NewDashboardService returns a mock of DashboardService where its methods will return zero values. | [
"NewDashboardService",
"returns",
"a",
"mock",
"of",
"DashboardService",
"where",
"its",
"methods",
"will",
"return",
"zero",
"values",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/mock/dashboard_service.go#L28-L58 |
123,856 | influxdata/influxdb | tsdb/meta.go | MarshalTags | func MarshalTags(tags map[string]string) []byte {
// Empty maps marshal to empty bytes.
if len(tags) == 0 {
return nil
}
// Extract keys and determine final size.
sz := (len(tags) * 2) - 1 // separators
keys := make([]string, 0, len(tags))
for k, v := range tags {
keys = append(keys, k)
sz += len(k) + len... | go | func MarshalTags(tags map[string]string) []byte {
// Empty maps marshal to empty bytes.
if len(tags) == 0 {
return nil
}
// Extract keys and determine final size.
sz := (len(tags) * 2) - 1 // separators
keys := make([]string, 0, len(tags))
for k, v := range tags {
keys = append(keys, k)
sz += len(k) + len... | [
"func",
"MarshalTags",
"(",
"tags",
"map",
"[",
"string",
"]",
"string",
")",
"[",
"]",
"byte",
"{",
"// Empty maps marshal to empty bytes.",
"if",
"len",
"(",
"tags",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Extract keys and determine fina... | // MarshalTags converts a tag set to bytes for use as a lookup key. | [
"MarshalTags",
"converts",
"a",
"tag",
"set",
"to",
"bytes",
"for",
"use",
"as",
"a",
"lookup",
"key",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/meta.go#L12-L44 |
123,857 | influxdata/influxdb | tsdb/meta.go | MakeTagsKey | func MakeTagsKey(keys []string, tags models.Tags) []byte {
// precondition: keys is sorted
// precondition: models.Tags is sorted
// Empty maps marshal to empty bytes.
if len(keys) == 0 || len(tags) == 0 {
return nil
}
sel := make([]int, 0, len(keys))
sz := 0
i, j := 0, 0
for i < len(keys) && j < len(tags... | go | func MakeTagsKey(keys []string, tags models.Tags) []byte {
// precondition: keys is sorted
// precondition: models.Tags is sorted
// Empty maps marshal to empty bytes.
if len(keys) == 0 || len(tags) == 0 {
return nil
}
sel := make([]int, 0, len(keys))
sz := 0
i, j := 0, 0
for i < len(keys) && j < len(tags... | [
"func",
"MakeTagsKey",
"(",
"keys",
"[",
"]",
"string",
",",
"tags",
"models",
".",
"Tags",
")",
"[",
"]",
"byte",
"{",
"// precondition: keys is sorted",
"// precondition: models.Tags is sorted",
"// Empty maps marshal to empty bytes.",
"if",
"len",
"(",
"keys",
")",... | // MakeTagsKey converts a tag set to bytes for use as a lookup key. | [
"MakeTagsKey",
"converts",
"a",
"tag",
"set",
"to",
"bytes",
"for",
"use",
"as",
"a",
"lookup",
"key",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/meta.go#L47-L98 |
123,858 | influxdata/influxdb | chronograf/server/version.go | Version | func Version(version string, h http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("X-Chronograf-Version", version)
h.ServeHTTP(w, r)
}
return http.HandlerFunc(fn)
} | go | func Version(version string, h http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("X-Chronograf-Version", version)
h.ServeHTTP(w, r)
}
return http.HandlerFunc(fn)
} | [
"func",
"Version",
"(",
"version",
"string",
",",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"fn",
":=",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"w",
".",
"Header",
"(",
... | // Version handler adds X-Chronograf-Version header to responses | [
"Version",
"handler",
"adds",
"X",
"-",
"Chronograf",
"-",
"Version",
"header",
"to",
"responses"
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/chronograf/server/version.go#L8-L14 |
123,859 | influxdata/influxdb | uuid/uuid.go | String | func (u UUID) String() string {
var offsets = [...]int{0, 2, 4, 6, 9, 11, 14, 16, 19, 21, 24, 26, 28, 30, 32, 34}
const hexString = "0123456789abcdef"
r := make([]byte, 36)
for i, b := range u {
r[offsets[i]] = hexString[b>>4]
r[offsets[i]+1] = hexString[b&0xF]
}
r[8] = '-'
r[13] = '-'
r[18] = '-'
r[23] = ... | go | func (u UUID) String() string {
var offsets = [...]int{0, 2, 4, 6, 9, 11, 14, 16, 19, 21, 24, 26, 28, 30, 32, 34}
const hexString = "0123456789abcdef"
r := make([]byte, 36)
for i, b := range u {
r[offsets[i]] = hexString[b>>4]
r[offsets[i]+1] = hexString[b&0xF]
}
r[8] = '-'
r[13] = '-'
r[18] = '-'
r[23] = ... | [
"func",
"(",
"u",
"UUID",
")",
"String",
"(",
")",
"string",
"{",
"var",
"offsets",
"=",
"[",
"...",
"]",
"int",
"{",
"0",
",",
"2",
",",
"4",
",",
"6",
",",
"9",
",",
"11",
",",
"14",
",",
"16",
",",
"19",
",",
"21",
",",
"24",
",",
"2... | // String returns the UUID in it's canonical form, a 32 digit hexadecimal
// number in the form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. | [
"String",
"returns",
"the",
"UUID",
"in",
"it",
"s",
"canonical",
"form",
"a",
"32",
"digit",
"hexadecimal",
"number",
"in",
"the",
"form",
"of",
"xxxxxxxx",
"-",
"xxxx",
"-",
"xxxx",
"-",
"xxxx",
"-",
"xxxxxxxxxxxx",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/uuid/uuid.go#L102-L116 |
123,860 | influxdata/influxdb | pkg/metrics/registry.go | MustRegisterGroup | func (r *Registry) MustRegisterGroup(name string) GID {
gd := &groupDesc{Name: name}
r.mustRegister(gd)
return gd.id
} | go | func (r *Registry) MustRegisterGroup(name string) GID {
gd := &groupDesc{Name: name}
r.mustRegister(gd)
return gd.id
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"MustRegisterGroup",
"(",
"name",
"string",
")",
"GID",
"{",
"gd",
":=",
"&",
"groupDesc",
"{",
"Name",
":",
"name",
"}",
"\n",
"r",
".",
"mustRegister",
"(",
"gd",
")",
"\n",
"return",
"gd",
".",
"id",
"\n",... | // MustRegisterGroup registers a new group and panics if a group already exists with the same name.
//
// MustRegisterGroup is not safe to call from concurrent goroutines. | [
"MustRegisterGroup",
"registers",
"a",
"new",
"group",
"and",
"panics",
"if",
"a",
"group",
"already",
"exists",
"with",
"the",
"same",
"name",
".",
"MustRegisterGroup",
"is",
"not",
"safe",
"to",
"call",
"from",
"concurrent",
"goroutines",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/pkg/metrics/registry.go#L54-L58 |
123,861 | influxdata/influxdb | pkg/metrics/registry.go | MustRegisterCounter | func (r *Registry) MustRegisterCounter(name string, opts ...descOption) ID {
desc := newDesc(name, opts...)
return r.mustGetGroupRegistry(desc.gid).mustRegisterCounter(desc)
} | go | func (r *Registry) MustRegisterCounter(name string, opts ...descOption) ID {
desc := newDesc(name, opts...)
return r.mustGetGroupRegistry(desc.gid).mustRegisterCounter(desc)
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"MustRegisterCounter",
"(",
"name",
"string",
",",
"opts",
"...",
"descOption",
")",
"ID",
"{",
"desc",
":=",
"newDesc",
"(",
"name",
",",
"opts",
"...",
")",
"\n",
"return",
"r",
".",
"mustGetGroupRegistry",
"(",
... | // MustRegisterCounter registers a new counter metric using the provided descriptor.
// If the metric name is not unique within the group, MustRegisterCounter will panic.
//
// MustRegisterCounter is not safe to call from concurrent goroutines. | [
"MustRegisterCounter",
"registers",
"a",
"new",
"counter",
"metric",
"using",
"the",
"provided",
"descriptor",
".",
"If",
"the",
"metric",
"name",
"is",
"not",
"unique",
"within",
"the",
"group",
"MustRegisterCounter",
"will",
"panic",
".",
"MustRegisterCounter",
... | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/pkg/metrics/registry.go#L71-L74 |
123,862 | influxdata/influxdb | pkg/metrics/registry.go | MustRegisterTimer | func (r *Registry) MustRegisterTimer(name string, opts ...descOption) ID {
desc := newDesc(name, opts...)
return r.mustGetGroupRegistry(desc.gid).mustRegisterTimer(desc)
} | go | func (r *Registry) MustRegisterTimer(name string, opts ...descOption) ID {
desc := newDesc(name, opts...)
return r.mustGetGroupRegistry(desc.gid).mustRegisterTimer(desc)
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"MustRegisterTimer",
"(",
"name",
"string",
",",
"opts",
"...",
"descOption",
")",
"ID",
"{",
"desc",
":=",
"newDesc",
"(",
"name",
",",
"opts",
"...",
")",
"\n",
"return",
"r",
".",
"mustGetGroupRegistry",
"(",
... | // MustRegisterTimer registers a new timer metric using the provided descriptor.
// If the metric name is not unique within the group, MustRegisterTimer will panic.
//
// MustRegisterTimer is not safe to call from concurrent goroutines. | [
"MustRegisterTimer",
"registers",
"a",
"new",
"timer",
"metric",
"using",
"the",
"provided",
"descriptor",
".",
"If",
"the",
"metric",
"name",
"is",
"not",
"unique",
"within",
"the",
"group",
"MustRegisterTimer",
"will",
"panic",
".",
"MustRegisterTimer",
"is",
... | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/pkg/metrics/registry.go#L80-L83 |
123,863 | influxdata/influxdb | pkg/bloom/bloom.go | NewFilter | func NewFilter(m uint64, k uint64) *Filter {
m = pow2(m)
return &Filter{k: k, b: make([]byte, m>>3), mask: m - 1}
} | go | func NewFilter(m uint64, k uint64) *Filter {
m = pow2(m)
return &Filter{k: k, b: make([]byte, m>>3), mask: m - 1}
} | [
"func",
"NewFilter",
"(",
"m",
"uint64",
",",
"k",
"uint64",
")",
"*",
"Filter",
"{",
"m",
"=",
"pow2",
"(",
"m",
")",
"\n",
"return",
"&",
"Filter",
"{",
"k",
":",
"k",
",",
"b",
":",
"make",
"(",
"[",
"]",
"byte",
",",
"m",
">>",
"3",
")"... | // NewFilter returns a new instance of Filter using m bits and k hash functions.
// If m is not a power of two then it is rounded to the next highest power of 2. | [
"NewFilter",
"returns",
"a",
"new",
"instance",
"of",
"Filter",
"using",
"m",
"bits",
"and",
"k",
"hash",
"functions",
".",
"If",
"m",
"is",
"not",
"a",
"power",
"of",
"two",
"then",
"it",
"is",
"rounded",
"to",
"the",
"next",
"highest",
"power",
"of",... | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/pkg/bloom/bloom.go#L27-L30 |
123,864 | influxdata/influxdb | pkg/bloom/bloom.go | NewFilterBuffer | func NewFilterBuffer(buf []byte, k uint64) (*Filter, error) {
m := pow2(uint64(len(buf)) * 8)
if m != uint64(len(buf))*8 {
return nil, fmt.Errorf("bloom.Filter: buffer bit count must a power of two: %d/%d", len(buf)*8, m)
}
return &Filter{k: k, b: buf, mask: m - 1}, nil
} | go | func NewFilterBuffer(buf []byte, k uint64) (*Filter, error) {
m := pow2(uint64(len(buf)) * 8)
if m != uint64(len(buf))*8 {
return nil, fmt.Errorf("bloom.Filter: buffer bit count must a power of two: %d/%d", len(buf)*8, m)
}
return &Filter{k: k, b: buf, mask: m - 1}, nil
} | [
"func",
"NewFilterBuffer",
"(",
"buf",
"[",
"]",
"byte",
",",
"k",
"uint64",
")",
"(",
"*",
"Filter",
",",
"error",
")",
"{",
"m",
":=",
"pow2",
"(",
"uint64",
"(",
"len",
"(",
"buf",
")",
")",
"*",
"8",
")",
"\n",
"if",
"m",
"!=",
"uint64",
... | // NewFilterBuffer returns a new instance of a filter using a backing buffer.
// The buffer length MUST be a power of 2. | [
"NewFilterBuffer",
"returns",
"a",
"new",
"instance",
"of",
"a",
"filter",
"using",
"a",
"backing",
"buffer",
".",
"The",
"buffer",
"length",
"MUST",
"be",
"a",
"power",
"of",
"2",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/pkg/bloom/bloom.go#L34-L40 |
123,865 | influxdata/influxdb | pkg/bloom/bloom.go | Clone | func (f *Filter) Clone() *Filter {
other := &Filter{k: f.k, b: make([]byte, len(f.b)), mask: f.mask}
copy(other.b, f.b)
return other
} | go | func (f *Filter) Clone() *Filter {
other := &Filter{k: f.k, b: make([]byte, len(f.b)), mask: f.mask}
copy(other.b, f.b)
return other
} | [
"func",
"(",
"f",
"*",
"Filter",
")",
"Clone",
"(",
")",
"*",
"Filter",
"{",
"other",
":=",
"&",
"Filter",
"{",
"k",
":",
"f",
".",
"k",
",",
"b",
":",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"f",
".",
"b",
")",
")",
",",
"mask",
... | // Clone returns a copy of f. | [
"Clone",
"returns",
"a",
"copy",
"of",
"f",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/pkg/bloom/bloom.go#L52-L56 |
123,866 | influxdata/influxdb | pkg/bloom/bloom.go | Insert | func (f *Filter) Insert(v []byte) {
h := f.hash(v)
for i := uint64(0); i < f.k; i++ {
loc := f.location(h, i)
f.b[loc>>3] |= 1 << (loc & 7)
}
} | go | func (f *Filter) Insert(v []byte) {
h := f.hash(v)
for i := uint64(0); i < f.k; i++ {
loc := f.location(h, i)
f.b[loc>>3] |= 1 << (loc & 7)
}
} | [
"func",
"(",
"f",
"*",
"Filter",
")",
"Insert",
"(",
"v",
"[",
"]",
"byte",
")",
"{",
"h",
":=",
"f",
".",
"hash",
"(",
"v",
")",
"\n",
"for",
"i",
":=",
"uint64",
"(",
"0",
")",
";",
"i",
"<",
"f",
".",
"k",
";",
"i",
"++",
"{",
"loc",... | // Insert inserts data to the filter. | [
"Insert",
"inserts",
"data",
"to",
"the",
"filter",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/pkg/bloom/bloom.go#L59-L65 |
123,867 | influxdata/influxdb | pkg/bloom/bloom.go | Contains | func (f *Filter) Contains(v []byte) bool {
h := f.hash(v)
for i := uint64(0); i < f.k; i++ {
loc := f.location(h, i)
if f.b[loc>>3]&(1<<(loc&7)) == 0 {
return false
}
}
return true
} | go | func (f *Filter) Contains(v []byte) bool {
h := f.hash(v)
for i := uint64(0); i < f.k; i++ {
loc := f.location(h, i)
if f.b[loc>>3]&(1<<(loc&7)) == 0 {
return false
}
}
return true
} | [
"func",
"(",
"f",
"*",
"Filter",
")",
"Contains",
"(",
"v",
"[",
"]",
"byte",
")",
"bool",
"{",
"h",
":=",
"f",
".",
"hash",
"(",
"v",
")",
"\n",
"for",
"i",
":=",
"uint64",
"(",
"0",
")",
";",
"i",
"<",
"f",
".",
"k",
";",
"i",
"++",
"... | // Contains returns true if the filter possibly contains v.
// Returns false if the filter definitely does not contain v. | [
"Contains",
"returns",
"true",
"if",
"the",
"filter",
"possibly",
"contains",
"v",
".",
"Returns",
"false",
"if",
"the",
"filter",
"definitely",
"does",
"not",
"contain",
"v",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/pkg/bloom/bloom.go#L69-L78 |
123,868 | influxdata/influxdb | pkg/bloom/bloom.go | Merge | func (f *Filter) Merge(other *Filter) error {
if other == nil {
return nil
}
// Ensure m & k fields match.
if len(f.b) != len(other.b) {
return fmt.Errorf("bloom.Filter.Merge(): m mismatch: %d <> %d", len(f.b), len(other.b))
} else if f.k != other.k {
return fmt.Errorf("bloom.Filter.Merge(): k mismatch: %d ... | go | func (f *Filter) Merge(other *Filter) error {
if other == nil {
return nil
}
// Ensure m & k fields match.
if len(f.b) != len(other.b) {
return fmt.Errorf("bloom.Filter.Merge(): m mismatch: %d <> %d", len(f.b), len(other.b))
} else if f.k != other.k {
return fmt.Errorf("bloom.Filter.Merge(): k mismatch: %d ... | [
"func",
"(",
"f",
"*",
"Filter",
")",
"Merge",
"(",
"other",
"*",
"Filter",
")",
"error",
"{",
"if",
"other",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Ensure m & k fields match.",
"if",
"len",
"(",
"f",
".",
"b",
")",
"!=",
"len",
... | // Merge performs an in-place union of other into f.
// Returns an error if m or k of the filters differs. | [
"Merge",
"performs",
"an",
"in",
"-",
"place",
"union",
"of",
"other",
"into",
"f",
".",
"Returns",
"an",
"error",
"if",
"m",
"or",
"k",
"of",
"the",
"filters",
"differs",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/pkg/bloom/bloom.go#L82-L100 |
123,869 | influxdata/influxdb | pkg/bloom/bloom.go | location | func (f *Filter) location(h [2]uint64, i uint64) uint {
return uint((h[0] + h[1]*i) & f.mask)
} | go | func (f *Filter) location(h [2]uint64, i uint64) uint {
return uint((h[0] + h[1]*i) & f.mask)
} | [
"func",
"(",
"f",
"*",
"Filter",
")",
"location",
"(",
"h",
"[",
"2",
"]",
"uint64",
",",
"i",
"uint64",
")",
"uint",
"{",
"return",
"uint",
"(",
"(",
"h",
"[",
"0",
"]",
"+",
"h",
"[",
"1",
"]",
"*",
"i",
")",
"&",
"f",
".",
"mask",
")",... | // location returns the ith hashed location using two hash values. | [
"location",
"returns",
"the",
"ith",
"hashed",
"location",
"using",
"two",
"hash",
"values",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/pkg/bloom/bloom.go#L103-L105 |
123,870 | influxdata/influxdb | pkg/bloom/bloom.go | hash | func (f *Filter) hash(data []byte) [2]uint64 {
v1 := xxhash.Sum64(data)
var v2 uint64
if len(data) > 0 {
b := data[len(data)-1] // We'll put the original byte back.
data[len(data)-1] = byte(0)
v2 = xxhash.Sum64(data)
data[len(data)-1] = b
}
return [2]uint64{v1, v2}
} | go | func (f *Filter) hash(data []byte) [2]uint64 {
v1 := xxhash.Sum64(data)
var v2 uint64
if len(data) > 0 {
b := data[len(data)-1] // We'll put the original byte back.
data[len(data)-1] = byte(0)
v2 = xxhash.Sum64(data)
data[len(data)-1] = b
}
return [2]uint64{v1, v2}
} | [
"func",
"(",
"f",
"*",
"Filter",
")",
"hash",
"(",
"data",
"[",
"]",
"byte",
")",
"[",
"2",
"]",
"uint64",
"{",
"v1",
":=",
"xxhash",
".",
"Sum64",
"(",
"data",
")",
"\n",
"var",
"v2",
"uint64",
"\n",
"if",
"len",
"(",
"data",
")",
">",
"0",
... | // hash returns two 64-bit hashes based on the output of xxhash. | [
"hash",
"returns",
"two",
"64",
"-",
"bit",
"hashes",
"based",
"on",
"the",
"output",
"of",
"xxhash",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/pkg/bloom/bloom.go#L108-L118 |
123,871 | influxdata/influxdb | pkg/bloom/bloom.go | Estimate | func Estimate(n uint64, p float64) (m uint64, k uint64) {
m = uint64(math.Ceil(-1 * float64(n) * math.Log(p) / math.Pow(math.Log(2), 2)))
k = uint64(math.Ceil(math.Log(2) * float64(m) / float64(n)))
return m, k
} | go | func Estimate(n uint64, p float64) (m uint64, k uint64) {
m = uint64(math.Ceil(-1 * float64(n) * math.Log(p) / math.Pow(math.Log(2), 2)))
k = uint64(math.Ceil(math.Log(2) * float64(m) / float64(n)))
return m, k
} | [
"func",
"Estimate",
"(",
"n",
"uint64",
",",
"p",
"float64",
")",
"(",
"m",
"uint64",
",",
"k",
"uint64",
")",
"{",
"m",
"=",
"uint64",
"(",
"math",
".",
"Ceil",
"(",
"-",
"1",
"*",
"float64",
"(",
"n",
")",
"*",
"math",
".",
"Log",
"(",
"p",... | // Estimate returns an estimated bit count and hash count given the element count and false positive rate. | [
"Estimate",
"returns",
"an",
"estimated",
"bit",
"count",
"and",
"hash",
"count",
"given",
"the",
"element",
"count",
"and",
"false",
"positive",
"rate",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/pkg/bloom/bloom.go#L121-L125 |
123,872 | influxdata/influxdb | status.go | Valid | func (s Status) Valid() error {
switch s {
case Active, Inactive:
return nil
default:
return &Error{
Code: EInvalid,
Msg: fmt.Sprintf("invalid status: must be %v or %v", Active, Inactive),
}
}
} | go | func (s Status) Valid() error {
switch s {
case Active, Inactive:
return nil
default:
return &Error{
Code: EInvalid,
Msg: fmt.Sprintf("invalid status: must be %v or %v", Active, Inactive),
}
}
} | [
"func",
"(",
"s",
"Status",
")",
"Valid",
"(",
")",
"error",
"{",
"switch",
"s",
"{",
"case",
"Active",
",",
"Inactive",
":",
"return",
"nil",
"\n",
"default",
":",
"return",
"&",
"Error",
"{",
"Code",
":",
"EInvalid",
",",
"Msg",
":",
"fmt",
".",
... | // Valid determines if a Status value matches the enum. | [
"Valid",
"determines",
"if",
"a",
"Status",
"value",
"matches",
"the",
"enum",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/status.go#L16-L26 |
123,873 | influxdata/influxdb | tsdb/tsm1/reader_index.go | MaybeContainsKey | func (d *indirectIndex) MaybeContainsKey(key []byte) bool {
return bytes.Compare(key, d.minKey) >= 0 && bytes.Compare(key, d.maxKey) <= 0
} | go | func (d *indirectIndex) MaybeContainsKey(key []byte) bool {
return bytes.Compare(key, d.minKey) >= 0 && bytes.Compare(key, d.maxKey) <= 0
} | [
"func",
"(",
"d",
"*",
"indirectIndex",
")",
"MaybeContainsKey",
"(",
"key",
"[",
"]",
"byte",
")",
"bool",
"{",
"return",
"bytes",
".",
"Compare",
"(",
"key",
",",
"d",
".",
"minKey",
")",
">=",
"0",
"&&",
"bytes",
".",
"Compare",
"(",
"key",
",",... | // MaybeContainsKey returns true of key may exist in this index. | [
"MaybeContainsKey",
"returns",
"true",
"of",
"key",
"may",
"exist",
"in",
"this",
"index",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L165-L167 |
123,874 | influxdata/influxdb | tsdb/tsm1/reader_index.go | ReadEntries | func (d *indirectIndex) ReadEntries(key []byte, entries []IndexEntry) ([]IndexEntry, error) {
d.mu.RLock()
defer d.mu.RUnlock()
iter := d.ro.Iterator()
exact, _ := iter.Seek(key, &d.b)
if !exact {
return nil, nil
}
entries, err := readEntries(d.b.access(iter.EntryOffset(&d.b), 0), entries)
if err != nil {
... | go | func (d *indirectIndex) ReadEntries(key []byte, entries []IndexEntry) ([]IndexEntry, error) {
d.mu.RLock()
defer d.mu.RUnlock()
iter := d.ro.Iterator()
exact, _ := iter.Seek(key, &d.b)
if !exact {
return nil, nil
}
entries, err := readEntries(d.b.access(iter.EntryOffset(&d.b), 0), entries)
if err != nil {
... | [
"func",
"(",
"d",
"*",
"indirectIndex",
")",
"ReadEntries",
"(",
"key",
"[",
"]",
"byte",
",",
"entries",
"[",
"]",
"IndexEntry",
")",
"(",
"[",
"]",
"IndexEntry",
",",
"error",
")",
"{",
"d",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"d"... | // ReadEntries returns all index entries for a key. | [
"ReadEntries",
"returns",
"all",
"index",
"entries",
"for",
"a",
"key",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L170-L186 |
123,875 | influxdata/influxdb | tsdb/tsm1/reader_index.go | Entry | func (d *indirectIndex) Entry(key []byte, timestamp int64) *IndexEntry {
entries, err := d.ReadEntries(key, nil)
if err != nil {
d.logger.Error("error reading tsm index key", zap.String("key", fmt.Sprintf("%q", key)))
return nil
}
for _, entry := range entries {
if entry.Contains(timestamp) {
return &entry... | go | func (d *indirectIndex) Entry(key []byte, timestamp int64) *IndexEntry {
entries, err := d.ReadEntries(key, nil)
if err != nil {
d.logger.Error("error reading tsm index key", zap.String("key", fmt.Sprintf("%q", key)))
return nil
}
for _, entry := range entries {
if entry.Contains(timestamp) {
return &entry... | [
"func",
"(",
"d",
"*",
"indirectIndex",
")",
"Entry",
"(",
"key",
"[",
"]",
"byte",
",",
"timestamp",
"int64",
")",
"*",
"IndexEntry",
"{",
"entries",
",",
"err",
":=",
"d",
".",
"ReadEntries",
"(",
"key",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
... | // Entry returns the index entry for the specified key and timestamp. If no entry
// matches the key an timestamp, nil is returned. | [
"Entry",
"returns",
"the",
"index",
"entry",
"for",
"the",
"specified",
"key",
"and",
"timestamp",
".",
"If",
"no",
"entry",
"matches",
"the",
"key",
"an",
"timestamp",
"nil",
"is",
"returned",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L190-L202 |
123,876 | influxdata/influxdb | tsdb/tsm1/reader_index.go | KeyCount | func (d *indirectIndex) KeyCount() int {
d.mu.RLock()
n := len(d.ro.offsets)
d.mu.RUnlock()
return n
} | go | func (d *indirectIndex) KeyCount() int {
d.mu.RLock()
n := len(d.ro.offsets)
d.mu.RUnlock()
return n
} | [
"func",
"(",
"d",
"*",
"indirectIndex",
")",
"KeyCount",
"(",
")",
"int",
"{",
"d",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"n",
":=",
"len",
"(",
"d",
".",
"ro",
".",
"offsets",
")",
"\n",
"d",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"... | // KeyCount returns the count of unique keys in the index. | [
"KeyCount",
"returns",
"the",
"count",
"of",
"unique",
"keys",
"in",
"the",
"index",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L205-L210 |
123,877 | influxdata/influxdb | tsdb/tsm1/reader_index.go | Delete | func (d *indirectIndex) Delete(keys [][]byte) bool {
if len(keys) == 0 {
return false
}
d.mu.RLock()
iter := d.ro.Iterator()
for _, key := range keys {
if !iter.Next() || !bytes.Equal(iter.Key(&d.b), key) {
if exact, _ := iter.Seek(key, &d.b); !exact {
continue
}
}
delete(d.tombstones, iter.Off... | go | func (d *indirectIndex) Delete(keys [][]byte) bool {
if len(keys) == 0 {
return false
}
d.mu.RLock()
iter := d.ro.Iterator()
for _, key := range keys {
if !iter.Next() || !bytes.Equal(iter.Key(&d.b), key) {
if exact, _ := iter.Seek(key, &d.b); !exact {
continue
}
}
delete(d.tombstones, iter.Off... | [
"func",
"(",
"d",
"*",
"indirectIndex",
")",
"Delete",
"(",
"keys",
"[",
"]",
"[",
"]",
"byte",
")",
"bool",
"{",
"if",
"len",
"(",
"keys",
")",
"==",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"d",
".",
"mu",
".",
"RLock",
"(",
")",
"\n... | // Delete removes the given keys from the index. | [
"Delete",
"removes",
"the",
"given",
"keys",
"from",
"the",
"index",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L232-L260 |
123,878 | influxdata/influxdb | tsdb/tsm1/reader_index.go | insertTimeRange | func insertTimeRange(ts []TimeRange, minTime, maxTime int64) []TimeRange {
n := sort.Search(len(ts), func(i int) bool {
if ts[i].Min == minTime {
return ts[i].Max >= maxTime
}
return ts[i].Min > minTime
})
ts = append(ts, TimeRange{})
copy(ts[n+1:], ts[n:])
ts[n] = TimeRange{Min: minTime, Max: maxTime}
... | go | func insertTimeRange(ts []TimeRange, minTime, maxTime int64) []TimeRange {
n := sort.Search(len(ts), func(i int) bool {
if ts[i].Min == minTime {
return ts[i].Max >= maxTime
}
return ts[i].Min > minTime
})
ts = append(ts, TimeRange{})
copy(ts[n+1:], ts[n:])
ts[n] = TimeRange{Min: minTime, Max: maxTime}
... | [
"func",
"insertTimeRange",
"(",
"ts",
"[",
"]",
"TimeRange",
",",
"minTime",
",",
"maxTime",
"int64",
")",
"[",
"]",
"TimeRange",
"{",
"n",
":=",
"sort",
".",
"Search",
"(",
"len",
"(",
"ts",
")",
",",
"func",
"(",
"i",
"int",
")",
"bool",
"{",
"... | // insertTimeRange adds a time range described by the minTime and maxTime into ts. | [
"insertTimeRange",
"adds",
"a",
"time",
"range",
"described",
"by",
"the",
"minTime",
"and",
"maxTime",
"into",
"ts",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L263-L275 |
123,879 | influxdata/influxdb | tsdb/tsm1/reader_index.go | coversEntries | func (d *indirectIndex) coversEntries(offset uint32, key []byte, buf []TimeRange,
entries []IndexEntry, minTime, maxTime int64) ([]TimeRange, bool) {
// grab the tombstones from the prefixes. these come out unsorted, so we sort
// them and place them in the merger section named unsorted.
buf = d.prefixTombstones.S... | go | func (d *indirectIndex) coversEntries(offset uint32, key []byte, buf []TimeRange,
entries []IndexEntry, minTime, maxTime int64) ([]TimeRange, bool) {
// grab the tombstones from the prefixes. these come out unsorted, so we sort
// them and place them in the merger section named unsorted.
buf = d.prefixTombstones.S... | [
"func",
"(",
"d",
"*",
"indirectIndex",
")",
"coversEntries",
"(",
"offset",
"uint32",
",",
"key",
"[",
"]",
"byte",
",",
"buf",
"[",
"]",
"TimeRange",
",",
"entries",
"[",
"]",
"IndexEntry",
",",
"minTime",
",",
"maxTime",
"int64",
")",
"(",
"[",
"]... | // coversEntries checks if all of the stored tombstones including one for minTime and maxTime cover
// all of the index entries. It mutates the entries slice to do the work, so be sure to make a copy
// if you must. | [
"coversEntries",
"checks",
"if",
"all",
"of",
"the",
"stored",
"tombstones",
"including",
"one",
"for",
"minTime",
"and",
"maxTime",
"cover",
"all",
"of",
"the",
"index",
"entries",
".",
"It",
"mutates",
"the",
"entries",
"slice",
"to",
"do",
"the",
"work",
... | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L289-L309 |
123,880 | influxdata/influxdb | tsdb/tsm1/reader_index.go | DeletePrefix | func (d *indirectIndex) DeletePrefix(prefix []byte, minTime, maxTime int64, dead func([]byte)) bool {
if dead == nil {
dead = func([]byte) {}
}
// If we're deleting everything, we won't need to worry about partial deletes.
partial := !(minTime <= d.minTime && maxTime >= d.maxTime)
// Is the range passed in out... | go | func (d *indirectIndex) DeletePrefix(prefix []byte, minTime, maxTime int64, dead func([]byte)) bool {
if dead == nil {
dead = func([]byte) {}
}
// If we're deleting everything, we won't need to worry about partial deletes.
partial := !(minTime <= d.minTime && maxTime >= d.maxTime)
// Is the range passed in out... | [
"func",
"(",
"d",
"*",
"indirectIndex",
")",
"DeletePrefix",
"(",
"prefix",
"[",
"]",
"byte",
",",
"minTime",
",",
"maxTime",
"int64",
",",
"dead",
"func",
"(",
"[",
"]",
"byte",
")",
")",
"bool",
"{",
"if",
"dead",
"==",
"nil",
"{",
"dead",
"=",
... | // DeletePrefix removes keys that begin with the given prefix with data between minTime and
// maxTime from the index. Returns true if there were any changes. It calls dead with any
// keys that became dead as a result of this call. | [
"DeletePrefix",
"removes",
"keys",
"that",
"begin",
"with",
"the",
"given",
"prefix",
"with",
"data",
"between",
"minTime",
"and",
"maxTime",
"from",
"the",
"index",
".",
"Returns",
"true",
"if",
"there",
"were",
"any",
"changes",
".",
"It",
"calls",
"dead",... | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L446-L549 |
123,881 | influxdata/influxdb | tsdb/tsm1/reader_index.go | Contains | func (d *indirectIndex) Contains(key []byte) bool {
d.mu.RLock()
iter := d.ro.Iterator()
exact, _ := iter.Seek(key, &d.b)
d.mu.RUnlock()
return exact
} | go | func (d *indirectIndex) Contains(key []byte) bool {
d.mu.RLock()
iter := d.ro.Iterator()
exact, _ := iter.Seek(key, &d.b)
d.mu.RUnlock()
return exact
} | [
"func",
"(",
"d",
"*",
"indirectIndex",
")",
"Contains",
"(",
"key",
"[",
"]",
"byte",
")",
"bool",
"{",
"d",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"iter",
":=",
"d",
".",
"ro",
".",
"Iterator",
"(",
")",
"\n",
"exact",
",",
"_",
":=",
"it... | // Contains return true if the given key exists in the index. | [
"Contains",
"return",
"true",
"if",
"the",
"given",
"key",
"exists",
"in",
"the",
"index",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L565-L571 |
123,882 | influxdata/influxdb | tsdb/tsm1/reader_index.go | MaybeContainsValue | func (d *indirectIndex) MaybeContainsValue(key []byte, timestamp int64) bool {
d.mu.RLock()
defer d.mu.RUnlock()
iter := d.ro.Iterator()
exact, _ := iter.Seek(key, &d.b)
if !exact {
return false
}
for _, t := range d.tombstones[iter.Offset()] {
if t.Min <= timestamp && timestamp <= t.Max {
return false
... | go | func (d *indirectIndex) MaybeContainsValue(key []byte, timestamp int64) bool {
d.mu.RLock()
defer d.mu.RUnlock()
iter := d.ro.Iterator()
exact, _ := iter.Seek(key, &d.b)
if !exact {
return false
}
for _, t := range d.tombstones[iter.Offset()] {
if t.Min <= timestamp && timestamp <= t.Max {
return false
... | [
"func",
"(",
"d",
"*",
"indirectIndex",
")",
"MaybeContainsValue",
"(",
"key",
"[",
"]",
"byte",
",",
"timestamp",
"int64",
")",
"bool",
"{",
"d",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"d",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
... | // MaybeContainsValue returns true if key and time might exist in this file. | [
"MaybeContainsValue",
"returns",
"true",
"if",
"key",
"and",
"time",
"might",
"exist",
"in",
"this",
"file",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L574-L607 |
123,883 | influxdata/influxdb | tsdb/tsm1/reader_index.go | Type | func (d *indirectIndex) Type(key []byte) (byte, error) {
d.mu.RLock()
defer d.mu.RUnlock()
iter := d.ro.Iterator()
exact, _ := iter.Seek(key, &d.b)
if !exact {
return 0, errors.New("key does not exist")
}
return d.b.access(iter.EntryOffset(&d.b), 1)[0], nil
} | go | func (d *indirectIndex) Type(key []byte) (byte, error) {
d.mu.RLock()
defer d.mu.RUnlock()
iter := d.ro.Iterator()
exact, _ := iter.Seek(key, &d.b)
if !exact {
return 0, errors.New("key does not exist")
}
return d.b.access(iter.EntryOffset(&d.b), 1)[0], nil
} | [
"func",
"(",
"d",
"*",
"indirectIndex",
")",
"Type",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"byte",
",",
"error",
")",
"{",
"d",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"d",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"iter",
":="... | // Type returns the block type of the values stored for the key. | [
"Type",
"returns",
"the",
"block",
"type",
"of",
"the",
"values",
"stored",
"for",
"the",
"key",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L610-L621 |
123,884 | influxdata/influxdb | tsdb/tsm1/reader_index.go | MarshalBinary | func (d *indirectIndex) MarshalBinary() ([]byte, error) {
d.mu.RLock()
defer d.mu.RUnlock()
return d.b.b, nil
} | go | func (d *indirectIndex) MarshalBinary() ([]byte, error) {
d.mu.RLock()
defer d.mu.RUnlock()
return d.b.b, nil
} | [
"func",
"(",
"d",
"*",
"indirectIndex",
")",
"MarshalBinary",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"d",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"d",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"d",
".",
... | // MarshalBinary returns a byte slice encoded version of the index. | [
"MarshalBinary",
"returns",
"a",
"byte",
"slice",
"encoded",
"version",
"of",
"the",
"index",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L658-L663 |
123,885 | influxdata/influxdb | tsdb/tsm1/reader_index.go | UnmarshalBinary | func (d *indirectIndex) UnmarshalBinary(b []byte) error {
d.mu.Lock()
defer d.mu.Unlock()
// Keep a reference to the actual index bytes
d.b = faultBuffer{b: b}
if len(b) == 0 {
return nil
}
// make sure a uint32 is sufficient to store any offset into the index.
if uint64(len(b)) != uint64(uint32(len(b))) {
... | go | func (d *indirectIndex) UnmarshalBinary(b []byte) error {
d.mu.Lock()
defer d.mu.Unlock()
// Keep a reference to the actual index bytes
d.b = faultBuffer{b: b}
if len(b) == 0 {
return nil
}
// make sure a uint32 is sufficient to store any offset into the index.
if uint64(len(b)) != uint64(uint32(len(b))) {
... | [
"func",
"(",
"d",
"*",
"indirectIndex",
")",
"UnmarshalBinary",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"d",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"// Keep a reference to the actual ind... | // UnmarshalBinary populates an index from an encoded byte slice
// representation of an index. | [
"UnmarshalBinary",
"populates",
"an",
"index",
"from",
"an",
"encoded",
"byte",
"slice",
"representation",
"of",
"an",
"index",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L667-L762 |
123,886 | influxdata/influxdb | tsdb/tsm1/reader_index.go | Size | func (d *indirectIndex) Size() uint32 {
d.mu.RLock()
defer d.mu.RUnlock()
return d.b.len()
} | go | func (d *indirectIndex) Size() uint32 {
d.mu.RLock()
defer d.mu.RUnlock()
return d.b.len()
} | [
"func",
"(",
"d",
"*",
"indirectIndex",
")",
"Size",
"(",
")",
"uint32",
"{",
"d",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"d",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"d",
".",
"b",
".",
"len",
"(",
")",
"\n",
"}"
] | // Size returns the size of the current index in bytes. | [
"Size",
"returns",
"the",
"size",
"of",
"the",
"current",
"index",
"in",
"bytes",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L765-L770 |
123,887 | influxdata/influxdb | tsdb/tsm1/reader_index.go | readEntriesTimes | func readEntriesTimes(b []byte, entries []IndexEntry) ([]IndexEntry, error) {
if len(b) < indexTypeSize+indexCountSize {
return entries[:0], errors.New("readEntries: data too short for headers")
}
count := int(binary.BigEndian.Uint16(b[indexTypeSize : indexTypeSize+indexCountSize]))
if cap(entries) < count {
e... | go | func readEntriesTimes(b []byte, entries []IndexEntry) ([]IndexEntry, error) {
if len(b) < indexTypeSize+indexCountSize {
return entries[:0], errors.New("readEntries: data too short for headers")
}
count := int(binary.BigEndian.Uint16(b[indexTypeSize : indexTypeSize+indexCountSize]))
if cap(entries) < count {
e... | [
"func",
"readEntriesTimes",
"(",
"b",
"[",
"]",
"byte",
",",
"entries",
"[",
"]",
"IndexEntry",
")",
"(",
"[",
"]",
"IndexEntry",
",",
"error",
")",
"{",
"if",
"len",
"(",
"b",
")",
"<",
"indexTypeSize",
"+",
"indexCountSize",
"{",
"return",
"entries",... | // readEntriesTimes is a helper function to read entries at the provided buffer but
// only reading in the min and max times. | [
"readEntriesTimes",
"is",
"a",
"helper",
"function",
"to",
"read",
"entries",
"at",
"the",
"provided",
"buffer",
"but",
"only",
"reading",
"in",
"the",
"min",
"and",
"max",
"times",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_index.go#L806-L829 |
123,888 | influxdata/influxdb | measurement.go | ReadMeasurement | func ReadMeasurement(name []byte) (orgID, bucketID []byte, err error) {
if len(name) != MeasurementLength {
return nil, nil, fmt.Errorf("measurement %v has invalid length (%d)", name, len(name))
}
return name[:OrgIDLength], name[len(name)-BucketIDLength:], nil
} | go | func ReadMeasurement(name []byte) (orgID, bucketID []byte, err error) {
if len(name) != MeasurementLength {
return nil, nil, fmt.Errorf("measurement %v has invalid length (%d)", name, len(name))
}
return name[:OrgIDLength], name[len(name)-BucketIDLength:], nil
} | [
"func",
"ReadMeasurement",
"(",
"name",
"[",
"]",
"byte",
")",
"(",
"orgID",
",",
"bucketID",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"name",
")",
"!=",
"MeasurementLength",
"{",
"return",
"nil",
",",
"nil",
",",
"fmt",
"... | // ReadMeasurement reads the provided measurement name and returns an Org ID and
// bucket ID. It returns an error if the provided name has an invalid length.
//
// ReadMeasurement does not allocate, and instead returns sub-slices of name,
// so callers should be careful about subsequent mutations to the provided name
... | [
"ReadMeasurement",
"reads",
"the",
"provided",
"measurement",
"name",
"and",
"returns",
"an",
"Org",
"ID",
"and",
"bucket",
"ID",
".",
"It",
"returns",
"an",
"error",
"if",
"the",
"provided",
"name",
"has",
"an",
"invalid",
"length",
".",
"ReadMeasurement",
... | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/measurement.go#L18-L23 |
123,889 | influxdata/influxdb | measurement.go | CreateMeasurement | func CreateMeasurement(org, bucket []byte) ([]byte, error) {
if len(org) < OrgIDLength {
return nil, fmt.Errorf("org %v has invalid length (%d)", org, len(org))
} else if len(bucket) < BucketIDLength {
return nil, fmt.Errorf("bucket %v has invalid length (%d)", bucket, len(bucket))
}
name := make([]byte, 0, Me... | go | func CreateMeasurement(org, bucket []byte) ([]byte, error) {
if len(org) < OrgIDLength {
return nil, fmt.Errorf("org %v has invalid length (%d)", org, len(org))
} else if len(bucket) < BucketIDLength {
return nil, fmt.Errorf("bucket %v has invalid length (%d)", bucket, len(bucket))
}
name := make([]byte, 0, Me... | [
"func",
"CreateMeasurement",
"(",
"org",
",",
"bucket",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"len",
"(",
"org",
")",
"<",
"OrgIDLength",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",... | // CreateMeasurement returns 16 bytes that represent a measurement.
//
// If either org or bucket are short then an error is returned, otherwise the
// first 8 bytes of each are combined and returned. | [
"CreateMeasurement",
"returns",
"16",
"bytes",
"that",
"represent",
"a",
"measurement",
".",
"If",
"either",
"org",
"or",
"bucket",
"are",
"short",
"then",
"an",
"error",
"is",
"returned",
"otherwise",
"the",
"first",
"8",
"bytes",
"of",
"each",
"are",
"comb... | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/measurement.go#L29-L39 |
123,890 | influxdata/influxdb | query/control/controller.go | Shutdown | func (c *Controller) Shutdown(ctx context.Context) error {
return c.c.Shutdown(ctx)
} | go | func (c *Controller) Shutdown(ctx context.Context) error {
return c.c.Shutdown(ctx)
} | [
"func",
"(",
"c",
"*",
"Controller",
")",
"Shutdown",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"return",
"c",
".",
"c",
".",
"Shutdown",
"(",
"ctx",
")",
"\n",
"}"
] | // Shutdown shuts down the underlying Controller. | [
"Shutdown",
"shuts",
"down",
"the",
"underlying",
"Controller",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/query/control/controller.go#L62-L64 |
123,891 | influxdata/influxdb | mock/passwords.go | NewPasswordsService | func NewPasswordsService(user, password string) *PasswordsService {
return &PasswordsService{
SetPasswordFn: func(context.Context, string, string) error { return fmt.Errorf("mock error") },
ComparePasswordFn: func(context.Context, string, string) error { return fmt.Errorf("mock error") },
Compare... | go | func NewPasswordsService(user, password string) *PasswordsService {
return &PasswordsService{
SetPasswordFn: func(context.Context, string, string) error { return fmt.Errorf("mock error") },
ComparePasswordFn: func(context.Context, string, string) error { return fmt.Errorf("mock error") },
Compare... | [
"func",
"NewPasswordsService",
"(",
"user",
",",
"password",
"string",
")",
"*",
"PasswordsService",
"{",
"return",
"&",
"PasswordsService",
"{",
"SetPasswordFn",
":",
"func",
"(",
"context",
".",
"Context",
",",
"string",
",",
"string",
")",
"error",
"{",
"... | // NewPasswordsService returns a mock PasswordsService where its methods will return
// zero values. | [
"NewPasswordsService",
"returns",
"a",
"mock",
"PasswordsService",
"where",
"its",
"methods",
"will",
"return",
"zero",
"values",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/mock/passwords.go#L18-L24 |
123,892 | influxdata/influxdb | mock/passwords.go | SetPassword | func (s *PasswordsService) SetPassword(ctx context.Context, name string, password string) error {
return s.SetPasswordFn(ctx, name, password)
} | go | func (s *PasswordsService) SetPassword(ctx context.Context, name string, password string) error {
return s.SetPasswordFn(ctx, name, password)
} | [
"func",
"(",
"s",
"*",
"PasswordsService",
")",
"SetPassword",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"password",
"string",
")",
"error",
"{",
"return",
"s",
".",
"SetPasswordFn",
"(",
"ctx",
",",
"name",
",",
"password",
")",... | // SetPassword sets the users current password to be the provided password. | [
"SetPassword",
"sets",
"the",
"users",
"current",
"password",
"to",
"be",
"the",
"provided",
"password",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/mock/passwords.go#L27-L29 |
123,893 | influxdata/influxdb | mock/passwords.go | ComparePassword | func (s *PasswordsService) ComparePassword(ctx context.Context, name string, password string) error {
return s.ComparePasswordFn(ctx, name, password)
} | go | func (s *PasswordsService) ComparePassword(ctx context.Context, name string, password string) error {
return s.ComparePasswordFn(ctx, name, password)
} | [
"func",
"(",
"s",
"*",
"PasswordsService",
")",
"ComparePassword",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"password",
"string",
")",
"error",
"{",
"return",
"s",
".",
"ComparePasswordFn",
"(",
"ctx",
",",
"name",
",",
"password"... | // ComparePassword password compares the provided password. | [
"ComparePassword",
"password",
"compares",
"the",
"provided",
"password",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/mock/passwords.go#L32-L34 |
123,894 | influxdata/influxdb | storage/reads/resultset.go | Close | func (r *resultSet) Close() {
if r == nil {
return // Nothing to do.
}
r.row.Query = nil
r.cur.Close()
} | go | func (r *resultSet) Close() {
if r == nil {
return // Nothing to do.
}
r.row.Query = nil
r.cur.Close()
} | [
"func",
"(",
"r",
"*",
"resultSet",
")",
"Close",
"(",
")",
"{",
"if",
"r",
"==",
"nil",
"{",
"return",
"// Nothing to do.",
"\n",
"}",
"\n",
"r",
".",
"row",
".",
"Query",
"=",
"nil",
"\n",
"r",
".",
"cur",
".",
"Close",
"(",
")",
"\n",
"}"
] | // Close closes the result set. Close is idempotent. | [
"Close",
"closes",
"the",
"result",
"set",
".",
"Close",
"is",
"idempotent",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/storage/reads/resultset.go#L36-L42 |
123,895 | influxdata/influxdb | storage/reads/resultset.go | Next | func (r *resultSet) Next() bool {
if r == nil {
return false
}
row := r.cur.Next()
if row == nil {
return false
}
r.row = *row
return true
} | go | func (r *resultSet) Next() bool {
if r == nil {
return false
}
row := r.cur.Next()
if row == nil {
return false
}
r.row = *row
return true
} | [
"func",
"(",
"r",
"*",
"resultSet",
")",
"Next",
"(",
")",
"bool",
"{",
"if",
"r",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"row",
":=",
"r",
".",
"cur",
".",
"Next",
"(",
")",
"\n",
"if",
"row",
"==",
"nil",
"{",
"return",
"fa... | // Next returns true if there are more results available. | [
"Next",
"returns",
"true",
"if",
"there",
"are",
"more",
"results",
"available",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/storage/reads/resultset.go#L45-L58 |
123,896 | influxdata/influxdb | tsdb/tsm1/reader_mmap.go | readAll | func (m *mmapAccessor) readAll(key []byte) ([]Value, error) {
m.incAccess()
blocks, err := m.index.ReadEntries(key, nil)
if len(blocks) == 0 || err != nil {
return nil, err
}
tombstones := m.index.TombstoneRange(key, nil)
m.mu.RLock()
defer m.mu.RUnlock()
var temp []Value
var values []Value
for _, block... | go | func (m *mmapAccessor) readAll(key []byte) ([]Value, error) {
m.incAccess()
blocks, err := m.index.ReadEntries(key, nil)
if len(blocks) == 0 || err != nil {
return nil, err
}
tombstones := m.index.TombstoneRange(key, nil)
m.mu.RLock()
defer m.mu.RUnlock()
var temp []Value
var values []Value
for _, block... | [
"func",
"(",
"m",
"*",
"mmapAccessor",
")",
"readAll",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"Value",
",",
"error",
")",
"{",
"m",
".",
"incAccess",
"(",
")",
"\n\n",
"blocks",
",",
"err",
":=",
"m",
".",
"index",
".",
"ReadEntries",
... | // readAll returns all values for a key in all blocks. | [
"readAll",
"returns",
"all",
"values",
"for",
"a",
"key",
"in",
"all",
"blocks",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/tsdb/tsm1/reader_mmap.go#L205-L250 |
123,897 | influxdata/influxdb | prometheus/auth_service.go | NewAuthorizationService | func NewAuthorizationService() *AuthorizationService {
// TODO: what to make these values
namespace := "auth"
subsystem := "prometheus"
s := &AuthorizationService{
requestCount: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "requests_total",
He... | go | func NewAuthorizationService() *AuthorizationService {
// TODO: what to make these values
namespace := "auth"
subsystem := "prometheus"
s := &AuthorizationService{
requestCount: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "requests_total",
He... | [
"func",
"NewAuthorizationService",
"(",
")",
"*",
"AuthorizationService",
"{",
"// TODO: what to make these values",
"namespace",
":=",
"\"",
"\"",
"\n",
"subsystem",
":=",
"\"",
"\"",
"\n",
"s",
":=",
"&",
"AuthorizationService",
"{",
"requestCount",
":",
"promethe... | // NewAuthorizationService creates an instance of AuthorizationService. | [
"NewAuthorizationService",
"creates",
"an",
"instance",
"of",
"AuthorizationService",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/prometheus/auth_service.go#L20-L42 |
123,898 | influxdata/influxdb | prometheus/auth_service.go | FindAuthorizations | func (s *AuthorizationService) FindAuthorizations(ctx context.Context, filter platform.AuthorizationFilter, opt ...platform.FindOptions) (as []*platform.Authorization, i int, err error) {
defer func(start time.Time) {
labels := prometheus.Labels{
"method": "FindAuthorizations",
"error": fmt.Sprint(err != nil)... | go | func (s *AuthorizationService) FindAuthorizations(ctx context.Context, filter platform.AuthorizationFilter, opt ...platform.FindOptions) (as []*platform.Authorization, i int, err error) {
defer func(start time.Time) {
labels := prometheus.Labels{
"method": "FindAuthorizations",
"error": fmt.Sprint(err != nil)... | [
"func",
"(",
"s",
"*",
"AuthorizationService",
")",
"FindAuthorizations",
"(",
"ctx",
"context",
".",
"Context",
",",
"filter",
"platform",
".",
"AuthorizationFilter",
",",
"opt",
"...",
"platform",
".",
"FindOptions",
")",
"(",
"as",
"[",
"]",
"*",
"platfor... | // FindAuthorizations returns authorizations given a filter, records function call latency, and counts function calls. | [
"FindAuthorizations",
"returns",
"authorizations",
"given",
"a",
"filter",
"records",
"function",
"call",
"latency",
"and",
"counts",
"function",
"calls",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/prometheus/auth_service.go#L71-L82 |
123,899 | influxdata/influxdb | prometheus/auth_service.go | UpdateAuthorization | func (s *AuthorizationService) UpdateAuthorization(ctx context.Context, id platform.ID, upd *platform.AuthorizationUpdate) (a *platform.Authorization, err error) {
defer func(start time.Time) {
labels := prometheus.Labels{
"method": "setAuthorizationStatus",
"error": fmt.Sprint(err != nil),
}
s.requestCou... | go | func (s *AuthorizationService) UpdateAuthorization(ctx context.Context, id platform.ID, upd *platform.AuthorizationUpdate) (a *platform.Authorization, err error) {
defer func(start time.Time) {
labels := prometheus.Labels{
"method": "setAuthorizationStatus",
"error": fmt.Sprint(err != nil),
}
s.requestCou... | [
"func",
"(",
"s",
"*",
"AuthorizationService",
")",
"UpdateAuthorization",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"platform",
".",
"ID",
",",
"upd",
"*",
"platform",
".",
"AuthorizationUpdate",
")",
"(",
"a",
"*",
"platform",
".",
"Authorization",... | // UpdateAuthorization updates the status and description. | [
"UpdateAuthorization",
"updates",
"the",
"status",
"and",
"description",
"."
] | 16d0bbb0cd468fd51f412021a76ae5c4b450dea8 | https://github.com/influxdata/influxdb/blob/16d0bbb0cd468fd51f412021a76ae5c4b450dea8/prometheus/auth_service.go#L113-L124 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.