id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
123,500 | rakyll/gom | internal/report/report.go | isRedundant | func isRedundant(e *edgeInfo) bool {
destPred := predecessors(e, e.dest)
if len(destPred) == 1 {
return false
}
srcPred := predecessors(e, e.src)
for n := range srcPred {
if destPred[n] && n != e.dest {
return true
}
}
return false
} | go | func isRedundant(e *edgeInfo) bool {
destPred := predecessors(e, e.dest)
if len(destPred) == 1 {
return false
}
srcPred := predecessors(e, e.src)
for n := range srcPred {
if destPred[n] && n != e.dest {
return true
}
}
return false
} | [
"func",
"isRedundant",
"(",
"e",
"*",
"edgeInfo",
")",
"bool",
"{",
"destPred",
":=",
"predecessors",
"(",
"e",
",",
"e",
".",
"dest",
")",
"\n",
"if",
"len",
"(",
"destPred",
")",
"==",
"1",
"{",
"return",
"false",
"\n",
"}",
"\n",
"srcPred",
":="... | // isRedundant determines if an edge can be removed without impacting
// connectivity of the whole graph. This is implemented by checking if the
// nodes have a common ancestor after removing the edge. | [
"isRedundant",
"determines",
"if",
"an",
"edge",
"can",
"be",
"removed",
"without",
"impacting",
"connectivity",
"of",
"the",
"whole",
"graph",
".",
"This",
"is",
"implemented",
"by",
"checking",
"if",
"the",
"nodes",
"have",
"a",
"common",
"ancestor",
"after"... | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/report/report.go#L1332-L1345 |
123,501 | rakyll/gom | internal/report/report.go | predecessors | func predecessors(e *edgeInfo, n *node) map[*node]bool {
seen := map[*node]bool{n: true}
queue := []*node{n}
for len(queue) > 0 {
n := queue[0]
queue = queue[1:]
for _, ie := range n.in {
if e == ie || seen[ie.src] {
continue
}
seen[ie.src] = true
queue = append(queue, ie.src)
}
}
return se... | go | func predecessors(e *edgeInfo, n *node) map[*node]bool {
seen := map[*node]bool{n: true}
queue := []*node{n}
for len(queue) > 0 {
n := queue[0]
queue = queue[1:]
for _, ie := range n.in {
if e == ie || seen[ie.src] {
continue
}
seen[ie.src] = true
queue = append(queue, ie.src)
}
}
return se... | [
"func",
"predecessors",
"(",
"e",
"*",
"edgeInfo",
",",
"n",
"*",
"node",
")",
"map",
"[",
"*",
"node",
"]",
"bool",
"{",
"seen",
":=",
"map",
"[",
"*",
"node",
"]",
"bool",
"{",
"n",
":",
"true",
"}",
"\n",
"queue",
":=",
"[",
"]",
"*",
"nod... | // predecessors collects all the predecessors to node n, excluding edge e. | [
"predecessors",
"collects",
"all",
"the",
"predecessors",
"to",
"node",
"n",
"excluding",
"edge",
"e",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/report/report.go#L1348-L1363 |
123,502 | rakyll/gom | internal/report/report.go | ScaleValue | func ScaleValue(value int64, fromUnit, toUnit string) (sv float64, su string) {
// Avoid infinite recursion on overflow.
if value < 0 && -value > 0 {
v, u := ScaleValue(-value, fromUnit, toUnit)
return -v, u
}
if m, u, ok := memoryLabel(value, fromUnit, toUnit); ok {
return m, u
}
if t, u, ok := timeLabel(v... | go | func ScaleValue(value int64, fromUnit, toUnit string) (sv float64, su string) {
// Avoid infinite recursion on overflow.
if value < 0 && -value > 0 {
v, u := ScaleValue(-value, fromUnit, toUnit)
return -v, u
}
if m, u, ok := memoryLabel(value, fromUnit, toUnit); ok {
return m, u
}
if t, u, ok := timeLabel(v... | [
"func",
"ScaleValue",
"(",
"value",
"int64",
",",
"fromUnit",
",",
"toUnit",
"string",
")",
"(",
"sv",
"float64",
",",
"su",
"string",
")",
"{",
"// Avoid infinite recursion on overflow.",
"if",
"value",
"<",
"0",
"&&",
"-",
"value",
">",
"0",
"{",
"v",
... | // ScaleValue reformats a value from a unit to a different unit. | [
"ScaleValue",
"reformats",
"a",
"value",
"from",
"a",
"unit",
"to",
"a",
"different",
"unit",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/report/report.go#L1510-L1529 |
123,503 | rakyll/gom | internal/report/report.go | prettyName | func (info *nodeInfo) prettyName() string {
var name string
if info.address != 0 {
name = fmt.Sprintf("%016x", info.address)
}
if info.name != "" {
name = name + " " + info.name
}
if info.file != "" {
name += " " + trimPath(info.file)
if info.lineno != 0 {
name += fmt.Sprintf(":%d", info.lineno)
}
... | go | func (info *nodeInfo) prettyName() string {
var name string
if info.address != 0 {
name = fmt.Sprintf("%016x", info.address)
}
if info.name != "" {
name = name + " " + info.name
}
if info.file != "" {
name += " " + trimPath(info.file)
if info.lineno != 0 {
name += fmt.Sprintf(":%d", info.lineno)
}
... | [
"func",
"(",
"info",
"*",
"nodeInfo",
")",
"prettyName",
"(",
")",
"string",
"{",
"var",
"name",
"string",
"\n",
"if",
"info",
".",
"address",
"!=",
"0",
"{",
"name",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"info",
".",
"address",
")",
... | // prettyName determines the printable name to be used for a node. | [
"prettyName",
"determines",
"the",
"printable",
"name",
"to",
"be",
"used",
"for",
"a",
"node",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/report/report.go#L1662-L1687 |
123,504 | rakyll/gom | internal/report/report.go | NewDefault | func NewDefault(prof *profile.Profile, options Options) *Report {
index := len(prof.SampleType) - 1
o := &options
if o.SampleUnit == "" {
o.SampleUnit = strings.ToLower(prof.SampleType[index].Unit)
}
value := func(s *profile.Sample) int64 {
return s.Value[index]
}
format := func(v int64) string {
if r := o... | go | func NewDefault(prof *profile.Profile, options Options) *Report {
index := len(prof.SampleType) - 1
o := &options
if o.SampleUnit == "" {
o.SampleUnit = strings.ToLower(prof.SampleType[index].Unit)
}
value := func(s *profile.Sample) int64 {
return s.Value[index]
}
format := func(v int64) string {
if r := o... | [
"func",
"NewDefault",
"(",
"prof",
"*",
"profile",
".",
"Profile",
",",
"options",
"Options",
")",
"*",
"Report",
"{",
"index",
":=",
"len",
"(",
"prof",
".",
"SampleType",
")",
"-",
"1",
"\n",
"o",
":=",
"&",
"options",
"\n",
"if",
"o",
".",
"Samp... | // NewDefault builds a new report indexing the sample values with the
// last value available. | [
"NewDefault",
"builds",
"a",
"new",
"report",
"indexing",
"the",
"sample",
"values",
"with",
"the",
"last",
"value",
"available",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/report/report.go#L1708-L1725 |
123,505 | rakyll/gom | internal/commands/commands.go | NewCompleter | func NewCompleter(cs Commands) Completer {
return func(line string) string {
switch tokens := strings.Fields(line); len(tokens) {
case 0:
// Nothing to complete
case 1:
// Single token -- complete command name
found := ""
for c := range cs {
if strings.HasPrefix(c, tokens[0]) {
if found != "... | go | func NewCompleter(cs Commands) Completer {
return func(line string) string {
switch tokens := strings.Fields(line); len(tokens) {
case 0:
// Nothing to complete
case 1:
// Single token -- complete command name
found := ""
for c := range cs {
if strings.HasPrefix(c, tokens[0]) {
if found != "... | [
"func",
"NewCompleter",
"(",
"cs",
"Commands",
")",
"Completer",
"{",
"return",
"func",
"(",
"line",
"string",
")",
"string",
"{",
"switch",
"tokens",
":=",
"strings",
".",
"Fields",
"(",
"line",
")",
";",
"len",
"(",
"tokens",
")",
"{",
"case",
"0",
... | // NewCompleter creates an autocompletion function for a set of commands. | [
"NewCompleter",
"creates",
"an",
"autocompletion",
"function",
"for",
"a",
"set",
"of",
"commands",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/commands/commands.go#L104-L140 |
123,506 | rakyll/gom | internal/fetch/fetch.go | Fetcher | func Fetcher(source string, timeout time.Duration, ui plugin.UI) (*profile.Profile, error) {
var f io.ReadCloser
var err error
url, err := url.Parse(source)
if err == nil && url.Host != "" {
f, err = FetchURL(source, timeout)
} else {
f, err = os.Open(source)
}
if err != nil {
return nil, err
}
defer f.... | go | func Fetcher(source string, timeout time.Duration, ui plugin.UI) (*profile.Profile, error) {
var f io.ReadCloser
var err error
url, err := url.Parse(source)
if err == nil && url.Host != "" {
f, err = FetchURL(source, timeout)
} else {
f, err = os.Open(source)
}
if err != nil {
return nil, err
}
defer f.... | [
"func",
"Fetcher",
"(",
"source",
"string",
",",
"timeout",
"time",
".",
"Duration",
",",
"ui",
"plugin",
".",
"UI",
")",
"(",
"*",
"profile",
".",
"Profile",
",",
"error",
")",
"{",
"var",
"f",
"io",
".",
"ReadCloser",
"\n",
"var",
"err",
"error",
... | // Fetcher is the plugin.Fetcher version of FetchProfile. | [
"Fetcher",
"is",
"the",
"plugin",
".",
"Fetcher",
"version",
"of",
"FetchProfile",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/fetch/fetch.go#L30-L45 |
123,507 | rakyll/gom | internal/fetch/fetch.go | FetchURL | func FetchURL(source string, timeout time.Duration) (io.ReadCloser, error) {
resp, err := httpGet(source, timeout)
if err != nil {
return nil, fmt.Errorf("http fetch %s: %v", source, err)
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("server response: %s", resp.Status)
}
return resp.Body, ni... | go | func FetchURL(source string, timeout time.Duration) (io.ReadCloser, error) {
resp, err := httpGet(source, timeout)
if err != nil {
return nil, fmt.Errorf("http fetch %s: %v", source, err)
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("server response: %s", resp.Status)
}
return resp.Body, ni... | [
"func",
"FetchURL",
"(",
"source",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"httpGet",
"(",
"source",
",",
"timeout",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // FetchURL fetches a profile from a URL using HTTP. | [
"FetchURL",
"fetches",
"a",
"profile",
"from",
"a",
"URL",
"using",
"HTTP",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/fetch/fetch.go#L48-L58 |
123,508 | rakyll/gom | internal/fetch/fetch.go | PostURL | func PostURL(source, post string) ([]byte, error) {
resp, err := http.Post(source, "application/octet-stream", strings.NewReader(post))
if err != nil {
return nil, fmt.Errorf("http post %s: %v", source, err)
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("server response: %s", resp.Status)
}
d... | go | func PostURL(source, post string) ([]byte, error) {
resp, err := http.Post(source, "application/octet-stream", strings.NewReader(post))
if err != nil {
return nil, fmt.Errorf("http post %s: %v", source, err)
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("server response: %s", resp.Status)
}
d... | [
"func",
"PostURL",
"(",
"source",
",",
"post",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"http",
".",
"Post",
"(",
"source",
",",
"\"",
"\"",
",",
"strings",
".",
"NewReader",
"(",
"post",
")",
")",
... | // PostURL issues a POST to a URL over HTTP. | [
"PostURL",
"issues",
"a",
"POST",
"to",
"a",
"URL",
"over",
"HTTP",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/fetch/fetch.go#L61-L71 |
123,509 | rakyll/gom | cmd/gom/report.go | fetch | func (r *report) fetch(force bool, secs time.Duration) error {
r.mu.Lock()
defer r.mu.Unlock()
if r.p != nil && !force {
return nil
}
if secs == 0 {
secs = 60 * time.Second
}
url := fmt.Sprintf("%s/debug/_gom?view=profile&name=%s", *target, r.name)
p, err := fetch.FetchProfile(url, secs)
if err != nil {
... | go | func (r *report) fetch(force bool, secs time.Duration) error {
r.mu.Lock()
defer r.mu.Unlock()
if r.p != nil && !force {
return nil
}
if secs == 0 {
secs = 60 * time.Second
}
url := fmt.Sprintf("%s/debug/_gom?view=profile&name=%s", *target, r.name)
p, err := fetch.FetchProfile(url, secs)
if err != nil {
... | [
"func",
"(",
"r",
"*",
"report",
")",
"fetch",
"(",
"force",
"bool",
",",
"secs",
"time",
".",
"Duration",
")",
"error",
"{",
"r",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"r",
".",... | // fetch fetches the current profile and the symbols from the target program. | [
"fetch",
"fetches",
"the",
"current",
"profile",
"and",
"the",
"symbols",
"from",
"the",
"target",
"program",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/cmd/gom/report.go#L39-L58 |
123,510 | rakyll/gom | cmd/gom/report.go | filter | func (r *report) filter(cum bool, focus *regexp.Regexp) []string {
r.mu.Lock()
defer r.mu.Unlock()
if r.p == nil {
return nil
}
c := r.p.Copy()
c.FilterSamplesByName(focus, nil, nil)
rpt := goreport.NewDefault(c, goreport.Options{
OutputFormat: goreport.Text,
CumSort: cum,
PrintAddresses: true,
... | go | func (r *report) filter(cum bool, focus *regexp.Regexp) []string {
r.mu.Lock()
defer r.mu.Unlock()
if r.p == nil {
return nil
}
c := r.p.Copy()
c.FilterSamplesByName(focus, nil, nil)
rpt := goreport.NewDefault(c, goreport.Options{
OutputFormat: goreport.Text,
CumSort: cum,
PrintAddresses: true,
... | [
"func",
"(",
"r",
"*",
"report",
")",
"filter",
"(",
"cum",
"bool",
",",
"focus",
"*",
"regexp",
".",
"Regexp",
")",
"[",
"]",
"string",
"{",
"r",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",... | // filter filters the report with a focus regex. If no focus is provided,
// it reports back with the entire set of calls.
// Focus regex works on the package, type and function names. Filtered
// results will include parent samples from the call graph. | [
"filter",
"filters",
"the",
"report",
"with",
"a",
"focus",
"regex",
".",
"If",
"no",
"focus",
"is",
"provided",
"it",
"reports",
"back",
"with",
"the",
"entire",
"set",
"of",
"calls",
".",
"Focus",
"regex",
"works",
"on",
"the",
"package",
"type",
"and"... | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/cmd/gom/report.go#L64-L80 |
123,511 | rakyll/gom | internal/driver/interactive.go | functionCompleter | func functionCompleter(substring string) string {
found := ""
for _, fName := range profileFunctionNames {
if strings.Contains(fName, substring) {
if found != "" {
return substring
}
found = fName
}
}
if found != "" {
return found
}
return substring
} | go | func functionCompleter(substring string) string {
found := ""
for _, fName := range profileFunctionNames {
if strings.Contains(fName, substring) {
if found != "" {
return substring
}
found = fName
}
}
if found != "" {
return found
}
return substring
} | [
"func",
"functionCompleter",
"(",
"substring",
"string",
")",
"string",
"{",
"found",
":=",
"\"",
"\"",
"\n",
"for",
"_",
",",
"fName",
":=",
"range",
"profileFunctionNames",
"{",
"if",
"strings",
".",
"Contains",
"(",
"fName",
",",
"substring",
")",
"{",
... | // functionCompleter replaces provided substring with a function
// name retrieved from a profile if a single match exists. Otherwise,
// it returns unchanged substring. It defaults to no-op if the profile
// is not specified. | [
"functionCompleter",
"replaces",
"provided",
"substring",
"with",
"a",
"function",
"name",
"retrieved",
"from",
"a",
"profile",
"if",
"a",
"single",
"match",
"exists",
".",
"Otherwise",
"it",
"returns",
"unchanged",
"substring",
".",
"It",
"defaults",
"to",
"no"... | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/driver/interactive.go#L26-L40 |
123,512 | rakyll/gom | internal/driver/interactive.go | updateAutoComplete | func updateAutoComplete(p *profile.Profile) {
profileFunctionNames = nil // remove function names retrieved previously
for _, fn := range p.Function {
profileFunctionNames = append(profileFunctionNames, fn.Name)
}
} | go | func updateAutoComplete(p *profile.Profile) {
profileFunctionNames = nil // remove function names retrieved previously
for _, fn := range p.Function {
profileFunctionNames = append(profileFunctionNames, fn.Name)
}
} | [
"func",
"updateAutoComplete",
"(",
"p",
"*",
"profile",
".",
"Profile",
")",
"{",
"profileFunctionNames",
"=",
"nil",
"// remove function names retrieved previously",
"\n",
"for",
"_",
",",
"fn",
":=",
"range",
"p",
".",
"Function",
"{",
"profileFunctionNames",
"=... | // updateAutoComplete enhances autocompletion with information that can be
// retrieved from the profile | [
"updateAutoComplete",
"enhances",
"autocompletion",
"with",
"information",
"that",
"can",
"be",
"retrieved",
"from",
"the",
"profile"
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/driver/interactive.go#L44-L49 |
123,513 | rakyll/gom | internal/driver/interactive.go | validateRegex | func validateRegex(v string) error {
_, err := regexp.Compile(v)
return err
} | go | func validateRegex(v string) error {
_, err := regexp.Compile(v)
return err
} | [
"func",
"validateRegex",
"(",
"v",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"regexp",
".",
"Compile",
"(",
"v",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // validateRegex checks if a string is a valid regular expression. | [
"validateRegex",
"checks",
"if",
"a",
"string",
"is",
"a",
"valid",
"regular",
"expression",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/driver/interactive.go#L137-L140 |
123,514 | rakyll/gom | internal/driver/interactive.go | readCommand | func readCommand(p *profile.Profile, ui plugin.UI, f *flags) (string, error) {
//ui.Print("Options:\n", f.String(p))
s, err := ui.ReadLine()
return strings.TrimSpace(s), err
} | go | func readCommand(p *profile.Profile, ui plugin.UI, f *flags) (string, error) {
//ui.Print("Options:\n", f.String(p))
s, err := ui.ReadLine()
return strings.TrimSpace(s), err
} | [
"func",
"readCommand",
"(",
"p",
"*",
"profile",
".",
"Profile",
",",
"ui",
"plugin",
".",
"UI",
",",
"f",
"*",
"flags",
")",
"(",
"string",
",",
"error",
")",
"{",
"//ui.Print(\"Options:\\n\", f.String(p))",
"s",
",",
"err",
":=",
"ui",
".",
"ReadLine",... | // readCommand prompts for and reads the next command. | [
"readCommand",
"prompts",
"for",
"and",
"reads",
"the",
"next",
"command",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/driver/interactive.go#L143-L147 |
123,515 | rakyll/gom | internal/driver/interactive.go | parseBool | func parseBool(v string) (bool, error) {
switch strings.ToLower(v) {
case "true", "t", "yes", "y", "1", "":
return true, nil
case "false", "f", "no", "n", "0":
return false, nil
}
return false, fmt.Errorf(`illegal input "%s" for bool value`, v)
} | go | func parseBool(v string) (bool, error) {
switch strings.ToLower(v) {
case "true", "t", "yes", "y", "1", "":
return true, nil
case "false", "f", "no", "n", "0":
return false, nil
}
return false, fmt.Errorf(`illegal input "%s" for bool value`, v)
} | [
"func",
"parseBool",
"(",
"v",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"switch",
"strings",
".",
"ToLower",
"(",
"v",
")",
"{",
"case",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"... | // parseBool parses a string as a boolean value. | [
"parseBool",
"parses",
"a",
"string",
"as",
"a",
"boolean",
"value",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/driver/interactive.go#L449-L457 |
123,516 | rakyll/gom | internal/driver/interactive.go | setGranularityToggle | func setGranularityToggle(o string, fl *flags) {
t, f := newBool(true), newBool(false)
fl.flagFunctions = f
fl.flagFiles = f
fl.flagLines = f
fl.flagAddresses = f
switch o {
case "functions":
fl.flagFunctions = t
case "files":
fl.flagFiles = t
case "lines":
fl.flagLines = t
case "addresses":
fl.flagAd... | go | func setGranularityToggle(o string, fl *flags) {
t, f := newBool(true), newBool(false)
fl.flagFunctions = f
fl.flagFiles = f
fl.flagLines = f
fl.flagAddresses = f
switch o {
case "functions":
fl.flagFunctions = t
case "files":
fl.flagFiles = t
case "lines":
fl.flagLines = t
case "addresses":
fl.flagAd... | [
"func",
"setGranularityToggle",
"(",
"o",
"string",
",",
"fl",
"*",
"flags",
")",
"{",
"t",
",",
"f",
":=",
"newBool",
"(",
"true",
")",
",",
"newBool",
"(",
"false",
")",
"\n",
"fl",
".",
"flagFunctions",
"=",
"f",
"\n",
"fl",
".",
"flagFiles",
"=... | // setGranularityToggle manages the set of granularity options. These
// operate as a toggle; turning one on turns the others off. | [
"setGranularityToggle",
"manages",
"the",
"set",
"of",
"granularity",
"options",
".",
"These",
"operate",
"as",
"a",
"toggle",
";",
"turning",
"one",
"on",
"turns",
"the",
"others",
"off",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/driver/interactive.go#L474-L492 |
123,517 | rakyll/gom | internal/svg/svg.go | Massage | func Massage(in bytes.Buffer) string {
svg := string(in.Bytes())
// Work around for dot bug which misses quoting some ampersands,
// resulting on unparsable SVG.
svg = strings.Replace(svg, "&;", "&;", -1)
//Dot's SVG output is
//
// <svg width="___" height="___"
// viewBox="___" xmlns=...>
// <... | go | func Massage(in bytes.Buffer) string {
svg := string(in.Bytes())
// Work around for dot bug which misses quoting some ampersands,
// resulting on unparsable SVG.
svg = strings.Replace(svg, "&;", "&;", -1)
//Dot's SVG output is
//
// <svg width="___" height="___"
// viewBox="___" xmlns=...>
// <... | [
"func",
"Massage",
"(",
"in",
"bytes",
".",
"Buffer",
")",
"string",
"{",
"svg",
":=",
"string",
"(",
"in",
".",
"Bytes",
"(",
")",
")",
"\n\n",
"// Work around for dot bug which misses quoting some ampersands,",
"// resulting on unparsable SVG.",
"svg",
"=",
"strin... | // Massage enhances the SVG output from DOT to provide better
// panning inside a web browser. It uses the SVGPan library, which is
// included directly. | [
"Massage",
"enhances",
"the",
"SVG",
"output",
"from",
"DOT",
"to",
"provide",
"better",
"panning",
"inside",
"a",
"web",
"browser",
".",
"It",
"uses",
"the",
"SVGPan",
"library",
"which",
"is",
"included",
"directly",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/svg/svg.go#L23-L71 |
123,518 | rakyll/gom | internal/profile/profile.go | setMain | func (p *Profile) setMain() {
for i := 0; i < len(p.Mapping); i++ {
file := strings.TrimSpace(strings.Replace(p.Mapping[i].File, "(deleted)", "", -1))
if len(file) == 0 {
continue
}
if len(libRx.FindStringSubmatch(file)) > 0 {
continue
}
if strings.HasPrefix(file, "[") {
continue
}
// Swap wha... | go | func (p *Profile) setMain() {
for i := 0; i < len(p.Mapping); i++ {
file := strings.TrimSpace(strings.Replace(p.Mapping[i].File, "(deleted)", "", -1))
if len(file) == 0 {
continue
}
if len(libRx.FindStringSubmatch(file)) > 0 {
continue
}
if strings.HasPrefix(file, "[") {
continue
}
// Swap wha... | [
"func",
"(",
"p",
"*",
"Profile",
")",
"setMain",
"(",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"p",
".",
"Mapping",
")",
";",
"i",
"++",
"{",
"file",
":=",
"strings",
".",
"TrimSpace",
"(",
"strings",
".",
"Replace",
"(",
... | // setMain scans Mapping entries and guesses which entry is main
// because legacy profiles don't obey the convention of putting main
// first. | [
"setMain",
"scans",
"Mapping",
"entries",
"and",
"guesses",
"which",
"entry",
"is",
"main",
"because",
"legacy",
"profiles",
"don",
"t",
"obey",
"the",
"convention",
"of",
"putting",
"main",
"first",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/profile/profile.go#L194-L212 |
123,519 | rakyll/gom | internal/profile/filter.go | matchesName | func (loc *Location) matchesName(re *regexp.Regexp) bool {
for _, ln := range loc.Line {
if fn := ln.Function; fn != nil {
if re.MatchString(fn.Name) {
return true
}
if re.MatchString(fn.Filename) {
return true
}
}
}
return false
} | go | func (loc *Location) matchesName(re *regexp.Regexp) bool {
for _, ln := range loc.Line {
if fn := ln.Function; fn != nil {
if re.MatchString(fn.Name) {
return true
}
if re.MatchString(fn.Filename) {
return true
}
}
}
return false
} | [
"func",
"(",
"loc",
"*",
"Location",
")",
"matchesName",
"(",
"re",
"*",
"regexp",
".",
"Regexp",
")",
"bool",
"{",
"for",
"_",
",",
"ln",
":=",
"range",
"loc",
".",
"Line",
"{",
"if",
"fn",
":=",
"ln",
".",
"Function",
";",
"fn",
"!=",
"nil",
... | // matchesName returns whether the function name or file in the
// location matches the regular expression. | [
"matchesName",
"returns",
"whether",
"the",
"function",
"name",
"or",
"file",
"in",
"the",
"location",
"matches",
"the",
"regular",
"expression",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/profile/filter.go#L60-L72 |
123,520 | rakyll/gom | internal/profile/filter.go | unmatchedLines | func (loc *Location) unmatchedLines(re *regexp.Regexp) []Line {
var lines []Line
for _, ln := range loc.Line {
if fn := ln.Function; fn != nil {
if re.MatchString(fn.Name) {
continue
}
if re.MatchString(fn.Filename) {
continue
}
}
lines = append(lines, ln)
}
return lines
} | go | func (loc *Location) unmatchedLines(re *regexp.Regexp) []Line {
var lines []Line
for _, ln := range loc.Line {
if fn := ln.Function; fn != nil {
if re.MatchString(fn.Name) {
continue
}
if re.MatchString(fn.Filename) {
continue
}
}
lines = append(lines, ln)
}
return lines
} | [
"func",
"(",
"loc",
"*",
"Location",
")",
"unmatchedLines",
"(",
"re",
"*",
"regexp",
".",
"Regexp",
")",
"[",
"]",
"Line",
"{",
"var",
"lines",
"[",
"]",
"Line",
"\n",
"for",
"_",
",",
"ln",
":=",
"range",
"loc",
".",
"Line",
"{",
"if",
"fn",
... | // unmatchedLines returns the lines in the location that do not match
// the regular expression. | [
"unmatchedLines",
"returns",
"the",
"lines",
"in",
"the",
"location",
"that",
"do",
"not",
"match",
"the",
"regular",
"expression",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/profile/filter.go#L76-L90 |
123,521 | rakyll/gom | internal/symbolizer/symbolizer.go | Symbolize | func Symbolize(mode string, prof *profile.Profile, obj plugin.ObjTool, ui plugin.UI) error {
force := false
// Disable some mechanisms based on mode string.
for _, o := range strings.Split(strings.ToLower(mode), ":") {
switch o {
case "force":
force = true
default:
}
}
if len(prof.Mapping) == 0 {
ret... | go | func Symbolize(mode string, prof *profile.Profile, obj plugin.ObjTool, ui plugin.UI) error {
force := false
// Disable some mechanisms based on mode string.
for _, o := range strings.Split(strings.ToLower(mode), ":") {
switch o {
case "force":
force = true
default:
}
}
if len(prof.Mapping) == 0 {
ret... | [
"func",
"Symbolize",
"(",
"mode",
"string",
",",
"prof",
"*",
"profile",
".",
"Profile",
",",
"obj",
"plugin",
".",
"ObjTool",
",",
"ui",
"plugin",
".",
"UI",
")",
"error",
"{",
"force",
":=",
"false",
"\n",
"// Disable some mechanisms based on mode string.",
... | // Symbolize adds symbol and line number information to all locations
// in a profile. mode enables some options to control
// symbolization. Currently only recognizes "force", which causes it
// to overwrite any existing data. | [
"Symbolize",
"adds",
"symbol",
"and",
"line",
"number",
"information",
"to",
"all",
"locations",
"in",
"a",
"profile",
".",
"mode",
"enables",
"some",
"options",
"to",
"control",
"symbolization",
".",
"Currently",
"only",
"recognizes",
"force",
"which",
"causes"... | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/symbolizer/symbolizer.go#L24-L94 |
123,522 | rakyll/gom | internal/report/source.go | printFunctionHeader | func printFunctionHeader(w io.Writer, name, path string, flatSum, cumSum int64, rpt *Report) {
fmt.Fprintf(w, `<h1>%s</h1>%s
<pre onClick="pprof_toggle_asm()">
Total: %10s %10s (flat, cum) %s
`,
template.HTMLEscapeString(name), template.HTMLEscapeString(path),
rpt.formatValue(flatSum), rpt.formatValue(cumSum),
... | go | func printFunctionHeader(w io.Writer, name, path string, flatSum, cumSum int64, rpt *Report) {
fmt.Fprintf(w, `<h1>%s</h1>%s
<pre onClick="pprof_toggle_asm()">
Total: %10s %10s (flat, cum) %s
`,
template.HTMLEscapeString(name), template.HTMLEscapeString(path),
rpt.formatValue(flatSum), rpt.formatValue(cumSum),
... | [
"func",
"printFunctionHeader",
"(",
"w",
"io",
".",
"Writer",
",",
"name",
",",
"path",
"string",
",",
"flatSum",
",",
"cumSum",
"int64",
",",
"rpt",
"*",
"Report",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"`<h1>%s</h1>%s\n<pre onClick=\"pprof_toggle_... | // printFunctionHeader prints a function header for a weblist report. | [
"printFunctionHeader",
"prints",
"a",
"function",
"header",
"for",
"a",
"weblist",
"report",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/report/source.go#L258-L266 |
123,523 | rakyll/gom | internal/report/source.go | getFunctionSource | func getFunctionSource(fun, file string, fns nodes, start, end int) (nodes, string, error) {
f, file, err := adjustSourcePath(file)
if err != nil {
return nil, file, err
}
lineNodes := make(map[int]nodes)
// Collect source coordinates from profile.
const margin = 5 // Lines before first/after last sample.
if... | go | func getFunctionSource(fun, file string, fns nodes, start, end int) (nodes, string, error) {
f, file, err := adjustSourcePath(file)
if err != nil {
return nil, file, err
}
lineNodes := make(map[int]nodes)
// Collect source coordinates from profile.
const margin = 5 // Lines before first/after last sample.
if... | [
"func",
"getFunctionSource",
"(",
"fun",
",",
"file",
"string",
",",
"fns",
"nodes",
",",
"start",
",",
"end",
"int",
")",
"(",
"nodes",
",",
"string",
",",
"error",
")",
"{",
"f",
",",
"file",
",",
"err",
":=",
"adjustSourcePath",
"(",
"file",
")",
... | // getFunctionSource collects the sources of a function from a source
// file and annotates it with the samples in fns. Returns the sources
// as nodes, using the info.name field to hold the source code. | [
"getFunctionSource",
"collects",
"the",
"sources",
"of",
"a",
"function",
"from",
"a",
"source",
"file",
"and",
"annotates",
"it",
"with",
"the",
"samples",
"in",
"fns",
".",
"Returns",
"the",
"sources",
"as",
"nodes",
"using",
"the",
"info",
".",
"name",
... | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/report/source.go#L317-L387 |
123,524 | rakyll/gom | internal/report/source.go | adjustSourcePath | func adjustSourcePath(path string) (*os.File, string, error) {
path = trimPath(path)
f, err := os.Open(path)
if err == nil {
return f, path, nil
}
if dir, wderr := os.Getwd(); wderr == nil {
for {
parent := filepath.Dir(dir)
if parent == dir {
break
}
if f, err := os.Open(filepath.Join(parent,... | go | func adjustSourcePath(path string) (*os.File, string, error) {
path = trimPath(path)
f, err := os.Open(path)
if err == nil {
return f, path, nil
}
if dir, wderr := os.Getwd(); wderr == nil {
for {
parent := filepath.Dir(dir)
if parent == dir {
break
}
if f, err := os.Open(filepath.Join(parent,... | [
"func",
"adjustSourcePath",
"(",
"path",
"string",
")",
"(",
"*",
"os",
".",
"File",
",",
"string",
",",
"error",
")",
"{",
"path",
"=",
"trimPath",
"(",
"path",
")",
"\n",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
... | // adjustSourcePath adjusts the pathe for a source file by trimmming
// known prefixes and searching for the file on all parents of the
// current working dir. | [
"adjustSourcePath",
"adjusts",
"the",
"pathe",
"for",
"a",
"source",
"file",
"by",
"trimmming",
"known",
"prefixes",
"and",
"searching",
"for",
"the",
"file",
"on",
"all",
"parents",
"of",
"the",
"current",
"working",
"dir",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/report/source.go#L414-L436 |
123,525 | rakyll/gom | internal/report/source.go | trimPath | func trimPath(path string) string {
basePaths := []string{
"/proc/self/cwd/./",
"/proc/self/cwd/",
}
sPath := filepath.ToSlash(path)
for _, base := range basePaths {
if strings.HasPrefix(sPath, base) {
return filepath.FromSlash(sPath[len(base):])
}
}
return path
} | go | func trimPath(path string) string {
basePaths := []string{
"/proc/self/cwd/./",
"/proc/self/cwd/",
}
sPath := filepath.ToSlash(path)
for _, base := range basePaths {
if strings.HasPrefix(sPath, base) {
return filepath.FromSlash(sPath[len(base):])
}
}
return path
} | [
"func",
"trimPath",
"(",
"path",
"string",
")",
"string",
"{",
"basePaths",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"}",
"\n\n",
"sPath",
":=",
"filepath",
".",
"ToSlash",
"(",
"path",
")",
"\n\n",
"for",
"_",
",",
"base",
... | // trimPath cleans up a path by removing prefixes that are commonly
// found on profiles. | [
"trimPath",
"cleans",
"up",
"a",
"path",
"by",
"removing",
"prefixes",
"that",
"are",
"commonly",
"found",
"on",
"profiles",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/report/source.go#L440-L454 |
123,526 | rakyll/gom | internal/profile/prune.go | Prune | func (p *Profile) Prune(dropRx, keepRx *regexp.Regexp) {
prune := make(map[uint64]bool)
pruneBeneath := make(map[uint64]bool)
for _, loc := range p.Location {
var i int
for i = len(loc.Line) - 1; i >= 0; i-- {
if fn := loc.Line[i].Function; fn != nil && fn.Name != "" {
funcName := fn.Name
// Account ... | go | func (p *Profile) Prune(dropRx, keepRx *regexp.Regexp) {
prune := make(map[uint64]bool)
pruneBeneath := make(map[uint64]bool)
for _, loc := range p.Location {
var i int
for i = len(loc.Line) - 1; i >= 0; i-- {
if fn := loc.Line[i].Function; fn != nil && fn.Name != "" {
funcName := fn.Name
// Account ... | [
"func",
"(",
"p",
"*",
"Profile",
")",
"Prune",
"(",
"dropRx",
",",
"keepRx",
"*",
"regexp",
".",
"Regexp",
")",
"{",
"prune",
":=",
"make",
"(",
"map",
"[",
"uint64",
"]",
"bool",
")",
"\n",
"pruneBeneath",
":=",
"make",
"(",
"map",
"[",
"uint64",... | // Prune removes all nodes beneath a node matching dropRx, and not
// matching keepRx. If the root node of a Sample matches, the sample
// will have an empty stack. | [
"Prune",
"removes",
"all",
"nodes",
"beneath",
"a",
"node",
"matching",
"dropRx",
"and",
"not",
"matching",
"keepRx",
".",
"If",
"the",
"root",
"node",
"of",
"a",
"Sample",
"matches",
"the",
"sample",
"will",
"have",
"an",
"empty",
"stack",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/profile/prune.go#L17-L77 |
123,527 | rakyll/gom | internal/driver/driver.go | adjustURL | func adjustURL(source string, sec int, ui plugin.UI) (adjusted, host string, duration time.Duration) {
// If there is a local file with this name, just use it.
if _, err := os.Stat(source); err == nil {
return source, "", 0
}
url, err := url.Parse(source)
// Automatically add http:// to URLs of the form hostna... | go | func adjustURL(source string, sec int, ui plugin.UI) (adjusted, host string, duration time.Duration) {
// If there is a local file with this name, just use it.
if _, err := os.Stat(source); err == nil {
return source, "", 0
}
url, err := url.Parse(source)
// Automatically add http:// to URLs of the form hostna... | [
"func",
"adjustURL",
"(",
"source",
"string",
",",
"sec",
"int",
",",
"ui",
"plugin",
".",
"UI",
")",
"(",
"adjusted",
",",
"host",
"string",
",",
"duration",
"time",
".",
"Duration",
")",
"{",
"// If there is a local file with this name, just use it.",
"if",
... | // adjustURL updates the profile source URL based on heuristics. It
// will append ?seconds=sec for CPU profiles if not already
// specified. Returns the hostname if the profile is remote. | [
"adjustURL",
"updates",
"the",
"profile",
"source",
"URL",
"based",
"on",
"heuristics",
".",
"It",
"will",
"append",
"?seconds",
"=",
"sec",
"for",
"CPU",
"profiles",
"if",
"not",
"already",
"specified",
".",
"Returns",
"the",
"hostname",
"if",
"the",
"profi... | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/driver/driver.go#L129-L181 |
123,528 | rakyll/gom | internal/driver/driver.go | preprocess | func preprocess(prof *profile.Profile, ui plugin.UI, f *flags) error {
if *f.flagFocus != "" || *f.flagIgnore != "" || *f.flagHide != "" {
focus, ignore, hide, err := compileFocusIgnore(*f.flagFocus, *f.flagIgnore, *f.flagHide)
if err != nil {
return err
}
fm, im, hm := prof.FilterSamplesByName(focus, ignor... | go | func preprocess(prof *profile.Profile, ui plugin.UI, f *flags) error {
if *f.flagFocus != "" || *f.flagIgnore != "" || *f.flagHide != "" {
focus, ignore, hide, err := compileFocusIgnore(*f.flagFocus, *f.flagIgnore, *f.flagHide)
if err != nil {
return err
}
fm, im, hm := prof.FilterSamplesByName(focus, ignor... | [
"func",
"preprocess",
"(",
"prof",
"*",
"profile",
".",
"Profile",
",",
"ui",
"plugin",
".",
"UI",
",",
"f",
"*",
"flags",
")",
"error",
"{",
"if",
"*",
"f",
".",
"flagFocus",
"!=",
"\"",
"\"",
"||",
"*",
"f",
".",
"flagIgnore",
"!=",
"\"",
"\"",... | // preprocess does filtering and aggregation of a profile based on the
// requested options. | [
"preprocess",
"does",
"filtering",
"and",
"aggregation",
"of",
"a",
"profile",
"based",
"on",
"the",
"requested",
"options",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/driver/driver.go#L194-L223 |
123,529 | rakyll/gom | internal/driver/driver.go | String | func (f *flags) String(p *profile.Profile) string {
var ret string
if ix := *f.flagSampleIndex; ix != -1 {
ret += fmt.Sprintf(" %-25s : %d (%s)\n", "sample_index", ix, p.SampleType[ix].Type)
}
if ix := *f.flagMean; ix {
ret += boolFlagString("mean")
}
if *f.flagDisplayUnit != "minimum" {
ret += stringFlag... | go | func (f *flags) String(p *profile.Profile) string {
var ret string
if ix := *f.flagSampleIndex; ix != -1 {
ret += fmt.Sprintf(" %-25s : %d (%s)\n", "sample_index", ix, p.SampleType[ix].Type)
}
if ix := *f.flagMean; ix {
ret += boolFlagString("mean")
}
if *f.flagDisplayUnit != "minimum" {
ret += stringFlag... | [
"func",
"(",
"f",
"*",
"flags",
")",
"String",
"(",
"p",
"*",
"profile",
".",
"Profile",
")",
"string",
"{",
"var",
"ret",
"string",
"\n\n",
"if",
"ix",
":=",
"*",
"f",
".",
"flagSampleIndex",
";",
"ix",
"!=",
"-",
"1",
"{",
"ret",
"+=",
"fmt",
... | // String provides a printable representation for the current set of flags. | [
"String",
"provides",
"a",
"printable",
"representation",
"for",
"the",
"current",
"set",
"of",
"flags",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/driver/driver.go#L494-L560 |
123,530 | rakyll/gom | internal/driver/driver.go | parseOptions | func parseOptions(f *flags) (o *report.Options, p commands.PostProcessor, err error) {
if *f.flagDivideBy == 0 {
return nil, nil, fmt.Errorf("zero divisor specified")
}
o = &report.Options{
CumSort: *f.flagCum,
CallTree: *f.flagCallTree,
PrintAddresses: *f.flagAddresses,
DropNegative: *f.f... | go | func parseOptions(f *flags) (o *report.Options, p commands.PostProcessor, err error) {
if *f.flagDivideBy == 0 {
return nil, nil, fmt.Errorf("zero divisor specified")
}
o = &report.Options{
CumSort: *f.flagCum,
CallTree: *f.flagCallTree,
PrintAddresses: *f.flagAddresses,
DropNegative: *f.f... | [
"func",
"parseOptions",
"(",
"f",
"*",
"flags",
")",
"(",
"o",
"*",
"report",
".",
"Options",
",",
"p",
"commands",
".",
"PostProcessor",
",",
"err",
"error",
")",
"{",
"if",
"*",
"f",
".",
"flagDivideBy",
"==",
"0",
"{",
"return",
"nil",
",",
"nil... | // parseOptions parses the options into report.Options
// Returns a function to postprocess the report after generation. | [
"parseOptions",
"parses",
"the",
"options",
"into",
"report",
".",
"Options",
"Returns",
"a",
"function",
"to",
"postprocess",
"the",
"report",
"after",
"generation",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/driver/driver.go#L924-L963 |
123,531 | rakyll/gom | internal/profile/legacy_profile.go | ParseTracebacks | func ParseTracebacks(b []byte) (*Profile, error) {
r := bytes.NewBuffer(b)
p := &Profile{
PeriodType: &ValueType{Type: "trace", Unit: "count"},
Period: 1,
SampleType: []*ValueType{
{Type: "trace", Unit: "count"},
},
}
var sources []string
var sloc []*Location
locs := make(map[uint64]*Location)
... | go | func ParseTracebacks(b []byte) (*Profile, error) {
r := bytes.NewBuffer(b)
p := &Profile{
PeriodType: &ValueType{Type: "trace", Unit: "count"},
Period: 1,
SampleType: []*ValueType{
{Type: "trace", Unit: "count"},
},
}
var sources []string
var sloc []*Location
locs := make(map[uint64]*Location)
... | [
"func",
"ParseTracebacks",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"*",
"Profile",
",",
"error",
")",
"{",
"r",
":=",
"bytes",
".",
"NewBuffer",
"(",
"b",
")",
"\n\n",
"p",
":=",
"&",
"Profile",
"{",
"PeriodType",
":",
"&",
"ValueType",
"{",
"Type",
... | // ParseTracebacks parses a set of tracebacks and returns a newly
// populated profile. It will accept any text file and generate a
// Profile out of it with any hex addresses it can identify, including
// a process map if it can recognize one. Each sample will include a
// tag "source" with the addresses recognized in... | [
"ParseTracebacks",
"parses",
"a",
"set",
"of",
"tracebacks",
"and",
"returns",
"a",
"newly",
"populated",
"profile",
".",
"It",
"will",
"accept",
"any",
"text",
"file",
"and",
"generate",
"a",
"Profile",
"out",
"of",
"it",
"with",
"any",
"hex",
"addresses",
... | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/profile/legacy_profile.go#L263-L328 |
123,532 | rakyll/gom | internal/profile/legacy_profile.go | extractHexAddresses | func extractHexAddresses(s string) ([]string, []uint64) {
hexStrings := hexNumberRE.FindAllString(s, -1)
var ids []uint64
for _, s := range hexStrings {
if id, err := strconv.ParseUint(s, 0, 64); err == nil {
ids = append(ids, id)
} else {
// Do not expect any parsing failures due to the regexp matching.
... | go | func extractHexAddresses(s string) ([]string, []uint64) {
hexStrings := hexNumberRE.FindAllString(s, -1)
var ids []uint64
for _, s := range hexStrings {
if id, err := strconv.ParseUint(s, 0, 64); err == nil {
ids = append(ids, id)
} else {
// Do not expect any parsing failures due to the regexp matching.
... | [
"func",
"extractHexAddresses",
"(",
"s",
"string",
")",
"(",
"[",
"]",
"string",
",",
"[",
"]",
"uint64",
")",
"{",
"hexStrings",
":=",
"hexNumberRE",
".",
"FindAllString",
"(",
"s",
",",
"-",
"1",
")",
"\n",
"var",
"ids",
"[",
"]",
"uint64",
"\n",
... | // extractHexAddresses extracts hex numbers from a string and returns
// them, together with their numeric value, in a slice. | [
"extractHexAddresses",
"extracts",
"hex",
"numbers",
"from",
"a",
"string",
"and",
"returns",
"them",
"together",
"with",
"their",
"numeric",
"value",
"in",
"a",
"slice",
"."
] | 183a9e70f4777aa03d377d21a0ed023a6afac141 | https://github.com/rakyll/gom/blob/183a9e70f4777aa03d377d21a0ed023a6afac141/internal/profile/legacy_profile.go#L644-L656 |
123,533 | rafaeljusto/redigomock | command.go | match | func match(commandName string, args []interface{}, cmd *Cmd) bool {
if commandName != cmd.Name || len(args) != len(cmd.Args) {
return false
}
for pos := range cmd.Args {
if implementsFuzzy(cmd.Args[pos]) {
if cmd.Args[pos].(FuzzyMatcher).Match(args[pos]) == false {
return false
}
} else if reflect.D... | go | func match(commandName string, args []interface{}, cmd *Cmd) bool {
if commandName != cmd.Name || len(args) != len(cmd.Args) {
return false
}
for pos := range cmd.Args {
if implementsFuzzy(cmd.Args[pos]) {
if cmd.Args[pos].(FuzzyMatcher).Match(args[pos]) == false {
return false
}
} else if reflect.D... | [
"func",
"match",
"(",
"commandName",
"string",
",",
"args",
"[",
"]",
"interface",
"{",
"}",
",",
"cmd",
"*",
"Cmd",
")",
"bool",
"{",
"if",
"commandName",
"!=",
"cmd",
".",
"Name",
"||",
"len",
"(",
"args",
")",
"!=",
"len",
"(",
"cmd",
".",
"Ar... | // match check if provided arguments can be matched with any registered
// commands | [
"match",
"check",
"if",
"provided",
"arguments",
"can",
"be",
"matched",
"with",
"any",
"registered",
"commands"
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/command.go#L54-L70 |
123,534 | rafaeljusto/redigomock | command.go | Expect | func (c *Cmd) Expect(response interface{}) *Cmd {
c.Responses = append(c.Responses, Response{response, nil})
return c
} | go | func (c *Cmd) Expect(response interface{}) *Cmd {
c.Responses = append(c.Responses, Response{response, nil})
return c
} | [
"func",
"(",
"c",
"*",
"Cmd",
")",
"Expect",
"(",
"response",
"interface",
"{",
"}",
")",
"*",
"Cmd",
"{",
"c",
".",
"Responses",
"=",
"append",
"(",
"c",
".",
"Responses",
",",
"Response",
"{",
"response",
",",
"nil",
"}",
")",
"\n",
"return",
"... | // Expect sets a response for this command. Every time a Do or Receive method
// is executed for a registered command this response or error will be
// returned. Expect call returns a pointer to Cmd struct, so you can chain
// Expect calls. Chained responses will be returned on subsequent calls
// matching this command... | [
"Expect",
"sets",
"a",
"response",
"for",
"this",
"command",
".",
"Every",
"time",
"a",
"Do",
"or",
"Receive",
"method",
"is",
"executed",
"for",
"a",
"registered",
"command",
"this",
"response",
"or",
"error",
"will",
"be",
"returned",
".",
"Expect",
"cal... | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/command.go#L77-L80 |
123,535 | rafaeljusto/redigomock | command.go | ExpectStringSlice | func (c *Cmd) ExpectStringSlice(resp ...string) *Cmd {
response := []interface{}{}
for _, r := range resp {
response = append(response, []byte(r))
}
c.Responses = append(c.Responses, Response{response, nil})
return c
} | go | func (c *Cmd) ExpectStringSlice(resp ...string) *Cmd {
response := []interface{}{}
for _, r := range resp {
response = append(response, []byte(r))
}
c.Responses = append(c.Responses, Response{response, nil})
return c
} | [
"func",
"(",
"c",
"*",
"Cmd",
")",
"ExpectStringSlice",
"(",
"resp",
"...",
"string",
")",
"*",
"Cmd",
"{",
"response",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"resp",
"{",
"response",
"=",
"app... | // ExpectStringSlice makes it easier to expect a slice of strings, plays nicely
// with redigo.Strings | [
"ExpectStringSlice",
"makes",
"it",
"easier",
"to",
"expect",
"a",
"slice",
"of",
"strings",
"plays",
"nicely",
"with",
"redigo",
".",
"Strings"
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/command.go#L114-L121 |
123,536 | rafaeljusto/redigomock | command.go | hash | func (c Cmd) hash() cmdHash {
output := c.Name
for _, arg := range c.Args {
output += fmt.Sprintf("%v", arg)
}
return cmdHash(output)
} | go | func (c Cmd) hash() cmdHash {
output := c.Name
for _, arg := range c.Args {
output += fmt.Sprintf("%v", arg)
}
return cmdHash(output)
} | [
"func",
"(",
"c",
"Cmd",
")",
"hash",
"(",
")",
"cmdHash",
"{",
"output",
":=",
"c",
".",
"Name",
"\n",
"for",
"_",
",",
"arg",
":=",
"range",
"c",
".",
"Args",
"{",
"output",
"+=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"arg",
")",
"\n... | // hash generates a unique identifier for the command | [
"hash",
"generates",
"a",
"unique",
"identifier",
"for",
"the",
"command"
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/command.go#L124-L130 |
123,537 | rafaeljusto/redigomock | redigomock.go | NewConn | func NewConn() *Conn {
return &Conn{
ReceiveNow: make(chan bool),
stats: make(map[cmdHash]int),
}
} | go | func NewConn() *Conn {
return &Conn{
ReceiveNow: make(chan bool),
stats: make(map[cmdHash]int),
}
} | [
"func",
"NewConn",
"(",
")",
"*",
"Conn",
"{",
"return",
"&",
"Conn",
"{",
"ReceiveNow",
":",
"make",
"(",
"chan",
"bool",
")",
",",
"stats",
":",
"make",
"(",
"map",
"[",
"cmdHash",
"]",
"int",
")",
",",
"}",
"\n",
"}"
] | // NewConn returns a new mocked connection. Obviously as we are mocking we
// don't need any Redis connection parameter | [
"NewConn",
"returns",
"a",
"new",
"mocked",
"connection",
".",
"Obviously",
"as",
"we",
"are",
"mocking",
"we",
"don",
"t",
"need",
"any",
"Redis",
"connection",
"parameter"
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/redigomock.go#L44-L49 |
123,538 | rafaeljusto/redigomock | redigomock.go | Close | func (c *Conn) Close() error {
if c.CloseMock == nil {
return nil
}
return c.CloseMock()
} | go | func (c *Conn) Close() error {
if c.CloseMock == nil {
return nil
}
return c.CloseMock()
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"c",
".",
"CloseMock",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"c",
".",
"CloseMock",
"(",
")",
"\n",
"}"
] | // Close can be mocked using the Conn struct attributes | [
"Close",
"can",
"be",
"mocked",
"using",
"the",
"Conn",
"struct",
"attributes"
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/redigomock.go#L52-L58 |
123,539 | rafaeljusto/redigomock | redigomock.go | Err | func (c *Conn) Err() error {
if c.ErrMock == nil {
return nil
}
return c.ErrMock()
} | go | func (c *Conn) Err() error {
if c.ErrMock == nil {
return nil
}
return c.ErrMock()
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Err",
"(",
")",
"error",
"{",
"if",
"c",
".",
"ErrMock",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"c",
".",
"ErrMock",
"(",
")",
"\n",
"}"
] | // Err can be mocked using the Conn struct attributes | [
"Err",
"can",
"be",
"mocked",
"using",
"the",
"Conn",
"struct",
"attributes"
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/redigomock.go#L61-L67 |
123,540 | rafaeljusto/redigomock | redigomock.go | Command | func (c *Conn) Command(commandName string, args ...interface{}) *Cmd {
cmd := &Cmd{
Name: commandName,
Args: args,
}
c.removeRelatedCommands(commandName, args)
c.commands = append(c.commands, cmd)
return cmd
} | go | func (c *Conn) Command(commandName string, args ...interface{}) *Cmd {
cmd := &Cmd{
Name: commandName,
Args: args,
}
c.removeRelatedCommands(commandName, args)
c.commands = append(c.commands, cmd)
return cmd
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Command",
"(",
"commandName",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"*",
"Cmd",
"{",
"cmd",
":=",
"&",
"Cmd",
"{",
"Name",
":",
"commandName",
",",
"Args",
":",
"args",
",",
"}",
"\n",
"c",... | // Command register a command in the mock system using the same arguments of
// a Do or Send commands. It will return a registered command object where
// you can set the response or error | [
"Command",
"register",
"a",
"command",
"in",
"the",
"mock",
"system",
"using",
"the",
"same",
"arguments",
"of",
"a",
"Do",
"or",
"Send",
"commands",
".",
"It",
"will",
"return",
"a",
"registered",
"command",
"object",
"where",
"you",
"can",
"set",
"the",
... | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/redigomock.go#L72-L80 |
123,541 | rafaeljusto/redigomock | redigomock.go | GenericCommand | func (c *Conn) GenericCommand(commandName string) *Cmd {
cmd := &Cmd{
Name: commandName,
}
c.removeRelatedCommands(commandName, nil)
c.commands = append(c.commands, cmd)
return cmd
} | go | func (c *Conn) GenericCommand(commandName string) *Cmd {
cmd := &Cmd{
Name: commandName,
}
c.removeRelatedCommands(commandName, nil)
c.commands = append(c.commands, cmd)
return cmd
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"GenericCommand",
"(",
"commandName",
"string",
")",
"*",
"Cmd",
"{",
"cmd",
":=",
"&",
"Cmd",
"{",
"Name",
":",
"commandName",
",",
"}",
"\n\n",
"c",
".",
"removeRelatedCommands",
"(",
"commandName",
",",
"nil",
")"... | // GenericCommand register a command without arguments. If a command with
// arguments doesn't match with any registered command, it will look for
// generic commands before throwing an error | [
"GenericCommand",
"register",
"a",
"command",
"without",
"arguments",
".",
"If",
"a",
"command",
"with",
"arguments",
"doesn",
"t",
"match",
"with",
"any",
"registered",
"command",
"it",
"will",
"look",
"for",
"generic",
"commands",
"before",
"throwing",
"an",
... | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/redigomock.go#L101-L109 |
123,542 | rafaeljusto/redigomock | redigomock.go | find | func (c *Conn) find(commandName string, args []interface{}) *Cmd {
for _, cmd := range c.commands {
if match(commandName, args, cmd) {
return cmd
}
}
return nil
} | go | func (c *Conn) find(commandName string, args []interface{}) *Cmd {
for _, cmd := range c.commands {
if match(commandName, args, cmd) {
return cmd
}
}
return nil
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"find",
"(",
"commandName",
"string",
",",
"args",
"[",
"]",
"interface",
"{",
"}",
")",
"*",
"Cmd",
"{",
"for",
"_",
",",
"cmd",
":=",
"range",
"c",
".",
"commands",
"{",
"if",
"match",
"(",
"commandName",
","... | // find will scan the registered commands, looking for the first command with
// the same name and arguments. If the command is not found nil is returned | [
"find",
"will",
"scan",
"the",
"registered",
"commands",
"looking",
"for",
"the",
"first",
"command",
"with",
"the",
"same",
"name",
"and",
"arguments",
".",
"If",
"the",
"command",
"is",
"not",
"found",
"nil",
"is",
"returned"
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/redigomock.go#L113-L120 |
123,543 | rafaeljusto/redigomock | redigomock.go | removeRelatedCommands | func (c *Conn) removeRelatedCommands(commandName string, args []interface{}) {
var unique []*Cmd
for _, cmd := range c.commands {
// new array will contain only commands that are not related to the given
// one
if !equal(commandName, args, cmd) {
unique = append(unique, cmd)
}
}
c.commands = unique
} | go | func (c *Conn) removeRelatedCommands(commandName string, args []interface{}) {
var unique []*Cmd
for _, cmd := range c.commands {
// new array will contain only commands that are not related to the given
// one
if !equal(commandName, args, cmd) {
unique = append(unique, cmd)
}
}
c.commands = unique
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"removeRelatedCommands",
"(",
"commandName",
"string",
",",
"args",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"var",
"unique",
"[",
"]",
"*",
"Cmd",
"\n\n",
"for",
"_",
",",
"cmd",
":=",
"range",
"c",
".",
"comm... | // removeRelatedCommands verify if a command is already registered, removing
// any command already registered with the same name and arguments. This
// should avoid duplicated mocked commands | [
"removeRelatedCommands",
"verify",
"if",
"a",
"command",
"is",
"already",
"registered",
"removing",
"any",
"command",
"already",
"registered",
"with",
"the",
"same",
"name",
"and",
"arguments",
".",
"This",
"should",
"avoid",
"duplicated",
"mocked",
"commands"
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/redigomock.go#L125-L136 |
123,544 | rafaeljusto/redigomock | redigomock.go | Clear | func (c *Conn) Clear() {
c.statsMut.Lock()
defer c.statsMut.Unlock()
c.commands = []*Cmd{}
c.queue = []queueElement{}
c.replies = []replyElement{}
c.stats = make(map[cmdHash]int)
} | go | func (c *Conn) Clear() {
c.statsMut.Lock()
defer c.statsMut.Unlock()
c.commands = []*Cmd{}
c.queue = []queueElement{}
c.replies = []replyElement{}
c.stats = make(map[cmdHash]int)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Clear",
"(",
")",
"{",
"c",
".",
"statsMut",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"statsMut",
".",
"Unlock",
"(",
")",
"\n\n",
"c",
".",
"commands",
"=",
"[",
"]",
"*",
"Cmd",
"{",
"}",
"\n",
... | // Clear removes all registered commands. Useful for connection reuse in test
// scenarios | [
"Clear",
"removes",
"all",
"registered",
"commands",
".",
"Useful",
"for",
"connection",
"reuse",
"in",
"test",
"scenarios"
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/redigomock.go#L140-L148 |
123,545 | rafaeljusto/redigomock | redigomock.go | DoWithTimeout | func (c *Conn) DoWithTimeout(readTimeout time.Duration, cmd string, args ...interface{}) (interface{}, error) {
return c.Do(cmd, args...)
} | go | func (c *Conn) DoWithTimeout(readTimeout time.Duration, cmd string, args ...interface{}) (interface{}, error) {
return c.Do(cmd, args...)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"DoWithTimeout",
"(",
"readTimeout",
"time",
".",
"Duration",
",",
"cmd",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"return",
"c",
".",
"Do",
"(... | // DoWithTimeout is a helper function for Do call to satisfy the ConnWithTimeout
// interface. | [
"DoWithTimeout",
"is",
"a",
"helper",
"function",
"for",
"Do",
"call",
"to",
"satisfy",
"the",
"ConnWithTimeout",
"interface",
"."
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/redigomock.go#L230-L232 |
123,546 | rafaeljusto/redigomock | redigomock.go | Flush | func (c *Conn) Flush() error {
if c.FlushMock != nil {
return c.FlushMock()
}
if len(c.queue) > 0 {
for _, cmd := range c.queue {
reply, err := c.do(cmd.commandName, cmd.args...)
c.replies = append(c.replies, replyElement{reply: reply, err: err})
}
c.queue = []queueElement{}
}
return nil
} | go | func (c *Conn) Flush() error {
if c.FlushMock != nil {
return c.FlushMock()
}
if len(c.queue) > 0 {
for _, cmd := range c.queue {
reply, err := c.do(cmd.commandName, cmd.args...)
c.replies = append(c.replies, replyElement{reply: reply, err: err})
}
c.queue = []queueElement{}
}
return nil
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Flush",
"(",
")",
"error",
"{",
"if",
"c",
".",
"FlushMock",
"!=",
"nil",
"{",
"return",
"c",
".",
"FlushMock",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"c",
".",
"queue",
")",
">",
"0",
"{",
"for",
... | // Flush can be mocked using the Conn struct attributes | [
"Flush",
"can",
"be",
"mocked",
"using",
"the",
"Conn",
"struct",
"attributes"
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/redigomock.go#L245-L259 |
123,547 | rafaeljusto/redigomock | redigomock.go | AddSubscriptionMessage | func (c *Conn) AddSubscriptionMessage(msg interface{}) {
resp := Response{}
resp.Response = msg
c.SubResponses = append(c.SubResponses, resp)
} | go | func (c *Conn) AddSubscriptionMessage(msg interface{}) {
resp := Response{}
resp.Response = msg
c.SubResponses = append(c.SubResponses, resp)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"AddSubscriptionMessage",
"(",
"msg",
"interface",
"{",
"}",
")",
"{",
"resp",
":=",
"Response",
"{",
"}",
"\n",
"resp",
".",
"Response",
"=",
"msg",
"\n",
"c",
".",
"SubResponses",
"=",
"append",
"(",
"c",
".",
... | // AddSubscriptionMessage register a response to be returned by the receive
// call. | [
"AddSubscriptionMessage",
"register",
"a",
"response",
"to",
"be",
"returned",
"by",
"the",
"receive",
"call",
"."
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/redigomock.go#L263-L267 |
123,548 | rafaeljusto/redigomock | redigomock.go | Receive | func (c *Conn) Receive() (reply interface{}, err error) {
if c.ReceiveWait {
<-c.ReceiveNow
}
if len(c.queue) == 0 && len(c.replies) == 0 {
if len(c.SubResponses) > 0 {
reply, err = c.SubResponses[0].Response, c.SubResponses[0].Error
c.SubResponses = c.SubResponses[1:]
return
}
return nil, fmt.Erro... | go | func (c *Conn) Receive() (reply interface{}, err error) {
if c.ReceiveWait {
<-c.ReceiveNow
}
if len(c.queue) == 0 && len(c.replies) == 0 {
if len(c.SubResponses) > 0 {
reply, err = c.SubResponses[0].Response, c.SubResponses[0].Error
c.SubResponses = c.SubResponses[1:]
return
}
return nil, fmt.Erro... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Receive",
"(",
")",
"(",
"reply",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"if",
"c",
".",
"ReceiveWait",
"{",
"<-",
"c",
".",
"ReceiveNow",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"c",
".",
"queue... | // Receive will process the queue created by the Send method, only one item
// of the queue is processed by Receive call. It will work as the Do method | [
"Receive",
"will",
"process",
"the",
"queue",
"created",
"by",
"the",
"Send",
"method",
"only",
"one",
"item",
"of",
"the",
"queue",
"is",
"processed",
"by",
"Receive",
"call",
".",
"It",
"will",
"work",
"as",
"the",
"Do",
"method"
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/redigomock.go#L271-L292 |
123,549 | rafaeljusto/redigomock | redigomock.go | Stats | func (c *Conn) Stats(cmd *Cmd) int {
c.statsMut.RLock()
defer c.statsMut.RUnlock()
return c.stats[cmd.hash()]
} | go | func (c *Conn) Stats(cmd *Cmd) int {
c.statsMut.RLock()
defer c.statsMut.RUnlock()
return c.stats[cmd.hash()]
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Stats",
"(",
"cmd",
"*",
"Cmd",
")",
"int",
"{",
"c",
".",
"statsMut",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"statsMut",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"c",
".",
"stats",
"[",
"cmd",
... | // Stats returns the number of times that a command was called in the current
// connection | [
"Stats",
"returns",
"the",
"number",
"of",
"times",
"that",
"a",
"command",
"was",
"called",
"in",
"the",
"current",
"connection"
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/redigomock.go#L302-L307 |
123,550 | rafaeljusto/redigomock | redigomock.go | ExpectationsWereMet | func (c *Conn) ExpectationsWereMet() error {
errMsg := ""
for _, err := range c.Errors {
errMsg = fmt.Sprintf("%s%s\n", errMsg, err.Error())
}
for _, cmd := range c.commands {
if !cmd.Called {
errMsg = fmt.Sprintf("%sCommand %s with arguments %#v expected but never called.\n", errMsg, cmd.Name, cmd.Args)
... | go | func (c *Conn) ExpectationsWereMet() error {
errMsg := ""
for _, err := range c.Errors {
errMsg = fmt.Sprintf("%s%s\n", errMsg, err.Error())
}
for _, cmd := range c.commands {
if !cmd.Called {
errMsg = fmt.Sprintf("%sCommand %s with arguments %#v expected but never called.\n", errMsg, cmd.Name, cmd.Args)
... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"ExpectationsWereMet",
"(",
")",
"error",
"{",
"errMsg",
":=",
"\"",
"\"",
"\n",
"for",
"_",
",",
"err",
":=",
"range",
"c",
".",
"Errors",
"{",
"errMsg",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
","... | // ExpectationsWereMet can guarantee that all commands that was set on unit tests
// called or call of unregistered command can be caught here too | [
"ExpectationsWereMet",
"can",
"guarantee",
"that",
"all",
"commands",
"that",
"was",
"set",
"on",
"unit",
"tests",
"called",
"or",
"call",
"of",
"unregistered",
"command",
"can",
"be",
"caught",
"here",
"too"
] | 257e089e14a15ee7bf9e8e845fd1229b6bf80048 | https://github.com/rafaeljusto/redigomock/blob/257e089e14a15ee7bf9e8e845fd1229b6bf80048/redigomock.go#L311-L328 |
123,551 | oxtoacart/bpool | sizedbufferpool.go | Get | func (bp *SizedBufferPool) Get() (b *bytes.Buffer) {
select {
case b = <-bp.c:
// reuse existing buffer
default:
// create new buffer
b = bytes.NewBuffer(make([]byte, 0, bp.a))
}
return
} | go | func (bp *SizedBufferPool) Get() (b *bytes.Buffer) {
select {
case b = <-bp.c:
// reuse existing buffer
default:
// create new buffer
b = bytes.NewBuffer(make([]byte, 0, bp.a))
}
return
} | [
"func",
"(",
"bp",
"*",
"SizedBufferPool",
")",
"Get",
"(",
")",
"(",
"b",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"select",
"{",
"case",
"b",
"=",
"<-",
"bp",
".",
"c",
":",
"// reuse existing buffer",
"default",
":",
"// create new buffer",
"b",
"=",
... | // Get gets a Buffer from the SizedBufferPool, or creates a new one if none are
// available in the pool. Buffers have a pre-allocated capacity. | [
"Get",
"gets",
"a",
"Buffer",
"from",
"the",
"SizedBufferPool",
"or",
"creates",
"a",
"new",
"one",
"if",
"none",
"are",
"available",
"in",
"the",
"pool",
".",
"Buffers",
"have",
"a",
"pre",
"-",
"allocated",
"capacity",
"."
] | 8c4636f812cc8920c26e2002b988c878b1fd6f5e | https://github.com/oxtoacart/bpool/blob/8c4636f812cc8920c26e2002b988c878b1fd6f5e/sizedbufferpool.go#L32-L41 |
123,552 | oxtoacart/bpool | sizedbufferpool.go | Put | func (bp *SizedBufferPool) Put(b *bytes.Buffer) {
b.Reset()
// Release buffers over our maximum capacity and re-create a pre-sized
// buffer to replace it.
// Note that the cap(b.Bytes()) provides the capacity from the read off-set
// only, but as we've called b.Reset() the full capacity of the underlying
// byt... | go | func (bp *SizedBufferPool) Put(b *bytes.Buffer) {
b.Reset()
// Release buffers over our maximum capacity and re-create a pre-sized
// buffer to replace it.
// Note that the cap(b.Bytes()) provides the capacity from the read off-set
// only, but as we've called b.Reset() the full capacity of the underlying
// byt... | [
"func",
"(",
"bp",
"*",
"SizedBufferPool",
")",
"Put",
"(",
"b",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"b",
".",
"Reset",
"(",
")",
"\n\n",
"// Release buffers over our maximum capacity and re-create a pre-sized",
"// buffer to replace it.",
"// Note that the cap(b.Byt... | // Put returns the given Buffer to the SizedBufferPool. | [
"Put",
"returns",
"the",
"given",
"Buffer",
"to",
"the",
"SizedBufferPool",
"."
] | 8c4636f812cc8920c26e2002b988c878b1fd6f5e | https://github.com/oxtoacart/bpool/blob/8c4636f812cc8920c26e2002b988c878b1fd6f5e/sizedbufferpool.go#L44-L60 |
123,553 | oxtoacart/bpool | bytepool.go | NewBytePool | func NewBytePool(maxSize int, width int) (bp *BytePool) {
return &BytePool{
c: make(chan []byte, maxSize),
w: width,
}
} | go | func NewBytePool(maxSize int, width int) (bp *BytePool) {
return &BytePool{
c: make(chan []byte, maxSize),
w: width,
}
} | [
"func",
"NewBytePool",
"(",
"maxSize",
"int",
",",
"width",
"int",
")",
"(",
"bp",
"*",
"BytePool",
")",
"{",
"return",
"&",
"BytePool",
"{",
"c",
":",
"make",
"(",
"chan",
"[",
"]",
"byte",
",",
"maxSize",
")",
",",
"w",
":",
"width",
",",
"}",
... | // NewBytePool creates a new BytePool bounded to the given maxSize, with new
// byte arrays sized based on width. | [
"NewBytePool",
"creates",
"a",
"new",
"BytePool",
"bounded",
"to",
"the",
"given",
"maxSize",
"with",
"new",
"byte",
"arrays",
"sized",
"based",
"on",
"width",
"."
] | 8c4636f812cc8920c26e2002b988c878b1fd6f5e | https://github.com/oxtoacart/bpool/blob/8c4636f812cc8920c26e2002b988c878b1fd6f5e/bytepool.go#L12-L17 |
123,554 | oxtoacart/bpool | bytepool.go | Put | func (bp *BytePool) Put(b []byte) {
if cap(b) < bp.w {
// someone tried to put back a too small buffer, discard it
return
}
select {
case bp.c <- b[:bp.w]:
// buffer went back into pool
default:
// buffer didn't go back into pool, just discard
}
} | go | func (bp *BytePool) Put(b []byte) {
if cap(b) < bp.w {
// someone tried to put back a too small buffer, discard it
return
}
select {
case bp.c <- b[:bp.w]:
// buffer went back into pool
default:
// buffer didn't go back into pool, just discard
}
} | [
"func",
"(",
"bp",
"*",
"BytePool",
")",
"Put",
"(",
"b",
"[",
"]",
"byte",
")",
"{",
"if",
"cap",
"(",
"b",
")",
"<",
"bp",
".",
"w",
"{",
"// someone tried to put back a too small buffer, discard it",
"return",
"\n",
"}",
"\n\n",
"select",
"{",
"case",... | // Put returns the given Buffer to the BytePool. | [
"Put",
"returns",
"the",
"given",
"Buffer",
"to",
"the",
"BytePool",
"."
] | 8c4636f812cc8920c26e2002b988c878b1fd6f5e | https://github.com/oxtoacart/bpool/blob/8c4636f812cc8920c26e2002b988c878b1fd6f5e/bytepool.go#L33-L45 |
123,555 | yvasiyarov/swagger | markup/markup_asciidoc.go | tableHeader | func (this *MarkupAsciiDoc) tableHeader(tableTitle string) string {
retval := "\n"
if tableTitle != "" {
retval += fmt.Sprintf(".%s\n", tableTitle)
}
return retval + "[width=\"60%\",options=\"header\"]\n|==========\n"
} | go | func (this *MarkupAsciiDoc) tableHeader(tableTitle string) string {
retval := "\n"
if tableTitle != "" {
retval += fmt.Sprintf(".%s\n", tableTitle)
}
return retval + "[width=\"60%\",options=\"header\"]\n|==========\n"
} | [
"func",
"(",
"this",
"*",
"MarkupAsciiDoc",
")",
"tableHeader",
"(",
"tableTitle",
"string",
")",
"string",
"{",
"retval",
":=",
"\"",
"\\n",
"\"",
"\n",
"if",
"tableTitle",
"!=",
"\"",
"\"",
"{",
"retval",
"+=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n"... | // tableHeader starts a table | [
"tableHeader",
"starts",
"a",
"table"
] | 39eb437316e9318213bb9daf3fdc7f7bc5acde38 | https://github.com/yvasiyarov/swagger/blob/39eb437316e9318213bb9daf3fdc7f7bc5acde38/markup/markup_asciidoc.go#L40-L46 |
123,556 | yvasiyarov/swagger | markup/markup_asciidoc.go | tableHeaderRow | func (this *MarkupAsciiDoc) tableHeaderRow(args ...string) string {
var retval string
for _, arg := range args {
retval += fmt.Sprintf("|%s ", arg)
}
return retval + "\n"
} | go | func (this *MarkupAsciiDoc) tableHeaderRow(args ...string) string {
var retval string
for _, arg := range args {
retval += fmt.Sprintf("|%s ", arg)
}
return retval + "\n"
} | [
"func",
"(",
"this",
"*",
"MarkupAsciiDoc",
")",
"tableHeaderRow",
"(",
"args",
"...",
"string",
")",
"string",
"{",
"var",
"retval",
"string",
"\n",
"for",
"_",
",",
"arg",
":=",
"range",
"args",
"{",
"retval",
"+=",
"fmt",
".",
"Sprintf",
"(",
"\"",
... | // tableRow issues a table header row | [
"tableRow",
"issues",
"a",
"table",
"header",
"row"
] | 39eb437316e9318213bb9daf3fdc7f7bc5acde38 | https://github.com/yvasiyarov/swagger/blob/39eb437316e9318213bb9daf3fdc7f7bc5acde38/markup/markup_asciidoc.go#L54-L60 |
123,557 | yvasiyarov/swagger | parser/parser.go | isController | func isController(funcDeclaration *ast.FuncDecl, controllerClass string) bool {
if len(controllerClass) == 0 {
// Search every method
return true
}
if funcDeclaration.Recv != nil && len(funcDeclaration.Recv.List) > 0 {
if starExpression, ok := funcDeclaration.Recv.List[0].Type.(*ast.StarExpr); ok {
receiver... | go | func isController(funcDeclaration *ast.FuncDecl, controllerClass string) bool {
if len(controllerClass) == 0 {
// Search every method
return true
}
if funcDeclaration.Recv != nil && len(funcDeclaration.Recv.List) > 0 {
if starExpression, ok := funcDeclaration.Recv.List[0].Type.(*ast.StarExpr); ok {
receiver... | [
"func",
"isController",
"(",
"funcDeclaration",
"*",
"ast",
".",
"FuncDecl",
",",
"controllerClass",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"controllerClass",
")",
"==",
"0",
"{",
"// Search every method",
"return",
"true",
"\n",
"}",
"\n",
"if",
"fun... | // It must return true if funcDeclaration is controller. We will try to parse only comments before controllers | [
"It",
"must",
"return",
"true",
"if",
"funcDeclaration",
"is",
"controller",
".",
"We",
"will",
"try",
"to",
"parse",
"only",
"comments",
"before",
"controllers"
] | 39eb437316e9318213bb9daf3fdc7f7bc5acde38 | https://github.com/yvasiyarov/swagger/blob/39eb437316e9318213bb9daf3fdc7f7bc5acde38/parser/parser.go#L43-L59 |
123,558 | yvasiyarov/swagger | parser/parser.go | ParseSubApiDescription | func (parser *Parser) ParseSubApiDescription(commentLine string) {
if !strings.HasPrefix(commentLine, "@SubApi") {
return
} else {
commentLine = strings.TrimSpace(commentLine[len("@SubApi"):])
}
re := regexp.MustCompile(`([^\[]+)\[{1}([\w\_\-/]+)`)
if matches := re.FindStringSubmatch(commentLine); len(matches... | go | func (parser *Parser) ParseSubApiDescription(commentLine string) {
if !strings.HasPrefix(commentLine, "@SubApi") {
return
} else {
commentLine = strings.TrimSpace(commentLine[len("@SubApi"):])
}
re := regexp.MustCompile(`([^\[]+)\[{1}([\w\_\-/]+)`)
if matches := re.FindStringSubmatch(commentLine); len(matches... | [
"func",
"(",
"parser",
"*",
"Parser",
")",
"ParseSubApiDescription",
"(",
"commentLine",
"string",
")",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"commentLine",
",",
"\"",
"\"",
")",
"{",
"return",
"\n",
"}",
"else",
"{",
"commentLine",
"=",
"str... | // Parse sub api declaration
// @SubApi Very fancy API [/fancy-api] | [
"Parse",
"sub",
"api",
"declaration"
] | 39eb437316e9318213bb9daf3fdc7f7bc5acde38 | https://github.com/yvasiyarov/swagger/blob/39eb437316e9318213bb9daf3fdc7f7bc5acde38/parser/parser.go#L543-L568 |
123,559 | yvasiyarov/swagger | markup/markup_markdown.go | tableHeaderRow | func (this *MarkupMarkDown) tableHeaderRow(args ...string) string {
var retval string = ""
var separator string = ""
for _, arg := range args {
retval += fmt.Sprintf("| %s ", arg)
separator += "|-----"
}
return retval + "|\n" + separator + "|\n"
} | go | func (this *MarkupMarkDown) tableHeaderRow(args ...string) string {
var retval string = ""
var separator string = ""
for _, arg := range args {
retval += fmt.Sprintf("| %s ", arg)
separator += "|-----"
}
return retval + "|\n" + separator + "|\n"
} | [
"func",
"(",
"this",
"*",
"MarkupMarkDown",
")",
"tableHeaderRow",
"(",
"args",
"...",
"string",
")",
"string",
"{",
"var",
"retval",
"string",
"=",
"\"",
"\"",
"\n",
"var",
"separator",
"string",
"=",
"\"",
"\"",
"\n",
"for",
"_",
",",
"arg",
":=",
... | // tableHeaderRow issues a table header row | [
"tableHeaderRow",
"issues",
"a",
"table",
"header",
"row"
] | 39eb437316e9318213bb9daf3fdc7f7bc5acde38 | https://github.com/yvasiyarov/swagger/blob/39eb437316e9318213bb9daf3fdc7f7bc5acde38/markup/markup_markdown.go#L45-L53 |
123,560 | yvasiyarov/swagger | parser/model.go | ParseModel | func (m *Model) ParseModel(modelName string, currentPackage string, knownModelNames map[string]bool) (error, []*Model) {
knownModelNames[modelName] = true
//log.Printf("Before parse model |%s|, package: |%s|\n", modelName, currentPackage)
astTypeSpec, modelPackage := m.parser.FindModelDefinition(modelName, currentP... | go | func (m *Model) ParseModel(modelName string, currentPackage string, knownModelNames map[string]bool) (error, []*Model) {
knownModelNames[modelName] = true
//log.Printf("Before parse model |%s|, package: |%s|\n", modelName, currentPackage)
astTypeSpec, modelPackage := m.parser.FindModelDefinition(modelName, currentP... | [
"func",
"(",
"m",
"*",
"Model",
")",
"ParseModel",
"(",
"modelName",
"string",
",",
"currentPackage",
"string",
",",
"knownModelNames",
"map",
"[",
"string",
"]",
"bool",
")",
"(",
"error",
",",
"[",
"]",
"*",
"Model",
")",
"{",
"knownModelNames",
"[",
... | // modelName is something like package.subpackage.SomeModel or just "subpackage.SomeModel" | [
"modelName",
"is",
"something",
"like",
"package",
".",
"subpackage",
".",
"SomeModel",
"or",
"just",
"subpackage",
".",
"SomeModel"
] | 39eb437316e9318213bb9daf3fdc7f7bc5acde38 | https://github.com/yvasiyarov/swagger/blob/39eb437316e9318213bb9daf3fdc7f7bc5acde38/parser/model.go#L25-L100 |
123,561 | yvasiyarov/swagger | utils/utils.go | GetGoVars | func GetGoVars() (string, string, error) {
gopath := os.Getenv("GOPATH")
if gopath == "" {
return "", "", errors.New("Please set the $GOPATH environment variable")
}
goroot := filepath.Clean(runtime.GOROOT())
if goroot == "" {
return "", "", errors.New("Please set $GOROOT environment variable")
}
return go... | go | func GetGoVars() (string, string, error) {
gopath := os.Getenv("GOPATH")
if gopath == "" {
return "", "", errors.New("Please set the $GOPATH environment variable")
}
goroot := filepath.Clean(runtime.GOROOT())
if goroot == "" {
return "", "", errors.New("Please set $GOROOT environment variable")
}
return go... | [
"func",
"GetGoVars",
"(",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"gopath",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"gopath",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"errors",
"... | // return gopath, goroot, err | [
"return",
"gopath",
"goroot",
"err"
] | 39eb437316e9318213bb9daf3fdc7f7bc5acde38 | https://github.com/yvasiyarov/swagger/blob/39eb437316e9318213bb9daf3fdc7f7bc5acde38/utils/utils.go#L21-L33 |
123,562 | hashicorp/consul-migrate | main.go | handleProgress | func handleProgress(ch <-chan *migrator.ProgressUpdate, doneCh <-chan struct{}) {
var lastOp string
var lastProgress float64
lastFlush := time.Now()
for {
select {
case update := <-ch:
switch {
case lastOp != update.Op:
lastProgress = update.Progress
lastOp = update.Op
fmt.Println(update.Op)
... | go | func handleProgress(ch <-chan *migrator.ProgressUpdate, doneCh <-chan struct{}) {
var lastOp string
var lastProgress float64
lastFlush := time.Now()
for {
select {
case update := <-ch:
switch {
case lastOp != update.Op:
lastProgress = update.Progress
lastOp = update.Op
fmt.Println(update.Op)
... | [
"func",
"handleProgress",
"(",
"ch",
"<-",
"chan",
"*",
"migrator",
".",
"ProgressUpdate",
",",
"doneCh",
"<-",
"chan",
"struct",
"{",
"}",
")",
"{",
"var",
"lastOp",
"string",
"\n",
"var",
"lastProgress",
"float64",
"\n",
"lastFlush",
":=",
"time",
".",
... | // handleProgress is used to dump progress information to the console while
// a migration is in flight. This allows the user to monitor a migration. | [
"handleProgress",
"is",
"used",
"to",
"dump",
"progress",
"information",
"to",
"the",
"console",
"while",
"a",
"migration",
"is",
"in",
"flight",
".",
"This",
"allows",
"the",
"user",
"to",
"monitor",
"a",
"migration",
"."
] | 678fb10cdeae25ab309e99e655148f0bf65f9710 | https://github.com/hashicorp/consul-migrate/blob/678fb10cdeae25ab309e99e655148f0bf65f9710/main.go#L58-L87 |
123,563 | hashicorp/consul-migrate | migrator/migrator.go | New | func New(dataDir string) (*Migrator, error) {
// Check that the directory exists
if _, err := os.Stat(dataDir); err != nil {
return nil, err
}
// Create the struct
m := &Migrator{
ProgressCh: make(chan *ProgressUpdate, 128),
dataDir: dataDir,
raftPath: filepath.Join(dataDir, raftDir),
mdbPath: ... | go | func New(dataDir string) (*Migrator, error) {
// Check that the directory exists
if _, err := os.Stat(dataDir); err != nil {
return nil, err
}
// Create the struct
m := &Migrator{
ProgressCh: make(chan *ProgressUpdate, 128),
dataDir: dataDir,
raftPath: filepath.Join(dataDir, raftDir),
mdbPath: ... | [
"func",
"New",
"(",
"dataDir",
"string",
")",
"(",
"*",
"Migrator",
",",
"error",
")",
"{",
"// Check that the directory exists",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"dataDir",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
... | // New creates a new Migrator given the path to a Consul
// data-dir. Returns the new Migrator and any error. | [
"New",
"creates",
"a",
"new",
"Migrator",
"given",
"the",
"path",
"to",
"a",
"Consul",
"data",
"-",
"dir",
".",
"Returns",
"the",
"new",
"Migrator",
"and",
"any",
"error",
"."
] | 678fb10cdeae25ab309e99e655148f0bf65f9710 | https://github.com/hashicorp/consul-migrate/blob/678fb10cdeae25ab309e99e655148f0bf65f9710/migrator/migrator.go#L71-L90 |
123,564 | hashicorp/consul-migrate | migrator/migrator.go | mdbConnect | func (m *Migrator) mdbConnect(dir string) error {
// Calculate and set the max size
size := maxLogSize32bit
if runtime.GOARCH == "amd64" {
size = maxLogSize64bit
}
// Open the connection
mdb, err := raftmdb.NewMDBStoreWithSize(dir, size)
if err != nil {
return err
}
// Return the new environment
m.mdbSt... | go | func (m *Migrator) mdbConnect(dir string) error {
// Calculate and set the max size
size := maxLogSize32bit
if runtime.GOARCH == "amd64" {
size = maxLogSize64bit
}
// Open the connection
mdb, err := raftmdb.NewMDBStoreWithSize(dir, size)
if err != nil {
return err
}
// Return the new environment
m.mdbSt... | [
"func",
"(",
"m",
"*",
"Migrator",
")",
"mdbConnect",
"(",
"dir",
"string",
")",
"error",
"{",
"// Calculate and set the max size",
"size",
":=",
"maxLogSize32bit",
"\n",
"if",
"runtime",
".",
"GOARCH",
"==",
"\"",
"\"",
"{",
"size",
"=",
"maxLogSize64bit",
... | // mdbConnect is used to open a handle on our LMDB raft backend. This
// is enough to read all of the Consul data we need to migrate. | [
"mdbConnect",
"is",
"used",
"to",
"open",
"a",
"handle",
"on",
"our",
"LMDB",
"raft",
"backend",
".",
"This",
"is",
"enough",
"to",
"read",
"all",
"of",
"the",
"Consul",
"data",
"we",
"need",
"to",
"migrate",
"."
] | 678fb10cdeae25ab309e99e655148f0bf65f9710 | https://github.com/hashicorp/consul-migrate/blob/678fb10cdeae25ab309e99e655148f0bf65f9710/migrator/migrator.go#L94-L110 |
123,565 | hashicorp/consul-migrate | migrator/migrator.go | boltConnect | func (m *Migrator) boltConnect(file string) error {
// Connect to the new BoltStore
store, err := raftboltdb.NewBoltStore(file)
if err != nil {
return err
}
m.boltStore = store
return nil
} | go | func (m *Migrator) boltConnect(file string) error {
// Connect to the new BoltStore
store, err := raftboltdb.NewBoltStore(file)
if err != nil {
return err
}
m.boltStore = store
return nil
} | [
"func",
"(",
"m",
"*",
"Migrator",
")",
"boltConnect",
"(",
"file",
"string",
")",
"error",
"{",
"// Connect to the new BoltStore",
"store",
",",
"err",
":=",
"raftboltdb",
".",
"NewBoltStore",
"(",
"file",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return... | // boltConnect creates a new BoltStore to copy our data into. We can
// use the BoltStore directly because it provides simple setter
// methods, provided our keys and values are known. | [
"boltConnect",
"creates",
"a",
"new",
"BoltStore",
"to",
"copy",
"our",
"data",
"into",
".",
"We",
"can",
"use",
"the",
"BoltStore",
"directly",
"because",
"it",
"provides",
"simple",
"setter",
"methods",
"provided",
"our",
"keys",
"and",
"values",
"are",
"k... | 678fb10cdeae25ab309e99e655148f0bf65f9710 | https://github.com/hashicorp/consul-migrate/blob/678fb10cdeae25ab309e99e655148f0bf65f9710/migrator/migrator.go#L115-L124 |
123,566 | hashicorp/consul-migrate | migrator/migrator.go | migrateStableStore | func (m *Migrator) migrateStableStore() error {
op := "Migrating stable store"
m.sendProgress(op, 0, 1)
total := len(stableStoreKeys)
for i, key := range stableStoreKeys {
val, err := m.mdbStore.Get(key)
if err != nil {
if err.Error() != "not found" {
return fmt.Errorf("Error getting key '%s': %s", stri... | go | func (m *Migrator) migrateStableStore() error {
op := "Migrating stable store"
m.sendProgress(op, 0, 1)
total := len(stableStoreKeys)
for i, key := range stableStoreKeys {
val, err := m.mdbStore.Get(key)
if err != nil {
if err.Error() != "not found" {
return fmt.Errorf("Error getting key '%s': %s", stri... | [
"func",
"(",
"m",
"*",
"Migrator",
")",
"migrateStableStore",
"(",
")",
"error",
"{",
"op",
":=",
"\"",
"\"",
"\n",
"m",
".",
"sendProgress",
"(",
"op",
",",
"0",
",",
"1",
")",
"\n\n",
"total",
":=",
"len",
"(",
"stableStoreKeys",
")",
"\n",
"for"... | // migrateStableStore copies values out of the origin StableStore
// and writes them into the destination. There are only a handful
// of keys we need, so we copy them explicitly. | [
"migrateStableStore",
"copies",
"values",
"out",
"of",
"the",
"origin",
"StableStore",
"and",
"writes",
"them",
"into",
"the",
"destination",
".",
"There",
"are",
"only",
"a",
"handful",
"of",
"keys",
"we",
"need",
"so",
"we",
"copy",
"them",
"explicitly",
"... | 678fb10cdeae25ab309e99e655148f0bf65f9710 | https://github.com/hashicorp/consul-migrate/blob/678fb10cdeae25ab309e99e655148f0bf65f9710/migrator/migrator.go#L129-L149 |
123,567 | hashicorp/consul-migrate | migrator/migrator.go | migrateLogStore | func (m *Migrator) migrateLogStore() error {
op := "Migrating log store"
m.sendProgress(op, 0, 1)
first, err := m.mdbStore.FirstIndex()
if err != nil {
return err
}
if first == 0 {
return errFirstIndexZero
}
last, err := m.mdbStore.LastIndex()
if err != nil {
return err
}
if last == 0 {
return errL... | go | func (m *Migrator) migrateLogStore() error {
op := "Migrating log store"
m.sendProgress(op, 0, 1)
first, err := m.mdbStore.FirstIndex()
if err != nil {
return err
}
if first == 0 {
return errFirstIndexZero
}
last, err := m.mdbStore.LastIndex()
if err != nil {
return err
}
if last == 0 {
return errL... | [
"func",
"(",
"m",
"*",
"Migrator",
")",
"migrateLogStore",
"(",
")",
"error",
"{",
"op",
":=",
"\"",
"\"",
"\n",
"m",
".",
"sendProgress",
"(",
"op",
",",
"0",
",",
"1",
")",
"\n\n",
"first",
",",
"err",
":=",
"m",
".",
"mdbStore",
".",
"FirstInd... | // migrateLogStore is like migrateStableStore, but iterates over
// all of our Raft logs and copies them into the new BoltStore. | [
"migrateLogStore",
"is",
"like",
"migrateStableStore",
"but",
"iterates",
"over",
"all",
"of",
"our",
"Raft",
"logs",
"and",
"copies",
"them",
"into",
"the",
"new",
"BoltStore",
"."
] | 678fb10cdeae25ab309e99e655148f0bf65f9710 | https://github.com/hashicorp/consul-migrate/blob/678fb10cdeae25ab309e99e655148f0bf65f9710/migrator/migrator.go#L153-L187 |
123,568 | hashicorp/consul-migrate | migrator/migrator.go | activateBoltStore | func (m *Migrator) activateBoltStore() error {
op := "Moving Bolt file into place"
m.sendProgress(op, 0, 1)
if err := os.Rename(m.boltTempPath, m.boltPath); err != nil {
return err
}
m.sendProgress(op, 1, 1)
return nil
} | go | func (m *Migrator) activateBoltStore() error {
op := "Moving Bolt file into place"
m.sendProgress(op, 0, 1)
if err := os.Rename(m.boltTempPath, m.boltPath); err != nil {
return err
}
m.sendProgress(op, 1, 1)
return nil
} | [
"func",
"(",
"m",
"*",
"Migrator",
")",
"activateBoltStore",
"(",
")",
"error",
"{",
"op",
":=",
"\"",
"\"",
"\n",
"m",
".",
"sendProgress",
"(",
"op",
",",
"0",
",",
"1",
")",
"\n\n",
"if",
"err",
":=",
"os",
".",
"Rename",
"(",
"m",
".",
"bol... | // activateBoltStore wraps moving the Bolt file into place after
// a data migration has finished successfully. | [
"activateBoltStore",
"wraps",
"moving",
"the",
"Bolt",
"file",
"into",
"place",
"after",
"a",
"data",
"migration",
"has",
"finished",
"successfully",
"."
] | 678fb10cdeae25ab309e99e655148f0bf65f9710 | https://github.com/hashicorp/consul-migrate/blob/678fb10cdeae25ab309e99e655148f0bf65f9710/migrator/migrator.go#L191-L201 |
123,569 | hashicorp/consul-migrate | migrator/migrator.go | archiveMDBStore | func (m *Migrator) archiveMDBStore() error {
op := "Archiving LMDB data"
m.sendProgress(op, 0, 1)
if err := os.Rename(m.mdbPath, m.mdbBackupPath); err != nil {
os.Remove(m.boltPath)
return err
}
m.sendProgress(op, 1, 1)
return nil
} | go | func (m *Migrator) archiveMDBStore() error {
op := "Archiving LMDB data"
m.sendProgress(op, 0, 1)
if err := os.Rename(m.mdbPath, m.mdbBackupPath); err != nil {
os.Remove(m.boltPath)
return err
}
m.sendProgress(op, 1, 1)
return nil
} | [
"func",
"(",
"m",
"*",
"Migrator",
")",
"archiveMDBStore",
"(",
")",
"error",
"{",
"op",
":=",
"\"",
"\"",
"\n",
"m",
".",
"sendProgress",
"(",
"op",
",",
"0",
",",
"1",
")",
"\n\n",
"if",
"err",
":=",
"os",
".",
"Rename",
"(",
"m",
".",
"mdbPa... | // archiveMDBStore is used to move the LMDB data directory to a backup
// location so that it is not used by Consul again. | [
"archiveMDBStore",
"is",
"used",
"to",
"move",
"the",
"LMDB",
"data",
"directory",
"to",
"a",
"backup",
"location",
"so",
"that",
"it",
"is",
"not",
"used",
"by",
"Consul",
"again",
"."
] | 678fb10cdeae25ab309e99e655148f0bf65f9710 | https://github.com/hashicorp/consul-migrate/blob/678fb10cdeae25ab309e99e655148f0bf65f9710/migrator/migrator.go#L205-L216 |
123,570 | hashicorp/consul-migrate | migrator/migrator.go | Migrate | func (m *Migrator) Migrate() (bool, error) {
// Check if we should attempt a migration
if _, err := os.Stat(m.mdbPath); os.IsNotExist(err) {
return false, nil
}
// Connect the stores
if err := m.mdbConnect(m.raftPath); err != nil {
return false, fmt.Errorf("Failed to connect MDB: %s", err)
}
defer m.mdbStor... | go | func (m *Migrator) Migrate() (bool, error) {
// Check if we should attempt a migration
if _, err := os.Stat(m.mdbPath); os.IsNotExist(err) {
return false, nil
}
// Connect the stores
if err := m.mdbConnect(m.raftPath); err != nil {
return false, fmt.Errorf("Failed to connect MDB: %s", err)
}
defer m.mdbStor... | [
"func",
"(",
"m",
"*",
"Migrator",
")",
"Migrate",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"// Check if we should attempt a migration",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"m",
".",
"mdbPath",
")",
";",
"os",
".",
"IsNotExist",
... | // Migrate is the high-level function we call when we want to attempt
// to migrate all of our LMDB data into BoltDB. If an error is
// encountered, the BoltStore is nuked from disk, since it is useless.
// The migration can be attempted again, as the LMDB data should
// still be intact. Returns a bool indicating wheth... | [
"Migrate",
"is",
"the",
"high",
"-",
"level",
"function",
"we",
"call",
"when",
"we",
"want",
"to",
"attempt",
"to",
"migrate",
"all",
"of",
"our",
"LMDB",
"data",
"into",
"BoltDB",
".",
"If",
"an",
"error",
"is",
"encountered",
"the",
"BoltStore",
"is",... | 678fb10cdeae25ab309e99e655148f0bf65f9710 | https://github.com/hashicorp/consul-migrate/blob/678fb10cdeae25ab309e99e655148f0bf65f9710/migrator/migrator.go#L224-L265 |
123,571 | hashicorp/consul-migrate | migrator/migrator.go | sendProgress | func (m *Migrator) sendProgress(op string, done, total int) {
update := ProgressUpdate{op, (float64(done) / float64(total)) * 100}
select {
case m.ProgressCh <- &update:
default:
}
} | go | func (m *Migrator) sendProgress(op string, done, total int) {
update := ProgressUpdate{op, (float64(done) / float64(total)) * 100}
select {
case m.ProgressCh <- &update:
default:
}
} | [
"func",
"(",
"m",
"*",
"Migrator",
")",
"sendProgress",
"(",
"op",
"string",
",",
"done",
",",
"total",
"int",
")",
"{",
"update",
":=",
"ProgressUpdate",
"{",
"op",
",",
"(",
"float64",
"(",
"done",
")",
"/",
"float64",
"(",
"total",
")",
")",
"*"... | // sendProgress is used to send a progress update message to the progress
// channel. Sending is a non-blocking operation. It is the responsibility
// of the caller to ensure they drain the queue promptly to avoid missing
// progress update messages. | [
"sendProgress",
"is",
"used",
"to",
"send",
"a",
"progress",
"update",
"message",
"to",
"the",
"progress",
"channel",
".",
"Sending",
"is",
"a",
"non",
"-",
"blocking",
"operation",
".",
"It",
"is",
"the",
"responsibility",
"of",
"the",
"caller",
"to",
"en... | 678fb10cdeae25ab309e99e655148f0bf65f9710 | https://github.com/hashicorp/consul-migrate/blob/678fb10cdeae25ab309e99e655148f0bf65f9710/migrator/migrator.go#L271-L277 |
123,572 | shibukawa/configdir | config.go | CreateParentDir | func (c Config) CreateParentDir(fileName string) error {
return os.MkdirAll(filepath.Dir(filepath.Join(c.Path, fileName)), 0755)
} | go | func (c Config) CreateParentDir(fileName string) error {
return os.MkdirAll(filepath.Dir(filepath.Join(c.Path, fileName)), 0755)
} | [
"func",
"(",
"c",
"Config",
")",
"CreateParentDir",
"(",
"fileName",
"string",
")",
"error",
"{",
"return",
"os",
".",
"MkdirAll",
"(",
"filepath",
".",
"Dir",
"(",
"filepath",
".",
"Join",
"(",
"c",
".",
"Path",
",",
"fileName",
")",
")",
",",
"0755... | // CreateParentDir creates the parent directory of fileName inside c. fileName
// is a relative path inside c, containing zero or more path separators. | [
"CreateParentDir",
"creates",
"the",
"parent",
"directory",
"of",
"fileName",
"inside",
"c",
".",
"fileName",
"is",
"a",
"relative",
"path",
"inside",
"c",
"containing",
"zero",
"or",
"more",
"path",
"separators",
"."
] | e180dbdc8da04c4fa04272e875ce64949f38bd3e | https://github.com/shibukawa/configdir/blob/e180dbdc8da04c4fa04272e875ce64949f38bd3e/config.go#L66-L68 |
123,573 | rakyll/portmidi | stream.go | NewInputStream | func NewInputStream(id DeviceID, bufferSize int64) (stream *Stream, err error) {
var str *C.PmStream
errCode := C.Pm_OpenInput(
(*unsafe.Pointer)(unsafe.Pointer(&str)),
C.PmDeviceID(id), nil, C.int32_t(bufferSize), nil, nil)
if errCode != 0 {
return nil, convertToError(errCode)
}
if info := Info(id); !info.I... | go | func NewInputStream(id DeviceID, bufferSize int64) (stream *Stream, err error) {
var str *C.PmStream
errCode := C.Pm_OpenInput(
(*unsafe.Pointer)(unsafe.Pointer(&str)),
C.PmDeviceID(id), nil, C.int32_t(bufferSize), nil, nil)
if errCode != 0 {
return nil, convertToError(errCode)
}
if info := Info(id); !info.I... | [
"func",
"NewInputStream",
"(",
"id",
"DeviceID",
",",
"bufferSize",
"int64",
")",
"(",
"stream",
"*",
"Stream",
",",
"err",
"error",
")",
"{",
"var",
"str",
"*",
"C",
".",
"PmStream",
"\n",
"errCode",
":=",
"C",
".",
"Pm_OpenInput",
"(",
"(",
"*",
"u... | // NewInputStream initializes a new input stream. | [
"NewInputStream",
"initializes",
"a",
"new",
"input",
"stream",
"."
] | 1246dd47c56089ea2ae791266edb7f4c6b90c045 | https://github.com/rakyll/portmidi/blob/1246dd47c56089ea2ae791266edb7f4c6b90c045/stream.go#L62-L74 |
123,574 | rakyll/portmidi | stream.go | NewOutputStream | func NewOutputStream(id DeviceID, bufferSize int64, latency int64) (stream *Stream, err error) {
var str *C.PmStream
errCode := C.Pm_OpenOutput(
(*unsafe.Pointer)(unsafe.Pointer(&str)),
C.PmDeviceID(id), nil, C.int32_t(bufferSize), nil, nil, C.int32_t(latency))
if errCode != 0 {
return nil, convertToError(errC... | go | func NewOutputStream(id DeviceID, bufferSize int64, latency int64) (stream *Stream, err error) {
var str *C.PmStream
errCode := C.Pm_OpenOutput(
(*unsafe.Pointer)(unsafe.Pointer(&str)),
C.PmDeviceID(id), nil, C.int32_t(bufferSize), nil, nil, C.int32_t(latency))
if errCode != 0 {
return nil, convertToError(errC... | [
"func",
"NewOutputStream",
"(",
"id",
"DeviceID",
",",
"bufferSize",
"int64",
",",
"latency",
"int64",
")",
"(",
"stream",
"*",
"Stream",
",",
"err",
"error",
")",
"{",
"var",
"str",
"*",
"C",
".",
"PmStream",
"\n",
"errCode",
":=",
"C",
".",
"Pm_OpenO... | // NewOutputStream initializes a new output stream. | [
"NewOutputStream",
"initializes",
"a",
"new",
"output",
"stream",
"."
] | 1246dd47c56089ea2ae791266edb7f4c6b90c045 | https://github.com/rakyll/portmidi/blob/1246dd47c56089ea2ae791266edb7f4c6b90c045/stream.go#L77-L89 |
123,575 | rakyll/portmidi | stream.go | Close | func (s *Stream) Close() error {
if s.pmStream == nil {
return nil
}
return convertToError(C.Pm_Close(unsafe.Pointer(s.pmStream)))
} | go | func (s *Stream) Close() error {
if s.pmStream == nil {
return nil
}
return convertToError(C.Pm_Close(unsafe.Pointer(s.pmStream)))
} | [
"func",
"(",
"s",
"*",
"Stream",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"s",
".",
"pmStream",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"convertToError",
"(",
"C",
".",
"Pm_Close",
"(",
"unsafe",
".",
"Pointer",
"(",
"s",
... | // Close closes the MIDI stream. | [
"Close",
"closes",
"the",
"MIDI",
"stream",
"."
] | 1246dd47c56089ea2ae791266edb7f4c6b90c045 | https://github.com/rakyll/portmidi/blob/1246dd47c56089ea2ae791266edb7f4c6b90c045/stream.go#L92-L97 |
123,576 | rakyll/portmidi | stream.go | Abort | func (s *Stream) Abort() error {
if s.pmStream == nil {
return nil
}
return convertToError(C.Pm_Abort(unsafe.Pointer(s.pmStream)))
} | go | func (s *Stream) Abort() error {
if s.pmStream == nil {
return nil
}
return convertToError(C.Pm_Abort(unsafe.Pointer(s.pmStream)))
} | [
"func",
"(",
"s",
"*",
"Stream",
")",
"Abort",
"(",
")",
"error",
"{",
"if",
"s",
".",
"pmStream",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"convertToError",
"(",
"C",
".",
"Pm_Abort",
"(",
"unsafe",
".",
"Pointer",
"(",
"s",
... | // Abort aborts the MIDI stream. | [
"Abort",
"aborts",
"the",
"MIDI",
"stream",
"."
] | 1246dd47c56089ea2ae791266edb7f4c6b90c045 | https://github.com/rakyll/portmidi/blob/1246dd47c56089ea2ae791266edb7f4c6b90c045/stream.go#L100-L105 |
123,577 | rakyll/portmidi | stream.go | Write | func (s *Stream) Write(events []Event) error {
size := len(events)
if size > maxEventBufferSize {
return ErrMaxBuffer
}
buffer := make([]C.PmEvent, size)
for i, evt := range events {
var event C.PmEvent
event.timestamp = C.PmTimestamp(evt.Timestamp)
event.message = C.PmMessage((((evt.Data2 << 16) & 0xFF000... | go | func (s *Stream) Write(events []Event) error {
size := len(events)
if size > maxEventBufferSize {
return ErrMaxBuffer
}
buffer := make([]C.PmEvent, size)
for i, evt := range events {
var event C.PmEvent
event.timestamp = C.PmTimestamp(evt.Timestamp)
event.message = C.PmMessage((((evt.Data2 << 16) & 0xFF000... | [
"func",
"(",
"s",
"*",
"Stream",
")",
"Write",
"(",
"events",
"[",
"]",
"Event",
")",
"error",
"{",
"size",
":=",
"len",
"(",
"events",
")",
"\n",
"if",
"size",
">",
"maxEventBufferSize",
"{",
"return",
"ErrMaxBuffer",
"\n",
"}",
"\n",
"buffer",
":="... | // Write writes a buffer of MIDI events to the output stream. | [
"Write",
"writes",
"a",
"buffer",
"of",
"MIDI",
"events",
"to",
"the",
"output",
"stream",
"."
] | 1246dd47c56089ea2ae791266edb7f4c6b90c045 | https://github.com/rakyll/portmidi/blob/1246dd47c56089ea2ae791266edb7f4c6b90c045/stream.go#L108-L121 |
123,578 | rakyll/portmidi | stream.go | WriteShort | func (s *Stream) WriteShort(status int64, data1 int64, data2 int64) error {
evt := Event{
Timestamp: Timestamp(C.Pt_Time()),
Status: status,
Data1: data1,
Data2: data2,
}
return s.Write([]Event{evt})
} | go | func (s *Stream) WriteShort(status int64, data1 int64, data2 int64) error {
evt := Event{
Timestamp: Timestamp(C.Pt_Time()),
Status: status,
Data1: data1,
Data2: data2,
}
return s.Write([]Event{evt})
} | [
"func",
"(",
"s",
"*",
"Stream",
")",
"WriteShort",
"(",
"status",
"int64",
",",
"data1",
"int64",
",",
"data2",
"int64",
")",
"error",
"{",
"evt",
":=",
"Event",
"{",
"Timestamp",
":",
"Timestamp",
"(",
"C",
".",
"Pt_Time",
"(",
")",
")",
",",
"St... | // WriteShort writes a MIDI event of three bytes immediately to the output stream. | [
"WriteShort",
"writes",
"a",
"MIDI",
"event",
"of",
"three",
"bytes",
"immediately",
"to",
"the",
"output",
"stream",
"."
] | 1246dd47c56089ea2ae791266edb7f4c6b90c045 | https://github.com/rakyll/portmidi/blob/1246dd47c56089ea2ae791266edb7f4c6b90c045/stream.go#L124-L132 |
123,579 | rakyll/portmidi | stream.go | Read | func (s *Stream) Read(max int) (events []Event, err error) {
if max > maxEventBufferSize {
return nil, ErrMaxBuffer
}
if max < minEventBufferSize {
return nil, ErrMinBuffer
}
buffer := make([]C.PmEvent, max)
numEvents := C.Pm_Read(unsafe.Pointer(s.pmStream), &buffer[0], C.int32_t(max))
if numEvents < 0 {
r... | go | func (s *Stream) Read(max int) (events []Event, err error) {
if max > maxEventBufferSize {
return nil, ErrMaxBuffer
}
if max < minEventBufferSize {
return nil, ErrMinBuffer
}
buffer := make([]C.PmEvent, max)
numEvents := C.Pm_Read(unsafe.Pointer(s.pmStream), &buffer[0], C.int32_t(max))
if numEvents < 0 {
r... | [
"func",
"(",
"s",
"*",
"Stream",
")",
"Read",
"(",
"max",
"int",
")",
"(",
"events",
"[",
"]",
"Event",
",",
"err",
"error",
")",
"{",
"if",
"max",
">",
"maxEventBufferSize",
"{",
"return",
"nil",
",",
"ErrMaxBuffer",
"\n",
"}",
"\n",
"if",
"max",
... | // Reads from the input stream, the max number events to be read are
// determined by max. | [
"Reads",
"from",
"the",
"input",
"stream",
"the",
"max",
"number",
"events",
"to",
"be",
"read",
"are",
"determined",
"by",
"max",
"."
] | 1246dd47c56089ea2ae791266edb7f4c6b90c045 | https://github.com/rakyll/portmidi/blob/1246dd47c56089ea2ae791266edb7f4c6b90c045/stream.go#L161-L183 |
123,580 | rakyll/portmidi | stream.go | Listen | func (s *Stream) Listen() <-chan Event {
ch := make(chan Event)
go func(s *Stream, ch chan Event) {
for {
// sleep for a while before the new polling tick,
// otherwise operation is too intensive and blocking
time.Sleep(10 * time.Millisecond)
events, err := s.Read(1024)
// Note: It's not very reasona... | go | func (s *Stream) Listen() <-chan Event {
ch := make(chan Event)
go func(s *Stream, ch chan Event) {
for {
// sleep for a while before the new polling tick,
// otherwise operation is too intensive and blocking
time.Sleep(10 * time.Millisecond)
events, err := s.Read(1024)
// Note: It's not very reasona... | [
"func",
"(",
"s",
"*",
"Stream",
")",
"Listen",
"(",
")",
"<-",
"chan",
"Event",
"{",
"ch",
":=",
"make",
"(",
"chan",
"Event",
")",
"\n",
"go",
"func",
"(",
"s",
"*",
"Stream",
",",
"ch",
"chan",
"Event",
")",
"{",
"for",
"{",
"// sleep for a wh... | // Listen input stream for MIDI events. | [
"Listen",
"input",
"stream",
"for",
"MIDI",
"events",
"."
] | 1246dd47c56089ea2ae791266edb7f4c6b90c045 | https://github.com/rakyll/portmidi/blob/1246dd47c56089ea2ae791266edb7f4c6b90c045/stream.go#L209-L229 |
123,581 | rakyll/portmidi | stream.go | Poll | func (s *Stream) Poll() (bool, error) {
poll := C.Pm_Poll(unsafe.Pointer(s.pmStream))
if poll < 0 {
return false, convertToError(C.PmError(poll))
}
return poll > 0, nil
} | go | func (s *Stream) Poll() (bool, error) {
poll := C.Pm_Poll(unsafe.Pointer(s.pmStream))
if poll < 0 {
return false, convertToError(C.PmError(poll))
}
return poll > 0, nil
} | [
"func",
"(",
"s",
"*",
"Stream",
")",
"Poll",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"poll",
":=",
"C",
".",
"Pm_Poll",
"(",
"unsafe",
".",
"Pointer",
"(",
"s",
".",
"pmStream",
")",
")",
"\n",
"if",
"poll",
"<",
"0",
"{",
"return",
"... | // Poll reports whether there is input available in the stream. | [
"Poll",
"reports",
"whether",
"there",
"is",
"input",
"available",
"in",
"the",
"stream",
"."
] | 1246dd47c56089ea2ae791266edb7f4c6b90c045 | https://github.com/rakyll/portmidi/blob/1246dd47c56089ea2ae791266edb7f4c6b90c045/stream.go#L232-L238 |
123,582 | rakyll/portmidi | portmidi.go | Initialize | func Initialize() error {
if code := C.Pm_Initialize(); code != 0 {
return convertToError(code)
}
C.Pt_Start(C.int(1), nil, nil)
return nil
} | go | func Initialize() error {
if code := C.Pm_Initialize(); code != 0 {
return convertToError(code)
}
C.Pt_Start(C.int(1), nil, nil)
return nil
} | [
"func",
"Initialize",
"(",
")",
"error",
"{",
"if",
"code",
":=",
"C",
".",
"Pm_Initialize",
"(",
")",
";",
"code",
"!=",
"0",
"{",
"return",
"convertToError",
"(",
"code",
")",
"\n",
"}",
"\n",
"C",
".",
"Pt_Start",
"(",
"C",
".",
"int",
"(",
"1... | // Initialize initializes the portmidi. Needs to be called before
// making any other call from the portmidi package.
// Once portmidi package is no longer required, Terminate should be
// called to free the underlying resources. | [
"Initialize",
"initializes",
"the",
"portmidi",
".",
"Needs",
"to",
"be",
"called",
"before",
"making",
"any",
"other",
"call",
"from",
"the",
"portmidi",
"package",
".",
"Once",
"portmidi",
"package",
"is",
"no",
"longer",
"required",
"Terminate",
"should",
"... | 1246dd47c56089ea2ae791266edb7f4c6b90c045 | https://github.com/rakyll/portmidi/blob/1246dd47c56089ea2ae791266edb7f4c6b90c045/portmidi.go#L48-L54 |
123,583 | rakyll/portmidi | portmidi.go | Info | func Info(deviceID DeviceID) *DeviceInfo {
info := C.Pm_GetDeviceInfo(C.PmDeviceID(deviceID))
if info == nil {
return nil
}
return &DeviceInfo{
Interface: C.GoString(info.interf),
Name: C.GoString(info.name),
IsInputAvailable: info.input > 0,
IsOutputAvailable: info.output > 0,
IsO... | go | func Info(deviceID DeviceID) *DeviceInfo {
info := C.Pm_GetDeviceInfo(C.PmDeviceID(deviceID))
if info == nil {
return nil
}
return &DeviceInfo{
Interface: C.GoString(info.interf),
Name: C.GoString(info.name),
IsInputAvailable: info.input > 0,
IsOutputAvailable: info.output > 0,
IsO... | [
"func",
"Info",
"(",
"deviceID",
"DeviceID",
")",
"*",
"DeviceInfo",
"{",
"info",
":=",
"C",
".",
"Pm_GetDeviceInfo",
"(",
"C",
".",
"PmDeviceID",
"(",
"deviceID",
")",
")",
"\n",
"if",
"info",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"ret... | // Info returns the device info for the device indentified with deviceID.
// If deviceID is out of range, Info returns nil. | [
"Info",
"returns",
"the",
"device",
"info",
"for",
"the",
"device",
"indentified",
"with",
"deviceID",
".",
"If",
"deviceID",
"is",
"out",
"of",
"range",
"Info",
"returns",
"nil",
"."
] | 1246dd47c56089ea2ae791266edb7f4c6b90c045 | https://github.com/rakyll/portmidi/blob/1246dd47c56089ea2ae791266edb7f4c6b90c045/portmidi.go#L79-L91 |
123,584 | rakyll/portmidi | portmidi.go | convertToError | func convertToError(code C.PmError) error {
if code >= 0 {
return nil
}
return errors.New(C.GoString(C.Pm_GetErrorText(code)))
} | go | func convertToError(code C.PmError) error {
if code >= 0 {
return nil
}
return errors.New(C.GoString(C.Pm_GetErrorText(code)))
} | [
"func",
"convertToError",
"(",
"code",
"C",
".",
"PmError",
")",
"error",
"{",
"if",
"code",
">=",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"errors",
".",
"New",
"(",
"C",
".",
"GoString",
"(",
"C",
".",
"Pm_GetErrorText",
"(",
"code",
... | // convertToError converts a portmidi error code to a Go error. | [
"convertToError",
"converts",
"a",
"portmidi",
"error",
"code",
"to",
"a",
"Go",
"error",
"."
] | 1246dd47c56089ea2ae791266edb7f4c6b90c045 | https://github.com/rakyll/portmidi/blob/1246dd47c56089ea2ae791266edb7f4c6b90c045/portmidi.go#L99-L104 |
123,585 | ryszard/goskiplist | skiplist/skiplist.go | next | func (n *node) next() *node {
if len(n.forward) == 0 {
return nil
}
return n.forward[0]
} | go | func (n *node) next() *node {
if len(n.forward) == 0 {
return nil
}
return n.forward[0]
} | [
"func",
"(",
"n",
"*",
"node",
")",
"next",
"(",
")",
"*",
"node",
"{",
"if",
"len",
"(",
"n",
".",
"forward",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"n",
".",
"forward",
"[",
"0",
"]",
"\n",
"}"
] | // next returns the next node in the skip list containing n. | [
"next",
"returns",
"the",
"next",
"node",
"in",
"the",
"skip",
"list",
"containing",
"n",
"."
] | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L41-L46 |
123,586 | ryszard/goskiplist | skiplist/skiplist.go | Iterator | func (s *SkipList) Iterator() Iterator {
return &iter{
current: s.header,
list: s,
}
} | go | func (s *SkipList) Iterator() Iterator {
return &iter{
current: s.header,
list: s,
}
} | [
"func",
"(",
"s",
"*",
"SkipList",
")",
"Iterator",
"(",
")",
"Iterator",
"{",
"return",
"&",
"iter",
"{",
"current",
":",
"s",
".",
"header",
",",
"list",
":",
"s",
",",
"}",
"\n",
"}"
] | // Iterator returns an Iterator that will go through all elements s. | [
"Iterator",
"returns",
"an",
"Iterator",
"that",
"will",
"go",
"through",
"all",
"elements",
"s",
"."
] | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L267-L272 |
123,587 | ryszard/goskiplist | skiplist/skiplist.go | Seek | func (s *SkipList) Seek(key interface{}) Iterator {
current := s.getPath(s.header, nil, key)
if current == nil {
return nil
}
return &iter{
current: current,
key: current.key,
list: s,
value: current.value,
}
} | go | func (s *SkipList) Seek(key interface{}) Iterator {
current := s.getPath(s.header, nil, key)
if current == nil {
return nil
}
return &iter{
current: current,
key: current.key,
list: s,
value: current.value,
}
} | [
"func",
"(",
"s",
"*",
"SkipList",
")",
"Seek",
"(",
"key",
"interface",
"{",
"}",
")",
"Iterator",
"{",
"current",
":=",
"s",
".",
"getPath",
"(",
"s",
".",
"header",
",",
"nil",
",",
"key",
")",
"\n",
"if",
"current",
"==",
"nil",
"{",
"return"... | // Seek returns a bidirectional iterator starting with the first element whose
// key is greater or equal to key; otherwise, a nil iterator is returned. | [
"Seek",
"returns",
"a",
"bidirectional",
"iterator",
"starting",
"with",
"the",
"first",
"element",
"whose",
"key",
"is",
"greater",
"or",
"equal",
"to",
"key",
";",
"otherwise",
"a",
"nil",
"iterator",
"is",
"returned",
"."
] | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L276-L288 |
123,588 | ryszard/goskiplist | skiplist/skiplist.go | SeekToFirst | func (s *SkipList) SeekToFirst() Iterator {
if s.length == 0 {
return nil
}
current := s.header.next()
return &iter{
current: current,
key: current.key,
list: s,
value: current.value,
}
} | go | func (s *SkipList) SeekToFirst() Iterator {
if s.length == 0 {
return nil
}
current := s.header.next()
return &iter{
current: current,
key: current.key,
list: s,
value: current.value,
}
} | [
"func",
"(",
"s",
"*",
"SkipList",
")",
"SeekToFirst",
"(",
")",
"Iterator",
"{",
"if",
"s",
".",
"length",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"current",
":=",
"s",
".",
"header",
".",
"next",
"(",
")",
"\n\n",
"return",
"&",
"it... | // SeekToFirst returns a bidirectional iterator starting from the first element
// in the list if the list is populated; otherwise, a nil iterator is returned. | [
"SeekToFirst",
"returns",
"a",
"bidirectional",
"iterator",
"starting",
"from",
"the",
"first",
"element",
"in",
"the",
"list",
"if",
"the",
"list",
"is",
"populated",
";",
"otherwise",
"a",
"nil",
"iterator",
"is",
"returned",
"."
] | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L292-L305 |
123,589 | ryszard/goskiplist | skiplist/skiplist.go | SeekToLast | func (s *SkipList) SeekToLast() Iterator {
current := s.footer
if current == nil {
return nil
}
return &iter{
current: current,
key: current.key,
list: s,
value: current.value,
}
} | go | func (s *SkipList) SeekToLast() Iterator {
current := s.footer
if current == nil {
return nil
}
return &iter{
current: current,
key: current.key,
list: s,
value: current.value,
}
} | [
"func",
"(",
"s",
"*",
"SkipList",
")",
"SeekToLast",
"(",
")",
"Iterator",
"{",
"current",
":=",
"s",
".",
"footer",
"\n",
"if",
"current",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"&",
"iter",
"{",
"current",
":",
"current",
... | // SeekToLast returns a bidirectional iterator starting from the last element
// in the list if the list is populated; otherwise, a nil iterator is returned. | [
"SeekToLast",
"returns",
"a",
"bidirectional",
"iterator",
"starting",
"from",
"the",
"last",
"element",
"in",
"the",
"list",
"if",
"the",
"list",
"is",
"populated",
";",
"otherwise",
"a",
"nil",
"iterator",
"is",
"returned",
"."
] | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L309-L321 |
123,590 | ryszard/goskiplist | skiplist/skiplist.go | Range | func (s *SkipList) Range(from, to interface{}) Iterator {
start := s.getPath(s.header, nil, from)
return &rangeIterator{
iter: iter{
current: &node{
forward: []*node{start},
backward: start,
},
list: s,
},
upperLimit: to,
lowerLimit: from,
}
} | go | func (s *SkipList) Range(from, to interface{}) Iterator {
start := s.getPath(s.header, nil, from)
return &rangeIterator{
iter: iter{
current: &node{
forward: []*node{start},
backward: start,
},
list: s,
},
upperLimit: to,
lowerLimit: from,
}
} | [
"func",
"(",
"s",
"*",
"SkipList",
")",
"Range",
"(",
"from",
",",
"to",
"interface",
"{",
"}",
")",
"Iterator",
"{",
"start",
":=",
"s",
".",
"getPath",
"(",
"s",
".",
"header",
",",
"nil",
",",
"from",
")",
"\n",
"return",
"&",
"rangeIterator",
... | // Range returns an iterator that will go through all the
// elements of the skip list that are greater or equal than from, but
// less than to. | [
"Range",
"returns",
"an",
"iterator",
"that",
"will",
"go",
"through",
"all",
"the",
"elements",
"of",
"the",
"skip",
"list",
"that",
"are",
"greater",
"or",
"equal",
"than",
"from",
"but",
"less",
"than",
"to",
"."
] | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L326-L339 |
123,591 | ryszard/goskiplist | skiplist/skiplist.go | randomLevel | func (s SkipList) randomLevel() (n int) {
for n = 0; n < s.effectiveMaxLevel() && rand.Float64() < p; n++ {
}
return
} | go | func (s SkipList) randomLevel() (n int) {
for n = 0; n < s.effectiveMaxLevel() && rand.Float64() < p; n++ {
}
return
} | [
"func",
"(",
"s",
"SkipList",
")",
"randomLevel",
"(",
")",
"(",
"n",
"int",
")",
"{",
"for",
"n",
"=",
"0",
";",
"n",
"<",
"s",
".",
"effectiveMaxLevel",
"(",
")",
"&&",
"rand",
".",
"Float64",
"(",
")",
"<",
"p",
";",
"n",
"++",
"{",
"}",
... | // Returns a new random level. | [
"Returns",
"a",
"new",
"random",
"level",
"."
] | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L357-L361 |
123,592 | ryszard/goskiplist | skiplist/skiplist.go | GetGreaterOrEqual | func (s *SkipList) GetGreaterOrEqual(min interface{}) (actualKey, value interface{}, ok bool) {
candidate := s.getPath(s.header, nil, min)
if candidate != nil {
return candidate.key, candidate.value, true
}
return nil, nil, false
} | go | func (s *SkipList) GetGreaterOrEqual(min interface{}) (actualKey, value interface{}, ok bool) {
candidate := s.getPath(s.header, nil, min)
if candidate != nil {
return candidate.key, candidate.value, true
}
return nil, nil, false
} | [
"func",
"(",
"s",
"*",
"SkipList",
")",
"GetGreaterOrEqual",
"(",
"min",
"interface",
"{",
"}",
")",
"(",
"actualKey",
",",
"value",
"interface",
"{",
"}",
",",
"ok",
"bool",
")",
"{",
"candidate",
":=",
"s",
".",
"getPath",
"(",
"s",
".",
"header",
... | // GetGreaterOrEqual finds the node whose key is greater than or equal
// to min. It returns its value, its actual key, and whether such a
// node is present in the skip list. | [
"GetGreaterOrEqual",
"finds",
"the",
"node",
"whose",
"key",
"is",
"greater",
"than",
"or",
"equal",
"to",
"min",
".",
"It",
"returns",
"its",
"value",
"its",
"actual",
"key",
"and",
"whether",
"such",
"a",
"node",
"is",
"present",
"in",
"the",
"skip",
"... | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L379-L386 |
123,593 | ryszard/goskiplist | skiplist/skiplist.go | Set | func (s *SkipList) Set(key, value interface{}) {
if key == nil {
panic("goskiplist: nil keys are not supported")
}
// s.level starts from 0, so we need to allocate one.
update := make([]*node, s.level()+1, s.effectiveMaxLevel()+1)
candidate := s.getPath(s.header, update, key)
if candidate != nil && candidate.k... | go | func (s *SkipList) Set(key, value interface{}) {
if key == nil {
panic("goskiplist: nil keys are not supported")
}
// s.level starts from 0, so we need to allocate one.
update := make([]*node, s.level()+1, s.effectiveMaxLevel()+1)
candidate := s.getPath(s.header, update, key)
if candidate != nil && candidate.k... | [
"func",
"(",
"s",
"*",
"SkipList",
")",
"Set",
"(",
"key",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"if",
"key",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"// s.level starts from 0, so we need to allocate one.",
"update",
":... | // Sets set the value associated with key in s. | [
"Sets",
"set",
"the",
"value",
"associated",
"with",
"key",
"in",
"s",
"."
] | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L408-L459 |
123,594 | ryszard/goskiplist | skiplist/skiplist.go | Delete | func (s *SkipList) Delete(key interface{}) (value interface{}, ok bool) {
if key == nil {
panic("goskiplist: nil keys are not supported")
}
update := make([]*node, s.level()+1, s.effectiveMaxLevel())
candidate := s.getPath(s.header, update, key)
if candidate == nil || candidate.key != key {
return nil, false
... | go | func (s *SkipList) Delete(key interface{}) (value interface{}, ok bool) {
if key == nil {
panic("goskiplist: nil keys are not supported")
}
update := make([]*node, s.level()+1, s.effectiveMaxLevel())
candidate := s.getPath(s.header, update, key)
if candidate == nil || candidate.key != key {
return nil, false
... | [
"func",
"(",
"s",
"*",
"SkipList",
")",
"Delete",
"(",
"key",
"interface",
"{",
"}",
")",
"(",
"value",
"interface",
"{",
"}",
",",
"ok",
"bool",
")",
"{",
"if",
"key",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"update",... | // Delete removes the node with the given key.
//
// It returns the old value and whether the node was present. | [
"Delete",
"removes",
"the",
"node",
"with",
"the",
"given",
"key",
".",
"It",
"returns",
"the",
"old",
"value",
"and",
"whether",
"the",
"node",
"was",
"present",
"."
] | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L464-L495 |
123,595 | ryszard/goskiplist | skiplist/skiplist.go | NewCustomMap | func NewCustomMap(lessThan func(l, r interface{}) bool) *SkipList {
return &SkipList{
lessThan: lessThan,
header: &node{
forward: []*node{nil},
},
MaxLevel: DefaultMaxLevel,
}
} | go | func NewCustomMap(lessThan func(l, r interface{}) bool) *SkipList {
return &SkipList{
lessThan: lessThan,
header: &node{
forward: []*node{nil},
},
MaxLevel: DefaultMaxLevel,
}
} | [
"func",
"NewCustomMap",
"(",
"lessThan",
"func",
"(",
"l",
",",
"r",
"interface",
"{",
"}",
")",
"bool",
")",
"*",
"SkipList",
"{",
"return",
"&",
"SkipList",
"{",
"lessThan",
":",
"lessThan",
",",
"header",
":",
"&",
"node",
"{",
"forward",
":",
"["... | // NewCustomMap returns a new SkipList that will use lessThan as the
// comparison function. lessThan should define a linear order on keys
// you intend to use with the SkipList. | [
"NewCustomMap",
"returns",
"a",
"new",
"SkipList",
"that",
"will",
"use",
"lessThan",
"as",
"the",
"comparison",
"function",
".",
"lessThan",
"should",
"define",
"a",
"linear",
"order",
"on",
"keys",
"you",
"intend",
"to",
"use",
"with",
"the",
"SkipList",
"... | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L500-L508 |
123,596 | ryszard/goskiplist | skiplist/skiplist.go | New | func New() *SkipList {
comparator := func(left, right interface{}) bool {
return left.(Ordered).LessThan(right.(Ordered))
}
return NewCustomMap(comparator)
} | go | func New() *SkipList {
comparator := func(left, right interface{}) bool {
return left.(Ordered).LessThan(right.(Ordered))
}
return NewCustomMap(comparator)
} | [
"func",
"New",
"(",
")",
"*",
"SkipList",
"{",
"comparator",
":=",
"func",
"(",
"left",
",",
"right",
"interface",
"{",
"}",
")",
"bool",
"{",
"return",
"left",
".",
"(",
"Ordered",
")",
".",
"LessThan",
"(",
"right",
".",
"(",
"Ordered",
")",
")",... | // New returns a new SkipList.
//
// Its keys must implement the Ordered interface. | [
"New",
"returns",
"a",
"new",
"SkipList",
".",
"Its",
"keys",
"must",
"implement",
"the",
"Ordered",
"interface",
"."
] | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L521-L527 |
123,597 | ryszard/goskiplist | skiplist/skiplist.go | NewIntMap | func NewIntMap() *SkipList {
return NewCustomMap(func(l, r interface{}) bool {
return l.(int) < r.(int)
})
} | go | func NewIntMap() *SkipList {
return NewCustomMap(func(l, r interface{}) bool {
return l.(int) < r.(int)
})
} | [
"func",
"NewIntMap",
"(",
")",
"*",
"SkipList",
"{",
"return",
"NewCustomMap",
"(",
"func",
"(",
"l",
",",
"r",
"interface",
"{",
"}",
")",
"bool",
"{",
"return",
"l",
".",
"(",
"int",
")",
"<",
"r",
".",
"(",
"int",
")",
"\n",
"}",
")",
"\n",
... | // NewIntKey returns a SkipList that accepts int keys. | [
"NewIntKey",
"returns",
"a",
"SkipList",
"that",
"accepts",
"int",
"keys",
"."
] | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L530-L534 |
123,598 | ryszard/goskiplist | skiplist/skiplist.go | NewStringMap | func NewStringMap() *SkipList {
return NewCustomMap(func(l, r interface{}) bool {
return l.(string) < r.(string)
})
} | go | func NewStringMap() *SkipList {
return NewCustomMap(func(l, r interface{}) bool {
return l.(string) < r.(string)
})
} | [
"func",
"NewStringMap",
"(",
")",
"*",
"SkipList",
"{",
"return",
"NewCustomMap",
"(",
"func",
"(",
"l",
",",
"r",
"interface",
"{",
"}",
")",
"bool",
"{",
"return",
"l",
".",
"(",
"string",
")",
"<",
"r",
".",
"(",
"string",
")",
"\n",
"}",
")",... | // NewStringMap returns a SkipList that accepts string keys. | [
"NewStringMap",
"returns",
"a",
"SkipList",
"that",
"accepts",
"string",
"keys",
"."
] | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L537-L541 |
123,599 | ryszard/goskiplist | skiplist/skiplist.go | NewSet | func NewSet() *Set {
comparator := func(left, right interface{}) bool {
return left.(Ordered).LessThan(right.(Ordered))
}
return NewCustomSet(comparator)
} | go | func NewSet() *Set {
comparator := func(left, right interface{}) bool {
return left.(Ordered).LessThan(right.(Ordered))
}
return NewCustomSet(comparator)
} | [
"func",
"NewSet",
"(",
")",
"*",
"Set",
"{",
"comparator",
":=",
"func",
"(",
"left",
",",
"right",
"interface",
"{",
"}",
")",
"bool",
"{",
"return",
"left",
".",
"(",
"Ordered",
")",
".",
"LessThan",
"(",
"right",
".",
"(",
"Ordered",
")",
")",
... | // NewSet returns a new Set. | [
"NewSet",
"returns",
"a",
"new",
"Set",
"."
] | 2dfbae5fcf46374f166f8969cb07e167f1be6273 | https://github.com/ryszard/goskiplist/blob/2dfbae5fcf46374f166f8969cb07e167f1be6273/skiplist/skiplist.go#L560-L565 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.