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/mysql/server.go | NewFromListener | func NewFromListener(l net.Listener, authServer AuthServer, handler Handler, connReadTimeout time.Duration, connWriteTimeout time.Duration) (*Listener, error) {
cfg := ListenerConfig{
Listener: l,
AuthServer: authServer,
Handler: handler,
ConnReadTimeout: connReadTimeout,
Conn... | go | func NewFromListener(l net.Listener, authServer AuthServer, handler Handler, connReadTimeout time.Duration, connWriteTimeout time.Duration) (*Listener, error) {
cfg := ListenerConfig{
Listener: l,
AuthServer: authServer,
Handler: handler,
ConnReadTimeout: connReadTimeout,
Conn... | [
"func",
"NewFromListener",
"(",
"l",
"net",
".",
"Listener",
",",
"authServer",
"AuthServer",
",",
"handler",
"Handler",
",",
"connReadTimeout",
"time",
".",
"Duration",
",",
"connWriteTimeout",
"time",
".",
"Duration",
")",
"(",
"*",
"Listener",
",",
"error",... | // NewFromListener creares a new mysql listener from an existing net.Listener | [
"NewFromListener",
"creares",
"a",
"new",
"mysql",
"listener",
"from",
"an",
"existing",
"net",
".",
"Listener"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/server.go#L160-L170 | train |
vitessio/vitess | go/mysql/server.go | NewListenerWithConfig | func NewListenerWithConfig(cfg ListenerConfig) (*Listener, error) {
var l net.Listener
if cfg.Listener != nil {
l = cfg.Listener
} else {
listener, err := net.Listen(cfg.Protocol, cfg.Address)
if err != nil {
return nil, err
}
l = listener
}
return &Listener{
authServer: cfg.AuthServer,
h... | go | func NewListenerWithConfig(cfg ListenerConfig) (*Listener, error) {
var l net.Listener
if cfg.Listener != nil {
l = cfg.Listener
} else {
listener, err := net.Listen(cfg.Protocol, cfg.Address)
if err != nil {
return nil, err
}
l = listener
}
return &Listener{
authServer: cfg.AuthServer,
h... | [
"func",
"NewListenerWithConfig",
"(",
"cfg",
"ListenerConfig",
")",
"(",
"*",
"Listener",
",",
"error",
")",
"{",
"var",
"l",
"net",
".",
"Listener",
"\n",
"if",
"cfg",
".",
"Listener",
"!=",
"nil",
"{",
"l",
"=",
"cfg",
".",
"Listener",
"\n",
"}",
"... | // NewListenerWithConfig creates new listener using provided config. There are
// no default values for config, so caller should ensure its correctness. | [
"NewListenerWithConfig",
"creates",
"new",
"listener",
"using",
"provided",
"config",
".",
"There",
"are",
"no",
"default",
"values",
"for",
"config",
"so",
"caller",
"should",
"ensure",
"its",
"correctness",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/server.go#L197-L219 | train |
vitessio/vitess | go/mysql/server.go | Accept | func (l *Listener) Accept() {
for {
conn, err := l.listener.Accept()
if err != nil {
// Close() was probably called.
return
}
acceptTime := time.Now()
connectionID := l.connectionID
l.connectionID++
connCount.Add(1)
connAccept.Add(1)
go l.handle(conn, connectionID, acceptTime)
}
} | go | func (l *Listener) Accept() {
for {
conn, err := l.listener.Accept()
if err != nil {
// Close() was probably called.
return
}
acceptTime := time.Now()
connectionID := l.connectionID
l.connectionID++
connCount.Add(1)
connAccept.Add(1)
go l.handle(conn, connectionID, acceptTime)
}
} | [
"func",
"(",
"l",
"*",
"Listener",
")",
"Accept",
"(",
")",
"{",
"for",
"{",
"conn",
",",
"err",
":=",
"l",
".",
"listener",
".",
"Accept",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Close() was probably called.",
"return",
"\n",
"}",
"\n\n",... | // Accept runs an accept loop until the listener is closed. | [
"Accept",
"runs",
"an",
"accept",
"loop",
"until",
"the",
"listener",
"is",
"closed",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/server.go#L227-L245 | train |
vitessio/vitess | go/mysql/server.go | Shutdown | func (l *Listener) Shutdown() {
if l.shutdown.CompareAndSwap(false, true) {
l.Close()
}
} | go | func (l *Listener) Shutdown() {
if l.shutdown.CompareAndSwap(false, true) {
l.Close()
}
} | [
"func",
"(",
"l",
"*",
"Listener",
")",
"Shutdown",
"(",
")",
"{",
"if",
"l",
".",
"shutdown",
".",
"CompareAndSwap",
"(",
"false",
",",
"true",
")",
"{",
"l",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // Shutdown closes listener and fails any Ping requests from existing connections.
// This can be used for graceful shutdown, to let clients know that they should reconnect to another server. | [
"Shutdown",
"closes",
"listener",
"and",
"fails",
"any",
"Ping",
"requests",
"from",
"existing",
"connections",
".",
"This",
"can",
"be",
"used",
"for",
"graceful",
"shutdown",
"to",
"let",
"clients",
"know",
"that",
"they",
"should",
"reconnect",
"to",
"anoth... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/server.go#L455-L459 | train |
vitessio/vitess | go/mysql/server.go | writeHandshakeV10 | func (c *Conn) writeHandshakeV10(serverVersion string, authServer AuthServer, enableTLS bool) ([]byte, error) {
capabilities := CapabilityClientLongPassword |
CapabilityClientLongFlag |
CapabilityClientConnectWithDB |
CapabilityClientProtocol41 |
CapabilityClientTransactions |
CapabilityClientSecureConnectio... | go | func (c *Conn) writeHandshakeV10(serverVersion string, authServer AuthServer, enableTLS bool) ([]byte, error) {
capabilities := CapabilityClientLongPassword |
CapabilityClientLongFlag |
CapabilityClientConnectWithDB |
CapabilityClientProtocol41 |
CapabilityClientTransactions |
CapabilityClientSecureConnectio... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"writeHandshakeV10",
"(",
"serverVersion",
"string",
",",
"authServer",
"AuthServer",
",",
"enableTLS",
"bool",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"capabilities",
":=",
"CapabilityClientLongPassword",
"|",
... | // writeHandshakeV10 writes the Initial Handshake Packet, server side.
// It returns the salt data. | [
"writeHandshakeV10",
"writes",
"the",
"Initial",
"Handshake",
"Packet",
"server",
"side",
".",
"It",
"returns",
"the",
"salt",
"data",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/server.go#L467-L565 | train |
vitessio/vitess | go/mysql/server.go | writeAuthSwitchRequest | func (c *Conn) writeAuthSwitchRequest(pluginName string, pluginData []byte) error {
length := 1 + // AuthSwitchRequestPacket
len(pluginName) + 1 + // 0-terminated pluginName
len(pluginData)
data := c.startEphemeralPacket(length)
pos := 0
// Packet header.
pos = writeByte(data, pos, AuthSwitchRequestPacket)
... | go | func (c *Conn) writeAuthSwitchRequest(pluginName string, pluginData []byte) error {
length := 1 + // AuthSwitchRequestPacket
len(pluginName) + 1 + // 0-terminated pluginName
len(pluginData)
data := c.startEphemeralPacket(length)
pos := 0
// Packet header.
pos = writeByte(data, pos, AuthSwitchRequestPacket)
... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"writeAuthSwitchRequest",
"(",
"pluginName",
"string",
",",
"pluginData",
"[",
"]",
"byte",
")",
"error",
"{",
"length",
":=",
"1",
"+",
"// AuthSwitchRequestPacket",
"len",
"(",
"pluginName",
")",
"+",
"1",
"+",
"// 0-t... | // writeAuthSwitchRequest writes an auth switch request packet. | [
"writeAuthSwitchRequest",
"writes",
"an",
"auth",
"switch",
"request",
"packet",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/server.go#L743-L765 | train |
vitessio/vitess | go/mysql/server.go | tlsVersionToString | func tlsVersionToString(version uint16) string {
switch version {
case tls.VersionSSL30:
return versionSSL30
case tls.VersionTLS10:
return versionTLS10
case tls.VersionTLS11:
return versionTLS11
case tls.VersionTLS12:
return versionTLS12
default:
return versionTLSUnknown
}
} | go | func tlsVersionToString(version uint16) string {
switch version {
case tls.VersionSSL30:
return versionSSL30
case tls.VersionTLS10:
return versionTLS10
case tls.VersionTLS11:
return versionTLS11
case tls.VersionTLS12:
return versionTLS12
default:
return versionTLSUnknown
}
} | [
"func",
"tlsVersionToString",
"(",
"version",
"uint16",
")",
"string",
"{",
"switch",
"version",
"{",
"case",
"tls",
".",
"VersionSSL30",
":",
"return",
"versionSSL30",
"\n",
"case",
"tls",
".",
"VersionTLS10",
":",
"return",
"versionTLS10",
"\n",
"case",
"tls... | // Whenever we move to a new version of go, we will need add any new supported TLS versions here | [
"Whenever",
"we",
"move",
"to",
"a",
"new",
"version",
"of",
"go",
"we",
"will",
"need",
"add",
"any",
"new",
"supported",
"TLS",
"versions",
"here"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/server.go#L768-L781 | train |
vitessio/vitess | go/vt/vtgate/vindexes/numeric_static_map.go | NewNumericStaticMap | func NewNumericStaticMap(name string, params map[string]string) (Vindex, error) {
jsonPath, ok := params["json_path"]
if !ok {
return nil, errors.New("NumericStaticMap: Could not find `json_path` param in vschema")
}
lt, err := loadNumericLookupTable(jsonPath)
if err != nil {
return nil, err
}
return &Nume... | go | func NewNumericStaticMap(name string, params map[string]string) (Vindex, error) {
jsonPath, ok := params["json_path"]
if !ok {
return nil, errors.New("NumericStaticMap: Could not find `json_path` param in vschema")
}
lt, err := loadNumericLookupTable(jsonPath)
if err != nil {
return nil, err
}
return &Nume... | [
"func",
"NewNumericStaticMap",
"(",
"name",
"string",
",",
"params",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"Vindex",
",",
"error",
")",
"{",
"jsonPath",
",",
"ok",
":=",
"params",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
... | // NewNumericStaticMap creates a NumericStaticMap vindex. | [
"NewNumericStaticMap",
"creates",
"a",
"NumericStaticMap",
"vindex",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/numeric_static_map.go#L51-L66 | train |
vitessio/vitess | go/vt/vtgate/vindexes/numeric_static_map.go | Verify | func (vind *NumericStaticMap) Verify(_ VCursor, ids []sqltypes.Value, ksids [][]byte) ([]bool, error) {
out := make([]bool, len(ids))
for i := range ids {
var keybytes [8]byte
num, err := sqltypes.ToUint64(ids[i])
if err != nil {
return nil, vterrors.Wrap(err, "NumericStaticMap.Verify")
}
lookupNum, ok :... | go | func (vind *NumericStaticMap) Verify(_ VCursor, ids []sqltypes.Value, ksids [][]byte) ([]bool, error) {
out := make([]bool, len(ids))
for i := range ids {
var keybytes [8]byte
num, err := sqltypes.ToUint64(ids[i])
if err != nil {
return nil, vterrors.Wrap(err, "NumericStaticMap.Verify")
}
lookupNum, ok :... | [
"func",
"(",
"vind",
"*",
"NumericStaticMap",
")",
"Verify",
"(",
"_",
"VCursor",
",",
"ids",
"[",
"]",
"sqltypes",
".",
"Value",
",",
"ksids",
"[",
"]",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"bool",
",",
"error",
")",
"{",
"out",
":=",
"make",
... | // Verify returns true if ids and ksids match. | [
"Verify",
"returns",
"true",
"if",
"ids",
"and",
"ksids",
"match",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/numeric_static_map.go#L89-L105 | train |
vitessio/vitess | go/mysql/binlog_event.go | String | func (q Query) String() string {
return fmt.Sprintf("{Database: %q, Charset: %v, SQL: %q}",
q.Database, q.Charset, q.SQL)
} | go | func (q Query) String() string {
return fmt.Sprintf("{Database: %q, Charset: %v, SQL: %q}",
q.Database, q.Charset, q.SQL)
} | [
"func",
"(",
"q",
"Query",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"q",
".",
"Database",
",",
"q",
".",
"Charset",
",",
"q",
".",
"SQL",
")",
"\n",
"}"
] | // String pretty-prints a Query. | [
"String",
"pretty",
"-",
"prints",
"a",
"Query",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event.go#L169-L172 | train |
vitessio/vitess | go/mysql/binlog_event.go | NewServerBitmap | func NewServerBitmap(count int) Bitmap {
byteSize := (count + 7) / 8
return Bitmap{
data: make([]byte, byteSize),
count: count,
}
} | go | func NewServerBitmap(count int) Bitmap {
byteSize := (count + 7) / 8
return Bitmap{
data: make([]byte, byteSize),
count: count,
}
} | [
"func",
"NewServerBitmap",
"(",
"count",
"int",
")",
"Bitmap",
"{",
"byteSize",
":=",
"(",
"count",
"+",
"7",
")",
"/",
"8",
"\n",
"return",
"Bitmap",
"{",
"data",
":",
"make",
"(",
"[",
"]",
"byte",
",",
"byteSize",
")",
",",
"count",
":",
"count"... | // NewServerBitmap returns a bitmap that can hold 'count' bits. | [
"NewServerBitmap",
"returns",
"a",
"bitmap",
"that",
"can",
"hold",
"count",
"bits",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event.go#L257-L263 | train |
vitessio/vitess | go/mysql/binlog_event.go | Bit | func (b *Bitmap) Bit(index int) bool {
byteIndex := index / 8
bitMask := byte(1 << (uint(index) & 0x7))
return b.data[byteIndex]&bitMask > 0
} | go | func (b *Bitmap) Bit(index int) bool {
byteIndex := index / 8
bitMask := byte(1 << (uint(index) & 0x7))
return b.data[byteIndex]&bitMask > 0
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"Bit",
"(",
"index",
"int",
")",
"bool",
"{",
"byteIndex",
":=",
"index",
"/",
"8",
"\n",
"bitMask",
":=",
"byte",
"(",
"1",
"<<",
"(",
"uint",
"(",
"index",
")",
"&",
"0x7",
")",
")",
"\n",
"return",
"b",
... | // Bit returned the value of a given bit in the Bitmap. | [
"Bit",
"returned",
"the",
"value",
"of",
"a",
"given",
"bit",
"in",
"the",
"Bitmap",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event.go#L271-L275 | train |
vitessio/vitess | go/mysql/binlog_event.go | Set | func (b *Bitmap) Set(index int, value bool) {
byteIndex := index / 8
bitMask := byte(1 << (uint(index) & 0x7))
if value {
b.data[byteIndex] |= bitMask
} else {
b.data[byteIndex] &= 0xff - bitMask
}
} | go | func (b *Bitmap) Set(index int, value bool) {
byteIndex := index / 8
bitMask := byte(1 << (uint(index) & 0x7))
if value {
b.data[byteIndex] |= bitMask
} else {
b.data[byteIndex] &= 0xff - bitMask
}
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"Set",
"(",
"index",
"int",
",",
"value",
"bool",
")",
"{",
"byteIndex",
":=",
"index",
"/",
"8",
"\n",
"bitMask",
":=",
"byte",
"(",
"1",
"<<",
"(",
"uint",
"(",
"index",
")",
"&",
"0x7",
")",
")",
"\n",
... | // Set sets the given boolean value. | [
"Set",
"sets",
"the",
"given",
"boolean",
"value",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event.go#L278-L286 | train |
vitessio/vitess | go/mysql/binlog_event.go | BitCount | func (b *Bitmap) BitCount() int {
sum := 0
for i := 0; i < b.count; i++ {
if b.Bit(i) {
sum++
}
}
return sum
} | go | func (b *Bitmap) BitCount() int {
sum := 0
for i := 0; i < b.count; i++ {
if b.Bit(i) {
sum++
}
}
return sum
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"BitCount",
"(",
")",
"int",
"{",
"sum",
":=",
"0",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"b",
".",
"count",
";",
"i",
"++",
"{",
"if",
"b",
".",
"Bit",
"(",
"i",
")",
"{",
"sum",
"++",
"\n",
... | // BitCount returns how many bits are set in the bitmap.
// Note values that are not used may be set to 0 or 1,
// hence the non-efficient logic. | [
"BitCount",
"returns",
"how",
"many",
"bits",
"are",
"set",
"in",
"the",
"bitmap",
".",
"Note",
"values",
"that",
"are",
"not",
"used",
"may",
"be",
"set",
"to",
"0",
"or",
"1",
"hence",
"the",
"non",
"-",
"efficient",
"logic",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event.go#L291-L299 | train |
vitessio/vitess | go/vt/binlog/event_streamer.go | NewEventStreamer | func NewEventStreamer(cp *mysql.ConnParams, se *schema.Engine, startPos mysql.Position, timestamp int64, sendEvent sendEventFunc) *EventStreamer {
evs := &EventStreamer{
sendEvent: sendEvent,
}
evs.bls = NewStreamer(cp, se, nil, startPos, timestamp, evs.transactionToEvent)
evs.bls.extractPK = true
return evs
} | go | func NewEventStreamer(cp *mysql.ConnParams, se *schema.Engine, startPos mysql.Position, timestamp int64, sendEvent sendEventFunc) *EventStreamer {
evs := &EventStreamer{
sendEvent: sendEvent,
}
evs.bls = NewStreamer(cp, se, nil, startPos, timestamp, evs.transactionToEvent)
evs.bls.extractPK = true
return evs
} | [
"func",
"NewEventStreamer",
"(",
"cp",
"*",
"mysql",
".",
"ConnParams",
",",
"se",
"*",
"schema",
".",
"Engine",
",",
"startPos",
"mysql",
".",
"Position",
",",
"timestamp",
"int64",
",",
"sendEvent",
"sendEventFunc",
")",
"*",
"EventStreamer",
"{",
"evs",
... | // NewEventStreamer returns a new EventStreamer on top of a Streamer | [
"NewEventStreamer",
"returns",
"a",
"new",
"EventStreamer",
"on",
"top",
"of",
"a",
"Streamer"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/event_streamer.go#L54-L61 | train |
vitessio/vitess | go/vt/binlog/event_streamer.go | Stream | func (evs *EventStreamer) Stream(ctx context.Context) error {
return evs.bls.Stream(ctx)
} | go | func (evs *EventStreamer) Stream(ctx context.Context) error {
return evs.bls.Stream(ctx)
} | [
"func",
"(",
"evs",
"*",
"EventStreamer",
")",
"Stream",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"return",
"evs",
".",
"bls",
".",
"Stream",
"(",
"ctx",
")",
"\n",
"}"
] | // Stream starts streaming updates | [
"Stream",
"starts",
"streaming",
"updates"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/event_streamer.go#L64-L66 | train |
vitessio/vitess | go/vt/topo/consultopo/error.go | convertError | func convertError(err error, nodePath string) error {
switch err {
case context.Canceled:
return topo.NewError(topo.Interrupted, nodePath)
case context.DeadlineExceeded:
return topo.NewError(topo.Timeout, nodePath)
}
return err
} | go | func convertError(err error, nodePath string) error {
switch err {
case context.Canceled:
return topo.NewError(topo.Interrupted, nodePath)
case context.DeadlineExceeded:
return topo.NewError(topo.Timeout, nodePath)
}
return err
} | [
"func",
"convertError",
"(",
"err",
"error",
",",
"nodePath",
"string",
")",
"error",
"{",
"switch",
"err",
"{",
"case",
"context",
".",
"Canceled",
":",
"return",
"topo",
".",
"NewError",
"(",
"topo",
".",
"Interrupted",
",",
"nodePath",
")",
"\n",
"cas... | // convertError converts a context error into a topo error. All errors
// are either application-level errors, or context errors. | [
"convertError",
"converts",
"a",
"context",
"error",
"into",
"a",
"topo",
"error",
".",
"All",
"errors",
"are",
"either",
"application",
"-",
"level",
"errors",
"or",
"context",
"errors",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/consultopo/error.go#L40-L48 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/messager/cache.go | newCache | func newCache(size int) *cache {
mc := &cache{
size: size,
inQueue: make(map[string]*MessageRow),
inFlight: make(map[string]bool),
}
return mc
} | go | func newCache(size int) *cache {
mc := &cache{
size: size,
inQueue: make(map[string]*MessageRow),
inFlight: make(map[string]bool),
}
return mc
} | [
"func",
"newCache",
"(",
"size",
"int",
")",
"*",
"cache",
"{",
"mc",
":=",
"&",
"cache",
"{",
"size",
":",
"size",
",",
"inQueue",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"MessageRow",
")",
",",
"inFlight",
":",
"make",
"(",
"map",
"["... | // NewMessagerCache creates a new cache. | [
"NewMessagerCache",
"creates",
"a",
"new",
"cache",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/messager/cache.go#L96-L103 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/messager/cache.go | Add | func (mc *cache) Add(mr *MessageRow) bool {
mc.mu.Lock()
defer mc.mu.Unlock()
if len(mc.sendQueue) >= mc.size {
return false
}
id := mr.Row[0].ToString()
if mc.inFlight[id] {
return true
}
if _, ok := mc.inQueue[id]; ok {
return true
}
heap.Push(&mc.sendQueue, mr)
mc.inQueue[id] = mr
return true
} | go | func (mc *cache) Add(mr *MessageRow) bool {
mc.mu.Lock()
defer mc.mu.Unlock()
if len(mc.sendQueue) >= mc.size {
return false
}
id := mr.Row[0].ToString()
if mc.inFlight[id] {
return true
}
if _, ok := mc.inQueue[id]; ok {
return true
}
heap.Push(&mc.sendQueue, mr)
mc.inQueue[id] = mr
return true
} | [
"func",
"(",
"mc",
"*",
"cache",
")",
"Add",
"(",
"mr",
"*",
"MessageRow",
")",
"bool",
"{",
"mc",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mc",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"len",
"(",
"mc",
".",
"sendQueue",
")",... | // Add adds a MessageRow to the cache. It returns
// false if the cache is full. | [
"Add",
"adds",
"a",
"MessageRow",
"to",
"the",
"cache",
".",
"It",
"returns",
"false",
"if",
"the",
"cache",
"is",
"full",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/messager/cache.go#L116-L132 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/messager/cache.go | Pop | func (mc *cache) Pop() *MessageRow {
mc.mu.Lock()
defer mc.mu.Unlock()
for {
if len(mc.sendQueue) == 0 {
return nil
}
mr := heap.Pop(&mc.sendQueue).(*MessageRow)
// If message was previously marked as defunct, drop
// it and continue.
if mr.defunct {
continue
}
id := mr.Row[0].ToString()
// ... | go | func (mc *cache) Pop() *MessageRow {
mc.mu.Lock()
defer mc.mu.Unlock()
for {
if len(mc.sendQueue) == 0 {
return nil
}
mr := heap.Pop(&mc.sendQueue).(*MessageRow)
// If message was previously marked as defunct, drop
// it and continue.
if mr.defunct {
continue
}
id := mr.Row[0].ToString()
// ... | [
"func",
"(",
"mc",
"*",
"cache",
")",
"Pop",
"(",
")",
"*",
"MessageRow",
"{",
"mc",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mc",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"for",
"{",
"if",
"len",
"(",
"mc",
".",
"sendQueue",
")",
... | // Pop removes the next MessageRow. Once the
// message has been sent, Discard must be called.
// The discard has to happen as a separate operation
// to prevent the poller thread from repopulating the
// message while it's being sent.
// If the Cache is empty Pop returns nil. | [
"Pop",
"removes",
"the",
"next",
"MessageRow",
".",
"Once",
"the",
"message",
"has",
"been",
"sent",
"Discard",
"must",
"be",
"called",
".",
"The",
"discard",
"has",
"to",
"happen",
"as",
"a",
"separate",
"operation",
"to",
"prevent",
"the",
"poller",
"thr... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/messager/cache.go#L140-L160 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/messager/cache.go | Discard | func (mc *cache) Discard(ids []string) {
mc.mu.Lock()
defer mc.mu.Unlock()
for _, id := range ids {
if mr := mc.inQueue[id]; mr != nil {
// The row is still in the queue somewhere. Mark
// it as defunct. It will be "garbage collected" later.
mr.defunct = true
}
delete(mc.inQueue, id)
delete(mc.inFli... | go | func (mc *cache) Discard(ids []string) {
mc.mu.Lock()
defer mc.mu.Unlock()
for _, id := range ids {
if mr := mc.inQueue[id]; mr != nil {
// The row is still in the queue somewhere. Mark
// it as defunct. It will be "garbage collected" later.
mr.defunct = true
}
delete(mc.inQueue, id)
delete(mc.inFli... | [
"func",
"(",
"mc",
"*",
"cache",
")",
"Discard",
"(",
"ids",
"[",
"]",
"string",
")",
"{",
"mc",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mc",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"for",
"_",
",",
"id",
":=",
"range",
"ids",
"... | // Discard forgets the specified id. | [
"Discard",
"forgets",
"the",
"specified",
"id",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/messager/cache.go#L163-L175 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/messager/cache.go | Size | func (mc *cache) Size() int {
mc.mu.Lock()
defer mc.mu.Unlock()
return mc.size
} | go | func (mc *cache) Size() int {
mc.mu.Lock()
defer mc.mu.Unlock()
return mc.size
} | [
"func",
"(",
"mc",
"*",
"cache",
")",
"Size",
"(",
")",
"int",
"{",
"mc",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mc",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"mc",
".",
"size",
"\n",
"}"
] | // Size returns the max size of cache. | [
"Size",
"returns",
"the",
"max",
"size",
"of",
"cache",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/messager/cache.go#L178-L182 | train |
vitessio/vitess | go/vt/dtids/dtids.go | New | func New(mmShard *vtgatepb.Session_ShardSession) string {
return fmt.Sprintf("%s:%s:%d", mmShard.Target.Keyspace, mmShard.Target.Shard, mmShard.TransactionId)
} | go | func New(mmShard *vtgatepb.Session_ShardSession) string {
return fmt.Sprintf("%s:%s:%d", mmShard.Target.Keyspace, mmShard.Target.Shard, mmShard.TransactionId)
} | [
"func",
"New",
"(",
"mmShard",
"*",
"vtgatepb",
".",
"Session_ShardSession",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"mmShard",
".",
"Target",
".",
"Keyspace",
",",
"mmShard",
".",
"Target",
".",
"Shard",
",",
"mmShard"... | // New generates a dtid based on Session_ShardSession. | [
"New",
"generates",
"a",
"dtid",
"based",
"on",
"Session_ShardSession",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/dtids/dtids.go#L34-L36 | train |
vitessio/vitess | go/vt/dtids/dtids.go | ShardSession | func ShardSession(dtid string) (*vtgatepb.Session_ShardSession, error) {
splits := strings.Split(dtid, ":")
if len(splits) != 3 {
return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "invalid parts in dtid: %s", dtid)
}
target := &querypb.Target{
Keyspace: splits[0],
Shard: splits[1],
TabletTyp... | go | func ShardSession(dtid string) (*vtgatepb.Session_ShardSession, error) {
splits := strings.Split(dtid, ":")
if len(splits) != 3 {
return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "invalid parts in dtid: %s", dtid)
}
target := &querypb.Target{
Keyspace: splits[0],
Shard: splits[1],
TabletTyp... | [
"func",
"ShardSession",
"(",
"dtid",
"string",
")",
"(",
"*",
"vtgatepb",
".",
"Session_ShardSession",
",",
"error",
")",
"{",
"splits",
":=",
"strings",
".",
"Split",
"(",
"dtid",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"splits",
")",
"!=",
"3... | // ShardSession builds a Session_ShardSession from a dtid. | [
"ShardSession",
"builds",
"a",
"Session_ShardSession",
"from",
"a",
"dtid",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/dtids/dtids.go#L39-L57 | train |
vitessio/vitess | go/vt/dtids/dtids.go | TransactionID | func TransactionID(dtid string) (int64, error) {
splits := strings.Split(dtid, ":")
if len(splits) != 3 {
return 0, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "invalid parts in dtid: %s", dtid)
}
txid, err := strconv.ParseInt(splits[2], 10, 0)
if err != nil {
return 0, vterrors.Errorf(vtrpcpb.Code_INVALID_... | go | func TransactionID(dtid string) (int64, error) {
splits := strings.Split(dtid, ":")
if len(splits) != 3 {
return 0, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "invalid parts in dtid: %s", dtid)
}
txid, err := strconv.ParseInt(splits[2], 10, 0)
if err != nil {
return 0, vterrors.Errorf(vtrpcpb.Code_INVALID_... | [
"func",
"TransactionID",
"(",
"dtid",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"splits",
":=",
"strings",
".",
"Split",
"(",
"dtid",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"splits",
")",
"!=",
"3",
"{",
"return",
"0",
",",
"vte... | // TransactionID extracts the original transaction ID from the dtid. | [
"TransactionID",
"extracts",
"the",
"original",
"transaction",
"ID",
"from",
"the",
"dtid",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/dtids/dtids.go#L60-L70 | train |
vitessio/vitess | go/cmd/vtexplain/vtexplain.go | flagUsage | func flagUsage(f *flag.Flag) {
s := fmt.Sprintf(" -%s", f.Name) // Two spaces before -; see next two comments.
name, usage := flag.UnquoteUsage(f)
if len(name) > 0 {
s += " " + name
}
// Boolean flags of one ASCII letter are so common we
// treat them specially, putting their usage on the same line.
if len(s)... | go | func flagUsage(f *flag.Flag) {
s := fmt.Sprintf(" -%s", f.Name) // Two spaces before -; see next two comments.
name, usage := flag.UnquoteUsage(f)
if len(name) > 0 {
s += " " + name
}
// Boolean flags of one ASCII letter are so common we
// treat them specially, putting their usage on the same line.
if len(s)... | [
"func",
"flagUsage",
"(",
"f",
"*",
"flag",
".",
"Flag",
")",
"{",
"s",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"f",
".",
"Name",
")",
"// Two spaces before -; see next two comments.",
"\n",
"name",
",",
"usage",
":=",
"flag",
".",
"UnquoteUsa... | // Cloned from the source to print out the usage for a given flag | [
"Cloned",
"from",
"the",
"source",
"to",
"print",
"out",
"the",
"usage",
"for",
"a",
"given",
"flag"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/cmd/vtexplain/vtexplain.go#L74-L97 | train |
vitessio/vitess | go/cmd/vtexplain/vtexplain.go | getFileParam | func getFileParam(flag, flagFile, name string) (string, error) {
if flag != "" {
if flagFile != "" {
return "", fmt.Errorf("action requires only one of %v or %v-file", name, name)
}
return flag, nil
}
if flagFile == "" {
return "", fmt.Errorf("action requires one of %v or %v-file", name, name)
}
data, ... | go | func getFileParam(flag, flagFile, name string) (string, error) {
if flag != "" {
if flagFile != "" {
return "", fmt.Errorf("action requires only one of %v or %v-file", name, name)
}
return flag, nil
}
if flagFile == "" {
return "", fmt.Errorf("action requires one of %v or %v-file", name, name)
}
data, ... | [
"func",
"getFileParam",
"(",
"flag",
",",
"flagFile",
",",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"flag",
"!=",
"\"",
"\"",
"{",
"if",
"flagFile",
"!=",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
... | // getFileParam returns a string containing either flag is not "",
// or the content of the file named flagFile | [
"getFileParam",
"returns",
"a",
"string",
"containing",
"either",
"flag",
"is",
"not",
"or",
"the",
"content",
"of",
"the",
"file",
"named",
"flagFile"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/cmd/vtexplain/vtexplain.go#L107-L123 | train |
vitessio/vitess | go/vt/mysqlctl/replication.go | WaitForSlaveStart | func WaitForSlaveStart(mysqld MysqlDaemon, slaveStartDeadline int) error {
var rowMap map[string]string
for slaveWait := 0; slaveWait < slaveStartDeadline; slaveWait++ {
status, err := mysqld.SlaveStatus()
if err != nil {
return err
}
if status.SlaveRunning() {
return nil
}
time.Sleep(time.Second)
... | go | func WaitForSlaveStart(mysqld MysqlDaemon, slaveStartDeadline int) error {
var rowMap map[string]string
for slaveWait := 0; slaveWait < slaveStartDeadline; slaveWait++ {
status, err := mysqld.SlaveStatus()
if err != nil {
return err
}
if status.SlaveRunning() {
return nil
}
time.Sleep(time.Second)
... | [
"func",
"WaitForSlaveStart",
"(",
"mysqld",
"MysqlDaemon",
",",
"slaveStartDeadline",
"int",
")",
"error",
"{",
"var",
"rowMap",
"map",
"[",
"string",
"]",
"string",
"\n",
"for",
"slaveWait",
":=",
"0",
";",
"slaveWait",
"<",
"slaveStartDeadline",
";",
"slaveW... | // WaitForSlaveStart waits until the deadline for replication to start.
// This validates the current master is correct and can be connected to. | [
"WaitForSlaveStart",
"waits",
"until",
"the",
"deadline",
"for",
"replication",
"to",
"start",
".",
"This",
"validates",
"the",
"current",
"master",
"is",
"correct",
"and",
"can",
"be",
"connected",
"to",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/replication.go#L42-L67 | train |
vitessio/vitess | go/vt/mysqlctl/replication.go | StartSlave | func (mysqld *Mysqld) StartSlave(hookExtraEnv map[string]string) error {
ctx := context.TODO()
conn, err := getPoolReconnect(ctx, mysqld.dbaPool)
if err != nil {
return err
}
defer conn.Recycle()
if err := mysqld.executeSuperQueryListConn(ctx, conn, []string{conn.StartSlaveCommand()}); err != nil {
return er... | go | func (mysqld *Mysqld) StartSlave(hookExtraEnv map[string]string) error {
ctx := context.TODO()
conn, err := getPoolReconnect(ctx, mysqld.dbaPool)
if err != nil {
return err
}
defer conn.Recycle()
if err := mysqld.executeSuperQueryListConn(ctx, conn, []string{conn.StartSlaveCommand()}); err != nil {
return er... | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"StartSlave",
"(",
"hookExtraEnv",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"ctx",
":=",
"context",
".",
"TODO",
"(",
")",
"\n",
"conn",
",",
"err",
":=",
"getPoolReconnect",
"(",
"ctx",
",",
... | // StartSlave starts a slave. | [
"StartSlave",
"starts",
"a",
"slave",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/replication.go#L70-L85 | train |
vitessio/vitess | go/vt/mysqlctl/replication.go | StartSlaveUntilAfter | func (mysqld *Mysqld) StartSlaveUntilAfter(ctx context.Context, targetPos mysql.Position) error {
conn, err := getPoolReconnect(ctx, mysqld.dbaPool)
if err != nil {
return err
}
defer conn.Recycle()
queries := []string{conn.StartSlaveUntilAfterCommand(targetPos)}
return mysqld.executeSuperQueryListConn(ctx, c... | go | func (mysqld *Mysqld) StartSlaveUntilAfter(ctx context.Context, targetPos mysql.Position) error {
conn, err := getPoolReconnect(ctx, mysqld.dbaPool)
if err != nil {
return err
}
defer conn.Recycle()
queries := []string{conn.StartSlaveUntilAfterCommand(targetPos)}
return mysqld.executeSuperQueryListConn(ctx, c... | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"StartSlaveUntilAfter",
"(",
"ctx",
"context",
".",
"Context",
",",
"targetPos",
"mysql",
".",
"Position",
")",
"error",
"{",
"conn",
",",
"err",
":=",
"getPoolReconnect",
"(",
"ctx",
",",
"mysqld",
".",
"dbaPool"... | // StartSlaveUntilAfter starts a slave until replication has come to `targetPos`, then it stops replication | [
"StartSlaveUntilAfter",
"starts",
"a",
"slave",
"until",
"replication",
"has",
"come",
"to",
"targetPos",
"then",
"it",
"stops",
"replication"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/replication.go#L88-L98 | train |
vitessio/vitess | go/vt/mysqlctl/replication.go | GetMysqlPort | func (mysqld *Mysqld) GetMysqlPort() (int32, error) {
qr, err := mysqld.FetchSuperQuery(context.TODO(), "SHOW VARIABLES LIKE 'port'")
if err != nil {
return 0, err
}
if len(qr.Rows) != 1 {
return 0, errors.New("no port variable in mysql")
}
utemp, err := sqltypes.ToUint64(qr.Rows[0][1])
if err != nil {
ret... | go | func (mysqld *Mysqld) GetMysqlPort() (int32, error) {
qr, err := mysqld.FetchSuperQuery(context.TODO(), "SHOW VARIABLES LIKE 'port'")
if err != nil {
return 0, err
}
if len(qr.Rows) != 1 {
return 0, errors.New("no port variable in mysql")
}
utemp, err := sqltypes.ToUint64(qr.Rows[0][1])
if err != nil {
ret... | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"GetMysqlPort",
"(",
")",
"(",
"int32",
",",
"error",
")",
"{",
"qr",
",",
"err",
":=",
"mysqld",
".",
"FetchSuperQuery",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"... | // GetMysqlPort returns mysql port | [
"GetMysqlPort",
"returns",
"mysql",
"port"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/replication.go#L118-L131 | train |
vitessio/vitess | go/vt/mysqlctl/replication.go | IsReadOnly | func (mysqld *Mysqld) IsReadOnly() (bool, error) {
qr, err := mysqld.FetchSuperQuery(context.TODO(), "SHOW VARIABLES LIKE 'read_only'")
if err != nil {
return true, err
}
if len(qr.Rows) != 1 {
return true, errors.New("no read_only variable in mysql")
}
if qr.Rows[0][1].ToString() == "ON" {
return true, nil... | go | func (mysqld *Mysqld) IsReadOnly() (bool, error) {
qr, err := mysqld.FetchSuperQuery(context.TODO(), "SHOW VARIABLES LIKE 'read_only'")
if err != nil {
return true, err
}
if len(qr.Rows) != 1 {
return true, errors.New("no read_only variable in mysql")
}
if qr.Rows[0][1].ToString() == "ON" {
return true, nil... | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"IsReadOnly",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"qr",
",",
"err",
":=",
"mysqld",
".",
"FetchSuperQuery",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!="... | // IsReadOnly return true if the instance is read only | [
"IsReadOnly",
"return",
"true",
"if",
"the",
"instance",
"is",
"read",
"only"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/replication.go#L134-L146 | train |
vitessio/vitess | go/vt/mysqlctl/replication.go | WaitMasterPos | func (mysqld *Mysqld) WaitMasterPos(ctx context.Context, targetPos mysql.Position) error {
// Get a connection.
conn, err := getPoolReconnect(ctx, mysqld.dbaPool)
if err != nil {
return err
}
defer conn.Recycle()
// Find the query to run, run it.
query, err := conn.WaitUntilPositionCommand(ctx, targetPos)
if... | go | func (mysqld *Mysqld) WaitMasterPos(ctx context.Context, targetPos mysql.Position) error {
// Get a connection.
conn, err := getPoolReconnect(ctx, mysqld.dbaPool)
if err != nil {
return err
}
defer conn.Recycle()
// Find the query to run, run it.
query, err := conn.WaitUntilPositionCommand(ctx, targetPos)
if... | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"WaitMasterPos",
"(",
"ctx",
"context",
".",
"Context",
",",
"targetPos",
"mysql",
".",
"Position",
")",
"error",
"{",
"// Get a connection.",
"conn",
",",
"err",
":=",
"getPoolReconnect",
"(",
"ctx",
",",
"mysqld",... | // WaitMasterPos lets slaves wait to given replication position | [
"WaitMasterPos",
"lets",
"slaves",
"wait",
"to",
"given",
"replication",
"position"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/replication.go#L176-L204 | train |
vitessio/vitess | go/vt/mysqlctl/replication.go | SlaveStatus | func (mysqld *Mysqld) SlaveStatus() (mysql.SlaveStatus, error) {
conn, err := getPoolReconnect(context.TODO(), mysqld.dbaPool)
if err != nil {
return mysql.SlaveStatus{}, err
}
defer conn.Recycle()
return conn.ShowSlaveStatus()
} | go | func (mysqld *Mysqld) SlaveStatus() (mysql.SlaveStatus, error) {
conn, err := getPoolReconnect(context.TODO(), mysqld.dbaPool)
if err != nil {
return mysql.SlaveStatus{}, err
}
defer conn.Recycle()
return conn.ShowSlaveStatus()
} | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"SlaveStatus",
"(",
")",
"(",
"mysql",
".",
"SlaveStatus",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"getPoolReconnect",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"mysqld",
".",
"dbaPool",
")",
"\n... | // SlaveStatus returns the slave replication statuses | [
"SlaveStatus",
"returns",
"the",
"slave",
"replication",
"statuses"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/replication.go#L207-L215 | train |
vitessio/vitess | go/vt/mysqlctl/replication.go | MasterPosition | func (mysqld *Mysqld) MasterPosition() (mysql.Position, error) {
conn, err := getPoolReconnect(context.TODO(), mysqld.dbaPool)
if err != nil {
return mysql.Position{}, err
}
defer conn.Recycle()
return conn.MasterPosition()
} | go | func (mysqld *Mysqld) MasterPosition() (mysql.Position, error) {
conn, err := getPoolReconnect(context.TODO(), mysqld.dbaPool)
if err != nil {
return mysql.Position{}, err
}
defer conn.Recycle()
return conn.MasterPosition()
} | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"MasterPosition",
"(",
")",
"(",
"mysql",
".",
"Position",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"getPoolReconnect",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"mysqld",
".",
"dbaPool",
")",
"\n... | // MasterPosition returns the master replication position. | [
"MasterPosition",
"returns",
"the",
"master",
"replication",
"position",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/replication.go#L218-L226 | train |
vitessio/vitess | go/vt/mysqlctl/replication.go | SetSlavePosition | func (mysqld *Mysqld) SetSlavePosition(ctx context.Context, pos mysql.Position) error {
conn, err := getPoolReconnect(ctx, mysqld.dbaPool)
if err != nil {
return err
}
defer conn.Recycle()
cmds := conn.SetSlavePositionCommands(pos)
log.Infof("Executing commands to set slave position: %v", cmds)
return mysqld.... | go | func (mysqld *Mysqld) SetSlavePosition(ctx context.Context, pos mysql.Position) error {
conn, err := getPoolReconnect(ctx, mysqld.dbaPool)
if err != nil {
return err
}
defer conn.Recycle()
cmds := conn.SetSlavePositionCommands(pos)
log.Infof("Executing commands to set slave position: %v", cmds)
return mysqld.... | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"SetSlavePosition",
"(",
"ctx",
"context",
".",
"Context",
",",
"pos",
"mysql",
".",
"Position",
")",
"error",
"{",
"conn",
",",
"err",
":=",
"getPoolReconnect",
"(",
"ctx",
",",
"mysqld",
".",
"dbaPool",
")",
... | // SetSlavePosition sets the replication position at which the slave will resume
// when its replication is started. | [
"SetSlavePosition",
"sets",
"the",
"replication",
"position",
"at",
"which",
"the",
"slave",
"will",
"resume",
"when",
"its",
"replication",
"is",
"started",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/replication.go#L230-L240 | train |
vitessio/vitess | go/vt/mysqlctl/replication.go | ResetReplication | func (mysqld *Mysqld) ResetReplication(ctx context.Context) error {
conn, connErr := getPoolReconnect(ctx, mysqld.dbaPool)
if connErr != nil {
return connErr
}
defer conn.Recycle()
cmds := conn.ResetReplicationCommands()
return mysqld.executeSuperQueryListConn(ctx, conn, cmds)
} | go | func (mysqld *Mysqld) ResetReplication(ctx context.Context) error {
conn, connErr := getPoolReconnect(ctx, mysqld.dbaPool)
if connErr != nil {
return connErr
}
defer conn.Recycle()
cmds := conn.ResetReplicationCommands()
return mysqld.executeSuperQueryListConn(ctx, conn, cmds)
} | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"ResetReplication",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"conn",
",",
"connErr",
":=",
"getPoolReconnect",
"(",
"ctx",
",",
"mysqld",
".",
"dbaPool",
")",
"\n",
"if",
"connErr",
"!=",
"nil",... | // ResetReplication resets all replication for this host. | [
"ResetReplication",
"resets",
"all",
"replication",
"for",
"this",
"host",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/replication.go#L268-L277 | train |
vitessio/vitess | go/vt/mysqlctl/replication.go | FindSlaves | func FindSlaves(mysqld MysqlDaemon) ([]string, error) {
qr, err := mysqld.FetchSuperQuery(context.TODO(), "SHOW PROCESSLIST")
if err != nil {
return nil, err
}
addrs := make([]string, 0, 32)
for _, row := range qr.Rows {
// Check for prefix, since it could be "Binlog Dump GTID".
if strings.HasPrefix(row[colC... | go | func FindSlaves(mysqld MysqlDaemon) ([]string, error) {
qr, err := mysqld.FetchSuperQuery(context.TODO(), "SHOW PROCESSLIST")
if err != nil {
return nil, err
}
addrs := make([]string, 0, 32)
for _, row := range qr.Rows {
// Check for prefix, since it could be "Binlog Dump GTID".
if strings.HasPrefix(row[colC... | [
"func",
"FindSlaves",
"(",
"mysqld",
"MysqlDaemon",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"qr",
",",
"err",
":=",
"mysqld",
".",
"FetchSuperQuery",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!="... | // FindSlaves gets IP addresses for all currently connected slaves. | [
"FindSlaves",
"gets",
"IP",
"addresses",
"for",
"all",
"currently",
"connected",
"slaves",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/replication.go#L304-L335 | train |
vitessio/vitess | go/vt/mysqlctl/replication.go | EnableBinlogPlayback | func (mysqld *Mysqld) EnableBinlogPlayback() error {
// Get a connection.
conn, err := getPoolReconnect(context.TODO(), mysqld.dbaPool)
if err != nil {
return err
}
defer conn.Recycle()
// See if we have a command to run, and run it.
cmd := conn.EnableBinlogPlaybackCommand()
if cmd == "" {
return nil
}
i... | go | func (mysqld *Mysqld) EnableBinlogPlayback() error {
// Get a connection.
conn, err := getPoolReconnect(context.TODO(), mysqld.dbaPool)
if err != nil {
return err
}
defer conn.Recycle()
// See if we have a command to run, and run it.
cmd := conn.EnableBinlogPlaybackCommand()
if cmd == "" {
return nil
}
i... | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"EnableBinlogPlayback",
"(",
")",
"error",
"{",
"// Get a connection.",
"conn",
",",
"err",
":=",
"getPoolReconnect",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"mysqld",
".",
"dbaPool",
")",
"\n",
"if",
"err",
... | // EnableBinlogPlayback prepares the server to play back events from a binlog stream.
// Whatever it does for a given flavor, it must be idempotent. | [
"EnableBinlogPlayback",
"prepares",
"the",
"server",
"to",
"play",
"back",
"events",
"from",
"a",
"binlog",
"stream",
".",
"Whatever",
"it",
"does",
"for",
"a",
"given",
"flavor",
"it",
"must",
"be",
"idempotent",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/replication.go#L339-L359 | train |
vitessio/vitess | go/vt/mysqlctl/replication.go | SemiSyncEnabled | func (mysqld *Mysqld) SemiSyncEnabled() (master, slave bool) {
vars, err := mysqld.fetchVariables(context.TODO(), "rpl_semi_sync_%_enabled")
if err != nil {
return false, false
}
master = (vars["rpl_semi_sync_master_enabled"] == "ON")
slave = (vars["rpl_semi_sync_slave_enabled"] == "ON")
return master, slave
} | go | func (mysqld *Mysqld) SemiSyncEnabled() (master, slave bool) {
vars, err := mysqld.fetchVariables(context.TODO(), "rpl_semi_sync_%_enabled")
if err != nil {
return false, false
}
master = (vars["rpl_semi_sync_master_enabled"] == "ON")
slave = (vars["rpl_semi_sync_slave_enabled"] == "ON")
return master, slave
} | [
"func",
"(",
"mysqld",
"*",
"Mysqld",
")",
"SemiSyncEnabled",
"(",
")",
"(",
"master",
",",
"slave",
"bool",
")",
"{",
"vars",
",",
"err",
":=",
"mysqld",
".",
"fetchVariables",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"if... | // SemiSyncEnabled returns whether semi-sync is enabled for master or slave.
// If the semi-sync plugin is not loaded, we assume semi-sync is disabled. | [
"SemiSyncEnabled",
"returns",
"whether",
"semi",
"-",
"sync",
"is",
"enabled",
"for",
"master",
"or",
"slave",
".",
"If",
"the",
"semi",
"-",
"sync",
"plugin",
"is",
"not",
"loaded",
"we",
"assume",
"semi",
"-",
"sync",
"is",
"disabled",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/mysqlctl/replication.go#L410-L418 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | RegisterFakeVTGateConnDialer | func RegisterFakeVTGateConnDialer() (*FakeVTGateConn, string) {
protocol := "fake"
impl := &FakeVTGateConn{
execMap: make(map[string]*queryResponse),
splitQueryMap: make(map[string]*splitQueryResponse),
}
vtgateconn.RegisterDialer(protocol, func(ctx context.Context, address string) (vtgateconn.Impl, error... | go | func RegisterFakeVTGateConnDialer() (*FakeVTGateConn, string) {
protocol := "fake"
impl := &FakeVTGateConn{
execMap: make(map[string]*queryResponse),
splitQueryMap: make(map[string]*splitQueryResponse),
}
vtgateconn.RegisterDialer(protocol, func(ctx context.Context, address string) (vtgateconn.Impl, error... | [
"func",
"RegisterFakeVTGateConnDialer",
"(",
")",
"(",
"*",
"FakeVTGateConn",
",",
"string",
")",
"{",
"protocol",
":=",
"\"",
"\"",
"\n",
"impl",
":=",
"&",
"FakeVTGateConn",
"{",
"execMap",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"queryResponse... | // RegisterFakeVTGateConnDialer registers the proper dialer for this fake,
// and returns the underlying instance that will be returned by the dialer,
// and the protocol to use to get this fake. | [
"RegisterFakeVTGateConnDialer",
"registers",
"the",
"proper",
"dialer",
"for",
"this",
"fake",
"and",
"returns",
"the",
"underlying",
"instance",
"that",
"will",
"be",
"returned",
"by",
"the",
"dialer",
"and",
"the",
"protocol",
"to",
"use",
"to",
"get",
"this",... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L91-L101 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | AddQuery | func (conn *FakeVTGateConn) AddQuery(
sql string,
bindVariables map[string]*querypb.BindVariable,
session *vtgatepb.Session,
expectedResult *sqltypes.Result) {
conn.execMap[sql] = &queryResponse{
execQuery: &queryExecute{
SQL: sql,
BindVariables: bindVariables,
Session: session,
},
r... | go | func (conn *FakeVTGateConn) AddQuery(
sql string,
bindVariables map[string]*querypb.BindVariable,
session *vtgatepb.Session,
expectedResult *sqltypes.Result) {
conn.execMap[sql] = &queryResponse{
execQuery: &queryExecute{
SQL: sql,
BindVariables: bindVariables,
Session: session,
},
r... | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"AddQuery",
"(",
"sql",
"string",
",",
"bindVariables",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
",",
"session",
"*",
"vtgatepb",
".",
"Session",
",",
"expectedResult",
"*",
"sqltypes",
... | // AddQuery adds a query and expected result. | [
"AddQuery",
"adds",
"a",
"query",
"and",
"expected",
"result",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L104-L117 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | AddShardQuery | func (conn *FakeVTGateConn) AddShardQuery(
sql string,
bindVariables map[string]*querypb.BindVariable,
keyspace string,
shards []string,
tabletType topodatapb.TabletType,
session *vtgatepb.Session,
notInTransaction bool,
expectedResult *sqltypes.Result) {
conn.execMap[getShardQueryKey(sql, shards)] = &queryRes... | go | func (conn *FakeVTGateConn) AddShardQuery(
sql string,
bindVariables map[string]*querypb.BindVariable,
keyspace string,
shards []string,
tabletType topodatapb.TabletType,
session *vtgatepb.Session,
notInTransaction bool,
expectedResult *sqltypes.Result) {
conn.execMap[getShardQueryKey(sql, shards)] = &queryRes... | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"AddShardQuery",
"(",
"sql",
"string",
",",
"bindVariables",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
",",
"keyspace",
"string",
",",
"shards",
"[",
"]",
"string",
",",
"tabletType",
"... | // AddShardQuery adds a shard query and expected result. | [
"AddShardQuery",
"adds",
"a",
"shard",
"query",
"and",
"expected",
"result",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L120-L141 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | AddSplitQuery | func (conn *FakeVTGateConn) AddSplitQuery(
keyspace string,
sql string,
bindVariables map[string]*querypb.BindVariable,
splitColumns []string,
splitCount int64,
numRowsPerQueryPart int64,
algorithm querypb.SplitQueryRequest_Algorithm,
expectedResult []*vtgatepb.SplitQueryResponse_Part) {
reply := make([]*vtga... | go | func (conn *FakeVTGateConn) AddSplitQuery(
keyspace string,
sql string,
bindVariables map[string]*querypb.BindVariable,
splitColumns []string,
splitCount int64,
numRowsPerQueryPart int64,
algorithm querypb.SplitQueryRequest_Algorithm,
expectedResult []*vtgatepb.SplitQueryResponse_Part) {
reply := make([]*vtga... | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"AddSplitQuery",
"(",
"keyspace",
"string",
",",
"sql",
"string",
",",
"bindVariables",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
",",
"splitColumns",
"[",
"]",
"string",
",",
"splitCount... | // AddSplitQuery adds a split query and expected result. | [
"AddSplitQuery",
"adds",
"a",
"split",
"query",
"and",
"expected",
"result",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L144-L170 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | Execute | func (conn *FakeVTGateConn) Execute(ctx context.Context, session *vtgatepb.Session, sql string, bindVars map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) {
response, ok := conn.execMap[sql]
if !ok {
return nil, nil, fmt.Errorf("no match for: %s", sql)
}
query := &queryExecute{
SQL:... | go | func (conn *FakeVTGateConn) Execute(ctx context.Context, session *vtgatepb.Session, sql string, bindVars map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) {
response, ok := conn.execMap[sql]
if !ok {
return nil, nil, fmt.Errorf("no match for: %s", sql)
}
query := &queryExecute{
SQL:... | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"Execute",
"(",
"ctx",
"context",
".",
"Context",
",",
"session",
"*",
"vtgatepb",
".",
"Session",
",",
"sql",
"string",
",",
"bindVars",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
")"... | // Execute please see vtgateconn.Impl.Execute | [
"Execute",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"Execute"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L173-L190 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | ExecuteBatch | func (conn *FakeVTGateConn) ExecuteBatch(ctx context.Context, session *vtgatepb.Session, sqlList []string, bindVarsList []map[string]*querypb.BindVariable) (*vtgatepb.Session, []sqltypes.QueryResponse, error) {
panic("not implemented")
} | go | func (conn *FakeVTGateConn) ExecuteBatch(ctx context.Context, session *vtgatepb.Session, sqlList []string, bindVarsList []map[string]*querypb.BindVariable) (*vtgatepb.Session, []sqltypes.QueryResponse, error) {
panic("not implemented")
} | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"ExecuteBatch",
"(",
"ctx",
"context",
".",
"Context",
",",
"session",
"*",
"vtgatepb",
".",
"Session",
",",
"sqlList",
"[",
"]",
"string",
",",
"bindVarsList",
"[",
"]",
"map",
"[",
"string",
"]",
"*",
... | // ExecuteBatch please see vtgateconn.Impl.ExecuteBatch | [
"ExecuteBatch",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"ExecuteBatch"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L193-L195 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | StreamExecute | func (conn *FakeVTGateConn) StreamExecute(ctx context.Context, session *vtgatepb.Session, sql string, bindVars map[string]*querypb.BindVariable) (sqltypes.ResultStream, error) {
response, ok := conn.execMap[sql]
if !ok {
return nil, fmt.Errorf("no match for: %s", sql)
}
query := &queryExecute{
SQL: sq... | go | func (conn *FakeVTGateConn) StreamExecute(ctx context.Context, session *vtgatepb.Session, sql string, bindVars map[string]*querypb.BindVariable) (sqltypes.ResultStream, error) {
response, ok := conn.execMap[sql]
if !ok {
return nil, fmt.Errorf("no match for: %s", sql)
}
query := &queryExecute{
SQL: sq... | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"StreamExecute",
"(",
"ctx",
"context",
".",
"Context",
",",
"session",
"*",
"vtgatepb",
".",
"Session",
",",
"sql",
"string",
",",
"bindVars",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",... | // StreamExecute please see vtgateconn.Impl.StreamExecute | [
"StreamExecute",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"StreamExecute"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L198-L232 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | ExecuteShards | func (conn *FakeVTGateConn) ExecuteShards(ctx context.Context, sql string, keyspace string, shards []string, bindVars map[string]*querypb.BindVariable, tabletType topodatapb.TabletType, session *vtgatepb.Session, options *querypb.ExecuteOptions) (*vtgatepb.Session, *sqltypes.Result, error) {
var s *vtgatepb.Session
i... | go | func (conn *FakeVTGateConn) ExecuteShards(ctx context.Context, sql string, keyspace string, shards []string, bindVars map[string]*querypb.BindVariable, tabletType topodatapb.TabletType, session *vtgatepb.Session, options *querypb.ExecuteOptions) (*vtgatepb.Session, *sqltypes.Result, error) {
var s *vtgatepb.Session
i... | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"ExecuteShards",
"(",
"ctx",
"context",
".",
"Context",
",",
"sql",
"string",
",",
"keyspace",
"string",
",",
"shards",
"[",
"]",
"string",
",",
"bindVars",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
... | // ExecuteShards please see vtgateconn.Impl.ExecuteShard | [
"ExecuteShards",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"ExecuteShard"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L235-L261 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | ExecuteKeyspaceIds | func (conn *FakeVTGateConn) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]*querypb.BindVariable, tabletType topodatapb.TabletType, session *vtgatepb.Session, options *querypb.ExecuteOptions) (*vtgatepb.Session, *sqltypes.Result, error) {
panic("not imp... | go | func (conn *FakeVTGateConn) ExecuteKeyspaceIds(ctx context.Context, query string, keyspace string, keyspaceIds [][]byte, bindVars map[string]*querypb.BindVariable, tabletType topodatapb.TabletType, session *vtgatepb.Session, options *querypb.ExecuteOptions) (*vtgatepb.Session, *sqltypes.Result, error) {
panic("not imp... | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"ExecuteKeyspaceIds",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"string",
",",
"keyspace",
"string",
",",
"keyspaceIds",
"[",
"]",
"[",
"]",
"byte",
",",
"bindVars",
"map",
"[",
"string",
"]",
"... | // ExecuteKeyspaceIds please see vtgateconn.Impl.ExecuteKeyspaceIds | [
"ExecuteKeyspaceIds",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"ExecuteKeyspaceIds"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L264-L266 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | ExecuteKeyRanges | func (conn *FakeVTGateConn) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]*querypb.BindVariable, tabletType topodatapb.TabletType, session *vtgatepb.Session, options *querypb.ExecuteOptions) (*vtgatepb.Session, *sqltypes.Result, error) {
pani... | go | func (conn *FakeVTGateConn) ExecuteKeyRanges(ctx context.Context, query string, keyspace string, keyRanges []*topodatapb.KeyRange, bindVars map[string]*querypb.BindVariable, tabletType topodatapb.TabletType, session *vtgatepb.Session, options *querypb.ExecuteOptions) (*vtgatepb.Session, *sqltypes.Result, error) {
pani... | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"ExecuteKeyRanges",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"string",
",",
"keyspace",
"string",
",",
"keyRanges",
"[",
"]",
"*",
"topodatapb",
".",
"KeyRange",
",",
"bindVars",
"map",
"[",
"str... | // ExecuteKeyRanges please see vtgateconn.Impl.ExecuteKeyRanges | [
"ExecuteKeyRanges",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"ExecuteKeyRanges"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L269-L271 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | ExecuteEntityIds | func (conn *FakeVTGateConn) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]*querypb.BindVariable, tabletType topodatapb.TabletType, session *vtgatepb.Session, options *querypb.ExecuteOption... | go | func (conn *FakeVTGateConn) ExecuteEntityIds(ctx context.Context, query string, keyspace string, entityColumnName string, entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId, bindVars map[string]*querypb.BindVariable, tabletType topodatapb.TabletType, session *vtgatepb.Session, options *querypb.ExecuteOption... | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"ExecuteEntityIds",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"string",
",",
"keyspace",
"string",
",",
"entityColumnName",
"string",
",",
"entityKeyspaceIDs",
"[",
"]",
"*",
"vtgatepb",
".",
"Execute... | // ExecuteEntityIds please see vtgateconn.Impl.ExecuteEntityIds | [
"ExecuteEntityIds",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"ExecuteEntityIds"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L274-L276 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | ExecuteBatchShards | func (conn *FakeVTGateConn) ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.BoundShardQuery, tabletType topodatapb.TabletType, asTransaction bool, session *vtgatepb.Session, options *querypb.ExecuteOptions) (*vtgatepb.Session, []sqltypes.Result, error) {
panic("not implemented")
} | go | func (conn *FakeVTGateConn) ExecuteBatchShards(ctx context.Context, queries []*vtgatepb.BoundShardQuery, tabletType topodatapb.TabletType, asTransaction bool, session *vtgatepb.Session, options *querypb.ExecuteOptions) (*vtgatepb.Session, []sqltypes.Result, error) {
panic("not implemented")
} | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"ExecuteBatchShards",
"(",
"ctx",
"context",
".",
"Context",
",",
"queries",
"[",
"]",
"*",
"vtgatepb",
".",
"BoundShardQuery",
",",
"tabletType",
"topodatapb",
".",
"TabletType",
",",
"asTransaction",
"bool",
"... | // ExecuteBatchShards please see vtgateconn.Impl.ExecuteBatchShards | [
"ExecuteBatchShards",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"ExecuteBatchShards"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L279-L281 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | StreamExecuteShards | func (conn *FakeVTGateConn) StreamExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]*querypb.BindVariable, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (sqltypes.ResultStream, error) {
panic("not implemented")
} | go | func (conn *FakeVTGateConn) StreamExecuteShards(ctx context.Context, query string, keyspace string, shards []string, bindVars map[string]*querypb.BindVariable, tabletType topodatapb.TabletType, options *querypb.ExecuteOptions) (sqltypes.ResultStream, error) {
panic("not implemented")
} | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"StreamExecuteShards",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"string",
",",
"keyspace",
"string",
",",
"shards",
"[",
"]",
"string",
",",
"bindVars",
"map",
"[",
"string",
"]",
"*",
"querypb",... | // StreamExecuteShards please see vtgateconn.Impl.StreamExecuteShards | [
"StreamExecuteShards",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"StreamExecuteShards"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L301-L303 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | Begin | func (conn *FakeVTGateConn) Begin(ctx context.Context, singledb bool) (*vtgatepb.Session, error) {
return &vtgatepb.Session{
InTransaction: true,
SingleDb: singledb,
}, nil
} | go | func (conn *FakeVTGateConn) Begin(ctx context.Context, singledb bool) (*vtgatepb.Session, error) {
return &vtgatepb.Session{
InTransaction: true,
SingleDb: singledb,
}, nil
} | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"Begin",
"(",
"ctx",
"context",
".",
"Context",
",",
"singledb",
"bool",
")",
"(",
"*",
"vtgatepb",
".",
"Session",
",",
"error",
")",
"{",
"return",
"&",
"vtgatepb",
".",
"Session",
"{",
"InTransaction",
... | // Begin please see vtgateconn.Impl.Begin | [
"Begin",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"Begin"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L316-L321 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | Commit | func (conn *FakeVTGateConn) Commit(ctx context.Context, session *vtgatepb.Session, twopc bool) error {
if session == nil {
return errors.New("commit: not in transaction")
}
return nil
} | go | func (conn *FakeVTGateConn) Commit(ctx context.Context, session *vtgatepb.Session, twopc bool) error {
if session == nil {
return errors.New("commit: not in transaction")
}
return nil
} | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"Commit",
"(",
"ctx",
"context",
".",
"Context",
",",
"session",
"*",
"vtgatepb",
".",
"Session",
",",
"twopc",
"bool",
")",
"error",
"{",
"if",
"session",
"==",
"nil",
"{",
"return",
"errors",
".",
"New... | // Commit please see vtgateconn.Impl.Commit | [
"Commit",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"Commit"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L324-L329 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | Rollback | func (conn *FakeVTGateConn) Rollback(ctx context.Context, session *vtgatepb.Session) error {
return nil
} | go | func (conn *FakeVTGateConn) Rollback(ctx context.Context, session *vtgatepb.Session) error {
return nil
} | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"Rollback",
"(",
"ctx",
"context",
".",
"Context",
",",
"session",
"*",
"vtgatepb",
".",
"Session",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] | // Rollback please see vtgateconn.Impl.Rollback | [
"Rollback",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"Rollback"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L332-L334 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | ResolveTransaction | func (conn *FakeVTGateConn) ResolveTransaction(ctx context.Context, dtid string) error {
return nil
} | go | func (conn *FakeVTGateConn) ResolveTransaction(ctx context.Context, dtid string) error {
return nil
} | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"ResolveTransaction",
"(",
"ctx",
"context",
".",
"Context",
",",
"dtid",
"string",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] | // ResolveTransaction please see vtgateconn.Impl.ResolveTransaction | [
"ResolveTransaction",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"ResolveTransaction"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L337-L339 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | MessageStream | func (conn *FakeVTGateConn) MessageStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, name string, callback func(*sqltypes.Result) error) error {
panic("not implemented")
} | go | func (conn *FakeVTGateConn) MessageStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, name string, callback func(*sqltypes.Result) error) error {
panic("not implemented")
} | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"MessageStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
",",
"shard",
"string",
",",
"keyRange",
"*",
"topodatapb",
".",
"KeyRange",
",",
"name",
"string",
",",
"callback",
"func",
... | // MessageStream is part of the vtgate service API. | [
"MessageStream",
"is",
"part",
"of",
"the",
"vtgate",
"service",
"API",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L342-L344 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | MessageAck | func (conn *FakeVTGateConn) MessageAck(ctx context.Context, keyspace string, name string, ids []*querypb.Value) (int64, error) {
panic("not implemented")
} | go | func (conn *FakeVTGateConn) MessageAck(ctx context.Context, keyspace string, name string, ids []*querypb.Value) (int64, error) {
panic("not implemented")
} | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"MessageAck",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
",",
"name",
"string",
",",
"ids",
"[",
"]",
"*",
"querypb",
".",
"Value",
")",
"(",
"int64",
",",
"error",
")",
"{",
"pa... | // MessageAck is part of the vtgate service API. | [
"MessageAck",
"is",
"part",
"of",
"the",
"vtgate",
"service",
"API",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L347-L349 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | MessageAckKeyspaceIds | func (conn *FakeVTGateConn) MessageAckKeyspaceIds(ctx context.Context, keyspace string, name string, idKeyspaceIDs []*vtgatepb.IdKeyspaceId) (int64, error) {
panic("not implemented")
} | go | func (conn *FakeVTGateConn) MessageAckKeyspaceIds(ctx context.Context, keyspace string, name string, idKeyspaceIDs []*vtgatepb.IdKeyspaceId) (int64, error) {
panic("not implemented")
} | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"MessageAckKeyspaceIds",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
",",
"name",
"string",
",",
"idKeyspaceIDs",
"[",
"]",
"*",
"vtgatepb",
".",
"IdKeyspaceId",
")",
"(",
"int64",
",",
... | // MessageAckKeyspaceIds is part of the vtgate service API. | [
"MessageAckKeyspaceIds",
"is",
"part",
"of",
"the",
"vtgate",
"service",
"API",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L352-L354 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | SplitQuery | func (conn *FakeVTGateConn) SplitQuery(
ctx context.Context,
keyspace string,
query string,
bindVars map[string]*querypb.BindVariable,
splitColumns []string,
splitCount int64,
numRowsPerQueryPart int64,
algorithm querypb.SplitQueryRequest_Algorithm) ([]*vtgatepb.SplitQueryResponse_Part, error) {
response, ok ... | go | func (conn *FakeVTGateConn) SplitQuery(
ctx context.Context,
keyspace string,
query string,
bindVars map[string]*querypb.BindVariable,
splitColumns []string,
splitCount int64,
numRowsPerQueryPart int64,
algorithm querypb.SplitQueryRequest_Algorithm) ([]*vtgatepb.SplitQueryResponse_Part, error) {
response, ok ... | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"SplitQuery",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
",",
"query",
"string",
",",
"bindVars",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
",",
"splitColumns",
"... | // SplitQuery please see vtgateconn.Impl.SplitQuery | [
"SplitQuery",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"SplitQuery"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L357-L382 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | GetSrvKeyspace | func (conn *FakeVTGateConn) GetSrvKeyspace(ctx context.Context, keyspace string) (*topodatapb.SrvKeyspace, error) {
return nil, fmt.Errorf("NYI")
} | go | func (conn *FakeVTGateConn) GetSrvKeyspace(ctx context.Context, keyspace string) (*topodatapb.SrvKeyspace, error) {
return nil, fmt.Errorf("NYI")
} | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"GetSrvKeyspace",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
")",
"(",
"*",
"topodatapb",
".",
"SrvKeyspace",
",",
"error",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",... | // GetSrvKeyspace please see vtgateconn.Impl.GetSrvKeyspace | [
"GetSrvKeyspace",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"GetSrvKeyspace"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L385-L387 | train |
vitessio/vitess | go/vt/vtgate/fakerpcvtgateconn/conn.go | UpdateStream | func (conn *FakeVTGateConn) UpdateStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, tabletType topodatapb.TabletType, timestamp int64, event *querypb.EventToken) (vtgateconn.UpdateStreamReader, error) {
return nil, fmt.Errorf("NYI")
} | go | func (conn *FakeVTGateConn) UpdateStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, tabletType topodatapb.TabletType, timestamp int64, event *querypb.EventToken) (vtgateconn.UpdateStreamReader, error) {
return nil, fmt.Errorf("NYI")
} | [
"func",
"(",
"conn",
"*",
"FakeVTGateConn",
")",
"UpdateStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
",",
"shard",
"string",
",",
"keyRange",
"*",
"topodatapb",
".",
"KeyRange",
",",
"tabletType",
"topodatapb",
".",
"TabletType",
... | // UpdateStream please see vtgateconn.Impl.UpdateStream | [
"UpdateStream",
"please",
"see",
"vtgateconn",
".",
"Impl",
".",
"UpdateStream"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/fakerpcvtgateconn/conn.go#L390-L392 | train |
vitessio/vitess | go/vt/sqlparser/encodable.go | EncodeSQL | func (iv InsertValues) EncodeSQL(buf *strings.Builder) {
for i, rows := range iv {
if i != 0 {
buf.WriteString(", ")
}
buf.WriteByte('(')
for j, bv := range rows {
if j != 0 {
buf.WriteString(", ")
}
bv.EncodeSQL(buf)
}
buf.WriteByte(')')
}
} | go | func (iv InsertValues) EncodeSQL(buf *strings.Builder) {
for i, rows := range iv {
if i != 0 {
buf.WriteString(", ")
}
buf.WriteByte('(')
for j, bv := range rows {
if j != 0 {
buf.WriteString(", ")
}
bv.EncodeSQL(buf)
}
buf.WriteByte(')')
}
} | [
"func",
"(",
"iv",
"InsertValues",
")",
"EncodeSQL",
"(",
"buf",
"*",
"strings",
".",
"Builder",
")",
"{",
"for",
"i",
",",
"rows",
":=",
"range",
"iv",
"{",
"if",
"i",
"!=",
"0",
"{",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"}",
... | // EncodeSQL performs the SQL encoding for InsertValues. | [
"EncodeSQL",
"performs",
"the",
"SQL",
"encoding",
"for",
"InsertValues",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/sqlparser/encodable.go#L38-L52 | train |
vitessio/vitess | go/vt/sqlparser/encodable.go | EncodeSQL | func (tpl *TupleEqualityList) EncodeSQL(buf *strings.Builder) {
if len(tpl.Columns) == 1 {
tpl.encodeAsIn(buf)
return
}
tpl.encodeAsEquality(buf)
} | go | func (tpl *TupleEqualityList) EncodeSQL(buf *strings.Builder) {
if len(tpl.Columns) == 1 {
tpl.encodeAsIn(buf)
return
}
tpl.encodeAsEquality(buf)
} | [
"func",
"(",
"tpl",
"*",
"TupleEqualityList",
")",
"EncodeSQL",
"(",
"buf",
"*",
"strings",
".",
"Builder",
")",
"{",
"if",
"len",
"(",
"tpl",
".",
"Columns",
")",
"==",
"1",
"{",
"tpl",
".",
"encodeAsIn",
"(",
"buf",
")",
"\n",
"return",
"\n",
"}"... | // EncodeSQL generates the where clause constraints for the tuple
// equality. | [
"EncodeSQL",
"generates",
"the",
"where",
"clause",
"constraints",
"for",
"the",
"tuple",
"equality",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/sqlparser/encodable.go#L63-L69 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/txserializer/tx_serializer.go | New | func New(dryRun bool, maxQueueSize, maxGlobalQueueSize, concurrentTransactions int) *TxSerializer {
return &TxSerializer{
ConsolidatorCache: sync2.NewConsolidatorCache(1000),
dryRun: dryRun,
maxQueueSize: maxQueueSize,
maxGlobalQueueSize: maxGlobalQueu... | go | func New(dryRun bool, maxQueueSize, maxGlobalQueueSize, concurrentTransactions int) *TxSerializer {
return &TxSerializer{
ConsolidatorCache: sync2.NewConsolidatorCache(1000),
dryRun: dryRun,
maxQueueSize: maxQueueSize,
maxGlobalQueueSize: maxGlobalQueu... | [
"func",
"New",
"(",
"dryRun",
"bool",
",",
"maxQueueSize",
",",
"maxGlobalQueueSize",
",",
"concurrentTransactions",
"int",
")",
"*",
"TxSerializer",
"{",
"return",
"&",
"TxSerializer",
"{",
"ConsolidatorCache",
":",
"sync2",
".",
"NewConsolidatorCache",
"(",
"100... | // New returns a TxSerializer object. | [
"New",
"returns",
"a",
"TxSerializer",
"object",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/txserializer/tx_serializer.go#L113-L127 | train |
vitessio/vitess | go/vt/vttablet/tabletserver/txserializer/tx_serializer.go | lockLocked | func (t *TxSerializer) lockLocked(ctx context.Context, key, table string) (bool, error) {
q, ok := t.queues[key]
if !ok {
// First transaction in the queue i.e. we don't wait and return immediately.
t.queues[key] = newQueueForFirstTransaction(t.concurrentTransactions)
t.globalSize++
return false, nil
}
if ... | go | func (t *TxSerializer) lockLocked(ctx context.Context, key, table string) (bool, error) {
q, ok := t.queues[key]
if !ok {
// First transaction in the queue i.e. we don't wait and return immediately.
t.queues[key] = newQueueForFirstTransaction(t.concurrentTransactions)
t.globalSize++
return false, nil
}
if ... | [
"func",
"(",
"t",
"*",
"TxSerializer",
")",
"lockLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
",",
"table",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"q",
",",
"ok",
":=",
"t",
".",
"queues",
"[",
"key",
"]",
"\n",
"if",
... | // lockLocked queues this transaction. It will unblock immediately if this
// transaction is the first in the queue or when it acquired a slot.
// The method has the suffix "Locked" to clarify that "t.mu" must be locked. | [
"lockLocked",
"queues",
"this",
"transaction",
".",
"It",
"will",
"unblock",
"immediately",
"if",
"this",
"transaction",
"is",
"the",
"first",
"in",
"the",
"queue",
"or",
"when",
"it",
"acquired",
"a",
"slot",
".",
"The",
"method",
"has",
"the",
"suffix",
... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletserver/txserializer/tx_serializer.go#L157-L237 | train |
vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | NewReader | func NewReader(checker connpool.MySQLChecker, config tabletenv.TabletConfig) *Reader {
if !config.HeartbeatEnable {
return &Reader{}
}
return &Reader{
enabled: true,
now: time.Now,
interval: config.HeartbeatInterval,
ticks: timer.NewTimer(config.HeartbeatInterval),
errorLog: logutil.NewThrottle... | go | func NewReader(checker connpool.MySQLChecker, config tabletenv.TabletConfig) *Reader {
if !config.HeartbeatEnable {
return &Reader{}
}
return &Reader{
enabled: true,
now: time.Now,
interval: config.HeartbeatInterval,
ticks: timer.NewTimer(config.HeartbeatInterval),
errorLog: logutil.NewThrottle... | [
"func",
"NewReader",
"(",
"checker",
"connpool",
".",
"MySQLChecker",
",",
"config",
"tabletenv",
".",
"TabletConfig",
")",
"*",
"Reader",
"{",
"if",
"!",
"config",
".",
"HeartbeatEnable",
"{",
"return",
"&",
"Reader",
"{",
"}",
"\n",
"}",
"\n\n",
"return"... | // NewReader returns a new heartbeat reader. | [
"NewReader",
"returns",
"a",
"new",
"heartbeat",
"reader",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L72-L85 | train |
vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | Init | func (r *Reader) Init(target querypb.Target) {
if !r.enabled {
return
}
r.dbName = sqlescape.EscapeID(r.dbconfigs.SidecarDBName.Get())
r.keyspaceShard = fmt.Sprintf("%s:%s", target.Keyspace, target.Shard)
} | go | func (r *Reader) Init(target querypb.Target) {
if !r.enabled {
return
}
r.dbName = sqlescape.EscapeID(r.dbconfigs.SidecarDBName.Get())
r.keyspaceShard = fmt.Sprintf("%s:%s", target.Keyspace, target.Shard)
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"Init",
"(",
"target",
"querypb",
".",
"Target",
")",
"{",
"if",
"!",
"r",
".",
"enabled",
"{",
"return",
"\n",
"}",
"\n",
"r",
".",
"dbName",
"=",
"sqlescape",
".",
"EscapeID",
"(",
"r",
".",
"dbconfigs",
".... | // Init does last minute initialization of db settings, such as dbName
// and keyspaceShard | [
"Init",
"does",
"last",
"minute",
"initialization",
"of",
"db",
"settings",
"such",
"as",
"dbName",
"and",
"keyspaceShard"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L94-L100 | train |
vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | Open | func (r *Reader) Open() {
if !r.enabled {
return
}
r.runMu.Lock()
defer r.runMu.Unlock()
if r.isOpen {
return
}
log.Info("Beginning heartbeat reads")
r.pool.Open(r.dbconfigs.AppWithDB(), r.dbconfigs.DbaWithDB(), r.dbconfigs.AppDebugWithDB())
r.ticks.Start(func() { r.readHeartbeat() })
r.isOpen = true
} | go | func (r *Reader) Open() {
if !r.enabled {
return
}
r.runMu.Lock()
defer r.runMu.Unlock()
if r.isOpen {
return
}
log.Info("Beginning heartbeat reads")
r.pool.Open(r.dbconfigs.AppWithDB(), r.dbconfigs.DbaWithDB(), r.dbconfigs.AppDebugWithDB())
r.ticks.Start(func() { r.readHeartbeat() })
r.isOpen = true
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"Open",
"(",
")",
"{",
"if",
"!",
"r",
".",
"enabled",
"{",
"return",
"\n",
"}",
"\n",
"r",
".",
"runMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"runMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"r... | // Open starts the heartbeat ticker and opens the db pool. It may be called multiple
// times, as long as it was closed since last invocation. | [
"Open",
"starts",
"the",
"heartbeat",
"ticker",
"and",
"opens",
"the",
"db",
"pool",
".",
"It",
"may",
"be",
"called",
"multiple",
"times",
"as",
"long",
"as",
"it",
"was",
"closed",
"since",
"last",
"invocation",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L104-L118 | train |
vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | Close | func (r *Reader) Close() {
if !r.enabled {
return
}
r.runMu.Lock()
defer r.runMu.Unlock()
if !r.isOpen {
return
}
r.ticks.Stop()
r.pool.Close()
log.Info("Stopped heartbeat reads")
r.isOpen = false
} | go | func (r *Reader) Close() {
if !r.enabled {
return
}
r.runMu.Lock()
defer r.runMu.Unlock()
if !r.isOpen {
return
}
r.ticks.Stop()
r.pool.Close()
log.Info("Stopped heartbeat reads")
r.isOpen = false
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"Close",
"(",
")",
"{",
"if",
"!",
"r",
".",
"enabled",
"{",
"return",
"\n",
"}",
"\n",
"r",
".",
"runMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"runMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"... | // Close cancels the watchHeartbeat periodic ticker and closes the db pool.
// A reader object can be re-opened after closing. | [
"Close",
"cancels",
"the",
"watchHeartbeat",
"periodic",
"ticker",
"and",
"closes",
"the",
"db",
"pool",
".",
"A",
"reader",
"object",
"can",
"be",
"re",
"-",
"opened",
"after",
"closing",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L122-L135 | train |
vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | fetchMostRecentHeartbeat | func (r *Reader) fetchMostRecentHeartbeat(ctx context.Context) (*sqltypes.Result, error) {
conn, err := r.pool.Get(ctx)
if err != nil {
return nil, err
}
defer conn.Recycle()
sel, err := r.bindHeartbeatFetch()
if err != nil {
return nil, err
}
return conn.Exec(ctx, sel, 1, false)
} | go | func (r *Reader) fetchMostRecentHeartbeat(ctx context.Context) (*sqltypes.Result, error) {
conn, err := r.pool.Get(ctx)
if err != nil {
return nil, err
}
defer conn.Recycle()
sel, err := r.bindHeartbeatFetch()
if err != nil {
return nil, err
}
return conn.Exec(ctx, sel, 1, false)
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"fetchMostRecentHeartbeat",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"sqltypes",
".",
"Result",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"r",
".",
"pool",
".",
"Get",
"(",
"ctx",
")",
"\n"... | // fetchMostRecentHeartbeat fetches the most recently recorded heartbeat from the heartbeat table,
// returning a result with the timestamp of the heartbeat. | [
"fetchMostRecentHeartbeat",
"fetches",
"the",
"most",
"recently",
"recorded",
"heartbeat",
"from",
"the",
"heartbeat",
"table",
"returning",
"a",
"result",
"with",
"the",
"timestamp",
"of",
"the",
"heartbeat",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L179-L190 | train |
vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | bindHeartbeatFetch | func (r *Reader) bindHeartbeatFetch() (string, error) {
bindVars := map[string]*querypb.BindVariable{
"ks": sqltypes.StringBindVariable(r.keyspaceShard),
}
parsed := sqlparser.BuildParsedQuery(sqlFetchMostRecentHeartbeat, r.dbName, ":ks")
bound, err := parsed.GenerateQuery(bindVars, nil)
if err != nil {
return... | go | func (r *Reader) bindHeartbeatFetch() (string, error) {
bindVars := map[string]*querypb.BindVariable{
"ks": sqltypes.StringBindVariable(r.keyspaceShard),
}
parsed := sqlparser.BuildParsedQuery(sqlFetchMostRecentHeartbeat, r.dbName, ":ks")
bound, err := parsed.GenerateQuery(bindVars, nil)
if err != nil {
return... | [
"func",
"(",
"r",
"*",
"Reader",
")",
"bindHeartbeatFetch",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"bindVars",
":=",
"map",
"[",
"string",
"]",
"*",
"querypb",
".",
"BindVariable",
"{",
"\"",
"\"",
":",
"sqltypes",
".",
"StringBindVariable",
... | // bindHeartbeatFetch takes a heartbeat read and adds the necessary
// fields to the query as bind vars. This is done to protect ourselves
// against a badly formed keyspace or shard name. | [
"bindHeartbeatFetch",
"takes",
"a",
"heartbeat",
"read",
"and",
"adds",
"the",
"necessary",
"fields",
"to",
"the",
"query",
"as",
"bind",
"vars",
".",
"This",
"is",
"done",
"to",
"protect",
"ourselves",
"against",
"a",
"badly",
"formed",
"keyspace",
"or",
"s... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L195-L205 | train |
vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | parseHeartbeatResult | func parseHeartbeatResult(res *sqltypes.Result) (int64, error) {
if len(res.Rows) != 1 {
return 0, fmt.Errorf("failed to read heartbeat: writer query did not result in 1 row. Got %v", len(res.Rows))
}
ts, err := sqltypes.ToInt64(res.Rows[0][0])
if err != nil {
return 0, err
}
return ts, nil
} | go | func parseHeartbeatResult(res *sqltypes.Result) (int64, error) {
if len(res.Rows) != 1 {
return 0, fmt.Errorf("failed to read heartbeat: writer query did not result in 1 row. Got %v", len(res.Rows))
}
ts, err := sqltypes.ToInt64(res.Rows[0][0])
if err != nil {
return 0, err
}
return ts, nil
} | [
"func",
"parseHeartbeatResult",
"(",
"res",
"*",
"sqltypes",
".",
"Result",
")",
"(",
"int64",
",",
"error",
")",
"{",
"if",
"len",
"(",
"res",
".",
"Rows",
")",
"!=",
"1",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len... | // parseHeartbeatResult turns a raw result into the timestamp for processing. | [
"parseHeartbeatResult",
"turns",
"a",
"raw",
"result",
"into",
"the",
"timestamp",
"for",
"processing",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L208-L217 | train |
vitessio/vitess | go/vt/vttablet/heartbeat/reader.go | recordError | func (r *Reader) recordError(err error) {
r.lagMu.Lock()
r.lastKnownError = err
r.lagMu.Unlock()
r.errorLog.Errorf("%v", err)
readErrors.Add(1)
} | go | func (r *Reader) recordError(err error) {
r.lagMu.Lock()
r.lastKnownError = err
r.lagMu.Unlock()
r.errorLog.Errorf("%v", err)
readErrors.Add(1)
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"recordError",
"(",
"err",
"error",
")",
"{",
"r",
".",
"lagMu",
".",
"Lock",
"(",
")",
"\n",
"r",
".",
"lastKnownError",
"=",
"err",
"\n",
"r",
".",
"lagMu",
".",
"Unlock",
"(",
")",
"\n",
"r",
".",
"error... | // recordError keeps track of the lastKnown error for reporting to the healthcheck.
// Errors tracked here are logged with throttling to cut down on log spam since
// operations can happen very frequently in this package. | [
"recordError",
"keeps",
"track",
"of",
"the",
"lastKnown",
"error",
"for",
"reporting",
"to",
"the",
"healthcheck",
".",
"Errors",
"tracked",
"here",
"are",
"logged",
"with",
"throttling",
"to",
"cut",
"down",
"on",
"log",
"spam",
"since",
"operations",
"can",... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/heartbeat/reader.go#L222-L228 | train |
vitessio/vitess | go/vt/servenv/rpc_utils.go | HandlePanic | func HandlePanic(component string, err *error) {
if x := recover(); x != nil {
// gRPC 0.13 chokes when you return a streaming error that contains newlines.
*err = fmt.Errorf("uncaught %v panic: %v, %s", component, x,
strings.Replace(string(tb.Stack(4)), "\n", ";", -1))
}
} | go | func HandlePanic(component string, err *error) {
if x := recover(); x != nil {
// gRPC 0.13 chokes when you return a streaming error that contains newlines.
*err = fmt.Errorf("uncaught %v panic: %v, %s", component, x,
strings.Replace(string(tb.Stack(4)), "\n", ";", -1))
}
} | [
"func",
"HandlePanic",
"(",
"component",
"string",
",",
"err",
"*",
"error",
")",
"{",
"if",
"x",
":=",
"recover",
"(",
")",
";",
"x",
"!=",
"nil",
"{",
"// gRPC 0.13 chokes when you return a streaming error that contains newlines.",
"*",
"err",
"=",
"fmt",
".",... | // HandlePanic should be called using 'defer' in the RPC code that executes the command. | [
"HandlePanic",
"should",
"be",
"called",
"using",
"defer",
"in",
"the",
"RPC",
"code",
"that",
"executes",
"the",
"command",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/servenv/rpc_utils.go#L27-L33 | train |
vitessio/vitess | go/vt/topo/consultopo/server.go | NewServer | func NewServer(cell, serverAddr, root string) (*Server, error) {
creds, err := getClientCreds()
if err != nil {
return nil, err
}
cfg := api.DefaultConfig()
cfg.Address = serverAddr
if creds != nil {
if creds[cell] != nil {
cfg.Token = creds[cell].ACLToken
} else {
log.Warningf("Client auth not config... | go | func NewServer(cell, serverAddr, root string) (*Server, error) {
creds, err := getClientCreds()
if err != nil {
return nil, err
}
cfg := api.DefaultConfig()
cfg.Address = serverAddr
if creds != nil {
if creds[cell] != nil {
cfg.Token = creds[cell].ACLToken
} else {
log.Warningf("Client auth not config... | [
"func",
"NewServer",
"(",
"cell",
",",
"serverAddr",
",",
"root",
"string",
")",
"(",
"*",
"Server",
",",
"error",
")",
"{",
"creds",
",",
"err",
":=",
"getClientCreds",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\... | // NewServer returns a new consultopo.Server. | [
"NewServer",
"returns",
"a",
"new",
"consultopo",
".",
"Server",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/consultopo/server.go#L107-L133 | train |
vitessio/vitess | go/vt/topo/consultopo/server.go | Close | func (s *Server) Close() {
s.client = nil
s.kv = nil
s.mu.Lock()
defer s.mu.Unlock()
s.locks = nil
} | go | func (s *Server) Close() {
s.client = nil
s.kv = nil
s.mu.Lock()
defer s.mu.Unlock()
s.locks = nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Close",
"(",
")",
"{",
"s",
".",
"client",
"=",
"nil",
"\n",
"s",
".",
"kv",
"=",
"nil",
"\n",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"s"... | // Close implements topo.Server.Close.
// It will nil out the global and cells fields, so any attempt to
// re-use this server will panic. | [
"Close",
"implements",
"topo",
".",
"Server",
".",
"Close",
".",
"It",
"will",
"nil",
"out",
"the",
"global",
"and",
"cells",
"fields",
"so",
"any",
"attempt",
"to",
"re",
"-",
"use",
"this",
"server",
"will",
"panic",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/consultopo/server.go#L138-L144 | train |
vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | MarshalJSON | func (ks *KeyspaceSchema) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
Sharded bool `json:"sharded,omitempty"`
Tables map[string]*Table `json:"tables,omitempty"`
Vindexes map[string]Vindex `json:"vindexes,omitempty"`
Error string `json:"error,omitempty"`
}{
Shar... | go | func (ks *KeyspaceSchema) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
Sharded bool `json:"sharded,omitempty"`
Tables map[string]*Table `json:"tables,omitempty"`
Vindexes map[string]Vindex `json:"vindexes,omitempty"`
Error string `json:"error,omitempty"`
}{
Shar... | [
"func",
"(",
"ks",
"*",
"KeyspaceSchema",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"struct",
"{",
"Sharded",
"bool",
"`json:\"sharded,omitempty\"`",
"\n",
"Tables",
"map",
"[",
"s... | // MarshalJSON returns a JSON representation of KeyspaceSchema. | [
"MarshalJSON",
"returns",
"a",
"JSON",
"representation",
"of",
"KeyspaceSchema",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L136-L153 | train |
vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | BuildVSchema | func BuildVSchema(source *vschemapb.SrvVSchema) (vschema *VSchema, err error) {
vschema = &VSchema{
RoutingRules: make(map[string]*RoutingRule),
uniqueTables: make(map[string]*Table),
uniqueVindexes: make(map[string]Vindex),
Keyspaces: make(map[string]*KeyspaceSchema),
}
buildKeyspaces(source, vsche... | go | func BuildVSchema(source *vschemapb.SrvVSchema) (vschema *VSchema, err error) {
vschema = &VSchema{
RoutingRules: make(map[string]*RoutingRule),
uniqueTables: make(map[string]*Table),
uniqueVindexes: make(map[string]Vindex),
Keyspaces: make(map[string]*KeyspaceSchema),
}
buildKeyspaces(source, vsche... | [
"func",
"BuildVSchema",
"(",
"source",
"*",
"vschemapb",
".",
"SrvVSchema",
")",
"(",
"vschema",
"*",
"VSchema",
",",
"err",
"error",
")",
"{",
"vschema",
"=",
"&",
"VSchema",
"{",
"RoutingRules",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Rout... | // BuildVSchema builds a VSchema from a SrvVSchema. | [
"BuildVSchema",
"builds",
"a",
"VSchema",
"from",
"a",
"SrvVSchema",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L162-L174 | train |
vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | BuildKeyspaceSchema | func BuildKeyspaceSchema(input *vschemapb.Keyspace, keyspace string) (*KeyspaceSchema, error) {
if input == nil {
input = &vschemapb.Keyspace{}
}
formal := &vschemapb.SrvVSchema{
Keyspaces: map[string]*vschemapb.Keyspace{
keyspace: input,
},
}
vschema := &VSchema{
uniqueTables: make(map[string]*Table)... | go | func BuildKeyspaceSchema(input *vschemapb.Keyspace, keyspace string) (*KeyspaceSchema, error) {
if input == nil {
input = &vschemapb.Keyspace{}
}
formal := &vschemapb.SrvVSchema{
Keyspaces: map[string]*vschemapb.Keyspace{
keyspace: input,
},
}
vschema := &VSchema{
uniqueTables: make(map[string]*Table)... | [
"func",
"BuildKeyspaceSchema",
"(",
"input",
"*",
"vschemapb",
".",
"Keyspace",
",",
"keyspace",
"string",
")",
"(",
"*",
"KeyspaceSchema",
",",
"error",
")",
"{",
"if",
"input",
"==",
"nil",
"{",
"input",
"=",
"&",
"vschemapb",
".",
"Keyspace",
"{",
"}"... | // BuildKeyspaceSchema builds the vschema portion for one keyspace.
// The build ignores sequence references because those dependencies can
// go cross-keyspace. | [
"BuildKeyspaceSchema",
"builds",
"the",
"vschema",
"portion",
"for",
"one",
"keyspace",
".",
"The",
"build",
"ignores",
"sequence",
"references",
"because",
"those",
"dependencies",
"can",
"go",
"cross",
"-",
"keyspace",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L179-L196 | train |
vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | addDual | func addDual(vschema *VSchema) {
first := ""
for ksname, ks := range vschema.Keyspaces {
t := &Table{
Name: sqlparser.NewTableIdent("dual"),
Keyspace: ks.Keyspace,
}
if ks.Keyspace.Sharded {
t.Pinned = []byte{0}
}
ks.Tables["dual"] = t
if first == "" || first > ksname {
// In case of a ref... | go | func addDual(vschema *VSchema) {
first := ""
for ksname, ks := range vschema.Keyspaces {
t := &Table{
Name: sqlparser.NewTableIdent("dual"),
Keyspace: ks.Keyspace,
}
if ks.Keyspace.Sharded {
t.Pinned = []byte{0}
}
ks.Tables["dual"] = t
if first == "" || first > ksname {
// In case of a ref... | [
"func",
"addDual",
"(",
"vschema",
"*",
"VSchema",
")",
"{",
"first",
":=",
"\"",
"\"",
"\n",
"for",
"ksname",
",",
"ks",
":=",
"range",
"vschema",
".",
"Keyspaces",
"{",
"t",
":=",
"&",
"Table",
"{",
"Name",
":",
"sqlparser",
".",
"NewTableIdent",
"... | // addDual adds dual as a valid table to all keyspaces.
// For sharded keyspaces, it gets pinned against keyspace id '0x00'. | [
"addDual",
"adds",
"dual",
"as",
"a",
"valid",
"table",
"to",
"all",
"keyspaces",
".",
"For",
"sharded",
"keyspaces",
"it",
"gets",
"pinned",
"against",
"keyspace",
"id",
"0x00",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L355-L375 | train |
vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | findQualified | func (vschema *VSchema) findQualified(name string) (*Table, error) {
splits := strings.Split(name, ".")
switch len(splits) {
case 1:
return vschema.FindTable("", splits[0])
case 2:
return vschema.FindTable(splits[0], splits[1])
}
return nil, fmt.Errorf("table %s not found", name)
} | go | func (vschema *VSchema) findQualified(name string) (*Table, error) {
splits := strings.Split(name, ".")
switch len(splits) {
case 1:
return vschema.FindTable("", splits[0])
case 2:
return vschema.FindTable(splits[0], splits[1])
}
return nil, fmt.Errorf("table %s not found", name)
} | [
"func",
"(",
"vschema",
"*",
"VSchema",
")",
"findQualified",
"(",
"name",
"string",
")",
"(",
"*",
"Table",
",",
"error",
")",
"{",
"splits",
":=",
"strings",
".",
"Split",
"(",
"name",
",",
"\"",
"\"",
")",
"\n",
"switch",
"len",
"(",
"splits",
"... | // findQualified finds a table t or k.t. | [
"findQualified",
"finds",
"a",
"table",
"t",
"or",
"k",
".",
"t",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L420-L429 | train |
vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | findTable | func (vschema *VSchema) findTable(keyspace, tablename string) (*Table, error) {
if keyspace == "" {
table, ok := vschema.uniqueTables[tablename]
if table == nil {
if ok {
return nil, fmt.Errorf("ambiguous table reference: %s", tablename)
}
if len(vschema.Keyspaces) != 1 {
return nil, nil
}
/... | go | func (vschema *VSchema) findTable(keyspace, tablename string) (*Table, error) {
if keyspace == "" {
table, ok := vschema.uniqueTables[tablename]
if table == nil {
if ok {
return nil, fmt.Errorf("ambiguous table reference: %s", tablename)
}
if len(vschema.Keyspaces) != 1 {
return nil, nil
}
/... | [
"func",
"(",
"vschema",
"*",
"VSchema",
")",
"findTable",
"(",
"keyspace",
",",
"tablename",
"string",
")",
"(",
"*",
"Table",
",",
"error",
")",
"{",
"if",
"keyspace",
"==",
"\"",
"\"",
"{",
"table",
",",
"ok",
":=",
"vschema",
".",
"uniqueTables",
... | // findTable is like FindTable, but does not return an error if a table is not found. | [
"findTable",
"is",
"like",
"FindTable",
"but",
"does",
"not",
"return",
"an",
"error",
"if",
"a",
"table",
"is",
"not",
"found",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L451-L483 | train |
vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | FindTablesOrVindex | func (vschema *VSchema) FindTablesOrVindex(keyspace, name string, tabletType topodatapb.TabletType) ([]*Table, Vindex, error) {
tables, err := vschema.findTables(keyspace, name, tabletType)
if err != nil {
return nil, nil, err
}
if tables != nil {
return tables, nil, nil
}
v, err := vschema.FindVindex(keyspac... | go | func (vschema *VSchema) FindTablesOrVindex(keyspace, name string, tabletType topodatapb.TabletType) ([]*Table, Vindex, error) {
tables, err := vschema.findTables(keyspace, name, tabletType)
if err != nil {
return nil, nil, err
}
if tables != nil {
return tables, nil, nil
}
v, err := vschema.FindVindex(keyspac... | [
"func",
"(",
"vschema",
"*",
"VSchema",
")",
"FindTablesOrVindex",
"(",
"keyspace",
",",
"name",
"string",
",",
"tabletType",
"topodatapb",
".",
"TabletType",
")",
"(",
"[",
"]",
"*",
"Table",
",",
"Vindex",
",",
"error",
")",
"{",
"tables",
",",
"err",
... | // FindTablesOrVindex finds a table or a Vindex by name using Find and FindVindex. | [
"FindTablesOrVindex",
"finds",
"a",
"table",
"or",
"a",
"Vindex",
"by",
"name",
"using",
"Find",
"and",
"FindVindex",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L516-L532 | train |
vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | FindVindex | func (vschema *VSchema) FindVindex(keyspace, name string) (Vindex, error) {
if keyspace == "" {
vindex, ok := vschema.uniqueVindexes[name]
if vindex == nil && ok {
return nil, fmt.Errorf("ambiguous vindex reference: %s", name)
}
return vindex, nil
}
ks, ok := vschema.Keyspaces[keyspace]
if !ok {
return... | go | func (vschema *VSchema) FindVindex(keyspace, name string) (Vindex, error) {
if keyspace == "" {
vindex, ok := vschema.uniqueVindexes[name]
if vindex == nil && ok {
return nil, fmt.Errorf("ambiguous vindex reference: %s", name)
}
return vindex, nil
}
ks, ok := vschema.Keyspaces[keyspace]
if !ok {
return... | [
"func",
"(",
"vschema",
"*",
"VSchema",
")",
"FindVindex",
"(",
"keyspace",
",",
"name",
"string",
")",
"(",
"Vindex",
",",
"error",
")",
"{",
"if",
"keyspace",
"==",
"\"",
"\"",
"{",
"vindex",
",",
"ok",
":=",
"vschema",
".",
"uniqueVindexes",
"[",
... | // FindVindex finds a vindex by name. If a keyspace is specified, only vindexes
// from that keyspace are searched. If no kesypace is specified, then a vindex
// is returned only if its name is unique across all keyspaces. The function
// returns an error only if the vindex name is ambiguous. | [
"FindVindex",
"finds",
"a",
"vindex",
"by",
"name",
".",
"If",
"a",
"keyspace",
"is",
"specified",
"only",
"vindexes",
"from",
"that",
"keyspace",
"are",
"searched",
".",
"If",
"no",
"kesypace",
"is",
"specified",
"then",
"a",
"vindex",
"is",
"returned",
"... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L538-L551 | train |
vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | LoadFormal | func LoadFormal(filename string) (*vschemapb.SrvVSchema, error) {
formal := &vschemapb.SrvVSchema{}
if filename == "" {
return formal, nil
}
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
err = json2.Unmarshal(data, formal)
if err != nil {
return nil, err
}
return formal, nil
} | go | func LoadFormal(filename string) (*vschemapb.SrvVSchema, error) {
formal := &vschemapb.SrvVSchema{}
if filename == "" {
return formal, nil
}
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
err = json2.Unmarshal(data, formal)
if err != nil {
return nil, err
}
return formal, nil
} | [
"func",
"LoadFormal",
"(",
"filename",
"string",
")",
"(",
"*",
"vschemapb",
".",
"SrvVSchema",
",",
"error",
")",
"{",
"formal",
":=",
"&",
"vschemapb",
".",
"SrvVSchema",
"{",
"}",
"\n",
"if",
"filename",
"==",
"\"",
"\"",
"{",
"return",
"formal",
",... | // LoadFormal loads the JSON representation of VSchema from a file. | [
"LoadFormal",
"loads",
"the",
"JSON",
"representation",
"of",
"VSchema",
"from",
"a",
"file",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L568-L582 | train |
vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | LoadFormalKeyspace | func LoadFormalKeyspace(filename string) (*vschemapb.Keyspace, error) {
formal := &vschemapb.Keyspace{}
if filename == "" {
return formal, nil
}
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
err = json2.Unmarshal(data, formal)
if err != nil {
return nil, err
}
return formal, n... | go | func LoadFormalKeyspace(filename string) (*vschemapb.Keyspace, error) {
formal := &vschemapb.Keyspace{}
if filename == "" {
return formal, nil
}
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
err = json2.Unmarshal(data, formal)
if err != nil {
return nil, err
}
return formal, n... | [
"func",
"LoadFormalKeyspace",
"(",
"filename",
"string",
")",
"(",
"*",
"vschemapb",
".",
"Keyspace",
",",
"error",
")",
"{",
"formal",
":=",
"&",
"vschemapb",
".",
"Keyspace",
"{",
"}",
"\n",
"if",
"filename",
"==",
"\"",
"\"",
"{",
"return",
"formal",
... | // LoadFormalKeyspace loads the JSON representation of VSchema from a file,
// for a single keyspace. | [
"LoadFormalKeyspace",
"loads",
"the",
"JSON",
"representation",
"of",
"VSchema",
"from",
"a",
"file",
"for",
"a",
"single",
"keyspace",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L586-L600 | train |
vitessio/vitess | go/vt/vtgate/vindexes/vschema.go | FindVindexForSharding | func FindVindexForSharding(tableName string, colVindexes []*ColumnVindex) (*ColumnVindex, error) {
if len(colVindexes) == 0 {
return nil, fmt.Errorf("no vindex definition for table %v", tableName)
}
result := colVindexes[0]
for _, colVindex := range colVindexes {
if colVindex.Vindex.Cost() < result.Vindex.Cost(... | go | func FindVindexForSharding(tableName string, colVindexes []*ColumnVindex) (*ColumnVindex, error) {
if len(colVindexes) == 0 {
return nil, fmt.Errorf("no vindex definition for table %v", tableName)
}
result := colVindexes[0]
for _, colVindex := range colVindexes {
if colVindex.Vindex.Cost() < result.Vindex.Cost(... | [
"func",
"FindVindexForSharding",
"(",
"tableName",
"string",
",",
"colVindexes",
"[",
"]",
"*",
"ColumnVindex",
")",
"(",
"*",
"ColumnVindex",
",",
"error",
")",
"{",
"if",
"len",
"(",
"colVindexes",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"fmt",
".",... | // FindVindexForSharding searches through the given slice
// to find the lowest cost unique vindex
// primary vindex is always unique
// if two have the same cost, use the one that occurs earlier in the definition
// if the final result is too expensive, return nil | [
"FindVindexForSharding",
"searches",
"through",
"the",
"given",
"slice",
"to",
"find",
"the",
"lowest",
"cost",
"unique",
"vindex",
"primary",
"vindex",
"is",
"always",
"unique",
"if",
"two",
"have",
"the",
"same",
"cost",
"use",
"the",
"one",
"that",
"occurs"... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/vindexes/vschema.go#L607-L621 | train |
vitessio/vitess | go/cmd/vtclient/vtclient.go | merge | func (r *results) merge(other *results) {
if other == nil {
return
}
r.mu.Lock()
defer r.mu.Unlock()
r.rowsAffected += other.rowsAffected
if other.lastInsertID > r.lastInsertID {
r.lastInsertID = other.lastInsertID
}
r.cumulativeDuration += other.duration
} | go | func (r *results) merge(other *results) {
if other == nil {
return
}
r.mu.Lock()
defer r.mu.Unlock()
r.rowsAffected += other.rowsAffected
if other.lastInsertID > r.lastInsertID {
r.lastInsertID = other.lastInsertID
}
r.cumulativeDuration += other.duration
} | [
"func",
"(",
"r",
"*",
"results",
")",
"merge",
"(",
"other",
"*",
"results",
")",
"{",
"if",
"other",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"r",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"mu",
".",
"Unlock",
"(",
")... | // merge aggregates "other" into "r".
// This is only used for executing DMLs concurrently and repeatedly.
// Therefore, "Fields" and "Rows" are not merged. | [
"merge",
"aggregates",
"other",
"into",
"r",
".",
"This",
"is",
"only",
"used",
"for",
"executing",
"DMLs",
"concurrently",
"and",
"repeatedly",
".",
"Therefore",
"Fields",
"and",
"Rows",
"are",
"not",
"merged",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/cmd/vtclient/vtclient.go#L317-L330 | train |
vitessio/vitess | go/vt/dbconfigs/credentials.go | GetCredentialsServer | func GetCredentialsServer() CredentialsServer {
cs, ok := AllCredentialsServers[*dbCredentialsServer]
if !ok {
log.Exitf("Invalid credential server: %v", *dbCredentialsServer)
}
return cs
} | go | func GetCredentialsServer() CredentialsServer {
cs, ok := AllCredentialsServers[*dbCredentialsServer]
if !ok {
log.Exitf("Invalid credential server: %v", *dbCredentialsServer)
}
return cs
} | [
"func",
"GetCredentialsServer",
"(",
")",
"CredentialsServer",
"{",
"cs",
",",
"ok",
":=",
"AllCredentialsServers",
"[",
"*",
"dbCredentialsServer",
"]",
"\n",
"if",
"!",
"ok",
"{",
"log",
".",
"Exitf",
"(",
"\"",
"\"",
",",
"*",
"dbCredentialsServer",
")",
... | // GetCredentialsServer returns the current CredentialsServer. Only valid
// after flag.Init was called. | [
"GetCredentialsServer",
"returns",
"the",
"current",
"CredentialsServer",
".",
"Only",
"valid",
"after",
"flag",
".",
"Init",
"was",
"called",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/dbconfigs/credentials.go#L67-L73 | train |
vitessio/vitess | go/vt/dbconfigs/credentials.go | GetUserAndPassword | func (fcs *FileCredentialsServer) GetUserAndPassword(user string) (string, string, error) {
fcs.mu.Lock()
defer fcs.mu.Unlock()
if *dbCredentialsFile == "" {
return "", "", ErrUnknownUser
}
// read the json file only once
if fcs.dbCredentials == nil {
fcs.dbCredentials = make(map[string][]string)
data, e... | go | func (fcs *FileCredentialsServer) GetUserAndPassword(user string) (string, string, error) {
fcs.mu.Lock()
defer fcs.mu.Unlock()
if *dbCredentialsFile == "" {
return "", "", ErrUnknownUser
}
// read the json file only once
if fcs.dbCredentials == nil {
fcs.dbCredentials = make(map[string][]string)
data, e... | [
"func",
"(",
"fcs",
"*",
"FileCredentialsServer",
")",
"GetUserAndPassword",
"(",
"user",
"string",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"fcs",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fcs",
".",
"mu",
".",
"Unlock",
"(... | // GetUserAndPassword is part of the CredentialsServer interface | [
"GetUserAndPassword",
"is",
"part",
"of",
"the",
"CredentialsServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/dbconfigs/credentials.go#L83-L112 | train |
vitessio/vitess | go/vt/dbconfigs/credentials.go | WithCredentials | func WithCredentials(cp *mysql.ConnParams) (*mysql.ConnParams, error) {
result := *cp
user, passwd, err := GetCredentialsServer().GetUserAndPassword(cp.Uname)
switch err {
case nil:
result.Uname = user
result.Pass = passwd
case ErrUnknownUser:
// we just use what we have, and will fail later anyway
err = n... | go | func WithCredentials(cp *mysql.ConnParams) (*mysql.ConnParams, error) {
result := *cp
user, passwd, err := GetCredentialsServer().GetUserAndPassword(cp.Uname)
switch err {
case nil:
result.Uname = user
result.Pass = passwd
case ErrUnknownUser:
// we just use what we have, and will fail later anyway
err = n... | [
"func",
"WithCredentials",
"(",
"cp",
"*",
"mysql",
".",
"ConnParams",
")",
"(",
"*",
"mysql",
".",
"ConnParams",
",",
"error",
")",
"{",
"result",
":=",
"*",
"cp",
"\n",
"user",
",",
"passwd",
",",
"err",
":=",
"GetCredentialsServer",
"(",
")",
".",
... | // WithCredentials returns a copy of the provided ConnParams that we can use
// to connect, after going through the CredentialsServer. | [
"WithCredentials",
"returns",
"a",
"copy",
"of",
"the",
"provided",
"ConnParams",
"that",
"we",
"can",
"use",
"to",
"connect",
"after",
"going",
"through",
"the",
"CredentialsServer",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/dbconfigs/credentials.go#L116-L128 | train |
vitessio/vitess | go/vt/topo/memorytopo/file.go | Create | func (c *Conn) Create(ctx context.Context, filePath string, contents []byte) (topo.Version, error) {
if contents == nil {
contents = []byte{}
}
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return nil, c.factory.err
}
// Get the parent dir.
dir, file := path.Split(filePath)
p... | go | func (c *Conn) Create(ctx context.Context, filePath string, contents []byte) (topo.Version, error) {
if contents == nil {
contents = []byte{}
}
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return nil, c.factory.err
}
// Get the parent dir.
dir, file := path.Split(filePath)
p... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"filePath",
"string",
",",
"contents",
"[",
"]",
"byte",
")",
"(",
"topo",
".",
"Version",
",",
"error",
")",
"{",
"if",
"contents",
"==",
"nil",
"{",
"conten... | // Create is part of topo.Conn interface. | [
"Create",
"is",
"part",
"of",
"topo",
".",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/memorytopo/file.go#L31-L59 | train |
vitessio/vitess | go/vt/topo/memorytopo/file.go | Update | func (c *Conn) Update(ctx context.Context, filePath string, contents []byte, version topo.Version) (topo.Version, error) {
if contents == nil {
contents = []byte{}
}
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return nil, c.factory.err
}
// Get the parent dir, we'll need it i... | go | func (c *Conn) Update(ctx context.Context, filePath string, contents []byte, version topo.Version) (topo.Version, error) {
if contents == nil {
contents = []byte{}
}
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return nil, c.factory.err
}
// Get the parent dir, we'll need it i... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Update",
"(",
"ctx",
"context",
".",
"Context",
",",
"filePath",
"string",
",",
"contents",
"[",
"]",
"byte",
",",
"version",
"topo",
".",
"Version",
")",
"(",
"topo",
".",
"Version",
",",
"error",
")",
"{",
"if... | // Update is part of topo.Conn interface. | [
"Update",
"is",
"part",
"of",
"topo",
".",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/memorytopo/file.go#L62-L123 | train |
vitessio/vitess | go/vt/topo/memorytopo/file.go | Get | func (c *Conn) Get(ctx context.Context, filePath string) ([]byte, topo.Version, error) {
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return nil, nil, c.factory.err
}
// Get the node.
n := c.factory.nodeByPath(c.cell, filePath)
if n == nil {
return nil, nil, topo.NewError(topo.... | go | func (c *Conn) Get(ctx context.Context, filePath string) ([]byte, topo.Version, error) {
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return nil, nil, c.factory.err
}
// Get the node.
n := c.factory.nodeByPath(c.cell, filePath)
if n == nil {
return nil, nil, topo.NewError(topo.... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"filePath",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"topo",
".",
"Version",
",",
"error",
")",
"{",
"c",
".",
"factory",
".",
"mu",
".",
"Lock",
"(",
")",... | // Get is part of topo.Conn interface. | [
"Get",
"is",
"part",
"of",
"topo",
".",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/memorytopo/file.go#L126-L144 | train |
vitessio/vitess | go/vt/topo/memorytopo/file.go | Delete | func (c *Conn) Delete(ctx context.Context, filePath string, version topo.Version) error {
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return c.factory.err
}
// Get the parent dir.
dir, file := path.Split(filePath)
p := c.factory.nodeByPath(c.cell, dir)
if p == nil {
return to... | go | func (c *Conn) Delete(ctx context.Context, filePath string, version topo.Version) error {
c.factory.mu.Lock()
defer c.factory.mu.Unlock()
if c.factory.err != nil {
return c.factory.err
}
// Get the parent dir.
dir, file := path.Split(filePath)
p := c.factory.nodeByPath(c.cell, dir)
if p == nil {
return to... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"filePath",
"string",
",",
"version",
"topo",
".",
"Version",
")",
"error",
"{",
"c",
".",
"factory",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
... | // Delete is part of topo.Conn interface. | [
"Delete",
"is",
"part",
"of",
"topo",
".",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/memorytopo/file.go#L147-L191 | train |
vitessio/vitess | go/mysql/flavor_mysql.go | masterGTIDSet | func (mysqlFlavor) masterGTIDSet(c *Conn) (GTIDSet, error) {
qr, err := c.ExecuteFetch("SELECT @@GLOBAL.gtid_executed", 1, false)
if err != nil {
return nil, err
}
if len(qr.Rows) != 1 || len(qr.Rows[0]) != 1 {
return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "unexpected result format for gtid_executed: %#v", q... | go | func (mysqlFlavor) masterGTIDSet(c *Conn) (GTIDSet, error) {
qr, err := c.ExecuteFetch("SELECT @@GLOBAL.gtid_executed", 1, false)
if err != nil {
return nil, err
}
if len(qr.Rows) != 1 || len(qr.Rows[0]) != 1 {
return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "unexpected result format for gtid_executed: %#v", q... | [
"func",
"(",
"mysqlFlavor",
")",
"masterGTIDSet",
"(",
"c",
"*",
"Conn",
")",
"(",
"GTIDSet",
",",
"error",
")",
"{",
"qr",
",",
"err",
":=",
"c",
".",
"ExecuteFetch",
"(",
"\"",
"\"",
",",
"1",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // masterGTIDSet is part of the Flavor interface. | [
"masterGTIDSet",
"is",
"part",
"of",
"the",
"Flavor",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/flavor_mysql.go#L33-L42 | train |
vitessio/vitess | go/mysql/flavor_mysql.go | status | func (mysqlFlavor) status(c *Conn) (SlaveStatus, error) {
qr, err := c.ExecuteFetch("SHOW SLAVE STATUS", 100, true /* wantfields */)
if err != nil {
return SlaveStatus{}, err
}
if len(qr.Rows) == 0 {
// The query returned no data, meaning the server
// is not configured as a slave.
return SlaveStatus{}, Err... | go | func (mysqlFlavor) status(c *Conn) (SlaveStatus, error) {
qr, err := c.ExecuteFetch("SHOW SLAVE STATUS", 100, true /* wantfields */)
if err != nil {
return SlaveStatus{}, err
}
if len(qr.Rows) == 0 {
// The query returned no data, meaning the server
// is not configured as a slave.
return SlaveStatus{}, Err... | [
"func",
"(",
"mysqlFlavor",
")",
"status",
"(",
"c",
"*",
"Conn",
")",
"(",
"SlaveStatus",
",",
"error",
")",
"{",
"qr",
",",
"err",
":=",
"c",
".",
"ExecuteFetch",
"(",
"\"",
"\"",
",",
"100",
",",
"true",
"/* wantfields */",
")",
"\n",
"if",
"err... | // status is part of the Flavor interface. | [
"status",
"is",
"part",
"of",
"the",
"Flavor",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/flavor_mysql.go#L92-L114 | train |
vitessio/vitess | go/mysql/flavor_mysql.go | waitUntilPositionCommand | func (mysqlFlavor) waitUntilPositionCommand(ctx context.Context, pos Position) (string, error) {
// A timeout of 0 means wait indefinitely.
timeoutSeconds := 0
if deadline, ok := ctx.Deadline(); ok {
timeout := time.Until(deadline)
if timeout <= 0 {
return "", vterrors.Errorf(vtrpc.Code_DEADLINE_EXCEEDED, "ti... | go | func (mysqlFlavor) waitUntilPositionCommand(ctx context.Context, pos Position) (string, error) {
// A timeout of 0 means wait indefinitely.
timeoutSeconds := 0
if deadline, ok := ctx.Deadline(); ok {
timeout := time.Until(deadline)
if timeout <= 0 {
return "", vterrors.Errorf(vtrpc.Code_DEADLINE_EXCEEDED, "ti... | [
"func",
"(",
"mysqlFlavor",
")",
"waitUntilPositionCommand",
"(",
"ctx",
"context",
".",
"Context",
",",
"pos",
"Position",
")",
"(",
"string",
",",
"error",
")",
"{",
"// A timeout of 0 means wait indefinitely.",
"timeoutSeconds",
":=",
"0",
"\n",
"if",
"deadline... | // waitUntilPositionCommand is part of the Flavor interface. | [
"waitUntilPositionCommand",
"is",
"part",
"of",
"the",
"Flavor",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/flavor_mysql.go#L117-L135 | 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.