id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
listlengths 1
418
| pl_tokens
listlengths 22
4.98k
|
---|---|---|---|
16,200 | all-16201 | [
"Keys",
"returns",
"all",
"the",
"keys",
"attached",
"to",
"the",
"lease",
"."
] | [
"func",
"(",
"l",
"*",
"Lease",
")",
"Keys",
"(",
")",
"[",
"]",
"string",
"{",
"l",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"l",
".",
"itemSet",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"l",
".",
"itemSet",
"{",
"keys",
"=",
"append",
"(",
"keys",
",",
"k",
".",
"<mask>",
")",
"\n",
"}",
"\n",
"l",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"keys",
"\n",
"}"
] |
16,201 | all-16202 | [
"FromKey",
"gets",
"a",
"portgroup",
"object",
"from",
"its",
"key",
"."
] | [
"func",
"FromKey",
"(",
"client",
"*",
"govmomi",
".",
"<mask>",
",",
"dvsUUID",
",",
"pgKey",
"string",
")",
"(",
"*",
"object",
".",
"DistributedVirtualPortgroup",
",",
"error",
")",
"{",
"dvsm",
":=",
"types",
".",
"ManagedObjectReference",
"{",
"Type",
":",
"\"",
"\"",
",",
"Value",
":",
"\"",
"\"",
"}",
"\n",
"req",
":=",
"&",
"types",
".",
"DVSManagerLookupDvPortGroup",
"{",
"This",
":",
"dvsm",
",",
"SwitchUuid",
":",
"dvsUUID",
",",
"PortgroupKey",
":",
"pgKey",
",",
"}",
"\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"provider",
".",
"DefaultAPITimeout",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"resp",
",",
"err",
":=",
"methods",
".",
"DVSManagerLookupDvPortGroup",
"(",
"ctx",
",",
"client",
",",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"resp",
".",
"Returnval",
"==",
"nil",
"{",
"return",
"nil",
",",
"NewMissingPortGroupReferenceError",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"dvsUUID",
",",
"pgKey",
",",
")",
",",
")",
"\n",
"}",
"\n\n",
"return",
"FromMOID",
"(",
"client",
",",
"resp",
".",
"Returnval",
".",
"Reference",
"(",
")",
".",
"Value",
")",
"\n",
"}"
] |
16,202 | all-16203 | [
"resourceVSphereDatastoreClusterGetPodFromPath",
"gets",
"the",
"StoragePod",
"from",
"a",
"supplied",
"path",
".",
"If",
"no",
"datacenter",
"is",
"supplied",
"the",
"path",
"must",
"be",
"a",
"full",
"path",
"."
] | [
"func",
"resourceVSphereDatastoreClusterGetPodFromPath",
"(",
"meta",
"interface",
"{",
"}",
",",
"path",
"string",
",",
"dcID",
"string",
")",
"(",
"*",
"object",
".",
"StoragePod",
",",
"error",
")",
"{",
"client",
":=",
"meta",
".",
"(",
"*",
"VSphereClient",
")",
".",
"vimClient",
"\n",
"var",
"dc",
"*",
"object",
".",
"Datacenter",
"\n",
"if",
"dcID",
"!=",
"\"",
"\"",
"{",
"var",
"err",
"error",
"\n",
"dc",
",",
"err",
"=",
"datacenterFromID",
"(",
"client",
",",
"dcID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"<mask>",
",",
"dc",
".",
"InventoryPath",
")",
"\n",
"}",
"else",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"path",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"viapi",
".",
"ValidateVirtualCenter",
"(",
"client",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"storagepod",
".",
"FromPath",
"(",
"client",
",",
"path",
",",
"dc",
")",
"\n",
"}"
] |
16,203 | all-16204 | [
"AddWithData",
"is",
"convenience",
"method",
"to",
"add",
"a",
"job",
"with",
"given",
"data",
"."
] | [
"func",
"AddWithData",
"(",
"q",
"Queue",
",",
"tx",
"*",
"reform",
".",
"TX",
",",
"jobType",
",",
"relatedType",
",",
"relatedID",
",",
"creator",
"string",
",",
"jobData",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"AddWithDataAndDelay",
"(",
"q",
",",
"<mask>",
",",
"jobType",
",",
"relatedType",
",",
"relatedID",
",",
"creator",
",",
"jobData",
",",
"time",
".",
"Duration",
"(",
"0",
")",
")",
"\n",
"}"
] |
16,204 | all-16205 | [
"SpatialEntropy",
"calculates",
"the",
"entropy",
"for",
"spatial",
"matches"
] | [
"func",
"SpatialEntropy",
"(",
"match",
"match",
".",
"Match",
",",
"turns",
"int",
",",
"shiftCount",
"int",
")",
"float64",
"{",
"var",
"s",
",",
"d",
"float64",
"\n",
"if",
"match",
".",
"DictionaryName",
"==",
"\"",
"\"",
"||",
"match",
".",
"DictionaryName",
"==",
"\"",
"\"",
"{",
"//todo: verify qwerty and dvorak have the same length and degree",
"s",
"=",
"float64",
"(",
"len",
"(",
"adjacency",
".",
"BuildQwerty",
"(",
")",
".",
"Graph",
")",
")",
"\n",
"d",
"=",
"adjacency",
".",
"BuildQwerty",
"(",
")",
".",
"CalculateAvgDegree",
"(",
")",
"\n",
"}",
"else",
"{",
"s",
"=",
"float64",
"(",
"keyPadStartingPositions",
")",
"\n",
"d",
"=",
"keyPadAvgDegree",
"\n",
"}",
"\n\n",
"possibilities",
":=",
"float64",
"(",
"0",
")",
"\n\n",
"length",
":=",
"float64",
"(",
"len",
"(",
"<mask>",
".",
"Token",
")",
")",
"\n\n",
"//TODO: Should this be <= or just < ?",
"//Estimate the number of possible patterns w/ length L or less with t turns or less",
"for",
"i",
":=",
"float64",
"(",
"2",
")",
";",
"i",
"<=",
"length",
"+",
"1",
";",
"i",
"++",
"{",
"possibleTurns",
":=",
"math",
".",
"Min",
"(",
"float64",
"(",
"turns",
")",
",",
"i",
"-",
"1",
")",
"\n",
"for",
"j",
":=",
"float64",
"(",
"1",
")",
";",
"j",
"<=",
"possibleTurns",
"+",
"1",
";",
"j",
"++",
"{",
"x",
":=",
"zxcvbnmath",
".",
"NChoseK",
"(",
"i",
"-",
"1",
",",
"j",
"-",
"1",
")",
"*",
"s",
"*",
"math",
".",
"Pow",
"(",
"d",
",",
"j",
")",
"\n",
"possibilities",
"+=",
"x",
"\n",
"}",
"\n",
"}",
"\n\n",
"entropy",
":=",
"math",
".",
"Log2",
"(",
"possibilities",
")",
"\n",
"//add extra entropu for shifted keys. ( % instead of 5 A instead of a)",
"//Math is similar to extra entropy for uppercase letters in dictionary matches.",
"if",
"S",
":=",
"float64",
"(",
"shiftCount",
")",
";",
"S",
">",
"float64",
"(",
"0",
")",
"{",
"possibilities",
"=",
"float64",
"(",
"0",
")",
"\n",
"U",
":=",
"length",
"-",
"S",
"\n\n",
"for",
"i",
":=",
"float64",
"(",
"0",
")",
";",
"i",
"<",
"math",
".",
"Min",
"(",
"S",
",",
"U",
")",
"+",
"1",
";",
"i",
"++",
"{",
"possibilities",
"+=",
"zxcvbnmath",
".",
"NChoseK",
"(",
"S",
"+",
"U",
",",
"i",
")",
"\n",
"}",
"\n\n",
"entropy",
"+=",
"math",
".",
"Log2",
"(",
"possibilities",
")",
"\n",
"}",
"\n\n",
"return",
"entropy",
"\n",
"}"
] |
16,205 | all-16206 | [
"GetMinOk",
"returns",
"a",
"tuple",
"with",
"the",
"Min",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"g",
"*",
"GraphDefinitionMarker",
")",
"GetMinOk",
"(",
")",
"(",
"json",
".",
"Number",
",",
"bool",
")",
"{",
"if",
"g",
"==",
"nil",
"||",
"g",
".",
"Min",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"g",
".",
"Min",
",",
"true",
"\n",
"}"
] |
16,206 | all-16207 | [
"mustNewMember",
"return",
"an",
"inited",
"member",
"with",
"the",
"given",
"name",
".",
"If",
"peerTLS",
"is",
"set",
"it",
"will",
"use",
"https",
"scheme",
"to",
"communicate",
"between",
"peers",
"."
] | [
"func",
"mustNewMember",
"(",
"t",
"testing",
".",
"TB",
",",
"mcfg",
"memberConfig",
")",
"*",
"member",
"{",
"var",
"err",
"error",
"\n",
"m",
":=",
"&",
"member",
"{",
"}",
"\n\n",
"peerScheme",
":=",
"schemeFromTLSInfo",
"(",
"mcfg",
".",
"peerTLS",
")",
"\n",
"clientScheme",
":=",
"schemeFromTLSInfo",
"(",
"mcfg",
".",
"clientTLS",
")",
"\n\n",
"pln",
":=",
"newLocalListener",
"(",
"t",
")",
"\n",
"m",
".",
"PeerListeners",
"=",
"[",
"]",
"net",
".",
"Listener",
"{",
"pln",
"}",
"\n",
"m",
".",
"PeerURLs",
",",
"err",
"=",
"types",
".",
"NewURLs",
"(",
"[",
"]",
"string",
"{",
"peerScheme",
"+",
"\"",
"\"",
"+",
"pln",
".",
"Addr",
"(",
")",
".",
"String",
"(",
")",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"t",
".",
"Fatal",
"(",
"err",
")",
"\n",
"}",
"\n",
"m",
".",
"PeerTLSInfo",
"=",
"mcfg",
".",
"peerTLS",
"\n\n",
"cln",
":=",
"newLocalListener",
"(",
"t",
")",
"\n",
"m",
".",
"ClientListeners",
"=",
"[",
"]",
"net",
".",
"Listener",
"{",
"cln",
"}",
"\n",
"m",
".",
"ClientURLs",
",",
"err",
"=",
"types",
".",
"NewURLs",
"(",
"[",
"]",
"string",
"{",
"clientScheme",
"+",
"\"",
"\"",
"+",
"cln",
".",
"Addr",
"(",
")",
".",
"String",
"(",
")",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"t",
".",
"Fatal",
"(",
"err",
")",
"\n",
"}",
"\n",
"m",
".",
"ClientTLSInfo",
"=",
"mcfg",
".",
"clientTLS",
"\n\n",
"m",
".",
"Name",
"=",
"mcfg",
".",
"name",
"\n\n",
"m",
".",
"DataDir",
",",
"err",
"=",
"ioutil",
".",
"TempDir",
"(",
"os",
".",
"TempDir",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"t",
".",
"Fatal",
"(",
"err",
")",
"\n",
"}",
"\n",
"clusterStr",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"mcfg",
".",
"<mask>",
",",
"peerScheme",
",",
"pln",
".",
"Addr",
"(",
")",
".",
"String",
"(",
")",
")",
"\n",
"m",
".",
"InitialPeerURLsMap",
",",
"err",
"=",
"types",
".",
"NewURLsMap",
"(",
"clusterStr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"t",
".",
"Fatal",
"(",
"err",
")",
"\n",
"}",
"\n",
"m",
".",
"InitialClusterToken",
"=",
"clusterName",
"\n",
"m",
".",
"NewCluster",
"=",
"true",
"\n",
"m",
".",
"BootstrapTimeout",
"=",
"10",
"*",
"time",
".",
"Millisecond",
"\n",
"if",
"m",
".",
"PeerTLSInfo",
"!=",
"nil",
"{",
"m",
".",
"ServerConfig",
".",
"PeerTLSInfo",
"=",
"*",
"m",
".",
"PeerTLSInfo",
"\n",
"}",
"\n",
"m",
".",
"ElectionTicks",
"=",
"electionTicks",
"\n",
"m",
".",
"InitialElectionTickAdvance",
"=",
"true",
"\n",
"m",
".",
"TickMs",
"=",
"uint",
"(",
"tickDuration",
"/",
"time",
".",
"Millisecond",
")",
"\n",
"m",
".",
"QuotaBackendBytes",
"=",
"mcfg",
".",
"quotaBackendBytes",
"\n",
"m",
".",
"MaxTxnOps",
"=",
"mcfg",
".",
"maxTxnOps",
"\n",
"if",
"m",
".",
"MaxTxnOps",
"==",
"0",
"{",
"m",
".",
"MaxTxnOps",
"=",
"embed",
".",
"DefaultMaxTxnOps",
"\n",
"}",
"\n",
"m",
".",
"MaxRequestBytes",
"=",
"mcfg",
".",
"maxRequestBytes",
"\n",
"if",
"m",
".",
"MaxRequestBytes",
"==",
"0",
"{",
"m",
".",
"MaxRequestBytes",
"=",
"embed",
".",
"DefaultMaxRequestBytes",
"\n",
"}",
"\n",
"m",
".",
"SnapshotCount",
"=",
"etcdserver",
".",
"DefaultSnapshotCount",
"\n",
"if",
"mcfg",
".",
"snapshotCount",
"!=",
"0",
"{",
"m",
".",
"SnapshotCount",
"=",
"mcfg",
".",
"snapshotCount",
"\n",
"}",
"\n",
"m",
".",
"SnapshotCatchUpEntries",
"=",
"etcdserver",
".",
"DefaultSnapshotCatchUpEntries",
"\n",
"if",
"mcfg",
".",
"snapshotCatchUpEntries",
"!=",
"0",
"{",
"m",
".",
"SnapshotCatchUpEntries",
"=",
"mcfg",
".",
"snapshotCatchUpEntries",
"\n",
"}",
"\n\n",
"// for the purpose of integration testing, simple token is enough",
"m",
".",
"AuthToken",
"=",
"\"",
"\"",
"\n",
"if",
"mcfg",
".",
"authToken",
"!=",
"\"",
"\"",
"{",
"m",
".",
"AuthToken",
"=",
"mcfg",
".",
"authToken",
"\n",
"}",
"\n\n",
"m",
".",
"BcryptCost",
"=",
"uint",
"(",
"bcrypt",
".",
"MinCost",
")",
"// use min bcrypt cost to speedy up integration testing",
"\n\n",
"m",
".",
"grpcServerOpts",
"=",
"[",
"]",
"grpc",
".",
"ServerOption",
"{",
"}",
"\n",
"if",
"mcfg",
".",
"grpcKeepAliveMinTime",
">",
"time",
".",
"Duration",
"(",
"0",
")",
"{",
"m",
".",
"grpcServerOpts",
"=",
"append",
"(",
"m",
".",
"grpcServerOpts",
",",
"grpc",
".",
"KeepaliveEnforcementPolicy",
"(",
"keepalive",
".",
"EnforcementPolicy",
"{",
"MinTime",
":",
"mcfg",
".",
"grpcKeepAliveMinTime",
",",
"PermitWithoutStream",
":",
"false",
",",
"}",
")",
")",
"\n",
"}",
"\n",
"if",
"mcfg",
".",
"grpcKeepAliveInterval",
">",
"time",
".",
"Duration",
"(",
"0",
")",
"&&",
"mcfg",
".",
"grpcKeepAliveTimeout",
">",
"time",
".",
"Duration",
"(",
"0",
")",
"{",
"m",
".",
"grpcServerOpts",
"=",
"append",
"(",
"m",
".",
"grpcServerOpts",
",",
"grpc",
".",
"KeepaliveParams",
"(",
"keepalive",
".",
"ServerParameters",
"{",
"Time",
":",
"mcfg",
".",
"grpcKeepAliveInterval",
",",
"Timeout",
":",
"mcfg",
".",
"grpcKeepAliveTimeout",
",",
"}",
")",
")",
"\n",
"}",
"\n",
"m",
".",
"clientMaxCallSendMsgSize",
"=",
"mcfg",
".",
"clientMaxCallSendMsgSize",
"\n",
"m",
".",
"clientMaxCallRecvMsgSize",
"=",
"mcfg",
".",
"clientMaxCallRecvMsgSize",
"\n",
"m",
".",
"useIP",
"=",
"mcfg",
".",
"useIP",
"\n",
"m",
".",
"LeaseCheckpointInterval",
"=",
"mcfg",
".",
"leaseCheckpointInterval",
"\n\n",
"m",
".",
"InitialCorruptCheck",
"=",
"true",
"\n\n",
"lcfg",
":=",
"logutil",
".",
"DefaultZapLoggerConfig",
"\n",
"m",
".",
"LoggerConfig",
"=",
"&",
"lcfg",
"\n",
"m",
".",
"LoggerConfig",
".",
"OutputPaths",
"=",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
"\n",
"m",
".",
"LoggerConfig",
".",
"ErrorOutputPaths",
"=",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
"\n",
"if",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"!=",
"\"",
"\"",
"{",
"m",
".",
"LoggerConfig",
".",
"OutputPaths",
"=",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
"\n",
"m",
".",
"LoggerConfig",
".",
"ErrorOutputPaths",
"=",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
"\n",
"}",
"\n",
"m",
".",
"Logger",
",",
"err",
"=",
"m",
".",
"LoggerConfig",
".",
"Build",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"t",
".",
"Fatal",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"m",
"\n",
"}"
] |
16,207 | all-16208 | [
"MarshalEasyJSON",
"satisfies",
"easyjson",
".",
"Marshaler",
"."
] | [
"func",
"(",
"t",
"ClientNavigationReason",
")",
"MarshalEasyJSON",
"(",
"out",
"*",
"jwriter",
".",
"Writer",
")",
"{",
"<mask>",
".",
"String",
"(",
"string",
"(",
"t",
")",
")",
"\n",
"}"
] |
16,208 | all-16209 | [
"NewSendToLogger",
"creates",
"a",
"logger",
"from",
"a",
"go",
"log",
"."
] | [
"func",
"NewSendToLogger",
"(",
"logger",
"*",
"golog",
".",
"Logger",
")",
"LogBackend",
"{",
"if",
"logger",
"==",
"nil",
"{",
"return",
"&",
"SendToLogger",
"{",
"Logger",
":",
"golog",
".",
"New",
"(",
"<mask>",
".",
"Stderr",
",",
"\"",
"\"",
",",
"golog",
".",
"LstdFlags",
")",
",",
"}",
"\n",
"}",
"\n",
"return",
"&",
"SendToLogger",
"{",
"Logger",
":",
"logger",
",",
"}",
"\n",
"}"
] |
16,209 | all-16210 | [
"ArmForSwitch",
"returns",
"which",
"field",
"name",
"should",
"be",
"used",
"for",
"storing",
"the",
"value",
"for",
"an",
"instance",
"of",
"LedgerEntryChange"
] | [
"func",
"(",
"u",
"LedgerEntryChange",
")",
"ArmForSwitch",
"(",
"sw",
"int32",
")",
"(",
"string",
",",
"bool",
")",
"{",
"switch",
"LedgerEntryChangeType",
"(",
"sw",
")",
"{",
"case",
"LedgerEntryChangeTypeLedgerEntryCreated",
":",
"return",
"\"",
"\"",
",",
"true",
"\n",
"<mask>",
"LedgerEntryChangeTypeLedgerEntryUpdated",
":",
"return",
"\"",
"\"",
",",
"true",
"\n",
"case",
"LedgerEntryChangeTypeLedgerEntryRemoved",
":",
"return",
"\"",
"\"",
",",
"true",
"\n",
"case",
"LedgerEntryChangeTypeLedgerEntryState",
":",
"return",
"\"",
"\"",
",",
"true",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}"
] |
16,210 | all-16211 | [
"WithContextAndTeardown",
"is",
"a",
"helper",
"function",
"to",
"set",
"teardown",
"at",
"initiation",
"of",
"WithContext"
] | [
"func",
"WithContextAndTeardown",
"(",
"ctx",
"context",
".",
"Context",
",",
"tf",
"goprocess",
".",
"TeardownFunc",
")",
"goprocess",
".",
"<mask>",
"{",
"p",
":=",
"goprocess",
".",
"WithTeardown",
"(",
"tf",
")",
"\n",
"CloseAfterContext",
"(",
"p",
",",
"ctx",
")",
"\n",
"return",
"p",
"\n",
"}"
] |
16,211 | all-16212 | [
"/",
"*",
"StringsFromSection",
"returns",
"the",
"value",
"of",
"an",
"array",
"key",
"if",
"the",
"value",
"of",
"the",
"key",
"is",
"a",
"non",
"-",
"array",
"then",
"that",
"value",
"is",
"returned",
"in",
"an",
"array",
"of",
"length",
"1",
"."
] | [
"func",
"(",
"config",
"*",
"Config",
")",
"StringsFromSection",
"(",
"sectionName",
"string",
",",
"key",
"string",
")",
"[",
"]",
"string",
"{",
"<mask>",
":=",
"config",
".",
"sectionForName",
"(",
"sectionName",
")",
"\n\n",
"if",
"section",
"!=",
"nil",
"{",
"return",
"getStrings",
"(",
"section",
".",
"values",
",",
"key",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
16,212 | all-16213 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"LoadSnapshotParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"<mask>",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoLayertree13",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
16,213 | all-16214 | [
"expandDvsHostInfrastructureTrafficResource",
"reads",
"the",
"network",
"I",
"/",
"O",
"control",
"resource",
"data",
"keys",
"for",
"the",
"traffic",
"class",
"supplied",
"by",
"key",
"and",
"returns",
"an",
"appropriate",
"types",
".",
"DvsHostInfrastructureTrafficResource",
"reference",
".",
"This",
"should",
"be",
"checked",
"for",
"nil",
"to",
"see",
"if",
"it",
"should",
"be",
"added",
"to",
"the",
"slice",
"in",
"the",
"config",
"."
] | [
"func",
"expandDvsHostInfrastructureTrafficResource",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
",",
"key",
"string",
")",
"*",
"types",
".",
"DvsHostInfrastructureTrafficResource",
"{",
"shareLevelKey",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"strings",
".",
"ToLower",
"(",
"key",
")",
")",
"\n",
"shareCountKey",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"strings",
".",
"ToLower",
"(",
"key",
")",
")",
"\n",
"maxMbitKey",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"strings",
".",
"ToLower",
"(",
"key",
")",
")",
"\n",
"resMbitKey",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"strings",
".",
"ToLower",
"(",
"key",
")",
")",
"\n\n",
"obj",
":=",
"&",
"types",
".",
"DvsHostInfrastructureTrafficResource",
"{",
"AllocationInfo",
":",
"types",
".",
"DvsHostInfrastructureTrafficResourceAllocation",
"{",
"Limit",
":",
"structure",
".",
"GetInt64Ptr",
"(",
"d",
",",
"maxMbitKey",
")",
",",
"Reservation",
":",
"structure",
".",
"GetInt64Ptr",
"(",
"d",
",",
"resMbitKey",
")",
",",
"}",
",",
"}",
"\n",
"shares",
":=",
"&",
"types",
".",
"SharesInfo",
"{",
"Level",
":",
"<mask>",
".",
"SharesLevel",
"(",
"d",
".",
"Get",
"(",
"shareLevelKey",
")",
".",
"(",
"string",
")",
")",
",",
"Shares",
":",
"int32",
"(",
"d",
".",
"Get",
"(",
"shareCountKey",
")",
".",
"(",
"int",
")",
")",
",",
"}",
"\n",
"if",
"!",
"structure",
".",
"AllFieldsEmpty",
"(",
"shares",
")",
"{",
"obj",
".",
"AllocationInfo",
".",
"Shares",
"=",
"shares",
"\n",
"}",
"\n\n",
"if",
"structure",
".",
"AllFieldsEmpty",
"(",
"obj",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"obj",
".",
"Key",
"=",
"key",
"\n",
"return",
"obj",
"\n",
"}"
] |
16,214 | all-16215 | [
"GetAccount",
"retrieves",
"the",
"Account",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | [
"func",
"(",
"u",
"LedgerEntryData",
")",
"GetAccount",
"(",
")",
"(",
"result",
"AccountEntry",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n\n",
"if",
"armName",
"==",
"\"",
"\"",
"{",
"<mask>",
"=",
"*",
"u",
".",
"Account",
"\n",
"ok",
"=",
"true",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] |
16,215 | all-16216 | [
"Len",
"is",
"the",
"size",
"of",
"the",
"set",
"."
] | [
"func",
"(",
"s",
"*",
"Set",
")",
"Len",
"(",
")",
"int",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"len",
"(",
"s",
".",
"<mask>",
")",
"\n",
"}"
] |
16,216 | all-16217 | [
"ForEach",
"calls",
"process",
"for",
"each",
"element",
"in",
"the",
"queue",
"."
] | [
"func",
"(",
"queue",
"*",
"queue",
")",
"ForEach",
"(",
"process",
"func",
"(",
"interface",
"{",
"}",
")",
")",
"{",
"for",
"i",
":=",
"queue",
".",
"start",
";",
"i",
"<",
"queue",
".",
"end",
";",
"i",
"++",
"{",
"process",
"(",
"<mask>",
".",
"elements",
"[",
"i",
"%",
"int64",
"(",
"queue",
".",
"cap",
")",
"]",
")",
"\n",
"}",
"\n",
"}"
] |
16,217 | all-16218 | [
"native",
"returns",
"a",
"pointer",
"to",
"the",
"underlying",
"GtkColorChooser",
"."
] | [
"func",
"(",
"v",
"*",
"ColorChooser",
")",
"native",
"(",
")",
"*",
"C",
".",
"GtkColorChooser",
"{",
"if",
"v",
"==",
"nil",
"||",
"v",
".",
"GObject",
"==",
"nil",
"{",
"<mask>",
"nil",
"\n",
"}",
"\n",
"p",
":=",
"unsafe",
".",
"Pointer",
"(",
"v",
".",
"GObject",
")",
"\n",
"return",
"C",
".",
"toGtkColorChooser",
"(",
"p",
")",
"\n",
"}"
] |
16,218 | all-16219 | [
"newStreamRoundTripper",
"returns",
"a",
"roundTripper",
"used",
"to",
"send",
"stream",
"requests",
"to",
"rafthttp",
"listener",
"of",
"remote",
"peers",
".",
"Read",
"/",
"write",
"timeout",
"is",
"set",
"for",
"stream",
"roundTripper",
"to",
"promptly",
"find",
"out",
"broken",
"status",
"which",
"minimizes",
"the",
"number",
"of",
"messages",
"sent",
"on",
"broken",
"connection",
"."
] | [
"func",
"newStreamRoundTripper",
"(",
"tlsInfo",
"transport",
".",
"TLSInfo",
",",
"dialTimeout",
"time",
".",
"Duration",
")",
"(",
"<mask>",
".",
"RoundTripper",
",",
"error",
")",
"{",
"return",
"transport",
".",
"NewTimeoutTransport",
"(",
"tlsInfo",
",",
"dialTimeout",
",",
"ConnReadTimeout",
",",
"ConnWriteTimeout",
")",
"\n",
"}"
] |
16,219 | all-16220 | [
"Visit",
"returns",
"a",
"channel",
"which",
"you",
"can",
"receive",
"Node",
"structs",
"in",
"order",
"that",
"that",
"they",
"would",
"be",
"processed"
] | [
"func",
"(",
"ast",
"*",
"AST",
")",
"Visit",
"(",
")",
"<-",
"chan",
"node",
".",
"Node",
"{",
"c",
":=",
"make",
"(",
"chan",
"node",
".",
"Node",
")",
"\n",
"<mask>",
"func",
"(",
")",
"{",
"defer",
"close",
"(",
"c",
")",
"\n",
"ast",
".",
"Root",
".",
"Visit",
"(",
"c",
")",
"\n",
"}",
"(",
")",
"\n",
"return",
"c",
"\n",
"}"
] |
16,220 | all-16221 | [
"EnvKeys",
"Reads",
"the",
"AWS",
"keys",
"from",
"the",
"environment"
] | [
"func",
"EnvKeys",
"(",
")",
"(",
"keys",
"Keys",
",",
"err",
"error",
")",
"{",
"keys",
"=",
"Keys",
"{",
"AccessKey",
":",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
",",
"SecretKey",
":",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
",",
"SecurityToken",
":",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
",",
"}",
"\n",
"if",
"<mask>",
".",
"AccessKey",
"==",
"\"",
"\"",
"||",
"keys",
".",
"SecretKey",
"==",
"\"",
"\"",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
16,221 | all-16222 | [
"/",
"*",
"ProcessEvent",
"processes",
"all",
"events",
"come",
"from",
"the",
"control",
"parent",
".",
"If",
"a",
"control",
"processes",
"an",
"event",
"it",
"should",
"return",
"true",
".",
"If",
"the",
"method",
"returns",
"false",
"it",
"means",
"that",
"the",
"control",
"do",
"not",
"want",
"or",
"cannot",
"process",
"the",
"event",
"and",
"the",
"caller",
"sends",
"the",
"event",
"to",
"the",
"control",
"parent"
] | [
"func",
"(",
"l",
"*",
"TextDisplay",
")",
"ProcessEvent",
"(",
"event",
"Event",
")",
"bool",
"{",
"if",
"!",
"l",
".",
"Active",
"(",
")",
"||",
"!",
"l",
".",
"Enabled",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"switch",
"event",
".",
"Type",
"{",
"case",
"EventKey",
":",
"switch",
"event",
".",
"Key",
"{",
"case",
"term",
".",
"KeyHome",
":",
"l",
".",
"home",
"(",
")",
"\n",
"return",
"true",
"\n",
"case",
"term",
".",
"KeyEnd",
":",
"l",
".",
"end",
"(",
")",
"\n",
"return",
"true",
"\n",
"case",
"term",
".",
"KeyArrowUp",
":",
"l",
".",
"moveUp",
"(",
"1",
")",
"\n",
"return",
"true",
"\n",
"case",
"term",
".",
"KeyArrowDown",
":",
"l",
".",
"moveDown",
"(",
"1",
")",
"\n",
"return",
"true",
"\n",
"case",
"term",
".",
"KeyPgup",
":",
"l",
".",
"moveUp",
"(",
"l",
".",
"height",
"-",
"1",
")",
"\n",
"return",
"true",
"\n",
"case",
"term",
".",
"KeyPgdn",
",",
"term",
".",
"KeySpace",
":",
"l",
".",
"moveDown",
"(",
"l",
".",
"height",
"-",
"1",
")",
"\n",
"return",
"true",
"\n",
"}",
"\n\n",
"switch",
"event",
".",
"Ch",
"{",
"case",
"'k'",
",",
"'K'",
":",
"l",
".",
"moveUp",
"(",
"1",
")",
"\n",
"return",
"true",
"\n",
"case",
"'j'",
",",
"'J'",
":",
"l",
".",
"moveDown",
"(",
"1",
")",
"\n",
"return",
"true",
"\n",
"case",
"'u'",
",",
"'U'",
":",
"l",
".",
"moveUp",
"(",
"l",
".",
"height",
"-",
"1",
")",
"\n",
"return",
"true",
"\n",
"case",
"'d'",
",",
"'D'",
":",
"l",
".",
"moveDown",
"(",
"l",
".",
"<mask>",
"-",
"1",
")",
"\n",
"return",
"true",
"\n",
"default",
":",
"return",
"false",
"\n",
"}",
"\n",
"case",
"EventMouse",
":",
"return",
"l",
".",
"processMouseClick",
"(",
"event",
")",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
16,222 | all-16223 | [
"New10sBackOff",
"returns",
"a",
"backoff",
"that",
"s",
"slightly",
"more",
"aggressive",
"than",
"NewExponentialBackOff",
".",
"The",
"Max",
"Elapsed",
"time",
"for",
"this",
"backoff",
"is",
"10s",
"and",
"the",
"initial",
"backoff",
"is",
"100ms",
"(",
"instead",
"of",
"500",
")",
".",
"Therefore",
"this",
"will",
"retry",
"at",
"most",
"10",
"times",
"and",
"then",
"fail",
"(",
"depending",
"on",
"RPC",
"timeout",
")",
"and",
"may",
"be",
"more",
"useful",
"for",
"interactive",
"RPCs",
"than",
"the",
"default",
"timeout",
"of",
"60s",
"."
] | [
"func",
"New10sBackOff",
"(",
")",
"*",
"ExponentialBackOff",
"{",
"b",
":=",
"&",
"ExponentialBackOff",
"{",
"InitialInterval",
":",
"100",
"*",
"time",
".",
"Millisecond",
",",
"RandomizationFactor",
":",
"DefaultRandomizationFactor",
",",
"Multiplier",
":",
"DefaultMultiplier",
",",
"MaxInterval",
":",
"2",
"*",
"<mask>",
".",
"Second",
",",
"MaxElapsedTime",
":",
"10",
"*",
"time",
".",
"Second",
",",
"Clock",
":",
"SystemClock",
",",
"}",
"\n",
"return",
"b",
".",
"withCanonicalRandomizationFactor",
"(",
")",
".",
"withReset",
"(",
")",
"\n",
"}"
] |
16,223 | all-16224 | [
"bind",
"a",
"buffer",
"to",
"a",
"vertex",
"buffer",
"bind",
"point"
] | [
"func",
"VertexArrayVertexBuffer",
"(",
"vaobj",
"uint32",
",",
"bindingindex",
"uint32",
",",
"buffer",
"uint32",
",",
"offset",
"int",
",",
"stride",
"int32",
")",
"{",
"syscall",
".",
"Syscall6",
"(",
"gpVertexArrayVertexBuffer",
",",
"5",
",",
"uintptr",
"(",
"vaobj",
")",
",",
"uintptr",
"(",
"bindingindex",
")",
",",
"uintptr",
"(",
"buffer",
")",
",",
"uintptr",
"(",
"<mask>",
")",
",",
"uintptr",
"(",
"stride",
")",
",",
"0",
")",
"\n",
"}"
] |
16,224 | all-16225 | [
"GetString",
"is",
"a",
"wrapper",
"around",
"g_settings_get_string",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Settings",
")",
"GetString",
"(",
"name",
"string",
")",
"string",
"{",
"cstr1",
":=",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"C",
".",
"CString",
"(",
"<mask>",
")",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr1",
")",
")",
"\n\n",
"return",
"C",
".",
"GoString",
"(",
"(",
"*",
"C",
".",
"char",
")",
"(",
"C",
".",
"g_settings_get_string",
"(",
"v",
".",
"native",
"(",
")",
",",
"cstr1",
")",
")",
")",
"\n",
"}"
] |
16,225 | all-16226 | [
"WithFormat",
"format",
"(",
"defaults",
"to",
"mhtml",
")",
"."
] | [
"func",
"(",
"p",
"CaptureSnapshotParams",
")",
"WithFormat",
"(",
"<mask>",
"CaptureSnapshotFormat",
")",
"*",
"CaptureSnapshotParams",
"{",
"p",
".",
"Format",
"=",
"format",
"\n",
"return",
"&",
"p",
"\n",
"}"
] |
16,226 | all-16227 | [
"retrieve",
"a",
"sub",
"-",
"region",
"of",
"a",
"compressed",
"texture",
"image",
"from",
"a",
"compressed",
"texture",
"object"
] | [
"func",
"GetCompressedTextureSubImage",
"(",
"texture",
"uint32",
",",
"level",
"int32",
",",
"xoffset",
"int32",
",",
"yoffset",
"int32",
",",
"zoffset",
"int32",
",",
"width",
"int32",
",",
"<mask>",
"int32",
",",
"depth",
"int32",
",",
"bufSize",
"int32",
",",
"pixels",
"unsafe",
".",
"Pointer",
")",
"{",
"C",
".",
"glowGetCompressedTextureSubImage",
"(",
"gpGetCompressedTextureSubImage",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"texture",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"level",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"xoffset",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"yoffset",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"zoffset",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"width",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"height",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"depth",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"bufSize",
")",
",",
"pixels",
")",
"\n",
"}"
] |
16,227 | all-16228 | [
"ataIdentify",
"performs",
"an",
"ATA",
"identify",
"request",
"on",
"rs",
"using",
"the",
"argument",
"values",
"in",
"r",
"."
] | [
"func",
"ataIdentify",
"(",
"r",
"*",
"ATAArg",
",",
"rs",
"io",
".",
"ReadSeeker",
")",
"(",
"*",
"ATAArg",
",",
"error",
")",
"{",
"// Only ATA device identify allowed here",
"if",
"r",
".",
"CmdStatus",
"!=",
"ATACmdStatusIdentify",
"{",
"return",
"nil",
",",
"errATAAbort",
"\n",
"}",
"\n\n",
"// Request must be for 1 sector (512 bytes)",
"if",
"r",
".",
"SectorCount",
"!=",
"1",
"{",
"return",
"nil",
",",
"errATAAbort",
"\n",
"}",
"\n\n",
"// If rs is an Identifier, request its identity directly",
"ident",
",",
"<mask>",
":=",
"rs",
".",
"(",
"Identifier",
")",
"\n",
"if",
"!",
"ok",
"{",
"// Currently no generic Identify implementation, as is done in",
"// vblade.",
"// TODO(mdlayher): add generic Identify implementation",
"return",
"nil",
",",
"ErrNotImplemented",
"\n",
"}",
"\n\n",
"// Retrieve device identity information",
"id",
",",
"err",
":=",
"ident",
".",
"Identify",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"ATAArg",
"{",
"CmdStatus",
":",
"ATACmdStatusReadyStatus",
",",
"Data",
":",
"id",
"[",
":",
"]",
",",
"}",
",",
"nil",
"\n",
"}"
] |
16,228 | all-16229 | [
"getValues",
"unlinks",
"two",
"goroutines"
] | [
"func",
"getValues",
"(",
")",
"Values",
"{",
"gid",
":=",
"curGoroutineID",
"(",
")",
"\n",
"dataLock",
".",
"Lock",
"(",
")",
"\n",
"<mask>",
":=",
"data",
"[",
"gid",
"]",
"\n",
"dataLock",
".",
"Unlock",
"(",
")",
"\n",
"return",
"values",
"\n",
"}"
] |
16,229 | all-16230 | [
"GetHAlign",
"is",
"a",
"wrapper",
"around",
"gtk_widget_get_halign",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Widget",
")",
"GetHAlign",
"(",
")",
"Align",
"{",
"c",
":=",
"C",
".",
"gtk_widget_get_halign",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"<mask>",
"Align",
"(",
"c",
")",
"\n",
"}"
] |
16,230 | all-16231 | [
"Reset",
"resets",
"the",
"template",
"t",
"to",
"new",
"one",
"defined",
"by",
"template",
"startTag",
"and",
"endTag",
".",
"Reset",
"allows",
"Template",
"object",
"re",
"-",
"use",
".",
"Reset",
"may",
"be",
"called",
"only",
"if",
"no",
"other",
"goroutines",
"call",
"t",
"methods",
"at",
"the",
"moment",
"."
] | [
"func",
"(",
"t",
"*",
"<mask>",
")",
"Reset",
"(",
"template",
",",
"startTag",
",",
"endTag",
"string",
")",
"error",
"{",
"// Keep these vars in t, so GC won't collect them and won't break",
"// vars derived via unsafe*",
"t",
".",
"template",
"=",
"template",
"\n",
"t",
".",
"startTag",
"=",
"startTag",
"\n",
"t",
".",
"endTag",
"=",
"endTag",
"\n",
"t",
".",
"texts",
"=",
"t",
".",
"texts",
"[",
":",
"0",
"]",
"\n",
"t",
".",
"tags",
"=",
"t",
".",
"tags",
"[",
":",
"0",
"]",
"\n\n",
"if",
"len",
"(",
"startTag",
")",
"==",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"endTag",
")",
"==",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"s",
":=",
"unsafeString2Bytes",
"(",
"template",
")",
"\n",
"a",
":=",
"unsafeString2Bytes",
"(",
"startTag",
")",
"\n",
"b",
":=",
"unsafeString2Bytes",
"(",
"endTag",
")",
"\n\n",
"tagsCount",
":=",
"bytes",
".",
"Count",
"(",
"s",
",",
"a",
")",
"\n",
"if",
"tagsCount",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"tagsCount",
"+",
"1",
">",
"cap",
"(",
"t",
".",
"texts",
")",
"{",
"t",
".",
"texts",
"=",
"make",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"0",
",",
"tagsCount",
"+",
"1",
")",
"\n",
"}",
"\n",
"if",
"tagsCount",
">",
"cap",
"(",
"t",
".",
"tags",
")",
"{",
"t",
".",
"tags",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"tagsCount",
")",
"\n",
"}",
"\n\n",
"for",
"{",
"n",
":=",
"bytes",
".",
"Index",
"(",
"s",
",",
"a",
")",
"\n",
"if",
"n",
"<",
"0",
"{",
"t",
".",
"texts",
"=",
"append",
"(",
"t",
".",
"texts",
",",
"s",
")",
"\n",
"break",
"\n",
"}",
"\n",
"t",
".",
"texts",
"=",
"append",
"(",
"t",
".",
"texts",
",",
"s",
"[",
":",
"n",
"]",
")",
"\n\n",
"s",
"=",
"s",
"[",
"n",
"+",
"len",
"(",
"a",
")",
":",
"]",
"\n",
"n",
"=",
"bytes",
".",
"Index",
"(",
"s",
",",
"b",
")",
"\n",
"if",
"n",
"<",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"endTag",
",",
"template",
",",
"s",
")",
"\n",
"}",
"\n\n",
"t",
".",
"tags",
"=",
"append",
"(",
"t",
".",
"tags",
",",
"unsafeBytes2String",
"(",
"s",
"[",
":",
"n",
"]",
")",
")",
"\n",
"s",
"=",
"s",
"[",
"n",
"+",
"len",
"(",
"b",
")",
":",
"]",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
16,231 | all-16232 | [
"set",
"the",
"active",
"program",
"object",
"for",
"a",
"program",
"pipeline",
"object"
] | [
"func",
"ActiveShaderProgram",
"(",
"pipeline",
"uint32",
",",
"program",
"uint32",
")",
"{",
"C",
".",
"glowActiveShaderProgram",
"(",
"gpActiveShaderProgram",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"pipeline",
")",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"<mask>",
")",
")",
"\n",
"}"
] |
16,232 | all-16233 | [
"ParseExpr",
"returns",
"the",
"expression",
"parsed",
"from",
"the",
"input",
"."
] | [
"func",
"ParseExpr",
"(",
"input",
"string",
")",
"(",
"Expr",
",",
"error",
")",
"{",
"p",
":=",
"newParser",
"(",
"<mask>",
")",
"\n\n",
"expr",
",",
"err",
":=",
"p",
".",
"parseExpr",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"err",
"=",
"p",
".",
"typecheck",
"(",
"expr",
")",
"\n",
"return",
"expr",
",",
"err",
"\n",
"}"
] |
16,233 | all-16234 | [
"condRelease",
"releases",
"this",
"connection",
"if",
"the",
"error",
"pointed",
"to",
"by",
"err",
"is",
"is",
"nil",
"(",
"not",
"an",
"error",
")",
"or",
"is",
"only",
"a",
"protocol",
"level",
"error",
"(",
"e",
".",
"g",
".",
"a",
"cache",
"miss",
")",
".",
"The",
"purpose",
"is",
"to",
"not",
"recycle",
"TCP",
"connections",
"that",
"are",
"bad",
"."
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"condRelease",
"(",
"cn",
"*",
"conn",
",",
"err",
"*",
"error",
")",
"{",
"switch",
"*",
"err",
"{",
"<mask>",
"nil",
",",
"ErrCacheMiss",
",",
"ErrCASConflict",
",",
"ErrNotStored",
",",
"ErrBadIncrDec",
":",
"c",
".",
"putFreeConn",
"(",
"cn",
")",
"\n",
"default",
":",
"cn",
".",
"nc",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"}"
] |
16,234 | all-16235 | [
"SetConfigFromFlags",
"initializes",
"the",
"driver",
"based",
"on",
"the",
"command",
"line",
"flags",
"."
] | [
"func",
"(",
"d",
"*",
"Driver",
")",
"SetConfigFromFlags",
"(",
"flags",
"drivers",
".",
"DriverOptions",
")",
"error",
"{",
"d",
".",
"Project",
"=",
"flags",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"if",
"d",
".",
"Project",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"d",
".",
"Zone",
"=",
"flags",
".",
"<mask>",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"UseExisting",
"=",
"flags",
".",
"Bool",
"(",
"\"",
"\"",
")",
"\n",
"if",
"!",
"d",
".",
"UseExisting",
"{",
"d",
".",
"MachineType",
"=",
"flags",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"MachineImage",
"=",
"flags",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"MachineImage",
"=",
"strings",
".",
"TrimPrefix",
"(",
"d",
".",
"MachineImage",
",",
"\"",
"\"",
")",
"\n",
"d",
".",
"DiskSize",
"=",
"flags",
".",
"Int",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"DiskType",
"=",
"flags",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"Address",
"=",
"flags",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"Network",
"=",
"flags",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"Subnetwork",
"=",
"flags",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"Preemptible",
"=",
"flags",
".",
"Bool",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"UseInternalIP",
"=",
"flags",
".",
"Bool",
"(",
"\"",
"\"",
")",
"||",
"flags",
".",
"Bool",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"UseInternalIPOnly",
"=",
"flags",
".",
"Bool",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"ServiceAccount",
"=",
"flags",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"Scopes",
"=",
"flags",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"Tags",
"=",
"flags",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"OpenPorts",
"=",
"flags",
".",
"StringSlice",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"d",
".",
"SSHUser",
"=",
"flags",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"d",
".",
"SSHPort",
"=",
"22",
"\n",
"d",
".",
"SetSwarmConfigFromFlags",
"(",
"flags",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
16,235 | all-16236 | [
"saveEntity",
"saves",
"an",
"EntityProto",
"into",
"a",
"PropertyLoadSaver",
"or",
"struct",
"pointer",
"."
] | [
"func",
"saveEntity",
"(",
"defaultAppID",
"string",
",",
"key",
"*",
"Key",
",",
"src",
"interface",
"{",
"}",
")",
"(",
"*",
"pb",
".",
"EntityProto",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"props",
"[",
"]",
"Property",
"\n",
"if",
"e",
",",
"ok",
":=",
"src",
".",
"(",
"PropertyLoadSaver",
")",
";",
"ok",
"{",
"props",
",",
"err",
"=",
"e",
".",
"Save",
"(",
")",
"\n",
"}",
"else",
"{",
"props",
",",
"err",
"=",
"SaveStruct",
"(",
"src",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"propertiesToProto",
"(",
"defaultAppID",
",",
"<mask>",
",",
"props",
")",
"\n",
"}"
] |
16,236 | all-16237 | [
"Step",
"2",
"is",
"the",
"stemming",
"of",
"various",
"endings",
"found",
"in",
"R1",
"including",
"al",
"ness",
"and",
"li",
"."
] | [
"func",
"step2",
"(",
"w",
"*",
"snowballword",
".",
"SnowballWord",
")",
"bool",
"{",
"// Possible sufficies for this step, longest first.",
"suffix",
",",
"suffixRunes",
":=",
"w",
".",
"FirstSuffix",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
")",
"\n\n",
"// If it is not in R1, do nothing",
"if",
"suffix",
"==",
"\"",
"\"",
"||",
"len",
"(",
"suffixRunes",
")",
">",
"len",
"(",
"w",
".",
"RS",
")",
"-",
"w",
".",
"R1start",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"// Handle special cases where we're not just going to",
"// replace the suffix with another suffix: there are",
"// other things we need to do.",
"//",
"switch",
"suffix",
"{",
"case",
"\"",
"\"",
":",
"// Delete if preceded by a valid li-ending. Valid li-endings inlude the",
"// following charaters: cdeghkmnrt. (Note, the unicode code points for",
"// these characters are, respectively, as follows:",
"// 99 100 101 103 104 107 109 110 114 116)",
"//",
"rsLen",
":=",
"len",
"(",
"w",
".",
"RS",
")",
"\n",
"if",
"rsLen",
">=",
"3",
"{",
"<mask>",
"w",
".",
"RS",
"[",
"rsLen",
"-",
"3",
"]",
"{",
"case",
"99",
",",
"100",
",",
"101",
",",
"103",
",",
"104",
",",
"107",
",",
"109",
",",
"110",
",",
"114",
",",
"116",
":",
"w",
".",
"RemoveLastNRunes",
"(",
"len",
"(",
"suffixRunes",
")",
")",
"\n",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n\n",
"case",
"\"",
"\"",
":",
"// Replace by og if preceded by l.",
"// (Note, the unicode code point for l is 108)",
"//",
"rsLen",
":=",
"len",
"(",
"w",
".",
"RS",
")",
"\n",
"if",
"rsLen",
">=",
"4",
"&&",
"w",
".",
"RS",
"[",
"rsLen",
"-",
"4",
"]",
"==",
"108",
"{",
"w",
".",
"ReplaceSuffixRunes",
"(",
"suffixRunes",
",",
"[",
"]",
"rune",
"(",
"\"",
"\"",
")",
",",
"true",
")",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}",
"\n\n",
"// Handle a suffix that was found, which is going",
"// to be replaced with a different suffix.",
"//",
"var",
"repl",
"string",
"\n",
"switch",
"suffix",
"{",
"case",
"\"",
"\"",
":",
"repl",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
":",
"repl",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
":",
"repl",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
":",
"repl",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
":",
"repl",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
",",
"\"",
"\"",
":",
"repl",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
":",
"repl",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
":",
"repl",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
":",
"repl",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
",",
"\"",
"\"",
":",
"repl",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
",",
"\"",
"\"",
":",
"repl",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
",",
"\"",
"\"",
":",
"repl",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
":",
"repl",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
":",
"repl",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"w",
".",
"ReplaceSuffixRunes",
"(",
"suffixRunes",
",",
"[",
"]",
"rune",
"(",
"repl",
")",
",",
"true",
")",
"\n",
"return",
"true",
"\n\n",
"}"
] |
16,237 | all-16238 | [
"WithBody",
"adds",
"the",
"body",
"to",
"the",
"order",
"Vm",
"by",
"filter",
"params"
] | [
"func",
"(",
"o",
"*",
"OrderVMByFilterParams",
")",
"WithBody",
"(",
"body",
"*",
"models",
".",
"VMFilter",
")",
"*",
"OrderVMByFilterParams",
"{",
"o",
".",
"SetBody",
"(",
"<mask>",
")",
"\n",
"return",
"o",
"\n",
"}"
] |
16,238 | all-16239 | [
"GetType",
"returns",
"the",
"Type",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"f",
"*",
"FreeTextDefinition",
")",
"GetType",
"(",
")",
"string",
"{",
"if",
"f",
"==",
"nil",
"||",
"f",
".",
"<mask>",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"f",
".",
"Type",
"\n",
"}"
] |
16,239 | all-16240 | [
"Image",
"copies",
"image",
"from",
"srcRef",
"to",
"destRef",
"using",
"policyContext",
"to",
"validate",
"source",
"image",
"admissibility",
".",
"It",
"returns",
"the",
"manifest",
"which",
"was",
"written",
"to",
"the",
"new",
"copy",
"of",
"the",
"image",
"."
] | [
"func",
"Image",
"(",
"ctx",
"context",
".",
"Context",
",",
"policyContext",
"*",
"signature",
".",
"PolicyContext",
",",
"destRef",
",",
"srcRef",
"types",
".",
"ImageReference",
",",
"options",
"*",
"Options",
")",
"(",
"manifest",
"[",
"]",
"byte",
",",
"retErr",
"error",
")",
"{",
"// NOTE this function uses an output parameter for the error return value.",
"// Setting this and returning is the ideal way to return an error.",
"//",
"// the defers in this routine will wrap the error return with its own errors",
"// which can be valuable context in the middle of a multi-streamed copy.",
"if",
"options",
"==",
"nil",
"{",
"options",
"=",
"&",
"Options",
"{",
"}",
"\n",
"}",
"\n\n",
"reportWriter",
":=",
"ioutil",
".",
"Discard",
"\n\n",
"if",
"options",
".",
"ReportWriter",
"!=",
"nil",
"{",
"reportWriter",
"=",
"<mask>",
".",
"ReportWriter",
"\n",
"}",
"\n\n",
"dest",
",",
"err",
":=",
"destRef",
".",
"NewImageDestination",
"(",
"ctx",
",",
"options",
".",
"DestinationCtx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"transports",
".",
"ImageName",
"(",
"destRef",
")",
")",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
":=",
"dest",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"retErr",
"=",
"errors",
".",
"Wrapf",
"(",
"retErr",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"rawSource",
",",
"err",
":=",
"srcRef",
".",
"NewImageSource",
"(",
"ctx",
",",
"options",
".",
"SourceCtx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"transports",
".",
"ImageName",
"(",
"srcRef",
")",
")",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
":=",
"rawSource",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"retErr",
"=",
"errors",
".",
"Wrapf",
"(",
"retErr",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"// If reportWriter is not a TTY (e.g., when piping to a file), do not",
"// print the progress bars to avoid long and hard to parse output.",
"// createProgressBar() will print a single line instead.",
"progressOutput",
":=",
"reportWriter",
"\n",
"if",
"!",
"isTTY",
"(",
"reportWriter",
")",
"{",
"progressOutput",
"=",
"ioutil",
".",
"Discard",
"\n",
"}",
"\n",
"copyInParallel",
":=",
"dest",
".",
"HasThreadSafePutBlob",
"(",
")",
"&&",
"rawSource",
".",
"HasThreadSafeGetBlob",
"(",
")",
"\n",
"c",
":=",
"&",
"copier",
"{",
"dest",
":",
"dest",
",",
"rawSource",
":",
"rawSource",
",",
"reportWriter",
":",
"reportWriter",
",",
"progressOutput",
":",
"progressOutput",
",",
"progressInterval",
":",
"options",
".",
"ProgressInterval",
",",
"progress",
":",
"options",
".",
"Progress",
",",
"copyInParallel",
":",
"copyInParallel",
",",
"// FIXME? The cache is used for sources and destinations equally, but we only have a SourceCtx and DestinationCtx.",
"// For now, use DestinationCtx (because blob reuse changes the behavior of the destination side more); eventually",
"// we might want to add a separate CommonCtx — or would that be too confusing?",
"blobInfoCache",
":",
"blobinfocache",
".",
"DefaultCache",
"(",
"options",
".",
"DestinationCtx",
")",
",",
"}",
"\n\n",
"unparsedToplevel",
":=",
"image",
".",
"UnparsedInstance",
"(",
"rawSource",
",",
"nil",
")",
"\n",
"multiImage",
",",
"err",
":=",
"isMultiImage",
"(",
"ctx",
",",
"unparsedToplevel",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"transports",
".",
"ImageName",
"(",
"srcRef",
")",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"multiImage",
"{",
"// The simple case: Just copy a single image.",
"if",
"manifest",
",",
"err",
"=",
"c",
".",
"copyOneImage",
"(",
"ctx",
",",
"policyContext",
",",
"options",
",",
"unparsedToplevel",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// This is a manifest list. Choose a single image and copy it.",
"// FIXME: Copy to destinations which support manifest lists, one image at a time.",
"instanceDigest",
",",
"err",
":=",
"image",
".",
"ChooseManifestInstanceFromManifestList",
"(",
"ctx",
",",
"options",
".",
"SourceCtx",
",",
"unparsedToplevel",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"transports",
".",
"ImageName",
"(",
"srcRef",
")",
")",
"\n",
"}",
"\n",
"logrus",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"instanceDigest",
")",
"\n",
"unparsedInstance",
":=",
"image",
".",
"UnparsedInstance",
"(",
"rawSource",
",",
"&",
"instanceDigest",
")",
"\n\n",
"if",
"manifest",
",",
"err",
"=",
"c",
".",
"copyOneImage",
"(",
"ctx",
",",
"policyContext",
",",
"options",
",",
"unparsedInstance",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"c",
".",
"dest",
".",
"Commit",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"manifest",
",",
"nil",
"\n",
"}"
] |
16,240 | all-16241 | [
"AppendEntries",
"sends",
"the",
"appropriate",
"RPC",
"to",
"the",
"target",
"node",
"."
] | [
"func",
"(",
"t",
"*",
"transport",
")",
"AppendEntries",
"(",
"<mask>",
"raft",
".",
"ServerID",
",",
"target",
"raft",
".",
"ServerAddress",
",",
"args",
"*",
"raft",
".",
"AppendEntriesRequest",
",",
"resp",
"*",
"raft",
".",
"AppendEntriesResponse",
")",
"error",
"{",
"ae",
":=",
"appendEntries",
"{",
"source",
":",
"t",
".",
"node",
",",
"target",
":",
"target",
",",
"firstIndex",
":",
"firstIndex",
"(",
"args",
")",
",",
"lastIndex",
":",
"lastIndex",
"(",
"args",
")",
",",
"commitIndex",
":",
"args",
".",
"LeaderCommitIndex",
",",
"}",
"\n",
"if",
"len",
"(",
"t",
".",
"ae",
")",
"<",
"cap",
"(",
"t",
".",
"ae",
")",
"{",
"t",
".",
"ae",
"=",
"append",
"(",
"t",
".",
"ae",
",",
"ae",
")",
"\n",
"}",
"\n",
"return",
"t",
".",
"sendRPC",
"(",
"string",
"(",
"target",
")",
",",
"args",
",",
"resp",
")",
"\n",
"}"
] |
16,241 | all-16242 | [
"Sum",
"appends",
"the",
"current",
"hash",
"to",
"b",
"and",
"returns",
"the",
"resulting",
"slice",
".",
"It",
"does",
"not",
"change",
"the",
"underlying",
"hash",
"state",
"."
] | [
"func",
"(",
"xx",
"*",
"XXHash32",
")",
"Sum",
"(",
"in",
"[",
"]",
"<mask>",
")",
"[",
"]",
"byte",
"{",
"s",
":=",
"xx",
".",
"Sum32",
"(",
")",
"\n",
"return",
"append",
"(",
"in",
",",
"byte",
"(",
"s",
">>",
"24",
")",
",",
"byte",
"(",
"s",
">>",
"16",
")",
",",
"byte",
"(",
"s",
">>",
"8",
")",
",",
"byte",
"(",
"s",
")",
")",
"\n",
"}"
] |
16,242 | all-16243 | [
"prowJobStatus",
"returns",
"the",
"desired",
"state",
"and",
"description",
"based",
"on",
"the",
"pipeline",
"status"
] | [
"func",
"prowJobStatus",
"(",
"ps",
"pipelinev1alpha1",
".",
"PipelineRunStatus",
")",
"(",
"prowjobv1",
".",
"ProwJobState",
",",
"string",
")",
"{",
"started",
":=",
"ps",
".",
"StartTime",
"\n",
"finished",
":=",
"ps",
".",
"CompletionTime",
"\n",
"pcond",
":=",
"ps",
".",
"GetCondition",
"(",
"duckv1alpha1",
".",
"ConditionSucceeded",
")",
"\n",
"if",
"pcond",
"==",
"nil",
"{",
"if",
"!",
"finished",
".",
"IsZero",
"(",
")",
"{",
"return",
"prowjobv1",
".",
"ErrorState",
",",
"descMissingCondition",
"\n",
"}",
"\n",
"return",
"prowjobv1",
".",
"TriggeredState",
",",
"descScheduling",
"\n",
"}",
"\n",
"cond",
":=",
"*",
"pcond",
"\n",
"switch",
"{",
"case",
"cond",
".",
"Status",
"==",
"untypedcorev1",
".",
"ConditionTrue",
":",
"return",
"prowjobv1",
".",
"SuccessState",
",",
"description",
"(",
"cond",
",",
"descSucceeded",
")",
"\n",
"<mask>",
"cond",
".",
"Status",
"==",
"untypedcorev1",
".",
"ConditionFalse",
":",
"return",
"prowjobv1",
".",
"FailureState",
",",
"description",
"(",
"cond",
",",
"descFailed",
")",
"\n",
"case",
"started",
".",
"IsZero",
"(",
")",
":",
"return",
"prowjobv1",
".",
"TriggeredState",
",",
"description",
"(",
"cond",
",",
"descInitializing",
")",
"\n",
"case",
"cond",
".",
"Status",
"==",
"untypedcorev1",
".",
"ConditionUnknown",
",",
"finished",
".",
"IsZero",
"(",
")",
":",
"return",
"prowjobv1",
".",
"PendingState",
",",
"description",
"(",
"cond",
",",
"descRunning",
")",
"\n",
"}",
"\n\n",
"logrus",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"cond",
")",
"\n",
"return",
"prowjobv1",
".",
"ErrorState",
",",
"description",
"(",
"cond",
",",
"descUnknown",
")",
"// shouldn't happen",
"\n",
"}"
] |
16,243 | all-16244 | [
"GetObject",
"gets",
"an",
"object",
"out",
"of",
"the",
"object",
"store",
"by",
"hash",
"."
] | [
"func",
"(",
"c",
"APIClient",
")",
"GetObject",
"(",
"<mask>",
"string",
",",
"writer",
"io",
".",
"Writer",
")",
"error",
"{",
"getObjectClient",
",",
"err",
":=",
"c",
".",
"ObjectAPIClient",
".",
"GetObject",
"(",
"c",
".",
"Ctx",
"(",
")",
",",
"&",
"pfs",
".",
"Object",
"{",
"Hash",
":",
"hash",
"}",
",",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"grpcutil",
".",
"WriteFromStreamingBytesClient",
"(",
"getObjectClient",
",",
"writer",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
16,244 | all-16245 | [
"HasThresholds",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"o",
"*",
"Options",
")",
"HasThresholds",
"(",
")",
"bool",
"{",
"if",
"o",
"!=",
"nil",
"&&",
"o",
".",
"Thresholds",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
16,245 | all-16246 | [
"FromTime",
"returns",
"a",
"new",
"millisecond",
"timestamp",
"from",
"a",
"time",
"."
] | [
"func",
"FromTime",
"(",
"t",
"time",
".",
"Time",
")",
"int64",
"{",
"return",
"t",
".",
"Unix",
"(",
")",
"*",
"1000",
"+",
"int64",
"(",
"t",
".",
"Nanosecond",
"(",
")",
")",
"/",
"int64",
"(",
"<mask>",
".",
"Millisecond",
")",
"\n",
"}"
] |
16,246 | all-16247 | [
"Checks",
"to",
"see",
"if",
"someone",
"has",
"tried",
"to",
"submit",
"a",
"JSON",
"string",
"for",
"an",
"object",
"which",
"is",
"no",
"longer",
"supported"
] | [
"func",
"isJSONFormattedObject",
"(",
"stringOrObject",
"interface",
"{",
"}",
")",
"bool",
"{",
"switch",
"content",
":=",
"stringOrObject",
".",
"(",
"type",
")",
"{",
"case",
"[",
"]",
"byte",
":",
"<mask>",
"string",
":",
"var",
"obj",
"interface",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"content",
")",
",",
"&",
"obj",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"// Check if a map type",
"if",
"_",
",",
"ok",
":=",
"obj",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
";",
"ok",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
16,247 | all-16248 | [
"Parse",
"a",
"string",
"into",
"the",
"appropriate",
"format",
"representation",
"type",
".",
"E",
".",
"g",
".",
"parsing",
"a",
"string",
"a",
"date",
"will",
"return",
"a",
"Date",
"type",
"."
] | [
"func",
"(",
"f",
"*",
"defaultFormats",
")",
"Parse",
"(",
"name",
",",
"data",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"f",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"Unlock",
"(",
")",
"\n",
"nme",
":=",
"f",
".",
"normalizeName",
"(",
"name",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"f",
".",
"data",
"{",
"if",
"v",
".",
"Name",
"==",
"nme",
"{",
"nw",
":=",
"reflect",
".",
"New",
"(",
"v",
".",
"Type",
")",
".",
"Interface",
"(",
")",
"\n",
"if",
"dec",
",",
"ok",
":=",
"nw",
".",
"(",
"encoding",
".",
"TextUnmarshaler",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"dec",
".",
"UnmarshalText",
"(",
"[",
"]",
"byte",
"(",
"data",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"nw",
",",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
",",
"errors",
".",
"InvalidTypeName",
"(",
"name",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
",",
"errors",
".",
"InvalidTypeName",
"(",
"<mask>",
")",
"\n",
"}"
] |
16,248 | all-16249 | [
"StopJob",
"stops",
"a",
"job",
"."
] | [
"func",
"(",
"c",
"APIClient",
")",
"StopJob",
"(",
"jobID",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"PpsAPIClient",
".",
"StopJob",
"(",
"c",
".",
"Ctx",
"(",
")",
",",
"&",
"pps",
".",
"StopJobRequest",
"{",
"<mask>",
":",
"NewJob",
"(",
"jobID",
")",
",",
"}",
",",
")",
"\n",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}"
] |
16,249 | all-16250 | [
"DeactivateCmd",
"returns",
"a",
"cobra",
".",
"Command",
"to",
"delete",
"all",
"ACLs",
"tokens",
"and",
"admins",
"deactivating",
"Pachyderm",
"s",
"auth",
"system"
] | [
"func",
"DeactivateCmd",
"(",
"noMetrics",
",",
"noPortForwarding",
"*",
"bool",
")",
"*",
"cobra",
".",
"Command",
"{",
"deactivate",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Short",
":",
"\"",
"\"",
",",
"Long",
":",
"\"",
"\"",
"+",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"Run",
":",
"cmdutil",
".",
"Run",
"(",
"func",
"(",
"args",
"[",
"]",
"string",
")",
"error",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
")",
"\n",
"confirm",
",",
"err",
":=",
"bufio",
".",
"NewReader",
"(",
"os",
".",
"Stdin",
")",
".",
"ReadString",
"(",
"'\\n'",
")",
"\n",
"if",
"!",
"strings",
".",
"Contains",
"(",
"\"",
"\"",
",",
"confirm",
"[",
":",
"1",
"]",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"c",
",",
"err",
":=",
"<mask>",
".",
"NewOnUserMachine",
"(",
"!",
"*",
"noMetrics",
",",
"!",
"*",
"noPortForwarding",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"defer",
"c",
".",
"Close",
"(",
")",
"\n",
"_",
",",
"err",
"=",
"c",
".",
"Deactivate",
"(",
"c",
".",
"Ctx",
"(",
")",
",",
"&",
"auth",
".",
"DeactivateRequest",
"{",
"}",
")",
"\n",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}",
")",
",",
"}",
"\n",
"return",
"cmdutil",
".",
"CreateAlias",
"(",
"deactivate",
",",
"\"",
"\"",
")",
"\n",
"}"
] |
16,250 | all-16251 | [
"printUsage",
"prints",
"usageTemplate",
"to",
"w",
"."
] | [
"func",
"printUsage",
"(",
"w",
"io",
".",
"<mask>",
")",
"{",
"bw",
":=",
"bufio",
".",
"NewWriter",
"(",
"w",
")",
"\n",
"tmpl",
"(",
"bw",
",",
"usageTemplate",
",",
"commands",
")",
"\n",
"bw",
".",
"Flush",
"(",
")",
"\n",
"}"
] |
16,251 | all-16252 | [
"GetChars",
"is",
"a",
"wrapper",
"around",
"gtk_editable_get_chars",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Editable",
")",
"GetChars",
"(",
"startPos",
",",
"endPos",
"int",
")",
"string",
"{",
"c",
":=",
"C",
".",
"gtk_editable_get_chars",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"gint",
"(",
"startPos",
")",
",",
"C",
".",
"gint",
"(",
"endPos",
")",
")",
"\n",
"defer",
"C",
".",
"<mask>",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
"\n",
"return",
"goString",
"(",
"c",
")",
"\n",
"}"
] |
16,252 | all-16253 | [
"Get",
"returns",
"a",
"peer",
"from",
"the",
"peer",
"list",
"or",
"nil",
"if",
"none",
"can",
"be",
"found",
"will",
"avoid",
"previously",
"selected",
"peers",
"if",
"possible",
"."
] | [
"func",
"(",
"l",
"*",
"PeerList",
")",
"Get",
"(",
"prevSelected",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")",
"(",
"*",
"Peer",
",",
"error",
")",
"{",
"peer",
",",
"err",
":=",
"l",
".",
"GetNew",
"(",
"prevSelected",
")",
"\n",
"if",
"err",
"==",
"ErrNoNewPeers",
"{",
"l",
".",
"Lock",
"(",
")",
"\n",
"peer",
"=",
"l",
".",
"choosePeer",
"(",
"nil",
",",
"false",
"/* avoidHost */",
")",
"\n",
"l",
".",
"Unlock",
"(",
")",
"\n",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"peer",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrNoPeers",
"\n",
"}",
"\n",
"return",
"<mask>",
",",
"nil",
"\n",
"}"
] |
16,253 | all-16254 | [
"GetOrderOk",
"returns",
"a",
"tuple",
"with",
"the",
"Order",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"a",
"*",
"ApmOrLogQueryGroupBySort",
")",
"GetOrderOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"a",
"==",
"nil",
"||",
"a",
".",
"Order",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"a",
".",
"Order",
",",
"<mask>",
"\n",
"}"
] |
16,254 | all-16255 | [
"isEmpty",
"returns",
"whether",
"printing",
"a",
"will",
"not",
"print",
"anything",
"."
] | [
"func",
"(",
"ps",
"*",
"printState",
")",
"isEmpty",
"(",
"a",
"AST",
")",
"bool",
"{",
"switch",
"a",
":=",
"a",
".",
"(",
"type",
")",
"{",
"case",
"*",
"ArgumentPack",
":",
"return",
"len",
"(",
"a",
".",
"Args",
")",
"==",
"0",
"\n",
"<mask>",
"*",
"ExprList",
":",
"return",
"len",
"(",
"a",
".",
"Exprs",
")",
"==",
"0",
"\n",
"case",
"*",
"PackExpansion",
":",
"return",
"a",
".",
"Pack",
"!=",
"nil",
"&&",
"ps",
".",
"isEmpty",
"(",
"a",
".",
"Base",
")",
"\n",
"default",
":",
"return",
"false",
"\n",
"}",
"\n",
"}"
] |
16,255 | all-16256 | [
"HasId",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"d",
"*",
"DashboardLite",
")",
"HasId",
"(",
")",
"bool",
"{",
"if",
"d",
"!=",
"nil",
"&&",
"d",
".",
"Id",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
16,256 | all-16257 | [
"d",
".",
"prepare",
"initializes",
"and",
"dereferences",
"pointers",
"and",
"calls",
"UnmarshalYAML",
"if",
"a",
"value",
"is",
"found",
"to",
"implement",
"it",
".",
"It",
"returns",
"the",
"initialized",
"and",
"dereferenced",
"out",
"value",
"whether",
"unmarshalling",
"was",
"already",
"done",
"by",
"UnmarshalYAML",
"and",
"if",
"so",
"whether",
"its",
"types",
"unmarshalled",
"appropriately",
".",
"If",
"n",
"holds",
"a",
"null",
"value",
"prepare",
"returns",
"before",
"doing",
"anything",
"."
] | [
"func",
"(",
"d",
"*",
"decoder",
")",
"prepare",
"(",
"n",
"*",
"node",
",",
"out",
"reflect",
".",
"Value",
")",
"(",
"newout",
"reflect",
".",
"Value",
",",
"unmarshaled",
",",
"good",
"bool",
")",
"{",
"if",
"n",
".",
"tag",
"==",
"yaml_NULL_TAG",
"||",
"n",
".",
"kind",
"==",
"scalarNode",
"&&",
"n",
".",
"tag",
"==",
"\"",
"\"",
"&&",
"(",
"n",
".",
"value",
"==",
"\"",
"\"",
"||",
"n",
".",
"value",
"==",
"\"",
"\"",
"||",
"n",
".",
"value",
"==",
"\"",
"\"",
"&&",
"n",
".",
"implicit",
")",
"{",
"return",
"out",
",",
"false",
",",
"<mask>",
"\n",
"}",
"\n",
"again",
":=",
"true",
"\n",
"for",
"again",
"{",
"again",
"=",
"false",
"\n",
"if",
"out",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Ptr",
"{",
"if",
"out",
".",
"IsNil",
"(",
")",
"{",
"out",
".",
"Set",
"(",
"reflect",
".",
"New",
"(",
"out",
".",
"Type",
"(",
")",
".",
"Elem",
"(",
")",
")",
")",
"\n",
"}",
"\n",
"out",
"=",
"out",
".",
"Elem",
"(",
")",
"\n",
"again",
"=",
"true",
"\n",
"}",
"\n",
"if",
"out",
".",
"CanAddr",
"(",
")",
"{",
"if",
"u",
",",
"ok",
":=",
"out",
".",
"Addr",
"(",
")",
".",
"Interface",
"(",
")",
".",
"(",
"Unmarshaler",
")",
";",
"ok",
"{",
"good",
"=",
"d",
".",
"callUnmarshaler",
"(",
"n",
",",
"u",
")",
"\n",
"return",
"out",
",",
"true",
",",
"good",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"out",
",",
"false",
",",
"false",
"\n",
"}"
] |
16,257 | all-16258 | [
"Execute",
"runs",
"the",
"lint",
"against",
"a",
"certificate",
".",
"For",
"lints",
"that",
"are",
"sourced",
"from",
"the",
"CA",
"/",
"B",
"Forum",
"Baseline",
"Requirements",
"we",
"first",
"determine",
"if",
"they",
"are",
"within",
"the",
"purview",
"of",
"the",
"BRs",
".",
"See",
"LintInterface",
"for",
"details",
"about",
"the",
"other",
"methods",
"called",
".",
"The",
"ordering",
"is",
"as",
"follows",
":",
"CheckApplies",
"()",
"CheckEffective",
"()",
"Execute",
"()"
] | [
"func",
"(",
"l",
"*",
"Lint",
")",
"Execute",
"(",
"cert",
"*",
"x509",
".",
"Certificate",
")",
"*",
"LintResult",
"{",
"if",
"l",
".",
"Source",
"==",
"CABFBaselineRequirements",
"&&",
"!",
"util",
".",
"IsServerAuthCert",
"(",
"<mask>",
")",
"{",
"return",
"&",
"LintResult",
"{",
"Status",
":",
"NA",
"}",
"\n",
"}",
"\n",
"if",
"!",
"l",
".",
"Lint",
".",
"CheckApplies",
"(",
"cert",
")",
"{",
"return",
"&",
"LintResult",
"{",
"Status",
":",
"NA",
"}",
"\n",
"}",
"else",
"if",
"!",
"l",
".",
"CheckEffective",
"(",
"cert",
")",
"{",
"return",
"&",
"LintResult",
"{",
"Status",
":",
"NE",
"}",
"\n",
"}",
"\n",
"res",
":=",
"l",
".",
"Lint",
".",
"Execute",
"(",
"cert",
")",
"\n",
"return",
"res",
"\n",
"}"
] |
16,258 | all-16259 | [
"Registry",
"returns",
"the",
"list",
"of",
"registered",
"provisioners",
"."
] | [
"func",
"Registry",
"(",
")",
"(",
"[",
"]",
"Provisioner",
",",
"error",
")",
"{",
"registry",
":=",
"<mask>",
"(",
"[",
"]",
"Provisioner",
",",
"0",
",",
"len",
"(",
"provisioners",
")",
")",
"\n",
"for",
"_",
",",
"pFunc",
":=",
"range",
"provisioners",
"{",
"p",
",",
"err",
":=",
"pFunc",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"registry",
"=",
"append",
"(",
"registry",
",",
"p",
")",
"\n",
"}",
"\n",
"return",
"registry",
",",
"nil",
"\n",
"}"
] |
16,259 | all-16260 | [
"RemoveFilter",
"is",
"a",
"wrapper",
"around",
"gtk_file_chooser_remove_filter",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"FileChooser",
")",
"RemoveFilter",
"(",
"filter",
"*",
"FileFilter",
")",
"{",
"C",
".",
"gtk_file_chooser_remove_filter",
"(",
"v",
".",
"native",
"(",
")",
",",
"<mask>",
".",
"native",
"(",
")",
")",
"\n",
"}"
] |
16,260 | all-16261 | [
"validateAttachTaskNetworkInterfacesMessage",
"performs",
"validation",
"checks",
"on",
"the",
"AttachTaskNetworkInterfacesMessage"
] | [
"func",
"validateAttachTaskNetworkInterfacesMessage",
"(",
"message",
"*",
"ecsacs",
".",
"AttachTaskNetworkInterfacesMessage",
")",
"error",
"{",
"if",
"message",
"==",
"nil",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"messageId",
":=",
"aws",
".",
"StringValue",
"(",
"message",
".",
"MessageId",
")",
"\n",
"if",
"messageId",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"clusterArn",
":=",
"aws",
".",
"StringValue",
"(",
"message",
".",
"ClusterArn",
")",
"\n",
"if",
"clusterArn",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"containerInstanceArn",
":=",
"aws",
".",
"StringValue",
"(",
"message",
".",
"ContainerInstanceArn",
")",
"\n",
"if",
"containerInstanceArn",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"enis",
":=",
"message",
".",
"ElasticNetworkInterfaces",
"\n",
"if",
"len",
"(",
"enis",
")",
"!=",
"1",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len",
"(",
"enis",
")",
")",
"\n",
"}",
"\n\n",
"eni",
":=",
"enis",
"[",
"0",
"]",
"\n",
"if",
"aws",
".",
"StringValue",
"(",
"eni",
".",
"MacAddress",
")",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"taskArn",
":=",
"aws",
".",
"StringValue",
"(",
"<mask>",
".",
"TaskArn",
")",
"\n",
"if",
"taskArn",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"timeout",
":=",
"aws",
".",
"Int64Value",
"(",
"message",
".",
"WaitTimeoutMs",
")",
"\n",
"if",
"timeout",
"<=",
"0",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
16,261 | all-16262 | [
"Detaches",
"a",
"shader",
"object",
"from",
"a",
"program",
"object",
"to",
"which",
"it",
"is",
"attached"
] | [
"func",
"DetachShader",
"(",
"program",
"uint32",
",",
"shader",
"uint32",
")",
"{",
"syscall",
".",
"Syscall",
"(",
"gpDetachShader",
",",
"2",
",",
"uintptr",
"(",
"<mask>",
")",
",",
"uintptr",
"(",
"shader",
")",
",",
"0",
")",
"\n",
"}"
] |
16,262 | all-16263 | [
"Translate",
"moves",
"the",
"following",
"text",
"drawings",
"and",
"images",
"horizontally",
"and",
"vertically",
"by",
"the",
"amounts",
"specified",
"by",
"tx",
"and",
"ty",
".",
"This",
"must",
"be",
"placed",
"between",
"gc",
".",
"Save",
"()",
"and",
"gc",
".",
"Restore",
"()",
"otherwise",
"the",
"pdf",
"is",
"invalid",
"."
] | [
"func",
"(",
"gc",
"*",
"GraphicContext",
")",
"Translate",
"(",
"tx",
",",
"ty",
"float64",
")",
"{",
"gc",
".",
"StackGraphicContext",
".",
"Translate",
"(",
"<mask>",
",",
"ty",
")",
"\n",
"gc",
".",
"pdf",
".",
"TransformTranslate",
"(",
"tx",
",",
"ty",
")",
"\n",
"}"
] |
16,263 | all-16264 | [
"Run",
"the",
"web",
"application",
"."
] | [
"func",
"(",
"c",
"*",
"<mask>",
")",
"Run",
"(",
")",
"{",
"http",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"c",
".",
"loginHandler",
")",
"\n",
"http",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"c",
".",
"logoutHandler",
")",
"\n",
"http",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"c",
".",
"viewHandler",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"http",
".",
"ListenAndServe",
"(",
"\"",
"\"",
",",
"nil",
")",
"\n",
"}"
] |
16,264 | all-16265 | [
"Error",
"formats",
"a",
"given",
"message",
"according",
"to",
"given",
"params",
"to",
"log",
"with",
"level",
"Error",
"."
] | [
"func",
"(",
"dl",
"*",
"DefaultLogger",
")",
"Error",
"(",
"message",
"string",
",",
"params",
"...",
"interface",
"{",
"}",
")",
"{",
"dl",
".",
"logger",
".",
"Errorf",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"caller",
"(",
")",
",",
"<mask>",
")",
",",
"params",
"...",
")",
"\n",
"}"
] |
16,265 | all-16266 | [
"PanedNew",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_paned_new",
"()",
"."
] | [
"func",
"PanedNew",
"(",
"orientation",
"Orientation",
")",
"(",
"*",
"Paned",
",",
"<mask>",
")",
"{",
"c",
":=",
"C",
".",
"gtk_paned_new",
"(",
"C",
".",
"GtkOrientation",
"(",
"orientation",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"return",
"wrapPaned",
"(",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
")",
",",
"nil",
"\n",
"}"
] |
16,266 | all-16267 | [
"newRecord",
"returns",
"a",
"RecordSet",
"based",
"on",
"the",
"given",
"endpoint",
"."
] | [
"func",
"newRecord",
"(",
"ep",
"*",
"endpoint",
".",
"Endpoint",
")",
"*",
"dns",
".",
"ResourceRecordSet",
"{",
"// TODO(linki): works around appending a trailing dot to TXT records. I think",
"// we should go back to storing DNS names with a trailing dot internally. This",
"// way we can use it has is here and trim it off if it exists when necessary.",
"targets",
":=",
"<mask>",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"ep",
".",
"Targets",
")",
")",
"\n",
"copy",
"(",
"targets",
",",
"[",
"]",
"string",
"(",
"ep",
".",
"Targets",
")",
")",
"\n",
"if",
"ep",
".",
"RecordType",
"==",
"endpoint",
".",
"RecordTypeCNAME",
"{",
"targets",
"[",
"0",
"]",
"=",
"ensureTrailingDot",
"(",
"targets",
"[",
"0",
"]",
")",
"\n",
"}",
"\n\n",
"// no annotation results in a Ttl of 0, default to 300 for backwards-compatability",
"var",
"ttl",
"int64",
"=",
"googleRecordTTL",
"\n",
"if",
"ep",
".",
"RecordTTL",
".",
"IsConfigured",
"(",
")",
"{",
"ttl",
"=",
"int64",
"(",
"ep",
".",
"RecordTTL",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"dns",
".",
"ResourceRecordSet",
"{",
"Name",
":",
"ensureTrailingDot",
"(",
"ep",
".",
"DNSName",
")",
",",
"Rrdatas",
":",
"targets",
",",
"Ttl",
":",
"ttl",
",",
"Type",
":",
"ep",
".",
"RecordType",
",",
"}",
"\n",
"}"
] |
16,267 | all-16268 | [
"SetTooltipText",
"is",
"a",
"wrapper",
"around",
"gtk_widget_set_tooltip_text",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Widget",
")",
"SetTooltipText",
"(",
"text",
"string",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"text",
")",
"\n",
"defer",
"C",
".",
"<mask>",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"C",
".",
"gtk_widget_set_tooltip_text",
"(",
"v",
".",
"native",
"(",
")",
",",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
")",
"\n",
"}"
] |
16,268 | all-16269 | [
"Min",
"returns",
"the",
"smallest",
"value",
"in",
"the",
"range"
] | [
"func",
"(",
"r",
"*",
"InclusiveRange",
")",
"Min",
"(",
")",
"int",
"{",
"<mask>",
":=",
"r",
".",
"Start",
"(",
")",
"\n",
"end",
":=",
"r",
".",
"End",
"(",
")",
"\n",
"if",
"start",
"<",
"end",
"{",
"return",
"start",
"\n",
"}",
"\n",
"return",
"end",
"\n",
"}"
] |
16,269 | all-16270 | [
"Get",
"the",
"mechanism",
"(",
"i",
".",
"e",
".",
"mx",
"a",
"all",
"ip4",
"...",
")"
] | [
"func",
"(",
"d",
"*",
"Directive",
")",
"getMechanism",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"d",
".",
"term",
")",
"<=",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"term",
":=",
"d",
".",
"term",
"\n",
"if",
"isQualifier",
"(",
"d",
".",
"term",
"[",
"0",
"]",
")",
"{",
"term",
"=",
"term",
"[",
"1",
":",
"]",
"\n",
"}",
"\n",
"index",
":=",
"strings",
".",
"Index",
"(",
"term",
",",
"\"",
"\"",
")",
"\n",
"if",
"index",
"==",
"-",
"1",
"{",
"return",
"term",
"\n",
"}",
"\n",
"return",
"<mask>",
"[",
"0",
":",
"index",
"]",
"\n",
"}"
] |
16,270 | all-16271 | [
"ApplyChanges",
"applies",
"a",
"given",
"set",
"of",
"changes",
"in",
"a",
"given",
"zone",
"."
] | [
"func",
"(",
"p",
"*",
"DigitalOceanProvider",
")",
"ApplyChanges",
"(",
"changes",
"*",
"plan",
".",
"Changes",
")",
"error",
"{",
"combinedChanges",
":=",
"make",
"(",
"[",
"]",
"*",
"DigitalOceanChange",
",",
"0",
",",
"len",
"(",
"changes",
".",
"Create",
")",
"+",
"len",
"(",
"changes",
".",
"UpdateNew",
")",
"+",
"len",
"(",
"changes",
".",
"Delete",
")",
")",
"\n\n",
"combinedChanges",
"=",
"append",
"(",
"combinedChanges",
",",
"newDigitalOceanChanges",
"(",
"DigitalOceanCreate",
",",
"changes",
".",
"Create",
")",
"...",
")",
"\n",
"combinedChanges",
"=",
"append",
"(",
"combinedChanges",
",",
"newDigitalOceanChanges",
"(",
"DigitalOceanUpdate",
",",
"changes",
".",
"UpdateNew",
")",
"...",
")",
"\n",
"combinedChanges",
"=",
"<mask>",
"(",
"combinedChanges",
",",
"newDigitalOceanChanges",
"(",
"DigitalOceanDelete",
",",
"changes",
".",
"Delete",
")",
"...",
")",
"\n\n",
"return",
"p",
".",
"submitChanges",
"(",
"combinedChanges",
")",
"\n",
"}"
] |
16,271 | all-16272 | [
"readPivnetRelease",
"reads",
"a",
"pivnet",
"release",
"out",
"of",
"the",
"given",
"reader",
"into",
"a",
"new",
"pivnetRelease",
"struct"
] | [
"func",
"(",
"r",
"*",
"PivnetRelease",
")",
"readPivnetRelease",
"(",
"path",
"string",
")",
"error",
"{",
"walker",
":=",
"pkg",
".",
"NewZipWalker",
"(",
"path",
")",
"\n",
"walker",
".",
"OnMatch",
"(",
"\"",
"\"",
",",
"func",
"(",
"file",
"pkg",
".",
"FileEntry",
")",
"error",
"{",
"br",
",",
"berr",
":=",
"readBoshRelease",
"(",
"file",
".",
"Reader",
")",
"\n",
"if",
"berr",
"!=",
"nil",
"{",
"return",
"berr",
"\n",
"}",
"\n",
"r",
".",
"BoshRelease",
"[",
"br",
".",
"ReleaseManifest",
".",
"Name",
"]",
"=",
"<mask>",
"\n",
"return",
"nil",
"\n",
"}",
")",
"\n",
"return",
"walker",
".",
"Walk",
"(",
")",
"\n",
"}"
] |
16,272 | all-16273 | [
"print",
"outputs",
"a",
"log",
"message",
"to",
"the",
"writer",
"associated",
"with",
"the",
"backend",
"after",
"creating",
"a",
"prefix",
"for",
"the",
"given",
"level",
"and",
"tag",
"according",
"to",
"the",
"formatHeader",
"function",
"and",
"formatting",
"the",
"provided",
"arguments",
"using",
"the",
"default",
"formatting",
"rules",
"."
] | [
"func",
"(",
"b",
"*",
"Backend",
")",
"print",
"(",
"lvl",
",",
"tag",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"t",
":=",
"time",
".",
"Now",
"(",
")",
"// get as early as possible",
"\n\n",
"bytebuf",
":=",
"buffer",
"(",
")",
"\n\n",
"var",
"file",
"string",
"\n",
"var",
"line",
"int",
"\n",
"if",
"b",
".",
"flag",
"&",
"(",
"Lshortfile",
"|",
"Llongfile",
")",
"!=",
"0",
"{",
"file",
",",
"<mask>",
"=",
"callsite",
"(",
"b",
".",
"flag",
")",
"\n",
"}",
"\n\n",
"formatHeader",
"(",
"bytebuf",
",",
"t",
",",
"lvl",
",",
"tag",
",",
"file",
",",
"line",
")",
"\n",
"buf",
":=",
"bytes",
".",
"NewBuffer",
"(",
"*",
"bytebuf",
")",
"\n",
"fmt",
".",
"Fprintln",
"(",
"buf",
",",
"args",
"...",
")",
"\n",
"*",
"bytebuf",
"=",
"buf",
".",
"Bytes",
"(",
")",
"\n\n",
"b",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"b",
".",
"w",
".",
"Write",
"(",
"*",
"bytebuf",
")",
"\n",
"b",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"recycleBuffer",
"(",
"bytebuf",
")",
"\n",
"}"
] |
16,273 | all-16274 | [
"IDFromMetadata",
"gets",
"the",
"key",
"from",
"the",
"metadata",
"or",
"returns",
"ErrNoID"
] | [
"func",
"IDFromMetadata",
"(",
"md",
"metadata",
".",
"MD",
")",
"(",
"string",
",",
"error",
")",
"{",
"id",
",",
"ok",
":=",
"md",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"!",
"<mask>",
"||",
"len",
"(",
"id",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
",",
"ErrNoID",
"\n",
"}",
"\n",
"return",
"id",
"[",
"0",
"]",
",",
"nil",
"\n",
"}"
] |
16,274 | all-16275 | [
"MutateSetOptions",
"for",
"MasterWeight",
"sets",
"the",
"SetOptionsOp",
"s",
"MasterWeight",
"field"
] | [
"func",
"(",
"m",
"MasterWeight",
")",
"MutateSetOptions",
"(",
"o",
"*",
"xdr",
".",
"SetOptionsOp",
")",
"(",
"<mask>",
"error",
")",
"{",
"val",
":=",
"xdr",
".",
"Uint32",
"(",
"m",
")",
"\n",
"o",
".",
"MasterWeight",
"=",
"&",
"val",
"\n",
"return",
"\n",
"}"
] |
16,275 | all-16276 | [
"pushmark",
"load_lvar",
"0",
"push",
"literal_i",
"start",
"push",
"literal_i",
"end",
"push",
"fetch_slice",
"/",
"*",
"func",
"txFetchSlice",
"(",
"st",
"*",
"State",
")",
"{",
"container",
":",
"=",
"st",
".",
"sa",
"if",
"container",
"==",
"nil",
"{",
"XXX",
"?",
"no",
"op?",
"st",
".",
"sa",
"=",
"nil",
"}",
"else",
"{",
"v",
":",
"=",
"reflect",
".",
"ValueOf",
"(",
"container",
")",
"v",
".",
"Slice",
"("
] | [
"func",
"txFetchField",
"(",
"st",
"*",
"State",
")",
"{",
"container",
":=",
"st",
".",
"sa",
"\n",
"if",
"container",
"==",
"nil",
"{",
"// XXX ? no op?",
"st",
".",
"sa",
"=",
"nil",
"\n",
"}",
"else",
"{",
"t",
":=",
"reflect",
".",
"TypeOf",
"(",
"container",
")",
"\n",
"var",
"f",
"reflect",
".",
"Value",
"\n",
"var",
"v",
"reflect",
".",
"Value",
"\n",
"name",
":=",
"st",
".",
"CurrentOp",
"(",
")",
".",
"ArgString",
"(",
")",
"\n",
"switch",
"t",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Ptr",
",",
"reflect",
".",
"Struct",
":",
"// Uppercase first character of field name",
"r",
",",
"size",
":=",
"utf8",
".",
"DecodeRuneInString",
"(",
"name",
")",
"\n",
"name",
"=",
"string",
"(",
"unicode",
".",
"ToUpper",
"(",
"r",
")",
")",
"+",
"name",
"[",
"size",
":",
"]",
"\n\n",
"v",
"=",
"reflect",
".",
"ValueOf",
"(",
"container",
")",
"\n",
"if",
"t",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Ptr",
"{",
"// dereference",
"v",
"=",
"v",
".",
"Elem",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"v",
".",
"Type",
"(",
")",
".",
"Name",
"(",
")",
"==",
"\"",
"\"",
"{",
"// some special treatment here",
"<mask>",
"name",
"{",
"case",
"\"",
"\"",
":",
"name",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
":",
"name",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
":",
"name",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
":",
"name",
"=",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
":",
"name",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"}",
"\n\n",
"f",
"=",
"v",
".",
"FieldByName",
"(",
"name",
")",
"\n",
"case",
"reflect",
".",
"Map",
":",
"v",
"=",
"reflect",
".",
"ValueOf",
"(",
"container",
")",
"\n",
"f",
"=",
"v",
".",
"MapIndex",
"(",
"reflect",
".",
"ValueOf",
"(",
"name",
")",
")",
"\n",
"default",
":",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"container",
",",
"t",
")",
")",
"\n",
"}",
"\n\n",
"st",
".",
"sa",
"=",
"f",
".",
"Interface",
"(",
")",
"\n",
"}",
"\n",
"st",
".",
"Advance",
"(",
")",
"\n",
"}"
] |
16,276 | all-16277 | [
"StoragePoolUpdate",
"updates",
"a",
"storage",
"pool",
"."
] | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"StoragePoolUpdate",
"(",
"poolName",
",",
"description",
"string",
",",
"poolConfig",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"poolID",
",",
"_",
",",
"err",
":=",
"c",
".",
"StoragePoolGet",
"(",
"poolName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"c",
".",
"Transaction",
"(",
"func",
"(",
"tx",
"*",
"ClusterTx",
")",
"error",
"{",
"err",
"=",
"StoragePoolUpdateDescription",
"(",
"tx",
".",
"tx",
",",
"poolID",
",",
"description",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"StoragePoolConfigClear",
"(",
"<mask>",
".",
"tx",
",",
"poolID",
",",
"c",
".",
"nodeID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"storagePoolConfigAdd",
"(",
"tx",
".",
"tx",
",",
"poolID",
",",
"c",
".",
"nodeID",
",",
"poolConfig",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
")",
"\n\n",
"return",
"err",
"\n",
"}"
] |
16,277 | all-16278 | [
"appleCTPolicyExpectedSCTs",
"returns",
"a",
"count",
"of",
"the",
"number",
"of",
"SCTs",
"expected",
"to",
"be",
"embedded",
"in",
"the",
"given",
"certificate",
"based",
"on",
"its",
"lifetime",
".",
"For",
"this",
"function",
"the",
"relevant",
"portion",
"of",
"Apple",
"s",
"policy",
"is",
"the",
"table",
"Number",
"of",
"embedded",
"SCTs",
"based",
"on",
"certificate",
"lifetime",
"(",
"Also",
"reproduced",
"in",
"the",
"Execute",
"godoc",
"comment",
")",
"."
] | [
"func",
"appleCTPolicyExpectedSCTs",
"(",
"cert",
"*",
"x509",
".",
"Certificate",
")",
"int",
"{",
"// Lifetime is relative to the certificate's NotBefore date.",
"start",
":=",
"cert",
".",
"NotBefore",
"\n\n",
"// Thresholds is an ordered array of lifetime periods and their expected # of",
"// SCTs. A lifetime period is defined by the cutoff date relative to the",
"// start of the certificate's lifetime.",
"thresholds",
":=",
"[",
"]",
"struct",
"{",
"CutoffDate",
"time",
".",
"Time",
"\n",
"Expected",
"int",
"\n",
"}",
"{",
"// Start date ... 15 months",
"{",
"CutoffDate",
":",
"start",
".",
"AddDate",
"(",
"0",
",",
"15",
",",
"0",
")",
",",
"Expected",
":",
"2",
"}",
",",
"// Start date ... 27 months",
"{",
"CutoffDate",
":",
"<mask>",
".",
"AddDate",
"(",
"0",
",",
"27",
",",
"0",
")",
",",
"Expected",
":",
"3",
"}",
",",
"// Start date ... 39 months",
"{",
"CutoffDate",
":",
"start",
".",
"AddDate",
"(",
"0",
",",
"39",
",",
"0",
")",
",",
"Expected",
":",
"4",
"}",
",",
"}",
"\n\n",
"// If the certificate's lifetime falls into any of the cutoff date ranges then",
"// we expect that range's expected # of SCTs for this certificate. This loop",
"// assumes the `thresholds` list is sorted in ascending order.",
"for",
"_",
",",
"threshold",
":=",
"range",
"thresholds",
"{",
"if",
"cert",
".",
"NotAfter",
".",
"Before",
"(",
"threshold",
".",
"CutoffDate",
")",
"{",
"return",
"threshold",
".",
"Expected",
"\n",
"}",
"\n",
"}",
"\n\n",
"// The certificate had a validity > 39 months.",
"return",
"5",
"\n",
"}"
] |
16,278 | all-16279 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"FunctionCoverage",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"<mask>",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoProfiler21",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
16,279 | all-16280 | [
"Wrap",
"initializes",
"the",
"buffer",
"to",
"wrap",
"the",
"given",
"byte",
"slice"
] | [
"func",
"(",
"w",
"*",
"WriteBuffer",
")",
"Wrap",
"(",
"b",
"[",
"]",
"byte",
")",
"{",
"w",
".",
"<mask>",
"=",
"b",
"\n",
"w",
".",
"remaining",
"=",
"b",
"\n",
"}"
] |
16,280 | all-16281 | [
"NewAuthStore",
"creates",
"a",
"new",
"AuthStore",
"."
] | [
"func",
"NewAuthStore",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"be",
"backend",
".",
"Backend",
",",
"tp",
"TokenProvider",
",",
"bcryptCost",
"int",
")",
"*",
"authStore",
"{",
"if",
"bcryptCost",
"<",
"bcrypt",
".",
"MinCost",
"||",
"bcryptCost",
">",
"bcrypt",
".",
"MaxCost",
"{",
"if",
"lg",
"!=",
"nil",
"{",
"lg",
".",
"Warn",
"(",
"\"",
"\"",
",",
"zap",
".",
"Int",
"(",
"\"",
"\"",
",",
"bcrypt",
".",
"MinCost",
")",
",",
"zap",
".",
"Int",
"(",
"\"",
"\"",
",",
"bcrypt",
".",
"MaxCost",
")",
",",
"zap",
".",
"Int",
"(",
"\"",
"\"",
",",
"bcrypt",
".",
"DefaultCost",
")",
",",
"zap",
".",
"Int",
"(",
"\"",
"\"",
",",
"bcryptCost",
")",
")",
"\n",
"}",
"else",
"{",
"plog",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"bcrypt",
".",
"DefaultCost",
",",
"bcryptCost",
")",
"\n",
"}",
"\n\n",
"bcryptCost",
"=",
"bcrypt",
".",
"DefaultCost",
"\n",
"}",
"\n\n",
"tx",
":=",
"be",
".",
"BatchTx",
"(",
")",
"\n",
"tx",
".",
"Lock",
"(",
")",
"\n\n",
"tx",
".",
"UnsafeCreateBucket",
"(",
"authBucketName",
")",
"\n",
"tx",
".",
"UnsafeCreateBucket",
"(",
"authUsersBucketName",
")",
"\n",
"tx",
".",
"UnsafeCreateBucket",
"(",
"authRolesBucketName",
")",
"\n\n",
"enabled",
":=",
"false",
"\n",
"_",
",",
"vs",
":=",
"tx",
".",
"UnsafeRange",
"(",
"authBucketName",
",",
"enableFlagKey",
",",
"nil",
",",
"0",
")",
"\n",
"if",
"len",
"(",
"vs",
")",
"==",
"1",
"{",
"if",
"bytes",
".",
"Equal",
"(",
"vs",
"[",
"0",
"]",
",",
"authEnabled",
")",
"{",
"enabled",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"as",
":=",
"&",
"authStore",
"{",
"revision",
":",
"getRevision",
"(",
"tx",
")",
",",
"lg",
":",
"lg",
",",
"be",
":",
"be",
",",
"enabled",
":",
"enabled",
",",
"rangePermCache",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"unifiedRangePermissions",
")",
",",
"tokenProvider",
":",
"tp",
",",
"bcryptCost",
":",
"bcryptCost",
",",
"}",
"\n\n",
"if",
"enabled",
"{",
"as",
".",
"tokenProvider",
".",
"enable",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"as",
".",
"Revision",
"(",
")",
"==",
"0",
"{",
"as",
".",
"commitRevision",
"(",
"<mask>",
")",
"\n",
"}",
"\n\n",
"tx",
".",
"Unlock",
"(",
")",
"\n",
"be",
".",
"ForceCommit",
"(",
")",
"\n\n",
"return",
"as",
"\n",
"}"
] |
16,281 | all-16282 | [
"Log",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockAuditLogger",
")",
"<mask>",
"(",
"arg0",
"request",
".",
"LogRequest",
",",
"arg1",
"int",
",",
"arg2",
"string",
")",
"{",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
",",
"arg1",
",",
"arg2",
")",
"\n",
"}"
] |
16,282 | all-16283 | [
"HTTPStatusCode",
"returns",
"the",
"HTTP",
"status",
"code",
"for",
"the",
"given",
"error",
"or",
"500",
"if",
"it",
"doesn",
"t",
"know"
] | [
"func",
"HTTPStatusCode",
"(",
"err",
"error",
")",
"int",
"{",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"Error",
")",
"\n",
"if",
"ok",
"{",
"return",
"e",
".",
"Type",
"(",
")",
".",
"HTTPStatusCode",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"<mask>",
".",
"StatusInternalServerError",
"\n",
"}"
] |
16,283 | all-16284 | [
"addFirewallTag",
"adds",
"a",
"tag",
"to",
"the",
"instance",
"to",
"match",
"the",
"firewall",
"rule",
"."
] | [
"func",
"(",
"c",
"*",
"ComputeUtil",
")",
"addFirewallTag",
"(",
"instance",
"*",
"raw",
".",
"Instance",
")",
"error",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n\n",
"<mask>",
":=",
"instance",
".",
"Tags",
"\n",
"for",
"_",
",",
"tag",
":=",
"range",
"tags",
".",
"Items",
"{",
"if",
"tag",
"==",
"firewallTargetTag",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"tags",
".",
"Items",
"=",
"append",
"(",
"tags",
".",
"Items",
",",
"firewallTargetTag",
")",
"\n\n",
"op",
",",
"err",
":=",
"c",
".",
"service",
".",
"Instances",
".",
"SetTags",
"(",
"c",
".",
"project",
",",
"c",
".",
"zone",
",",
"instance",
".",
"Name",
",",
"tags",
")",
".",
"Do",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"c",
".",
"waitForRegionalOp",
"(",
"op",
".",
"Name",
")",
"\n",
"}"
] |
16,284 | all-16285 | [
"Validate",
"returns",
"an",
"error",
"if",
"any",
"contexts",
"are",
"listed",
"more",
"than",
"once",
"in",
"the",
"config",
"."
] | [
"func",
"(",
"cp",
"*",
"TideContextPolicy",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"inter",
":=",
"sets",
".",
"NewString",
"(",
"cp",
".",
"RequiredContexts",
"...",
")",
".",
"Intersection",
"(",
"sets",
".",
"NewString",
"(",
"cp",
".",
"OptionalContexts",
"...",
")",
")",
";",
"inter",
".",
"Len",
"(",
")",
">",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"inter",
".",
"List",
"(",
")",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"if",
"inter",
":=",
"sets",
".",
"NewString",
"(",
"cp",
".",
"RequiredContexts",
"...",
")",
".",
"Intersection",
"(",
"sets",
".",
"NewString",
"(",
"cp",
".",
"RequiredIfPresentContexts",
"...",
")",
")",
";",
"inter",
".",
"Len",
"(",
")",
">",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"inter",
".",
"List",
"(",
")",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"if",
"inter",
":=",
"sets",
".",
"NewString",
"(",
"cp",
".",
"OptionalContexts",
"...",
")",
".",
"Intersection",
"(",
"sets",
".",
"NewString",
"(",
"cp",
".",
"RequiredIfPresentContexts",
"...",
")",
")",
";",
"inter",
".",
"Len",
"(",
")",
">",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"inter",
".",
"<mask>",
"(",
")",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
16,285 | all-16286 | [
"mergeStats",
"merges",
"y",
"into",
"x"
] | [
"func",
"mergeStats",
"(",
"x",
",",
"y",
"*",
"pps",
".",
"ProcessStats",
")",
"error",
"{",
"<mask>",
"err",
"error",
"\n",
"if",
"x",
".",
"DownloadTime",
",",
"err",
"=",
"plusDuration",
"(",
"x",
".",
"DownloadTime",
",",
"y",
".",
"DownloadTime",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"x",
".",
"ProcessTime",
",",
"err",
"=",
"plusDuration",
"(",
"x",
".",
"ProcessTime",
",",
"y",
".",
"ProcessTime",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"x",
".",
"UploadTime",
",",
"err",
"=",
"plusDuration",
"(",
"x",
".",
"UploadTime",
",",
"y",
".",
"UploadTime",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"x",
".",
"DownloadBytes",
"+=",
"y",
".",
"DownloadBytes",
"\n",
"x",
".",
"UploadBytes",
"+=",
"y",
".",
"UploadBytes",
"\n",
"return",
"nil",
"\n",
"}"
] |
16,286 | all-16287 | [
"WithValidatorTimeout",
"is",
"an",
"option",
"that",
"sets",
"the",
"topic",
"validator",
"timeout",
"."
] | [
"func",
"WithValidatorTimeout",
"(",
"timeout",
"<mask>",
".",
"Duration",
")",
"ValidatorOpt",
"{",
"return",
"func",
"(",
"addVal",
"*",
"addValReq",
")",
"error",
"{",
"addVal",
".",
"timeout",
"=",
"timeout",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] |
16,287 | all-16288 | [
"NewBackgroundTx",
"returns",
"a",
"new",
"background",
"transaction"
] | [
"func",
"NewBackgroundTx",
"(",
"<mask>",
"string",
",",
"category",
"string",
")",
"*",
"tx",
"{",
"t",
":=",
"NewTx",
"(",
"name",
")",
"\n",
"t",
".",
"txnType",
"=",
"OtherTransaction",
"\n",
"t",
".",
"category",
"=",
"category",
"\n",
"return",
"t",
"\n",
"}"
] |
16,288 | all-16289 | [
"ScrollMarkOnscreen",
"is",
"a",
"wrapper",
"around",
"gtk_text_view_scroll_mark_onscreen",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"TextView",
")",
"ScrollMarkOnscreen",
"(",
"<mask>",
"*",
"TextMark",
")",
"{",
"C",
".",
"gtk_text_view_scroll_mark_onscreen",
"(",
"v",
".",
"native",
"(",
")",
",",
"mark",
".",
"native",
"(",
")",
")",
"\n",
"}"
] |
16,289 | all-16290 | [
"retrieve",
"a",
"sub",
"-",
"region",
"of",
"a",
"texture",
"image",
"from",
"a",
"texture",
"object"
] | [
"func",
"GetTextureSubImage",
"(",
"texture",
"uint32",
",",
"level",
"int32",
",",
"xoffset",
"int32",
",",
"yoffset",
"int32",
",",
"zoffset",
"int32",
",",
"<mask>",
"int32",
",",
"height",
"int32",
",",
"depth",
"int32",
",",
"format",
"uint32",
",",
"xtype",
"uint32",
",",
"bufSize",
"int32",
",",
"pixels",
"unsafe",
".",
"Pointer",
")",
"{",
"syscall",
".",
"Syscall12",
"(",
"gpGetTextureSubImage",
",",
"12",
",",
"uintptr",
"(",
"texture",
")",
",",
"uintptr",
"(",
"level",
")",
",",
"uintptr",
"(",
"xoffset",
")",
",",
"uintptr",
"(",
"yoffset",
")",
",",
"uintptr",
"(",
"zoffset",
")",
",",
"uintptr",
"(",
"width",
")",
",",
"uintptr",
"(",
"height",
")",
",",
"uintptr",
"(",
"depth",
")",
",",
"uintptr",
"(",
"format",
")",
",",
"uintptr",
"(",
"xtype",
")",
",",
"uintptr",
"(",
"bufSize",
")",
",",
"uintptr",
"(",
"pixels",
")",
")",
"\n",
"}"
] |
16,290 | all-16291 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"Viewport",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage2",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
16,291 | all-16292 | [
"Delete",
"removes",
"the",
"node",
"with",
"the",
"given",
"interval",
"from",
"the",
"tree",
"returning",
"true",
"if",
"a",
"node",
"is",
"in",
"fact",
"removed",
"."
] | [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"Delete",
"(",
"ivl",
"Interval",
")",
"bool",
"{",
"z",
":=",
"ivt",
".",
"find",
"(",
"ivl",
")",
"\n",
"if",
"z",
"==",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"y",
":=",
"z",
"\n",
"if",
"z",
".",
"left",
"!=",
"nil",
"&&",
"z",
".",
"right",
"!=",
"nil",
"{",
"y",
"=",
"z",
".",
"successor",
"(",
")",
"\n",
"}",
"\n\n",
"x",
":=",
"y",
".",
"left",
"\n",
"if",
"x",
"==",
"nil",
"{",
"x",
"=",
"y",
".",
"right",
"\n",
"}",
"\n",
"if",
"x",
"!=",
"nil",
"{",
"x",
".",
"parent",
"=",
"y",
".",
"parent",
"\n",
"}",
"\n\n",
"if",
"y",
".",
"parent",
"==",
"nil",
"{",
"ivt",
".",
"root",
"=",
"x",
"\n",
"}",
"else",
"{",
"if",
"y",
"==",
"y",
".",
"parent",
".",
"left",
"{",
"y",
".",
"parent",
".",
"left",
"=",
"x",
"\n",
"}",
"else",
"{",
"y",
".",
"parent",
".",
"right",
"=",
"x",
"\n",
"}",
"\n",
"y",
".",
"parent",
".",
"updateMax",
"(",
")",
"\n",
"}",
"\n",
"if",
"y",
"!=",
"z",
"{",
"z",
".",
"iv",
"=",
"y",
".",
"iv",
"\n",
"z",
".",
"updateMax",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"y",
".",
"color",
"(",
")",
"==",
"black",
"&&",
"x",
"!=",
"nil",
"{",
"ivt",
".",
"deleteFixup",
"(",
"x",
")",
"\n",
"}",
"\n\n",
"ivt",
".",
"count",
"--",
"\n",
"return",
"true",
"\n",
"}"
] |
16,292 | all-16293 | [
"DeepCopyInto",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"writing",
"into",
"out",
".",
"in",
"must",
"be",
"non",
"-",
"nil",
"."
] | [
"func",
"(",
"in",
"*",
"AppSpec",
")",
"DeepCopyInto",
"(",
"out",
"*",
"AppSpec",
")",
"{",
"*",
"out",
"=",
"*",
"in",
"\n",
"if",
"in",
".",
"Deployments",
"!=",
"nil",
"{",
"in",
",",
"out",
":=",
"&",
"in",
".",
"Deployments",
",",
"&",
"out",
".",
"Deployments",
"\n",
"*",
"out",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
",",
"len",
"(",
"*",
"in",
")",
")",
"\n",
"for",
"key",
",",
"val",
":=",
"range",
"*",
"in",
"{",
"if",
"val",
"==",
"nil",
"{",
"(",
"*",
"out",
")",
"[",
"key",
"]",
"=",
"nil",
"\n",
"}",
"else",
"{",
"(",
"*",
"out",
")",
"[",
"key",
"]",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"val",
")",
")",
"\n",
"copy",
"(",
"(",
"*",
"out",
")",
"[",
"key",
"]",
",",
"val",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"in",
".",
"Services",
"!=",
"nil",
"{",
"in",
",",
"out",
":=",
"&",
"in",
".",
"Services",
",",
"&",
"out",
".",
"Services",
"\n",
"*",
"out",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
",",
"len",
"(",
"*",
"in",
")",
")",
"\n",
"for",
"key",
",",
"val",
":=",
"range",
"*",
"in",
"{",
"if",
"val",
"==",
"nil",
"{",
"(",
"*",
"out",
")",
"[",
"key",
"]",
"=",
"nil",
"\n",
"}",
"else",
"{",
"(",
"*",
"out",
")",
"[",
"key",
"]",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"val",
")",
")",
"\n",
"copy",
"(",
"(",
"*",
"out",
")",
"[",
"<mask>",
"]",
",",
"val",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
16,293 | all-16294 | [
"isHidden",
"checks",
"to",
"see",
"if",
"key",
"path",
"is",
"considered",
"hidden",
"to",
"watch",
"path",
"i",
".",
"e",
".",
"the",
"last",
"element",
"is",
"hidden",
"or",
"it",
"s",
"within",
"a",
"hidden",
"directory"
] | [
"func",
"isHidden",
"(",
"watchPath",
",",
"keyPath",
"string",
")",
"bool",
"{",
"// When deleting a directory, watchPath might be deeper than the actual keyPath",
"// For example, when deleting /foo we also need to notify watchers on /foo/bar.",
"if",
"len",
"(",
"watchPath",
")",
">",
"len",
"(",
"keyPath",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"// if watch path is just a \"/\", after path will start without \"/\"",
"// add a \"/\" to deal with the special case when watchPath is \"/\"",
"afterPath",
":=",
"<mask>",
".",
"Clean",
"(",
"\"",
"\"",
"+",
"keyPath",
"[",
"len",
"(",
"watchPath",
")",
":",
"]",
")",
"\n",
"return",
"strings",
".",
"Contains",
"(",
"afterPath",
",",
"\"",
"\"",
")",
"\n",
"}"
] |
16,294 | all-16295 | [
"WithDownloadPath",
"the",
"default",
"path",
"to",
"save",
"downloaded",
"files",
"to",
".",
"This",
"is",
"required",
"if",
"behavior",
"is",
"set",
"to",
"allow",
"."
] | [
"func",
"(",
"p",
"SetDownloadBehaviorParams",
")",
"WithDownloadPath",
"(",
"downloadPath",
"<mask>",
")",
"*",
"SetDownloadBehaviorParams",
"{",
"p",
".",
"DownloadPath",
"=",
"downloadPath",
"\n",
"return",
"&",
"p",
"\n",
"}"
] |
16,295 | all-16296 | [
"Sleep",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockTime",
")",
"Sleep",
"(",
"arg0",
"<mask>",
".",
"Duration",
")",
"{",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"}"
] |
16,296 | all-16297 | [
"GetYOk",
"returns",
"a",
"tuple",
"with",
"the",
"Y",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"s",
"*",
"ScatterplotRequests",
")",
"GetYOk",
"(",
")",
"(",
"ScatterplotRequest",
",",
"bool",
")",
"{",
"if",
"s",
"==",
"nil",
"||",
"s",
".",
"Y",
"==",
"nil",
"{",
"return",
"ScatterplotRequest",
"{",
"}",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"s",
".",
"Y",
",",
"<mask>",
"\n",
"}"
] |
16,297 | all-16298 | [
"CreateStatus",
"creates",
"or",
"updates",
"a",
"status",
"context",
"on",
"the",
"indicated",
"reference",
"."
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateStatus",
"(",
"owner",
",",
"repo",
",",
"ref",
"string",
",",
"status",
"*",
"github",
".",
"RepoStatus",
")",
"(",
"*",
"github",
".",
"RepoStatus",
",",
"error",
")",
"{",
"glog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"c",
".",
"dryRun",
",",
"ref",
",",
"*",
"status",
".",
"Context",
",",
"*",
"status",
".",
"State",
")",
"\n",
"if",
"c",
".",
"dryRun",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"var",
"result",
"*",
"github",
".",
"RepoStatus",
"\n",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ref",
")",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"retry",
"(",
"msg",
",",
"func",
"(",
")",
"(",
"*",
"github",
".",
"Response",
",",
"error",
")",
"{",
"var",
"resp",
"*",
"github",
".",
"Response",
"\n",
"var",
"err",
"error",
"\n",
"result",
",",
"resp",
",",
"err",
"=",
"c",
".",
"repoService",
".",
"CreateStatus",
"(",
"context",
".",
"Background",
"(",
")",
",",
"owner",
",",
"repo",
",",
"ref",
",",
"<mask>",
")",
"\n",
"return",
"resp",
",",
"err",
"\n",
"}",
")",
"\n",
"return",
"result",
",",
"err",
"\n",
"}"
] |
16,298 | all-16299 | [
"CONTRACT",
":",
"rv",
".",
"CanAddr",
"()",
"is",
"true",
"."
] | [
"func",
"(",
"cdc",
"*",
"Codec",
")",
"decodeReflectJSONStruct",
"(",
"bz",
"[",
"]",
"byte",
",",
"info",
"*",
"TypeInfo",
",",
"rv",
"reflect",
".",
"Value",
",",
"fopts",
"FieldOptions",
")",
"(",
"err",
"error",
")",
"{",
"if",
"!",
"rv",
".",
"CanAddr",
"(",
")",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"printLog",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
"\n",
"}",
"(",
")",
"\n",
"}",
"\n\n",
"// Map all the fields(keys) to their blobs/bytes.",
"// NOTE: In decodeReflectBinaryStruct, we don't need to do this,",
"// since fields are encoded in order.",
"var",
"rawMap",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"json",
".",
"RawMessage",
")",
"\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"bz",
",",
"&",
"rawMap",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"<mask>",
":=",
"range",
"info",
".",
"Fields",
"{",
"// Get field rv and info.",
"var",
"frv",
"=",
"rv",
".",
"Field",
"(",
"field",
".",
"Index",
")",
"\n",
"var",
"finfo",
"*",
"TypeInfo",
"\n",
"finfo",
",",
"err",
"=",
"cdc",
".",
"getTypeInfo_wlock",
"(",
"field",
".",
"Type",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"// Get value from rawMap.",
"var",
"valueBytes",
"=",
"rawMap",
"[",
"field",
".",
"JSONName",
"]",
"\n",
"if",
"len",
"(",
"valueBytes",
")",
"==",
"0",
"{",
"// TODO: Since the Go stdlib's JSON codec allows case-insensitive",
"// keys perhaps we need to also do case-insensitive lookups here.",
"// So \"Vanilla\" and \"vanilla\" would both match to the same field.",
"// It is actually a security flaw with encoding/json library",
"// - See https://github.com/golang/go/issues/14750",
"// but perhaps we are aiming for as much compatibility here.",
"// JAE: I vote we depart from encoding/json, than carry a vuln.",
"// Set nil/zero on frv.",
"frv",
".",
"Set",
"(",
"reflect",
".",
"Zero",
"(",
"frv",
".",
"Type",
"(",
")",
")",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"// Decode into field rv.",
"err",
"=",
"cdc",
".",
"decodeReflectJSON",
"(",
"valueBytes",
",",
"finfo",
",",
"frv",
",",
"fopts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
16,299 | all-16300 | [
"rangeEval",
"evaluates",
"the",
"given",
"expressions",
"and",
"then",
"for",
"each",
"step",
"calls",
"the",
"given",
"function",
"with",
"the",
"values",
"computed",
"for",
"each",
"expression",
"at",
"that",
"step",
".",
"The",
"return",
"value",
"is",
"the",
"combination",
"into",
"time",
"series",
"of",
"all",
"the",
"function",
"call",
"results",
"."
] | [
"func",
"(",
"ev",
"*",
"evaluator",
")",
"rangeEval",
"(",
"f",
"func",
"(",
"[",
"]",
"Value",
",",
"*",
"EvalNodeHelper",
")",
"Vector",
",",
"exprs",
"...",
"Expr",
")",
"Matrix",
"{",
"numSteps",
":=",
"int",
"(",
"(",
"ev",
".",
"endTimestamp",
"-",
"ev",
".",
"startTimestamp",
")",
"/",
"ev",
".",
"interval",
")",
"+",
"1",
"\n",
"matrixes",
":=",
"make",
"(",
"[",
"]",
"Matrix",
",",
"len",
"(",
"exprs",
")",
")",
"\n",
"origMatrixes",
":=",
"make",
"(",
"[",
"]",
"Matrix",
",",
"len",
"(",
"exprs",
")",
")",
"\n",
"originalNumSamples",
":=",
"ev",
".",
"currentSamples",
"\n\n",
"for",
"i",
",",
"e",
":=",
"range",
"exprs",
"{",
"// Functions will take string arguments from the expressions, not the values.",
"if",
"e",
"!=",
"nil",
"&&",
"e",
".",
"Type",
"(",
")",
"!=",
"ValueTypeString",
"{",
"// ev.currentSamples will be updated to the correct value within the ev.eval call.",
"matrixes",
"[",
"i",
"]",
"=",
"ev",
".",
"eval",
"(",
"e",
")",
".",
"(",
"Matrix",
")",
"\n\n",
"// Keep a copy of the original point slices so that they",
"// can be returned to the pool.",
"origMatrixes",
"[",
"i",
"]",
"=",
"make",
"(",
"Matrix",
",",
"len",
"(",
"matrixes",
"[",
"i",
"]",
")",
")",
"\n",
"copy",
"(",
"origMatrixes",
"[",
"i",
"]",
",",
"matrixes",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"vectors",
":=",
"make",
"(",
"[",
"]",
"Vector",
",",
"len",
"(",
"exprs",
")",
")",
"// Input vectors for the function.",
"\n",
"args",
":=",
"make",
"(",
"[",
"]",
"Value",
",",
"len",
"(",
"exprs",
")",
")",
"// Argument to function.",
"\n",
"// Create an output vector that is as big as the input matrix with",
"// the most time series.",
"biggestLen",
":=",
"1",
"\n",
"for",
"i",
":=",
"range",
"exprs",
"{",
"vectors",
"[",
"i",
"]",
"=",
"make",
"(",
"Vector",
",",
"0",
",",
"len",
"(",
"matrixes",
"[",
"i",
"]",
")",
")",
"\n",
"if",
"len",
"(",
"matrixes",
"[",
"i",
"]",
")",
">",
"biggestLen",
"{",
"biggestLen",
"=",
"len",
"(",
"matrixes",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"}",
"\n",
"enh",
":=",
"&",
"EvalNodeHelper",
"{",
"out",
":",
"make",
"(",
"Vector",
",",
"0",
",",
"biggestLen",
")",
"}",
"\n",
"seriess",
":=",
"<mask>",
"(",
"map",
"[",
"uint64",
"]",
"Series",
",",
"biggestLen",
")",
"// Output series by series hash.",
"\n",
"tempNumSamples",
":=",
"ev",
".",
"currentSamples",
"\n",
"for",
"ts",
":=",
"ev",
".",
"startTimestamp",
";",
"ts",
"<=",
"ev",
".",
"endTimestamp",
";",
"ts",
"+=",
"ev",
".",
"interval",
"{",
"if",
"err",
":=",
"contextDone",
"(",
"ev",
".",
"ctx",
",",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"ev",
".",
"error",
"(",
"err",
")",
"\n",
"}",
"\n",
"// Reset number of samples in memory after each timestamp.",
"ev",
".",
"currentSamples",
"=",
"tempNumSamples",
"\n",
"// Gather input vectors for this timestamp.",
"for",
"i",
":=",
"range",
"exprs",
"{",
"vectors",
"[",
"i",
"]",
"=",
"vectors",
"[",
"i",
"]",
"[",
":",
"0",
"]",
"\n",
"for",
"si",
",",
"series",
":=",
"range",
"matrixes",
"[",
"i",
"]",
"{",
"for",
"_",
",",
"point",
":=",
"range",
"series",
".",
"Points",
"{",
"if",
"point",
".",
"T",
"==",
"ts",
"{",
"if",
"ev",
".",
"currentSamples",
"<",
"ev",
".",
"maxSamples",
"{",
"vectors",
"[",
"i",
"]",
"=",
"append",
"(",
"vectors",
"[",
"i",
"]",
",",
"Sample",
"{",
"Metric",
":",
"series",
".",
"Metric",
",",
"Point",
":",
"point",
"}",
")",
"\n",
"// Move input vectors forward so we don't have to re-scan the same",
"// past points at the next step.",
"matrixes",
"[",
"i",
"]",
"[",
"si",
"]",
".",
"Points",
"=",
"series",
".",
"Points",
"[",
"1",
":",
"]",
"\n",
"ev",
".",
"currentSamples",
"++",
"\n",
"}",
"else",
"{",
"ev",
".",
"error",
"(",
"ErrTooManySamples",
"(",
"env",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"args",
"[",
"i",
"]",
"=",
"vectors",
"[",
"i",
"]",
"\n",
"}",
"\n",
"// Make the function call.",
"enh",
".",
"ts",
"=",
"ts",
"\n",
"result",
":=",
"f",
"(",
"args",
",",
"enh",
")",
"\n",
"if",
"result",
".",
"ContainsSameLabelset",
"(",
")",
"{",
"ev",
".",
"errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"enh",
".",
"out",
"=",
"result",
"[",
":",
"0",
"]",
"// Reuse result vector.",
"\n\n",
"ev",
".",
"currentSamples",
"+=",
"len",
"(",
"result",
")",
"\n",
"// When we reset currentSamples to tempNumSamples during the next iteration of the loop it also",
"// needs to include the samples from the result here, as they're still in memory.",
"tempNumSamples",
"+=",
"len",
"(",
"result",
")",
"\n\n",
"if",
"ev",
".",
"currentSamples",
">",
"ev",
".",
"maxSamples",
"{",
"ev",
".",
"error",
"(",
"ErrTooManySamples",
"(",
"env",
")",
")",
"\n",
"}",
"\n\n",
"// If this could be an instant query, shortcut so as not to change sort order.",
"if",
"ev",
".",
"endTimestamp",
"==",
"ev",
".",
"startTimestamp",
"{",
"mat",
":=",
"make",
"(",
"Matrix",
",",
"len",
"(",
"result",
")",
")",
"\n",
"for",
"i",
",",
"s",
":=",
"range",
"result",
"{",
"s",
".",
"Point",
".",
"T",
"=",
"ts",
"\n",
"mat",
"[",
"i",
"]",
"=",
"Series",
"{",
"Metric",
":",
"s",
".",
"Metric",
",",
"Points",
":",
"[",
"]",
"Point",
"{",
"s",
".",
"Point",
"}",
"}",
"\n",
"}",
"\n",
"ev",
".",
"currentSamples",
"=",
"originalNumSamples",
"+",
"mat",
".",
"TotalSamples",
"(",
")",
"\n",
"return",
"mat",
"\n",
"}",
"\n\n",
"// Add samples in output vector to output series.",
"for",
"_",
",",
"sample",
":=",
"range",
"result",
"{",
"h",
":=",
"sample",
".",
"Metric",
".",
"Hash",
"(",
")",
"\n",
"ss",
",",
"ok",
":=",
"seriess",
"[",
"h",
"]",
"\n",
"if",
"!",
"ok",
"{",
"ss",
"=",
"Series",
"{",
"Metric",
":",
"sample",
".",
"Metric",
",",
"Points",
":",
"getPointSlice",
"(",
"numSteps",
")",
",",
"}",
"\n",
"}",
"\n",
"sample",
".",
"Point",
".",
"T",
"=",
"ts",
"\n",
"ss",
".",
"Points",
"=",
"append",
"(",
"ss",
".",
"Points",
",",
"sample",
".",
"Point",
")",
"\n",
"seriess",
"[",
"h",
"]",
"=",
"ss",
"\n\n",
"}",
"\n",
"}",
"\n\n",
"// Reuse the original point slices.",
"for",
"_",
",",
"m",
":=",
"range",
"origMatrixes",
"{",
"for",
"_",
",",
"s",
":=",
"range",
"m",
"{",
"putPointSlice",
"(",
"s",
".",
"Points",
")",
"\n",
"}",
"\n",
"}",
"\n",
"// Assemble the output matrix. By the time we get here we know we don't have too many samples.",
"mat",
":=",
"make",
"(",
"Matrix",
",",
"0",
",",
"len",
"(",
"seriess",
")",
")",
"\n",
"for",
"_",
",",
"ss",
":=",
"range",
"seriess",
"{",
"mat",
"=",
"append",
"(",
"mat",
",",
"ss",
")",
"\n",
"}",
"\n",
"ev",
".",
"currentSamples",
"=",
"originalNumSamples",
"+",
"mat",
".",
"TotalSamples",
"(",
")",
"\n",
"return",
"mat",
"\n",
"}"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.