id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
sequencelengths
1
418
pl_tokens
sequencelengths
22
4.98k
10,200
all-10201
[ "SubmitTransaction", "submits", "a", "transaction", "to", "the", "network", ".", "err", "can", "be", "either", "error", "object", "or", "horizon", ".", "Error", "object", "." ]
[ "func", "(", "c", "*", "Client", ")", "SubmitTransaction", "(", "transactionEnvelopeXdr", "string", ")", "(", "response", "TransactionSuccess", ",", "err", "error", ")", "{", "v", ":=", "url", ".", "Values", "{", "}", "\n", "v", ".", "<mask>", "(", "\"", "\"", ",", "transactionEnvelopeXdr", ")", "\n\n", "c", ".", "initHTTPClient", "(", ")", "\n", "resp", ",", "err", ":=", "c", ".", "Client", ".", "PostForm", "(", "c", ".", "URL", "+", "\"", "\"", ",", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "err", "=", "decodeResponse", "(", "resp", ",", "&", "response", ")", "\n", "return", "\n", "}" ]
10,201
all-10202
[ "Encode", "encodes", "the", "provided", "data", "to", "a", "StrKey", "using", "the", "provided", "version", "byte", "." ]
[ "func", "Encode", "(", "version", "VersionByte", ",", "src", "[", "]", "byte", ")", "(", "string", ",", "error", ")", "{", "if", "err", ":=", "checkValidVersionByte", "(", "version", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "var", "raw", "bytes", ".", "Buffer", "\n\n", "// write version byte", "if", "err", ":=", "binary", ".", "Write", "(", "&", "raw", ",", "binary", ".", "LittleEndian", ",", "version", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "// write payload", "if", "_", ",", "err", ":=", "<mask>", ".", "Write", "(", "src", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "// calculate and write checksum", "checksum", ":=", "crc16", ".", "Checksum", "(", "raw", ".", "Bytes", "(", ")", ")", "\n", "if", "_", ",", "err", ":=", "raw", ".", "Write", "(", "checksum", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "result", ":=", "base32", ".", "StdEncoding", ".", "EncodeToString", "(", "raw", ".", "Bytes", "(", ")", ")", "\n", "return", "result", ",", "nil", "\n", "}" ]
10,202
all-10203
[ "HostPort", "finds", "the", "specified", "host", ":", "port", "combo", "for", "a", "service", "based", "off", "of", "the", "service", "s", "name", "and", "which", "interface", "you", "are", "accessing", ".", "Values", "are", "found", "in", "environment", "variables", "fitting", "the", "scheme", ":", "SERVICE_", "{", "SERVICE", "NAME", "}", "_", "{", "INTERFACE", "NAME", "}", "_", "{", "PROTO", "HOST", "PORT", "}", "." ]
[ "func", "HostPort", "(", "service", ",", "name", "string", ")", "(", "string", ",", "error", ")", "{", "host", ",", "err", ":=", "Host", "(", "service", ",", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "port", ",", "err", ":=", "Port", "(", "<mask>", ",", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "net", ".", "JoinHostPort", "(", "host", ",", "port", ")", ",", "nil", "\n", "}" ]
10,203
all-10204
[ "compileCORSRegexString", "compiles", "given", "string", "and", "adds", "anchors" ]
[ "func", "compileCORSRegexString", "(", "s", "<mask>", ")", "(", "*", "regexp", ".", "Regexp", ",", "error", ")", "{", "r", ",", "err", ":=", "relabel", ".", "NewRegexp", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "r", ".", "Regexp", ",", "nil", "\n", "}" ]
10,204
all-10205
[ "Parse", "parses", "the", "given", "string", "containing", "query", "args", "." ]
[ "func", "(", "a", "*", "Args", ")", "Parse", "(", "s", "string", ")", "{", "a", ".", "buf", "=", "<mask>", "(", "a", ".", "buf", "[", ":", "0", "]", ",", "s", "...", ")", "\n", "a", ".", "ParseBytes", "(", "a", ".", "buf", ")", "\n", "}" ]
10,205
all-10206
[ "Insert", "marks", "this", "statement", "for", "insertion", "at", "the", "end", "of", "the", "file", ".", "Multiple", "statements", "will", "be", "inserted", "in", "the", "order", "Insert", "is", "called", "." ]
[ "func", "(", "r", "*", "Rule", ")", "Insert", "(", "f", "*", "File", ")", "{", "// TODO(jayconrod): should rules always be inserted at the end? Should there", "// be some sort order?", "var", "stmt", "[", "]", "bzl", ".", "Expr", "\n", "if", "f", ".", "<mask>", "==", "nil", "{", "stmt", "=", "f", ".", "File", ".", "Stmt", "\n", "}", "else", "{", "stmt", "=", "f", ".", "function", ".", "stmt", ".", "Body", "\n", "}", "\n", "r", ".", "index", "=", "len", "(", "stmt", ")", "\n", "r", ".", "inserted", "=", "true", "\n", "f", ".", "Rules", "=", "append", "(", "f", ".", "Rules", ",", "r", ")", "\n", "}" ]
10,206
all-10207
[ "GetStyle", "returns", "the", "Style", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "t", "*", "TimeseriesRequest", ")", "GetStyle", "(", ")", "TimeseriesRequestStyle", "{", "if", "t", "==", "nil", "||", "t", ".", "Style", "==", "nil", "{", "<mask>", "TimeseriesRequestStyle", "{", "}", "\n", "}", "\n", "return", "*", "t", ".", "Style", "\n", "}" ]
10,207
all-10208
[ "Synchronize", "flushes", "any", "copy", "of", "the", "specified", "resource", "from", "its", "corresponding", "Device", "caches", "and", "if", "needed", "invalidates", "any", "CPU", "caches", ".", "Reference", ":", "https", ":", "//", "developer", ".", "apple", ".", "com", "/", "documentation", "/", "metal", "/", "mtlblitcommandencoder", "/", "1400775", "-", "synchronize", "." ]
[ "func", "(", "bce", "BlitCommandEncoder", ")", "Synchronize", "(", "<mask>", "Resource", ")", "{", "C", ".", "BlitCommandEncoder_Synchronize", "(", "bce", ".", "commandEncoder", ",", "resource", ".", "resource", "(", ")", ")", "\n", "}" ]
10,208
all-10209
[ "FileName", "returns", "HTTP", "file", "name" ]
[ "func", "(", "r", "*", "FileResponse", ")", "FileName", "(", ")", "string", "{", "value", ":=", "r", ".", "headers", ".", "Get", "(", "\"", "\"", ")", "\n", "if", "len", "(", "<mask>", ")", "==", "0", "{", "return", "\"", "\"", "\n", "}", "\n", "_", ",", "params", ",", "err", ":=", "mime", ".", "ParseMediaType", "(", "value", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "params", "[", "\"", "\"", "]", "\n", "}" ]
10,209
all-10210
[ "AddLoader", "for", "a", "document" ]
[ "func", "AddLoader", "(", "predicate", "DocMatcher", ",", "load", "DocLoader", ")", "{", "prev", ":=", "loaders", "\n", "loaders", "=", "&", "loader", "{", "Match", ":", "predicate", ",", "Fn", ":", "<mask>", ",", "Next", ":", "prev", ",", "}", "\n", "spec", ".", "PathLoader", "=", "loaders", ".", "Fn", "\n", "}" ]
10,210
all-10211
[ "specify", "a", "one", "-", "dimensional", "texture", "subimage", "in", "a", "compressed", "format" ]
[ "func", "CompressedTexSubImage1D", "(", "target", "uint32", ",", "<mask>", "int32", ",", "xoffset", "int32", ",", "width", "int32", ",", "format", "uint32", ",", "imageSize", "int32", ",", "data", "unsafe", ".", "Pointer", ")", "{", "C", ".", "glowCompressedTexSubImage1D", "(", "gpCompressedTexSubImage1D", ",", "(", "C", ".", "GLenum", ")", "(", "target", ")", ",", "(", "C", ".", "GLint", ")", "(", "level", ")", ",", "(", "C", ".", "GLint", ")", "(", "xoffset", ")", ",", "(", "C", ".", "GLsizei", ")", "(", "width", ")", ",", "(", "C", ".", "GLenum", ")", "(", "format", ")", ",", "(", "C", ".", "GLsizei", ")", "(", "imageSize", ")", ",", "data", ")", "\n", "}" ]
10,211
all-10212
[ "It", "spins", "up", "multiple", "goroutines", "in", "order", "to", "retrieve", "values", "in", "parallel", "." ]
[ "func", "(", "secret", "*", "ASMSecretResource", ")", "Create", "(", ")", "error", "{", "// To fail fast, check execution role first", "executionCredentials", ",", "ok", ":=", "secret", ".", "credentialsManager", ".", "GetTaskCredentials", "(", "secret", ".", "getExecutionCredentialsID", "(", ")", ")", "\n", "if", "!", "ok", "{", "// No need to log here. managedTask.applyResourceState already does that", "err", ":=", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "secret", ".", "setTerminalReason", "(", "err", ".", "Error", "(", ")", ")", "\n", "return", "err", "\n", "}", "\n", "iamCredentials", ":=", "executionCredentials", ".", "GetIAMRoleCredentials", "(", ")", "\n\n", "var", "wg", "sync", ".", "WaitGroup", "\n\n", "// Get the maximum number of errors to be returned, which will be one error per goroutine", "errorEvents", ":=", "make", "(", "chan", "error", ",", "len", "(", "secret", ".", "requiredSecrets", ")", ")", "\n\n", "seelog", ".", "Infof", "(", "\"", "\"", ",", "secret", ".", "taskARN", ")", "\n", "<mask>", ".", "secretData", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n\n", "for", "_", ",", "asmsecret", ":=", "range", "secret", ".", "getRequiredSecrets", "(", ")", "{", "wg", ".", "Add", "(", "1", ")", "\n", "// Spin up goroutine per secret to speed up processing time", "go", "secret", ".", "retrieveASMSecretValue", "(", "asmsecret", ",", "iamCredentials", ",", "&", "wg", ",", "errorEvents", ")", "\n", "}", "\n\n", "wg", ".", "Wait", "(", ")", "\n", "close", "(", "errorEvents", ")", "\n\n", "if", "len", "(", "errorEvents", ")", ">", "0", "{", "var", "terminalReasons", "[", "]", "string", "\n", "for", "err", ":=", "range", "errorEvents", "{", "terminalReasons", "=", "append", "(", "terminalReasons", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n\n", "errorString", ":=", "strings", ".", "Join", "(", "terminalReasons", ",", "\"", "\"", ")", "\n", "secret", ".", "setTerminalReason", "(", "errorString", ")", "\n", "return", "errors", ".", "New", "(", "errorString", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
10,212
all-10213
[ "Open", "opens", "the", "index", "with", "the", "given", "name", ".", "The", "index", "is", "created", "if", "it", "does", "not", "already", "exist", ".", "The", "name", "is", "a", "human", "-", "readable", "ASCII", "string", ".", "It", "must", "contain", "no", "whitespace", "characters", "and", "not", "start", "with", "!", "." ]
[ "func", "Open", "(", "name", "string", ")", "(", "*", "Index", ",", "error", ")", "{", "if", "!", "validIndexNameOrDocID", "(", "name", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n", "return", "&", "Index", "{", "spec", ":", "pb", ".", "IndexSpec", "{", "<mask>", ":", "&", "name", ",", "}", ",", "}", ",", "nil", "\n", "}" ]
10,213
all-10214
[ "GetCustomTitle", "is", "a", "wrapper", "around", "gtk_header_bar_get_custom_title", "()", "." ]
[ "func", "(", "v", "*", "HeaderBar", ")", "GetCustomTitle", "(", ")", "(", "*", "Widget", ",", "error", ")", "{", "c", ":=", "C", ".", "gtk_header_bar_get_custom_title", "(", "v", ".", "native", "(", ")", ")", "\n", "if", "c", "==", "nil", "{", "return", "nil", ",", "nilPtrErr", "\n", "}", "\n", "<mask>", "wrapWidget", "(", "glib", ".", "Take", "(", "unsafe", ".", "Pointer", "(", "c", ")", ")", ")", ",", "nil", "\n", "}" ]
10,214
all-10215
[ "Nodes", "returns", "all", "LXD", "nodes", "part", "of", "the", "cluster", "." ]
[ "func", "(", "c", "*", "ClusterTx", ")", "nodes", "(", "pending", "bool", ",", "where", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "[", "]", "NodeInfo", ",", "error", ")", "{", "nodes", ":=", "[", "]", "NodeInfo", "{", "}", "\n", "dest", ":=", "func", "(", "i", "int", ")", "[", "]", "interface", "{", "}", "{", "nodes", "=", "append", "(", "nodes", ",", "NodeInfo", "{", "}", ")", "\n", "return", "[", "]", "interface", "{", "}", "{", "&", "nodes", "[", "i", "]", ".", "ID", ",", "&", "nodes", "[", "i", "]", ".", "Name", ",", "&", "nodes", "[", "i", "]", ".", "Address", ",", "&", "nodes", "[", "i", "]", ".", "Description", ",", "&", "nodes", "[", "i", "]", ".", "Schema", ",", "&", "nodes", "[", "i", "]", ".", "APIExtensions", ",", "&", "nodes", "[", "i", "]", ".", "Heartbeat", ",", "}", "\n", "}", "\n", "if", "pending", "{", "args", "=", "append", "(", "[", "]", "interface", "{", "}", "{", "1", "}", ",", "args", "...", ")", "\n", "}", "else", "{", "args", "=", "append", "(", "[", "]", "interface", "{", "}", "{", "0", "}", ",", "args", "...", ")", "\n", "}", "\n", "sql", ":=", "`\nSELECT id, name, address, description, schema, api_extensions, heartbeat FROM nodes WHERE pending=? `", "\n", "if", "where", "!=", "\"", "\"", "{", "sql", "+=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "where", ")", "\n", "}", "\n", "sql", "+=", "\"", "\"", "\n", "stmt", ",", "err", ":=", "c", ".", "tx", ".", "Prepare", "(", "sql", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "stmt", ".", "Close", "(", ")", "\n", "err", "=", "query", ".", "SelectObjects", "(", "stmt", ",", "dest", ",", "args", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "<mask>", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "nodes", ",", "nil", "\n", "}" ]
10,215
all-10216
[ "POST", "/", "api", "/", "catalog", "/", "accounts", "/", ":", "account_id", "/", "notification_rules", "Create", "one", "notification", "rule", "for", "a", "specific", "target", "and", "source", ".", "The", "source", "must", "be", "unique", "in", "the", "scope", "of", "target", "and", "account", "." ]
[ "func", "(", "loc", "*", "NotificationRuleLocator", ")", "Create", "(", "minSeverity", "string", ",", "source", "string", ",", "target", "string", ",", "options", "rsapi", ".", "APIParams", ")", "(", "*", "NotificationRuleLocator", ",", "error", ")", "{", "<mask>", "res", "*", "NotificationRuleLocator", "\n", "if", "minSeverity", "==", "\"", "\"", "{", "return", "res", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "source", "==", "\"", "\"", "{", "return", "res", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "target", "==", "\"", "\"", "{", "return", "res", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "var", "params", "rsapi", ".", "APIParams", "\n", "params", "=", "rsapi", ".", "APIParams", "{", "}", "\n", "var", "filterOpt", "=", "options", "[", "\"", "\"", "]", "\n", "if", "filterOpt", "!=", "nil", "{", "params", "[", "\"", "\"", "]", "=", "filterOpt", "\n", "}", "\n", "var", "p", "rsapi", ".", "APIParams", "\n", "p", "=", "rsapi", ".", "APIParams", "{", "\"", "\"", ":", "minSeverity", ",", "\"", "\"", ":", "source", ",", "\"", "\"", ":", "target", ",", "}", "\n", "var", "categoryOpt", "=", "options", "[", "\"", "\"", "]", "\n", "if", "categoryOpt", "!=", "nil", "{", "p", "[", "\"", "\"", "]", "=", "categoryOpt", "\n", "}", "\n", "uri", ",", "err", ":=", "loc", ".", "ActionPath", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "req", ",", "err", ":=", "loc", ".", "api", ".", "BuildHTTPRequest", "(", "uri", ".", "HTTPMethod", ",", "uri", ".", "Path", ",", "APIVersion", ",", "params", ",", "p", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "resp", ",", "err", ":=", "loc", ".", "api", ".", "PerformRequest", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "defer", "resp", ".", "Body", ".", "Close", "(", ")", "\n", "if", "resp", ".", "StatusCode", "<", "200", "||", "resp", ".", "StatusCode", ">", "299", "{", "respBody", ",", "_", ":=", "ioutil", ".", "ReadAll", "(", "resp", ".", "Body", ")", "\n", "sr", ":=", "string", "(", "respBody", ")", "\n", "if", "sr", "!=", "\"", "\"", "{", "sr", "=", "\"", "\"", "+", "sr", "\n", "}", "\n", "return", "res", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "resp", ".", "Status", ",", "sr", ")", "\n", "}", "\n", "location", ":=", "resp", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "if", "len", "(", "location", ")", "==", "0", "{", "return", "res", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "else", "{", "return", "&", "NotificationRuleLocator", "{", "Href", "(", "location", ")", ",", "loc", ".", "api", "}", ",", "nil", "\n", "}", "\n", "}" ]
10,216
all-10217
[ "Returns", "the", "source", "code", "string", "from", "a", "shader", "object" ]
[ "func", "GetShaderSource", "(", "shader", "uint32", ",", "bufSize", "int32", ",", "length", "*", "int32", ",", "<mask>", "*", "uint8", ")", "{", "C", ".", "glowGetShaderSource", "(", "gpGetShaderSource", ",", "(", "C", ".", "GLuint", ")", "(", "shader", ")", ",", "(", "C", ".", "GLsizei", ")", "(", "bufSize", ")", ",", "(", "*", "C", ".", "GLsizei", ")", "(", "unsafe", ".", "Pointer", "(", "length", ")", ")", ",", "(", "*", "C", ".", "GLchar", ")", "(", "unsafe", ".", "Pointer", "(", "source", ")", ")", ")", "\n", "}" ]
10,217
all-10218
[ "NewEvent", "construct", "new", "event", "." ]
[ "func", "NewEvent", "(", "name", "string", ",", "body", "interface", "{", "}", ")", "Event", "{", "return", "Event", "{", "name", ":", "name", ",", "<mask>", ":", "body", ",", "occuredTime", ":", "time", ".", "Now", "(", ")", ",", "}", "\n", "}" ]
10,218
all-10219
[ "render", "multiple", "instances", "of", "a", "set", "of", "primitives", "from", "array", "data", "with", "a", "per", "-", "element", "offset" ]
[ "func", "DrawElementsInstancedBaseVertex", "(", "mode", "uint32", ",", "count", "int32", ",", "xtype", "uint32", ",", "indices", "unsafe", ".", "Pointer", ",", "instancecount", "int32", ",", "basevertex", "int32", ")", "{", "C", ".", "glowDrawElementsInstancedBaseVertex", "(", "gpDrawElementsInstancedBaseVertex", ",", "(", "C", ".", "GLenum", ")", "(", "mode", ")", ",", "(", "C", ".", "GLsizei", ")", "(", "<mask>", ")", ",", "(", "C", ".", "GLenum", ")", "(", "xtype", ")", ",", "indices", ",", "(", "C", ".", "GLsizei", ")", "(", "instancecount", ")", ",", "(", "C", ".", "GLint", ")", "(", "basevertex", ")", ")", "\n", "}" ]
10,219
all-10220
[ "Peek", "returns", "header", "value", "for", "the", "given", "key", ".", "Returned", "value", "is", "valid", "until", "the", "next", "call", "to", "ResponseHeader", ".", "Do", "not", "store", "references", "to", "returned", "value", ".", "Make", "copies", "instead", "." ]
[ "func", "(", "h", "*", "ResponseHeader", ")", "Peek", "(", "<mask>", "string", ")", "[", "]", "byte", "{", "k", ":=", "getHeaderKeyBytes", "(", "&", "h", ".", "bufKV", ",", "key", ",", "h", ".", "disableNormalizing", ")", "\n", "return", "h", ".", "peek", "(", "k", ")", "\n", "}" ]
10,220
all-10221
[ "A", "heuristic", "to", "guess", "the", "size", "of", "a", "registered", "type", "and", "return", "it", "as", "a", "string", ".", "If", "the", "size", "is", "not", "fixed", "it", "returns", "variable", "." ]
[ "func", "getLengthStr", "(", "info", "*", "TypeInfo", ")", "string", "{", "switch", "info", ".", "Type", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Array", ",", "reflect", ".", "Int8", ",", "reflect", ".", "Int16", ",", "reflect", ".", "Int32", ",", "reflect", ".", "Int64", ",", "reflect", ".", "Float32", ",", "reflect", ".", "Float64", ",", "reflect", ".", "Complex64", ",", "reflect", ".", "Complex128", ":", "s", ":=", "info", ".", "Type", ".", "Size", "(", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ")", "\n", "<mask>", ":", "return", "\"", "\"", "\n", "}", "\n", "}" ]
10,221
all-10222
[ "ServeHTTP", "makes", "a", "context", "for", "the", "request", "sets", "some", "good", "practice", "default", "headers", "and", "enters", "the", "handlers", "stack", "." ]
[ "func", "(", "hs", "*", "HandlersStack", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "<mask>", ".", "Request", ")", "{", "// Get a context for the request from ctxPool.", "c", ":=", "getContext", "(", "w", ",", "r", ")", "\n\n", "// Set some \"good practice\" default headers.", "c", ".", "ResponseWriter", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "c", ".", "ResponseWriter", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "c", ".", "ResponseWriter", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "c", ".", "ResponseWriter", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "//c.ResponseWriter.Header().Set(\"Access-Control-Allow-Origin\", \"*\")", "c", ".", "ResponseWriter", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "c", ".", "ResponseWriter", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "// Always recover form panics.", "defer", "c", ".", "Recover", "(", ")", "\n\n", "// Enter the handlers stack.", "c", ".", "Next", "(", ")", "\n\n", "// Respnose data", "// if c.written == false {", "// \tc.Fail(errors.New(\"not written\"))", "// }", "// Put the context to ctxPool", "putContext", "(", "c", ")", "\n", "}" ]
10,222
all-10223
[ "Specify", "the", "value", "of", "a", "uniform", "variable", "for", "a", "specified", "program", "object" ]
[ "func", "ProgramUniform4f", "(", "program", "uint32", ",", "<mask>", "int32", ",", "v0", "float32", ",", "v1", "float32", ",", "v2", "float32", ",", "v3", "float32", ")", "{", "syscall", ".", "Syscall6", "(", "gpProgramUniform4f", ",", "6", ",", "uintptr", "(", "program", ")", ",", "uintptr", "(", "location", ")", ",", "uintptr", "(", "math", ".", "Float32bits", "(", "v0", ")", ")", ",", "uintptr", "(", "math", ".", "Float32bits", "(", "v1", ")", ")", ",", "uintptr", "(", "math", ".", "Float32bits", "(", "v2", ")", ")", ",", "uintptr", "(", "math", ".", "Float32bits", "(", "v3", ")", ")", ")", "\n", "}" ]
10,223
all-10224
[ "Using", "the", "EZ", "API", "posts", "a", "value", "to", "a", "stat", "at", "a", "specific", "time", "." ]
[ "func", "(", "r", "*", "BasicReporter", ")", "PostEZValueTime", "(", "statName", ",", "ezkey", "string", ",", "value", "float64", ",", "timestamp", "int64", ")", "error", "{", "x", ":=", "newEZStatValue", "(", "statName", ",", "ezkey", ",", "value", ")", "\n", "x", ".", "Timestamp", "=", "timestamp", "\n", "r", ".", "<mask>", "(", "x", ")", "\n", "return", "nil", "\n", "}" ]
10,224
all-10225
[ "setGroupsForUserInternal", "is", "a", "helper", "function", "used", "by", "SetGroupsForUser", "and", "also", "by", "handleSAMLResponse", "(", "which", "updates", "group", "membership", "information", "based", "on", "signed", "SAML", "assertions", ")", ".", "This", "does", "no", "auth", "checks", "so", "the", "caller", "must", "do", "all", "relevant", "authorization", "." ]
[ "func", "(", "a", "*", "apiServer", ")", "setGroupsForUserInternal", "(", "ctx", "context", ".", "Context", ",", "subject", "string", ",", "groups", "[", "]", "string", ")", "error", "{", "_", ",", "err", ":=", "col", ".", "NewSTM", "(", "ctx", ",", "a", ".", "env", ".", "GetEtcdClient", "(", ")", ",", "func", "(", "stm", "col", ".", "STM", ")", "error", "{", "members", ":=", "a", ".", "members", ".", "ReadWrite", "(", "stm", ")", "\n\n", "// Get groups to remove/add user from/to", "var", "removeGroups", "authclient", ".", "Groups", "\n", "addGroups", ":=", "addToSet", "(", "nil", ",", "groups", "...", ")", "\n", "if", "err", ":=", "members", ".", "Get", "(", "subject", ",", "&", "removeGroups", ")", ";", "err", "==", "nil", "{", "for", "_", ",", "group", ":=", "range", "<mask>", "{", "if", "removeGroups", ".", "Groups", "[", "group", "]", "{", "removeGroups", ".", "Groups", "=", "removeFromSet", "(", "removeGroups", ".", "Groups", ",", "group", ")", "\n", "addGroups", "=", "removeFromSet", "(", "addGroups", ",", "group", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "// Set groups for user", "if", "err", ":=", "members", ".", "Put", "(", "subject", ",", "&", "authclient", ".", "Groups", "{", "Groups", ":", "addToSet", "(", "nil", ",", "groups", "...", ")", ",", "}", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Remove user from previous groups", "groups", ":=", "a", ".", "groups", ".", "ReadWrite", "(", "stm", ")", "\n", "var", "membersProto", "authclient", ".", "Users", "\n", "for", "group", ":=", "range", "removeGroups", ".", "Groups", "{", "if", "err", ":=", "groups", ".", "Upsert", "(", "group", ",", "&", "membersProto", ",", "func", "(", ")", "error", "{", "membersProto", ".", "Usernames", "=", "removeFromSet", "(", "membersProto", ".", "Usernames", ",", "subject", ")", "\n", "return", "nil", "\n", "}", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "// Add user to new groups", "for", "group", ":=", "range", "addGroups", "{", "if", "err", ":=", "groups", ".", "Upsert", "(", "group", ",", "&", "membersProto", ",", "func", "(", ")", "error", "{", "membersProto", ".", "Usernames", "=", "addToSet", "(", "membersProto", ".", "Usernames", ",", "subject", ")", "\n", "return", "nil", "\n", "}", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}", ")", "\n", "return", "err", "\n", "}" ]
10,225
all-10226
[ "NewResponse", "returns", "a", "new", "OAuth2Response" ]
[ "func", "NewResponse", "(", "clientID", ",", "redirectURI", ",", "userID", ",", "exp", ",", "code", "string", ")", "<mask>", "{", "return", "Response", "{", "ClientID", ":", "clientID", ",", "RedirectURI", ":", "redirectURI", ",", "UserID", ":", "userID", ",", "Exp", ":", "exp", ",", "Code", ":", "code", "}", "\n", "}" ]
10,226
all-10227
[ "Do", "executes", "DOM", ".", "pushNodeByPathToFrontend", "against", "the", "provided", "context", ".", "returns", ":", "nodeID", "-", "Id", "of", "the", "node", "for", "given", "path", "." ]
[ "func", "(", "p", "*", "PushNodeByPathToFrontendParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "nodeID", "cdp", ".", "NodeID", ",", "err", "error", ")", "{", "// execute", "var", "res", "PushNodeByPathToFrontendReturns", "\n", "err", "=", "cdp", ".", "Execute", "(", "ctx", ",", "CommandPushNodeByPathToFrontend", ",", "p", ",", "&", "<mask>", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n\n", "return", "res", ".", "NodeID", ",", "nil", "\n", "}" ]
10,227
all-10228
[ "client", "returns", "an", "authenticated", "HTTP", "client", "for", "use", "with", "GCE", "." ]
[ "func", "<mask>", "(", "path", "string", ")", "(", "*", "http", ".", "Client", ",", "error", ")", "{", "if", "path", "==", "\"", "\"", "{", "return", "google", ".", "DefaultClient", "(", "oauth2", ".", "NoContext", ",", "compute", ".", "ComputeScope", ")", "\n", "}", "\n\n", "key", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "jwtConfig", ",", "err", ":=", "google", ".", "JWTConfigFromJSON", "(", "key", ",", "compute", ".", "ComputeScope", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "jwtConfig", ".", "Client", "(", "oauth2", ".", "NoContext", ")", ",", "nil", "\n", "}" ]
10,228
all-10229
[ "WithPointerType", "pointer", "type", "(", "default", ":", "mouse", ")", "." ]
[ "func", "(", "p", "DispatchMouseEventParams", ")", "WithPointerType", "(", "pointerType", "DispatchMouseEventPointerType", ")", "*", "DispatchMouseEventParams", "{", "p", ".", "PointerType", "=", "pointerType", "\n", "<mask>", "&", "p", "\n", "}" ]
10,229
all-10230
[ "runCandidate", "runs", "the", "FSM", "for", "a", "candidate", "." ]
[ "func", "(", "r", "*", "Raft", ")", "runCandidate", "(", ")", "{", "r", ".", "logger", ".", "Info", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "r", ",", "r", ".", "getCurrentTerm", "(", ")", "+", "1", ")", ")", "\n", "metrics", ".", "IncrCounter", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "1", ")", "\n\n", "// Start vote for us, and set a timeout", "voteCh", ":=", "r", ".", "electSelf", "(", ")", "\n", "electionTimer", ":=", "randomTimeout", "(", "r", ".", "conf", ".", "ElectionTimeout", ")", "\n\n", "// Tally the votes, need a simple majority", "grantedVotes", ":=", "0", "\n", "votesNeeded", ":=", "r", ".", "quorumSize", "(", ")", "\n", "r", ".", "logger", ".", "Debug", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "votesNeeded", ")", ")", "\n\n", "for", "r", ".", "getState", "(", ")", "==", "Candidate", "{", "select", "{", "<mask>", "rpc", ":=", "<-", "r", ".", "rpcCh", ":", "r", ".", "processRPC", "(", "rpc", ")", "\n\n", "case", "vote", ":=", "<-", "voteCh", ":", "// Check if the term is greater than ours, bail", "if", "vote", ".", "Term", ">", "r", ".", "getCurrentTerm", "(", ")", "{", "r", ".", "logger", ".", "Debug", "(", "\"", "\"", ")", "\n", "r", ".", "setState", "(", "Follower", ")", "\n", "r", ".", "setCurrentTerm", "(", "vote", ".", "Term", ")", "\n", "return", "\n", "}", "\n\n", "// Check if the vote is granted", "if", "vote", ".", "Granted", "{", "grantedVotes", "++", "\n", "r", ".", "logger", ".", "Debug", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "vote", ".", "voterID", ",", "vote", ".", "Term", ",", "grantedVotes", ")", ")", "\n", "}", "\n\n", "// Check if we've become the leader", "if", "grantedVotes", ">=", "votesNeeded", "{", "r", ".", "logger", ".", "Info", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "grantedVotes", ")", ")", "\n", "r", ".", "setState", "(", "Leader", ")", "\n", "r", ".", "setLeader", "(", "r", ".", "localAddr", ")", "\n", "return", "\n", "}", "\n\n", "case", "c", ":=", "<-", "r", ".", "configurationChangeCh", ":", "// Reject any operations since we are not the leader", "c", ".", "respond", "(", "ErrNotLeader", ")", "\n\n", "case", "a", ":=", "<-", "r", ".", "applyCh", ":", "// Reject any operations since we are not the leader", "a", ".", "respond", "(", "ErrNotLeader", ")", "\n\n", "case", "v", ":=", "<-", "r", ".", "verifyCh", ":", "// Reject any operations since we are not the leader", "v", ".", "respond", "(", "ErrNotLeader", ")", "\n\n", "case", "r", ":=", "<-", "r", ".", "userRestoreCh", ":", "// Reject any restores since we are not the leader", "r", ".", "respond", "(", "ErrNotLeader", ")", "\n\n", "case", "c", ":=", "<-", "r", ".", "configurationsCh", ":", "c", ".", "configurations", "=", "r", ".", "configurations", ".", "Clone", "(", ")", "\n", "c", ".", "respond", "(", "nil", ")", "\n\n", "case", "b", ":=", "<-", "r", ".", "bootstrapCh", ":", "b", ".", "respond", "(", "ErrCantBootstrap", ")", "\n\n", "case", "<-", "electionTimer", ":", "// Election failed! Restart the election. We simply return,", "// which will kick us back into runCandidate", "r", ".", "logger", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "\n\n", "case", "<-", "r", ".", "shutdownCh", ":", "return", "\n", "}", "\n", "}", "\n", "}" ]
10,230
all-10231
[ "Do", "executes", "Browser", ".", "getWindowForTarget", "against", "the", "provided", "context", ".", "returns", ":", "windowID", "-", "Browser", "window", "id", ".", "bounds", "-", "Bounds", "information", "of", "the", "window", ".", "When", "window", "state", "is", "minimized", "the", "restored", "window", "position", "and", "size", "are", "returned", "." ]
[ "func", "(", "p", "*", "GetWindowForTargetParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "windowID", "WindowID", ",", "bounds", "*", "Bounds", ",", "err", "error", ")", "{", "// execute", "var", "<mask>", "GetWindowForTargetReturns", "\n", "err", "=", "cdp", ".", "Execute", "(", "ctx", ",", "CommandGetWindowForTarget", ",", "p", ",", "&", "res", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "nil", ",", "err", "\n", "}", "\n\n", "return", "res", ".", "WindowID", ",", "res", ".", "Bounds", ",", "nil", "\n", "}" ]
10,231
all-10232
[ "StopVirtualMachine", "power", "offs", "the", "virtual", "machine", "and", "waits", "until", "it", "reaches", "the", "goal", "state", "(", "stopped", ")", "or", "times", "out", "." ]
[ "func", "(", "a", "AzureClient", ")", "StopVirtualMachine", "(", "resourceGroup", ",", "name", "string", ")", "error", "{", "log", ".", "Info", "(", "\"", "\"", ",", "logutil", ".", "Fields", "{", "\"", "\"", ":", "<mask>", "}", ")", "\n", "if", "_", ",", "err", ":=", "a", ".", "virtualMachinesClient", "(", ")", ".", "PowerOff", "(", "resourceGroup", ",", "name", ",", "nil", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "a", ".", "waitVMPowerState", "(", "resourceGroup", ",", "name", ",", "Stopped", ",", "waitPowerOffTimeout", ")", "\n", "}" ]
10,232
all-10233
[ "merge", "takes", "two", "sorted", "lists", "and", "merges", "them", "into", "one", "sorted", "list", ".", "Behavior", "is", "undefined", "when", "you", "pass", "a", "non", "-", "sorted", "list", "as", "left", "or", "right" ]
[ "func", "merge", "(", "left", ",", "right", "*", "llNode", ",", "comparator", "Comparator", ")", "(", "first", "*", "llNode", ",", "err", "error", ")", "{", "curLeft", ":=", "left", "\n", "curRight", ":=", "<mask>", "\n\n", "var", "last", "*", "llNode", "\n\n", "appendResults", ":=", "func", "(", "updated", "*", "llNode", ")", "{", "if", "last", "==", "nil", "{", "last", "=", "updated", "\n", "}", "else", "{", "last", ".", "next", "=", "updated", "\n", "last", "=", "last", ".", "next", "\n", "}", "\n", "if", "first", "==", "nil", "{", "first", "=", "last", "\n", "}", "\n", "}", "\n\n", "for", "curLeft", "!=", "nil", "&&", "curRight", "!=", "nil", "{", "var", "res", "int", "\n", "if", "res", ",", "err", "=", "comparator", "(", "curLeft", ".", "payload", ",", "curRight", ".", "payload", ")", ";", "nil", "!=", "err", "{", "break", "// Don't return, stitch the remaining elements back on.", "\n", "}", "else", "if", "res", "<", "0", "{", "appendResults", "(", "curLeft", ")", "\n", "curLeft", "=", "curLeft", ".", "next", "\n", "}", "else", "{", "appendResults", "(", "curRight", ")", "\n", "curRight", "=", "curRight", ".", "next", "\n", "}", "\n", "}", "\n\n", "if", "curLeft", "!=", "nil", "{", "appendResults", "(", "curLeft", ")", "\n", "}", "\n", "if", "curRight", "!=", "nil", "{", "appendResults", "(", "curRight", ")", "\n", "}", "\n", "return", "\n", "}" ]
10,233
all-10234
[ "/", "*", "TriggerBatch", "triggers", "multiple", "events", "on", "multiple", "types", "of", "channels", "in", "a", "single", "call", ":", "client", ".", "TriggerBatch", "(", "[]", "pusher", ".", "Event", "{", "{", "Channel", ":", "donut", "-", "1", "Name", ":", "ev1", "Data", ":", "pippo1", "}", "{", "Channel", ":", "private", "-", "encrypted", "-", "secretdonut", "Name", ":", "ev2", "Data", ":", "pippo2", "}", "}", ")" ]
[ "func", "(", "c", "*", "<mask>", ")", "TriggerBatch", "(", "batch", "[", "]", "Event", ")", "(", "*", "BufferedEvents", ",", "error", ")", "{", "hasEncryptedChannel", ":=", "false", "\n", "// validate every channel name and every sockedID (if present) in batch", "for", "_", ",", "event", ":=", "range", "batch", "{", "if", "!", "validChannel", "(", "event", ".", "Channel", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "event", ".", "Channel", ")", "\n", "}", "\n", "if", "err", ":=", "validateSocketID", "(", "event", ".", "SocketId", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "isEncryptedChannel", "(", "event", ".", "Channel", ")", "{", "hasEncryptedChannel", "=", "true", "\n", "}", "\n", "}", "\n", "if", "hasEncryptedChannel", "{", "// validate EncryptionMasterKey", "if", "!", "validEncryptionKey", "(", "c", ".", "EncryptionMasterKey", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "payload", ",", "err", ":=", "encodeTriggerBatchBody", "(", "batch", ",", "c", ".", "EncryptionMasterKey", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "path", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "AppId", ")", "\n", "u", ",", "err", ":=", "createRequestURL", "(", "\"", "\"", ",", "c", ".", "Host", ",", "path", ",", "c", ".", "Key", ",", "c", ".", "Secret", ",", "authTimestamp", "(", ")", ",", "c", ".", "Secure", ",", "payload", ",", "nil", ",", "c", ".", "Cluster", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "response", ",", "err", ":=", "c", ".", "request", "(", "\"", "\"", ",", "u", ",", "payload", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "unmarshalledBufferedEvents", "(", "response", ")", "\n", "}" ]
10,234
all-10235
[ "StrokeExtents", "is", "a", "wrapper", "around", "cairo_stroke_extents", "()", "." ]
[ "func", "(", "v", "*", "<mask>", ")", "StrokeExtents", "(", ")", "(", "x1", ",", "y1", ",", "x2", ",", "y2", "float64", ")", "{", "var", "cx1", ",", "cy1", ",", "cx2", ",", "cy2", "C", ".", "double", "\n", "C", ".", "cairo_stroke_extents", "(", "v", ".", "native", "(", ")", ",", "&", "cx1", ",", "&", "cy1", ",", "&", "cx2", ",", "&", "cy2", ")", "\n", "return", "float64", "(", "cx1", ")", ",", "float64", "(", "cy1", ")", ",", "float64", "(", "cx2", ")", ",", "float64", "(", "cy2", ")", "\n", "}" ]
10,235
all-10236
[ "ConnectByPath", "is", "a", "wrapper", "around", "gtk_accel_group_connect_by_path", "()", "." ]
[ "func", "(", "v", "*", "AccelGroup", ")", "ConnectByPath", "(", "<mask>", "string", ",", "f", "interface", "{", "}", ")", "{", "closure", ",", "_", ":=", "glib", ".", "ClosureNew", "(", "f", ")", "\n", "cl", ":=", "(", "*", "C", ".", "struct__GClosure", ")", "(", "unsafe", ".", "Pointer", "(", "closure", ")", ")", "\n\n", "cstr", ":=", "C", ".", "CString", "(", "path", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cstr", ")", ")", "\n\n", "C", ".", "gtk_accel_group_connect_by_path", "(", "v", ".", "native", "(", ")", ",", "(", "*", "C", ".", "gchar", ")", "(", "cstr", ")", ",", "cl", ")", "\n", "}" ]
10,236
all-10237
[ "MustState", "retrieves", "the", "State", "value", "from", "the", "union", "panicing", "if", "the", "value", "is", "not", "set", "." ]
[ "func", "(", "u", "LedgerEntryChange", ")", "MustState", "(", ")", "LedgerEntry", "{", "val", ",", "ok", ":=", "u", ".", "GetState", "(", ")", "\n\n", "if", "!", "<mask>", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "val", "\n", "}" ]
10,237
all-10238
[ "Prints", "the", "contents", "of", "register", "sa", "to", "Output", ".", "Forcefully", "applies", "html", "escaping", "unless", "the", "variable", "in", "sa", "is", "marked", "raw" ]
[ "func", "txPrint", "(", "st", "*", "State", ")", "{", "arg", ":=", "st", ".", "sa", "\n", "if", "arg", "==", "nil", "{", "st", ".", "Warnf", "(", "\"", "\\n", "\"", ")", "\n", "}", "else", "if", "reflect", ".", "ValueOf", "(", "st", ".", "sa", ")", ".", "<mask>", "(", ")", "!=", "rawStringType", "{", "st", ".", "AppendOutputString", "(", "html", ".", "EscapeString", "(", "interfaceToString", "(", "arg", ")", ")", ")", "\n", "}", "else", "{", "st", ".", "AppendOutputString", "(", "interfaceToString", "(", "arg", ")", ")", "\n", "}", "\n", "st", ".", "Advance", "(", ")", "\n", "}" ]
10,238
all-10239
[ "GetAuthors", "is", "a", "wrapper", "around", "gtk_about_dialog_get_authors", "()", "." ]
[ "func", "(", "v", "*", "AboutDialog", ")", "GetAuthors", "(", ")", "[", "]", "string", "{", "var", "authors", "[", "]", "string", "\n", "cauthors", ":=", "C", ".", "gtk_about_dialog_get_authors", "(", "v", ".", "native", "(", ")", ")", "\n", "if", "cauthors", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "for", "{", "if", "*", "cauthors", "==", "nil", "{", "break", "\n", "}", "\n", "authors", "=", "append", "(", "authors", ",", "C", ".", "GoString", "(", "(", "*", "C", ".", "<mask>", ")", "(", "*", "cauthors", ")", ")", ")", "\n", "cauthors", "=", "C", ".", "next_gcharptr", "(", "cauthors", ")", "\n", "}", "\n", "return", "authors", "\n", "}" ]
10,239
all-10240
[ "Update", "inserts", "or", "replaces", "an", "existing", "entry" ]
[ "func", "(", "nt", "*", "NodeTable", ")", "Update", "(", "key", "[", "]", "byte", ",", "nptr", "unsafe", ".", "Pointer", ")", "(", "updated", "bool", ",", "oldPtr", "unsafe", ".", "Pointer", ")", "{", "res", ":=", "nt", ".", "find", "(", "key", ")", "\n", "if", "res", ".", "status", "&", "ntFoundMask", "==", "ntFoundMask", "{", "// Found key, replace old pointer value with new one", "updated", "=", "true", "\n", "if", "res", ".", "status", "==", "ntFoundInFast", "{", "oldPtr", "=", "decodePointer", "(", "res", ".", "fastHTValue", ")", "\n", "nt", ".", "fastHT", "[", "res", ".", "hash", "]", "=", "encodePointer", "(", "nptr", ",", "res", ".", "hasConflict", ")", "\n", "}", "else", "{", "oldPtr", "=", "decodePointer", "(", "res", ".", "slowHTValues", "[", "res", ".", "slowHTPos", "]", ")", "\n", "res", ".", "slowHTValues", "[", "res", ".", "slowHTPos", "]", "=", "encodePointer", "(", "nptr", ",", "true", ")", "\n", "}", "\n", "}", "else", "{", "// Insert new key", "updated", "=", "false", "\n", "newSlowValue", ":=", "res", ".", "fastHTHasEntry", "&&", "!", "res", ".", "hasConflict", "\n", "// Key needs to be inserted into slowHT", "if", "res", ".", "hasConflict", "||", "newSlowValue", "{", "slowHTValues", ":=", "nt", ".", "slowHT", "[", "res", ".", "hash", "]", "\n", "slowHTValues", "=", "append", "(", "slowHTValues", ",", "encodePointer", "(", "nptr", ",", "false", ")", ")", "\n", "nt", ".", "slowHT", "[", "res", ".", "hash", "]", "=", "slowHTValues", "\n", "// There is an entry already in the fastHT for same crc32 hash", "// We have inserted first entry into the slowHT. Now mark conflict bit.", "if", "newSlowValue", "{", "nt", ".", "fastHT", "[", "res", ".", "hash", "]", "=", "encodePointer", "(", "decodePointer", "(", "nt", ".", "fastHT", "[", "res", ".", "<mask>", "]", ")", ",", "true", ")", "\n", "nt", ".", "conflicts", "++", "\n", "}", "\n", "nt", ".", "slowHTCount", "++", "\n", "}", "else", "{", "// Insert new item into fastHT", "nt", ".", "fastHT", "[", "res", ".", "hash", "]", "=", "encodePointer", "(", "nptr", ",", "false", ")", "\n", "nt", ".", "fastHTCount", "++", "\n", "}", "\n", "}", "\n\n", "return", "\n", "}" ]
10,240
all-10241
[ "Start", "implements", "storage", "interface", "." ]
[ "func", "(", "s", "*", "Storage", ")", "Start", "(", "ctx", "context", ".", "Context", ",", "accessToken", ",", "refreshToken", ",", "sid", ",", "sc", "string", ",", "b", "map", "[", "string", "]", "string", ")", "(", "*", "mnemosynerpc", ".", "Session", ",", "error", ")", "{", "span", ",", "ctx", ":=", "opentracing", ".", "StartSpanFromContext", "(", "ctx", ",", "\"", "\"", ")", "\n", "defer", "<mask>", ".", "Finish", "(", ")", "\n\n", "ent", ":=", "&", "sessionEntity", "{", "AccessToken", ":", "accessToken", ",", "RefreshToken", ":", "refreshToken", ",", "SubjectID", ":", "sid", ",", "SubjectClient", ":", "sc", ",", "Bag", ":", "model", ".", "Bag", "(", "b", ")", ",", "}", "\n\n", "if", "err", ":=", "s", ".", "save", "(", "ctx", ",", "ent", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "ent", ".", "session", "(", ")", "\n", "}" ]
10,241
all-10242
[ "Handle", "sends", "a", "record", "message", "to", "syslog", "Writer", "." ]
[ "func", "(", "handler", "*", "SyslogHandler", ")", "Handle", "(", "record", "*", "Record", ")", "error", "{", "if", "handler", ".", "writter", "==", "nil", "{", "writter", ",", "err", ":=", "syslog", ".", "Dial", "(", "handler", ".", "Network", ",", "handler", ".", "Address", ",", "handler", ".", "Facility", "|", "handler", ".", "Severity", ",", "handler", ".", "Tag", ",", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "handler", ".", "writter", "=", "writter", "\n", "}", "\n\n", "msg", ":=", "handler", ".", "Formatter", ".", "Format", "(", "record", ")", "\n\n", "<mask>", "record", ".", "Level", "{", "case", "EMERGENCY", ":", "return", "handler", ".", "writter", ".", "Emerg", "(", "msg", ")", "\n", "case", "ALERT", ":", "return", "handler", ".", "writter", ".", "Alert", "(", "msg", ")", "\n", "case", "CRITICAL", ":", "return", "handler", ".", "writter", ".", "Crit", "(", "msg", ")", "\n", "case", "ERROR", ":", "return", "handler", ".", "writter", ".", "Err", "(", "msg", ")", "\n", "case", "WARNING", ":", "return", "handler", ".", "writter", ".", "Warning", "(", "msg", ")", "\n", "case", "NOTICE", ":", "return", "handler", ".", "writter", ".", "Notice", "(", "msg", ")", "\n", "case", "INFO", ":", "return", "handler", ".", "writter", ".", "Info", "(", "msg", ")", "\n", "default", ":", "return", "handler", ".", "writter", ".", "Debug", "(", "msg", ")", "\n", "}", "\n", "}" ]
10,242
all-10243
[ "HasY", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "w", "*", "WidgetLayout", ")", "HasY", "(", ")", "bool", "{", "if", "w", "!=", "nil", "&&", "w", ".", "Y", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
10,243
all-10244
[ "DialFunc", "returns", "a", "dial", "function", "that", "can", "be", "used", "to", "connect", "to", "one", "of", "the", "dqlite", "nodes", "." ]
[ "func", "(", "g", "*", "Gateway", ")", "DialFunc", "(", ")", "dqlite", ".", "DialFunc", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "<mask>", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "// Memory connection.", "if", "g", ".", "memoryDial", "!=", "nil", "{", "return", "g", ".", "memoryDial", "(", "ctx", ",", "address", ")", "\n", "}", "\n\n", "return", "dqliteNetworkDial", "(", "ctx", ",", "address", ",", "g", ".", "cert", ")", "\n", "}", "\n", "}" ]
10,244
all-10245
[ "Verify", "compares", "a", "signature", "against", "input", "data" ]
[ "func", "(", "pk", "*", "RsaPublicKey", ")", "Verify", "(", "<mask>", ",", "sig", "[", "]", "byte", ")", "(", "bool", ",", "error", ")", "{", "hashed", ":=", "sha256", ".", "Sum256", "(", "data", ")", "\n", "err", ":=", "rsa", ".", "VerifyPKCS1v15", "(", "pk", ".", "k", ",", "crypto", ".", "SHA256", ",", "hashed", "[", ":", "]", ",", "sig", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "return", "true", ",", "nil", "\n", "}" ]
10,245
all-10246
[ "NewServer", "create", "a", "new", "instance", "of", "Server" ]
[ "func", "NewServer", "(", "filename", "string", ",", "environment", "string", ")", "(", "server", "*", "Server", ",", "err", "error", ")", "{", "conf", ",", "err", ":=", "GetConfig", "(", "filename", ",", "environment", ")", "\n\n", "logFile", ",", "err", ":=", "os", ".", "OpenFile", "(", "conf", ".", "Log", ".", "File", "+", "logFilename", ",", "os", ".", "O_WRONLY", "|", "os", ".", "O_CREATE", "|", "os", ".", "O_APPEND", ",", "0666", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "SetOutput", "(", "os", ".", "Stderr", ")", "\n", "log", ".", "Warningf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "else", "{", "log", ".", "SetOutput", "(", "logFile", ")", "\n", "}", "\n\n", "level", ":=", "<mask>", ".", "ErrorLevel", "\n", "if", "strings", ".", "Compare", "(", "conf", ".", "Log", ".", "Level", ",", "\"", "\"", ")", "!=", "0", "{", "level", ",", "_", "=", "log", ".", "ParseLevel", "(", "conf", ".", "Log", ".", "Level", ")", "\n", "}", "else", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "level", ")", "\n", "}", "\n", "log", ".", "SetLevel", "(", "level", ")", "\n\n", "server", "=", "&", "Server", "{", "Config", ":", "conf", ",", "Done", ":", "make", "(", "chan", "bool", ",", "1", ")", ",", "Error", ":", "make", "(", "chan", "error", ",", "1", ")", ",", "Server", ":", "http", ".", "Server", "{", "Handler", ":", "NewLoggingServeMux", "(", "conf", ")", "}", ",", "quit", ":", "make", "(", "chan", "bool", ")", ",", "isStarted", ":", "false", "}", "\n", "return", "\n", "}" ]
10,246
all-10247
[ "Complete", "internalizes", "command", "line", "arguments" ]
[ "func", "(", "o", "*", "Options", ")", "Complete", "(", "args", "[", "]", "string", ")", "{", "o", ".", "GitRefs", "=", "o", ".", "refs", ".", "gitRefs", "\n", "o", ".", "KeyFiles", "=", "o", ".", "keys", ".", "data", "\n\n", "for", "_", ",", "ref", ":=", "<mask>", "o", ".", "GitRefs", "{", "alias", ",", "err", ":=", "o", ".", "clonePath", ".", "Execute", "(", "OrgRepo", "{", "Org", ":", "ref", ".", "Org", ",", "Repo", ":", "ref", ".", "Repo", "}", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "ref", ".", "PathAlias", "=", "alias", "\n\n", "alias", ",", "err", "=", "o", ".", "cloneURI", ".", "Execute", "(", "OrgRepo", "{", "Org", ":", "ref", ".", "Org", ",", "Repo", ":", "ref", ".", "Repo", "}", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "ref", ".", "CloneURI", "=", "alias", "\n", "}", "\n", "}" ]
10,247
all-10248
[ "SetWithTTL", "is", "equivalent", "of", "Txn", ".", "SetWithTTL", "." ]
[ "func", "(", "wb", "*", "WriteBatch", ")", "SetWithTTL", "(", "key", ",", "val", "[", "]", "byte", ",", "dur", "time", ".", "Duration", ")", "error", "{", "expire", ":=", "time", ".", "Now", "(", ")", ".", "Add", "(", "dur", ")", ".", "Unix", "(", ")", "\n", "e", ":=", "&", "<mask>", "{", "Key", ":", "key", ",", "Value", ":", "val", ",", "ExpiresAt", ":", "uint64", "(", "expire", ")", "}", "\n", "return", "wb", ".", "SetEntry", "(", "e", ")", "\n", "}" ]
10,248
all-10249
[ "Init", "makes", "and", "initializes", "a", "new", "pre", "-", "configured", "Lua", "state", ".", "It", "populates", "the", "luar", "table", "with", "some", "helper", "functions", "/", "values", ":", "method", ":", "ProxyMethod", "unproxify", ":", "Unproxify", "chan", ":", "MakeChan", "complex", ":", "MakeComplex", "map", ":", "MakeMap", "slice", ":", "MakeSlice", "null", ":", "Null", "It", "replaces", "the", "pairs", "/", "ipairs", "functions", "with", "ProxyPairs", "/", "ProxyIpairs", "respectively", "so", "that", "__pairs", "/", "__ipairs", "can", "be", "used", "Lua", "5", ".", "2", "style", ".", "It", "allows", "for", "looping", "over", "Go", "composite", "types", "and", "strings", ".", "It", "also", "replaces", "the", "type", "function", "with", "ProxyType", ".", "It", "is", "not", "required", "for", "using", "the", "GoToLua", "and", "LuaToGo", "functions", "." ]
[ "func", "Init", "(", ")", "*", "lua", ".", "State", "{", "<mask>", "L", "=", "lua", ".", "NewState", "(", ")", "\n", "L", ".", "OpenLibs", "(", ")", "\n", "Register", "(", "L", ",", "\"", "\"", ",", "Map", "{", "// Functions.", "\"", "\"", ":", "Unproxify", ",", "\"", "\"", ":", "ProxyMethod", ",", "\"", "\"", ":", "MakeChan", ",", "\"", "\"", ":", "Complex", ",", "\"", "\"", ":", "MakeMap", ",", "\"", "\"", ":", "MakeSlice", ",", "// Values.", "\"", "\"", ":", "Null", ",", "}", ")", "\n", "Register", "(", "L", ",", "\"", "\"", ",", "Map", "{", "\"", "\"", ":", "ProxyPairs", ",", "\"", "\"", ":", "ProxyType", ",", "}", ")", "\n", "// 'ipairs' needs a special case for performance reasons.", "RegProxyIpairs", "(", "L", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "return", "L", "\n", "}" ]
10,249
all-10250
[ "RegisterClusterHandler", "registers", "the", "http", "handlers", "for", "service", "Cluster", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "the", "given", "implementation", "of", "ClusterClient", ".", "Note", ":", "the", "gRPC", "framework", "executes", "interceptors", "within", "the", "gRPC", "handler", ".", "If", "the", "passed", "in", "ClusterClient", "doesn", "t", "go", "through", "the", "normal", "gRPC", "flow", "(", "creating", "a", "gRPC", "client", "etc", ".", ")", "then", "it", "will", "be", "up", "to", "the", "passed", "in", "ClusterClient", "to", "call", "the", "correct", "interceptors", "." ]
[ "func", "RegisterClusterHandlerClient", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "client", "etcdserverpb", ".", "ClusterClient", ")", "error", "{", "mux", ".", "Handle", "(", "\"", "\"", ",", "pattern_Cluster_MemberAdd_0", ",", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "pathParams", "map", "[", "string", "]", "string", ")", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "req", ".", "Context", "(", ")", ")", "\n", "defer", "cancel", "(", ")", "\n", "if", "cn", ",", "ok", ":=", "w", ".", "(", "http", ".", "CloseNotifier", ")", ";", "ok", "{", "go", "func", "(", "done", "<-", "chan", "struct", "{", "}", ",", "closed", "<-", "chan", "bool", ")", "{", "select", "{", "case", "<-", "done", ":", "case", "<-", "closed", ":", "cancel", "(", ")", "\n", "}", "\n", "}", "(", "ctx", ".", "Done", "(", ")", ",", "cn", ".", "CloseNotify", "(", ")", ")", "\n", "}", "\n", "inboundMarshaler", ",", "outboundMarshaler", ":=", "runtime", ".", "MarshalerForRequest", "(", "mux", ",", "req", ")", "\n", "rctx", ",", "err", ":=", "runtime", ".", "AnnotateContext", "(", "ctx", ",", "mux", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "runtime", ".", "HTTPError", "(", "ctx", ",", "mux", ",", "outboundMarshaler", ",", "w", ",", "req", ",", "err", ")", "\n", "return", "\n", "}", "\n", "resp", ",", "md", ",", "err", ":=", "request_Cluster_MemberAdd_0", "(", "rctx", ",", "inboundMarshaler", ",", "client", ",", "req", ",", "pathParams", ")", "\n", "ctx", "=", "runtime", ".", "NewServerMetadataContext", "(", "ctx", ",", "<mask>", ")", "\n", "if", "err", "!=", "nil", "{", "runtime", ".", "HTTPError", "(", "ctx", ",", "mux", ",", "outboundMarshaler", ",", "w", ",", "req", ",", "err", ")", "\n", "return", "\n", "}", "\n\n", "forward_Cluster_MemberAdd_0", "(", "ctx", ",", "mux", ",", "outboundMarshaler", ",", "w", ",", "req", ",", "resp", ",", "mux", ".", "GetForwardResponseOptions", "(", ")", "...", ")", "\n\n", "}", ")", "\n\n", "mux", ".", "Handle", "(", "\"", "\"", ",", "pattern_Cluster_MemberRemove_0", ",", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "pathParams", "map", "[", "string", "]", "string", ")", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "req", ".", "Context", "(", ")", ")", "\n", "defer", "cancel", "(", ")", "\n", "if", "cn", ",", "ok", ":=", "w", ".", "(", "http", ".", "CloseNotifier", ")", ";", "ok", "{", "go", "func", "(", "done", "<-", "chan", "struct", "{", "}", ",", "closed", "<-", "chan", "bool", ")", "{", "select", "{", "case", "<-", "done", ":", "case", "<-", "closed", ":", "cancel", "(", ")", "\n", "}", "\n", "}", "(", "ctx", ".", "Done", "(", ")", ",", "cn", ".", "CloseNotify", "(", ")", ")", "\n", "}", "\n", "inboundMarshaler", ",", "outboundMarshaler", ":=", "runtime", ".", "MarshalerForRequest", "(", "mux", ",", "req", ")", "\n", "rctx", ",", "err", ":=", "runtime", ".", "AnnotateContext", "(", "ctx", ",", "mux", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "runtime", ".", "HTTPError", "(", "ctx", ",", "mux", ",", "outboundMarshaler", ",", "w", ",", "req", ",", "err", ")", "\n", "return", "\n", "}", "\n", "resp", ",", "md", ",", "err", ":=", "request_Cluster_MemberRemove_0", "(", "rctx", ",", "inboundMarshaler", ",", "client", ",", "req", ",", "pathParams", ")", "\n", "ctx", "=", "runtime", ".", "NewServerMetadataContext", "(", "ctx", ",", "md", ")", "\n", "if", "err", "!=", "nil", "{", "runtime", ".", "HTTPError", "(", "ctx", ",", "mux", ",", "outboundMarshaler", ",", "w", ",", "req", ",", "err", ")", "\n", "return", "\n", "}", "\n\n", "forward_Cluster_MemberRemove_0", "(", "ctx", ",", "mux", ",", "outboundMarshaler", ",", "w", ",", "req", ",", "resp", ",", "mux", ".", "GetForwardResponseOptions", "(", ")", "...", ")", "\n\n", "}", ")", "\n\n", "mux", ".", "Handle", "(", "\"", "\"", ",", "pattern_Cluster_MemberUpdate_0", ",", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "pathParams", "map", "[", "string", "]", "string", ")", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "req", ".", "Context", "(", ")", ")", "\n", "defer", "cancel", "(", ")", "\n", "if", "cn", ",", "ok", ":=", "w", ".", "(", "http", ".", "CloseNotifier", ")", ";", "ok", "{", "go", "func", "(", "done", "<-", "chan", "struct", "{", "}", ",", "closed", "<-", "chan", "bool", ")", "{", "select", "{", "case", "<-", "done", ":", "case", "<-", "closed", ":", "cancel", "(", ")", "\n", "}", "\n", "}", "(", "ctx", ".", "Done", "(", ")", ",", "cn", ".", "CloseNotify", "(", ")", ")", "\n", "}", "\n", "inboundMarshaler", ",", "outboundMarshaler", ":=", "runtime", ".", "MarshalerForRequest", "(", "mux", ",", "req", ")", "\n", "rctx", ",", "err", ":=", "runtime", ".", "AnnotateContext", "(", "ctx", ",", "mux", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "runtime", ".", "HTTPError", "(", "ctx", ",", "mux", ",", "outboundMarshaler", ",", "w", ",", "req", ",", "err", ")", "\n", "return", "\n", "}", "\n", "resp", ",", "md", ",", "err", ":=", "request_Cluster_MemberUpdate_0", "(", "rctx", ",", "inboundMarshaler", ",", "client", ",", "req", ",", "pathParams", ")", "\n", "ctx", "=", "runtime", ".", "NewServerMetadataContext", "(", "ctx", ",", "md", ")", "\n", "if", "err", "!=", "nil", "{", "runtime", ".", "HTTPError", "(", "ctx", ",", "mux", ",", "outboundMarshaler", ",", "w", ",", "req", ",", "err", ")", "\n", "return", "\n", "}", "\n\n", "forward_Cluster_MemberUpdate_0", "(", "ctx", ",", "mux", ",", "outboundMarshaler", ",", "w", ",", "req", ",", "resp", ",", "mux", ".", "GetForwardResponseOptions", "(", ")", "...", ")", "\n\n", "}", ")", "\n\n", "mux", ".", "Handle", "(", "\"", "\"", ",", "pattern_Cluster_MemberList_0", ",", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "pathParams", "map", "[", "string", "]", "string", ")", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "req", ".", "Context", "(", ")", ")", "\n", "defer", "cancel", "(", ")", "\n", "if", "cn", ",", "ok", ":=", "w", ".", "(", "http", ".", "CloseNotifier", ")", ";", "ok", "{", "go", "func", "(", "done", "<-", "chan", "struct", "{", "}", ",", "closed", "<-", "chan", "bool", ")", "{", "select", "{", "case", "<-", "done", ":", "case", "<-", "closed", ":", "cancel", "(", ")", "\n", "}", "\n", "}", "(", "ctx", ".", "Done", "(", ")", ",", "cn", ".", "CloseNotify", "(", ")", ")", "\n", "}", "\n", "inboundMarshaler", ",", "outboundMarshaler", ":=", "runtime", ".", "MarshalerForRequest", "(", "mux", ",", "req", ")", "\n", "rctx", ",", "err", ":=", "runtime", ".", "AnnotateContext", "(", "ctx", ",", "mux", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "runtime", ".", "HTTPError", "(", "ctx", ",", "mux", ",", "outboundMarshaler", ",", "w", ",", "req", ",", "err", ")", "\n", "return", "\n", "}", "\n", "resp", ",", "md", ",", "err", ":=", "request_Cluster_MemberList_0", "(", "rctx", ",", "inboundMarshaler", ",", "client", ",", "req", ",", "pathParams", ")", "\n", "ctx", "=", "runtime", ".", "NewServerMetadataContext", "(", "ctx", ",", "md", ")", "\n", "if", "err", "!=", "nil", "{", "runtime", ".", "HTTPError", "(", "ctx", ",", "mux", ",", "outboundMarshaler", ",", "w", ",", "req", ",", "err", ")", "\n", "return", "\n", "}", "\n\n", "forward_Cluster_MemberList_0", "(", "ctx", ",", "mux", ",", "outboundMarshaler", ",", "w", ",", "req", ",", "resp", ",", "mux", ".", "GetForwardResponseOptions", "(", ")", "...", ")", "\n\n", "}", ")", "\n\n", "return", "nil", "\n", "}" ]
10,250
all-10251
[ "SetHostBytes", "sets", "Host", "header", "value", "." ]
[ "func", "(", "h", "*", "RequestHeader", ")", "SetHostBytes", "(", "host", "[", "]", "byte", ")", "{", "h", ".", "parseRawHeaders", "(", ")", "\n", "h", ".", "host", "=", "<mask>", "(", "h", ".", "host", "[", ":", "0", "]", ",", "host", "...", ")", "\n", "}" ]
10,251
all-10252
[ "Status", "returns", "the", "statuses", "of", "workers", "referenced", "by", "pipelineRcName", ".", "pipelineRcName", "is", "the", "name", "of", "the", "pipeline", "s", "RC", "and", "can", "be", "gotten", "with", "ppsutil", ".", "PipelineRcName", ".", "You", "can", "also", "pass", "for", "pipelineRcName", "to", "get", "all", "clients", "for", "all", "workers", "." ]
[ "func", "Status", "(", "ctx", "context", ".", "Context", ",", "pipelineRcName", "string", ",", "etcdClient", "*", "etcd", ".", "<mask>", ",", "etcdPrefix", "string", ",", "workerGrpcPort", "uint16", ")", "(", "[", "]", "*", "pps", ".", "WorkerStatus", ",", "error", ")", "{", "workerClients", ",", "err", ":=", "Clients", "(", "ctx", ",", "pipelineRcName", ",", "etcdClient", ",", "etcdPrefix", ",", "workerGrpcPort", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "var", "result", "[", "]", "*", "pps", ".", "WorkerStatus", "\n", "for", "_", ",", "workerClient", ":=", "range", "workerClients", "{", "status", ",", "err", ":=", "workerClient", ".", "Status", "(", "ctx", ",", "&", "types", ".", "Empty", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "result", "=", "append", "(", "result", ",", "status", ")", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
10,252
all-10253
[ "SetPath", "sets", "URI", "path", "." ]
[ "func", "(", "u", "*", "URI", ")", "SetPath", "(", "path", "string", ")", "{", "u", ".", "pathOriginal", "=", "<mask>", "(", "u", ".", "pathOriginal", "[", ":", "0", "]", ",", "path", "...", ")", "\n", "u", ".", "path", "=", "normalizePath", "(", "u", ".", "path", ",", "u", ".", "pathOriginal", ")", "\n", "}" ]
10,253
all-10254
[ "EventButtonNewFromEvent", "returns", "an", "EventButton", "from", "an", "Event", ".", "Using", "widget", ".", "Connect", "()", "for", "a", "key", "related", "signal", "such", "as", "button", "-", "press", "-", "event", "results", "in", "a", "*", "Event", "being", "passed", "as", "the", "callback", "s", "second", "argument", ".", "The", "argument", "is", "actually", "a", "*", "EventButton", ".", "EventButtonNewFromEvent", "provides", "a", "means", "of", "creating", "an", "EventKey", "from", "the", "Event", "." ]
[ "func", "EventButtonNewFromEvent", "(", "<mask>", "*", "Event", ")", "*", "EventButton", "{", "ee", ":=", "(", "*", "C", ".", "GdkEvent", ")", "(", "unsafe", ".", "Pointer", "(", "event", ".", "native", "(", ")", ")", ")", "\n", "ev", ":=", "Event", "{", "ee", "}", "\n", "return", "&", "EventButton", "{", "&", "ev", "}", "\n", "}" ]
10,254
all-10255
[ "WithImage", "png", "encoded", "image", "." ]
[ "func", "(", "p", "SetDockTileParams", ")", "WithImage", "(", "image", "string", ")", "*", "SetDockTileParams", "{", "p", ".", "Image", "=", "<mask>", "\n", "return", "&", "p", "\n", "}" ]
10,255
all-10256
[ "Validate", "returns", "an", "error", "if", "the", "query", "has", "any", "errors", ".", "Examples", "include", ":", "*", "an", "org", "name", "that", "is", "empty", "or", "includes", "a", "/", "*", "repos", "that", "are", "not", "org", "/", "repo", "*", "a", "label", "that", "is", "in", "both", "the", "labels", "and", "missing_labels", "section", "*", "a", "branch", "that", "is", "in", "both", "included", "and", "excluded", "branch", "set", "." ]
[ "func", "(", "tq", "*", "TideQuery", ")", "Validate", "(", ")", "error", "{", "duplicates", ":=", "func", "(", "field", "string", ",", "list", "[", "]", "string", ")", "error", "{", "dups", ":=", "sets", ".", "NewString", "(", ")", "\n", "seen", ":=", "sets", ".", "NewString", "(", ")", "\n", "for", "_", ",", "elem", ":=", "range", "list", "{", "if", "seen", ".", "Has", "(", "elem", ")", "{", "dups", ".", "Insert", "(", "elem", ")", "\n", "}", "else", "{", "seen", ".", "Insert", "(", "elem", ")", "\n", "}", "\n", "}", "\n", "dupCount", ":=", "len", "(", "list", ")", "-", "seen", ".", "Len", "(", ")", "\n", "if", "dupCount", "==", "0", "{", "return", "nil", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "field", ",", "dupCount", ",", "strings", ".", "Join", "(", "dups", ".", "List", "(", ")", ",", "\"", "\"", ")", ")", "\n", "}", "\n\n", "orgs", ":=", "sets", ".", "NewString", "(", ")", "\n", "for", "o", ":=", "range", "tq", ".", "Orgs", "{", "if", "strings", ".", "Contains", "(", "tq", ".", "Orgs", "[", "o", "]", ",", "\"", "\"", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "o", ",", "tq", ".", "Orgs", "[", "o", "]", ")", "\n", "}", "\n", "if", "len", "(", "tq", ".", "Orgs", "[", "o", "]", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "o", ")", "\n", "}", "\n", "orgs", ".", "Insert", "(", "tq", ".", "Orgs", "[", "o", "]", ")", "\n", "}", "\n", "if", "err", ":=", "duplicates", "(", "\"", "\"", ",", "tq", ".", "Orgs", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "for", "r", ":=", "range", "tq", ".", "Repos", "{", "parts", ":=", "strings", ".", "Split", "(", "tq", ".", "Repos", "[", "r", "]", ",", "\"", "\"", ")", "\n", "if", "len", "(", "parts", ")", "!=", "2", "||", "len", "(", "<mask>", "[", "0", "]", ")", "==", "0", "||", "len", "(", "parts", "[", "1", "]", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ",", "r", ",", "tq", ".", "Repos", "[", "r", "]", ")", "\n", "}", "\n", "if", "orgs", ".", "Has", "(", "parts", "[", "0", "]", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "r", ",", "tq", ".", "Repos", "[", "r", "]", ",", "parts", "[", "0", "]", ")", "\n", "}", "\n", "}", "\n", "if", "err", ":=", "duplicates", "(", "\"", "\"", ",", "tq", ".", "Repos", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "len", "(", "tq", ".", "Orgs", ")", "==", "0", "&&", "len", "(", "tq", ".", "Repos", ")", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "for", "er", ":=", "range", "tq", ".", "ExcludedRepos", "{", "parts", ":=", "strings", ".", "Split", "(", "tq", ".", "ExcludedRepos", "[", "er", "]", ",", "\"", "\"", ")", "\n", "if", "len", "(", "parts", ")", "!=", "2", "||", "len", "(", "parts", "[", "0", "]", ")", "==", "0", "||", "len", "(", "parts", "[", "1", "]", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ",", "er", ",", "tq", ".", "ExcludedRepos", "[", "er", "]", ")", "\n", "}", "\n", "if", "!", "orgs", ".", "Has", "(", "parts", "[", "0", "]", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "er", ",", "tq", ".", "ExcludedRepos", "[", "er", "]", ",", "parts", "[", "0", "]", ")", "\n", "}", "\n", "// Note: At this point we also know that this excludedRepo is not found in 'repos'.", "}", "\n", "if", "err", ":=", "duplicates", "(", "\"", "\"", ",", "tq", ".", "ExcludedRepos", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "invalids", ":=", "sets", ".", "NewString", "(", "tq", ".", "Labels", "...", ")", ".", "Intersection", "(", "sets", ".", "NewString", "(", "tq", ".", "MissingLabels", "...", ")", ")", ";", "len", "(", "invalids", ")", ">", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "invalids", ".", "List", "(", ")", ")", "\n", "}", "\n", "if", "err", ":=", "duplicates", "(", "\"", "\"", ",", "tq", ".", "Labels", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "duplicates", "(", "\"", "\"", ",", "tq", ".", "MissingLabels", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "len", "(", "tq", ".", "ExcludedBranches", ")", ">", "0", "&&", "len", "(", "tq", ".", "IncludedBranches", ")", ">", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "err", ":=", "duplicates", "(", "\"", "\"", ",", "tq", ".", "IncludedBranches", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "duplicates", "(", "\"", "\"", ",", "tq", ".", "ExcludedBranches", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
10,256
all-10257
[ "formatValue", "formats", "a", "value", "for", "serialization" ]
[ "func", "formatLogfmtValue", "(", "value", "interface", "{", "}", ")", "string", "{", "if", "value", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n\n", "value", "=", "formatShared", "(", "value", ")", "\n", "switch", "v", ":=", "value", ".", "(", "type", ")", "{", "case", "bool", ":", "return", "strconv", ".", "FormatBool", "(", "v", ")", "\n", "case", "float32", ":", "return", "strconv", ".", "FormatFloat", "(", "float64", "(", "v", ")", ",", "floatFormat", ",", "3", ",", "64", ")", "\n", "<mask>", "float64", ":", "return", "strconv", ".", "FormatFloat", "(", "v", ",", "floatFormat", ",", "3", ",", "64", ")", "\n", "case", "int", ",", "int8", ",", "int16", ",", "int32", ",", "int64", ",", "uint", ",", "uint8", ",", "uint16", ",", "uint32", ",", "uint64", ":", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "value", ")", "\n", "case", "string", ":", "return", "escapeString", "(", "v", ")", "\n", "default", ":", "return", "escapeString", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "value", ")", ")", "\n", "}", "\n", "}" ]
10,257
all-10258
[ "PullImage", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockDockerClient", ")", "PullImage", "(", "arg0", "context", ".", "Context", ",", "arg1", "string", ",", "arg2", "*", "<mask>", ".", "RegistryAuthenticationData", ",", "arg3", "time", ".", "Duration", ")", "dockerapi", ".", "DockerContainerMetadata", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "dockerapi", ".", "DockerContainerMetadata", ")", "\n", "return", "ret0", "\n", "}" ]
10,258
all-10259
[ "Warnf", "outputs", "formatted", "Warn", "level", "log" ]
[ "func", "Warnf", "(", "format", "string", ",", "val", "...", "interface", "{", "}", ")", "error", "{", "return", "glg", ".", "out", "(", "WARN", ",", "<mask>", ",", "val", "...", ")", "\n", "}" ]
10,259
all-10260
[ "selectToSlice", "returns", "a", "slice", "value", "fetched", "from", "rows", "." ]
[ "func", "(", "db", "*", "DB", ")", "selectToSlice", "(", "<mask>", "*", "sql", ".", "Rows", ",", "t", "reflect", ".", "Type", ")", "(", "reflect", ".", "Value", ",", "error", ")", "{", "columns", ",", "err", ":=", "rows", ".", "Columns", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "reflect", ".", "Value", "{", "}", ",", "err", "\n", "}", "\n", "t", "=", "t", ".", "Elem", "(", ")", "\n", "ptrN", ":=", "0", "\n", "for", ";", "t", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", ";", "ptrN", "++", "{", "t", "=", "t", ".", "Elem", "(", ")", "\n", "}", "\n", "fieldIndexes", ":=", "make", "(", "[", "]", "[", "]", "int", ",", "len", "(", "columns", ")", ")", "\n", "for", "i", ",", "column", ":=", "range", "columns", "{", "index", ":=", "db", ".", "fieldIndexByName", "(", "t", ",", "column", ",", "nil", ")", "\n", "if", "len", "(", "index", ")", "<", "1", "{", "return", "reflect", ".", "Value", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "stringutil", ".", "ToUpperCamelCase", "(", "column", ")", ",", "t", ")", "\n", "}", "\n", "fieldIndexes", "[", "i", "]", "=", "index", "\n", "}", "\n", "dest", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "len", "(", "columns", ")", ")", "\n", "var", "result", "[", "]", "reflect", ".", "Value", "\n", "for", "rows", ".", "Next", "(", ")", "{", "v", ":=", "reflect", ".", "New", "(", "t", ")", ".", "Elem", "(", ")", "\n", "for", "i", ",", "index", ":=", "range", "fieldIndexes", "{", "field", ":=", "v", ".", "FieldByIndex", "(", "index", ")", "\n", "dest", "[", "i", "]", "=", "field", ".", "Addr", "(", ")", ".", "Interface", "(", ")", "\n", "}", "\n", "if", "err", ":=", "rows", ".", "Scan", "(", "dest", "...", ")", ";", "err", "!=", "nil", "{", "return", "reflect", ".", "Value", "{", "}", ",", "err", "\n", "}", "\n", "result", "=", "append", "(", "result", ",", "v", ")", "\n", "}", "\n", "if", "err", ":=", "rows", ".", "Err", "(", ")", ";", "err", "!=", "nil", "{", "return", "reflect", ".", "Value", "{", "}", ",", "err", "\n", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "ptrN", ";", "i", "++", "{", "t", "=", "reflect", ".", "PtrTo", "(", "t", ")", "\n", "}", "\n", "slice", ":=", "reflect", ".", "MakeSlice", "(", "reflect", ".", "SliceOf", "(", "t", ")", ",", "len", "(", "result", ")", ",", "len", "(", "result", ")", ")", "\n", "for", "i", ",", "v", ":=", "range", "result", "{", "for", "j", ":=", "0", ";", "j", "<", "ptrN", ";", "j", "++", "{", "v", "=", "v", ".", "Addr", "(", ")", "\n", "}", "\n", "slice", ".", "Index", "(", "i", ")", ".", "Set", "(", "v", ")", "\n", "}", "\n", "return", "slice", ",", "nil", "\n", "}" ]
10,260
all-10261
[ "GetRevisionFromSpec", "returns", "a", "main", "ref", "or", "sha", "from", "a", "spec", "object" ]
[ "func", "GetRevisionFromSpec", "(", "spec", "*", "JobSpec", ")", "string", "{", "if", "<mask>", ".", "Refs", "!=", "nil", "{", "return", "getRevisionFromRef", "(", "spec", ".", "Refs", ")", "\n", "}", "else", "if", "len", "(", "spec", ".", "ExtraRefs", ")", ">", "0", "{", "return", "getRevisionFromRef", "(", "&", "spec", ".", "ExtraRefs", "[", "0", "]", ")", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
10,261
all-10262
[ "removeJob", "removes", "the", "job", "from", "cronAgent" ]
[ "func", "(", "c", "*", "Cron", ")", "removeJob", "(", "name", "string", ")", "error", "{", "job", ",", "ok", ":=", "c", ".", "<mask>", "[", "name", "]", "\n", "if", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n", "c", ".", "cronAgent", ".", "Remove", "(", "job", ".", "entryID", ")", "\n", "delete", "(", "c", ".", "jobs", ",", "name", ")", "\n", "c", ".", "logger", ".", "Infof", "(", "\"", "\"", ",", "name", ")", "\n", "return", "nil", "\n", "}" ]
10,262
all-10263
[ "LogResp", "is", "like", "log", ".", "Logger", ".", "Log", "()", ".", "However", "1", ")", "It", "assumes", "that", "it", "s", "being", "called", "from", "a", "defer", "()", "statement", "in", "a", "GRPC", "method", "and", "correspondingly", "extracts", "the", "method", "name", "from", "the", "grandparent", "stack", "frame", "2", ")", "It", "logs", "NotActivatedError", "at", "DebugLevel", "instead", "of", "ErrorLevel", "as", "in", "most", "cases", "this", "error", "is", "expected", "and", "logging", "it", "frequently", "may", "confuse", "users" ]
[ "func", "(", "a", "*", "apiServer", ")", "LogResp", "(", "request", "interface", "{", "}", ",", "response", "interface", "{", "}", ",", "err", "error", ",", "duration", "time", ".", "Duration", ")", "{", "if", "err", "==", "nil", "{", "a", ".", "pachLogger", ".", "LogAtLevelFromDepth", "(", "request", ",", "response", ",", "err", ",", "duration", ",", "logrus", ".", "InfoLevel", ",", "4", ")", "\n", "}", "else", "if", "authclient", ".", "IsErrNotActivated", "(", "err", ")", "{", "a", ".", "pachLogger", ".", "LogAtLevelFromDepth", "(", "<mask>", ",", "response", ",", "err", ",", "duration", ",", "logrus", ".", "DebugLevel", ",", "4", ")", "\n", "}", "else", "{", "a", ".", "pachLogger", ".", "LogAtLevelFromDepth", "(", "request", ",", "response", ",", "err", ",", "duration", ",", "logrus", ".", "ErrorLevel", ",", "4", ")", "\n", "}", "\n", "}" ]
10,263
all-10264
[ "UpdateAll", "updates", "all", "the", "acquired", "resources", "with", "a", "given", "state" ]
[ "func", "(", "c", "*", "Client", ")", "UpdateAll", "(", "<mask>", "string", ")", "error", "{", "return", "c", ".", "basic", ".", "UpdateAll", "(", "state", ")", "\n", "}" ]
10,264
all-10265
[ "GetLastStat", "returns", "the", "last", "recorded", "raw", "statistics", "object", "from", "docker" ]
[ "func", "(", "queue", "*", "Queue", ")", "GetLastStat", "(", ")", "*", "types", ".", "StatsJSON", "{", "queue", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "queue", ".", "<mask>", ".", "RUnlock", "(", ")", "\n\n", "return", "queue", ".", "lastStat", "\n", "}" ]
10,265
all-10266
[ "attach", "multiple", "buffer", "objects", "to", "a", "vertex", "array", "object" ]
[ "func", "VertexArrayVertexBuffers", "(", "vaobj", "uint32", ",", "first", "uint32", ",", "count", "int32", ",", "buffers", "*", "uint32", ",", "offsets", "*", "int", ",", "strides", "*", "int32", ")", "{", "syscall", ".", "Syscall6", "(", "gpVertexArrayVertexBuffers", ",", "6", ",", "uintptr", "(", "vaobj", ")", ",", "uintptr", "(", "first", ")", ",", "uintptr", "(", "<mask>", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "buffers", ")", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "offsets", ")", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "strides", ")", ")", ")", "\n", "}" ]
10,266
all-10267
[ "DeepCopyInto", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "writing", "into", "out", ".", "in", "must", "be", "non", "-", "nil", "." ]
[ "func", "(", "in", "Labels", ")", "DeepCopyInto", "(", "out", "*", "Labels", ")", "{", "{", "in", ":=", "&", "in", "\n", "*", "<mask>", "=", "make", "(", "Labels", ",", "len", "(", "*", "in", ")", ")", "\n", "for", "key", ",", "val", ":=", "range", "*", "in", "{", "(", "*", "out", ")", "[", "key", "]", "=", "val", "\n", "}", "\n", "return", "\n", "}", "\n", "}" ]
10,267
all-10268
[ "title", ":", "remove", "node", "healing", "path", ":", "/", "healing", "/", "node", "method", ":", "DELETE", "produce", ":", "application", "/", "json", "responses", ":", "200", ":", "Ok", "401", ":", "Unauthorized" ]
[ "func", "nodeHealingDelete", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "t", "auth", ".", "Token", ")", "(", "err", "error", ")", "{", "poolName", ":=", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "var", "ctxs", "[", "]", "permTypes", ".", "PermissionContext", "\n", "if", "poolName", "!=", "\"", "\"", "{", "ctxs", "=", "append", "(", "ctxs", ",", "permission", ".", "Context", "(", "permTypes", ".", "CtxPool", ",", "poolName", ")", ")", "\n", "}", "\n", "if", "!", "permission", ".", "Check", "(", "t", ",", "permission", ".", "PermHealingDelete", ",", "ctxs", "...", ")", "{", "return", "permission", ".", "ErrUnauthorized", "\n", "}", "\n", "evt", ",", "err", ":=", "event", ".", "New", "(", "&", "<mask>", ".", "Opts", "{", "Target", ":", "event", ".", "Target", "{", "Type", ":", "event", ".", "TargetTypePool", ",", "Value", ":", "poolName", "}", ",", "Kind", ":", "permission", ".", "PermHealingDelete", ",", "Owner", ":", "t", ",", "CustomData", ":", "event", ".", "FormToCustomData", "(", "InputFields", "(", "r", ")", ")", ",", "DisableLock", ":", "true", ",", "Allowed", ":", "event", ".", "Allowed", "(", "permission", ".", "PermPoolReadEvents", ",", "ctxs", "...", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "func", "(", ")", "{", "evt", ".", "Done", "(", "err", ")", "}", "(", ")", "\n", "if", "len", "(", "r", ".", "URL", ".", "Query", "(", ")", "[", "\"", "\"", "]", ")", "==", "0", "{", "return", "healer", ".", "RemoveConfig", "(", "poolName", ",", "\"", "\"", ")", "\n", "}", "\n", "for", "_", ",", "v", ":=", "range", "r", ".", "URL", ".", "Query", "(", ")", "[", "\"", "\"", "]", "{", "err", ":=", "healer", ".", "RemoveConfig", "(", "poolName", ",", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
10,268
all-10269
[ "seekFrom", "brings", "us", "to", "a", "key", "that", "is", ">", "=", "input", "key", "." ]
[ "func", "(", "itr", "*", "Iterator", ")", "seekFrom", "(", "key", "[", "]", "byte", ",", "whence", "int", ")", "{", "itr", ".", "err", "=", "nil", "\n", "<mask>", "whence", "{", "case", "origin", ":", "itr", ".", "reset", "(", ")", "\n", "case", "current", ":", "}", "\n\n", "idx", ":=", "sort", ".", "Search", "(", "len", "(", "itr", ".", "t", ".", "blockIndex", ")", ",", "func", "(", "idx", "int", ")", "bool", "{", "ko", ":=", "itr", ".", "t", ".", "blockIndex", "[", "idx", "]", "\n", "return", "y", ".", "CompareKeys", "(", "ko", ".", "key", ",", "key", ")", ">", "0", "\n", "}", ")", "\n", "if", "idx", "==", "0", "{", "// The smallest key in our table is already strictly > key. We can return that.", "// This is like a SeekToFirst.", "itr", ".", "seekHelper", "(", "0", ",", "key", ")", "\n", "return", "\n", "}", "\n\n", "// block[idx].smallest is > key.", "// Since idx>0, we know block[idx-1].smallest is <= key.", "// There are two cases.", "// 1) Everything in block[idx-1] is strictly < key. In this case, we should go to the first", "// element of block[idx].", "// 2) Some element in block[idx-1] is >= key. We should go to that element.", "itr", ".", "seekHelper", "(", "idx", "-", "1", ",", "key", ")", "\n", "if", "itr", ".", "err", "==", "io", ".", "EOF", "{", "// Case 1. Need to visit block[idx].", "if", "idx", "==", "len", "(", "itr", ".", "t", ".", "blockIndex", ")", "{", "// If idx == len(itr.t.blockIndex), then input key is greater than ANY element of table.", "// There's nothing we can do. Valid() should return false as we seek to end of table.", "return", "\n", "}", "\n", "// Since block[idx].smallest is > key. This is essentially a block[idx].SeekToFirst.", "itr", ".", "seekHelper", "(", "idx", ",", "key", ")", "\n", "}", "\n", "// Case 2: No need to do anything. We already did the seek in block[idx-1].", "}" ]
10,269
all-10270
[ "Stability", ":", "***", "EXPERIMENTAL", "***", "Give", "some", "basic", "stats", "on", "the", "health", "of", "our", "EC2", "account", "See", "https", ":", "//", "docs", ".", "taskcluster", ".", "net", "/", "reference", "/", "core", "/", "ec2", "-", "manager", "/", "api", "-", "docs#getHealth" ]
[ "func", "(", "eC2Manager", "*", "EC2Manager", ")", "GetHealth", "(", ")", "(", "*", "HealthOfTheEC2Account", ",", "error", ")", "{", "cd", ":=", "tcclient", ".", "<mask>", "(", "*", "eC2Manager", ")", "\n", "responseObject", ",", "_", ",", "err", ":=", "(", "&", "cd", ")", ".", "APICall", "(", "nil", ",", "\"", "\"", ",", "\"", "\"", ",", "new", "(", "HealthOfTheEC2Account", ")", ",", "nil", ")", "\n", "return", "responseObject", ".", "(", "*", "HealthOfTheEC2Account", ")", ",", "err", "\n", "}" ]
10,270
all-10271
[ "DockerIDByV3EndpointID", "returns", "a", "docker", "ID", "for", "a", "given", "v3", "endpoint", "ID" ]
[ "func", "(", "state", "*", "DockerTaskEngineState", ")", "DockerIDByV3EndpointID", "(", "v3EndpointID", "string", ")", "(", "string", ",", "bool", ")", "{", "state", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "state", ".", "<mask>", ".", "RUnlock", "(", ")", "\n\n", "dockerID", ",", "ok", ":=", "state", ".", "v3EndpointIDToDockerID", "[", "v3EndpointID", "]", "\n", "return", "dockerID", ",", "ok", "\n", "}" ]
10,271
all-10272
[ "GetError", "retrieves", "the", "Error", "value", "from", "the", "union", "returning", "ok", "if", "the", "union", "s", "switch", "indicated", "the", "value", "is", "valid", "." ]
[ "func", "(", "u", "StellarMessage", ")", "GetError", "(", ")", "(", "result", "Error", ",", "ok", "bool", ")", "{", "armName", ",", "_", ":=", "u", ".", "ArmForSwitch", "(", "int32", "(", "u", ".", "Type", ")", ")", "\n\n", "if", "armName", "==", "\"", "\"", "{", "result", "=", "*", "u", ".", "Error", "\n", "<mask>", "=", "true", "\n", "}", "\n\n", "return", "\n", "}" ]
10,272
all-10273
[ "RecordContainerReference", "adds", "container", "reference", "to", "the", "corresponding", "imageState", "object" ]
[ "func", "(", "imageManager", "*", "dockerImageManager", ")", "RecordContainerReference", "(", "container", "*", "apicontainer", ".", "Container", ")", "error", "{", "// the image state has been updated, save the new state", "defer", "imageManager", ".", "saver", ".", "ForceSave", "(", ")", "\n", "// On agent restart, container ID was retrieved from agent state file", "// TODO add setter and getter for modifying this", "if", "container", ".", "ImageID", "!=", "\"", "\"", "{", "if", "!", "imageManager", ".", "addContainerReferenceToExistingImageState", "(", "container", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}", "\n\n", "if", "container", ".", "Image", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Inspect image for obtaining Container's Image ID", "imageInspected", ",", "err", ":=", "imageManager", ".", "client", ".", "InspectImage", "(", "container", ".", "Image", ")", "\n", "if", "err", "!=", "nil", "{", "seelog", ".", "Errorf", "(", "\"", "\"", ",", "<mask>", ".", "Image", ",", "err", ")", "\n", "return", "err", "\n", "}", "\n\n", "container", ".", "ImageID", "=", "imageInspected", ".", "ID", "\n", "added", ":=", "imageManager", ".", "addContainerReferenceToExistingImageState", "(", "container", ")", "\n", "if", "!", "added", "{", "imageManager", ".", "addContainerReferenceToNewImageState", "(", "container", ",", "imageInspected", ".", "Size", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
10,273
all-10274
[ "Subscribe", "subscribes", "to", "a", "topic", "in", "a", "remote", "event", "bus" ]
[ "func", "(", "client", "*", "<mask>", ")", "Subscribe", "(", "topic", "string", ",", "fn", "interface", "{", "}", ",", "serverAddr", ",", "serverPath", "string", ")", "{", "client", ".", "doSubscribe", "(", "topic", ",", "fn", ",", "serverAddr", ",", "serverPath", ",", "Subscribe", ")", "\n", "}" ]
10,274
all-10275
[ "List", "lists", "all", "Apps", "in", "the", "indexer", "." ]
[ "func", "(", "s", "*", "appLister", ")", "List", "(", "selector", "labels", ".", "Selector", ")", "(", "<mask>", "[", "]", "*", "v1", ".", "App", ",", "err", "error", ")", "{", "err", "=", "cache", ".", "ListAll", "(", "s", ".", "indexer", ",", "selector", ",", "func", "(", "m", "interface", "{", "}", ")", "{", "ret", "=", "append", "(", "ret", ",", "m", ".", "(", "*", "v1", ".", "App", ")", ")", "\n", "}", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
10,275
all-10276
[ "compactBuildTables", "merge", "topTables", "and", "botTables", "to", "form", "a", "list", "of", "new", "tables", "." ]
[ "func", "(", "s", "*", "levelsController", ")", "compactBuildTables", "(", "lev", "int", ",", "cd", "compactDef", ")", "(", "[", "]", "*", "table", ".", "Table", ",", "func", "(", ")", "error", ",", "error", ")", "{", "topTables", ":=", "cd", ".", "<mask>", "\n", "botTables", ":=", "cd", ".", "bot", "\n\n", "var", "hasOverlap", "bool", "\n", "{", "kr", ":=", "getKeyRange", "(", "cd", ".", "top", ")", "\n", "for", "i", ",", "lh", ":=", "range", "s", ".", "levels", "{", "if", "i", "<=", "lev", "{", "// Skip upper levels.", "continue", "\n", "}", "\n", "lh", ".", "RLock", "(", ")", "\n", "left", ",", "right", ":=", "lh", ".", "overlappingTables", "(", "levelHandlerRLocked", "{", "}", ",", "kr", ")", "\n", "lh", ".", "RUnlock", "(", ")", "\n", "if", "right", "-", "left", ">", "0", "{", "hasOverlap", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "}", "\n\n", "// Try to collect stats so that we can inform value log about GC. That would help us find which", "// value log file should be GCed.", "discardStats", ":=", "make", "(", "map", "[", "uint32", "]", "int64", ")", "\n", "updateStats", ":=", "func", "(", "vs", "y", ".", "ValueStruct", ")", "{", "if", "vs", ".", "Meta", "&", "bitValuePointer", ">", "0", "{", "var", "vp", "valuePointer", "\n", "vp", ".", "Decode", "(", "vs", ".", "Value", ")", "\n", "discardStats", "[", "vp", ".", "Fid", "]", "+=", "int64", "(", "vp", ".", "Len", ")", "\n", "}", "\n", "}", "\n\n", "// Create iterators across all the tables involved first.", "var", "iters", "[", "]", "y", ".", "Iterator", "\n", "if", "lev", "==", "0", "{", "iters", "=", "appendIteratorsReversed", "(", "iters", ",", "topTables", ",", "false", ")", "\n", "}", "else", "if", "len", "(", "topTables", ")", ">", "0", "{", "y", ".", "AssertTrue", "(", "len", "(", "topTables", ")", "==", "1", ")", "\n", "iters", "=", "[", "]", "y", ".", "Iterator", "{", "topTables", "[", "0", "]", ".", "NewIterator", "(", "false", ")", "}", "\n", "}", "\n\n", "// Next level has level>=1 and we can use ConcatIterator as key ranges do not overlap.", "var", "valid", "[", "]", "*", "table", ".", "Table", "\n", "for", "_", ",", "table", ":=", "range", "botTables", "{", "if", "len", "(", "cd", ".", "dropPrefix", ")", ">", "0", "&&", "bytes", ".", "HasPrefix", "(", "table", ".", "Smallest", "(", ")", ",", "cd", ".", "dropPrefix", ")", "&&", "bytes", ".", "HasPrefix", "(", "table", ".", "Biggest", "(", ")", ",", "cd", ".", "dropPrefix", ")", "{", "// All the keys in this table have the dropPrefix. So, this table does not need to be", "// in the iterator and can be dropped immediately.", "continue", "\n", "}", "\n", "valid", "=", "append", "(", "valid", ",", "table", ")", "\n", "}", "\n", "iters", "=", "append", "(", "iters", ",", "table", ".", "NewConcatIterator", "(", "valid", ",", "false", ")", ")", "\n", "it", ":=", "y", ".", "NewMergeIterator", "(", "iters", ",", "false", ")", "\n", "defer", "it", ".", "Close", "(", ")", "// Important to close the iterator to do ref counting.", "\n\n", "it", ".", "Rewind", "(", ")", "\n\n", "// Pick a discard ts, so we can discard versions below this ts. We should", "// never discard any versions starting from above this timestamp, because", "// that would affect the snapshot view guarantee provided by transactions.", "discardTs", ":=", "s", ".", "kv", ".", "orc", ".", "discardAtOrBelow", "(", ")", "\n\n", "// Start generating new tables.", "type", "newTableResult", "struct", "{", "table", "*", "table", ".", "Table", "\n", "err", "error", "\n", "}", "\n", "resultCh", ":=", "make", "(", "chan", "newTableResult", ")", "\n", "var", "numBuilds", ",", "numVersions", "int", "\n", "var", "lastKey", ",", "skipKey", "[", "]", "byte", "\n", "for", "it", ".", "Valid", "(", ")", "{", "timeStart", ":=", "time", ".", "Now", "(", ")", "\n", "builder", ":=", "table", ".", "NewTableBuilder", "(", ")", "\n", "var", "numKeys", ",", "numSkips", "uint64", "\n", "for", ";", "it", ".", "Valid", "(", ")", ";", "it", ".", "Next", "(", ")", "{", "// See if we need to skip the prefix.", "if", "len", "(", "cd", ".", "dropPrefix", ")", ">", "0", "&&", "bytes", ".", "HasPrefix", "(", "it", ".", "Key", "(", ")", ",", "cd", ".", "dropPrefix", ")", "{", "numSkips", "++", "\n", "updateStats", "(", "it", ".", "Value", "(", ")", ")", "\n", "continue", "\n", "}", "\n\n", "// See if we need to skip this key.", "if", "len", "(", "skipKey", ")", ">", "0", "{", "if", "y", ".", "SameKey", "(", "it", ".", "Key", "(", ")", ",", "skipKey", ")", "{", "numSkips", "++", "\n", "updateStats", "(", "it", ".", "Value", "(", ")", ")", "\n", "continue", "\n", "}", "else", "{", "skipKey", "=", "skipKey", "[", ":", "0", "]", "\n", "}", "\n", "}", "\n\n", "if", "!", "y", ".", "SameKey", "(", "it", ".", "Key", "(", ")", ",", "lastKey", ")", "{", "if", "builder", ".", "ReachedCapacity", "(", "s", ".", "kv", ".", "opt", ".", "MaxTableSize", ")", "{", "// Only break if we are on a different key, and have reached capacity. We want", "// to ensure that all versions of the key are stored in the same sstable, and", "// not divided across multiple tables at the same level.", "break", "\n", "}", "\n", "lastKey", "=", "y", ".", "SafeCopy", "(", "lastKey", ",", "it", ".", "Key", "(", ")", ")", "\n", "numVersions", "=", "0", "\n", "}", "\n\n", "vs", ":=", "it", ".", "Value", "(", ")", "\n", "version", ":=", "y", ".", "ParseTs", "(", "it", ".", "Key", "(", ")", ")", "\n", "if", "version", "<=", "discardTs", "{", "// Keep track of the number of versions encountered for this key. Only consider the", "// versions which are below the minReadTs, otherwise, we might end up discarding the", "// only valid version for a running transaction.", "numVersions", "++", "\n", "lastValidVersion", ":=", "vs", ".", "Meta", "&", "bitDiscardEarlierVersions", ">", "0", "\n", "if", "isDeletedOrExpired", "(", "vs", ".", "Meta", ",", "vs", ".", "ExpiresAt", ")", "||", "numVersions", ">", "s", ".", "kv", ".", "opt", ".", "NumVersionsToKeep", "||", "lastValidVersion", "{", "// If this version of the key is deleted or expired, skip all the rest of the", "// versions. Ensure that we're only removing versions below readTs.", "skipKey", "=", "y", ".", "SafeCopy", "(", "skipKey", ",", "it", ".", "Key", "(", ")", ")", "\n\n", "if", "lastValidVersion", "{", "// Add this key. We have set skipKey, so the following key versions", "// would be skipped.", "}", "else", "if", "hasOverlap", "{", "// If this key range has overlap with lower levels, then keep the deletion", "// marker with the latest version, discarding the rest. We have set skipKey,", "// so the following key versions would be skipped.", "}", "else", "{", "// If no overlap, we can skip all the versions, by continuing here.", "numSkips", "++", "\n", "updateStats", "(", "vs", ")", "\n", "continue", "// Skip adding this key.", "\n", "}", "\n", "}", "\n", "}", "\n", "numKeys", "++", "\n", "y", ".", "Check", "(", "builder", ".", "Add", "(", "it", ".", "Key", "(", ")", ",", "it", ".", "Value", "(", ")", ")", ")", "\n", "}", "\n", "// It was true that it.Valid() at least once in the loop above, which means we", "// called Add() at least once, and builder is not Empty().", "s", ".", "kv", ".", "opt", ".", "Debugf", "(", "\"", "\"", ",", "numKeys", ",", "numSkips", ",", "time", ".", "Since", "(", "timeStart", ")", ")", "\n", "if", "!", "builder", ".", "Empty", "(", ")", "{", "numBuilds", "++", "\n", "fileID", ":=", "s", ".", "reserveFileID", "(", ")", "\n", "go", "func", "(", "builder", "*", "table", ".", "Builder", ")", "{", "defer", "builder", ".", "Close", "(", ")", "\n\n", "fd", ",", "err", ":=", "y", ".", "CreateSyncedFile", "(", "table", ".", "NewFilename", "(", "fileID", ",", "s", ".", "kv", ".", "opt", ".", "Dir", ")", ",", "true", ")", "\n", "if", "err", "!=", "nil", "{", "resultCh", "<-", "newTableResult", "{", "nil", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "fileID", ")", "}", "\n", "return", "\n", "}", "\n\n", "if", "_", ",", "err", ":=", "fd", ".", "Write", "(", "builder", ".", "Finish", "(", ")", ")", ";", "err", "!=", "nil", "{", "resultCh", "<-", "newTableResult", "{", "nil", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "fileID", ")", "}", "\n", "return", "\n", "}", "\n\n", "tbl", ",", "err", ":=", "table", ".", "OpenTable", "(", "fd", ",", "s", ".", "kv", ".", "opt", ".", "TableLoadingMode", ",", "nil", ")", "\n", "// decrRef is added below.", "resultCh", "<-", "newTableResult", "{", "tbl", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "fd", ".", "Name", "(", ")", ")", "}", "\n", "}", "(", "builder", ")", "\n", "}", "\n", "}", "\n\n", "newTables", ":=", "make", "(", "[", "]", "*", "table", ".", "Table", ",", "0", ",", "20", ")", "\n", "// Wait for all table builders to finish.", "var", "firstErr", "error", "\n", "for", "x", ":=", "0", ";", "x", "<", "numBuilds", ";", "x", "++", "{", "res", ":=", "<-", "resultCh", "\n", "newTables", "=", "append", "(", "newTables", ",", "res", ".", "table", ")", "\n", "if", "firstErr", "==", "nil", "{", "firstErr", "=", "res", ".", "err", "\n", "}", "\n", "}", "\n\n", "if", "firstErr", "==", "nil", "{", "// Ensure created files' directory entries are visible. We don't mind the extra latency", "// from not doing this ASAP after all file creation has finished because this is a", "// background operation.", "firstErr", "=", "syncDir", "(", "s", ".", "kv", ".", "opt", ".", "Dir", ")", "\n", "}", "\n\n", "if", "firstErr", "!=", "nil", "{", "// An error happened. Delete all the newly created table files (by calling DecrRef", "// -- we're the only holders of a ref).", "for", "j", ":=", "0", ";", "j", "<", "numBuilds", ";", "j", "++", "{", "if", "newTables", "[", "j", "]", "!=", "nil", "{", "newTables", "[", "j", "]", ".", "DecrRef", "(", ")", "\n", "}", "\n", "}", "\n", "errorReturn", ":=", "errors", ".", "Wrapf", "(", "firstErr", ",", "\"", "\"", ",", "cd", ")", "\n", "return", "nil", ",", "nil", ",", "errorReturn", "\n", "}", "\n\n", "sort", ".", "Slice", "(", "newTables", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "y", ".", "CompareKeys", "(", "newTables", "[", "i", "]", ".", "Biggest", "(", ")", ",", "newTables", "[", "j", "]", ".", "Biggest", "(", ")", ")", "<", "0", "\n", "}", ")", "\n", "s", ".", "kv", ".", "vlog", ".", "updateDiscardStats", "(", "discardStats", ")", "\n", "s", ".", "kv", ".", "opt", ".", "Debugf", "(", "\"", "\"", ",", "discardStats", ")", "\n", "return", "newTables", ",", "func", "(", ")", "error", "{", "return", "decrRefs", "(", "newTables", ")", "}", ",", "nil", "\n", "}" ]
10,276
all-10277
[ "Return", "code", "corresponding", "to", "param", "location" ]
[ "func", "location", "(", "p", "*", "gen", ".", "ActionParam", ")", "string", "{", "switch", "p", ".", "Location", "{", "case", "gen", ".", "PathParam", ":", "return", "\"", "\"", "\n", "case", "gen", ".", "QueryParam", ":", "return", "\"", "\"", "\n", "case", "gen", ".", "PayloadParam", ":", "return", "\"", "\"", "\n", "<mask>", ":", "return", "\"", "\"", "\n", "}", "\n", "}" ]
10,277
all-10278
[ "Prefix", "appends", "the", "prefix", "that", "will", "be", "used", "in", "every", "bucket", "name", ".", "Note", "that", "when", "used", "in", "cloned", "the", "prefix", "of", "the", "parent", "Client", "is", "not", "replaced", "but", "is", "prepended", "to", "the", "given", "prefix", "." ]
[ "func", "Prefix", "(", "p", "string", ")", "Option", "{", "return", "Option", "(", "func", "(", "c", "*", "config", ")", "{", "c", ".", "<mask>", ".", "Prefix", "+=", "strings", ".", "TrimSuffix", "(", "p", ",", "\"", "\"", ")", "+", "\"", "\"", "\n", "}", ")", "\n", "}" ]
10,278
all-10279
[ "WithReportProgress", "if", "true", "reportHeapSnapshotProgress", "events", "will", "be", "generated", "while", "snapshot", "is", "being", "taken", "." ]
[ "func", "(", "p", "TakeHeapSnapshotParams", ")", "WithReportProgress", "(", "reportProgress", "bool", ")", "*", "TakeHeapSnapshotParams", "{", "p", ".", "ReportProgress", "=", "reportProgress", "\n", "<mask>", "&", "p", "\n", "}" ]
10,279
all-10280
[ "New", "creates", "a", "net", "/", "http", ".", "Client", "with", "options", "from", "Options", "." ]
[ "func", "New", "(", "options", "*", "Options", ")", "*", "http", ".", "Client", "{", "return", "&", "<mask>", ".", "Client", "{", "Transport", ":", "Transport", "(", "options", ")", ",", "}", "\n", "}" ]
10,280
all-10281
[ "GetCreateFlags", "registers", "the", "flags", "this", "driver", "adds", "to", "docker", "hosts", "create" ]
[ "func", "(", "d", "*", "Driver", ")", "GetCreateFlags", "(", ")", "[", "]", "mcnflag", ".", "Flag", "{", "return", "[", "]", "mcnflag", ".", "Flag", "{", "mcnflag", ".", "StringFlag", "{", "EnvVar", ":", "\"", "\"", ",", "Name", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "EnvVar", ":", "\"", "\"", ",", "<mask>", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "EnvVar", ":", "\"", "\"", ",", "Name", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "EnvVar", ":", "\"", "\"", ",", "Name", ":", "\"", "\"", ",", "Value", ":", "defaultInstanceProfile", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "IntFlag", "{", "EnvVar", ":", "\"", "\"", ",", "Name", ":", "\"", "\"", ",", "Value", ":", "defaultDiskSize", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "EnvVar", ":", "\"", "\"", ",", "Name", ":", "\"", "\"", ",", "Value", ":", "defaultImage", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringSliceFlag", "{", "EnvVar", ":", "\"", "\"", ",", "Name", ":", "\"", "\"", ",", "Value", ":", "[", "]", "string", "{", "defaultSecurityGroup", "}", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "EnvVar", ":", "\"", "\"", ",", "Name", ":", "\"", "\"", ",", "Value", ":", "defaultAvailabilityZone", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "EnvVar", ":", "\"", "\"", ",", "Name", ":", "\"", "\"", ",", "Value", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "EnvVar", ":", "\"", "\"", ",", "Name", ":", "\"", "\"", ",", "Value", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "EnvVar", ":", "\"", "\"", ",", "Name", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringSliceFlag", "{", "EnvVar", ":", "\"", "\"", ",", "Name", ":", "\"", "\"", ",", "Value", ":", "[", "]", "string", "{", "}", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "}", "\n", "}" ]
10,281
all-10282
[ "Replaces", "the", "source", "code", "in", "a", "shader", "object" ]
[ "func", "ShaderSource", "(", "shader", "uint32", ",", "count", "int32", ",", "xstring", "*", "*", "uint8", ",", "length", "*", "int32", ")", "{", "syscall", ".", "Syscall6", "(", "gpShaderSource", ",", "4", ",", "uintptr", "(", "shader", ")", ",", "uintptr", "(", "<mask>", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "xstring", ")", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "length", ")", ")", ",", "0", ",", "0", ")", "\n", "}" ]
10,282
all-10283
[ "CombineHandler", "takes", "variadic", "list", "of", "handlers", "and", "produces", "one", "handler", "that", "calls", "each", "handler", "in", "order", "." ]
[ "func", "CombineHandlers", "(", "handlers", "...", "http", ".", "HandlerFunc", ")", "http", ".", "HandlerFunc", "{", "return", "func", "(", "w", "<mask>", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "for", "_", ",", "handler", ":=", "range", "handlers", "{", "handler", "(", "w", ",", "req", ")", "\n", "}", "\n", "}", "\n", "}" ]
10,283
all-10284
[ "newLog", "returns", "log", "using", "the", "given", "storage", "and", "default", "options", ".", "It", "recovers", "the", "log", "to", "the", "state", "that", "it", "just", "commits", "and", "applies", "the", "latest", "snapshot", "." ]
[ "func", "newLog", "(", "storage", "<mask>", ",", "logger", "Logger", ")", "*", "raftLog", "{", "return", "newLogWithSize", "(", "storage", ",", "logger", ",", "noLimit", ")", "\n", "}" ]
10,284
all-10285
[ "UnmarshalJSON", "implements", "the", "json", ".", "Unmarshaler", "interface", "." ]
[ "func", "(", "prm", "*", "prmExactRepository", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "*", "prm", "=", "prmExactRepository", "{", "}", "\n", "var", "tmp", "prmExactRepository", "\n", "if", "err", ":=", "paranoidUnmarshalJSONObjectExactFields", "(", "data", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "&", "tmp", ".", "<mask>", ",", "\"", "\"", ":", "&", "tmp", ".", "DockerRepository", ",", "}", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "tmp", ".", "Type", "!=", "prmTypeExactRepository", "{", "return", "InvalidPolicyFormatError", "(", "fmt", ".", "Sprintf", "(", "\"", "\\\"", "\\\"", "\"", ",", "tmp", ".", "Type", ")", ")", "\n", "}", "\n\n", "res", ",", "err", ":=", "newPRMExactRepository", "(", "tmp", ".", "DockerRepository", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "*", "prm", "=", "*", "res", "\n", "return", "nil", "\n", "}" ]
10,285
all-10286
[ "NewCatalogServicesQuery", "parses", "a", "string", "of", "the", "format" ]
[ "func", "NewCatalogServicesQuery", "(", "s", "string", ")", "(", "*", "CatalogServicesQuery", ",", "error", ")", "{", "if", "!", "CatalogServicesQueryRe", ".", "MatchString", "(", "s", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ")", "\n", "}", "\n\n", "m", ":=", "regexpMatch", "(", "CatalogServicesQueryRe", ",", "s", ")", "\n", "return", "&", "CatalogServicesQuery", "{", "stopCh", ":", "<mask>", "(", "chan", "struct", "{", "}", ",", "1", ")", ",", "dc", ":", "m", "[", "\"", "\"", "]", ",", "}", ",", "nil", "\n", "}" ]
10,286
all-10287
[ "ConfigPath", "returns", "the", "value", "for", "the", "component", "s", "configPath", "if", "provided", "explicitly", "or", "default", "otherwise", "." ]
[ "func", "ConfigPath", "(", "value", "string", ")", "string", "{", "if", "value", "!=", "\"", "\"", "{", "return", "<mask>", "\n", "}", "\n", "logrus", ".", "Warningf", "(", "\"", "\"", ",", "DefaultConfigPath", ")", "\n", "return", "DefaultConfigPath", "\n", "}" ]
10,287
all-10288
[ "WriteHeaders", "writes", "the", "given", "key", "-", "value", "pairs", "using", "the", "following", "encoding", ":", "len~2", "(", "k~4", "v~4", ")", "~len" ]
[ "func", "WriteHeaders", "(", "w", "io", ".", "Writer", ",", "headers", "map", "[", "string", "]", "string", ")", "error", "{", "// TODO(prashant): Since we are not writing length-prefixed data here,", "// we can write out to the buffer, and if it fills up, flush it.", "// Right now, we calculate the size of the required buffer and write it out.", "// Calculate the size of the buffer that we need.", "size", ":=", "2", "\n", "for", "k", ",", "v", ":=", "range", "headers", "{", "size", "+=", "4", "/* size of key/value lengths */", "\n", "size", "+=", "len", "(", "k", ")", "+", "len", "(", "v", ")", "\n", "}", "\n\n", "buf", ":=", "make", "(", "[", "]", "byte", ",", "size", ")", "\n", "writeBuffer", ":=", "typed", ".", "NewWriteBuffer", "(", "buf", ")", "\n", "writeBuffer", ".", "WriteUint16", "(", "uint16", "(", "len", "(", "<mask>", ")", ")", ")", "\n", "for", "k", ",", "v", ":=", "range", "headers", "{", "writeBuffer", ".", "WriteLen16String", "(", "k", ")", "\n", "writeBuffer", ".", "WriteLen16String", "(", "v", ")", "\n", "}", "\n\n", "if", "err", ":=", "writeBuffer", ".", "Err", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Safety check to ensure the bytes written calculation is correct.", "if", "writeBuffer", ".", "BytesWritten", "(", ")", "!=", "size", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "size", ",", "writeBuffer", ".", "BytesWritten", "(", ")", ")", "\n", "}", "\n\n", "_", ",", "err", ":=", "writeBuffer", ".", "FlushTo", "(", "w", ")", "\n", "return", "err", "\n", "}" ]
10,288
all-10289
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "Creator", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoHar11", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
10,289
all-10290
[ "expandCustomizationLinuxPrep", "reads", "certain", "ResourceData", "keys", "and", "returns", "a", "CustomizationLinuxPrep", "." ]
[ "func", "expandCustomizationLinuxPrep", "(", "d", "*", "schema", ".", "ResourceData", ")", "*", "types", ".", "CustomizationLinuxPrep", "{", "obj", ":=", "&", "types", ".", "CustomizationLinuxPrep", "{", "HostName", ":", "&", "types", ".", "CustomizationFixedName", "{", "Name", ":", "d", ".", "Get", "(", "cLinuxKeyPrefix", "+", "\"", "\"", "+", "\"", "\"", ")", ".", "(", "string", ")", ",", "}", ",", "<mask>", ":", "d", ".", "Get", "(", "cLinuxKeyPrefix", "+", "\"", "\"", "+", "\"", "\"", ")", ".", "(", "string", ")", ",", "TimeZone", ":", "d", ".", "Get", "(", "cLinuxKeyPrefix", "+", "\"", "\"", "+", "\"", "\"", ")", ".", "(", "string", ")", ",", "HwClockUTC", ":", "structure", ".", "GetBoolPtr", "(", "d", ",", "cLinuxKeyPrefix", "+", "\"", "\"", "+", "\"", "\"", ")", ",", "}", "\n", "return", "obj", "\n", "}" ]
10,290
all-10291
[ "ReadInt8", "returns", "an", "int8", "read", "from", "address", "a", "of", "the", "inferior", "." ]
[ "func", "(", "p", "*", "Process", ")", "ReadInt8", "(", "a", "<mask>", ")", "int8", "{", "return", "int8", "(", "p", ".", "ReadUint8", "(", "a", ")", ")", "\n", "}" ]
10,291
all-10292
[ "CreateDatabaseServer", "creates", "a", "new", "database", "server", ".", "It", "takes", "a", "DatabaseServerOptions", "struct", "for", "specifying", "name", "and", "other", "attributes", ".", "Not", "all", "attributes", "can", "be", "specified", "at", "create", "time", "(", "such", "as", "Id", "which", "is", "allocated", "for", "you", ")" ]
[ "func", "(", "c", "*", "Client", ")", "CreateDatabaseServer", "(", "options", "*", "DatabaseServerOptions", ")", "(", "*", "DatabaseServer", ",", "error", ")", "{", "dbs", ":=", "new", "(", "DatabaseServer", ")", "\n", "_", ",", "err", ":=", "c", ".", "MakeApiRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "<mask>", ",", "&", "dbs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "dbs", ",", "nil", "\n", "}" ]
10,292
all-10293
[ "Do", "executes", "Network", ".", "clearBrowserCache", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "ClearBrowserCacheParams", ")", "Do", "(", "ctx", "context", ".", "<mask>", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandClearBrowserCache", ",", "nil", ",", "nil", ")", "\n", "}" ]
10,293
all-10294
[ "/", "*", "Build", "uses", "go", "build", "to", "compile", "the", "package", "at", "packagePath", ".", "The", "resulting", "binary", "is", "saved", "off", "in", "a", "temporary", "directory", ".", "A", "path", "pointing", "to", "this", "binary", "is", "returned", "." ]
[ "func", "Build", "(", "packagePath", "string", ",", "args", "...", "string", ")", "(", "compiledPath", "string", ",", "err", "error", ")", "{", "return", "doBuild", "(", "build", ".", "<mask>", ".", "GOPATH", ",", "packagePath", ",", "nil", ",", "args", "...", ")", "\n", "}" ]
10,294
all-10295
[ "ValidateVirtualMachineClone", "does", "pre", "-", "creation", "validation", "of", "a", "virtual", "machine", "s", "configuration", "to", "make", "sure", "it", "s", "suitable", "for", "use", "in", "cloning", ".", "This", "includes", "but", "is", "not", "limited", "to", "checking", "to", "make", "sure", "that", "the", "disks", "in", "the", "new", "VM", "configuration", "line", "up", "with", "the", "configuration", "in", "the", "existing", "template", "and", "checking", "to", "make", "sure", "that", "the", "VM", "has", "a", "single", "snapshot", "we", "can", "use", "in", "the", "even", "that", "linked", "clones", "are", "enabled", "." ]
[ "func", "ValidateVirtualMachineClone", "(", "d", "*", "schema", ".", "ResourceDiff", ",", "c", "*", "govmomi", ".", "Client", ")", "error", "{", "tUUID", ":=", "d", ".", "Get", "(", "\"", "\"", ")", ".", "(", "string", ")", "\n", "log", ".", "Printf", "(", "\"", "\"", ",", "tUUID", ")", "\n", "vm", ",", "err", ":=", "virtualmachine", ".", "FromUUID", "(", "c", ",", "tUUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "tUUID", ",", "err", ")", "\n", "}", "\n", "vprops", ",", "err", ":=", "virtualmachine", ".", "Properties", "(", "vm", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "// The virtual machine needs to be powered off to be suitable for cloning.", "if", "vprops", ".", "Runtime", ".", "PowerState", "!=", "types", ".", "VirtualMachinePowerStatePoweredOff", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "tUUID", ")", "\n", "}", "\n", "// Check to see if our guest IDs match.", "eGuestID", ":=", "vprops", ".", "Config", ".", "GuestId", "\n", "aGuestID", ":=", "d", ".", "Get", "(", "\"", "\"", ")", ".", "(", "string", ")", "\n", "if", "eGuestID", "!=", "aGuestID", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "aGuestID", ",", "eGuestID", ")", "\n", "}", "\n", "// If linked clone is enabled, check to see if we have a snapshot. There need", "// to be a single snapshot on the template for it to be eligible.", "linked", ":=", "d", ".", "Get", "(", "\"", "\"", ")", ".", "(", "bool", ")", "\n", "if", "<mask>", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "tUUID", ")", "\n", "if", "err", ":=", "validateCloneSnapshots", "(", "vprops", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "// Check to make sure the disks for this VM/template line up with the disks", "// in the configuration. This is in the virtual device package, so pass off", "// to that now.", "l", ":=", "object", ".", "VirtualDeviceList", "(", "vprops", ".", "Config", ".", "Hardware", ".", "Device", ")", "\n", "if", "err", ":=", "virtualdevice", ".", "DiskCloneValidateOperation", "(", "d", ",", "c", ",", "l", ",", "linked", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// If a customization spec was defined, we need to check some items in it as well.", "if", "len", "(", "d", ".", "Get", "(", "\"", "\"", ")", ".", "(", "[", "]", "interface", "{", "}", ")", ")", ">", "0", "{", "if", "poolID", ",", "ok", ":=", "d", ".", "GetOk", "(", "\"", "\"", ")", ";", "ok", "{", "pool", ",", "err", ":=", "resourcepool", ".", "FromID", "(", "c", ",", "poolID", ".", "(", "string", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "poolID", ",", "err", ")", "\n", "}", "\n", "family", ",", "err", ":=", "resourcepool", ".", "OSFamily", "(", "c", ",", "pool", ",", "d", ".", "Get", "(", "\"", "\"", ")", ".", "(", "string", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "d", ".", "Get", "(", "\"", "\"", ")", ".", "(", "string", ")", ",", "err", ")", "\n", "}", "\n", "if", "err", ":=", "ValidateCustomizationSpec", "(", "d", ",", "family", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "else", "{", "log", ".", "Printf", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "vconfig", ":=", "vprops", ".", "Config", ".", "VAppConfig", "\n", "if", "vconfig", "!=", "nil", "{", "// We need to set the vApp transport types here so that it is available", "// later in CustomizeDiff where transport requirements are validated in", "// ValidateVAppTransport", "d", ".", "SetNew", "(", "\"", "\"", ",", "vconfig", ".", "GetVmConfigInfo", "(", ")", ".", "OvfEnvironmentTransport", ")", "\n", "}", "\n\n", "log", ".", "Printf", "(", "\"", "\"", ",", "tUUID", ")", "\n", "return", "nil", "\n", "}" ]
10,295
all-10296
[ "Init", "initializes", "a", "WaterMark", "struct", ".", "MUST", "be", "called", "before", "using", "it", "." ]
[ "func", "(", "w", "*", "WaterMark", ")", "Init", "(", "closer", "*", "Closer", ")", "{", "w", ".", "markCh", "=", "make", "(", "chan", "mark", ",", "100", ")", "\n", "w", ".", "elog", "=", "trace", ".", "NewEventLog", "(", "\"", "\"", ",", "w", ".", "<mask>", ")", "\n", "go", "w", ".", "process", "(", "closer", ")", "\n", "}" ]
10,296
all-10297
[ "UnmarshalJSON", "satisfies", "json", ".", "Unmarshaler", "." ]
[ "func", "(", "t", "*", "BlockedReason", ")", "UnmarshalJSON", "(", "buf", "[", "]", "<mask>", ")", "error", "{", "return", "easyjson", ".", "Unmarshal", "(", "buf", ",", "t", ")", "\n", "}" ]
10,297
all-10298
[ "Do", "executes", "Debugger", ".", "setBreakpoint", "against", "the", "provided", "context", ".", "returns", ":", "breakpointID", "-", "Id", "of", "the", "created", "breakpoint", "for", "further", "reference", ".", "actualLocation", "-", "Location", "this", "breakpoint", "resolved", "into", "." ]
[ "func", "(", "p", "*", "SetBreakpointParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "breakpointID", "BreakpointID", ",", "actualLocation", "*", "Location", ",", "err", "error", ")", "{", "// execute", "var", "res", "SetBreakpointReturns", "\n", "err", "=", "cdp", ".", "Execute", "(", "ctx", ",", "CommandSetBreakpoint", ",", "p", ",", "&", "<mask>", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "nil", ",", "err", "\n", "}", "\n\n", "return", "res", ".", "BreakpointID", ",", "res", ".", "ActualLocation", ",", "nil", "\n", "}" ]
10,298
all-10299
[ "Set", "implements", "the", "StableStore", "interface", "." ]
[ "func", "(", "i", "*", "InmemStore", ")", "Set", "(", "key", "[", "]", "byte", ",", "val", "[", "]", "<mask>", ")", "error", "{", "i", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "i", ".", "l", ".", "Unlock", "(", ")", "\n", "i", ".", "kv", "[", "string", "(", "key", ")", "]", "=", "val", "\n", "return", "nil", "\n", "}" ]
10,299
all-10300
[ "FsyncLock", "locks", "all", "writes", "in", "the", "specific", "server", "the", "session", "is", "established", "with", "and", "returns", ".", "Any", "writes", "attempted", "to", "the", "server", "after", "it", "is", "successfully", "locked", "will", "block", "until", "FsyncUnlock", "is", "called", "for", "the", "same", "server", ".", "This", "method", "works", "on", "secondaries", "as", "well", "preventing", "the", "oplog", "from", "being", "flushed", "while", "the", "server", "is", "locked", "but", "since", "only", "the", "server", "connected", "to", "is", "locked", "for", "locking", "specific", "secondaries", "it", "may", "be", "necessary", "to", "establish", "a", "connection", "directly", "to", "the", "secondary", "(", "see", "Dial", "s", "connect", "=", "direct", "option", ")", ".", "As", "an", "important", "caveat", "note", "that", "once", "a", "write", "is", "attempted", "and", "blocks", "follow", "up", "reads", "will", "block", "as", "well", "due", "to", "the", "way", "the", "lock", "is", "internally", "implemented", "in", "the", "server", ".", "More", "details", "at", ":", "https", ":", "//", "jira", ".", "mongodb", ".", "org", "/", "browse", "/", "SERVER", "-", "4243", "FsyncLock", "is", "often", "used", "for", "performing", "consistent", "backups", "of", "the", "database", "files", "on", "disk", ".", "Relevant", "documentation", ":", "http", ":", "//", "www", ".", "mongodb", ".", "org", "/", "display", "/", "DOCS", "/", "fsync", "+", "Command", "http", ":", "//", "www", ".", "mongodb", ".", "org", "/", "display", "/", "DOCS", "/", "Backups" ]
[ "func", "(", "s", "*", "Session", ")", "FsyncLock", "(", ")", "error", "{", "return", "s", ".", "Run", "(", "bson", ".", "D", "{", "{", "\"", "\"", ",", "1", "}", ",", "{", "\"", "\"", ",", "<mask>", "}", "}", ",", "nil", ")", "\n", "}" ]