id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
listlengths 1
418
| pl_tokens
listlengths 22
4.98k
|
---|---|---|---|
20,300 | all-20301 | [
"Star",
"draws",
"many",
"lines",
"from",
"a",
"center",
"."
]
| [
"func",
"Star",
"(",
"gc",
"draw2d",
".",
"GraphicContext",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
"float64",
")",
"{",
"gc",
".",
"Save",
"(",
")",
"\n",
"gc",
".",
"Translate",
"(",
"x",
"+",
"width",
"/",
"2",
",",
"y",
"+",
"height",
"/",
"2",
")",
"\n",
"gc",
".",
"SetLineWidth",
"(",
"width",
"/",
"40",
")",
"\n",
"for",
"i",
":=",
"0.0",
";",
"i",
"<",
"360",
";",
"i",
"=",
"i",
"+",
"10",
"{",
"// Go from 0 to 360 degrees in 10 degree steps",
"gc",
".",
"Save",
"(",
")",
"// Keep rotations temporary",
"\n",
"gc",
".",
"Rotate",
"(",
"i",
"*",
"(",
"math",
".",
"Pi",
"/",
"180.0",
")",
")",
"// Rotate by degrees on stack from 'for'",
"\n",
"gc",
".",
"MoveTo",
"(",
"0",
",",
"0",
")",
"\n",
"gc",
".",
"LineTo",
"(",
"<mask>",
"/",
"2",
",",
"0",
")",
"\n",
"gc",
".",
"Stroke",
"(",
")",
"\n",
"gc",
".",
"Restore",
"(",
")",
"\n",
"}",
"\n",
"gc",
".",
"Restore",
"(",
")",
"\n",
"}"
]
|
20,301 | all-20302 | [
"getLastIndex",
"returns",
"the",
"last",
"index",
"in",
"stable",
"storage",
".",
"Either",
"from",
"the",
"last",
"log",
"or",
"from",
"the",
"last",
"snapshot",
"."
]
| [
"func",
"(",
"r",
"*",
"raftState",
")",
"getLastIndex",
"(",
")",
"uint64",
"{",
"r",
".",
"lastLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"lastLock",
".",
"Unlock",
"(",
")",
"\n",
"return",
"<mask>",
"(",
"r",
".",
"lastLogIndex",
",",
"r",
".",
"lastSnapshotIndex",
")",
"\n",
"}"
]
|
20,302 | all-20303 | [
"WithoutHeaders",
"hides",
"any",
"TChannel",
"headers",
"from",
"the",
"given",
"context",
"."
]
| [
"func",
"WithoutHeaders",
"(",
"ctx",
"context",
".",
"Context",
")",
"context",
".",
"Context",
"{",
"return",
"<mask>",
".",
"WithValue",
"(",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"contextKeyTChannel",
",",
"nil",
")",
",",
"contextKeyHeaders",
",",
"nil",
")",
"\n",
"}"
]
|
20,303 | all-20304 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"NavigationEntry",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage24",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
20,304 | all-20305 | [
"next",
"advances",
"the",
"generators",
"internal",
"state",
"to",
"the",
"next",
"value",
"and",
"returns",
"this",
"value",
"as",
"an",
"uint64",
"."
]
| [
"func",
"(",
"s",
"*",
"Xor64Source",
")",
"<mask>",
"(",
")",
"uint64",
"{",
"x",
":=",
"xor64",
"(",
"uint64",
"(",
"*",
"s",
")",
")",
"\n",
"*",
"s",
"=",
"Xor64Source",
"(",
"x",
")",
"\n",
"return",
"x",
"\n",
"}"
]
|
20,305 | all-20306 | [
"getOneSignature",
"downloads",
"one",
"signature",
"from",
"url",
".",
"If",
"it",
"successfully",
"determines",
"that",
"the",
"signature",
"does",
"not",
"exist",
"returns",
"with",
"missing",
"set",
"to",
"true",
"and",
"error",
"set",
"to",
"nil",
".",
"NOTE",
":",
"Keep",
"this",
"in",
"sync",
"with",
"docs",
"/",
"signature",
"-",
"protocols",
".",
"md!"
]
| [
"func",
"(",
"s",
"*",
"dockerImageSource",
")",
"getOneSignature",
"(",
"ctx",
"context",
".",
"Context",
",",
"url",
"*",
"url",
".",
"URL",
")",
"(",
"signature",
"[",
"]",
"byte",
",",
"missing",
"bool",
",",
"err",
"error",
")",
"{",
"switch",
"url",
".",
"Scheme",
"{",
"case",
"\"",
"\"",
":",
"logrus",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"url",
".",
"Path",
")",
"\n",
"sig",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"url",
".",
"Path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"return",
"nil",
",",
"true",
",",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
",",
"false",
",",
"err",
"\n",
"}",
"\n",
"return",
"sig",
",",
"false",
",",
"nil",
"\n\n",
"case",
"\"",
"\"",
",",
"\"",
"\"",
":",
"logrus",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"url",
")",
"\n",
"req",
",",
"err",
":=",
"<mask>",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"url",
".",
"String",
"(",
")",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"false",
",",
"err",
"\n",
"}",
"\n",
"req",
"=",
"req",
".",
"WithContext",
"(",
"ctx",
")",
"\n",
"res",
",",
"err",
":=",
"s",
".",
"c",
".",
"doHTTP",
"(",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"false",
",",
"err",
"\n",
"}",
"\n",
"defer",
"res",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"if",
"res",
".",
"StatusCode",
"==",
"http",
".",
"StatusNotFound",
"{",
"return",
"nil",
",",
"true",
",",
"nil",
"\n",
"}",
"else",
"if",
"res",
".",
"StatusCode",
"!=",
"http",
".",
"StatusOK",
"{",
"return",
"nil",
",",
"false",
",",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"url",
".",
"String",
"(",
")",
",",
"res",
".",
"StatusCode",
",",
"http",
".",
"StatusText",
"(",
"res",
".",
"StatusCode",
")",
")",
"\n",
"}",
"\n",
"sig",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"res",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"false",
",",
"err",
"\n",
"}",
"\n",
"return",
"sig",
",",
"false",
",",
"nil",
"\n\n",
"default",
":",
"return",
"nil",
",",
"false",
",",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"url",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n",
"}"
]
|
20,306 | all-20307 | [
"GetFileSize",
"-",
"gets",
"the",
"filesize",
"of",
"a",
"given",
"path"
]
| [
"func",
"GetFileSize",
"(",
"<mask>",
"string",
")",
"(",
"fileSize",
"int64",
")",
"{",
"var",
"(",
"fileInfo",
"os",
".",
"FileInfo",
"\n",
"err",
"error",
"\n",
"file",
"*",
"os",
".",
"File",
"\n",
")",
"\n\n",
"if",
"file",
",",
"err",
"=",
"os",
".",
"Open",
"(",
"filename",
")",
";",
"err",
"==",
"nil",
"{",
"fileInfo",
",",
"err",
"=",
"file",
".",
"Stat",
"(",
")",
"\n",
"fileSize",
"=",
"fileInfo",
".",
"Size",
"(",
")",
"\n\n",
"}",
"else",
"{",
"fileSize",
"=",
"-",
"1",
"\n",
"}",
"\n",
"return",
"\n",
"}"
]
|
20,307 | all-20308 | [
"GetStartOk",
"returns",
"a",
"tuple",
"with",
"the",
"Start",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"d",
"*",
"Downtime",
")",
"GetStartOk",
"(",
")",
"(",
"int",
",",
"bool",
")",
"{",
"if",
"d",
"==",
"nil",
"||",
"d",
".",
"Start",
"==",
"nil",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"d",
".",
"Start",
",",
"<mask>",
"\n",
"}"
]
|
20,308 | all-20309 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"CreateIsolatedWorldParams",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage73",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
]
|
20,309 | all-20310 | [
"authenticate",
"in",
"OpenStack",
"and",
"obtain",
"Designate",
"service",
"endpoint"
]
| [
"func",
"createDesignateServiceClient",
"(",
")",
"(",
"*",
"gophercloud",
".",
"ServiceClient",
",",
"error",
")",
"{",
"opts",
",",
"err",
":=",
"getAuthSettings",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"opts",
".",
"IdentityEndpoint",
")",
"\n",
"authProvider",
",",
"err",
":=",
"openstack",
".",
"NewClient",
"(",
"opts",
".",
"IdentityEndpoint",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"tlsConfig",
",",
"err",
":=",
"tlsutils",
".",
"CreateTLSConfig",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"transport",
":=",
"&",
"<mask>",
".",
"Transport",
"{",
"Proxy",
":",
"http",
".",
"ProxyFromEnvironment",
",",
"DialContext",
":",
"(",
"&",
"net",
".",
"Dialer",
"{",
"Timeout",
":",
"30",
"*",
"time",
".",
"Second",
",",
"KeepAlive",
":",
"30",
"*",
"time",
".",
"Second",
",",
"}",
")",
".",
"DialContext",
",",
"MaxIdleConns",
":",
"100",
",",
"IdleConnTimeout",
":",
"90",
"*",
"time",
".",
"Second",
",",
"TLSHandshakeTimeout",
":",
"10",
"*",
"time",
".",
"Second",
",",
"ExpectContinueTimeout",
":",
"1",
"*",
"time",
".",
"Second",
",",
"TLSClientConfig",
":",
"tlsConfig",
",",
"}",
"\n",
"authProvider",
".",
"HTTPClient",
".",
"Transport",
"=",
"transport",
"\n\n",
"if",
"err",
"=",
"openstack",
".",
"Authenticate",
"(",
"authProvider",
",",
"opts",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"eo",
":=",
"gophercloud",
".",
"EndpointOpts",
"{",
"Region",
":",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
",",
"}",
"\n\n",
"client",
",",
"err",
":=",
"openstack",
".",
"NewDNSV2",
"(",
"authProvider",
",",
"eo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"client",
".",
"Endpoint",
")",
"\n",
"return",
"client",
",",
"nil",
"\n",
"}"
]
|
20,310 | all-20311 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"WebSocketFrame",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoNetwork2",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"<mask>",
"(",
")",
"\n",
"}"
]
|
20,311 | all-20312 | [
"String",
"representation",
"."
]
| [
"func",
"(",
"na",
"*",
"NetAddress",
")",
"<mask>",
"(",
")",
"string",
"{",
"if",
"na",
".",
"str",
"==",
"\"",
"\"",
"{",
"na",
".",
"str",
"=",
"net",
".",
"JoinHostPort",
"(",
"na",
".",
"IP",
".",
"String",
"(",
")",
",",
"strconv",
".",
"FormatUint",
"(",
"uint64",
"(",
"na",
".",
"Port",
")",
",",
"10",
")",
",",
")",
"\n",
"}",
"\n",
"return",
"na",
".",
"str",
"\n",
"}"
]
|
20,312 | all-20313 | [
"AddRequestHandler",
"adds",
"a",
"request",
"handler",
"to",
"this",
"client",
".",
"A",
"request",
"handler",
"*",
"must",
"*",
"be",
"a",
"function",
"taking",
"a",
"single",
"argument",
"and",
"that",
"argument",
"*",
"must",
"*",
"be",
"a",
"pointer",
"to",
"a",
"recognized",
"ecsacs",
"struct",
".",
"E",
".",
"g",
".",
"if",
"you",
"desired",
"to",
"handle",
"messages",
"from",
"acs",
"of",
"type",
"FooMessage",
"you",
"would",
"pass",
"the",
"following",
"handler",
"in",
":",
"func",
"(",
"message",
"*",
"ecsacs",
".",
"FooMessage",
")",
"This",
"function",
"will",
"panic",
"if",
"the",
"passed",
"in",
"function",
"does",
"not",
"have",
"one",
"pointer",
"argument",
"or",
"the",
"argument",
"is",
"not",
"a",
"recognized",
"type",
".",
"Additionally",
"the",
"request",
"handler",
"will",
"block",
"processing",
"of",
"further",
"messages",
"on",
"this",
"connection",
"so",
"it",
"s",
"important",
"that",
"it",
"return",
"quickly",
"."
]
| [
"func",
"(",
"cs",
"*",
"ClientServerImpl",
")",
"AddRequestHandler",
"(",
"f",
"RequestHandler",
")",
"{",
"firstArg",
":=",
"reflect",
".",
"TypeOf",
"(",
"f",
")",
".",
"In",
"(",
"0",
")",
"\n",
"firstArgTypeStr",
":=",
"firstArg",
".",
"Elem",
"(",
")",
".",
"Name",
"(",
")",
"\n",
"recognizedTypes",
":=",
"cs",
".",
"GetRecognizedTypes",
"(",
")",
"\n",
"_",
",",
"ok",
":=",
"recognizedTypes",
"[",
"firstArgTypeStr",
"]",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"",
"\"",
"+",
"firstArgTypeStr",
")",
"\n",
"}",
"\n",
"<mask>",
".",
"RequestHandlers",
"[",
"firstArgTypeStr",
"]",
"=",
"f",
"\n",
"}"
]
|
20,313 | all-20314 | [
"NewFileSnapshotStore",
"creates",
"a",
"new",
"FileSnapshotStore",
"based",
"on",
"a",
"base",
"directory",
".",
"The",
"retain",
"parameter",
"controls",
"how",
"many",
"snapshots",
"are",
"retained",
".",
"Must",
"be",
"at",
"least",
"1",
"."
]
| [
"func",
"NewFileSnapshotStore",
"(",
"base",
"string",
",",
"retain",
"int",
",",
"logOutput",
"io",
".",
"Writer",
")",
"(",
"*",
"FileSnapshotStore",
",",
"error",
")",
"{",
"if",
"logOutput",
"==",
"nil",
"{",
"logOutput",
"=",
"<mask>",
".",
"Stderr",
"\n",
"}",
"\n",
"return",
"NewFileSnapshotStoreWithLogger",
"(",
"base",
",",
"retain",
",",
"log",
".",
"New",
"(",
"logOutput",
",",
"\"",
"\"",
",",
"log",
".",
"LstdFlags",
")",
")",
"\n",
"}"
]
|
20,314 | all-20315 | [
"This",
"method",
"is",
"DEPRICATED",
"and",
"subject",
"to",
"be",
"removed",
"in",
"next",
"version",
".",
"Use",
"Encrypt",
"(",
"..",
")",
"with",
"Zip",
"option",
"instead",
".",
"Compress",
"produces",
"encrypted",
"&",
"comressed",
"JWT",
"token",
"given",
"arbitrary",
"payload",
"key",
"management",
"encryption",
"and",
"compression",
"algorithms",
"to",
"use",
"(",
"see",
"constants",
"for",
"list",
"of",
"supported",
"algs",
")",
"and",
"management",
"key",
".",
"Management",
"key",
"is",
"of",
"different",
"type",
"for",
"different",
"key",
"management",
"alg",
"see",
"specific",
"key",
"management",
"alg",
"implementation",
"documentation",
".",
"It",
"returns",
"5",
"parts",
"encrypted",
"&",
"compressed",
"JWT",
"token",
"as",
"string",
"and",
"not",
"nil",
"error",
"if",
"something",
"went",
"wrong",
"."
]
| [
"func",
"Compress",
"(",
"payload",
"string",
",",
"alg",
"string",
",",
"enc",
"string",
",",
"zip",
"string",
",",
"<mask>",
"interface",
"{",
"}",
")",
"(",
"token",
"string",
",",
"err",
"error",
")",
"{",
"if",
"zipAlg",
",",
"ok",
":=",
"jwcCompressors",
"[",
"zip",
"]",
";",
"ok",
"{",
"compressed",
":=",
"zipAlg",
".",
"Compress",
"(",
"[",
"]",
"byte",
"(",
"payload",
")",
")",
"\n\n",
"jwtHeader",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"enc",
",",
"\"",
"\"",
":",
"alg",
",",
"\"",
"\"",
":",
"zip",
",",
"}",
"\n\n",
"return",
"encrypt",
"(",
"compressed",
",",
"jwtHeader",
",",
"key",
")",
"\n",
"}",
"\n\n",
"return",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"zip",
")",
")",
"\n",
"}"
]
|
20,315 | all-20316 | [
"GetCustomBgColorOk",
"returns",
"a",
"tuple",
"with",
"the",
"CustomBgColor",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"d",
"*",
"DashboardConditionalFormat",
")",
"GetCustomBgColorOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"d",
"==",
"nil",
"||",
"d",
".",
"CustomBgColor",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"d",
".",
"CustomBgColor",
",",
"<mask>",
"\n",
"}"
]
|
20,316 | all-20317 | [
"EnableColor",
"enables",
"color",
"output"
]
| [
"func",
"(",
"g",
"*",
"Glg",
")",
"EnableColor",
"(",
")",
"*",
"Glg",
"{",
"g",
".",
"logger",
".",
"Range",
"(",
"func",
"(",
"key",
",",
"val",
"interface",
"{",
"}",
")",
"bool",
"{",
"l",
":=",
"val",
".",
"(",
"*",
"logger",
")",
"\n",
"l",
".",
"isColor",
"=",
"true",
"\n",
"l",
".",
"updateMode",
"(",
")",
"\n",
"g",
".",
"logger",
".",
"<mask>",
"(",
"key",
".",
"(",
"LEVEL",
")",
",",
"l",
")",
"\n",
"return",
"true",
"\n",
"}",
")",
"\n\n",
"return",
"g",
"\n",
"}"
]
|
20,317 | all-20318 | [
"CreateContainer",
"requests",
"that",
"LXD",
"creates",
"a",
"new",
"container"
]
| [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"CreateContainer",
"(",
"container",
"api",
".",
"ContainersPost",
")",
"(",
"Operation",
",",
"error",
")",
"{",
"if",
"<mask>",
".",
"Source",
".",
"ContainerOnly",
"{",
"if",
"!",
"r",
".",
"HasExtension",
"(",
"\"",
"\"",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Send the request",
"op",
",",
"_",
",",
"err",
":=",
"r",
".",
"queryOperation",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"container",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"op",
",",
"nil",
"\n",
"}"
]
|
20,318 | all-20319 | [
"WriteUint32",
"writes",
"an",
"uint32",
"."
]
| [
"func",
"(",
"w",
"*",
"Writer",
")",
"WriteUint32",
"(",
"i",
"uint32",
")",
"{",
"if",
"w",
".",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"<mask>",
".",
"LittleEndian",
".",
"PutUint32",
"(",
"w",
".",
"b",
"[",
":",
"4",
"]",
",",
"i",
")",
"\n",
"w",
".",
"wr",
".",
"Write",
"(",
"w",
".",
"b",
"[",
":",
"4",
"]",
")",
"\n",
"}"
]
|
20,319 | all-20320 | [
"zfsIsEnabled",
"returns",
"whether",
"zfs",
"backend",
"is",
"supported",
"."
]
| [
"func",
"zfsIsEnabled",
"(",
")",
"bool",
"{",
"out",
",",
"err",
":=",
"exec",
".",
"LookPath",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"||",
"len",
"(",
"out",
")",
"==",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
]
|
20,320 | all-20321 | [
"FlushPeriod",
"sets",
"how",
"often",
"the",
"Client",
"s",
"buffer",
"is",
"flushed",
".",
"If",
"p",
"is",
"0",
"the",
"goroutine",
"that",
"periodically",
"flush",
"the",
"buffer",
"is",
"not",
"lauched",
"and",
"the",
"buffer",
"is",
"only",
"flushed",
"when",
"it",
"is",
"full",
".",
"By",
"default",
"the",
"flush",
"period",
"is",
"100",
"ms",
".",
"This",
"option",
"is",
"ignored",
"in",
"Client",
".",
"Clone",
"()",
"."
]
| [
"func",
"FlushPeriod",
"(",
"p",
"<mask>",
".",
"Duration",
")",
"Option",
"{",
"return",
"Option",
"(",
"func",
"(",
"c",
"*",
"config",
")",
"{",
"c",
".",
"Conn",
".",
"FlushPeriod",
"=",
"p",
"\n",
"}",
")",
"\n",
"}"
]
|
20,321 | all-20322 | [
"CreateResourceGroup",
"creates",
"a",
"Resource",
"Group",
"if",
"not",
"exists"
]
| [
"func",
"(",
"a",
"AzureClient",
")",
"CreateResourceGroup",
"(",
"name",
",",
"location",
"string",
")",
"error",
"{",
"if",
"ok",
",",
"err",
":=",
"a",
".",
"resourceGroupExists",
"(",
"name",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"else",
"if",
"ok",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"name",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"log",
".",
"Info",
"(",
"\"",
"\"",
",",
"logutil",
".",
"Fields",
"{",
"\"",
"\"",
":",
"name",
",",
"\"",
"\"",
":",
"location",
"}",
")",
"\n",
"_",
",",
"err",
":=",
"a",
".",
"resourceGroupsClient",
"(",
")",
".",
"CreateOrUpdate",
"(",
"name",
",",
"resources",
".",
"ResourceGroup",
"{",
"<mask>",
":",
"to",
".",
"StringPtr",
"(",
"location",
")",
",",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
]
|
20,322 | all-20323 | [
"Stop",
"Mason"
]
| [
"func",
"(",
"m",
"*",
"Mason",
")",
"Stop",
"(",
")",
"{",
"logrus",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"m",
".",
"cancel",
"(",
")",
"\n",
"m",
".",
"wg",
".",
"Wait",
"(",
")",
"\n",
"close",
"(",
"m",
".",
"pending",
")",
"\n",
"close",
"(",
"m",
".",
"cleaned",
")",
"\n",
"<mask>",
"(",
"m",
".",
"fulfilled",
")",
"\n",
"m",
".",
"client",
".",
"ReleaseAll",
"(",
"common",
".",
"Dirty",
")",
"\n",
"logrus",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"}"
]
|
20,323 | all-20324 | [
"Failed",
"checks",
"if",
"the",
"task",
"has",
"failed"
]
| [
"func",
"(",
"t",
"*",
"T",
")",
"Failed",
"(",
")",
"bool",
"{",
"t",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"t",
".",
"<mask>",
"\n",
"}"
]
|
20,324 | all-20325 | [
"SetPath",
"sets",
"cookie",
"path",
"."
]
| [
"func",
"(",
"c",
"*",
"Cookie",
")",
"SetPath",
"(",
"path",
"string",
")",
"{",
"c",
".",
"buf",
"=",
"append",
"(",
"c",
".",
"buf",
"[",
":",
"0",
"]",
",",
"path",
"...",
")",
"\n",
"c",
".",
"<mask>",
"=",
"normalizePath",
"(",
"c",
".",
"path",
",",
"c",
".",
"buf",
")",
"\n",
"}"
]
|
20,325 | all-20326 | [
"ListenAndServe",
"starts",
"the",
"Neptulon",
"server",
".",
"This",
"function",
"blocks",
"until",
"server",
"is",
"closed",
"."
]
| [
"func",
"(",
"s",
"*",
"Server",
")",
"ListenAndServe",
"(",
")",
"error",
"{",
"mux",
":=",
"http",
".",
"NewServeMux",
"(",
")",
"\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"websocket",
".",
"Server",
"{",
"Config",
":",
"s",
".",
"wsConfig",
",",
"<mask>",
":",
"s",
".",
"wsConnHandler",
",",
"Handshake",
":",
"func",
"(",
"config",
"*",
"websocket",
".",
"Config",
",",
"req",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"s",
".",
"wg",
".",
"Add",
"(",
"1",
")",
"// todo: this needs to happen inside the gorotune executing the Start method and not the request goroutine or we'll miss some edge connections",
"\n",
"config",
".",
"Origin",
",",
"_",
"=",
"url",
".",
"Parse",
"(",
"req",
".",
"RemoteAddr",
")",
"// we're interested in remote address and not origin header text",
"\n",
"return",
"nil",
"\n",
"}",
",",
"}",
")",
"\n\n",
"l",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"s",
".",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"s",
".",
"addr",
",",
"err",
")",
"\n",
"}",
"\n",
"s",
".",
"listener",
"=",
"l",
"\n\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"s",
".",
"addr",
")",
"\n",
"s",
".",
"running",
".",
"Store",
"(",
"true",
")",
"\n",
"err",
"=",
"http",
".",
"Serve",
"(",
"l",
",",
"mux",
")",
"\n",
"if",
"!",
"s",
".",
"running",
".",
"Load",
"(",
")",
".",
"(",
"bool",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
]
|
20,326 | all-20327 | [
"Seek",
"is",
"implementation",
"of",
"ReadSeekCloser",
"s",
"Seek",
"."
]
| [
"func",
"(",
"i",
"*",
"InfiniteLoop",
")",
"Seek",
"(",
"<mask>",
"int64",
",",
"whence",
"int",
")",
"(",
"int64",
",",
"error",
")",
"{",
"if",
"err",
":=",
"i",
".",
"ensurePos",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"next",
":=",
"int64",
"(",
"0",
")",
"\n",
"switch",
"whence",
"{",
"case",
"io",
".",
"SeekStart",
":",
"next",
"=",
"offset",
"\n",
"case",
"io",
".",
"SeekCurrent",
":",
"next",
"=",
"i",
".",
"pos",
"+",
"offset",
"\n",
"case",
"io",
".",
"SeekEnd",
":",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"next",
"<",
"0",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"next",
">=",
"i",
".",
"lstart",
"{",
"next",
"=",
"(",
"(",
"next",
"-",
"i",
".",
"lstart",
")",
"%",
"i",
".",
"llength",
")",
"+",
"i",
".",
"lstart",
"\n",
"}",
"\n",
"// Ignore the new position returned by Seek since the source position might not be match with the position",
"// managed by this.",
"if",
"_",
",",
"err",
":=",
"i",
".",
"src",
".",
"Seek",
"(",
"next",
",",
"io",
".",
"SeekStart",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"i",
".",
"pos",
"=",
"next",
"\n",
"return",
"i",
".",
"pos",
",",
"nil",
"\n",
"}"
]
|
20,327 | all-20328 | [
"handleAddSubscription",
"adds",
"a",
"Subscription",
"for",
"a",
"particular",
"topic",
".",
"If",
"it",
"is",
"the",
"first",
"Subscription",
"for",
"the",
"topic",
"it",
"will",
"announce",
"that",
"this",
"node",
"subscribes",
"to",
"the",
"topic",
".",
"Only",
"called",
"from",
"processLoop",
"."
]
| [
"func",
"(",
"p",
"*",
"PubSub",
")",
"handleAddSubscription",
"(",
"req",
"*",
"addSubReq",
")",
"{",
"sub",
":=",
"req",
".",
"sub",
"\n",
"subs",
":=",
"p",
".",
"myTopics",
"[",
"sub",
".",
"topic",
"]",
"\n\n",
"// announce we want this topic",
"if",
"len",
"(",
"subs",
")",
"==",
"0",
"{",
"p",
".",
"announce",
"(",
"sub",
".",
"topic",
",",
"true",
")",
"\n",
"p",
".",
"rt",
".",
"Join",
"(",
"sub",
".",
"topic",
")",
"\n",
"}",
"\n\n",
"// make new if not there",
"if",
"subs",
"==",
"nil",
"{",
"p",
".",
"myTopics",
"[",
"sub",
".",
"topic",
"]",
"=",
"<mask>",
"(",
"map",
"[",
"*",
"Subscription",
"]",
"struct",
"{",
"}",
")",
"\n",
"subs",
"=",
"p",
".",
"myTopics",
"[",
"sub",
".",
"topic",
"]",
"\n",
"}",
"\n\n",
"sub",
".",
"ch",
"=",
"make",
"(",
"chan",
"*",
"Message",
",",
"32",
")",
"\n",
"sub",
".",
"cancelCh",
"=",
"p",
".",
"cancelCh",
"\n\n",
"p",
".",
"myTopics",
"[",
"sub",
".",
"topic",
"]",
"[",
"sub",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n\n",
"req",
".",
"resp",
"<-",
"sub",
"\n",
"}"
]
|
20,328 | all-20329 | [
"NewSession",
"creates",
"a",
"new",
"Session",
"object"
]
| [
"func",
"NewSession",
"(",
"ctx",
"context",
".",
"<mask>",
",",
"config",
"*",
"config",
".",
"Config",
",",
"deregisterInstanceEventStream",
"*",
"eventstream",
".",
"EventStream",
",",
"containerInstanceArn",
"string",
",",
"credentialsProvider",
"*",
"credentials",
".",
"Credentials",
",",
"ecsClient",
"api",
".",
"ECSClient",
",",
"taskEngineState",
"dockerstate",
".",
"TaskEngineState",
",",
"stateManager",
"statemanager",
".",
"StateManager",
",",
"taskEngine",
"engine",
".",
"TaskEngine",
",",
"credentialsManager",
"rolecredentials",
".",
"Manager",
",",
"taskHandler",
"*",
"eventhandler",
".",
"TaskHandler",
")",
"Session",
"{",
"resources",
":=",
"newSessionResources",
"(",
"credentialsProvider",
")",
"\n",
"backoff",
":=",
"retry",
".",
"NewExponentialBackoff",
"(",
"connectionBackoffMin",
",",
"connectionBackoffMax",
",",
"connectionBackoffJitter",
",",
"connectionBackoffMultiplier",
")",
"\n",
"derivedContext",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"ctx",
")",
"\n\n",
"return",
"&",
"session",
"{",
"agentConfig",
":",
"config",
",",
"deregisterInstanceEventStream",
":",
"deregisterInstanceEventStream",
",",
"containerInstanceARN",
":",
"containerInstanceArn",
",",
"credentialsProvider",
":",
"credentialsProvider",
",",
"ecsClient",
":",
"ecsClient",
",",
"state",
":",
"taskEngineState",
",",
"stateManager",
":",
"stateManager",
",",
"taskEngine",
":",
"taskEngine",
",",
"credentialsManager",
":",
"credentialsManager",
",",
"taskHandler",
":",
"taskHandler",
",",
"ctx",
":",
"derivedContext",
",",
"cancel",
":",
"cancel",
",",
"backoff",
":",
"backoff",
",",
"resources",
":",
"resources",
",",
"_heartbeatTimeout",
":",
"heartbeatTimeout",
",",
"_heartbeatJitter",
":",
"heartbeatJitter",
",",
"_inactiveInstanceReconnectDelay",
":",
"inactiveInstanceReconnectDelay",
",",
"}",
"\n",
"}"
]
|
20,329 | all-20330 | [
"DeepCopyInto",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"writing",
"into",
"out",
".",
"in",
"must",
"be",
"non",
"-",
"nil",
"."
]
| [
"func",
"(",
"in",
"*",
"DNSEndpoint",
")",
"DeepCopyInto",
"(",
"out",
"*",
"DNSEndpoint",
")",
"{",
"*",
"out",
"=",
"*",
"in",
"\n",
"<mask>",
".",
"TypeMeta",
"=",
"in",
".",
"TypeMeta",
"\n",
"in",
".",
"ObjectMeta",
".",
"DeepCopyInto",
"(",
"&",
"out",
".",
"ObjectMeta",
")",
"\n",
"in",
".",
"Spec",
".",
"DeepCopyInto",
"(",
"&",
"out",
".",
"Spec",
")",
"\n",
"out",
".",
"Status",
"=",
"in",
".",
"Status",
"\n",
"return",
"\n",
"}"
]
|
20,330 | all-20331 | [
"Generic",
"function",
"for",
"snapshots",
"use",
"map",
"[",
"string",
"]",
"string",
"to",
"create",
"url",
".",
"Values",
"()",
"instead",
"of",
"pre",
"-",
"defined",
"params"
]
| [
"func",
"(",
"<mask>",
"*",
"Client",
")",
"SnapshotGeneric",
"(",
"options",
"map",
"[",
"string",
"]",
"string",
",",
"start",
",",
"end",
"time",
".",
"Time",
")",
"(",
"string",
",",
"error",
")",
"{",
"v",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"v",
".",
"Add",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"start",
".",
"Unix",
"(",
")",
")",
")",
"\n",
"v",
".",
"Add",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"end",
".",
"Unix",
"(",
")",
")",
")",
"\n\n",
"for",
"opt",
",",
"val",
":=",
"range",
"options",
"{",
"v",
".",
"Add",
"(",
"opt",
",",
"val",
")",
"\n",
"}",
"\n\n",
"return",
"client",
".",
"doSnapshotRequest",
"(",
"v",
")",
"\n",
"}"
]
|
20,331 | all-20332 | [
"UpdateOffer",
"updates",
"an",
"existing",
"offer"
]
| [
"func",
"UpdateOffer",
"(",
"rate",
"Rate",
",",
"amount",
"Amount",
",",
"offerID",
"OfferID",
")",
"(",
"result",
"ManageOfferBuilder",
")",
"{",
"return",
"ManageOffer",
"(",
"<mask>",
",",
"rate",
",",
"amount",
",",
"offerID",
")",
"\n",
"}"
]
|
20,332 | all-20333 | [
"DelaySvcNotification",
"creates",
"a",
"new",
"DELAY_SVC_NOTIFICATION",
"Nagios",
"command",
".",
"Delays",
"the",
"next",
"notification",
"for",
"a",
"parciular",
"service",
"until",
"notification_time",
".",
"The",
"notification_time",
"argument",
"is",
"specified",
"in",
"time_t",
"format",
"(",
"seconds",
"since",
"the",
"UNIX",
"epoch",
")",
".",
"Note",
"that",
"this",
"will",
"only",
"have",
"an",
"affect",
"if",
"the",
"service",
"stays",
"in",
"the",
"same",
"problem",
"state",
"that",
"it",
"is",
"currently",
"in",
".",
"If",
"the",
"service",
"changes",
"to",
"another",
"state",
"a",
"new",
"notification",
"may",
"go",
"out",
"before",
"the",
"time",
"you",
"specify",
"in",
"the",
"notification_time",
"argument",
"."
]
| [
"func",
"DelaySvcNotification",
"(",
"host_name",
"string",
",",
"service_description",
"string",
",",
"notification_time",
"<mask>",
".",
"Time",
",",
")",
"*",
"livestatus",
".",
"Command",
"{",
"return",
"livestatus",
".",
"NewCommand",
"(",
"\"",
"\"",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"host_name",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"service_description",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"notification_time",
")",
",",
")",
"\n",
"}"
]
|
20,333 | all-20334 | [
"checkError",
"is",
"called",
"before",
"waiting",
"on",
"the",
"mex",
"channels",
".",
"It",
"returns",
"any",
"existing",
"errors",
"(",
"timeout",
"cancellation",
"connection",
"errors",
")",
"."
]
| [
"func",
"(",
"mex",
"*",
"messageExchange",
")",
"checkError",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"mex",
".",
"ctx",
".",
"Err",
"(",
")",
";",
"<mask>",
"!=",
"nil",
"{",
"return",
"GetContextError",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"mex",
".",
"errCh",
".",
"checkErr",
"(",
")",
"\n",
"}"
]
|
20,334 | all-20335 | [
"GenerateReceiveAddress",
"generates",
"and",
"returns",
"a",
"new",
"bitcoin",
"receive",
"address"
]
| [
"func",
"(",
"c",
"Client",
")",
"GenerateReceiveAddress",
"(",
"params",
"*",
"AddressParams",
")",
"(",
"string",
",",
"error",
")",
"{",
"holder",
":=",
"map",
"[",
"string",
"]",
"<mask>",
"{",
"}",
"{",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"Post",
"(",
"\"",
"\"",
",",
"params",
",",
"&",
"holder",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"holder",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
",",
"nil",
"\n",
"}"
]
|
20,335 | all-20336 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"GetPlaybackRateReturns",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoAnimation9",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
]
|
20,336 | all-20337 | [
"Errorf",
"is",
"a",
"sentinel",
"option",
"to",
"set",
"a",
"error",
"logger",
"."
]
| [
"func",
"Errorf",
"(",
"f",
"func",
"(",
"string",
",",
"...",
"<mask>",
"{",
"}",
")",
")",
"Option",
"{",
"return",
"func",
"(",
"s",
"*",
"Sentinel",
")",
"error",
"{",
"s",
".",
"errf",
"=",
"f",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
]
|
20,337 | all-20338 | [
"/",
"*",
"get",
"a",
"uid",
"or",
"gid",
"mapping",
"from",
"/",
"proc",
"/",
"self",
"/",
"{",
"g",
"u",
"}",
"id_map"
]
| [
"func",
"getFromProc",
"(",
"fname",
"string",
")",
"(",
"[",
"]",
"[",
"]",
"int64",
",",
"error",
")",
"{",
"entries",
":=",
"[",
"]",
"[",
"]",
"int64",
"{",
"}",
"\n\n",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"fname",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"f",
".",
"Close",
"(",
")",
"\n\n",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"f",
")",
"\n",
"for",
"scanner",
".",
"Scan",
"(",
")",
"{",
"// Skip comments",
"s",
":=",
"strings",
".",
"Split",
"(",
"scanner",
".",
"Text",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"s",
"[",
"0",
"]",
")",
"==",
"0",
"{",
"continue",
"\n",
"}",
"\n\n",
"// Validate format",
"s",
"=",
"strings",
".",
"Fields",
"(",
"s",
"[",
"0",
"]",
")",
"\n",
"if",
"len",
"(",
"s",
")",
"<",
"3",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"fname",
",",
"s",
")",
"\n",
"}",
"\n\n",
"// Get range start",
"entryStart",
",",
"err",
":=",
"strconv",
".",
"ParseUint",
"(",
"s",
"[",
"0",
"]",
",",
"10",
",",
"32",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"continue",
"\n",
"}",
"\n\n",
"// Get range size",
"entryHost",
",",
"err",
":=",
"strconv",
".",
"ParseUint",
"(",
"s",
"[",
"1",
"]",
",",
"10",
",",
"32",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"continue",
"\n",
"}",
"\n\n",
"// Get range size",
"entrySize",
",",
"err",
":=",
"strconv",
".",
"ParseUint",
"(",
"s",
"[",
"2",
"]",
",",
"10",
",",
"32",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"<mask>",
"\n",
"}",
"\n\n",
"entries",
"=",
"append",
"(",
"entries",
",",
"[",
"]",
"int64",
"{",
"int64",
"(",
"entryStart",
")",
",",
"int64",
"(",
"entryHost",
")",
",",
"int64",
"(",
"entrySize",
")",
"}",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"entries",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"entries",
",",
"nil",
"\n",
"}"
]
|
20,338 | all-20339 | [
"Update",
"updates",
"the",
"uint32",
"in",
"the",
"buffer"
]
| [
"func",
"(",
"<mask>",
"Uint32Ref",
")",
"Update",
"(",
"n",
"uint32",
")",
"{",
"if",
"ref",
"!=",
"nil",
"{",
"binary",
".",
"BigEndian",
".",
"PutUint32",
"(",
"ref",
",",
"n",
")",
"\n",
"}",
"\n",
"}"
]
|
20,339 | all-20340 | [
"Sync",
"upgrades",
"a",
"given",
"HTTP",
"connection",
"into",
"a",
"velox",
"connection",
"and",
"synchronises",
"the",
"provided",
"struct",
"with",
"the",
"client",
".",
"velox",
"takes",
"responsibility",
"for",
"writing",
"the",
"response",
"in",
"the",
"event",
"of",
"failure",
".",
"Default",
"handlers",
"close",
"the",
"TCP",
"connection",
"on",
"return",
"so",
"when",
"manually",
"using",
"this",
"method",
"you",
"ll",
"most",
"likely",
"want",
"to",
"block",
"using",
"Conn",
".",
"Wait",
"()",
"."
]
| [
"func",
"Sync",
"(",
"gostruct",
"interface",
"{",
"}",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"Conn",
",",
"error",
")",
"{",
"//access gostruct.State via interfaces:",
"gosyncable",
",",
"ok",
":=",
"gostruct",
".",
"(",
"syncer",
")",
"\n",
"if",
"!",
"<mask>",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"//extract internal state from gostruct",
"state",
",",
"err",
":=",
"gosyncable",
".",
"sync",
"(",
"gostruct",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"version",
":=",
"int64",
"(",
"0",
")",
"\n",
"//matching id, allow user to pick version",
"if",
"id",
":=",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
";",
"id",
"!=",
"\"",
"\"",
"&&",
"id",
"==",
"state",
".",
"data",
".",
"id",
"{",
"if",
"v",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
",",
"10",
",",
"64",
")",
";",
"err",
"==",
"nil",
"&&",
"v",
">",
"0",
"{",
"version",
"=",
"v",
"\n",
"}",
"\n",
"}",
"\n",
"//set initial connection state",
"conn",
":=",
"newConn",
"(",
"atomic",
".",
"AddInt64",
"(",
"&",
"connectionID",
",",
"1",
")",
",",
"r",
".",
"RemoteAddr",
",",
"state",
",",
"version",
")",
"\n",
"//attempt connection over transport",
"//(negotiate websockets / start eventsource emitter)",
"//return when connected",
"if",
"err",
":=",
"conn",
".",
"connect",
"(",
"w",
",",
"r",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"//hand over to state to keep in sync",
"state",
".",
"subscribe",
"(",
"conn",
")",
"\n",
"//do an initial push only to this client",
"conn",
".",
"Push",
"(",
")",
"\n",
"//pass connection to user",
"return",
"conn",
",",
"nil",
"\n",
"}"
]
|
20,340 | all-20341 | [
"matchPrefix",
"reports",
"whether",
"any",
"selector",
"in",
"the",
"fieldTree",
"matches",
"the",
"start",
"of",
"path",
"p",
"."
]
| [
"func",
"(",
"ft",
"fieldTree",
")",
"matchPrefix",
"(",
"p",
"cmp",
".",
"Path",
")",
"bool",
"{",
"for",
"_",
",",
"ps",
":=",
"range",
"p",
"{",
"switch",
"ps",
":=",
"ps",
".",
"(",
"type",
")",
"{",
"case",
"cmp",
".",
"StructField",
":",
"ft",
"=",
"ft",
".",
"sub",
"[",
"ps",
".",
"Name",
"(",
")",
"]",
"\n",
"if",
"ft",
".",
"ok",
"{",
"return",
"true",
"\n",
"}",
"\n",
"if",
"len",
"(",
"ft",
".",
"<mask>",
")",
"==",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n",
"case",
"cmp",
".",
"Indirect",
":",
"default",
":",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
]
|
20,341 | all-20342 | [
"Now",
"indicates",
"an",
"expected",
"call",
"of",
"Now"
]
| [
"func",
"(",
"mr",
"*",
"MockTimeMockRecorder",
")",
"Now",
"(",
")",
"*",
"gomock",
".",
"Call",
"{",
"<mask>",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
".",
"TypeOf",
"(",
"(",
"*",
"MockTime",
")",
"(",
"nil",
")",
".",
"Now",
")",
")",
"\n",
"}"
]
|
20,342 | all-20343 | [
"Msg",
"sends",
"a",
"message",
"to",
"who",
"(",
"user",
"or",
"channel",
")"
]
| [
"func",
"(",
"bot",
"*",
"Bot",
")",
"Msg",
"(",
"who",
",",
"text",
"string",
")",
"{",
"for",
"len",
"(",
"text",
")",
">",
"400",
"{",
"bot",
".",
"Send",
"(",
"\"",
"\"",
"+",
"who",
"+",
"\"",
"\"",
"+",
"<mask>",
"[",
":",
"400",
"]",
")",
"\n",
"text",
"=",
"text",
"[",
"400",
":",
"]",
"\n",
"}",
"\n",
"bot",
".",
"Send",
"(",
"\"",
"\"",
"+",
"who",
"+",
"\"",
"\"",
"+",
"text",
")",
"\n",
"}"
]
|
20,343 | all-20344 | [
"GetContainerSnapshotNames",
"returns",
"a",
"list",
"of",
"snapshot",
"names",
"for",
"the",
"container"
]
| [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"GetContainerSnapshotNames",
"(",
"containerName",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"urls",
":=",
"[",
"]",
"string",
"{",
"}",
"\n\n",
"// Fetch the raw value",
"_",
",",
"err",
":=",
"r",
".",
"queryStruct",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"url",
".",
"QueryEscape",
"(",
"containerName",
")",
")",
",",
"nil",
",",
"\"",
"\"",
",",
"&",
"urls",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Parse it",
"names",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"uri",
":=",
"range",
"urls",
"{",
"fields",
":=",
"strings",
".",
"Split",
"(",
"uri",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"url",
".",
"QueryEscape",
"(",
"containerName",
")",
")",
")",
"\n",
"names",
"=",
"append",
"(",
"names",
",",
"<mask>",
"[",
"len",
"(",
"fields",
")",
"-",
"1",
"]",
")",
"\n",
"}",
"\n\n",
"return",
"names",
",",
"nil",
"\n",
"}"
]
|
20,344 | all-20345 | [
"NewStreamEncoder",
"returns",
"a",
"new",
"stream",
"encoder",
"that",
"outputs",
"to",
"e",
".",
"The",
"function",
"panics",
"if",
"e",
"is",
"nil",
"."
]
| [
"func",
"NewStreamEncoder",
"(",
"e",
"Emitter",
")",
"*",
"StreamEncoder",
"{",
"if",
"e",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"<mask>",
"&",
"StreamEncoder",
"{",
"Emitter",
":",
"e",
"}",
"\n",
"}"
]
|
20,345 | all-20346 | [
"Creates",
"an",
"LRUCache",
"with",
"maximum",
"size",
"ttl",
"for",
"items",
"."
]
| [
"func",
"NewLRUCache",
"(",
"size",
"int",
",",
"ttl",
"time",
".",
"Duration",
")",
"Cache",
"{",
"lru",
":=",
"&",
"lruCache",
"{",
"<mask>",
":",
"size",
",",
"ttl",
":",
"ttl",
",",
"cache",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"entry",
")",
",",
"evictList",
":",
"list",
".",
"New",
"(",
")",
",",
"}",
"\n",
"return",
"lru",
"\n",
"}"
]
|
20,346 | all-20347 | [
"GetIconTooltipText",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_entry_get_icon_tooltip_text",
"()",
"."
]
| [
"func",
"(",
"v",
"*",
"<mask>",
")",
"GetIconTooltipText",
"(",
"iconPos",
"EntryIconPosition",
")",
"(",
"string",
",",
"error",
")",
"{",
"c",
":=",
"C",
".",
"gtk_entry_get_icon_tooltip_text",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"GtkEntryIconPosition",
"(",
"iconPos",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"return",
"goString",
"(",
"c",
")",
",",
"nil",
"\n",
"}"
]
|
20,347 | all-20348 | [
"startEtcd",
"runs",
"StartEtcd",
"in",
"addition",
"to",
"hooks",
"needed",
"for",
"standalone",
"etcd",
"."
]
| [
"func",
"startEtcd",
"(",
"cfg",
"*",
"embed",
".",
"Config",
")",
"(",
"<-",
"chan",
"struct",
"{",
"}",
",",
"<-",
"chan",
"error",
",",
"error",
")",
"{",
"e",
",",
"err",
":=",
"embed",
".",
"StartEtcd",
"(",
"cfg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"osutil",
".",
"RegisterInterruptHandler",
"(",
"e",
".",
"Close",
")",
"\n",
"<mask>",
"{",
"case",
"<-",
"e",
".",
"Server",
".",
"ReadyNotify",
"(",
")",
":",
"// wait for e.Server to join the cluster",
"case",
"<-",
"e",
".",
"Server",
".",
"StopNotify",
"(",
")",
":",
"// publish aborted from 'ErrStopped'",
"}",
"\n",
"return",
"e",
".",
"Server",
".",
"StopNotify",
"(",
")",
",",
"e",
".",
"Err",
"(",
")",
",",
"nil",
"\n",
"}"
]
|
20,348 | all-20349 | [
"LogoutAll",
"removes",
"all",
"established",
"authentication",
"credentials",
"for",
"the",
"session",
"."
]
| [
"func",
"(",
"s",
"*",
"Session",
")",
"LogoutAll",
"(",
")",
"{",
"s",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"for",
"_",
",",
"cred",
":=",
"range",
"s",
".",
"creds",
"{",
"if",
"s",
".",
"masterSocket",
"!=",
"nil",
"{",
"s",
".",
"masterSocket",
".",
"Logout",
"(",
"cred",
".",
"<mask>",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"slaveSocket",
"!=",
"nil",
"{",
"s",
".",
"slaveSocket",
".",
"Logout",
"(",
"cred",
".",
"Source",
")",
"\n",
"}",
"\n",
"}",
"\n",
"s",
".",
"creds",
"=",
"s",
".",
"creds",
"[",
"0",
":",
"0",
"]",
"\n",
"s",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"}"
]
|
20,349 | all-20350 | [
"ContainerUpdate",
"updates",
"the",
"description",
"architecture",
"and",
"ephemeral",
"flag",
"of",
"the",
"container",
"with",
"the",
"given",
"ID",
"."
]
| [
"func",
"ContainerUpdate",
"(",
"tx",
"*",
"sql",
".",
"Tx",
",",
"id",
"int",
",",
"description",
"string",
",",
"architecture",
"int",
",",
"ephemeral",
"bool",
",",
"expiryDate",
"time",
".",
"Time",
")",
"error",
"{",
"str",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
")",
"\n",
"stmt",
",",
"err",
":=",
"tx",
".",
"Prepare",
"(",
"str",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"stmt",
".",
"Close",
"(",
")",
"\n\n",
"ephemeralInt",
":=",
"0",
"\n",
"if",
"ephemeral",
"{",
"ephemeralInt",
"=",
"1",
"\n",
"}",
"\n\n",
"if",
"expiryDate",
".",
"IsZero",
"(",
")",
"{",
"_",
",",
"err",
"=",
"stmt",
".",
"Exec",
"(",
"description",
",",
"architecture",
",",
"ephemeralInt",
",",
"\"",
"\"",
",",
"id",
")",
"\n",
"}",
"else",
"{",
"_",
",",
"err",
"=",
"stmt",
".",
"Exec",
"(",
"<mask>",
",",
"architecture",
",",
"ephemeralInt",
",",
"expiryDate",
",",
"id",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
20,350 | all-20351 | [
"Cookie",
"returns",
"cookie",
"representation",
".",
"The",
"returned",
"value",
"is",
"valid",
"until",
"the",
"next",
"call",
"to",
"Cookie",
"methods",
"."
]
| [
"func",
"(",
"c",
"*",
"Cookie",
")",
"Cookie",
"(",
")",
"[",
"]",
"<mask>",
"{",
"c",
".",
"buf",
"=",
"c",
".",
"AppendBytes",
"(",
"c",
".",
"buf",
"[",
":",
"0",
"]",
")",
"\n",
"return",
"c",
".",
"buf",
"\n",
"}"
]
|
20,351 | all-20352 | [
"FromFile",
"reads",
"the",
"configuration",
"file",
"at",
"the",
"given",
"path",
"and",
"returns",
"a",
"new",
"Config",
"struct",
"with",
"the",
"data",
"populated",
"."
]
| [
"func",
"FromFile",
"(",
"path",
"string",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
"+",
"path",
")",
"\n",
"}",
"\n\n",
"config",
",",
"err",
":=",
"Parse",
"(",
"string",
"(",
"c",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
"+",
"<mask>",
")",
"\n",
"}",
"\n",
"return",
"config",
",",
"nil",
"\n",
"}"
]
|
20,352 | all-20353 | [
"failRelayItem",
"tombs",
"the",
"relay",
"item",
"so",
"that",
"future",
"frames",
"for",
"this",
"call",
"are",
"not",
"forwarded",
".",
"We",
"keep",
"the",
"relay",
"item",
"tombed",
"rather",
"than",
"delete",
"it",
"to",
"ensure",
"that",
"future",
"frames",
"do",
"not",
"cause",
"error",
"logs",
"."
]
| [
"func",
"(",
"r",
"*",
"Relayer",
")",
"failRelayItem",
"(",
"items",
"*",
"relayItems",
",",
"id",
"uint32",
",",
"failure",
"string",
")",
"{",
"item",
",",
"ok",
":=",
"items",
".",
"Get",
"(",
"id",
")",
"\n",
"if",
"!",
"ok",
"{",
"items",
".",
"logger",
".",
"WithFields",
"(",
"LogField",
"{",
"\"",
"\"",
",",
"id",
"}",
")",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"// The call could time-out right as we entomb it, which would cause spurious",
"// error logs, so ensure we can stop the timeout.",
"if",
"!",
"item",
".",
"timeout",
".",
"Stop",
"(",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"// Entomb it so that we don't get unknown exchange errors on further frames",
"// for this call.",
"item",
",",
"ok",
"=",
"items",
".",
"Entomb",
"(",
"id",
",",
"_relayTombTTL",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\n",
"}",
"\n",
"if",
"item",
".",
"call",
"!=",
"nil",
"{",
"// If the client is too slow, then there's no point sending an error frame.",
"if",
"failure",
"!=",
"_relayErrorSourceConnSlow",
"{",
"r",
".",
"conn",
".",
"SendSystemError",
"(",
"id",
",",
"item",
".",
"span",
",",
"errFrameNotSent",
")",
"\n",
"}",
"\n",
"item",
".",
"call",
".",
"Failed",
"(",
"failure",
")",
"\n",
"<mask>",
".",
"call",
".",
"End",
"(",
")",
"\n",
"}",
"\n\n",
"r",
".",
"decrementPending",
"(",
")",
"\n",
"}"
]
|
20,353 | all-20354 | [
"NewLogEntry",
"creates",
"a",
"new",
"LogEntry",
"for",
"the",
"request",
"."
]
| [
"func",
"(",
"l",
"*",
"DefaultLogFormatter",
")",
"NewLogEntry",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"LogEntry",
"{",
"useColor",
":=",
"!",
"l",
".",
"NoColor",
"\n",
"entry",
":=",
"&",
"defaultLogEntry",
"{",
"DefaultLogFormatter",
":",
"l",
",",
"request",
":",
"r",
",",
"buf",
":",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
",",
"useColor",
":",
"useColor",
",",
"}",
"\n\n",
"reqID",
":=",
"GetReqID",
"(",
"r",
".",
"Context",
"(",
")",
")",
"\n",
"if",
"reqID",
"!=",
"\"",
"\"",
"{",
"cW",
"(",
"entry",
".",
"buf",
",",
"useColor",
",",
"nYellow",
",",
"\"",
"\"",
",",
"reqID",
")",
"\n",
"}",
"\n",
"cW",
"(",
"<mask>",
".",
"buf",
",",
"useColor",
",",
"nCyan",
",",
"\"",
"\\\"",
"\"",
")",
"\n",
"cW",
"(",
"entry",
".",
"buf",
",",
"useColor",
",",
"bMagenta",
",",
"\"",
"\"",
",",
"r",
".",
"Method",
")",
"\n\n",
"scheme",
":=",
"\"",
"\"",
"\n",
"if",
"r",
".",
"TLS",
"!=",
"nil",
"{",
"scheme",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"cW",
"(",
"entry",
".",
"buf",
",",
"useColor",
",",
"nCyan",
",",
"\"",
"\\\"",
"\"",
",",
"scheme",
",",
"r",
".",
"Host",
",",
"r",
".",
"RequestURI",
",",
"r",
".",
"Proto",
")",
"\n\n",
"entry",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"entry",
".",
"buf",
".",
"WriteString",
"(",
"r",
".",
"RemoteAddr",
")",
"\n",
"entry",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n\n",
"return",
"entry",
"\n",
"}"
]
|
20,354 | all-20355 | [
"/",
"*",
"GetApps",
"gets",
"all",
"app",
"names"
]
| [
"func",
"(",
"a",
"*",
"Client",
")",
"GetApps",
"(",
"params",
"*",
"GetAppsParams",
")",
"(",
"*",
"GetAppsOK",
",",
"error",
")",
"{",
"// TODO: Validate the params before sending",
"if",
"params",
"==",
"nil",
"{",
"params",
"=",
"NewGetAppsParams",
"(",
")",
"\n",
"}",
"\n\n",
"result",
",",
"err",
":=",
"a",
".",
"transport",
".",
"Submit",
"(",
"&",
"runtime",
".",
"ClientOperation",
"{",
"<mask>",
":",
"\"",
"\"",
",",
"Method",
":",
"\"",
"\"",
",",
"PathPattern",
":",
"\"",
"\"",
",",
"ProducesMediaTypes",
":",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
",",
"ConsumesMediaTypes",
":",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
",",
"Schemes",
":",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"Params",
":",
"params",
",",
"Reader",
":",
"&",
"GetAppsReader",
"{",
"formats",
":",
"a",
".",
"formats",
"}",
",",
"Context",
":",
"params",
".",
"Context",
",",
"Client",
":",
"params",
".",
"HTTPClient",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"result",
".",
"(",
"*",
"GetAppsOK",
")",
",",
"nil",
"\n\n",
"}"
]
|
20,355 | all-20356 | [
"If",
"the",
"connection",
"is",
"successful",
"it",
"will",
"end",
"up",
"in",
"the",
"local",
"peer",
"s",
"connections",
"map",
"."
]
| [
"func",
"startLocalConnection",
"(",
"connRemote",
"*",
"remoteConnection",
",",
"tcpConn",
"*",
"net",
".",
"TCPConn",
",",
"router",
"*",
"Router",
",",
"acceptNewPeer",
"bool",
",",
"logger",
"Logger",
")",
"{",
"if",
"connRemote",
".",
"local",
"!=",
"router",
".",
"Ourself",
".",
"Peer",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"errorChan",
":=",
"make",
"(",
"chan",
"error",
",",
"1",
")",
"\n",
"finished",
":=",
"<mask>",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"conn",
":=",
"&",
"LocalConnection",
"{",
"remoteConnection",
":",
"*",
"connRemote",
",",
"// NB, we're taking a copy of connRemote here.",
"router",
":",
"router",
",",
"tcpConn",
":",
"tcpConn",
",",
"trustRemote",
":",
"router",
".",
"trusts",
"(",
"connRemote",
")",
",",
"uid",
":",
"randUint64",
"(",
")",
",",
"errorChan",
":",
"errorChan",
",",
"finished",
":",
"finished",
",",
"logger",
":",
"logger",
",",
"}",
"\n",
"conn",
".",
"senders",
"=",
"newGossipSenders",
"(",
"conn",
",",
"finished",
")",
"\n",
"go",
"conn",
".",
"run",
"(",
"errorChan",
",",
"finished",
",",
"acceptNewPeer",
")",
"\n",
"}"
]
|
20,356 | all-20357 | [
"ValidEnum",
"validates",
"a",
"proposed",
"value",
"for",
"this",
"enum",
".",
"Implements",
"the",
"Enum",
"interface",
"for",
"CreateAccountResultCode"
]
| [
"func",
"(",
"e",
"CreateAccountResultCode",
")",
"ValidEnum",
"(",
"v",
"int32",
")",
"bool",
"{",
"_",
",",
"<mask>",
":=",
"createAccountResultCodeMap",
"[",
"v",
"]",
"\n",
"return",
"ok",
"\n",
"}"
]
|
20,357 | all-20358 | [
"NewJournalWriter",
"wraps",
"io",
".",
"Writer",
"to",
"redirect",
"log",
"output",
"to",
"the",
"local",
"systemd",
"journal",
".",
"If",
"journald",
"send",
"fails",
"it",
"fails",
"back",
"to",
"writing",
"to",
"the",
"original",
"writer",
".",
"The",
"decode",
"overhead",
"is",
"only",
"<30µs",
"per",
"write",
".",
"Reference",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"coreos",
"/",
"pkg",
"/",
"blob",
"/",
"master",
"/",
"capnslog",
"/",
"journald_formatter",
".",
"go"
]
| [
"func",
"NewJournalWriter",
"(",
"wr",
"<mask>",
".",
"Writer",
")",
"(",
"io",
".",
"Writer",
",",
"error",
")",
"{",
"return",
"&",
"journalWriter",
"{",
"Writer",
":",
"wr",
"}",
",",
"systemd",
".",
"DialJournal",
"(",
")",
"\n",
"}"
]
|
20,358 | all-20359 | [
"GetFile",
"returns",
"the",
"contents",
"of",
"a",
"file",
"at",
"a",
"specific",
"Commit",
".",
"offset",
"specifies",
"a",
"number",
"of",
"bytes",
"that",
"should",
"be",
"skipped",
"in",
"the",
"beginning",
"of",
"the",
"file",
".",
"size",
"limits",
"the",
"total",
"amount",
"of",
"data",
"returned",
"note",
"you",
"will",
"get",
"fewer",
"bytes",
"than",
"size",
"if",
"you",
"pass",
"a",
"value",
"larger",
"than",
"the",
"size",
"of",
"the",
"file",
".",
"If",
"size",
"is",
"set",
"to",
"0",
"then",
"all",
"of",
"the",
"data",
"will",
"be",
"returned",
"."
]
| [
"func",
"(",
"c",
"APIClient",
")",
"GetFile",
"(",
"repoName",
"string",
",",
"commitID",
"string",
",",
"path",
"string",
",",
"offset",
"int64",
",",
"size",
"int64",
",",
"writer",
"io",
".",
"Writer",
")",
"error",
"{",
"if",
"c",
".",
"limiter",
"!=",
"nil",
"{",
"c",
".",
"limiter",
".",
"Acquire",
"(",
")",
"\n",
"defer",
"c",
".",
"limiter",
".",
"Release",
"(",
")",
"\n",
"}",
"\n",
"apiGetFileClient",
",",
"err",
":=",
"c",
".",
"getFile",
"(",
"repoName",
",",
"commitID",
",",
"path",
",",
"offset",
",",
"size",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"grpcutil",
".",
"WriteFromStreamingBytesClient",
"(",
"apiGetFileClient",
",",
"<mask>",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
20,359 | all-20360 | [
"RetryAuthClient",
"implements",
"a",
"AuthClient",
"."
]
| [
"func",
"RetryAuthClient",
"(",
"c",
"*",
"Client",
")",
"pb",
".",
"AuthClient",
"{",
"return",
"&",
"retryAuthClient",
"{",
"ac",
":",
"pb",
".",
"NewAuthClient",
"(",
"c",
".",
"<mask>",
")",
",",
"}",
"\n",
"}"
]
|
20,360 | all-20361 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"ContinueToLocationParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoDebugger47",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
20,361 | all-20362 | [
"UnmarshalJSON",
"implements",
"the",
"json",
".",
"Unmarshaler",
"interface",
"."
]
| [
"func",
"(",
"pr",
"*",
"prSignedBy",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"*",
"pr",
"=",
"prSignedBy",
"{",
"}",
"\n",
"var",
"tmp",
"prSignedBy",
"\n",
"var",
"gotKeyPath",
",",
"gotKeyData",
"=",
"false",
",",
"false",
"\n",
"var",
"signedIdentity",
"json",
".",
"RawMessage",
"\n",
"if",
"err",
":=",
"paranoidUnmarshalJSONObject",
"(",
"data",
",",
"func",
"(",
"key",
"string",
")",
"interface",
"{",
"}",
"{",
"switch",
"key",
"{",
"case",
"\"",
"\"",
":",
"return",
"&",
"tmp",
".",
"Type",
"\n",
"case",
"\"",
"\"",
":",
"return",
"&",
"tmp",
".",
"KeyType",
"\n",
"case",
"\"",
"\"",
":",
"gotKeyPath",
"=",
"true",
"\n",
"return",
"&",
"tmp",
".",
"KeyPath",
"\n",
"case",
"\"",
"\"",
":",
"gotKeyData",
"=",
"true",
"\n",
"return",
"&",
"tmp",
".",
"KeyData",
"\n",
"case",
"\"",
"\"",
":",
"return",
"&",
"signedIdentity",
"\n",
"default",
":",
"return",
"nil",
"\n",
"}",
"\n",
"}",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"tmp",
".",
"Type",
"!=",
"prTypeSignedBy",
"{",
"return",
"InvalidPolicyFormatError",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"tmp",
".",
"Type",
")",
")",
"\n",
"}",
"\n",
"if",
"signedIdentity",
"==",
"nil",
"{",
"tmp",
".",
"SignedIdentity",
"=",
"NewPRMMatchRepoDigestOrExact",
"(",
")",
"\n",
"}",
"else",
"{",
"si",
",",
"err",
":=",
"newPolicyReferenceMatchFromJSON",
"(",
"signedIdentity",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"tmp",
".",
"SignedIdentity",
"=",
"si",
"\n",
"}",
"\n\n",
"var",
"res",
"*",
"prSignedBy",
"\n",
"var",
"err",
"error",
"\n",
"switch",
"{",
"case",
"gotKeyPath",
"&&",
"gotKeyData",
":",
"return",
"InvalidPolicyFormatError",
"(",
"\"",
"\"",
")",
"\n",
"case",
"gotKeyPath",
"&&",
"!",
"gotKeyData",
":",
"res",
",",
"err",
"=",
"newPRSignedByKeyPath",
"(",
"tmp",
".",
"KeyType",
",",
"tmp",
".",
"KeyPath",
",",
"tmp",
".",
"SignedIdentity",
")",
"\n",
"case",
"!",
"gotKeyPath",
"&&",
"gotKeyData",
":",
"res",
",",
"err",
"=",
"newPRSignedByKeyData",
"(",
"tmp",
".",
"KeyType",
",",
"tmp",
".",
"KeyData",
",",
"tmp",
".",
"SignedIdentity",
")",
"\n",
"case",
"!",
"gotKeyPath",
"&&",
"!",
"gotKeyData",
":",
"return",
"InvalidPolicyFormatError",
"(",
"\"",
"\"",
")",
"\n",
"default",
":",
"// Coverage: This should never happen",
"return",
"<mask>",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"*",
"pr",
"=",
"*",
"res",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
20,362 | all-20363 | [
"NewPatternRadial",
"is",
"a",
"wrapper",
"around",
"cairo_pattern_create_radial",
"()",
"."
]
| [
"func",
"NewPatternRadial",
"(",
"x0",
",",
"y0",
",",
"r0",
",",
"x1",
",",
"y1",
",",
"r1",
"float64",
")",
"(",
"*",
"<mask>",
",",
"error",
")",
"{",
"c",
":=",
"C",
".",
"cairo_pattern_create_radial",
"(",
"C",
".",
"double",
"(",
"x0",
")",
",",
"C",
".",
"double",
"(",
"y0",
")",
",",
"C",
".",
"double",
"(",
"r0",
")",
",",
"C",
".",
"double",
"(",
"x1",
")",
",",
"C",
".",
"double",
"(",
"y1",
")",
",",
"C",
".",
"double",
"(",
"r1",
")",
")",
"\n",
"return",
"newPatternFromNative",
"(",
"c",
")",
"\n",
"}"
]
|
20,363 | all-20364 | [
"Add",
"indicates",
"an",
"expected",
"call",
"of",
"Add"
]
| [
"func",
"(",
"mr",
"*",
"MockCgroupMockRecorder",
")",
"Add",
"(",
"arg0",
"<mask>",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
".",
"TypeOf",
"(",
"(",
"*",
"MockCgroup",
")",
"(",
"nil",
")",
".",
"Add",
")",
",",
"arg0",
")",
"\n",
"}"
]
|
20,364 | all-20365 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"GetResponseBodyForInterceptionParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork31",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
20,365 | all-20366 | [
"SendPayload",
"发送消息"
]
| [
"func",
"(",
"w",
"*",
"Webhook",
")",
"SendPayload",
"(",
"payload",
"*",
"Payload",
")",
"error",
"{",
"bs",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"payload",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"resp",
",",
"err",
":=",
"http",
".",
"Post",
"(",
"\"",
"\"",
"+",
"w",
".",
"accessToken",
",",
"\"",
"\"",
",",
"<mask>",
".",
"NewReader",
"(",
"bs",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"bs",
",",
"err",
"=",
"ioutil",
".",
"ReadAll",
"(",
"resp",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"resp",
".",
"StatusCode",
"!=",
"200",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"resp",
".",
"StatusCode",
",",
"string",
"(",
"bs",
")",
")",
"\n",
"}",
"\n\n",
"var",
"result",
"Response",
"\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"bs",
",",
"&",
"result",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"result",
".",
"ErrorCode",
"!=",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"result",
".",
"ErrorCode",
",",
"result",
".",
"ErrorMessage",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
20,366 | all-20367 | [
"WaitStartup",
"blocks",
"current",
"thread",
"until",
"current",
"container",
"begins",
"to",
"listen",
"exposed",
"port",
"."
]
| [
"func",
"(",
"s",
"*",
"Container",
")",
"WaitStartup",
"(",
"timeout",
"time",
".",
"Duration",
")",
"error",
"{",
"nodes",
",",
"err",
":=",
"s",
".",
"NetworkNodes",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"s",
".",
"HasExposedPorts",
"(",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"<mask>",
":=",
"raiqub",
".",
"WaitPeerListening",
"(",
"nodes",
"[",
"0",
"]",
".",
"Protocol",
",",
"nodes",
"[",
"0",
"]",
".",
"FormatDialAddress",
"(",
")",
",",
"timeout",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"nodes",
"[",
"0",
"]",
".",
"FormatDialAddress",
"(",
")",
",",
"timeout",
")",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}"
]
|
20,367 | all-20368 | [
"Do",
"performs",
"the",
"given",
"http",
"request",
"and",
"sets",
"the",
"corresponding",
"response",
".",
"Request",
"must",
"contain",
"at",
"least",
"non",
"-",
"zero",
"RequestURI",
"with",
"full",
"url",
"(",
"including",
"scheme",
"and",
"host",
")",
"or",
"non",
"-",
"zero",
"Host",
"header",
"+",
"RequestURI",
".",
"The",
"function",
"doesn",
"t",
"follow",
"redirects",
".",
"Use",
"Get",
"*",
"for",
"following",
"redirects",
".",
"Response",
"is",
"ignored",
"if",
"resp",
"is",
"nil",
".",
"It",
"is",
"recommended",
"obtaining",
"req",
"and",
"resp",
"via",
"AcquireRequest",
"and",
"AcquireResponse",
"in",
"performance",
"-",
"critical",
"code",
"."
]
| [
"func",
"(",
"c",
"*",
"PipelineClient",
")",
"Do",
"(",
"req",
"*",
"Request",
",",
"resp",
"*",
"<mask>",
")",
"error",
"{",
"return",
"c",
".",
"getConnClient",
"(",
")",
".",
"Do",
"(",
"req",
",",
"resp",
")",
"\n",
"}"
]
|
20,368 | all-20369 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"FrameResource",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage47",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
]
|
20,369 | all-20370 | [
"HasResource",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"s",
"*",
"ScreenboardLite",
")",
"HasResource",
"(",
")",
"bool",
"{",
"if",
"s",
"!=",
"nil",
"&&",
"s",
".",
"Resource",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
]
|
20,370 | all-20371 | [
"PeerNameFromUserInput",
"parses",
"PeerName",
"from",
"a",
"user",
"-",
"provided",
"string",
"."
]
| [
"func",
"PeerNameFromUserInput",
"(",
"userInput",
"string",
")",
"(",
"PeerName",
",",
"error",
")",
"{",
"// fixed-length identity",
"nameByteAry",
":=",
"sha256",
".",
"Sum256",
"(",
"[",
"]",
"<mask>",
"(",
"userInput",
")",
")",
"\n",
"return",
"PeerNameFromBin",
"(",
"nameByteAry",
"[",
":",
"NameSize",
"]",
")",
",",
"nil",
"\n",
"}"
]
|
20,371 | all-20372 | [
"GetStatsdIntervalOk",
"returns",
"a",
"tuple",
"with",
"the",
"StatsdInterval",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"m",
"*",
"MetricMetadata",
")",
"GetStatsdIntervalOk",
"(",
")",
"(",
"int",
",",
"bool",
")",
"{",
"if",
"m",
"==",
"nil",
"||",
"m",
".",
"StatsdInterval",
"==",
"nil",
"{",
"return",
"0",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"m",
".",
"StatsdInterval",
",",
"true",
"\n",
"}"
]
|
20,372 | all-20373 | [
"return",
"a",
"compressed",
"texture",
"image"
]
| [
"func",
"GetCompressedTexImage",
"(",
"target",
"uint32",
",",
"<mask>",
"int32",
",",
"img",
"unsafe",
".",
"Pointer",
")",
"{",
"syscall",
".",
"Syscall",
"(",
"gpGetCompressedTexImage",
",",
"3",
",",
"uintptr",
"(",
"target",
")",
",",
"uintptr",
"(",
"level",
")",
",",
"uintptr",
"(",
"img",
")",
")",
"\n",
"}"
]
|
20,373 | all-20374 | [
"PutFileHeaderFooter",
"implements",
"the",
"HashTree",
"PutFileHeaderFooter",
"method"
]
| [
"func",
"(",
"h",
"*",
"dbHashTree",
")",
"PutFileHeaderFooter",
"(",
"path",
"string",
",",
"objects",
"[",
"]",
"*",
"pfs",
".",
"Object",
",",
"<mask>",
"int64",
")",
"error",
"{",
"return",
"h",
".",
"putFile",
"(",
"path",
",",
"objects",
",",
"nil",
",",
"size",
",",
"true",
")",
"\n",
"}"
]
|
20,374 | all-20375 | [
"bind",
"a",
"framebuffer",
"to",
"a",
"framebuffer",
"target"
]
| [
"func",
"BindFramebuffer",
"(",
"target",
"uint32",
",",
"framebuffer",
"uint32",
")",
"{",
"C",
".",
"glowBindFramebuffer",
"(",
"gpBindFramebuffer",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"<mask>",
")",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"framebuffer",
")",
")",
"\n",
"}"
]
|
20,375 | all-20376 | [
"UnmarshalEasyJSON",
"satisfies",
"easyjson",
".",
"Unmarshaler",
"."
]
| [
"func",
"(",
"t",
"*",
"CaptureSnapshotFormat",
")",
"UnmarshalEasyJSON",
"(",
"in",
"*",
"jlexer",
".",
"Lexer",
")",
"{",
"switch",
"CaptureSnapshotFormat",
"(",
"in",
".",
"String",
"(",
")",
")",
"{",
"<mask>",
"CaptureSnapshotFormatMhtml",
":",
"*",
"t",
"=",
"CaptureSnapshotFormatMhtml",
"\n\n",
"default",
":",
"in",
".",
"AddError",
"(",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"}"
]
|
20,376 | all-20377 | [
"Call",
"the",
"parent",
"CloseNotify",
".",
"Provided",
"in",
"order",
"to",
"implement",
"the",
"http",
".",
"CloseNotifier",
"interface",
"."
]
| [
"func",
"(",
"w",
"*",
"recorderResponseWriter",
")",
"CloseNotify",
"(",
")",
"<-",
"chan",
"bool",
"{",
"notifier",
":=",
"w",
".",
"ResponseWriter",
".",
"(",
"<mask>",
".",
"CloseNotifier",
")",
"\n",
"return",
"notifier",
".",
"CloseNotify",
"(",
")",
"\n",
"}"
]
|
20,377 | all-20378 | [
"Records",
"returns",
"the",
"current",
"records",
"from",
"the",
"registry",
"excluding",
"TXT",
"Records",
"If",
"TXT",
"records",
"was",
"created",
"previously",
"to",
"indicate",
"ownership",
"its",
"corresponding",
"value",
"will",
"be",
"added",
"to",
"the",
"endpoints",
"Labels",
"map"
]
| [
"func",
"(",
"im",
"*",
"TXTRegistry",
")",
"Records",
"(",
")",
"(",
"[",
"]",
"*",
"endpoint",
".",
"Endpoint",
",",
"error",
")",
"{",
"// If we have the zones cached AND we have refreshed the cache since the",
"// last given interval, then just use the cached results.",
"if",
"im",
".",
"recordsCache",
"!=",
"nil",
"&&",
"time",
".",
"Since",
"(",
"im",
".",
"recordsCacheRefreshTime",
")",
"<",
"im",
".",
"cacheInterval",
"{",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"im",
".",
"recordsCache",
",",
"nil",
"\n",
"}",
"\n\n",
"records",
",",
"err",
":=",
"im",
".",
"provider",
".",
"Records",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"endpoints",
":=",
"[",
"]",
"*",
"endpoint",
".",
"Endpoint",
"{",
"}",
"\n\n",
"labelMap",
":=",
"map",
"[",
"string",
"]",
"endpoint",
".",
"Labels",
"{",
"}",
"\n\n",
"for",
"_",
",",
"record",
":=",
"range",
"records",
"{",
"if",
"<mask>",
".",
"RecordType",
"!=",
"endpoint",
".",
"RecordTypeTXT",
"{",
"endpoints",
"=",
"append",
"(",
"endpoints",
",",
"record",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"// We simply assume that TXT records for the registry will always have only one target.",
"labels",
",",
"err",
":=",
"endpoint",
".",
"NewLabelsFromString",
"(",
"record",
".",
"Targets",
"[",
"0",
"]",
")",
"\n",
"if",
"err",
"==",
"endpoint",
".",
"ErrInvalidHeritage",
"{",
"//if no heritage is found or it is invalid",
"//case when value of txt record cannot be identified",
"//record will not be removed as it will have empty owner",
"endpoints",
"=",
"append",
"(",
"endpoints",
",",
"record",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"endpointDNSName",
":=",
"im",
".",
"mapper",
".",
"toEndpointName",
"(",
"record",
".",
"DNSName",
")",
"\n",
"labelMap",
"[",
"endpointDNSName",
"]",
"=",
"labels",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"ep",
":=",
"range",
"endpoints",
"{",
"ep",
".",
"Labels",
"=",
"endpoint",
".",
"NewLabels",
"(",
")",
"\n",
"if",
"labels",
",",
"ok",
":=",
"labelMap",
"[",
"ep",
".",
"DNSName",
"]",
";",
"ok",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"labels",
"{",
"ep",
".",
"Labels",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Update the cache.",
"if",
"im",
".",
"cacheInterval",
">",
"0",
"{",
"im",
".",
"recordsCache",
"=",
"endpoints",
"\n",
"im",
".",
"recordsCacheRefreshTime",
"=",
"time",
".",
"Now",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"endpoints",
",",
"nil",
"\n",
"}"
]
|
20,378 | all-20379 | [
"ChangeSvcCheckCommand",
"creates",
"a",
"new",
"CHANGE_SVC_CHECK_COMMAND",
"Nagios",
"command",
".",
"Changes",
"the",
"check",
"command",
"for",
"a",
"particular",
"service",
"to",
"be",
"that",
"specified",
"by",
"the",
"check_command",
"option",
".",
"The",
"check_command",
"option",
"specifies",
"the",
"short",
"name",
"of",
"the",
"command",
"that",
"should",
"be",
"used",
"as",
"the",
"new",
"service",
"check",
"command",
".",
"The",
"command",
"must",
"have",
"been",
"configured",
"in",
"Nagios",
"before",
"it",
"was",
"last",
"(",
"re",
")",
"started",
"."
]
| [
"func",
"ChangeSvcCheckCommand",
"(",
"host_name",
"<mask>",
",",
"service_description",
"string",
",",
"check_command",
"string",
",",
")",
"*",
"livestatus",
".",
"Command",
"{",
"return",
"livestatus",
".",
"NewCommand",
"(",
"\"",
"\"",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"host_name",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"service_description",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"check_command",
")",
",",
")",
"\n",
"}"
]
|
20,379 | all-20380 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"HAR",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoHar9",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
20,380 | all-20381 | [
"GetInstanceMetrics",
"gets",
"all",
"task",
"metrics",
"and",
"instance",
"metadata",
"from",
"stats",
"engine",
"."
]
| [
"func",
"(",
"engine",
"*",
"DockerStatsEngine",
")",
"GetInstanceMetrics",
"(",
")",
"(",
"*",
"ecstcs",
".",
"MetricsMetadata",
",",
"[",
"]",
"*",
"ecstcs",
".",
"TaskMetric",
",",
"error",
")",
"{",
"var",
"taskMetrics",
"[",
"]",
"*",
"ecstcs",
".",
"TaskMetric",
"\n",
"idle",
":=",
"engine",
".",
"isIdle",
"(",
")",
"\n",
"metricsMetadata",
":=",
"&",
"ecstcs",
".",
"MetricsMetadata",
"{",
"Cluster",
":",
"aws",
".",
"String",
"(",
"engine",
".",
"cluster",
")",
",",
"ContainerInstance",
":",
"aws",
".",
"String",
"(",
"engine",
".",
"containerInstanceArn",
")",
",",
"Idle",
":",
"aws",
".",
"Bool",
"(",
"idle",
")",
",",
"MessageId",
":",
"aws",
".",
"String",
"(",
"uuid",
".",
"NewRandom",
"(",
")",
".",
"String",
"(",
")",
")",
",",
"}",
"\n\n",
"if",
"idle",
"{",
"seelog",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"fin",
":=",
"true",
"\n",
"metricsMetadata",
".",
"Fin",
"=",
"&",
"fin",
"\n",
"return",
"metricsMetadata",
",",
"taskMetrics",
",",
"nil",
"\n",
"}",
"\n\n",
"engine",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"engine",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"taskArn",
":=",
"<mask>",
"engine",
".",
"tasksToContainers",
"{",
"containerMetrics",
",",
"err",
":=",
"engine",
".",
"taskContainerMetricsUnsafe",
"(",
"taskArn",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"seelog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"taskArn",
",",
"err",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"containerMetrics",
")",
"==",
"0",
"{",
"seelog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"taskArn",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"taskDef",
",",
"exists",
":=",
"engine",
".",
"tasksToDefinitions",
"[",
"taskArn",
"]",
"\n",
"if",
"!",
"exists",
"{",
"seelog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"taskArn",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"metricTaskArn",
":=",
"taskArn",
"\n",
"taskMetric",
":=",
"&",
"ecstcs",
".",
"TaskMetric",
"{",
"TaskArn",
":",
"&",
"metricTaskArn",
",",
"TaskDefinitionFamily",
":",
"&",
"taskDef",
".",
"family",
",",
"TaskDefinitionVersion",
":",
"&",
"taskDef",
".",
"version",
",",
"ContainerMetrics",
":",
"containerMetrics",
",",
"}",
"\n",
"taskMetrics",
"=",
"append",
"(",
"taskMetrics",
",",
"taskMetric",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"taskMetrics",
")",
"==",
"0",
"{",
"// Not idle. Expect taskMetrics to be there.",
"return",
"nil",
",",
"nil",
",",
"EmptyMetricsError",
"\n",
"}",
"\n\n",
"// Reset current stats. Retaining older stats results in incorrect utilization stats",
"// until they are removed from the queue.",
"engine",
".",
"resetStatsUnsafe",
"(",
")",
"\n",
"return",
"metricsMetadata",
",",
"taskMetrics",
",",
"nil",
"\n",
"}"
]
|
20,381 | all-20382 | [
"remove",
"removes",
"img",
"from",
"the",
"images",
"."
]
| [
"func",
"(",
"i",
"*",
"<mask>",
")",
"remove",
"(",
"img",
"*",
"Image",
")",
"{",
"i",
".",
"makeStaleIfDependingOnImpl",
"(",
"img",
")",
"\n",
"delete",
"(",
"i",
".",
"images",
",",
"img",
")",
"\n",
"}"
]
|
20,382 | all-20383 | [
"Brace",
"matches",
"path",
"with",
"REST",
"-",
"full",
"resources",
"URI",
"in",
"brace",
"form",
".",
"e",
".",
"g",
".",
"/",
"foo",
"/",
"v1",
"/",
"bar",
"/",
"v2",
"will",
"map",
"to",
"/",
"{",
"foo",
"}",
"/",
"{",
"bar",
"}",
"form",
"while",
"the",
"value",
"of",
"foo",
"and",
"bar",
"are",
"v1",
"and",
"v2",
"respectively",
"."
]
| [
"func",
"Brace",
"(",
"<mask>",
"string",
")",
"*",
"brace",
"{",
"matches",
":=",
"strings",
".",
"Split",
"(",
"path",
",",
"\"",
"\"",
")",
"\n",
"return",
"&",
"brace",
"{",
"matches",
":",
"matches",
",",
"}",
"\n",
"}"
]
|
20,383 | all-20384 | [
"Keys",
"returns",
"a",
"sorted",
"list",
"of",
"the",
"keys",
"in",
"the",
"dictionary",
"v",
".",
"If",
"v",
"is",
"a",
"stream",
"Keys",
"applies",
"to",
"the",
"stream",
"s",
"header",
"dictionary",
".",
"If",
"v",
".",
"Kind",
"()",
"!",
"=",
"Dict",
"and",
"v",
".",
"Kind",
"()",
"!",
"=",
"Stream",
"Keys",
"returns",
"nil",
"."
]
| [
"func",
"(",
"v",
"<mask>",
")",
"Keys",
"(",
")",
"[",
"]",
"string",
"{",
"x",
",",
"ok",
":=",
"v",
".",
"data",
".",
"(",
"dict",
")",
"\n",
"if",
"!",
"ok",
"{",
"strm",
",",
"ok",
":=",
"v",
".",
"data",
".",
"(",
"stream",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"x",
"=",
"strm",
".",
"hdr",
"\n",
"}",
"\n",
"keys",
":=",
"[",
"]",
"string",
"{",
"}",
"// not nil",
"\n",
"for",
"k",
":=",
"range",
"x",
"{",
"keys",
"=",
"append",
"(",
"keys",
",",
"string",
"(",
"k",
")",
")",
"\n",
"}",
"\n",
"sort",
".",
"Strings",
"(",
"keys",
")",
"\n",
"return",
"keys",
"\n",
"}"
]
|
20,384 | all-20385 | [
"String",
"renderer",
"that",
"will",
"run",
"the",
"string",
"through",
"the",
"github",
".",
"com",
"/",
"gobuffalo",
"/",
"plush",
"package",
"and",
"return",
"text",
"/",
"plain",
"as",
"the",
"content",
"type",
"."
]
| [
"func",
"String",
"(",
"s",
"string",
",",
"args",
"...",
"<mask>",
"{",
"}",
")",
"Renderer",
"{",
"e",
":=",
"New",
"(",
"Options",
"{",
"}",
")",
"\n",
"return",
"e",
".",
"String",
"(",
"s",
",",
"args",
"...",
")",
"\n",
"}"
]
|
20,385 | all-20386 | [
"Encode",
"returns",
"a",
"packed",
"slice",
"of",
"the",
"values",
"from",
"src",
".",
"If",
"a",
"value",
"is",
"over",
"1",
"<<",
"60",
"an",
"error",
"is",
"returned",
".",
"The",
"input",
"src",
"is",
"modified",
"to",
"avoid",
"extra",
"allocations",
".",
"If",
"you",
"need",
"to",
"re",
"-",
"use",
"use",
"a",
"copy",
"."
]
| [
"func",
"EncodeAll",
"(",
"src",
"[",
"]",
"uint64",
")",
"(",
"[",
"]",
"uint64",
",",
"error",
")",
"{",
"i",
":=",
"0",
"\n\n",
"// Re-use the input slice and write encoded values back in place",
"dst",
":=",
"src",
"\n",
"j",
":=",
"0",
"\n\n",
"for",
"{",
"if",
"i",
">=",
"len",
"(",
"src",
")",
"{",
"<mask>",
"\n",
"}",
"\n",
"remaining",
":=",
"src",
"[",
"i",
":",
"]",
"\n\n",
"if",
"canPack",
"(",
"remaining",
",",
"240",
",",
"0",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"0",
"\n",
"i",
"+=",
"240",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"120",
",",
"0",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"1",
"<<",
"60",
"\n",
"i",
"+=",
"120",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"60",
",",
"1",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"pack60",
"(",
"src",
"[",
"i",
":",
"i",
"+",
"60",
"]",
")",
"\n",
"i",
"+=",
"60",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"30",
",",
"2",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"pack30",
"(",
"src",
"[",
"i",
":",
"i",
"+",
"30",
"]",
")",
"\n",
"i",
"+=",
"30",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"20",
",",
"3",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"pack20",
"(",
"src",
"[",
"i",
":",
"i",
"+",
"20",
"]",
")",
"\n",
"i",
"+=",
"20",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"15",
",",
"4",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"pack15",
"(",
"src",
"[",
"i",
":",
"i",
"+",
"15",
"]",
")",
"\n",
"i",
"+=",
"15",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"12",
",",
"5",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"pack12",
"(",
"src",
"[",
"i",
":",
"i",
"+",
"12",
"]",
")",
"\n",
"i",
"+=",
"12",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"10",
",",
"6",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"pack10",
"(",
"src",
"[",
"i",
":",
"i",
"+",
"10",
"]",
")",
"\n",
"i",
"+=",
"10",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"8",
",",
"7",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"pack8",
"(",
"src",
"[",
"i",
":",
"i",
"+",
"8",
"]",
")",
"\n",
"i",
"+=",
"8",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"7",
",",
"8",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"pack7",
"(",
"src",
"[",
"i",
":",
"i",
"+",
"7",
"]",
")",
"\n",
"i",
"+=",
"7",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"6",
",",
"10",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"pack6",
"(",
"src",
"[",
"i",
":",
"i",
"+",
"6",
"]",
")",
"\n",
"i",
"+=",
"6",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"5",
",",
"12",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"pack5",
"(",
"src",
"[",
"i",
":",
"i",
"+",
"5",
"]",
")",
"\n",
"i",
"+=",
"5",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"4",
",",
"15",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"pack4",
"(",
"src",
"[",
"i",
":",
"i",
"+",
"4",
"]",
")",
"\n",
"i",
"+=",
"4",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"3",
",",
"20",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"pack3",
"(",
"src",
"[",
"i",
":",
"i",
"+",
"3",
"]",
")",
"\n",
"i",
"+=",
"3",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"2",
",",
"30",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"pack2",
"(",
"src",
"[",
"i",
":",
"i",
"+",
"2",
"]",
")",
"\n",
"i",
"+=",
"2",
"\n",
"}",
"else",
"if",
"canPack",
"(",
"remaining",
",",
"1",
",",
"60",
")",
"{",
"dst",
"[",
"j",
"]",
"=",
"pack1",
"(",
"src",
"[",
"i",
":",
"i",
"+",
"1",
"]",
")",
"\n",
"i",
"+=",
"1",
"\n",
"}",
"else",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"j",
"+=",
"1",
"\n",
"}",
"\n",
"return",
"dst",
"[",
":",
"j",
"]",
",",
"nil",
"\n",
"}"
]
|
20,386 | all-20387 | [
"/",
"*",
"Allocates",
"and",
"initializes",
"CvMatND",
"header",
"and",
"allocates",
"data"
]
| [
"func",
"CreateMatND",
"(",
"sizes",
"[",
"]",
"int",
",",
"type_",
"int",
")",
"*",
"MatND",
"{",
"dims",
":=",
"C",
".",
"int",
"(",
"len",
"(",
"sizes",
")",
")",
"\n",
"sizes_c",
":=",
"<mask>",
"(",
"[",
"]",
"C",
".",
"int",
",",
"len",
"(",
"sizes",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"sizes",
")",
";",
"i",
"++",
"{",
"sizes_c",
"[",
"i",
"]",
"=",
"C",
".",
"int",
"(",
"sizes",
"[",
"i",
"]",
")",
"\n",
"}",
"\n\n",
"mat",
":=",
"C",
".",
"cvCreateMatND",
"(",
"dims",
",",
"(",
"*",
"C",
".",
"int",
")",
"(",
"&",
"sizes_c",
"[",
"0",
"]",
")",
",",
"C",
".",
"int",
"(",
"type_",
")",
",",
")",
"\n",
"return",
"(",
"*",
"MatND",
")",
"(",
"mat",
")",
"\n",
"}"
]
|
20,387 | all-20388 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"SetNodeNameParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoDom5",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
20,388 | all-20389 | [
"GetAuthURIOk",
"returns",
"a",
"tuple",
"with",
"the",
"AuthURI",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"i",
"*",
"IntegrationGCPCreateRequest",
")",
"GetAuthURIOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"i",
"==",
"nil",
"||",
"i",
".",
"AuthURI",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"i",
".",
"AuthURI",
",",
"true",
"\n",
"}"
]
|
20,389 | all-20390 | [
"Pins",
"returns",
"a",
"map",
"of",
"the",
"pin",
"hashes",
"to",
"their",
"info",
"(",
"currently",
"just",
"the",
"pin",
"type",
"one",
"of",
"DirectPin",
"RecursivePin",
"or",
"IndirectPin",
".",
"A",
"map",
"is",
"returned",
"instead",
"of",
"a",
"slice",
"because",
"it",
"is",
"easier",
"to",
"do",
"existence",
"lookup",
"by",
"map",
"key",
"than",
"unordered",
"array",
"searching",
".",
"The",
"map",
"is",
"likely",
"to",
"be",
"more",
"useful",
"to",
"a",
"client",
"than",
"a",
"flat",
"list",
"."
]
| [
"func",
"(",
"s",
"*",
"Shell",
")",
"Pins",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"PinInfo",
",",
"error",
")",
"{",
"var",
"raw",
"struct",
"{",
"Keys",
"map",
"[",
"string",
"]",
"PinInfo",
"}",
"\n",
"return",
"<mask>",
".",
"Keys",
",",
"s",
".",
"Request",
"(",
"\"",
"\"",
")",
".",
"Exec",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"raw",
")",
"\n",
"}"
]
|
20,390 | all-20391 | [
"ChangeStaticPath",
"changes",
"static",
"path",
"from",
"old",
"to",
"new",
"one",
"."
]
| [
"func",
"(",
"ctx",
"*",
"Context",
")",
"ChangeStaticPath",
"(",
"oldPath",
",",
"newPath",
"string",
")",
"{",
"if",
"!",
"filepath",
".",
"IsAbs",
"(",
"oldPath",
")",
"{",
"oldPath",
"=",
"filepath",
".",
"Join",
"(",
"Root",
",",
"oldPath",
")",
"\n",
"}",
"\n",
"dir",
":=",
"statics",
".",
"Get",
"(",
"oldPath",
")",
"\n",
"if",
"dir",
"!=",
"nil",
"{",
"statics",
".",
"Delete",
"(",
"oldPath",
")",
"\n\n",
"if",
"!",
"filepath",
".",
"IsAbs",
"(",
"newPath",
")",
"{",
"newPath",
"=",
"filepath",
".",
"Join",
"(",
"<mask>",
",",
"newPath",
")",
"\n",
"}",
"\n",
"*",
"dir",
"=",
"http",
".",
"Dir",
"(",
"newPath",
")",
"\n",
"statics",
".",
"Set",
"(",
"dir",
")",
"\n",
"}",
"\n",
"}"
]
|
20,391 | all-20392 | [
"SetAnnotation",
"sets",
"annotations",
"for",
"the",
"virtual",
"machine",
"."
]
| [
"func",
"(",
"v",
"*",
"VM",
")",
"SetAnnotation",
"(",
"text",
"string",
")",
"error",
"{",
"return",
"v",
".",
"updateVMX",
"(",
"func",
"(",
"<mask>",
"*",
"vmx",
".",
"VirtualMachine",
")",
"error",
"{",
"model",
".",
"Annotation",
"=",
"text",
"\n",
"return",
"nil",
"\n",
"}",
")",
"\n",
"}"
]
|
20,392 | all-20393 | [
"Flatten",
"can",
"be",
"used",
"to",
"force",
"compactions",
"on",
"the",
"LSM",
"tree",
"so",
"all",
"the",
"tables",
"fall",
"on",
"the",
"same",
"level",
".",
"This",
"ensures",
"that",
"all",
"the",
"versions",
"of",
"keys",
"are",
"colocated",
"and",
"not",
"split",
"across",
"multiple",
"levels",
"which",
"is",
"necessary",
"after",
"a",
"restore",
"from",
"backup",
".",
"During",
"Flatten",
"live",
"compactions",
"are",
"stopped",
".",
"Ideally",
"no",
"writes",
"are",
"going",
"on",
"during",
"Flatten",
".",
"Otherwise",
"it",
"would",
"create",
"competition",
"between",
"flattening",
"the",
"tree",
"and",
"new",
"tables",
"being",
"created",
"at",
"level",
"zero",
"."
]
| [
"func",
"(",
"db",
"*",
"DB",
")",
"Flatten",
"(",
"workers",
"int",
")",
"error",
"{",
"db",
".",
"stopCompactions",
"(",
")",
"\n",
"defer",
"db",
".",
"startCompactions",
"(",
")",
"\n\n",
"compactAway",
":=",
"func",
"(",
"cp",
"compactionPriority",
")",
"error",
"{",
"db",
".",
"opt",
".",
"Infof",
"(",
"\"",
"\\n",
"\"",
",",
"cp",
")",
"\n",
"errCh",
":=",
"<mask>",
"(",
"chan",
"error",
",",
"1",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"workers",
";",
"i",
"++",
"{",
"go",
"func",
"(",
")",
"{",
"errCh",
"<-",
"db",
".",
"lc",
".",
"doCompact",
"(",
"cp",
")",
"\n",
"}",
"(",
")",
"\n",
"}",
"\n",
"var",
"success",
"int",
"\n",
"var",
"rerr",
"error",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"workers",
";",
"i",
"++",
"{",
"err",
":=",
"<-",
"errCh",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"rerr",
"=",
"err",
"\n",
"db",
".",
"opt",
".",
"Warningf",
"(",
"\"",
"\\n",
"\"",
",",
"cp",
",",
"err",
")",
"\n",
"}",
"else",
"{",
"success",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"success",
"==",
"0",
"{",
"return",
"rerr",
"\n",
"}",
"\n",
"// We could do at least one successful compaction. So, we'll consider this a success.",
"db",
".",
"opt",
".",
"Infof",
"(",
"\"",
"\\n",
"\"",
",",
"success",
",",
"cp",
".",
"level",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"hbytes",
":=",
"func",
"(",
"sz",
"int64",
")",
"string",
"{",
"return",
"humanize",
".",
"Bytes",
"(",
"uint64",
"(",
"sz",
")",
")",
"\n",
"}",
"\n\n",
"for",
"{",
"db",
".",
"opt",
".",
"Infof",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"var",
"levels",
"[",
"]",
"int",
"\n",
"for",
"i",
",",
"l",
":=",
"range",
"db",
".",
"lc",
".",
"levels",
"{",
"sz",
":=",
"l",
".",
"getTotalSize",
"(",
")",
"\n",
"db",
".",
"opt",
".",
"Infof",
"(",
"\"",
"\\n",
"\"",
",",
"i",
",",
"hbytes",
"(",
"l",
".",
"getTotalSize",
"(",
")",
")",
",",
"hbytes",
"(",
"l",
".",
"maxTotalSize",
")",
")",
"\n",
"if",
"sz",
">",
"0",
"{",
"levels",
"=",
"append",
"(",
"levels",
",",
"i",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"len",
"(",
"levels",
")",
"<=",
"1",
"{",
"prios",
":=",
"db",
".",
"lc",
".",
"pickCompactLevels",
"(",
")",
"\n",
"if",
"len",
"(",
"prios",
")",
"==",
"0",
"||",
"prios",
"[",
"0",
"]",
".",
"score",
"<=",
"1.0",
"{",
"db",
".",
"opt",
".",
"Infof",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"err",
":=",
"compactAway",
"(",
"prios",
"[",
"0",
"]",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"continue",
"\n",
"}",
"\n",
"// Create an artificial compaction priority, to ensure that we compact the level.",
"cp",
":=",
"compactionPriority",
"{",
"level",
":",
"levels",
"[",
"0",
"]",
",",
"score",
":",
"1.71",
"}",
"\n",
"if",
"err",
":=",
"compactAway",
"(",
"cp",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}"
]
|
20,393 | all-20394 | [
"DistSqr",
"returns",
"the",
"square",
"of",
"the",
"distance",
"between",
"two",
"points",
"."
]
| [
"func",
"(",
"v",
"Vec3",
")",
"DistSqr",
"(",
"v1",
"Vec3",
")",
"float32",
"{",
"dx",
":=",
"v1",
"[",
"0",
"]",
"-",
"v",
"[",
"0",
"]",
"\n",
"dy",
":=",
"v1",
"[",
"1",
"]",
"-",
"v",
"[",
"1",
"]",
"\n",
"dz",
":=",
"v1",
"[",
"2",
"]",
"-",
"v",
"[",
"2",
"]",
"\n",
"<mask>",
"dx",
"*",
"dx",
"+",
"dy",
"*",
"dy",
"+",
"dz",
"*",
"dz",
"\n",
"}"
]
|
20,394 | all-20395 | [
"GetTypeOk",
"returns",
"a",
"tuple",
"with",
"the",
"Type",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"l",
"*",
"LogStreamDefinition",
")",
"GetTypeOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"l",
"==",
"nil",
"||",
"l",
".",
"<mask>",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"l",
".",
"Type",
",",
"true",
"\n",
"}"
]
|
20,395 | all-20396 | [
"copy",
"returns",
"a",
"copy",
"of",
"the",
"current",
"state",
"."
]
| [
"func",
"(",
"st",
"*",
"state",
")",
"copy",
"(",
")",
"*",
"state",
"{",
"n",
":=",
"<mask>",
"(",
"state",
")",
"\n",
"*",
"n",
"=",
"*",
"st",
"\n",
"return",
"n",
"\n",
"}"
]
|
20,396 | all-20397 | [
"Format",
"proxies",
"the",
"closure",
"in",
"order",
"to",
"satisfy",
"logrus",
".",
"Formatter",
"s",
"interface",
"."
]
| [
"func",
"(",
"f",
"FormatterFunc",
")",
"Format",
"(",
"entry",
"*",
"logrus",
".",
"Entry",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"f",
"(",
"<mask>",
")",
"\n",
"}"
]
|
20,397 | all-20398 | [
"Delete",
"deletes",
"the",
"file",
"at",
"key"
]
| [
"func",
"(",
"c",
"*",
"Cache",
")",
"Delete",
"(",
"key",
"string",
")",
"error",
"{",
"return",
"os",
".",
"Remove",
"(",
"c",
".",
"KeyToPath",
"(",
"<mask>",
")",
")",
"\n",
"}"
]
|
20,398 | all-20399 | [
"HasCustomBgColor",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"w",
"*",
"WidgetConditionalFormat",
")",
"HasCustomBgColor",
"(",
")",
"bool",
"{",
"if",
"w",
"!=",
"nil",
"&&",
"w",
".",
"CustomBgColor",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
]
|
20,399 | all-20400 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"Cache",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"<mask>",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoCachestorage11",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.