repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
vitessio/vitess | go/vt/key/key.go | ParseKeyRangeParts | func ParseKeyRangeParts(start, end string) (*topodatapb.KeyRange, error) {
s, err := hex.DecodeString(start)
if err != nil {
return nil, err
}
e, err := hex.DecodeString(end)
if err != nil {
return nil, err
}
return &topodatapb.KeyRange{Start: s, End: e}, nil
} | go | func ParseKeyRangeParts(start, end string) (*topodatapb.KeyRange, error) {
s, err := hex.DecodeString(start)
if err != nil {
return nil, err
}
e, err := hex.DecodeString(end)
if err != nil {
return nil, err
}
return &topodatapb.KeyRange{Start: s, End: e}, nil
} | [
"func",
"ParseKeyRangeParts",
"(",
"start",
",",
"end",
"string",
")",
"(",
"*",
"topodatapb",
".",
"KeyRange",
",",
"error",
")",
"{",
"s",
",",
"err",
":=",
"hex",
".",
"DecodeString",
"(",
"start",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return... | // ParseKeyRangeParts parses a start and end hex values and build a proto KeyRange | [
"ParseKeyRangeParts",
"parses",
"a",
"start",
"and",
"end",
"hex",
"values",
"and",
"build",
"a",
"proto",
"KeyRange"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/key/key.go#L132-L142 | train |
vitessio/vitess | go/vt/key/key.go | KeyRangeString | func KeyRangeString(k *topodatapb.KeyRange) string {
if k == nil {
return "-"
}
return hex.EncodeToString(k.Start) + "-" + hex.EncodeToString(k.End)
} | go | func KeyRangeString(k *topodatapb.KeyRange) string {
if k == nil {
return "-"
}
return hex.EncodeToString(k.Start) + "-" + hex.EncodeToString(k.End)
} | [
"func",
"KeyRangeString",
"(",
"k",
"*",
"topodatapb",
".",
"KeyRange",
")",
"string",
"{",
"if",
"k",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"hex",
".",
"EncodeToString",
"(",
"k",
".",
"Start",
")",
"+",
"\"",
"\"",
"+... | // KeyRangeString prints a topodatapb.KeyRange | [
"KeyRangeString",
"prints",
"a",
"topodatapb",
".",
"KeyRange"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/key/key.go#L145-L150 | train |
vitessio/vitess | go/vt/key/key.go | KeyRangeIsPartial | func KeyRangeIsPartial(kr *topodatapb.KeyRange) bool {
if kr == nil {
return false
}
return !(len(kr.Start) == 0 && len(kr.End) == 0)
} | go | func KeyRangeIsPartial(kr *topodatapb.KeyRange) bool {
if kr == nil {
return false
}
return !(len(kr.Start) == 0 && len(kr.End) == 0)
} | [
"func",
"KeyRangeIsPartial",
"(",
"kr",
"*",
"topodatapb",
".",
"KeyRange",
")",
"bool",
"{",
"if",
"kr",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"!",
"(",
"len",
"(",
"kr",
".",
"Start",
")",
"==",
"0",
"&&",
"len",
"(",
... | // KeyRangeIsPartial returns true if the KeyRange does not cover the entire space. | [
"KeyRangeIsPartial",
"returns",
"true",
"if",
"the",
"KeyRange",
"does",
"not",
"cover",
"the",
"entire",
"space",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/key/key.go#L153-L158 | train |
vitessio/vitess | go/vt/key/key.go | KeyRangeEqual | func KeyRangeEqual(left, right *topodatapb.KeyRange) bool {
if left == nil {
return right == nil || (len(right.Start) == 0 && len(right.End) == 0)
}
if right == nil {
return len(left.Start) == 0 && len(left.End) == 0
}
return bytes.Equal(left.Start, right.Start) &&
bytes.Equal(left.End, right.End)
} | go | func KeyRangeEqual(left, right *topodatapb.KeyRange) bool {
if left == nil {
return right == nil || (len(right.Start) == 0 && len(right.End) == 0)
}
if right == nil {
return len(left.Start) == 0 && len(left.End) == 0
}
return bytes.Equal(left.Start, right.Start) &&
bytes.Equal(left.End, right.End)
} | [
"func",
"KeyRangeEqual",
"(",
"left",
",",
"right",
"*",
"topodatapb",
".",
"KeyRange",
")",
"bool",
"{",
"if",
"left",
"==",
"nil",
"{",
"return",
"right",
"==",
"nil",
"||",
"(",
"len",
"(",
"right",
".",
"Start",
")",
"==",
"0",
"&&",
"len",
"("... | // KeyRangeEqual returns true if both key ranges cover the same area | [
"KeyRangeEqual",
"returns",
"true",
"if",
"both",
"key",
"ranges",
"cover",
"the",
"same",
"area"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/key/key.go#L161-L170 | train |
vitessio/vitess | go/vt/key/key.go | KeyRangeStartEqual | func KeyRangeStartEqual(left, right *topodatapb.KeyRange) bool {
if left == nil {
return right == nil || len(right.Start) == 0
}
if right == nil {
return len(left.Start) == 0
}
return bytes.Equal(left.Start, right.Start)
} | go | func KeyRangeStartEqual(left, right *topodatapb.KeyRange) bool {
if left == nil {
return right == nil || len(right.Start) == 0
}
if right == nil {
return len(left.Start) == 0
}
return bytes.Equal(left.Start, right.Start)
} | [
"func",
"KeyRangeStartEqual",
"(",
"left",
",",
"right",
"*",
"topodatapb",
".",
"KeyRange",
")",
"bool",
"{",
"if",
"left",
"==",
"nil",
"{",
"return",
"right",
"==",
"nil",
"||",
"len",
"(",
"right",
".",
"Start",
")",
"==",
"0",
"\n",
"}",
"\n",
... | // KeyRangeStartEqual returns true if both key ranges have the same start | [
"KeyRangeStartEqual",
"returns",
"true",
"if",
"both",
"key",
"ranges",
"have",
"the",
"same",
"start"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/key/key.go#L173-L181 | train |
vitessio/vitess | go/vt/key/key.go | KeyRangeEndEqual | func KeyRangeEndEqual(left, right *topodatapb.KeyRange) bool {
if left == nil {
return right == nil || len(right.End) == 0
}
if right == nil {
return len(left.End) == 0
}
return bytes.Equal(left.End, right.End)
} | go | func KeyRangeEndEqual(left, right *topodatapb.KeyRange) bool {
if left == nil {
return right == nil || len(right.End) == 0
}
if right == nil {
return len(left.End) == 0
}
return bytes.Equal(left.End, right.End)
} | [
"func",
"KeyRangeEndEqual",
"(",
"left",
",",
"right",
"*",
"topodatapb",
".",
"KeyRange",
")",
"bool",
"{",
"if",
"left",
"==",
"nil",
"{",
"return",
"right",
"==",
"nil",
"||",
"len",
"(",
"right",
".",
"End",
")",
"==",
"0",
"\n",
"}",
"\n",
"if... | // KeyRangeEndEqual returns true if both key ranges have the same end | [
"KeyRangeEndEqual",
"returns",
"true",
"if",
"both",
"key",
"ranges",
"have",
"the",
"same",
"end"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/key/key.go#L184-L192 | train |
vitessio/vitess | go/vt/key/key.go | KeyRangesOverlap | func KeyRangesOverlap(first, second *topodatapb.KeyRange) (*topodatapb.KeyRange, error) {
if !KeyRangesIntersect(first, second) {
return nil, fmt.Errorf("KeyRanges %v and %v don't overlap", first, second)
}
if first == nil {
return second, nil
}
if second == nil {
return first, nil
}
// compute max(c,a) an... | go | func KeyRangesOverlap(first, second *topodatapb.KeyRange) (*topodatapb.KeyRange, error) {
if !KeyRangesIntersect(first, second) {
return nil, fmt.Errorf("KeyRanges %v and %v don't overlap", first, second)
}
if first == nil {
return second, nil
}
if second == nil {
return first, nil
}
// compute max(c,a) an... | [
"func",
"KeyRangesOverlap",
"(",
"first",
",",
"second",
"*",
"topodatapb",
".",
"KeyRange",
")",
"(",
"*",
"topodatapb",
".",
"KeyRange",
",",
"error",
")",
"{",
"if",
"!",
"KeyRangesIntersect",
"(",
"first",
",",
"second",
")",
"{",
"return",
"nil",
",... | // KeyRangesOverlap returns the overlap between two KeyRanges.
// They need to overlap, otherwise an error is returned. | [
"KeyRangesOverlap",
"returns",
"the",
"overlap",
"between",
"two",
"KeyRanges",
".",
"They",
"need",
"to",
"overlap",
"otherwise",
"an",
"error",
"is",
"returned",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/key/key.go#L211-L236 | train |
vitessio/vitess | go/vt/key/key.go | KeyRangeIncludes | func KeyRangeIncludes(big, small *topodatapb.KeyRange) bool {
if big == nil {
// The outside one covers everything, we're good.
return true
}
if small == nil {
// The smaller one covers everything, better have the
// bigger one also cover everything.
return len(big.Start) == 0 && len(big.End) == 0
}
// N... | go | func KeyRangeIncludes(big, small *topodatapb.KeyRange) bool {
if big == nil {
// The outside one covers everything, we're good.
return true
}
if small == nil {
// The smaller one covers everything, better have the
// bigger one also cover everything.
return len(big.Start) == 0 && len(big.End) == 0
}
// N... | [
"func",
"KeyRangeIncludes",
"(",
"big",
",",
"small",
"*",
"topodatapb",
".",
"KeyRange",
")",
"bool",
"{",
"if",
"big",
"==",
"nil",
"{",
"// The outside one covers everything, we're good.",
"return",
"true",
"\n",
"}",
"\n",
"if",
"small",
"==",
"nil",
"{",
... | // KeyRangeIncludes returns true if the first provided KeyRange, big,
// contains the second KeyRange, small. If they intersect, but small
// spills out, this returns false. | [
"KeyRangeIncludes",
"returns",
"true",
"if",
"the",
"first",
"provided",
"KeyRange",
"big",
"contains",
"the",
"second",
"KeyRange",
"small",
".",
"If",
"they",
"intersect",
"but",
"small",
"spills",
"out",
"this",
"returns",
"false",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/key/key.go#L241-L259 | train |
vitessio/vitess | go/vt/automation/task_containers.go | NewTaskContainerWithSingleTask | func NewTaskContainerWithSingleTask(taskName string, parameters map[string]string) *automationpb.TaskContainer {
return &automationpb.TaskContainer{
ParallelTasks: []*automationpb.Task{
NewTask(taskName, parameters),
},
}
} | go | func NewTaskContainerWithSingleTask(taskName string, parameters map[string]string) *automationpb.TaskContainer {
return &automationpb.TaskContainer{
ParallelTasks: []*automationpb.Task{
NewTask(taskName, parameters),
},
}
} | [
"func",
"NewTaskContainerWithSingleTask",
"(",
"taskName",
"string",
",",
"parameters",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"automationpb",
".",
"TaskContainer",
"{",
"return",
"&",
"automationpb",
".",
"TaskContainer",
"{",
"ParallelTasks",
":",
"[",
... | // Helper functions for "TaskContainer" protobuf message.
// NewTaskContainerWithSingleTask creates a new task container with exactly one task. | [
"Helper",
"functions",
"for",
"TaskContainer",
"protobuf",
"message",
".",
"NewTaskContainerWithSingleTask",
"creates",
"a",
"new",
"task",
"container",
"with",
"exactly",
"one",
"task",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/task_containers.go#L26-L32 | train |
vitessio/vitess | go/vt/automation/task_containers.go | AddTask | func AddTask(t *automationpb.TaskContainer, taskName string, parameters map[string]string) {
t.ParallelTasks = append(t.ParallelTasks, NewTask(taskName, parameters))
} | go | func AddTask(t *automationpb.TaskContainer, taskName string, parameters map[string]string) {
t.ParallelTasks = append(t.ParallelTasks, NewTask(taskName, parameters))
} | [
"func",
"AddTask",
"(",
"t",
"*",
"automationpb",
".",
"TaskContainer",
",",
"taskName",
"string",
",",
"parameters",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"t",
".",
"ParallelTasks",
"=",
"append",
"(",
"t",
".",
"ParallelTasks",
",",
"NewTask",
... | // AddTask adds a new task to an existing task container. | [
"AddTask",
"adds",
"a",
"new",
"task",
"to",
"an",
"existing",
"task",
"container",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/task_containers.go#L42-L44 | train |
vitessio/vitess | go/vt/automation/task_containers.go | AddMissingTaskID | func AddMissingTaskID(tc []*automationpb.TaskContainer, taskIDGenerator *IDGenerator) {
for _, taskContainer := range tc {
for _, task := range taskContainer.ParallelTasks {
if task.Id == "" {
task.Id = taskIDGenerator.GetNextID()
}
}
}
} | go | func AddMissingTaskID(tc []*automationpb.TaskContainer, taskIDGenerator *IDGenerator) {
for _, taskContainer := range tc {
for _, task := range taskContainer.ParallelTasks {
if task.Id == "" {
task.Id = taskIDGenerator.GetNextID()
}
}
}
} | [
"func",
"AddMissingTaskID",
"(",
"tc",
"[",
"]",
"*",
"automationpb",
".",
"TaskContainer",
",",
"taskIDGenerator",
"*",
"IDGenerator",
")",
"{",
"for",
"_",
",",
"taskContainer",
":=",
"range",
"tc",
"{",
"for",
"_",
",",
"task",
":=",
"range",
"taskConta... | // AddMissingTaskID assigns a task id to each task in "tc". | [
"AddMissingTaskID",
"assigns",
"a",
"task",
"id",
"to",
"each",
"task",
"in",
"tc",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/automation/task_containers.go#L47-L55 | train |
vitessio/vitess | go/vt/vtgate/vindexes/hash.go | NewHash | func NewHash(name string, m map[string]string) (Vindex, error) {
return &Hash{name: name}, nil
} | go | func NewHash(name string, m map[string]string) (Vindex, error) {
return &Hash{name: name}, nil
} | [
"func",
"NewHash",
"(",
"name",
"string",
",",
"m",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"Vindex",
",",
"error",
")",
"{",
"return",
"&",
"Hash",
"{",
"name",
":",
"name",
"}",
",",
"nil",
"\n",
"}"
] | // NewHash creates a new Hash. | [
"NewHash",
"creates",
"a",
"new",
"Hash",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/hash.go#L46-L48 | train |
vitessio/vitess | go/vt/worker/restartable_result_reader.go | Next | func (r *RestartableResultReader) Next() (*sqltypes.Result, error) {
result, err := r.output.Recv()
if err != nil && err != io.EOF {
// We start the retries only on the second attempt to avoid the cost
// of starting a timer (for the retry timeout) for every Next() call
// when no error occurs.
alias := topop... | go | func (r *RestartableResultReader) Next() (*sqltypes.Result, error) {
result, err := r.output.Recv()
if err != nil && err != io.EOF {
// We start the retries only on the second attempt to avoid the cost
// of starting a timer (for the retry timeout) for every Next() call
// when no error occurs.
alias := topop... | [
"func",
"(",
"r",
"*",
"RestartableResultReader",
")",
"Next",
"(",
")",
"(",
"*",
"sqltypes",
".",
"Result",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"r",
".",
"output",
".",
"Recv",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"er... | // Next returns the next result on the stream. It implements ResultReader. | [
"Next",
"returns",
"the",
"next",
"result",
"on",
"the",
"stream",
".",
"It",
"implements",
"ResultReader",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/restartable_result_reader.go#L209-L224 | train |
vitessio/vitess | go/proc/counting_listener.go | Published | func Published(l net.Listener, countTag, acceptTag string) net.Listener {
return &CountingListener{
Listener: l,
ConnCount: stats.NewGauge(countTag, "Active connections accepted by counting listener"),
ConnAccept: stats.NewCounter(acceptTag, "Count of connections accepted by the counting listener"),
}
} | go | func Published(l net.Listener, countTag, acceptTag string) net.Listener {
return &CountingListener{
Listener: l,
ConnCount: stats.NewGauge(countTag, "Active connections accepted by counting listener"),
ConnAccept: stats.NewCounter(acceptTag, "Count of connections accepted by the counting listener"),
}
} | [
"func",
"Published",
"(",
"l",
"net",
".",
"Listener",
",",
"countTag",
",",
"acceptTag",
"string",
")",
"net",
".",
"Listener",
"{",
"return",
"&",
"CountingListener",
"{",
"Listener",
":",
"l",
",",
"ConnCount",
":",
"stats",
".",
"NewGauge",
"(",
"cou... | // Published creates a wrapper for net.Listener that
// publishes connection stats. | [
"Published",
"creates",
"a",
"wrapper",
"for",
"net",
".",
"Listener",
"that",
"publishes",
"connection",
"stats",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/proc/counting_listener.go#L38-L44 | train |
vitessio/vitess | go/proc/counting_listener.go | Accept | func (l *CountingListener) Accept() (c net.Conn, err error) {
conn, err := l.Listener.Accept()
if err != nil {
return nil, err
}
l.ConnCount.Add(1)
l.ConnAccept.Add(1)
return &countingConnection{conn, l}, nil
} | go | func (l *CountingListener) Accept() (c net.Conn, err error) {
conn, err := l.Listener.Accept()
if err != nil {
return nil, err
}
l.ConnCount.Add(1)
l.ConnAccept.Add(1)
return &countingConnection{conn, l}, nil
} | [
"func",
"(",
"l",
"*",
"CountingListener",
")",
"Accept",
"(",
")",
"(",
"c",
"net",
".",
"Conn",
",",
"err",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"l",
".",
"Listener",
".",
"Accept",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retu... | // Accept increments stats counters before returning
// a connection. | [
"Accept",
"increments",
"stats",
"counters",
"before",
"returning",
"a",
"connection",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/proc/counting_listener.go#L48-L56 | train |
vitessio/vitess | go/proc/counting_listener.go | Close | func (c *countingConnection) Close() error {
if c.listener != nil {
c.listener.ConnCount.Add(-1)
c.listener = nil
}
return c.Conn.Close()
} | go | func (c *countingConnection) Close() error {
if c.listener != nil {
c.listener.ConnCount.Add(-1)
c.listener = nil
}
return c.Conn.Close()
} | [
"func",
"(",
"c",
"*",
"countingConnection",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"c",
".",
"listener",
"!=",
"nil",
"{",
"c",
".",
"listener",
".",
"ConnCount",
".",
"Add",
"(",
"-",
"1",
")",
"\n",
"c",
".",
"listener",
"=",
"nil",
"\n",... | // Close decrements the stats counter and
// closes the connection. | [
"Close",
"decrements",
"the",
"stats",
"counter",
"and",
"closes",
"the",
"connection",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/proc/counting_listener.go#L60-L66 | train |
vitessio/vitess | go/vt/throttler/throttlerclient/throttlerclient.go | New | func New(addr string) (Client, error) {
factory, ok := factories[*protocol]
if !ok {
return nil, fmt.Errorf("unknown throttler client protocol: %v", *protocol)
}
return factory(addr)
} | go | func New(addr string) (Client, error) {
factory, ok := factories[*protocol]
if !ok {
return nil, fmt.Errorf("unknown throttler client protocol: %v", *protocol)
}
return factory(addr)
} | [
"func",
"New",
"(",
"addr",
"string",
")",
"(",
"Client",
",",
"error",
")",
"{",
"factory",
",",
"ok",
":=",
"factories",
"[",
"*",
"protocol",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
... | // New will return a client for the selected RPC implementation. | [
"New",
"will",
"return",
"a",
"client",
"for",
"the",
"selected",
"RPC",
"implementation",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/throttler/throttlerclient/throttlerclient.go#L82-L88 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/connpool/pool.go | New | func New(
name string,
capacity int,
idleTimeout time.Duration,
checker MySQLChecker) *Pool {
cp := &Pool{
capacity: capacity,
idleTimeout: idleTimeout,
dbaPool: dbconnpool.NewConnectionPool("", 1, idleTimeout, 0),
checker: checker,
}
if name == "" || usedNames[name] {
return cp
}
usedName... | go | func New(
name string,
capacity int,
idleTimeout time.Duration,
checker MySQLChecker) *Pool {
cp := &Pool{
capacity: capacity,
idleTimeout: idleTimeout,
dbaPool: dbconnpool.NewConnectionPool("", 1, idleTimeout, 0),
checker: checker,
}
if name == "" || usedNames[name] {
return cp
}
usedName... | [
"func",
"New",
"(",
"name",
"string",
",",
"capacity",
"int",
",",
"idleTimeout",
"time",
".",
"Duration",
",",
"checker",
"MySQLChecker",
")",
"*",
"Pool",
"{",
"cp",
":=",
"&",
"Pool",
"{",
"capacity",
":",
"capacity",
",",
"idleTimeout",
":",
"idleTim... | // New creates a new Pool. The name is used
// to publish stats only. | [
"New",
"creates",
"a",
"new",
"Pool",
".",
"The",
"name",
"is",
"used",
"to",
"publish",
"stats",
"only",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/connpool/pool.go#L71-L96 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/connpool/pool.go | Open | func (cp *Pool) Open(appParams, dbaParams, appDebugParams *mysql.ConnParams) {
cp.mu.Lock()
defer cp.mu.Unlock()
f := func() (pools.Resource, error) {
return NewDBConn(cp, appParams)
}
cp.connections = pools.NewResourcePool(f, cp.capacity, cp.capacity, cp.idleTimeout)
cp.appDebugParams = appDebugParams
cp.db... | go | func (cp *Pool) Open(appParams, dbaParams, appDebugParams *mysql.ConnParams) {
cp.mu.Lock()
defer cp.mu.Unlock()
f := func() (pools.Resource, error) {
return NewDBConn(cp, appParams)
}
cp.connections = pools.NewResourcePool(f, cp.capacity, cp.capacity, cp.idleTimeout)
cp.appDebugParams = appDebugParams
cp.db... | [
"func",
"(",
"cp",
"*",
"Pool",
")",
"Open",
"(",
"appParams",
",",
"dbaParams",
",",
"appDebugParams",
"*",
"mysql",
".",
"ConnParams",
")",
"{",
"cp",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cp",
".",
"mu",
".",
"Unlock",
"(",
")",
"\... | // Open must be called before starting to use the pool. | [
"Open",
"must",
"be",
"called",
"before",
"starting",
"to",
"use",
"the",
"pool",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/connpool/pool.go#L106-L117 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/connpool/pool.go | Get | func (cp *Pool) Get(ctx context.Context) (*DBConn, error) {
span, ctx := trace.NewSpan(ctx, "Pool.Get")
defer span.Finish()
if cp.isCallerIDAppDebug(ctx) {
return NewDBConnNoPool(cp.appDebugParams, cp.dbaPool)
}
p := cp.pool()
if p == nil {
return nil, ErrConnPoolClosed
}
span.Annotate("capacity", p.Capaci... | go | func (cp *Pool) Get(ctx context.Context) (*DBConn, error) {
span, ctx := trace.NewSpan(ctx, "Pool.Get")
defer span.Finish()
if cp.isCallerIDAppDebug(ctx) {
return NewDBConnNoPool(cp.appDebugParams, cp.dbaPool)
}
p := cp.pool()
if p == nil {
return nil, ErrConnPoolClosed
}
span.Annotate("capacity", p.Capaci... | [
"func",
"(",
"cp",
"*",
"Pool",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"DBConn",
",",
"error",
")",
"{",
"span",
",",
"ctx",
":=",
"trace",
".",
"NewSpan",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",... | // Get returns a connection.
// You must call Recycle on DBConn once done. | [
"Get",
"returns",
"a",
"connection",
".",
"You",
"must",
"call",
"Recycle",
"on",
"DBConn",
"once",
"done",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/connpool/pool.go#L137-L158 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/connpool/pool.go | StatsJSON | func (cp *Pool) StatsJSON() string {
p := cp.pool()
if p == nil {
return "{}"
}
return p.StatsJSON()
} | go | func (cp *Pool) StatsJSON() string {
p := cp.pool()
if p == nil {
return "{}"
}
return p.StatsJSON()
} | [
"func",
"(",
"cp",
"*",
"Pool",
")",
"StatsJSON",
"(",
")",
"string",
"{",
"p",
":=",
"cp",
".",
"pool",
"(",
")",
"\n",
"if",
"p",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"p",
".",
"StatsJSON",
"(",
")",
"\n",
"}"
... | // StatsJSON returns the pool stats as a JSON object. | [
"StatsJSON",
"returns",
"the",
"pool",
"stats",
"as",
"a",
"JSON",
"object",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/connpool/pool.go#L199-L205 | train |
vitessio/vitess | go/json2/unmarshal.go | Unmarshal | func Unmarshal(data []byte, v interface{}) error {
if pb, ok := v.(proto.Message); ok {
return annotate(data, jsonpb.Unmarshal(bytes.NewBuffer(data), pb))
}
return annotate(data, json.Unmarshal(data, v))
} | go | func Unmarshal(data []byte, v interface{}) error {
if pb, ok := v.(proto.Message); ok {
return annotate(data, jsonpb.Unmarshal(bytes.NewBuffer(data), pb))
}
return annotate(data, json.Unmarshal(data, v))
} | [
"func",
"Unmarshal",
"(",
"data",
"[",
"]",
"byte",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"pb",
",",
"ok",
":=",
"v",
".",
"(",
"proto",
".",
"Message",
")",
";",
"ok",
"{",
"return",
"annotate",
"(",
"data",
",",
"jsonpb",
... | // Unmarshal wraps json.Unmarshal, but returns errors that
// also mention the line number. This function is not very
// efficient and should not be used for high QPS operations. | [
"Unmarshal",
"wraps",
"json",
".",
"Unmarshal",
"but",
"returns",
"errors",
"that",
"also",
"mention",
"the",
"line",
"number",
".",
"This",
"function",
"is",
"not",
"very",
"efficient",
"and",
"should",
"not",
"be",
"used",
"for",
"high",
"QPS",
"operations... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/json2/unmarshal.go#L34-L39 | train |
vitessio/vitess | go/sync2/batcher.go | NewBatcher | func NewBatcher(interval time.Duration) *Batcher {
return &Batcher{
interval: interval,
queue: make(chan int),
waiters: NewAtomicInt32(0),
nextID: NewAtomicInt32(0),
after: time.After,
}
} | go | func NewBatcher(interval time.Duration) *Batcher {
return &Batcher{
interval: interval,
queue: make(chan int),
waiters: NewAtomicInt32(0),
nextID: NewAtomicInt32(0),
after: time.After,
}
} | [
"func",
"NewBatcher",
"(",
"interval",
"time",
".",
"Duration",
")",
"*",
"Batcher",
"{",
"return",
"&",
"Batcher",
"{",
"interval",
":",
"interval",
",",
"queue",
":",
"make",
"(",
"chan",
"int",
")",
",",
"waiters",
":",
"NewAtomicInt32",
"(",
"0",
"... | // NewBatcher returns a new Batcher | [
"NewBatcher",
"returns",
"a",
"new",
"Batcher"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/sync2/batcher.go#L39-L47 | train |
vitessio/vitess | go/sync2/batcher.go | Wait | func (b *Batcher) Wait() int {
numWaiters := b.waiters.Add(1)
if numWaiters == 1 {
b.newBatch()
}
return <-b.queue
} | go | func (b *Batcher) Wait() int {
numWaiters := b.waiters.Add(1)
if numWaiters == 1 {
b.newBatch()
}
return <-b.queue
} | [
"func",
"(",
"b",
"*",
"Batcher",
")",
"Wait",
"(",
")",
"int",
"{",
"numWaiters",
":=",
"b",
".",
"waiters",
".",
"Add",
"(",
"1",
")",
"\n",
"if",
"numWaiters",
"==",
"1",
"{",
"b",
".",
"newBatch",
"(",
")",
"\n",
"}",
"\n",
"return",
"<-",
... | // Wait adds a new waiter to the queue and blocks until the next batch | [
"Wait",
"adds",
"a",
"new",
"waiter",
"to",
"the",
"queue",
"and",
"blocks",
"until",
"the",
"next",
"batch"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/sync2/batcher.go#L62-L68 | train |
vitessio/vitess | go/sync2/batcher.go | newBatch | func (b *Batcher) newBatch() {
go func() {
<-b.after(b.interval)
id := b.nextID.Add(1)
// Make sure to atomically reset the number of waiters to make
// sure that all incoming requests either make it into the
// current batch or the next one.
waiters := b.waiters.Get()
for !b.waiters.CompareAndSwap(wai... | go | func (b *Batcher) newBatch() {
go func() {
<-b.after(b.interval)
id := b.nextID.Add(1)
// Make sure to atomically reset the number of waiters to make
// sure that all incoming requests either make it into the
// current batch or the next one.
waiters := b.waiters.Get()
for !b.waiters.CompareAndSwap(wai... | [
"func",
"(",
"b",
"*",
"Batcher",
")",
"newBatch",
"(",
")",
"{",
"go",
"func",
"(",
")",
"{",
"<-",
"b",
".",
"after",
"(",
"b",
".",
"interval",
")",
"\n\n",
"id",
":=",
"b",
".",
"nextID",
".",
"Add",
"(",
"1",
")",
"\n\n",
"// Make sure to ... | // newBatch starts a new batch | [
"newBatch",
"starts",
"a",
"new",
"batch"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/sync2/batcher.go#L71-L89 | train |
vitessio/vitess | go/mysql/encoding.go | readBytesCopy | func readBytesCopy(data []byte, pos int, size int) ([]byte, int, bool) {
if pos+size-1 >= len(data) {
return nil, 0, false
}
result := make([]byte, size)
copy(result, data[pos:pos+size])
return result, pos + size, true
} | go | func readBytesCopy(data []byte, pos int, size int) ([]byte, int, bool) {
if pos+size-1 >= len(data) {
return nil, 0, false
}
result := make([]byte, size)
copy(result, data[pos:pos+size])
return result, pos + size, true
} | [
"func",
"readBytesCopy",
"(",
"data",
"[",
"]",
"byte",
",",
"pos",
"int",
",",
"size",
"int",
")",
"(",
"[",
"]",
"byte",
",",
"int",
",",
"bool",
")",
"{",
"if",
"pos",
"+",
"size",
"-",
"1",
">=",
"len",
"(",
"data",
")",
"{",
"return",
"n... | // readBytesCopy returns a copy of the bytes in the packet.
// Useful to remember contents of ephemeral packets. | [
"readBytesCopy",
"returns",
"a",
"copy",
"of",
"the",
"bytes",
"in",
"the",
"packet",
".",
"Useful",
"to",
"remember",
"contents",
"of",
"ephemeral",
"packets",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/encoding.go#L166-L173 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/pullout_subquery.go | newPulloutSubquery | func newPulloutSubquery(opcode engine.PulloutOpcode, sqName, hasValues string, subquery builder) *pulloutSubquery {
return &pulloutSubquery{
subquery: subquery,
eSubquery: &engine.PulloutSubquery{
Opcode: opcode,
SubqueryResult: sqName,
HasValues: hasValues,
},
}
} | go | func newPulloutSubquery(opcode engine.PulloutOpcode, sqName, hasValues string, subquery builder) *pulloutSubquery {
return &pulloutSubquery{
subquery: subquery,
eSubquery: &engine.PulloutSubquery{
Opcode: opcode,
SubqueryResult: sqName,
HasValues: hasValues,
},
}
} | [
"func",
"newPulloutSubquery",
"(",
"opcode",
"engine",
".",
"PulloutOpcode",
",",
"sqName",
",",
"hasValues",
"string",
",",
"subquery",
"builder",
")",
"*",
"pulloutSubquery",
"{",
"return",
"&",
"pulloutSubquery",
"{",
"subquery",
":",
"subquery",
",",
"eSubqu... | // newPulloutSubquery builds a new pulloutSubquery. | [
"newPulloutSubquery",
"builds",
"a",
"new",
"pulloutSubquery",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/pullout_subquery.go#L37-L46 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/pullout_subquery.go | setUnderlying | func (ps *pulloutSubquery) setUnderlying(underlying builder) {
ps.underlying = underlying
ps.underlying.Reorder(ps.subquery.Order())
ps.order = ps.underlying.Order() + 1
} | go | func (ps *pulloutSubquery) setUnderlying(underlying builder) {
ps.underlying = underlying
ps.underlying.Reorder(ps.subquery.Order())
ps.order = ps.underlying.Order() + 1
} | [
"func",
"(",
"ps",
"*",
"pulloutSubquery",
")",
"setUnderlying",
"(",
"underlying",
"builder",
")",
"{",
"ps",
".",
"underlying",
"=",
"underlying",
"\n",
"ps",
".",
"underlying",
".",
"Reorder",
"(",
"ps",
".",
"subquery",
".",
"Order",
"(",
")",
")",
... | // setUnderlying sets the underlying primitive. | [
"setUnderlying",
"sets",
"the",
"underlying",
"primitive",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/pullout_subquery.go#L49-L53 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/pullout_subquery.go | SetUpperLimit | func (ps *pulloutSubquery) SetUpperLimit(count *sqlparser.SQLVal) {
ps.underlying.SetUpperLimit(count)
} | go | func (ps *pulloutSubquery) SetUpperLimit(count *sqlparser.SQLVal) {
ps.underlying.SetUpperLimit(count)
} | [
"func",
"(",
"ps",
"*",
"pulloutSubquery",
")",
"SetUpperLimit",
"(",
"count",
"*",
"sqlparser",
".",
"SQLVal",
")",
"{",
"ps",
".",
"underlying",
".",
"SetUpperLimit",
"(",
"count",
")",
"\n",
"}"
] | // SetUpperLimit satisfies the builder interface.
// This is a no-op because we actually call SetLimit for this primitive.
// In the future, we may have to honor this call for subqueries. | [
"SetUpperLimit",
"satisfies",
"the",
"builder",
"interface",
".",
"This",
"is",
"a",
"no",
"-",
"op",
"because",
"we",
"actually",
"call",
"SetLimit",
"for",
"this",
"primitive",
".",
"In",
"the",
"future",
"we",
"may",
"have",
"to",
"honor",
"this",
"call... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/pullout_subquery.go#L107-L109 | train |
vitessio/vitess | go/vt/mysqlctl/tmutils/schema.go | TableDefinitionGetColumn | func TableDefinitionGetColumn(td *tabletmanagerdatapb.TableDefinition, name string) (index int, ok bool) {
lowered := strings.ToLower(name)
for i, n := range td.Columns {
if lowered == strings.ToLower(n) {
return i, true
}
}
return -1, false
} | go | func TableDefinitionGetColumn(td *tabletmanagerdatapb.TableDefinition, name string) (index int, ok bool) {
lowered := strings.ToLower(name)
for i, n := range td.Columns {
if lowered == strings.ToLower(n) {
return i, true
}
}
return -1, false
} | [
"func",
"TableDefinitionGetColumn",
"(",
"td",
"*",
"tabletmanagerdatapb",
".",
"TableDefinition",
",",
"name",
"string",
")",
"(",
"index",
"int",
",",
"ok",
"bool",
")",
"{",
"lowered",
":=",
"strings",
".",
"ToLower",
"(",
"name",
")",
"\n",
"for",
"i",... | // TableDefinitionGetColumn returns the index of a column inside a
// TableDefinition. | [
"TableDefinitionGetColumn",
"returns",
"the",
"index",
"of",
"a",
"column",
"inside",
"a",
"TableDefinition",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/tmutils/schema.go#L43-L51 | train |
vitessio/vitess | go/vt/mysqlctl/tmutils/schema.go | Swap | func (tds TableDefinitions) Swap(i, j int) {
tds[i], tds[j] = tds[j], tds[i]
} | go | func (tds TableDefinitions) Swap(i, j int) {
tds[i], tds[j] = tds[j], tds[i]
} | [
"func",
"(",
"tds",
"TableDefinitions",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"tds",
"[",
"i",
"]",
",",
"tds",
"[",
"j",
"]",
"=",
"tds",
"[",
"j",
"]",
",",
"tds",
"[",
"i",
"]",
"\n",
"}"
] | // Swap used for sorting TableDefinitions. | [
"Swap",
"used",
"for",
"sorting",
"TableDefinitions",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/tmutils/schema.go#L62-L64 | train |
vitessio/vitess | go/vt/mysqlctl/tmutils/schema.go | GenerateSchemaVersion | func GenerateSchemaVersion(sd *tabletmanagerdatapb.SchemaDefinition) {
hasher := md5.New()
for _, td := range sd.TableDefinitions {
if _, err := hasher.Write([]byte(td.Schema)); err != nil {
panic(err) // extremely unlikely
}
}
sd.Version = hex.EncodeToString(hasher.Sum(nil))
} | go | func GenerateSchemaVersion(sd *tabletmanagerdatapb.SchemaDefinition) {
hasher := md5.New()
for _, td := range sd.TableDefinitions {
if _, err := hasher.Write([]byte(td.Schema)); err != nil {
panic(err) // extremely unlikely
}
}
sd.Version = hex.EncodeToString(hasher.Sum(nil))
} | [
"func",
"GenerateSchemaVersion",
"(",
"sd",
"*",
"tabletmanagerdatapb",
".",
"SchemaDefinition",
")",
"{",
"hasher",
":=",
"md5",
".",
"New",
"(",
")",
"\n",
"for",
"_",
",",
"td",
":=",
"range",
"sd",
".",
"TableDefinitions",
"{",
"if",
"_",
",",
"err",... | // GenerateSchemaVersion return a unique schema version string based on
// its TableDefinitions. | [
"GenerateSchemaVersion",
"return",
"a",
"unique",
"schema",
"version",
"string",
"based",
"on",
"its",
"TableDefinitions",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/tmutils/schema.go#L166-L174 | train |
vitessio/vitess | go/vt/mysqlctl/tmutils/schema.go | SchemaDefinitionGetTable | func SchemaDefinitionGetTable(sd *tabletmanagerdatapb.SchemaDefinition, table string) (td *tabletmanagerdatapb.TableDefinition, ok bool) {
for _, td := range sd.TableDefinitions {
if td.Name == table {
return td, true
}
}
return nil, false
} | go | func SchemaDefinitionGetTable(sd *tabletmanagerdatapb.SchemaDefinition, table string) (td *tabletmanagerdatapb.TableDefinition, ok bool) {
for _, td := range sd.TableDefinitions {
if td.Name == table {
return td, true
}
}
return nil, false
} | [
"func",
"SchemaDefinitionGetTable",
"(",
"sd",
"*",
"tabletmanagerdatapb",
".",
"SchemaDefinition",
",",
"table",
"string",
")",
"(",
"td",
"*",
"tabletmanagerdatapb",
".",
"TableDefinition",
",",
"ok",
"bool",
")",
"{",
"for",
"_",
",",
"td",
":=",
"range",
... | // SchemaDefinitionGetTable returns TableDefinition for a given table name. | [
"SchemaDefinitionGetTable",
"returns",
"TableDefinition",
"for",
"a",
"given",
"table",
"name",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/tmutils/schema.go#L177-L184 | train |
vitessio/vitess | go/vt/mysqlctl/tmutils/schema.go | DiffSchema | func DiffSchema(leftName string, left *tabletmanagerdatapb.SchemaDefinition, rightName string, right *tabletmanagerdatapb.SchemaDefinition, er concurrency.ErrorRecorder) {
if left == nil && right == nil {
return
}
if left == nil || right == nil {
er.RecordError(fmt.Errorf("schemas are different:\n%s: %v, %s: %v"... | go | func DiffSchema(leftName string, left *tabletmanagerdatapb.SchemaDefinition, rightName string, right *tabletmanagerdatapb.SchemaDefinition, er concurrency.ErrorRecorder) {
if left == nil && right == nil {
return
}
if left == nil || right == nil {
er.RecordError(fmt.Errorf("schemas are different:\n%s: %v, %s: %v"... | [
"func",
"DiffSchema",
"(",
"leftName",
"string",
",",
"left",
"*",
"tabletmanagerdatapb",
".",
"SchemaDefinition",
",",
"rightName",
"string",
",",
"right",
"*",
"tabletmanagerdatapb",
".",
"SchemaDefinition",
",",
"er",
"concurrency",
".",
"ErrorRecorder",
")",
"... | // DiffSchema generates a report on what's different between two SchemaDefinitions
// including views. | [
"DiffSchema",
"generates",
"a",
"report",
"on",
"what",
"s",
"different",
"between",
"two",
"SchemaDefinitions",
"including",
"views",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/tmutils/schema.go#L214-L274 | train |
vitessio/vitess | go/vt/mysqlctl/tmutils/schema.go | DiffSchemaToArray | func DiffSchemaToArray(leftName string, left *tabletmanagerdatapb.SchemaDefinition, rightName string, right *tabletmanagerdatapb.SchemaDefinition) (result []string) {
er := concurrency.AllErrorRecorder{}
DiffSchema(leftName, left, rightName, right, &er)
if er.HasErrors() {
return er.ErrorStrings()
}
return nil
} | go | func DiffSchemaToArray(leftName string, left *tabletmanagerdatapb.SchemaDefinition, rightName string, right *tabletmanagerdatapb.SchemaDefinition) (result []string) {
er := concurrency.AllErrorRecorder{}
DiffSchema(leftName, left, rightName, right, &er)
if er.HasErrors() {
return er.ErrorStrings()
}
return nil
} | [
"func",
"DiffSchemaToArray",
"(",
"leftName",
"string",
",",
"left",
"*",
"tabletmanagerdatapb",
".",
"SchemaDefinition",
",",
"rightName",
"string",
",",
"right",
"*",
"tabletmanagerdatapb",
".",
"SchemaDefinition",
")",
"(",
"result",
"[",
"]",
"string",
")",
... | // DiffSchemaToArray diffs two schemas and return the schema diffs if there is any. | [
"DiffSchemaToArray",
"diffs",
"two",
"schemas",
"and",
"return",
"the",
"schema",
"diffs",
"if",
"there",
"is",
"any",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/tmutils/schema.go#L277-L284 | train |
vitessio/vitess | go/vt/mysqlctl/tmutils/schema.go | Equal | func (s *SchemaChange) Equal(s2 *SchemaChange) bool {
return s.SQL == s2.SQL &&
s.Force == s2.Force &&
s.AllowReplication == s2.AllowReplication &&
proto.Equal(s.BeforeSchema, s2.BeforeSchema) &&
proto.Equal(s.AfterSchema, s2.AfterSchema)
} | go | func (s *SchemaChange) Equal(s2 *SchemaChange) bool {
return s.SQL == s2.SQL &&
s.Force == s2.Force &&
s.AllowReplication == s2.AllowReplication &&
proto.Equal(s.BeforeSchema, s2.BeforeSchema) &&
proto.Equal(s.AfterSchema, s2.AfterSchema)
} | [
"func",
"(",
"s",
"*",
"SchemaChange",
")",
"Equal",
"(",
"s2",
"*",
"SchemaChange",
")",
"bool",
"{",
"return",
"s",
".",
"SQL",
"==",
"s2",
".",
"SQL",
"&&",
"s",
".",
"Force",
"==",
"s2",
".",
"Force",
"&&",
"s",
".",
"AllowReplication",
"==",
... | // Equal compares two SchemaChange objects. | [
"Equal",
"compares",
"two",
"SchemaChange",
"objects",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/tmutils/schema.go#L297-L303 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/splitquery/utils.go | populateNewBindVariable | func populateNewBindVariable(
bindVariableName string,
bindVariableValue *querypb.BindVariable,
resultBindVariables map[string]*querypb.BindVariable) {
_, alreadyInMap := resultBindVariables[bindVariableName]
if alreadyInMap {
panic(fmt.Sprintf(
"bindVariable %v already exists in map: %v. bindVariableValue gi... | go | func populateNewBindVariable(
bindVariableName string,
bindVariableValue *querypb.BindVariable,
resultBindVariables map[string]*querypb.BindVariable) {
_, alreadyInMap := resultBindVariables[bindVariableName]
if alreadyInMap {
panic(fmt.Sprintf(
"bindVariable %v already exists in map: %v. bindVariableValue gi... | [
"func",
"populateNewBindVariable",
"(",
"bindVariableName",
"string",
",",
"bindVariableValue",
"*",
"querypb",
".",
"BindVariable",
",",
"resultBindVariables",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
")",
"{",
"_",
",",
"alreadyInMap",
":=... | // populateNewBindVariable inserts 'bindVariableName' with 'bindVariableValue' to the
// 'resultBindVariables' map. Panics if 'bindVariableName' already exists in the map. | [
"populateNewBindVariable",
"inserts",
"bindVariableName",
"with",
"bindVariableValue",
"to",
"the",
"resultBindVariables",
"map",
".",
"Panics",
"if",
"bindVariableName",
"already",
"exists",
"in",
"the",
"map",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/splitquery/utils.go#L31-L44 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/splitquery/utils.go | cloneBindVariables | func cloneBindVariables(bindVariables map[string]*querypb.BindVariable) map[string]*querypb.BindVariable {
result := make(map[string]*querypb.BindVariable)
for key, value := range bindVariables {
result[key] = value
}
return result
} | go | func cloneBindVariables(bindVariables map[string]*querypb.BindVariable) map[string]*querypb.BindVariable {
result := make(map[string]*querypb.BindVariable)
for key, value := range bindVariables {
result[key] = value
}
return result
} | [
"func",
"cloneBindVariables",
"(",
"bindVariables",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
")",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
"{",
"result",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"qu... | // cloneBindVariables returns a shallow-copy of the given bindVariables map. | [
"cloneBindVariables",
"returns",
"a",
"shallow",
"-",
"copy",
"of",
"the",
"given",
"bindVariables",
"map",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/splitquery/utils.go#L47-L53 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/tabletenv/logstats.go | ImmediateCaller | func (stats *LogStats) ImmediateCaller() string {
return callerid.GetUsername(callerid.ImmediateCallerIDFromContext(stats.Ctx))
} | go | func (stats *LogStats) ImmediateCaller() string {
return callerid.GetUsername(callerid.ImmediateCallerIDFromContext(stats.Ctx))
} | [
"func",
"(",
"stats",
"*",
"LogStats",
")",
"ImmediateCaller",
"(",
")",
"string",
"{",
"return",
"callerid",
".",
"GetUsername",
"(",
"callerid",
".",
"ImmediateCallerIDFromContext",
"(",
"stats",
".",
"Ctx",
")",
")",
"\n",
"}"
] | // ImmediateCaller returns the immediate caller stored in LogStats.Ctx | [
"ImmediateCaller",
"returns",
"the",
"immediate",
"caller",
"stored",
"in",
"LogStats",
".",
"Ctx"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/tabletenv/logstats.go#L87-L89 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/tabletenv/logstats.go | EffectiveCaller | func (stats *LogStats) EffectiveCaller() string {
return callerid.GetPrincipal(callerid.EffectiveCallerIDFromContext(stats.Ctx))
} | go | func (stats *LogStats) EffectiveCaller() string {
return callerid.GetPrincipal(callerid.EffectiveCallerIDFromContext(stats.Ctx))
} | [
"func",
"(",
"stats",
"*",
"LogStats",
")",
"EffectiveCaller",
"(",
")",
"string",
"{",
"return",
"callerid",
".",
"GetPrincipal",
"(",
"callerid",
".",
"EffectiveCallerIDFromContext",
"(",
"stats",
".",
"Ctx",
")",
")",
"\n",
"}"
] | // EffectiveCaller returns the effective caller stored in LogStats.Ctx | [
"EffectiveCaller",
"returns",
"the",
"effective",
"caller",
"stored",
"in",
"LogStats",
".",
"Ctx"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/tabletenv/logstats.go#L92-L94 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/tabletenv/logstats.go | AddRewrittenSQL | func (stats *LogStats) AddRewrittenSQL(sql string, start time.Time) {
stats.QuerySources |= QuerySourceMySQL
stats.NumberOfQueries++
stats.rewrittenSqls = append(stats.rewrittenSqls, sql)
stats.MysqlResponseTime += time.Since(start)
} | go | func (stats *LogStats) AddRewrittenSQL(sql string, start time.Time) {
stats.QuerySources |= QuerySourceMySQL
stats.NumberOfQueries++
stats.rewrittenSqls = append(stats.rewrittenSqls, sql)
stats.MysqlResponseTime += time.Since(start)
} | [
"func",
"(",
"stats",
"*",
"LogStats",
")",
"AddRewrittenSQL",
"(",
"sql",
"string",
",",
"start",
"time",
".",
"Time",
")",
"{",
"stats",
".",
"QuerySources",
"|=",
"QuerySourceMySQL",
"\n",
"stats",
".",
"NumberOfQueries",
"++",
"\n",
"stats",
".",
"rewr... | // AddRewrittenSQL adds a single sql statement to the rewritten list | [
"AddRewrittenSQL",
"adds",
"a",
"single",
"sql",
"statement",
"to",
"the",
"rewritten",
"list"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/tabletenv/logstats.go#L102-L107 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/tabletenv/logstats.go | TotalTime | func (stats *LogStats) TotalTime() time.Duration {
return stats.EndTime.Sub(stats.StartTime)
} | go | func (stats *LogStats) TotalTime() time.Duration {
return stats.EndTime.Sub(stats.StartTime)
} | [
"func",
"(",
"stats",
"*",
"LogStats",
")",
"TotalTime",
"(",
")",
"time",
".",
"Duration",
"{",
"return",
"stats",
".",
"EndTime",
".",
"Sub",
"(",
"stats",
".",
"StartTime",
")",
"\n",
"}"
] | // TotalTime returns how long this query has been running | [
"TotalTime",
"returns",
"how",
"long",
"this",
"query",
"has",
"been",
"running"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/tabletenv/logstats.go#L110-L112 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/tabletenv/logstats.go | FmtQuerySources | func (stats *LogStats) FmtQuerySources() string {
if stats.QuerySources == 0 {
return "none"
}
sources := make([]string, 2)
n := 0
if stats.QuerySources&QuerySourceMySQL != 0 {
sources[n] = "mysql"
n++
}
if stats.QuerySources&QuerySourceConsolidator != 0 {
sources[n] = "consolidator"
n++
}
return str... | go | func (stats *LogStats) FmtQuerySources() string {
if stats.QuerySources == 0 {
return "none"
}
sources := make([]string, 2)
n := 0
if stats.QuerySources&QuerySourceMySQL != 0 {
sources[n] = "mysql"
n++
}
if stats.QuerySources&QuerySourceConsolidator != 0 {
sources[n] = "consolidator"
n++
}
return str... | [
"func",
"(",
"stats",
"*",
"LogStats",
")",
"FmtQuerySources",
"(",
")",
"string",
"{",
"if",
"stats",
".",
"QuerySources",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"sources",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"2",
")",
"\n"... | // FmtQuerySources returns a comma separated list of query
// sources. If there were no query sources, it returns the string
// "none". | [
"FmtQuerySources",
"returns",
"a",
"comma",
"separated",
"list",
"of",
"query",
"sources",
".",
"If",
"there",
"were",
"no",
"query",
"sources",
"it",
"returns",
"the",
"string",
"none",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/tabletenv/logstats.go#L139-L154 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/tabletenv/logstats.go | ErrorStr | func (stats *LogStats) ErrorStr() string {
if stats.Error != nil {
return stats.Error.Error()
}
return ""
} | go | func (stats *LogStats) ErrorStr() string {
if stats.Error != nil {
return stats.Error.Error()
}
return ""
} | [
"func",
"(",
"stats",
"*",
"LogStats",
")",
"ErrorStr",
"(",
")",
"string",
"{",
"if",
"stats",
".",
"Error",
"!=",
"nil",
"{",
"return",
"stats",
".",
"Error",
".",
"Error",
"(",
")",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] | // ErrorStr returns the error string or "" | [
"ErrorStr",
"returns",
"the",
"error",
"string",
"or"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/tabletenv/logstats.go#L164-L169 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/tabletenv/logstats.go | CallInfo | func (stats *LogStats) CallInfo() (string, string) {
ci, ok := callinfo.FromContext(stats.Ctx)
if !ok {
return "", ""
}
return ci.Text(), ci.Username()
} | go | func (stats *LogStats) CallInfo() (string, string) {
ci, ok := callinfo.FromContext(stats.Ctx)
if !ok {
return "", ""
}
return ci.Text(), ci.Username()
} | [
"func",
"(",
"stats",
"*",
"LogStats",
")",
"CallInfo",
"(",
")",
"(",
"string",
",",
"string",
")",
"{",
"ci",
",",
"ok",
":=",
"callinfo",
".",
"FromContext",
"(",
"stats",
".",
"Ctx",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
",",... | // CallInfo returns some parts of CallInfo if set | [
"CallInfo",
"returns",
"some",
"parts",
"of",
"CallInfo",
"if",
"set"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/tabletenv/logstats.go#L172-L178 | train |
vitessio/vitess | go/vtbench/vtbench.go | String | func (cp ClientProtocol) String() string {
switch cp {
case MySQL:
return "mysql"
case GRPCVtgate:
return "grpc-vtgate"
case GRPCVttablet:
return "grpc-vttablet"
default:
return fmt.Sprintf("unknown-protocol-%d", cp)
}
} | go | func (cp ClientProtocol) String() string {
switch cp {
case MySQL:
return "mysql"
case GRPCVtgate:
return "grpc-vtgate"
case GRPCVttablet:
return "grpc-vttablet"
default:
return fmt.Sprintf("unknown-protocol-%d", cp)
}
} | [
"func",
"(",
"cp",
"ClientProtocol",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"cp",
"{",
"case",
"MySQL",
":",
"return",
"\"",
"\"",
"\n",
"case",
"GRPCVtgate",
":",
"return",
"\"",
"\"",
"\n",
"case",
"GRPCVttablet",
":",
"return",
"\"",
"\""... | // ProtocolString returns a string representation of the protocol | [
"ProtocolString",
"returns",
"a",
"string",
"representation",
"of",
"the",
"protocol"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vtbench/vtbench.go#L47-L58 | train |
vitessio/vitess | go/vtbench/vtbench.go | NewBench | func NewBench(threads, count int, cp ConnParams, query string) *Bench {
bench := Bench{
Threads: threads,
Count: count,
ConnParams: cp,
Query: query,
Rows: stats.NewCounter("", ""),
Timings: stats.NewTimings("", "", ""),
}
return &bench
} | go | func NewBench(threads, count int, cp ConnParams, query string) *Bench {
bench := Bench{
Threads: threads,
Count: count,
ConnParams: cp,
Query: query,
Rows: stats.NewCounter("", ""),
Timings: stats.NewTimings("", "", ""),
}
return &bench
} | [
"func",
"NewBench",
"(",
"threads",
",",
"count",
"int",
",",
"cp",
"ConnParams",
",",
"query",
"string",
")",
"*",
"Bench",
"{",
"bench",
":=",
"Bench",
"{",
"Threads",
":",
"threads",
",",
"Count",
":",
"count",
",",
"ConnParams",
":",
"cp",
",",
"... | // NewBench creates a new bench test | [
"NewBench",
"creates",
"a",
"new",
"bench",
"test"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vtbench/vtbench.go#L102-L112 | train |
vitessio/vitess | go/vtbench/vtbench.go | Run | func (b *Bench) Run(ctx context.Context) error {
err := b.createConns(ctx)
if err != nil {
return err
}
b.createThreads(ctx)
b.runTest(ctx)
return nil
} | go | func (b *Bench) Run(ctx context.Context) error {
err := b.createConns(ctx)
if err != nil {
return err
}
b.createThreads(ctx)
b.runTest(ctx)
return nil
} | [
"func",
"(",
"b",
"*",
"Bench",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"err",
":=",
"b",
".",
"createConns",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"b",
".",
"cre... | // Run executes the test | [
"Run",
"executes",
"the",
"test"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vtbench/vtbench.go#L115-L124 | train |
vitessio/vitess | go/history/history.go | Add | func (history *History) Add(record interface{}) {
history.mu.Lock()
defer history.mu.Unlock()
history.latest = record
if equiv, ok := record.(Deduplicable); ok && history.length > 0 {
if equiv.IsDuplicate(history.lastAdded) {
return
}
}
history.records[history.next] = record
history.lastAdded = record
... | go | func (history *History) Add(record interface{}) {
history.mu.Lock()
defer history.mu.Unlock()
history.latest = record
if equiv, ok := record.(Deduplicable); ok && history.length > 0 {
if equiv.IsDuplicate(history.lastAdded) {
return
}
}
history.records[history.next] = record
history.lastAdded = record
... | [
"func",
"(",
"history",
"*",
"History",
")",
"Add",
"(",
"record",
"interface",
"{",
"}",
")",
"{",
"history",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"history",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"history",
".",
"latest",
"=",
... | // Add a new record in a threadsafe manner. If record implements
// Deduplicable, and IsDuplicate returns true when called on the last
// previously added record, it will not be added. | [
"Add",
"a",
"new",
"record",
"in",
"a",
"threadsafe",
"manner",
".",
"If",
"record",
"implements",
"Deduplicable",
"and",
"IsDuplicate",
"returns",
"true",
"when",
"called",
"on",
"the",
"last",
"previously",
"added",
"record",
"it",
"will",
"not",
"be",
"ad... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/history/history.go#L52-L72 | train |
vitessio/vitess | go/history/history.go | Records | func (history *History) Records() []interface{} {
history.mu.Lock()
defer history.mu.Unlock()
records := make([]interface{}, 0, history.length)
records = append(records, history.records[history.next:history.length]...)
records = append(records, history.records[:history.next]...)
// In place reverse.
for i := 0... | go | func (history *History) Records() []interface{} {
history.mu.Lock()
defer history.mu.Unlock()
records := make([]interface{}, 0, history.length)
records = append(records, history.records[history.next:history.length]...)
records = append(records, history.records[:history.next]...)
// In place reverse.
for i := 0... | [
"func",
"(",
"history",
"*",
"History",
")",
"Records",
"(",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"history",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"history",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"records",
":=",
"make",
"(... | // Records returns the kept records in reverse chronological order in a
// threadsafe manner. | [
"Records",
"returns",
"the",
"kept",
"records",
"in",
"reverse",
"chronological",
"order",
"in",
"a",
"threadsafe",
"manner",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/history/history.go#L76-L90 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_external_reparent.go | TabletExternallyReparented | func (agent *ActionAgent) TabletExternallyReparented(ctx context.Context, externalID string) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
startTime := time.Now()
// If there is a finalize step running, wait for it to finish or time out
// before checking the global shard r... | go | func (agent *ActionAgent) TabletExternallyReparented(ctx context.Context, externalID string) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
startTime := time.Now()
// If there is a finalize step running, wait for it to finish or time out
// before checking the global shard r... | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"TabletExternallyReparented",
"(",
"ctx",
"context",
".",
"Context",
",",
"externalID",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
... | // TabletExternallyReparented updates all topo records so the current
// tablet is the new master for this shard. | [
"TabletExternallyReparented",
"updates",
"all",
"topo",
"records",
"so",
"the",
"current",
"tablet",
"is",
"the",
"new",
"master",
"for",
"this",
"shard",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_external_reparent.go#L52-L135 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_external_reparent.go | setExternallyReparentedTime | func (agent *ActionAgent) setExternallyReparentedTime(t time.Time) {
agent.mutex.Lock()
defer agent.mutex.Unlock()
agent._tabletExternallyReparentedTime = t
agent._replicationDelay = 0
} | go | func (agent *ActionAgent) setExternallyReparentedTime(t time.Time) {
agent.mutex.Lock()
defer agent.mutex.Unlock()
agent._tabletExternallyReparentedTime = t
agent._replicationDelay = 0
} | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"setExternallyReparentedTime",
"(",
"t",
"time",
".",
"Time",
")",
"{",
"agent",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"agent",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"agent",
".",
... | // setExternallyReparentedTime remembers the last time when we were told we're
// the master.
// If another tablet claims to be master and offers a more recent time,
// that tablet will be trusted over us. | [
"setExternallyReparentedTime",
"remembers",
"the",
"last",
"time",
"when",
"we",
"were",
"told",
"we",
"re",
"the",
"master",
".",
"If",
"another",
"tablet",
"claims",
"to",
"be",
"master",
"and",
"offers",
"a",
"more",
"recent",
"time",
"that",
"tablet",
"w... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_external_reparent.go#L253-L259 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/vreplication/vplayer.go | play | func (vp *vplayer) play(ctx context.Context) error {
if !vp.stopPos.IsZero() && vp.startPos.AtLeast(vp.stopPos) {
if vp.saveStop {
return vp.vr.setState(binlogplayer.BlpStopped, fmt.Sprintf("Stop position %v already reached: %v", vp.startPos, vp.stopPos))
}
return nil
}
plan, err := buildReplicatorPlan(vp.... | go | func (vp *vplayer) play(ctx context.Context) error {
if !vp.stopPos.IsZero() && vp.startPos.AtLeast(vp.stopPos) {
if vp.saveStop {
return vp.vr.setState(binlogplayer.BlpStopped, fmt.Sprintf("Stop position %v already reached: %v", vp.startPos, vp.stopPos))
}
return nil
}
plan, err := buildReplicatorPlan(vp.... | [
"func",
"(",
"vp",
"*",
"vplayer",
")",
"play",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"!",
"vp",
".",
"stopPos",
".",
"IsZero",
"(",
")",
"&&",
"vp",
".",
"startPos",
".",
"AtLeast",
"(",
"vp",
".",
"stopPos",
")",
"{",
... | // play is not resumable. If pausePos is set, play returns without updating the vreplication state. | [
"play",
"is",
"not",
"resumable",
".",
"If",
"pausePos",
"is",
"set",
"play",
"returns",
"without",
"updating",
"the",
"vreplication",
"state",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/vreplication/vplayer.go#L79-L105 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/vindex_func.go | PushFilter | func (vf *vindexFunc) PushFilter(pb *primitiveBuilder, filter sqlparser.Expr, whereType string, _ builder) error {
if vf.eVindexFunc.Opcode != engine.VindexNone {
return errors.New("unsupported: where clause for vindex function must be of the form id = <val> (multiple filters)")
}
// Check LHS.
comparison, ok :=... | go | func (vf *vindexFunc) PushFilter(pb *primitiveBuilder, filter sqlparser.Expr, whereType string, _ builder) error {
if vf.eVindexFunc.Opcode != engine.VindexNone {
return errors.New("unsupported: where clause for vindex function must be of the form id = <val> (multiple filters)")
}
// Check LHS.
comparison, ok :=... | [
"func",
"(",
"vf",
"*",
"vindexFunc",
")",
"PushFilter",
"(",
"pb",
"*",
"primitiveBuilder",
",",
"filter",
"sqlparser",
".",
"Expr",
",",
"whereType",
"string",
",",
"_",
"builder",
")",
"error",
"{",
"if",
"vf",
".",
"eVindexFunc",
".",
"Opcode",
"!=",... | // PushFilter satisfies the builder interface.
// Only some where clauses are allowed. | [
"PushFilter",
"satisfies",
"the",
"builder",
"interface",
".",
"Only",
"some",
"where",
"clauses",
"are",
"allowed",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/vindex_func.go#L97-L130 | train |
vitessio/vitess | go/vt/vtgate/vindexes/reverse_bits.go | NewReverseBits | func NewReverseBits(name string, m map[string]string) (Vindex, error) {
return &ReverseBits{name: name}, nil
} | go | func NewReverseBits(name string, m map[string]string) (Vindex, error) {
return &ReverseBits{name: name}, nil
} | [
"func",
"NewReverseBits",
"(",
"name",
"string",
",",
"m",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"Vindex",
",",
"error",
")",
"{",
"return",
"&",
"ReverseBits",
"{",
"name",
":",
"name",
"}",
",",
"nil",
"\n",
"}"
] | // NewReverseBits creates a new ReverseBits. | [
"NewReverseBits",
"creates",
"a",
"new",
"ReverseBits",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/reverse_bits.go#L43-L45 | train |
vitessio/vitess | go/vt/vtgate/vindexes/reverse_bits.go | Map | func (vind *ReverseBits) Map(cursor VCursor, ids []sqltypes.Value) ([]key.Destination, error) {
out := make([]key.Destination, len(ids))
for i, id := range ids {
num, err := sqltypes.ToUint64(id)
if err != nil {
out[i] = key.DestinationNone{}
continue
}
out[i] = key.DestinationKeyspaceID(reverse(num))
... | go | func (vind *ReverseBits) Map(cursor VCursor, ids []sqltypes.Value) ([]key.Destination, error) {
out := make([]key.Destination, len(ids))
for i, id := range ids {
num, err := sqltypes.ToUint64(id)
if err != nil {
out[i] = key.DestinationNone{}
continue
}
out[i] = key.DestinationKeyspaceID(reverse(num))
... | [
"func",
"(",
"vind",
"*",
"ReverseBits",
")",
"Map",
"(",
"cursor",
"VCursor",
",",
"ids",
"[",
"]",
"sqltypes",
".",
"Value",
")",
"(",
"[",
"]",
"key",
".",
"Destination",
",",
"error",
")",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"key",
".",
... | // Map returns the corresponding KeyspaceId values for the given ids. | [
"Map",
"returns",
"the",
"corresponding",
"KeyspaceId",
"values",
"for",
"the",
"given",
"ids",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/reverse_bits.go#L68-L79 | train |
vitessio/vitess | go/vt/vtgate/vindexes/reverse_bits.go | ReverseMap | func (vind *ReverseBits) ReverseMap(_ VCursor, ksids [][]byte) ([]sqltypes.Value, error) {
reverseIds := make([]sqltypes.Value, 0, len(ksids))
for _, keyspaceID := range ksids {
val, err := unreverse(keyspaceID)
if err != nil {
return reverseIds, err
}
reverseIds = append(reverseIds, sqltypes.NewUint64(val... | go | func (vind *ReverseBits) ReverseMap(_ VCursor, ksids [][]byte) ([]sqltypes.Value, error) {
reverseIds := make([]sqltypes.Value, 0, len(ksids))
for _, keyspaceID := range ksids {
val, err := unreverse(keyspaceID)
if err != nil {
return reverseIds, err
}
reverseIds = append(reverseIds, sqltypes.NewUint64(val... | [
"func",
"(",
"vind",
"*",
"ReverseBits",
")",
"ReverseMap",
"(",
"_",
"VCursor",
",",
"ksids",
"[",
"]",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"sqltypes",
".",
"Value",
",",
"error",
")",
"{",
"reverseIds",
":=",
"make",
"(",
"[",
"]",
"sqltypes",
... | // ReverseMap returns the ids from ksids. | [
"ReverseMap",
"returns",
"the",
"ids",
"from",
"ksids",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/reverse_bits.go#L95-L105 | train |
vitessio/vitess | go/stats/multidimensional.go | CounterForDimension | func CounterForDimension(mt MultiTracker, dimension string) CountTracker {
for i, lab := range mt.Labels() {
if lab == dimension {
return wrappedCountTracker{
f: func() map[string]int64 {
result := make(map[string]int64)
for k, v := range mt.Counts() {
if k == "All" {
result[k] = v
... | go | func CounterForDimension(mt MultiTracker, dimension string) CountTracker {
for i, lab := range mt.Labels() {
if lab == dimension {
return wrappedCountTracker{
f: func() map[string]int64 {
result := make(map[string]int64)
for k, v := range mt.Counts() {
if k == "All" {
result[k] = v
... | [
"func",
"CounterForDimension",
"(",
"mt",
"MultiTracker",
",",
"dimension",
"string",
")",
"CountTracker",
"{",
"for",
"i",
",",
"lab",
":=",
"range",
"mt",
".",
"Labels",
"(",
")",
"{",
"if",
"lab",
"==",
"dimension",
"{",
"return",
"wrappedCountTracker",
... | // CounterForDimension returns a CountTracker for the provided
// dimension. It will panic if the dimension isn't a legal label for
// mt. | [
"CounterForDimension",
"returns",
"a",
"CountTracker",
"for",
"the",
"provided",
"dimension",
".",
"It",
"will",
"panic",
"if",
"the",
"dimension",
"isn",
"t",
"a",
"legal",
"label",
"for",
"mt",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/stats/multidimensional.go#L34-L54 | train |
vitessio/vitess | go/vt/vtctld/tablet_stats_cache.go | StatsUpdate | func (c *tabletStatsCache) StatsUpdate(stats *discovery.TabletStats) {
c.mu.Lock()
defer c.mu.Unlock()
keyspace := stats.Tablet.Keyspace
shard := stats.Tablet.Shard
cell := stats.Tablet.Alias.Cell
tabletType := stats.Tablet.Type
aliasKey := tabletToMapKey(stats)
ts, ok := c.statusesByAlias[aliasKey]
if !stat... | go | func (c *tabletStatsCache) StatsUpdate(stats *discovery.TabletStats) {
c.mu.Lock()
defer c.mu.Unlock()
keyspace := stats.Tablet.Keyspace
shard := stats.Tablet.Shard
cell := stats.Tablet.Alias.Cell
tabletType := stats.Tablet.Type
aliasKey := tabletToMapKey(stats)
ts, ok := c.statusesByAlias[aliasKey]
if !stat... | [
"func",
"(",
"c",
"*",
"tabletStatsCache",
")",
"StatsUpdate",
"(",
"stats",
"*",
"discovery",
".",
"TabletStats",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"keyspace",
":=",
"s... | // StatsUpdate is part of the discovery.HealthCheckStatsListener interface.
// Upon receiving a new TabletStats, it updates the two maps in tablet_stats_cache. | [
"StatsUpdate",
"is",
"part",
"of",
"the",
"discovery",
".",
"HealthCheckStatsListener",
"interface",
".",
"Upon",
"receiving",
"a",
"new",
"TabletStats",
"it",
"updates",
"the",
"two",
"maps",
"in",
"tablet_stats_cache",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctld/tablet_stats_cache.go#L110-L166 | train |
vitessio/vitess | go/vt/vtctld/tablet_stats_cache.go | keyspacesLocked | func (c *tabletStatsCache) keyspacesLocked(keyspace string) []string {
if keyspace != "all" {
return []string{keyspace}
}
var keyspaces []string
for ks := range c.statuses {
keyspaces = append(keyspaces, ks)
}
sort.Strings(keyspaces)
return keyspaces
} | go | func (c *tabletStatsCache) keyspacesLocked(keyspace string) []string {
if keyspace != "all" {
return []string{keyspace}
}
var keyspaces []string
for ks := range c.statuses {
keyspaces = append(keyspaces, ks)
}
sort.Strings(keyspaces)
return keyspaces
} | [
"func",
"(",
"c",
"*",
"tabletStatsCache",
")",
"keyspacesLocked",
"(",
"keyspace",
"string",
")",
"[",
"]",
"string",
"{",
"if",
"keyspace",
"!=",
"\"",
"\"",
"{",
"return",
"[",
"]",
"string",
"{",
"keyspace",
"}",
"\n",
"}",
"\n",
"var",
"keyspaces"... | // keyspacesLocked returns the keyspaces to be displayed in the heatmap based on the dropdown filters.
// It returns one keyspace if a specific one was chosen or returns all of them if 'all' is chosen.
// This method is used by heatmapData to traverse over desired keyspaces and
// topologyInfo to send all available opt... | [
"keyspacesLocked",
"returns",
"the",
"keyspaces",
"to",
"be",
"displayed",
"in",
"the",
"heatmap",
"based",
"on",
"the",
"dropdown",
"filters",
".",
"It",
"returns",
"one",
"keyspace",
"if",
"a",
"specific",
"one",
"was",
"chosen",
"or",
"returns",
"all",
"o... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctld/tablet_stats_cache.go#L207-L217 | train |
vitessio/vitess | go/vt/vtctld/tablet_stats_cache.go | cellsLocked | func (c *tabletStatsCache) cellsLocked(keyspace, cell string) []string {
if cell != "all" {
return []string{cell}
}
return c.cellsInTopology(keyspace)
} | go | func (c *tabletStatsCache) cellsLocked(keyspace, cell string) []string {
if cell != "all" {
return []string{cell}
}
return c.cellsInTopology(keyspace)
} | [
"func",
"(",
"c",
"*",
"tabletStatsCache",
")",
"cellsLocked",
"(",
"keyspace",
",",
"cell",
"string",
")",
"[",
"]",
"string",
"{",
"if",
"cell",
"!=",
"\"",
"\"",
"{",
"return",
"[",
"]",
"string",
"{",
"cell",
"}",
"\n",
"}",
"\n",
"return",
"c"... | // cellsLocked returns the cells needed to be displayed in the heatmap based on the dropdown filters.
// returns one cell if a specific one was chosen or returns all of them if 'all' is chosen.
// This method is used by heatmapData to traverse over the desired cells. | [
"cellsLocked",
"returns",
"the",
"cells",
"needed",
"to",
"be",
"displayed",
"in",
"the",
"heatmap",
"based",
"on",
"the",
"dropdown",
"filters",
".",
"returns",
"one",
"cell",
"if",
"a",
"specific",
"one",
"was",
"chosen",
"or",
"returns",
"all",
"of",
"t... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctld/tablet_stats_cache.go#L222-L227 | train |
vitessio/vitess | go/vt/vtctld/tablet_stats_cache.go | cellsInTopology | func (c *tabletStatsCache) cellsInTopology(keyspace string) []string {
keyspaces := c.keyspacesLocked(keyspace)
cells := make(map[string]bool)
// Going through all shards in each keyspace to get all existing cells
for _, ks := range keyspaces {
shardsPerKeyspace := c.statuses[ks]
for s := range shardsPerKeyspac... | go | func (c *tabletStatsCache) cellsInTopology(keyspace string) []string {
keyspaces := c.keyspacesLocked(keyspace)
cells := make(map[string]bool)
// Going through all shards in each keyspace to get all existing cells
for _, ks := range keyspaces {
shardsPerKeyspace := c.statuses[ks]
for s := range shardsPerKeyspac... | [
"func",
"(",
"c",
"*",
"tabletStatsCache",
")",
"cellsInTopology",
"(",
"keyspace",
"string",
")",
"[",
"]",
"string",
"{",
"keyspaces",
":=",
"c",
".",
"keyspacesLocked",
"(",
"keyspace",
")",
"\n",
"cells",
":=",
"make",
"(",
"map",
"[",
"string",
"]",... | // cellsInTopology returns all the cells in the given keyspace.
// If all keyspaces is chosen, it returns the cells from every keyspace.
// This method is used by topologyInfo to send all available options for the cell dropdown | [
"cellsInTopology",
"returns",
"all",
"the",
"cells",
"in",
"the",
"given",
"keyspace",
".",
"If",
"all",
"keyspaces",
"is",
"chosen",
"it",
"returns",
"the",
"cells",
"from",
"every",
"keyspace",
".",
"This",
"method",
"is",
"used",
"by",
"topologyInfo",
"to... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctld/tablet_stats_cache.go#L243-L262 | train |
vitessio/vitess | go/vt/vtctld/tablet_stats_cache.go | typesInTopology | func (c *tabletStatsCache) typesInTopology(keyspace, cell string) []topodatapb.TabletType {
keyspaces := c.keyspacesLocked(keyspace)
types := make(map[topodatapb.TabletType]bool)
// Going through the shards in every cell in every keyspace to get existing tablet types
for _, ks := range keyspaces {
cellsPerKeyspac... | go | func (c *tabletStatsCache) typesInTopology(keyspace, cell string) []topodatapb.TabletType {
keyspaces := c.keyspacesLocked(keyspace)
types := make(map[topodatapb.TabletType]bool)
// Going through the shards in every cell in every keyspace to get existing tablet types
for _, ks := range keyspaces {
cellsPerKeyspac... | [
"func",
"(",
"c",
"*",
"tabletStatsCache",
")",
"typesInTopology",
"(",
"keyspace",
",",
"cell",
"string",
")",
"[",
"]",
"topodatapb",
".",
"TabletType",
"{",
"keyspaces",
":=",
"c",
".",
"keyspacesLocked",
"(",
"keyspace",
")",
"\n",
"types",
":=",
"make... | // typesInTopology returns all the types in the given keyspace and cell.
// If all keyspaces and cells is chosen, it returns the types from every cell in every keyspace.
// This method is used by topologyInfo to send all available options for the tablet type dropdown | [
"typesInTopology",
"returns",
"all",
"the",
"types",
"in",
"the",
"given",
"keyspace",
"and",
"cell",
".",
"If",
"all",
"keyspaces",
"and",
"cells",
"is",
"chosen",
"it",
"returns",
"the",
"types",
"from",
"every",
"cell",
"in",
"every",
"keyspace",
".",
"... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtctld/tablet_stats_cache.go#L267-L288 | train |
vitessio/vitess | go/vt/logutil/logger.go | EventToBuffer | func EventToBuffer(event *logutilpb.Event, buf *bytes.Buffer) {
// Avoid Fprintf, for speed. The format is so simple that we
// can do it quickly by hand. It's worth about 3X. Fprintf is hard.
// Lmmdd hh:mm:ss.uuuuuu file:line]
switch event.Level {
case logutilpb.Level_INFO:
buf.WriteByte('I')
case logutilpb... | go | func EventToBuffer(event *logutilpb.Event, buf *bytes.Buffer) {
// Avoid Fprintf, for speed. The format is so simple that we
// can do it quickly by hand. It's worth about 3X. Fprintf is hard.
// Lmmdd hh:mm:ss.uuuuuu file:line]
switch event.Level {
case logutilpb.Level_INFO:
buf.WriteByte('I')
case logutilpb... | [
"func",
"EventToBuffer",
"(",
"event",
"*",
"logutilpb",
".",
"Event",
",",
"buf",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"// Avoid Fprintf, for speed. The format is so simple that we",
"// can do it quickly by hand. It's worth about 3X. Fprintf is hard.",
"// Lmmdd hh:mm:ss.uuu... | // EventToBuffer formats an individual Event into a buffer, without the
// final '\n' | [
"EventToBuffer",
"formats",
"an",
"individual",
"Event",
"into",
"a",
"buffer",
"without",
"the",
"final",
"\\",
"n"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L59-L96 | train |
vitessio/vitess | go/vt/logutil/logger.go | EventString | func EventString(event *logutilpb.Event) string {
buf := new(bytes.Buffer)
EventToBuffer(event, buf)
return buf.String()
} | go | func EventString(event *logutilpb.Event) string {
buf := new(bytes.Buffer)
EventToBuffer(event, buf)
return buf.String()
} | [
"func",
"EventString",
"(",
"event",
"*",
"logutilpb",
".",
"Event",
")",
"string",
"{",
"buf",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"EventToBuffer",
"(",
"event",
",",
"buf",
")",
"\n",
"return",
"buf",
".",
"String",
"(",
")",
"\n",... | // EventString returns the line in one string | [
"EventString",
"returns",
"the",
"line",
"in",
"one",
"string"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L99-L103 | train |
vitessio/vitess | go/vt/logutil/logger.go | Warningf | func (cl *CallbackLogger) Warningf(format string, v ...interface{}) {
cl.WarningDepth(1, fmt.Sprintf(format, v...))
} | go | func (cl *CallbackLogger) Warningf(format string, v ...interface{}) {
cl.WarningDepth(1, fmt.Sprintf(format, v...))
} | [
"func",
"(",
"cl",
"*",
"CallbackLogger",
")",
"Warningf",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"cl",
".",
"WarningDepth",
"(",
"1",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"v",
"...",
")",
")",
"\n",
... | // Warningf is part of the Logger interface. | [
"Warningf",
"is",
"part",
"of",
"the",
"Logger",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L178-L180 | train |
vitessio/vitess | go/vt/logutil/logger.go | Errorf | func (cl *CallbackLogger) Errorf(format string, v ...interface{}) {
cl.ErrorDepth(1, fmt.Sprintf(format, v...))
} | go | func (cl *CallbackLogger) Errorf(format string, v ...interface{}) {
cl.ErrorDepth(1, fmt.Sprintf(format, v...))
} | [
"func",
"(",
"cl",
"*",
"CallbackLogger",
")",
"Errorf",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"cl",
".",
"ErrorDepth",
"(",
"1",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"v",
"...",
")",
")",
"\n",
"}"... | // Errorf is part of the Logger interface. | [
"Errorf",
"is",
"part",
"of",
"the",
"Logger",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L183-L185 | train |
vitessio/vitess | go/vt/logutil/logger.go | Printf | func (cl *CallbackLogger) Printf(format string, v ...interface{}) {
file, line := fileAndLine(2)
cl.f(&logutilpb.Event{
Time: TimeToProto(time.Now()),
Level: logutilpb.Level_CONSOLE,
File: file,
Line: line,
Value: fmt.Sprintf(format, v...),
})
} | go | func (cl *CallbackLogger) Printf(format string, v ...interface{}) {
file, line := fileAndLine(2)
cl.f(&logutilpb.Event{
Time: TimeToProto(time.Now()),
Level: logutilpb.Level_CONSOLE,
File: file,
Line: line,
Value: fmt.Sprintf(format, v...),
})
} | [
"func",
"(",
"cl",
"*",
"CallbackLogger",
")",
"Printf",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"file",
",",
"line",
":=",
"fileAndLine",
"(",
"2",
")",
"\n",
"cl",
".",
"f",
"(",
"&",
"logutilpb",
".",
"Event",
... | // Printf is part of the Logger interface. | [
"Printf",
"is",
"part",
"of",
"the",
"Logger",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L198-L207 | train |
vitessio/vitess | go/vt/logutil/logger.go | NewChannelLogger | func NewChannelLogger(size int) *ChannelLogger {
c := make(chan *logutilpb.Event, size)
return &ChannelLogger{
CallbackLogger: CallbackLogger{
f: func(e *logutilpb.Event) {
c <- e
},
},
C: c,
}
} | go | func NewChannelLogger(size int) *ChannelLogger {
c := make(chan *logutilpb.Event, size)
return &ChannelLogger{
CallbackLogger: CallbackLogger{
f: func(e *logutilpb.Event) {
c <- e
},
},
C: c,
}
} | [
"func",
"NewChannelLogger",
"(",
"size",
"int",
")",
"*",
"ChannelLogger",
"{",
"c",
":=",
"make",
"(",
"chan",
"*",
"logutilpb",
".",
"Event",
",",
"size",
")",
"\n",
"return",
"&",
"ChannelLogger",
"{",
"CallbackLogger",
":",
"CallbackLogger",
"{",
"f",
... | // NewChannelLogger returns a CallbackLogger which will write the data
// on a channel | [
"NewChannelLogger",
"returns",
"a",
"CallbackLogger",
"which",
"will",
"write",
"the",
"data",
"on",
"a",
"channel"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L218-L228 | train |
vitessio/vitess | go/vt/logutil/logger.go | NewMemoryLogger | func NewMemoryLogger() *MemoryLogger {
ml := &MemoryLogger{}
ml.CallbackLogger.f = func(e *logutilpb.Event) {
ml.mu.Lock()
defer ml.mu.Unlock()
ml.Events = append(ml.Events, e)
}
return ml
} | go | func NewMemoryLogger() *MemoryLogger {
ml := &MemoryLogger{}
ml.CallbackLogger.f = func(e *logutilpb.Event) {
ml.mu.Lock()
defer ml.mu.Unlock()
ml.Events = append(ml.Events, e)
}
return ml
} | [
"func",
"NewMemoryLogger",
"(",
")",
"*",
"MemoryLogger",
"{",
"ml",
":=",
"&",
"MemoryLogger",
"{",
"}",
"\n",
"ml",
".",
"CallbackLogger",
".",
"f",
"=",
"func",
"(",
"e",
"*",
"logutilpb",
".",
"Event",
")",
"{",
"ml",
".",
"mu",
".",
"Lock",
"(... | // NewMemoryLogger returns a new MemoryLogger | [
"NewMemoryLogger",
"returns",
"a",
"new",
"MemoryLogger"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L241-L249 | train |
vitessio/vitess | go/vt/logutil/logger.go | String | func (ml *MemoryLogger) String() string {
buf := new(bytes.Buffer)
ml.mu.Lock()
defer ml.mu.Unlock()
for _, event := range ml.Events {
EventToBuffer(event, buf)
buf.WriteByte('\n')
}
return buf.String()
} | go | func (ml *MemoryLogger) String() string {
buf := new(bytes.Buffer)
ml.mu.Lock()
defer ml.mu.Unlock()
for _, event := range ml.Events {
EventToBuffer(event, buf)
buf.WriteByte('\n')
}
return buf.String()
} | [
"func",
"(",
"ml",
"*",
"MemoryLogger",
")",
"String",
"(",
")",
"string",
"{",
"buf",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"ml",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ml",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
... | // String returns all the lines in one String, separated by '\n' | [
"String",
"returns",
"all",
"the",
"lines",
"in",
"one",
"String",
"separated",
"by",
"\\",
"n"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L252-L261 | train |
vitessio/vitess | go/vt/logutil/logger.go | Clear | func (ml *MemoryLogger) Clear() {
ml.mu.Lock()
ml.Events = nil
ml.mu.Unlock()
} | go | func (ml *MemoryLogger) Clear() {
ml.mu.Lock()
ml.Events = nil
ml.mu.Unlock()
} | [
"func",
"(",
"ml",
"*",
"MemoryLogger",
")",
"Clear",
"(",
")",
"{",
"ml",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"ml",
".",
"Events",
"=",
"nil",
"\n",
"ml",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // Clear clears the logs. | [
"Clear",
"clears",
"the",
"logs",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L264-L268 | train |
vitessio/vitess | go/vt/logutil/logger.go | NewTeeLogger | func NewTeeLogger(one, two Logger) *TeeLogger {
return &TeeLogger{
One: one,
Two: two,
}
} | go | func NewTeeLogger(one, two Logger) *TeeLogger {
return &TeeLogger{
One: one,
Two: two,
}
} | [
"func",
"NewTeeLogger",
"(",
"one",
",",
"two",
"Logger",
")",
"*",
"TeeLogger",
"{",
"return",
"&",
"TeeLogger",
"{",
"One",
":",
"one",
",",
"Two",
":",
"two",
",",
"}",
"\n",
"}"
] | // NewTeeLogger returns a logger that sends its logs to both loggers | [
"NewTeeLogger",
"returns",
"a",
"logger",
"that",
"sends",
"its",
"logs",
"to",
"both",
"loggers"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L297-L302 | train |
vitessio/vitess | go/vt/logutil/logger.go | InfoDepth | func (tl *TeeLogger) InfoDepth(depth int, s string) {
tl.One.InfoDepth(1+depth, s)
tl.Two.InfoDepth(1+depth, s)
} | go | func (tl *TeeLogger) InfoDepth(depth int, s string) {
tl.One.InfoDepth(1+depth, s)
tl.Two.InfoDepth(1+depth, s)
} | [
"func",
"(",
"tl",
"*",
"TeeLogger",
")",
"InfoDepth",
"(",
"depth",
"int",
",",
"s",
"string",
")",
"{",
"tl",
".",
"One",
".",
"InfoDepth",
"(",
"1",
"+",
"depth",
",",
"s",
")",
"\n",
"tl",
".",
"Two",
".",
"InfoDepth",
"(",
"1",
"+",
"depth... | // InfoDepth is part of the Logger interface | [
"InfoDepth",
"is",
"part",
"of",
"the",
"Logger",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L305-L308 | train |
vitessio/vitess | go/vt/logutil/logger.go | Warningf | func (tl *TeeLogger) Warningf(format string, v ...interface{}) {
tl.WarningDepth(1, fmt.Sprintf(format, v...))
} | go | func (tl *TeeLogger) Warningf(format string, v ...interface{}) {
tl.WarningDepth(1, fmt.Sprintf(format, v...))
} | [
"func",
"(",
"tl",
"*",
"TeeLogger",
")",
"Warningf",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"tl",
".",
"WarningDepth",
"(",
"1",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"v",
"...",
")",
")",
"\n",
"}"
... | // Warningf is part of the Logger interface | [
"Warningf",
"is",
"part",
"of",
"the",
"Logger",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L328-L330 | train |
vitessio/vitess | go/vt/logutil/logger.go | Errorf | func (tl *TeeLogger) Errorf(format string, v ...interface{}) {
tl.ErrorDepth(1, fmt.Sprintf(format, v...))
} | go | func (tl *TeeLogger) Errorf(format string, v ...interface{}) {
tl.ErrorDepth(1, fmt.Sprintf(format, v...))
} | [
"func",
"(",
"tl",
"*",
"TeeLogger",
")",
"Errorf",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"tl",
".",
"ErrorDepth",
"(",
"1",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"v",
"...",
")",
")",
"\n",
"}"
] | // Errorf is part of the Logger interface | [
"Errorf",
"is",
"part",
"of",
"the",
"Logger",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L333-L335 | train |
vitessio/vitess | go/vt/logutil/logger.go | twoDigits | func twoDigits(buf *bytes.Buffer, value int) {
buf.WriteByte(digits[value/10])
buf.WriteByte(digits[value%10])
} | go | func twoDigits(buf *bytes.Buffer, value int) {
buf.WriteByte(digits[value/10])
buf.WriteByte(digits[value%10])
} | [
"func",
"twoDigits",
"(",
"buf",
"*",
"bytes",
".",
"Buffer",
",",
"value",
"int",
")",
"{",
"buf",
".",
"WriteByte",
"(",
"digits",
"[",
"value",
"/",
"10",
"]",
")",
"\n",
"buf",
".",
"WriteByte",
"(",
"digits",
"[",
"value",
"%",
"10",
"]",
")... | // twoDigits adds a zero-prefixed two-digit integer to buf | [
"twoDigits",
"adds",
"a",
"zero",
"-",
"prefixed",
"two",
"-",
"digit",
"integer",
"to",
"buf"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L357-L360 | train |
vitessio/vitess | go/vt/logutil/logger.go | nDigits | func nDigits(buf *bytes.Buffer, n, d int, pad byte) {
tmp := make([]byte, n)
j := n - 1
for ; j >= 0 && d > 0; j-- {
tmp[j] = digits[d%10]
d /= 10
}
for ; j >= 0; j-- {
tmp[j] = pad
}
buf.Write(tmp)
} | go | func nDigits(buf *bytes.Buffer, n, d int, pad byte) {
tmp := make([]byte, n)
j := n - 1
for ; j >= 0 && d > 0; j-- {
tmp[j] = digits[d%10]
d /= 10
}
for ; j >= 0; j-- {
tmp[j] = pad
}
buf.Write(tmp)
} | [
"func",
"nDigits",
"(",
"buf",
"*",
"bytes",
".",
"Buffer",
",",
"n",
",",
"d",
"int",
",",
"pad",
"byte",
")",
"{",
"tmp",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"n",
")",
"\n",
"j",
":=",
"n",
"-",
"1",
"\n",
"for",
";",
"j",
">=",
"... | // nDigits adds an n-digit integer d to buf
// padding with pad on the left.
// It assumes d >= 0. | [
"nDigits",
"adds",
"an",
"n",
"-",
"digit",
"integer",
"d",
"to",
"buf",
"padding",
"with",
"pad",
"on",
"the",
"left",
".",
"It",
"assumes",
"d",
">",
"=",
"0",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L365-L376 | train |
vitessio/vitess | go/vt/logutil/logger.go | someDigits | func someDigits(buf *bytes.Buffer, d int64) {
// Print into the top, then copy down.
tmp := make([]byte, 10)
j := 10
for {
j--
tmp[j] = digits[d%10]
d /= 10
if d == 0 {
break
}
}
buf.Write(tmp[j:])
} | go | func someDigits(buf *bytes.Buffer, d int64) {
// Print into the top, then copy down.
tmp := make([]byte, 10)
j := 10
for {
j--
tmp[j] = digits[d%10]
d /= 10
if d == 0 {
break
}
}
buf.Write(tmp[j:])
} | [
"func",
"someDigits",
"(",
"buf",
"*",
"bytes",
".",
"Buffer",
",",
"d",
"int64",
")",
"{",
"// Print into the top, then copy down.",
"tmp",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"10",
")",
"\n",
"j",
":=",
"10",
"\n",
"for",
"{",
"j",
"--",
"\n"... | // someDigits adds a zero-prefixed variable-width integer to buf | [
"someDigits",
"adds",
"a",
"zero",
"-",
"prefixed",
"variable",
"-",
"width",
"integer",
"to",
"buf"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L379-L392 | train |
vitessio/vitess | go/vt/logutil/logger.go | fileAndLine | func fileAndLine(depth int) (string, int64) {
_, file, line, ok := runtime.Caller(depth)
if !ok {
return "???", 1
}
slash := strings.LastIndex(file, "/")
if slash >= 0 {
file = file[slash+1:]
}
return file, int64(line)
} | go | func fileAndLine(depth int) (string, int64) {
_, file, line, ok := runtime.Caller(depth)
if !ok {
return "???", 1
}
slash := strings.LastIndex(file, "/")
if slash >= 0 {
file = file[slash+1:]
}
return file, int64(line)
} | [
"func",
"fileAndLine",
"(",
"depth",
"int",
")",
"(",
"string",
",",
"int64",
")",
"{",
"_",
",",
"file",
",",
"line",
",",
"ok",
":=",
"runtime",
".",
"Caller",
"(",
"depth",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
",",
"1",
"\n... | // fileAndLine returns the caller's file and line 2 levels above | [
"fileAndLine",
"returns",
"the",
"caller",
"s",
"file",
"and",
"line",
"2",
"levels",
"above"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/logger.go#L395-L406 | train |
vitessio/vitess | go/vt/discovery/replicationlag.go | IsReplicationLagHigh | func IsReplicationLagHigh(tabletStats *TabletStats) bool {
return float64(tabletStats.Stats.SecondsBehindMaster) > lowReplicationLag.Seconds()
} | go | func IsReplicationLagHigh(tabletStats *TabletStats) bool {
return float64(tabletStats.Stats.SecondsBehindMaster) > lowReplicationLag.Seconds()
} | [
"func",
"IsReplicationLagHigh",
"(",
"tabletStats",
"*",
"TabletStats",
")",
"bool",
"{",
"return",
"float64",
"(",
"tabletStats",
".",
"Stats",
".",
"SecondsBehindMaster",
")",
">",
"lowReplicationLag",
".",
"Seconds",
"(",
")",
"\n",
"}"
] | // IsReplicationLagHigh verifies that the given TabletStats refers to a tablet with high
// replication lag, i.e. higher than the configured discovery_low_replication_lag flag. | [
"IsReplicationLagHigh",
"verifies",
"that",
"the",
"given",
"TabletStats",
"refers",
"to",
"a",
"tablet",
"with",
"high",
"replication",
"lag",
"i",
".",
"e",
".",
"higher",
"than",
"the",
"configured",
"discovery_low_replication_lag",
"flag",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/replicationlag.go#L35-L37 | train |
vitessio/vitess | go/vt/discovery/replicationlag.go | IsReplicationLagVeryHigh | func IsReplicationLagVeryHigh(tabletStats *TabletStats) bool {
return float64(tabletStats.Stats.SecondsBehindMaster) > highReplicationLagMinServing.Seconds()
} | go | func IsReplicationLagVeryHigh(tabletStats *TabletStats) bool {
return float64(tabletStats.Stats.SecondsBehindMaster) > highReplicationLagMinServing.Seconds()
} | [
"func",
"IsReplicationLagVeryHigh",
"(",
"tabletStats",
"*",
"TabletStats",
")",
"bool",
"{",
"return",
"float64",
"(",
"tabletStats",
".",
"Stats",
".",
"SecondsBehindMaster",
")",
">",
"highReplicationLagMinServing",
".",
"Seconds",
"(",
")",
"\n",
"}"
] | // IsReplicationLagVeryHigh verifies that the given TabletStats refers to a tablet with very high
// replication lag, i.e. higher than the configured discovery_high_replication_lag_minimum_serving flag. | [
"IsReplicationLagVeryHigh",
"verifies",
"that",
"the",
"given",
"TabletStats",
"refers",
"to",
"a",
"tablet",
"with",
"very",
"high",
"replication",
"lag",
"i",
".",
"e",
".",
"higher",
"than",
"the",
"configured",
"discovery_high_replication_lag_minimum_serving",
"fl... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/replicationlag.go#L41-L43 | train |
vitessio/vitess | go/vt/discovery/replicationlag.go | mean | func mean(tabletStatsList []*TabletStats, idxExclude int) (uint64, error) {
var sum uint64
var count uint64
for i, ts := range tabletStatsList {
if i == idxExclude {
continue
}
sum = sum + uint64(ts.Stats.SecondsBehindMaster)
count++
}
if count == 0 {
return 0, fmt.Errorf("empty list")
}
return sum ... | go | func mean(tabletStatsList []*TabletStats, idxExclude int) (uint64, error) {
var sum uint64
var count uint64
for i, ts := range tabletStatsList {
if i == idxExclude {
continue
}
sum = sum + uint64(ts.Stats.SecondsBehindMaster)
count++
}
if count == 0 {
return 0, fmt.Errorf("empty list")
}
return sum ... | [
"func",
"mean",
"(",
"tabletStatsList",
"[",
"]",
"*",
"TabletStats",
",",
"idxExclude",
"int",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"var",
"sum",
"uint64",
"\n",
"var",
"count",
"uint64",
"\n",
"for",
"i",
",",
"ts",
":=",
"range",
"tabletStats... | // mean calculates the mean value over the given list,
// while excluding the item with the specified index. | [
"mean",
"calculates",
"the",
"mean",
"value",
"over",
"the",
"given",
"list",
"while",
"excluding",
"the",
"item",
"with",
"the",
"specified",
"index",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/replicationlag.go#L163-L177 | train |
vitessio/vitess | go/vt/discovery/replicationlag.go | TrivialStatsUpdate | func TrivialStatsUpdate(o, n *TabletStats) bool {
// Skip replag filter when replag remains in the low rep lag range,
// which should be the case majority of the time.
lowRepLag := lowReplicationLag.Seconds()
oldRepLag := float64(o.Stats.SecondsBehindMaster)
newRepLag := float64(n.Stats.SecondsBehindMaster)
if ol... | go | func TrivialStatsUpdate(o, n *TabletStats) bool {
// Skip replag filter when replag remains in the low rep lag range,
// which should be the case majority of the time.
lowRepLag := lowReplicationLag.Seconds()
oldRepLag := float64(o.Stats.SecondsBehindMaster)
newRepLag := float64(n.Stats.SecondsBehindMaster)
if ol... | [
"func",
"TrivialStatsUpdate",
"(",
"o",
",",
"n",
"*",
"TabletStats",
")",
"bool",
"{",
"// Skip replag filter when replag remains in the low rep lag range,",
"// which should be the case majority of the time.",
"lowRepLag",
":=",
"lowReplicationLag",
".",
"Seconds",
"(",
")",
... | // TrivialStatsUpdate returns true iff the old and new TabletStats
// haven't changed enough to warrant re-calling FilterByReplicationLag. | [
"TrivialStatsUpdate",
"returns",
"true",
"iff",
"the",
"old",
"and",
"new",
"TabletStats",
"haven",
"t",
"changed",
"enough",
"to",
"warrant",
"re",
"-",
"calling",
"FilterByReplicationLag",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/discovery/replicationlag.go#L181-L202 | train |
vitessio/vitess | go/vt/logutil/throttled.go | NewThrottledLogger | func NewThrottledLogger(name string, maxInterval time.Duration) *ThrottledLogger {
return &ThrottledLogger{
name: name,
maxInterval: maxInterval,
}
} | go | func NewThrottledLogger(name string, maxInterval time.Duration) *ThrottledLogger {
return &ThrottledLogger{
name: name,
maxInterval: maxInterval,
}
} | [
"func",
"NewThrottledLogger",
"(",
"name",
"string",
",",
"maxInterval",
"time",
".",
"Duration",
")",
"*",
"ThrottledLogger",
"{",
"return",
"&",
"ThrottledLogger",
"{",
"name",
":",
"name",
",",
"maxInterval",
":",
"maxInterval",
",",
"}",
"\n",
"}"
] | // NewThrottledLogger will create a ThrottledLogger with the given
// name and throttling interval. | [
"NewThrottledLogger",
"will",
"create",
"a",
"ThrottledLogger",
"with",
"the",
"given",
"name",
"and",
"throttling",
"interval",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/throttled.go#L42-L47 | train |
vitessio/vitess | go/vt/logutil/throttled.go | Infof | func (tl *ThrottledLogger) Infof(format string, v ...interface{}) {
tl.log(infoDepth, format, v...)
} | go | func (tl *ThrottledLogger) Infof(format string, v ...interface{}) {
tl.log(infoDepth, format, v...)
} | [
"func",
"(",
"tl",
"*",
"ThrottledLogger",
")",
"Infof",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"tl",
".",
"log",
"(",
"infoDepth",
",",
"format",
",",
"v",
"...",
")",
"\n",
"}"
] | // Infof logs an info if not throttled. | [
"Infof",
"logs",
"an",
"info",
"if",
"not",
"throttled",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/throttled.go#L85-L87 | train |
vitessio/vitess | go/vt/logutil/throttled.go | Warningf | func (tl *ThrottledLogger) Warningf(format string, v ...interface{}) {
tl.log(warningDepth, format, v...)
} | go | func (tl *ThrottledLogger) Warningf(format string, v ...interface{}) {
tl.log(warningDepth, format, v...)
} | [
"func",
"(",
"tl",
"*",
"ThrottledLogger",
")",
"Warningf",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"tl",
".",
"log",
"(",
"warningDepth",
",",
"format",
",",
"v",
"...",
")",
"\n",
"}"
] | // Warningf logs a warning if not throttled. | [
"Warningf",
"logs",
"a",
"warning",
"if",
"not",
"throttled",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/throttled.go#L90-L92 | train |
vitessio/vitess | go/vt/logutil/throttled.go | Errorf | func (tl *ThrottledLogger) Errorf(format string, v ...interface{}) {
tl.log(errorDepth, format, v...)
} | go | func (tl *ThrottledLogger) Errorf(format string, v ...interface{}) {
tl.log(errorDepth, format, v...)
} | [
"func",
"(",
"tl",
"*",
"ThrottledLogger",
")",
"Errorf",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"tl",
".",
"log",
"(",
"errorDepth",
",",
"format",
",",
"v",
"...",
")",
"\n",
"}"
] | // Errorf logs an error if not throttled. | [
"Errorf",
"logs",
"an",
"error",
"if",
"not",
"throttled",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/logutil/throttled.go#L95-L97 | train |
vitessio/vitess | go/vt/vtgate/vschema_manager.go | GetCurrentSrvVschema | func (vm *VSchemaManager) GetCurrentSrvVschema() *vschemapb.SrvVSchema {
vm.mu.Lock()
defer vm.mu.Unlock()
return proto.Clone(vm.currentSrvVschema).(*vschemapb.SrvVSchema)
} | go | func (vm *VSchemaManager) GetCurrentSrvVschema() *vschemapb.SrvVSchema {
vm.mu.Lock()
defer vm.mu.Unlock()
return proto.Clone(vm.currentSrvVschema).(*vschemapb.SrvVSchema)
} | [
"func",
"(",
"vm",
"*",
"VSchemaManager",
")",
"GetCurrentSrvVschema",
"(",
")",
"*",
"vschemapb",
".",
"SrvVSchema",
"{",
"vm",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"vm",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"proto",
".",
... | // GetCurrentSrvVschema returns a copy of the latest SrvVschema from the
// topo watch | [
"GetCurrentSrvVschema",
"returns",
"a",
"copy",
"of",
"the",
"latest",
"SrvVschema",
"from",
"the",
"topo",
"watch"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vschema_manager.go#L43-L47 | train |
vitessio/vitess | go/vt/vtgate/vschema_manager.go | watchSrvVSchema | func (vm *VSchemaManager) watchSrvVSchema(ctx context.Context, cell string) {
vm.e.serv.WatchSrvVSchema(ctx, cell, func(v *vschemapb.SrvVSchema, err error) {
// Create a closure to save the vschema. If the value
// passed is nil, it means we encountered an error and
// we don't know the real value. In this case,... | go | func (vm *VSchemaManager) watchSrvVSchema(ctx context.Context, cell string) {
vm.e.serv.WatchSrvVSchema(ctx, cell, func(v *vschemapb.SrvVSchema, err error) {
// Create a closure to save the vschema. If the value
// passed is nil, it means we encountered an error and
// we don't know the real value. In this case,... | [
"func",
"(",
"vm",
"*",
"VSchemaManager",
")",
"watchSrvVSchema",
"(",
"ctx",
"context",
".",
"Context",
",",
"cell",
"string",
")",
"{",
"vm",
".",
"e",
".",
"serv",
".",
"WatchSrvVSchema",
"(",
"ctx",
",",
"cell",
",",
"func",
"(",
"v",
"*",
"vsche... | // watchSrvVSchema watches the SrvVSchema from the topo. The function does
// not return an error. It instead logs warnings on failure.
// The SrvVSchema object is roll-up of all the Keyspace information,
// so when a keyspace is added or removed, it will be properly updated.
//
// This function will wait until the fir... | [
"watchSrvVSchema",
"watches",
"the",
"SrvVSchema",
"from",
"the",
"topo",
".",
"The",
"function",
"does",
"not",
"return",
"an",
"error",
".",
"It",
"instead",
"logs",
"warnings",
"on",
"failure",
".",
"The",
"SrvVSchema",
"object",
"is",
"roll",
"-",
"up",
... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vschema_manager.go#L56-L119 | train |
vitessio/vitess | go/vt/vtgate/vschema_manager.go | UpdateVSchema | func (vm *VSchemaManager) UpdateVSchema(ctx context.Context, ksName string, vschema *vschemapb.SrvVSchema) error {
topoServer, err := vm.e.serv.GetTopoServer()
if err != nil {
return err
}
ks := vschema.Keyspaces[ksName]
err = topoServer.SaveVSchema(ctx, ksName, ks)
if err != nil {
return err
}
cells, err... | go | func (vm *VSchemaManager) UpdateVSchema(ctx context.Context, ksName string, vschema *vschemapb.SrvVSchema) error {
topoServer, err := vm.e.serv.GetTopoServer()
if err != nil {
return err
}
ks := vschema.Keyspaces[ksName]
err = topoServer.SaveVSchema(ctx, ksName, ks)
if err != nil {
return err
}
cells, err... | [
"func",
"(",
"vm",
"*",
"VSchemaManager",
")",
"UpdateVSchema",
"(",
"ctx",
"context",
".",
"Context",
",",
"ksName",
"string",
",",
"vschema",
"*",
"vschemapb",
".",
"SrvVSchema",
")",
"error",
"{",
"topoServer",
",",
"err",
":=",
"vm",
".",
"e",
".",
... | // UpdateVSchema propagates the updated vschema to the topo. The entry for
// the given keyspace is updated in the global topo, and the full SrvVSchema
// is updated in all known cells. | [
"UpdateVSchema",
"propagates",
"the",
"updated",
"vschema",
"to",
"the",
"topo",
".",
"The",
"entry",
"for",
"the",
"given",
"keyspace",
"is",
"updated",
"in",
"the",
"global",
"topo",
"and",
"the",
"full",
"SrvVSchema",
"is",
"updated",
"in",
"all",
"known"... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vschema_manager.go#L124-L151 | train |
vitessio/vitess | go/mysql/flavor.go | MasterPosition | func (c *Conn) MasterPosition() (Position, error) {
gtidSet, err := c.flavor.masterGTIDSet(c)
if err != nil {
return Position{}, err
}
return Position{
GTIDSet: gtidSet,
}, nil
} | go | func (c *Conn) MasterPosition() (Position, error) {
gtidSet, err := c.flavor.masterGTIDSet(c)
if err != nil {
return Position{}, err
}
return Position{
GTIDSet: gtidSet,
}, nil
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"MasterPosition",
"(",
")",
"(",
"Position",
",",
"error",
")",
"{",
"gtidSet",
",",
"err",
":=",
"c",
".",
"flavor",
".",
"masterGTIDSet",
"(",
"c",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"Position"... | // MasterPosition returns the current master replication position. | [
"MasterPosition",
"returns",
"the",
"current",
"master",
"replication",
"position",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/flavor.go#L141-L149 | train |
vitessio/vitess | go/mysql/flavor.go | StartSlaveUntilAfterCommand | func (c *Conn) StartSlaveUntilAfterCommand(pos Position) string {
return c.flavor.startSlaveUntilAfter(pos)
} | go | func (c *Conn) StartSlaveUntilAfterCommand(pos Position) string {
return c.flavor.startSlaveUntilAfter(pos)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"StartSlaveUntilAfterCommand",
"(",
"pos",
"Position",
")",
"string",
"{",
"return",
"c",
".",
"flavor",
".",
"startSlaveUntilAfter",
"(",
"pos",
")",
"\n",
"}"
] | // StartSlaveUntilAfterCommand returns the command to start the slave. | [
"StartSlaveUntilAfterCommand",
"returns",
"the",
"command",
"to",
"start",
"the",
"slave",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/flavor.go#L157-L159 | train |
vitessio/vitess | go/mysql/flavor.go | SendBinlogDumpCommand | func (c *Conn) SendBinlogDumpCommand(slaveID uint32, startPos Position) error {
return c.flavor.sendBinlogDumpCommand(c, slaveID, startPos)
} | go | func (c *Conn) SendBinlogDumpCommand(slaveID uint32, startPos Position) error {
return c.flavor.sendBinlogDumpCommand(c, slaveID, startPos)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"SendBinlogDumpCommand",
"(",
"slaveID",
"uint32",
",",
"startPos",
"Position",
")",
"error",
"{",
"return",
"c",
".",
"flavor",
".",
"sendBinlogDumpCommand",
"(",
"c",
",",
"slaveID",
",",
"startPos",
")",
"\n",
"}"
] | // SendBinlogDumpCommand sends the flavor-specific version of
// the COM_BINLOG_DUMP command to start dumping raw binlog
// events over a slave connection, starting at a given GTID. | [
"SendBinlogDumpCommand",
"sends",
"the",
"flavor",
"-",
"specific",
"version",
"of",
"the",
"COM_BINLOG_DUMP",
"command",
"to",
"start",
"dumping",
"raw",
"binlog",
"events",
"over",
"a",
"slave",
"connection",
"starting",
"at",
"a",
"given",
"GTID",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/flavor.go#L169-L171 | train |
vitessio/vitess | go/mysql/flavor.go | SetSlavePositionCommands | func (c *Conn) SetSlavePositionCommands(pos Position) []string {
return c.flavor.setSlavePositionCommands(pos)
} | go | func (c *Conn) SetSlavePositionCommands(pos Position) []string {
return c.flavor.setSlavePositionCommands(pos)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"SetSlavePositionCommands",
"(",
"pos",
"Position",
")",
"[",
"]",
"string",
"{",
"return",
"c",
".",
"flavor",
".",
"setSlavePositionCommands",
"(",
"pos",
")",
"\n",
"}"
] | // SetSlavePositionCommands returns the commands to set the
// replication position at which the slave will resume
// when it is later reparented with SetMasterCommands. | [
"SetSlavePositionCommands",
"returns",
"the",
"commands",
"to",
"set",
"the",
"replication",
"position",
"at",
"which",
"the",
"slave",
"will",
"resume",
"when",
"it",
"is",
"later",
"reparented",
"with",
"SetMasterCommands",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/flavor.go#L188-L190 | train |
vitessio/vitess | go/mysql/flavor.go | resultToMap | func resultToMap(qr *sqltypes.Result) (map[string]string, error) {
if len(qr.Rows) == 0 {
// The query succeeded, but there is no data.
return nil, nil
}
if len(qr.Rows) > 1 {
return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "query returned %d rows, expected 1", len(qr.Rows))
}
if len(qr.Fields) != len(qr.Ro... | go | func resultToMap(qr *sqltypes.Result) (map[string]string, error) {
if len(qr.Rows) == 0 {
// The query succeeded, but there is no data.
return nil, nil
}
if len(qr.Rows) > 1 {
return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "query returned %d rows, expected 1", len(qr.Rows))
}
if len(qr.Fields) != len(qr.Ro... | [
"func",
"resultToMap",
"(",
"qr",
"*",
"sqltypes",
".",
"Result",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"if",
"len",
"(",
"qr",
".",
"Rows",
")",
"==",
"0",
"{",
"// The query succeeded, but there is no data.",
"return",
... | // resultToMap is a helper function used by ShowSlaveStatus. | [
"resultToMap",
"is",
"a",
"helper",
"function",
"used",
"by",
"ShowSlaveStatus",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/flavor.go#L224-L241 | train |
vitessio/vitess | go/mysql/flavor.go | parseSlaveStatus | func parseSlaveStatus(fields map[string]string) SlaveStatus {
status := SlaveStatus{
MasterHost: fields["Master_Host"],
SlaveIORunning: fields["Slave_IO_Running"] == "Yes",
SlaveSQLRunning: fields["Slave_SQL_Running"] == "Yes",
}
parseInt, _ := strconv.ParseInt(fields["Master_Port"], 10, 0)
status.Maste... | go | func parseSlaveStatus(fields map[string]string) SlaveStatus {
status := SlaveStatus{
MasterHost: fields["Master_Host"],
SlaveIORunning: fields["Slave_IO_Running"] == "Yes",
SlaveSQLRunning: fields["Slave_SQL_Running"] == "Yes",
}
parseInt, _ := strconv.ParseInt(fields["Master_Port"], 10, 0)
status.Maste... | [
"func",
"parseSlaveStatus",
"(",
"fields",
"map",
"[",
"string",
"]",
"string",
")",
"SlaveStatus",
"{",
"status",
":=",
"SlaveStatus",
"{",
"MasterHost",
":",
"fields",
"[",
"\"",
"\"",
"]",
",",
"SlaveIORunning",
":",
"fields",
"[",
"\"",
"\"",
"]",
"=... | // parseSlaveStatus parses the common fields of SHOW SLAVE STATUS. | [
"parseSlaveStatus",
"parses",
"the",
"common",
"fields",
"of",
"SHOW",
"SLAVE",
"STATUS",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/flavor.go#L244-L257 | train |
vitessio/vitess | go/mysql/flavor.go | WaitUntilPositionCommand | func (c *Conn) WaitUntilPositionCommand(ctx context.Context, pos Position) (string, error) {
return c.flavor.waitUntilPositionCommand(ctx, pos)
} | go | func (c *Conn) WaitUntilPositionCommand(ctx context.Context, pos Position) (string, error) {
return c.flavor.waitUntilPositionCommand(ctx, pos)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"WaitUntilPositionCommand",
"(",
"ctx",
"context",
".",
"Context",
",",
"pos",
"Position",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"flavor",
".",
"waitUntilPositionCommand",
"(",
"ctx",
",",
"po... | // WaitUntilPositionCommand returns the SQL command to issue
// to wait until the given position, until the context
// expires. The command returns -1 if it times out. It
// returns NULL if GTIDs are not enabled. | [
"WaitUntilPositionCommand",
"returns",
"the",
"SQL",
"command",
"to",
"issue",
"to",
"wait",
"until",
"the",
"given",
"position",
"until",
"the",
"context",
"expires",
".",
"The",
"command",
"returns",
"-",
"1",
"if",
"it",
"times",
"out",
".",
"It",
"return... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/flavor.go#L269-L271 | train |
vitessio/vitess | go/vt/topotools/events/migrate_syslog.go | Syslog | func (ev *MigrateServedFrom) Syslog() (syslog.Priority, string) {
var format string
if ev.Reverse {
format = "%s [migrate served-from %s/%s <- %s/%s] %s"
} else {
format = "%s [migrate served-from %s/%s -> %s/%s] %s"
}
return syslog.LOG_INFO, fmt.Sprintf(format,
ev.KeyspaceName,
ev.SourceShard.Keyspace(), ... | go | func (ev *MigrateServedFrom) Syslog() (syslog.Priority, string) {
var format string
if ev.Reverse {
format = "%s [migrate served-from %s/%s <- %s/%s] %s"
} else {
format = "%s [migrate served-from %s/%s -> %s/%s] %s"
}
return syslog.LOG_INFO, fmt.Sprintf(format,
ev.KeyspaceName,
ev.SourceShard.Keyspace(), ... | [
"func",
"(",
"ev",
"*",
"MigrateServedFrom",
")",
"Syslog",
"(",
")",
"(",
"syslog",
".",
"Priority",
",",
"string",
")",
"{",
"var",
"format",
"string",
"\n",
"if",
"ev",
".",
"Reverse",
"{",
"format",
"=",
"\"",
"\"",
"\n",
"}",
"else",
"{",
"for... | // Syslog writes a MigrateServedFrom event to syslog. | [
"Syslog",
"writes",
"a",
"MigrateServedFrom",
"event",
"to",
"syslog",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topotools/events/migrate_syslog.go#L28-L40 | train |
vitessio/vitess | go/vt/topotools/events/migrate_syslog.go | Syslog | func (ev *MigrateServedTypes) Syslog() (syslog.Priority, string) {
var format string
if ev.Reverse {
format = "%s [migrate served-types {%v} <- {%v}] %s"
} else {
format = "%s [migrate served-types {%v} -> {%v}] %s"
}
sourceShards := make([]string, len(ev.SourceShards))
for i, shard := range ev.SourceShards ... | go | func (ev *MigrateServedTypes) Syslog() (syslog.Priority, string) {
var format string
if ev.Reverse {
format = "%s [migrate served-types {%v} <- {%v}] %s"
} else {
format = "%s [migrate served-types {%v} -> {%v}] %s"
}
sourceShards := make([]string, len(ev.SourceShards))
for i, shard := range ev.SourceShards ... | [
"func",
"(",
"ev",
"*",
"MigrateServedTypes",
")",
"Syslog",
"(",
")",
"(",
"syslog",
".",
"Priority",
",",
"string",
")",
"{",
"var",
"format",
"string",
"\n",
"if",
"ev",
".",
"Reverse",
"{",
"format",
"=",
"\"",
"\"",
"\n",
"}",
"else",
"{",
"fo... | // Syslog writes a MigrateServedTypes event to syslog. | [
"Syslog",
"writes",
"a",
"MigrateServedTypes",
"event",
"to",
"syslog",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topotools/events/migrate_syslog.go#L45-L71 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.