repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
vitessio/vitess | go/vt/vtgate/safe_session.go | SetAutocommitable | func (session *SafeSession) SetAutocommitable(flag bool) {
session.mu.Lock()
defer session.mu.Unlock()
if session.autocommitState == autocommitted {
panic("BUG: SetAutocommitable: unexpected autocommit state")
}
if flag {
session.autocommitState = autocommittable
} else {
session.autocommitState = notAuto... | go | func (session *SafeSession) SetAutocommitable(flag bool) {
session.mu.Lock()
defer session.mu.Unlock()
if session.autocommitState == autocommitted {
panic("BUG: SetAutocommitable: unexpected autocommit state")
}
if flag {
session.autocommitState = autocommittable
} else {
session.autocommitState = notAuto... | [
"func",
"(",
"session",
"*",
"SafeSession",
")",
"SetAutocommitable",
"(",
"flag",
"bool",
")",
"{",
"session",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"session",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"session",
".",
"autocommitSta... | // SetAutocommitable sets the state to autocommitable if true.
// Otherwise, it's notAutocommitable. | [
"SetAutocommitable",
"sets",
"the",
"state",
"to",
"autocommitable",
"if",
"true",
".",
"Otherwise",
"it",
"s",
"notAutocommitable",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/safe_session.go#L83-L96 | train |
vitessio/vitess | go/vt/vtgate/safe_session.go | AutocommitApproval | func (session *SafeSession) AutocommitApproval() bool {
session.mu.Lock()
defer session.mu.Unlock()
if session.autocommitState == autocommitted {
panic("BUG: AutocommitToken: unexpected autocommit state")
}
if session.autocommitState == autocommittable && len(session.ShardSessions) == 0 {
session.autocommitS... | go | func (session *SafeSession) AutocommitApproval() bool {
session.mu.Lock()
defer session.mu.Unlock()
if session.autocommitState == autocommitted {
panic("BUG: AutocommitToken: unexpected autocommit state")
}
if session.autocommitState == autocommittable && len(session.ShardSessions) == 0 {
session.autocommitS... | [
"func",
"(",
"session",
"*",
"SafeSession",
")",
"AutocommitApproval",
"(",
")",
"bool",
"{",
"session",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"session",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"session",
".",
"autocommitState",
"=... | // AutocommitApproval returns true if we can perform a single round-trip
// autocommit. If so, the caller is responsible for committing their
// transaction. | [
"AutocommitApproval",
"returns",
"true",
"if",
"we",
"can",
"perform",
"a",
"single",
"round",
"-",
"trip",
"autocommit",
".",
"If",
"so",
"the",
"caller",
"is",
"responsible",
"for",
"committing",
"their",
"transaction",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/safe_session.go#L101-L114 | train |
vitessio/vitess | go/vt/vtgate/safe_session.go | InTransaction | func (session *SafeSession) InTransaction() bool {
if session == nil || session.Session == nil {
return false
}
session.mu.Lock()
defer session.mu.Unlock()
return session.Session.InTransaction
} | go | func (session *SafeSession) InTransaction() bool {
if session == nil || session.Session == nil {
return false
}
session.mu.Lock()
defer session.mu.Unlock()
return session.Session.InTransaction
} | [
"func",
"(",
"session",
"*",
"SafeSession",
")",
"InTransaction",
"(",
")",
"bool",
"{",
"if",
"session",
"==",
"nil",
"||",
"session",
".",
"Session",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"session",
".",
"mu",
".",
"Lock",
"(",
")",... | // InTransaction returns true if we are in a transaction | [
"InTransaction",
"returns",
"true",
"if",
"we",
"are",
"in",
"a",
"transaction"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/safe_session.go#L117-L124 | train |
vitessio/vitess | go/vt/vtgate/safe_session.go | Find | func (session *SafeSession) Find(keyspace, shard string, tabletType topodatapb.TabletType) int64 {
if session == nil {
return 0
}
session.mu.Lock()
defer session.mu.Unlock()
for _, shardSession := range session.ShardSessions {
if keyspace == shardSession.Target.Keyspace && tabletType == shardSession.Target.Tab... | go | func (session *SafeSession) Find(keyspace, shard string, tabletType topodatapb.TabletType) int64 {
if session == nil {
return 0
}
session.mu.Lock()
defer session.mu.Unlock()
for _, shardSession := range session.ShardSessions {
if keyspace == shardSession.Target.Keyspace && tabletType == shardSession.Target.Tab... | [
"func",
"(",
"session",
"*",
"SafeSession",
")",
"Find",
"(",
"keyspace",
",",
"shard",
"string",
",",
"tabletType",
"topodatapb",
".",
"TabletType",
")",
"int64",
"{",
"if",
"session",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"session",
".",
... | // Find returns the transactionId, if any, for a session | [
"Find",
"returns",
"the",
"transactionId",
"if",
"any",
"for",
"a",
"session"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/safe_session.go#L127-L139 | train |
vitessio/vitess | go/vt/vtgate/safe_session.go | Append | func (session *SafeSession) Append(shardSession *vtgatepb.Session_ShardSession, txMode vtgatepb.TransactionMode) error {
session.mu.Lock()
defer session.mu.Unlock()
if session.autocommitState == autocommitted {
panic("BUG: SafeSession.Append: unexpected autocommit state")
}
// Always append, in order for rollb... | go | func (session *SafeSession) Append(shardSession *vtgatepb.Session_ShardSession, txMode vtgatepb.TransactionMode) error {
session.mu.Lock()
defer session.mu.Unlock()
if session.autocommitState == autocommitted {
panic("BUG: SafeSession.Append: unexpected autocommit state")
}
// Always append, in order for rollb... | [
"func",
"(",
"session",
"*",
"SafeSession",
")",
"Append",
"(",
"shardSession",
"*",
"vtgatepb",
".",
"Session_ShardSession",
",",
"txMode",
"vtgatepb",
".",
"TransactionMode",
")",
"error",
"{",
"session",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
... | // Append adds a new ShardSession | [
"Append",
"adds",
"a",
"new",
"ShardSession"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/safe_session.go#L142-L157 | train |
vitessio/vitess | go/vt/vtgate/safe_session.go | SetRollback | func (session *SafeSession) SetRollback() {
if session == nil || session.Session == nil || !session.Session.InTransaction {
return
}
session.mu.Lock()
defer session.mu.Unlock()
session.mustRollback = true
} | go | func (session *SafeSession) SetRollback() {
if session == nil || session.Session == nil || !session.Session.InTransaction {
return
}
session.mu.Lock()
defer session.mu.Unlock()
session.mustRollback = true
} | [
"func",
"(",
"session",
"*",
"SafeSession",
")",
"SetRollback",
"(",
")",
"{",
"if",
"session",
"==",
"nil",
"||",
"session",
".",
"Session",
"==",
"nil",
"||",
"!",
"session",
".",
"Session",
".",
"InTransaction",
"{",
"return",
"\n",
"}",
"\n",
"sess... | // SetRollback sets the flag indicating that the transaction must be rolled back.
// The call is a no-op if the session is not in a transaction. | [
"SetRollback",
"sets",
"the",
"flag",
"indicating",
"that",
"the",
"transaction",
"must",
"be",
"rolled",
"back",
".",
"The",
"call",
"is",
"a",
"no",
"-",
"op",
"if",
"the",
"session",
"is",
"not",
"in",
"a",
"transaction",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/safe_session.go#L167-L174 | train |
vitessio/vitess | go/vt/vtgate/safe_session.go | MustRollback | func (session *SafeSession) MustRollback() bool {
if session == nil {
return false
}
session.mu.Lock()
defer session.mu.Unlock()
return session.mustRollback
} | go | func (session *SafeSession) MustRollback() bool {
if session == nil {
return false
}
session.mu.Lock()
defer session.mu.Unlock()
return session.mustRollback
} | [
"func",
"(",
"session",
"*",
"SafeSession",
")",
"MustRollback",
"(",
")",
"bool",
"{",
"if",
"session",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"session",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"session",
".",
"mu",
".",
"U... | // MustRollback returns true if the transaction must be rolled back. | [
"MustRollback",
"returns",
"true",
"if",
"the",
"transaction",
"must",
"be",
"rolled",
"back",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/safe_session.go#L177-L184 | train |
vitessio/vitess | go/vt/vtgate/safe_session.go | RecordWarning | func (session *SafeSession) RecordWarning(warning *querypb.QueryWarning) {
session.mu.Lock()
defer session.mu.Unlock()
session.Session.Warnings = append(session.Session.Warnings, warning)
} | go | func (session *SafeSession) RecordWarning(warning *querypb.QueryWarning) {
session.mu.Lock()
defer session.mu.Unlock()
session.Session.Warnings = append(session.Session.Warnings, warning)
} | [
"func",
"(",
"session",
"*",
"SafeSession",
")",
"RecordWarning",
"(",
"warning",
"*",
"querypb",
".",
"QueryWarning",
")",
"{",
"session",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"session",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"session",... | // RecordWarning stores the given warning in the session | [
"RecordWarning",
"stores",
"the",
"given",
"warning",
"in",
"the",
"session"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/safe_session.go#L187-L191 | train |
vitessio/vitess | go/vt/vtgate/safe_session.go | ClearWarnings | func (session *SafeSession) ClearWarnings() {
session.mu.Lock()
defer session.mu.Unlock()
session.Session.Warnings = nil
} | go | func (session *SafeSession) ClearWarnings() {
session.mu.Lock()
defer session.mu.Unlock()
session.Session.Warnings = nil
} | [
"func",
"(",
"session",
"*",
"SafeSession",
")",
"ClearWarnings",
"(",
")",
"{",
"session",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"session",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"session",
".",
"Session",
".",
"Warnings",
"=",
"nil",
... | // ClearWarnings removes all the warnings from the session | [
"ClearWarnings",
"removes",
"all",
"the",
"warnings",
"from",
"the",
"session"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/safe_session.go#L194-L198 | train |
vitessio/vitess | go/vt/vtgate/safe_session.go | Reset | func (session *SafeSession) Reset() {
if session == nil || session.Session == nil {
return
}
session.mu.Lock()
defer session.mu.Unlock()
session.mustRollback = false
session.autocommitState = notAutocommittable
session.Session.InTransaction = false
session.SingleDb = false
session.ShardSessions = nil
} | go | func (session *SafeSession) Reset() {
if session == nil || session.Session == nil {
return
}
session.mu.Lock()
defer session.mu.Unlock()
session.mustRollback = false
session.autocommitState = notAutocommittable
session.Session.InTransaction = false
session.SingleDb = false
session.ShardSessions = nil
} | [
"func",
"(",
"session",
"*",
"SafeSession",
")",
"Reset",
"(",
")",
"{",
"if",
"session",
"==",
"nil",
"||",
"session",
".",
"Session",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"session",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"sessio... | // Reset clears the session | [
"Reset",
"clears",
"the",
"session"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/safe_session.go#L201-L212 | train |
vitessio/vitess | go/vt/topo/srv_vschema.go | WatchSrvVSchema | func (ts *Server) WatchSrvVSchema(ctx context.Context, cell string) (*WatchSrvVSchemaData, <-chan *WatchSrvVSchemaData, CancelFunc) {
conn, err := ts.ConnForCell(ctx, cell)
if err != nil {
return &WatchSrvVSchemaData{Err: err}, nil, nil
}
current, wdChannel, cancel := conn.Watch(ctx, SrvVSchemaFile)
if current.... | go | func (ts *Server) WatchSrvVSchema(ctx context.Context, cell string) (*WatchSrvVSchemaData, <-chan *WatchSrvVSchemaData, CancelFunc) {
conn, err := ts.ConnForCell(ctx, cell)
if err != nil {
return &WatchSrvVSchemaData{Err: err}, nil, nil
}
current, wdChannel, cancel := conn.Watch(ctx, SrvVSchemaFile)
if current.... | [
"func",
"(",
"ts",
"*",
"Server",
")",
"WatchSrvVSchema",
"(",
"ctx",
"context",
".",
"Context",
",",
"cell",
"string",
")",
"(",
"*",
"WatchSrvVSchemaData",
",",
"<-",
"chan",
"*",
"WatchSrvVSchemaData",
",",
"CancelFunc",
")",
"{",
"conn",
",",
"err",
... | // WatchSrvVSchema will set a watch on the SrvVSchema object.
// It has the same contract as Conn.Watch, but it also unpacks the
// contents into a SrvVSchema object. | [
"WatchSrvVSchema",
"will",
"set",
"a",
"watch",
"on",
"the",
"SrvVSchema",
"object",
".",
"It",
"has",
"the",
"same",
"contract",
"as",
"Conn",
".",
"Watch",
"but",
"it",
"also",
"unpacks",
"the",
"contents",
"into",
"a",
"SrvVSchema",
"object",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/srv_vschema.go#L39-L90 | train |
vitessio/vitess | go/vt/topo/srv_vschema.go | UpdateSrvVSchema | func (ts *Server) UpdateSrvVSchema(ctx context.Context, cell string, srvVSchema *vschemapb.SrvVSchema) error {
conn, err := ts.ConnForCell(ctx, cell)
if err != nil {
return err
}
nodePath := SrvVSchemaFile
data, err := proto.Marshal(srvVSchema)
if err != nil {
return err
}
_, err = conn.Update(ctx, nodePat... | go | func (ts *Server) UpdateSrvVSchema(ctx context.Context, cell string, srvVSchema *vschemapb.SrvVSchema) error {
conn, err := ts.ConnForCell(ctx, cell)
if err != nil {
return err
}
nodePath := SrvVSchemaFile
data, err := proto.Marshal(srvVSchema)
if err != nil {
return err
}
_, err = conn.Update(ctx, nodePat... | [
"func",
"(",
"ts",
"*",
"Server",
")",
"UpdateSrvVSchema",
"(",
"ctx",
"context",
".",
"Context",
",",
"cell",
"string",
",",
"srvVSchema",
"*",
"vschemapb",
".",
"SrvVSchema",
")",
"error",
"{",
"conn",
",",
"err",
":=",
"ts",
".",
"ConnForCell",
"(",
... | // UpdateSrvVSchema updates the SrvVSchema file for a cell. | [
"UpdateSrvVSchema",
"updates",
"the",
"SrvVSchema",
"file",
"for",
"a",
"cell",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/srv_vschema.go#L93-L106 | train |
vitessio/vitess | go/vt/topo/srv_vschema.go | GetSrvVSchema | func (ts *Server) GetSrvVSchema(ctx context.Context, cell string) (*vschemapb.SrvVSchema, error) {
conn, err := ts.ConnForCell(ctx, cell)
if err != nil {
return nil, err
}
nodePath := SrvVSchemaFile
data, _, err := conn.Get(ctx, nodePath)
if err != nil {
return nil, err
}
srvVSchema := &vschemapb.SrvVSchem... | go | func (ts *Server) GetSrvVSchema(ctx context.Context, cell string) (*vschemapb.SrvVSchema, error) {
conn, err := ts.ConnForCell(ctx, cell)
if err != nil {
return nil, err
}
nodePath := SrvVSchemaFile
data, _, err := conn.Get(ctx, nodePath)
if err != nil {
return nil, err
}
srvVSchema := &vschemapb.SrvVSchem... | [
"func",
"(",
"ts",
"*",
"Server",
")",
"GetSrvVSchema",
"(",
"ctx",
"context",
".",
"Context",
",",
"cell",
"string",
")",
"(",
"*",
"vschemapb",
".",
"SrvVSchema",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"ts",
".",
"ConnForCell",
"(",
"ctx... | // GetSrvVSchema returns the SrvVSchema for a cell. | [
"GetSrvVSchema",
"returns",
"the",
"SrvVSchema",
"for",
"a",
"cell",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/srv_vschema.go#L109-L125 | train |
vitessio/vitess | go/vt/topo/srv_vschema.go | DeleteSrvVSchema | func (ts *Server) DeleteSrvVSchema(ctx context.Context, cell string) error {
conn, err := ts.ConnForCell(ctx, cell)
if err != nil {
return err
}
nodePath := SrvVSchemaFile
return conn.Delete(ctx, nodePath, nil)
} | go | func (ts *Server) DeleteSrvVSchema(ctx context.Context, cell string) error {
conn, err := ts.ConnForCell(ctx, cell)
if err != nil {
return err
}
nodePath := SrvVSchemaFile
return conn.Delete(ctx, nodePath, nil)
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"DeleteSrvVSchema",
"(",
"ctx",
"context",
".",
"Context",
",",
"cell",
"string",
")",
"error",
"{",
"conn",
",",
"err",
":=",
"ts",
".",
"ConnForCell",
"(",
"ctx",
",",
"cell",
")",
"\n",
"if",
"err",
"!=",
"... | // DeleteSrvVSchema deletes the SrvVSchema file for a cell. | [
"DeleteSrvVSchema",
"deletes",
"the",
"SrvVSchema",
"file",
"for",
"a",
"cell",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/srv_vschema.go#L128-L136 | train |
vitessio/vitess | go/vt/vtgate/engine/delete.go | MarshalJSON | func (del *Delete) MarshalJSON() ([]byte, error) {
var tname, vindexName string
if del.Table != nil {
tname = del.Table.Name.String()
}
if del.Vindex != nil {
vindexName = del.Vindex.String()
}
marshalDelete := struct {
Opcode DeleteOpcode
Keyspace *vindexes.Keyspace `json:",om... | go | func (del *Delete) MarshalJSON() ([]byte, error) {
var tname, vindexName string
if del.Table != nil {
tname = del.Table.Name.String()
}
if del.Vindex != nil {
vindexName = del.Vindex.String()
}
marshalDelete := struct {
Opcode DeleteOpcode
Keyspace *vindexes.Keyspace `json:",om... | [
"func",
"(",
"del",
"*",
"Delete",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"tname",
",",
"vindexName",
"string",
"\n",
"if",
"del",
".",
"Table",
"!=",
"nil",
"{",
"tname",
"=",
"del",
".",
"Table",
"."... | // MarshalJSON serializes the Delete into a JSON representation.
// It's used for testing and diagnostics. | [
"MarshalJSON",
"serializes",
"the",
"Delete",
"into",
"a",
"JSON",
"representation",
".",
"It",
"s",
"used",
"for",
"testing",
"and",
"diagnostics",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/engine/delete.go#L74-L104 | train |
vitessio/vitess | go/vt/topo/keyspace.go | GetServedFrom | func (ki *KeyspaceInfo) GetServedFrom(tabletType topodatapb.TabletType) *topodatapb.Keyspace_ServedFrom {
for _, ksf := range ki.ServedFroms {
if ksf.TabletType == tabletType {
return ksf
}
}
return nil
} | go | func (ki *KeyspaceInfo) GetServedFrom(tabletType topodatapb.TabletType) *topodatapb.Keyspace_ServedFrom {
for _, ksf := range ki.ServedFroms {
if ksf.TabletType == tabletType {
return ksf
}
}
return nil
} | [
"func",
"(",
"ki",
"*",
"KeyspaceInfo",
")",
"GetServedFrom",
"(",
"tabletType",
"topodatapb",
".",
"TabletType",
")",
"*",
"topodatapb",
".",
"Keyspace_ServedFrom",
"{",
"for",
"_",
",",
"ksf",
":=",
"range",
"ki",
".",
"ServedFroms",
"{",
"if",
"ksf",
".... | // GetServedFrom returns a Keyspace_ServedFrom record if it exists. | [
"GetServedFrom",
"returns",
"a",
"Keyspace_ServedFrom",
"record",
"if",
"it",
"exists",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/keyspace.go#L53-L60 | train |
vitessio/vitess | go/vt/topo/keyspace.go | CheckServedFromMigration | func (ki *KeyspaceInfo) CheckServedFromMigration(tabletType topodatapb.TabletType, cells []string, keyspace string, remove bool) error {
// master is a special case with a few extra checks
if tabletType == topodatapb.TabletType_MASTER {
if !remove {
return vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "cannot ... | go | func (ki *KeyspaceInfo) CheckServedFromMigration(tabletType topodatapb.TabletType, cells []string, keyspace string, remove bool) error {
// master is a special case with a few extra checks
if tabletType == topodatapb.TabletType_MASTER {
if !remove {
return vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "cannot ... | [
"func",
"(",
"ki",
"*",
"KeyspaceInfo",
")",
"CheckServedFromMigration",
"(",
"tabletType",
"topodatapb",
".",
"TabletType",
",",
"cells",
"[",
"]",
"string",
",",
"keyspace",
"string",
",",
"remove",
"bool",
")",
"error",
"{",
"// master is a special case with a ... | // CheckServedFromMigration makes sure a requested migration is safe | [
"CheckServedFromMigration",
"makes",
"sure",
"a",
"requested",
"migration",
"is",
"safe"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/keyspace.go#L63-L90 | train |
vitessio/vitess | go/vt/topo/keyspace.go | UpdateServedFromMap | func (ki *KeyspaceInfo) UpdateServedFromMap(tabletType topodatapb.TabletType, cells []string, keyspace string, remove bool, allCells []string) error {
// check parameters to be sure
if err := ki.CheckServedFromMigration(tabletType, cells, keyspace, remove); err != nil {
return err
}
ksf := ki.GetServedFrom(table... | go | func (ki *KeyspaceInfo) UpdateServedFromMap(tabletType topodatapb.TabletType, cells []string, keyspace string, remove bool, allCells []string) error {
// check parameters to be sure
if err := ki.CheckServedFromMigration(tabletType, cells, keyspace, remove); err != nil {
return err
}
ksf := ki.GetServedFrom(table... | [
"func",
"(",
"ki",
"*",
"KeyspaceInfo",
")",
"UpdateServedFromMap",
"(",
"tabletType",
"topodatapb",
".",
"TabletType",
",",
"cells",
"[",
"]",
"string",
",",
"keyspace",
"string",
",",
"remove",
"bool",
",",
"allCells",
"[",
"]",
"string",
")",
"error",
"... | // UpdateServedFromMap handles ServedFromMap. It can add or remove
// records, cells, ... | [
"UpdateServedFromMap",
"handles",
"ServedFromMap",
".",
"It",
"can",
"add",
"or",
"remove",
"records",
"cells",
"..."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/keyspace.go#L94-L139 | train |
vitessio/vitess | go/vt/topo/keyspace.go | ComputeCellServedFrom | func (ki *KeyspaceInfo) ComputeCellServedFrom(cell string) []*topodatapb.SrvKeyspace_ServedFrom {
var result []*topodatapb.SrvKeyspace_ServedFrom
for _, ksf := range ki.ServedFroms {
if InCellList(cell, ksf.Cells) {
result = append(result, &topodatapb.SrvKeyspace_ServedFrom{
TabletType: ksf.TabletType,
K... | go | func (ki *KeyspaceInfo) ComputeCellServedFrom(cell string) []*topodatapb.SrvKeyspace_ServedFrom {
var result []*topodatapb.SrvKeyspace_ServedFrom
for _, ksf := range ki.ServedFroms {
if InCellList(cell, ksf.Cells) {
result = append(result, &topodatapb.SrvKeyspace_ServedFrom{
TabletType: ksf.TabletType,
K... | [
"func",
"(",
"ki",
"*",
"KeyspaceInfo",
")",
"ComputeCellServedFrom",
"(",
"cell",
"string",
")",
"[",
"]",
"*",
"topodatapb",
".",
"SrvKeyspace_ServedFrom",
"{",
"var",
"result",
"[",
"]",
"*",
"topodatapb",
".",
"SrvKeyspace_ServedFrom",
"\n",
"for",
"_",
... | // ComputeCellServedFrom returns the ServedFrom list for a cell | [
"ComputeCellServedFrom",
"returns",
"the",
"ServedFrom",
"list",
"for",
"a",
"cell"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/keyspace.go#L142-L153 | train |
vitessio/vitess | go/vt/topo/keyspace.go | CreateKeyspace | func (ts *Server) CreateKeyspace(ctx context.Context, keyspace string, value *topodatapb.Keyspace) error {
data, err := proto.Marshal(value)
if err != nil {
return err
}
keyspacePath := path.Join(KeyspacesPath, keyspace, KeyspaceFile)
if _, err := ts.globalCell.Create(ctx, keyspacePath, data); err != nil {
re... | go | func (ts *Server) CreateKeyspace(ctx context.Context, keyspace string, value *topodatapb.Keyspace) error {
data, err := proto.Marshal(value)
if err != nil {
return err
}
keyspacePath := path.Join(KeyspacesPath, keyspace, KeyspaceFile)
if _, err := ts.globalCell.Create(ctx, keyspacePath, data); err != nil {
re... | [
"func",
"(",
"ts",
"*",
"Server",
")",
"CreateKeyspace",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
",",
"value",
"*",
"topodatapb",
".",
"Keyspace",
")",
"error",
"{",
"data",
",",
"err",
":=",
"proto",
".",
"Marshal",
"(",
"val... | // CreateKeyspace wraps the underlying Conn.Create
// and dispatches the event. | [
"CreateKeyspace",
"wraps",
"the",
"underlying",
"Conn",
".",
"Create",
"and",
"dispatches",
"the",
"event",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/keyspace.go#L157-L173 | train |
vitessio/vitess | go/vt/topo/keyspace.go | GetKeyspace | func (ts *Server) GetKeyspace(ctx context.Context, keyspace string) (*KeyspaceInfo, error) {
keyspacePath := path.Join(KeyspacesPath, keyspace, KeyspaceFile)
data, version, err := ts.globalCell.Get(ctx, keyspacePath)
if err != nil {
return nil, err
}
k := &topodatapb.Keyspace{}
if err = proto.Unmarshal(data, k... | go | func (ts *Server) GetKeyspace(ctx context.Context, keyspace string) (*KeyspaceInfo, error) {
keyspacePath := path.Join(KeyspacesPath, keyspace, KeyspaceFile)
data, version, err := ts.globalCell.Get(ctx, keyspacePath)
if err != nil {
return nil, err
}
k := &topodatapb.Keyspace{}
if err = proto.Unmarshal(data, k... | [
"func",
"(",
"ts",
"*",
"Server",
")",
"GetKeyspace",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
")",
"(",
"*",
"KeyspaceInfo",
",",
"error",
")",
"{",
"keyspacePath",
":=",
"path",
".",
"Join",
"(",
"KeyspacesPath",
",",
"keyspace... | // GetKeyspace reads the given keyspace and returns it | [
"GetKeyspace",
"reads",
"the",
"given",
"keyspace",
"and",
"returns",
"it"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/keyspace.go#L176-L193 | train |
vitessio/vitess | go/vt/topo/keyspace.go | UpdateKeyspace | func (ts *Server) UpdateKeyspace(ctx context.Context, ki *KeyspaceInfo) error {
// make sure it is locked first
if err := CheckKeyspaceLocked(ctx, ki.keyspace); err != nil {
return err
}
data, err := proto.Marshal(ki.Keyspace)
if err != nil {
return err
}
keyspacePath := path.Join(KeyspacesPath, ki.keyspace... | go | func (ts *Server) UpdateKeyspace(ctx context.Context, ki *KeyspaceInfo) error {
// make sure it is locked first
if err := CheckKeyspaceLocked(ctx, ki.keyspace); err != nil {
return err
}
data, err := proto.Marshal(ki.Keyspace)
if err != nil {
return err
}
keyspacePath := path.Join(KeyspacesPath, ki.keyspace... | [
"func",
"(",
"ts",
"*",
"Server",
")",
"UpdateKeyspace",
"(",
"ctx",
"context",
".",
"Context",
",",
"ki",
"*",
"KeyspaceInfo",
")",
"error",
"{",
"// make sure it is locked first",
"if",
"err",
":=",
"CheckKeyspaceLocked",
"(",
"ctx",
",",
"ki",
".",
"keysp... | // UpdateKeyspace updates the keyspace data. It checks the keyspace is locked. | [
"UpdateKeyspace",
"updates",
"the",
"keyspace",
"data",
".",
"It",
"checks",
"the",
"keyspace",
"is",
"locked",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/keyspace.go#L196-L219 | train |
vitessio/vitess | go/vt/topo/keyspace.go | FindAllShardsInKeyspace | func (ts *Server) FindAllShardsInKeyspace(ctx context.Context, keyspace string) (map[string]*ShardInfo, error) {
shards, err := ts.GetShardNames(ctx, keyspace)
if err != nil {
return nil, vterrors.Wrapf(err, "failed to get list of shards for keyspace '%v'", keyspace)
}
result := make(map[string]*ShardInfo, len(s... | go | func (ts *Server) FindAllShardsInKeyspace(ctx context.Context, keyspace string) (map[string]*ShardInfo, error) {
shards, err := ts.GetShardNames(ctx, keyspace)
if err != nil {
return nil, vterrors.Wrapf(err, "failed to get list of shards for keyspace '%v'", keyspace)
}
result := make(map[string]*ShardInfo, len(s... | [
"func",
"(",
"ts",
"*",
"Server",
")",
"FindAllShardsInKeyspace",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"ShardInfo",
",",
"error",
")",
"{",
"shards",
",",
"err",
":=",
"ts",
".",
... | // FindAllShardsInKeyspace reads and returns all the existing shards in
// a keyspace. It doesn't take any lock. | [
"FindAllShardsInKeyspace",
"reads",
"and",
"returns",
"all",
"the",
"existing",
"shards",
"in",
"a",
"keyspace",
".",
"It",
"doesn",
"t",
"take",
"any",
"lock",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/keyspace.go#L223-L256 | train |
vitessio/vitess | go/vt/topo/keyspace.go | GetOnlyShard | func (ts *Server) GetOnlyShard(ctx context.Context, keyspace string) (*ShardInfo, error) {
allShards, err := ts.FindAllShardsInKeyspace(ctx, keyspace)
if err != nil {
return nil, err
}
if len(allShards) == 1 {
for _, s := range allShards {
return s, nil
}
}
return nil, vterrors.Errorf(vtrpc.Code_INVALID_... | go | func (ts *Server) GetOnlyShard(ctx context.Context, keyspace string) (*ShardInfo, error) {
allShards, err := ts.FindAllShardsInKeyspace(ctx, keyspace)
if err != nil {
return nil, err
}
if len(allShards) == 1 {
for _, s := range allShards {
return s, nil
}
}
return nil, vterrors.Errorf(vtrpc.Code_INVALID_... | [
"func",
"(",
"ts",
"*",
"Server",
")",
"GetOnlyShard",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
")",
"(",
"*",
"ShardInfo",
",",
"error",
")",
"{",
"allShards",
",",
"err",
":=",
"ts",
".",
"FindAllShardsInKeyspace",
"(",
"ctx",
... | // GetOnlyShard returns the single ShardInfo of an unsharded keyspace. | [
"GetOnlyShard",
"returns",
"the",
"single",
"ShardInfo",
"of",
"an",
"unsharded",
"keyspace",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/keyspace.go#L259-L270 | train |
vitessio/vitess | go/vt/topo/keyspace.go | DeleteKeyspace | func (ts *Server) DeleteKeyspace(ctx context.Context, keyspace string) error {
keyspacePath := path.Join(KeyspacesPath, keyspace, KeyspaceFile)
if err := ts.globalCell.Delete(ctx, keyspacePath, nil); err != nil {
return err
}
event.Dispatch(&events.KeyspaceChange{
KeyspaceName: keyspace,
Keyspace: nil,
... | go | func (ts *Server) DeleteKeyspace(ctx context.Context, keyspace string) error {
keyspacePath := path.Join(KeyspacesPath, keyspace, KeyspaceFile)
if err := ts.globalCell.Delete(ctx, keyspacePath, nil); err != nil {
return err
}
event.Dispatch(&events.KeyspaceChange{
KeyspaceName: keyspace,
Keyspace: nil,
... | [
"func",
"(",
"ts",
"*",
"Server",
")",
"DeleteKeyspace",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
")",
"error",
"{",
"keyspacePath",
":=",
"path",
".",
"Join",
"(",
"KeyspacesPath",
",",
"keyspace",
",",
"KeyspaceFile",
")",
"\n",
... | // DeleteKeyspace wraps the underlying Conn.Delete
// and dispatches the event. | [
"DeleteKeyspace",
"wraps",
"the",
"underlying",
"Conn",
".",
"Delete",
"and",
"dispatches",
"the",
"event",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/keyspace.go#L274-L285 | train |
vitessio/vitess | go/vt/topo/keyspace.go | GetKeyspaces | func (ts *Server) GetKeyspaces(ctx context.Context) ([]string, error) {
children, err := ts.globalCell.ListDir(ctx, KeyspacesPath, false /*full*/)
switch {
case err == nil:
return DirEntriesToStringArray(children), nil
case IsErrType(err, NoNode):
return nil, nil
default:
return nil, err
}
} | go | func (ts *Server) GetKeyspaces(ctx context.Context) ([]string, error) {
children, err := ts.globalCell.ListDir(ctx, KeyspacesPath, false /*full*/)
switch {
case err == nil:
return DirEntriesToStringArray(children), nil
case IsErrType(err, NoNode):
return nil, nil
default:
return nil, err
}
} | [
"func",
"(",
"ts",
"*",
"Server",
")",
"GetKeyspaces",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"children",
",",
"err",
":=",
"ts",
".",
"globalCell",
".",
"ListDir",
"(",
"ctx",
",",
"KeyspacesPath... | // GetKeyspaces returns the list of keyspaces in the topology. | [
"GetKeyspaces",
"returns",
"the",
"list",
"of",
"keyspaces",
"in",
"the",
"topology",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/keyspace.go#L288-L298 | train |
vitessio/vitess | go/vt/topo/keyspace.go | GetShardNames | func (ts *Server) GetShardNames(ctx context.Context, keyspace string) ([]string, error) {
shardsPath := path.Join(KeyspacesPath, keyspace, ShardsPath)
children, err := ts.globalCell.ListDir(ctx, shardsPath, false /*full*/)
if IsErrType(err, NoNode) {
// The directory doesn't exist, let's see if the keyspace
// i... | go | func (ts *Server) GetShardNames(ctx context.Context, keyspace string) ([]string, error) {
shardsPath := path.Join(KeyspacesPath, keyspace, ShardsPath)
children, err := ts.globalCell.ListDir(ctx, shardsPath, false /*full*/)
if IsErrType(err, NoNode) {
// The directory doesn't exist, let's see if the keyspace
// i... | [
"func",
"(",
"ts",
"*",
"Server",
")",
"GetShardNames",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"shardsPath",
":=",
"path",
".",
"Join",
"(",
"KeyspacesPath",
",",
"keyspac... | // GetShardNames returns the list of shards in a keyspace. | [
"GetShardNames",
"returns",
"the",
"list",
"of",
"shards",
"in",
"a",
"keyspace",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/keyspace.go#L301-L315 | train |
vitessio/vitess | go/vt/worker/vtworkerclient/interface.go | RegisterFactory | func RegisterFactory(name string, factory Factory) {
if _, ok := factories[name]; ok {
log.Fatalf("RegisterFactory: %s already exists", name)
}
factories[name] = factory
} | go | func RegisterFactory(name string, factory Factory) {
if _, ok := factories[name]; ok {
log.Fatalf("RegisterFactory: %s already exists", name)
}
factories[name] = factory
} | [
"func",
"RegisterFactory",
"(",
"name",
"string",
",",
"factory",
"Factory",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"factories",
"[",
"name",
"]",
";",
"ok",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"name",
")",
"\n",
"}",
"\n",
"factories",... | // RegisterFactory allows a client implementation to register itself. | [
"RegisterFactory",
"allows",
"a",
"client",
"implementation",
"to",
"register",
"itself",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/worker/vtworkerclient/interface.go#L49-L54 | train |
vitessio/vitess | go/sync2/semaphore.go | NewSemaphore | func NewSemaphore(count int, timeout time.Duration) *Semaphore {
sem := &Semaphore{
slots: make(chan struct{}, count),
timeout: timeout,
}
for i := 0; i < count; i++ {
sem.slots <- struct{}{}
}
return sem
} | go | func NewSemaphore(count int, timeout time.Duration) *Semaphore {
sem := &Semaphore{
slots: make(chan struct{}, count),
timeout: timeout,
}
for i := 0; i < count; i++ {
sem.slots <- struct{}{}
}
return sem
} | [
"func",
"NewSemaphore",
"(",
"count",
"int",
",",
"timeout",
"time",
".",
"Duration",
")",
"*",
"Semaphore",
"{",
"sem",
":=",
"&",
"Semaphore",
"{",
"slots",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"count",
")",
",",
"timeout",
":",
"time... | // NewSemaphore creates a Semaphore. The count parameter must be a positive
// number. A timeout of zero means that there is no timeout. | [
"NewSemaphore",
"creates",
"a",
"Semaphore",
".",
"The",
"count",
"parameter",
"must",
"be",
"a",
"positive",
"number",
".",
"A",
"timeout",
"of",
"zero",
"means",
"that",
"there",
"is",
"no",
"timeout",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/sync2/semaphore.go#L36-L45 | train |
vitessio/vitess | go/vt/topo/helpers/tee.go | NewTee | func NewTee(primary, secondary *topo.Server, reverseLockOrder bool) (*topo.Server, error) {
f := &TeeFactory{
primary: primary,
secondary: secondary,
reverseLockOrder: reverseLockOrder,
}
return topo.NewWithFactory(f, "" /*serverAddress*/, "" /*root*/)
} | go | func NewTee(primary, secondary *topo.Server, reverseLockOrder bool) (*topo.Server, error) {
f := &TeeFactory{
primary: primary,
secondary: secondary,
reverseLockOrder: reverseLockOrder,
}
return topo.NewWithFactory(f, "" /*serverAddress*/, "" /*root*/)
} | [
"func",
"NewTee",
"(",
"primary",
",",
"secondary",
"*",
"topo",
".",
"Server",
",",
"reverseLockOrder",
"bool",
")",
"(",
"*",
"topo",
".",
"Server",
",",
"error",
")",
"{",
"f",
":=",
"&",
"TeeFactory",
"{",
"primary",
":",
"primary",
",",
"secondary... | // NewTee returns a new topo.Server object. It uses a TeeFactory. | [
"NewTee",
"returns",
"a",
"new",
"topo",
".",
"Server",
"object",
".",
"It",
"uses",
"a",
"TeeFactory",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/helpers/tee.go#L75-L82 | train |
vitessio/vitess | go/vt/topo/helpers/tee.go | Watch | func (c *TeeConn) Watch(ctx context.Context, filePath string) (*topo.WatchData, <-chan *topo.WatchData, topo.CancelFunc) {
return c.primary.Watch(ctx, filePath)
} | go | func (c *TeeConn) Watch(ctx context.Context, filePath string) (*topo.WatchData, <-chan *topo.WatchData, topo.CancelFunc) {
return c.primary.Watch(ctx, filePath)
} | [
"func",
"(",
"c",
"*",
"TeeConn",
")",
"Watch",
"(",
"ctx",
"context",
".",
"Context",
",",
"filePath",
"string",
")",
"(",
"*",
"topo",
".",
"WatchData",
",",
"<-",
"chan",
"*",
"topo",
".",
"WatchData",
",",
"topo",
".",
"CancelFunc",
")",
"{",
"... | // Watch is part of the topo.Conn interface | [
"Watch",
"is",
"part",
"of",
"the",
"topo",
".",
"Conn",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/helpers/tee.go#L161-L163 | train |
vitessio/vitess | go/vt/topo/helpers/tee.go | NewMasterParticipation | func (c *TeeConn) NewMasterParticipation(name, id string) (topo.MasterParticipation, error) {
return c.primary.NewMasterParticipation(name, id)
} | go | func (c *TeeConn) NewMasterParticipation(name, id string) (topo.MasterParticipation, error) {
return c.primary.NewMasterParticipation(name, id)
} | [
"func",
"(",
"c",
"*",
"TeeConn",
")",
"NewMasterParticipation",
"(",
"name",
",",
"id",
"string",
")",
"(",
"topo",
".",
"MasterParticipation",
",",
"error",
")",
"{",
"return",
"c",
".",
"primary",
".",
"NewMasterParticipation",
"(",
"name",
",",
"id",
... | // NewMasterParticipation is part of the topo.Conn interface. | [
"NewMasterParticipation",
"is",
"part",
"of",
"the",
"topo",
".",
"Conn",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/helpers/tee.go#L227-L229 | train |
vitessio/vitess | go/vt/binlog/grpcbinlogstreamer/streamer.go | StreamKeyRange | func (server *UpdateStream) StreamKeyRange(req *binlogdatapb.StreamKeyRangeRequest, stream binlogservicepb.UpdateStream_StreamKeyRangeServer) (err error) {
defer server.updateStream.HandlePanic(&err)
return server.updateStream.StreamKeyRange(stream.Context(), req.Position, req.KeyRange, req.Charset, func(reply *binlo... | go | func (server *UpdateStream) StreamKeyRange(req *binlogdatapb.StreamKeyRangeRequest, stream binlogservicepb.UpdateStream_StreamKeyRangeServer) (err error) {
defer server.updateStream.HandlePanic(&err)
return server.updateStream.StreamKeyRange(stream.Context(), req.Position, req.KeyRange, req.Charset, func(reply *binlo... | [
"func",
"(",
"server",
"*",
"UpdateStream",
")",
"StreamKeyRange",
"(",
"req",
"*",
"binlogdatapb",
".",
"StreamKeyRangeRequest",
",",
"stream",
"binlogservicepb",
".",
"UpdateStream_StreamKeyRangeServer",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"server",
"."... | // StreamKeyRange is part of the binlogservicepb.UpdateStreamServer interface | [
"StreamKeyRange",
"is",
"part",
"of",
"the",
"binlogservicepb",
".",
"UpdateStreamServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/grpcbinlogstreamer/streamer.go#L40-L47 | train |
vitessio/vitess | go/vt/binlog/grpcbinlogstreamer/streamer.go | StreamTables | func (server *UpdateStream) StreamTables(req *binlogdatapb.StreamTablesRequest, stream binlogservicepb.UpdateStream_StreamTablesServer) (err error) {
defer server.updateStream.HandlePanic(&err)
return server.updateStream.StreamTables(stream.Context(), req.Position, req.Tables, req.Charset, func(reply *binlogdatapb.Bi... | go | func (server *UpdateStream) StreamTables(req *binlogdatapb.StreamTablesRequest, stream binlogservicepb.UpdateStream_StreamTablesServer) (err error) {
defer server.updateStream.HandlePanic(&err)
return server.updateStream.StreamTables(stream.Context(), req.Position, req.Tables, req.Charset, func(reply *binlogdatapb.Bi... | [
"func",
"(",
"server",
"*",
"UpdateStream",
")",
"StreamTables",
"(",
"req",
"*",
"binlogdatapb",
".",
"StreamTablesRequest",
",",
"stream",
"binlogservicepb",
".",
"UpdateStream_StreamTablesServer",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"server",
".",
"u... | // StreamTables is part of the binlogservicepb.UpdateStreamServer interface | [
"StreamTables",
"is",
"part",
"of",
"the",
"binlogservicepb",
".",
"UpdateStreamServer",
"interface"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/binlog/grpcbinlogstreamer/streamer.go#L50-L57 | train |
vitessio/vitess | go/mysql/binlog_event_make.go | NewMySQL56BinlogFormat | func NewMySQL56BinlogFormat() BinlogFormat {
return BinlogFormat{
FormatVersion: 4,
ServerVersion: "5.6.33-0ubuntu0.14.04.1-log",
HeaderLength: 19,
ChecksumAlgorithm: BinlogChecksumAlgCRC32, // most commonly used.
HeaderSizes: []byte{
56, 13, 0, 8, 0, 18, 0, 4, 4, 4,
4, 18, 0, 0, 92, 0, 4,... | go | func NewMySQL56BinlogFormat() BinlogFormat {
return BinlogFormat{
FormatVersion: 4,
ServerVersion: "5.6.33-0ubuntu0.14.04.1-log",
HeaderLength: 19,
ChecksumAlgorithm: BinlogChecksumAlgCRC32, // most commonly used.
HeaderSizes: []byte{
56, 13, 0, 8, 0, 18, 0, 4, 4, 4,
4, 18, 0, 0, 92, 0, 4,... | [
"func",
"NewMySQL56BinlogFormat",
"(",
")",
"BinlogFormat",
"{",
"return",
"BinlogFormat",
"{",
"FormatVersion",
":",
"4",
",",
"ServerVersion",
":",
"\"",
"\"",
",",
"HeaderLength",
":",
"19",
",",
"ChecksumAlgorithm",
":",
"BinlogChecksumAlgCRC32",
",",
"// most... | // This file contains utility methods to create binlog replication
// packets. They are mostly used for testing.
// NewMySQL56BinlogFormat returns a typical BinlogFormat for MySQL 5.6. | [
"This",
"file",
"contains",
"utility",
"methods",
"to",
"create",
"binlog",
"replication",
"packets",
".",
"They",
"are",
"mostly",
"used",
"for",
"testing",
".",
"NewMySQL56BinlogFormat",
"returns",
"a",
"typical",
"BinlogFormat",
"for",
"MySQL",
"5",
".",
"6",... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_make.go#L27-L39 | train |
vitessio/vitess | go/mysql/binlog_event_make.go | NewMariaDBBinlogFormat | func NewMariaDBBinlogFormat() BinlogFormat {
return BinlogFormat{
FormatVersion: 4,
ServerVersion: "10.0.13-MariaDB-1~precise-log",
HeaderLength: 19,
ChecksumAlgorithm: BinlogChecksumAlgOff,
// HeaderSizes is very long because the MariaDB specific events are indexed at 160+
HeaderSizes: []byte... | go | func NewMariaDBBinlogFormat() BinlogFormat {
return BinlogFormat{
FormatVersion: 4,
ServerVersion: "10.0.13-MariaDB-1~precise-log",
HeaderLength: 19,
ChecksumAlgorithm: BinlogChecksumAlgOff,
// HeaderSizes is very long because the MariaDB specific events are indexed at 160+
HeaderSizes: []byte... | [
"func",
"NewMariaDBBinlogFormat",
"(",
")",
"BinlogFormat",
"{",
"return",
"BinlogFormat",
"{",
"FormatVersion",
":",
"4",
",",
"ServerVersion",
":",
"\"",
"\"",
",",
"HeaderLength",
":",
"19",
",",
"ChecksumAlgorithm",
":",
"BinlogChecksumAlgOff",
",",
"// Header... | // NewMariaDBBinlogFormat returns a typical BinlogFormat for MariaDB 10.0. | [
"NewMariaDBBinlogFormat",
"returns",
"a",
"typical",
"BinlogFormat",
"for",
"MariaDB",
"10",
".",
"0",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_make.go#L42-L68 | train |
vitessio/vitess | go/mysql/binlog_event_make.go | Packetize | func (s *FakeBinlogStream) Packetize(f BinlogFormat, typ byte, flags uint16, data []byte) []byte {
length := int(f.HeaderLength) + len(data)
if typ == eFormatDescriptionEvent || f.ChecksumAlgorithm == BinlogChecksumAlgCRC32 {
// Just add 4 zeroes to the end.
length += 4
}
result := make([]byte, length)
binary... | go | func (s *FakeBinlogStream) Packetize(f BinlogFormat, typ byte, flags uint16, data []byte) []byte {
length := int(f.HeaderLength) + len(data)
if typ == eFormatDescriptionEvent || f.ChecksumAlgorithm == BinlogChecksumAlgCRC32 {
// Just add 4 zeroes to the end.
length += 4
}
result := make([]byte, length)
binary... | [
"func",
"(",
"s",
"*",
"FakeBinlogStream",
")",
"Packetize",
"(",
"f",
"BinlogFormat",
",",
"typ",
"byte",
",",
"flags",
"uint16",
",",
"data",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"length",
":=",
"int",
"(",
"f",
".",
"HeaderLength",
")",
... | // Packetize adds the binlog event header to a packet, and optionally
// the checksum. | [
"Packetize",
"adds",
"the",
"binlog",
"event",
"header",
"to",
"a",
"packet",
"and",
"optionally",
"the",
"checksum",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_make.go#L95-L113 | train |
vitessio/vitess | go/mysql/binlog_event_make.go | NewFormatDescriptionEvent | func NewFormatDescriptionEvent(f BinlogFormat, s *FakeBinlogStream) BinlogEvent {
length := 2 + // binlog-version
50 + // server version
4 + // create timestamp
1 + // event header length
len(f.HeaderSizes) + // event type header lengths
1 // (undocumented) checksum algorithm
data := make([]byte, length)
b... | go | func NewFormatDescriptionEvent(f BinlogFormat, s *FakeBinlogStream) BinlogEvent {
length := 2 + // binlog-version
50 + // server version
4 + // create timestamp
1 + // event header length
len(f.HeaderSizes) + // event type header lengths
1 // (undocumented) checksum algorithm
data := make([]byte, length)
b... | [
"func",
"NewFormatDescriptionEvent",
"(",
"f",
"BinlogFormat",
",",
"s",
"*",
"FakeBinlogStream",
")",
"BinlogEvent",
"{",
"length",
":=",
"2",
"+",
"// binlog-version",
"50",
"+",
"// server version",
"4",
"+",
"// create timestamp",
"1",
"+",
"// event header leng... | // NewFormatDescriptionEvent creates a new FormatDescriptionEvent
// based on the provided BinlogFormat. It uses a mysql56BinlogEvent
// but could use a MariaDB one. | [
"NewFormatDescriptionEvent",
"creates",
"a",
"new",
"FormatDescriptionEvent",
"based",
"on",
"the",
"provided",
"BinlogFormat",
".",
"It",
"uses",
"a",
"mysql56BinlogEvent",
"but",
"could",
"use",
"a",
"MariaDB",
"one",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_make.go#L123-L140 | train |
vitessio/vitess | go/mysql/binlog_event_make.go | NewRotateEvent | func NewRotateEvent(f BinlogFormat, s *FakeBinlogStream, position uint64, filename string) BinlogEvent {
length := 8 + // position
len(filename)
data := make([]byte, length)
binary.LittleEndian.PutUint64(data[0:8], position)
ev := s.Packetize(f, eRotateEvent, 0, data)
ev[0] = 0
ev[1] = 0
ev[2] = 0
ev[3] = 0
... | go | func NewRotateEvent(f BinlogFormat, s *FakeBinlogStream, position uint64, filename string) BinlogEvent {
length := 8 + // position
len(filename)
data := make([]byte, length)
binary.LittleEndian.PutUint64(data[0:8], position)
ev := s.Packetize(f, eRotateEvent, 0, data)
ev[0] = 0
ev[1] = 0
ev[2] = 0
ev[3] = 0
... | [
"func",
"NewRotateEvent",
"(",
"f",
"BinlogFormat",
",",
"s",
"*",
"FakeBinlogStream",
",",
"position",
"uint64",
",",
"filename",
"string",
")",
"BinlogEvent",
"{",
"length",
":=",
"8",
"+",
"// position",
"len",
"(",
"filename",
")",
"\n",
"data",
":=",
... | // NewRotateEvent returns a RotateEvent.
// The timestmap of such an event should be zero, so we patch it in. | [
"NewRotateEvent",
"returns",
"a",
"RotateEvent",
".",
"The",
"timestmap",
"of",
"such",
"an",
"event",
"should",
"be",
"zero",
"so",
"we",
"patch",
"it",
"in",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_make.go#L155-L167 | train |
vitessio/vitess | go/mysql/binlog_event_make.go | NewQueryEvent | func NewQueryEvent(f BinlogFormat, s *FakeBinlogStream, q Query) BinlogEvent {
statusVarLength := 0
if q.Charset != nil {
statusVarLength += 1 + 2 + 2 + 2
}
length := 4 + // slave proxy id
4 + // execution time
1 + // schema length
2 + // error code
2 + // status vars length
statusVarLength +
len(q.Da... | go | func NewQueryEvent(f BinlogFormat, s *FakeBinlogStream, q Query) BinlogEvent {
statusVarLength := 0
if q.Charset != nil {
statusVarLength += 1 + 2 + 2 + 2
}
length := 4 + // slave proxy id
4 + // execution time
1 + // schema length
2 + // error code
2 + // status vars length
statusVarLength +
len(q.Da... | [
"func",
"NewQueryEvent",
"(",
"f",
"BinlogFormat",
",",
"s",
"*",
"FakeBinlogStream",
",",
"q",
"Query",
")",
"BinlogEvent",
"{",
"statusVarLength",
":=",
"0",
"\n",
"if",
"q",
".",
"Charset",
"!=",
"nil",
"{",
"statusVarLength",
"+=",
"1",
"+",
"2",
"+"... | // NewQueryEvent makes up a QueryEvent based on the Query structure. | [
"NewQueryEvent",
"makes",
"up",
"a",
"QueryEvent",
"based",
"on",
"the",
"Query",
"structure",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_make.go#L170-L209 | train |
vitessio/vitess | go/mysql/binlog_event_make.go | NewInvalidQueryEvent | func NewInvalidQueryEvent(f BinlogFormat, s *FakeBinlogStream) BinlogEvent {
length := 100
data := make([]byte, length)
data[4+4] = 200 // > 100
ev := s.Packetize(f, eQueryEvent, 0, data)
return NewMysql56BinlogEvent(ev)
} | go | func NewInvalidQueryEvent(f BinlogFormat, s *FakeBinlogStream) BinlogEvent {
length := 100
data := make([]byte, length)
data[4+4] = 200 // > 100
ev := s.Packetize(f, eQueryEvent, 0, data)
return NewMysql56BinlogEvent(ev)
} | [
"func",
"NewInvalidQueryEvent",
"(",
"f",
"BinlogFormat",
",",
"s",
"*",
"FakeBinlogStream",
")",
"BinlogEvent",
"{",
"length",
":=",
"100",
"\n",
"data",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"length",
")",
"\n",
"data",
"[",
"4",
"+",
"4",
"]",
... | // NewInvalidQueryEvent returns an invalid QueryEvent. IsValid is however true.
// sqlPos is out of bounds. | [
"NewInvalidQueryEvent",
"returns",
"an",
"invalid",
"QueryEvent",
".",
"IsValid",
"is",
"however",
"true",
".",
"sqlPos",
"is",
"out",
"of",
"bounds",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_make.go#L213-L220 | train |
vitessio/vitess | go/mysql/binlog_event_make.go | NewXIDEvent | func NewXIDEvent(f BinlogFormat, s *FakeBinlogStream) BinlogEvent {
length := 8
data := make([]byte, length)
ev := s.Packetize(f, eXIDEvent, 0, data)
return NewMysql56BinlogEvent(ev)
} | go | func NewXIDEvent(f BinlogFormat, s *FakeBinlogStream) BinlogEvent {
length := 8
data := make([]byte, length)
ev := s.Packetize(f, eXIDEvent, 0, data)
return NewMysql56BinlogEvent(ev)
} | [
"func",
"NewXIDEvent",
"(",
"f",
"BinlogFormat",
",",
"s",
"*",
"FakeBinlogStream",
")",
"BinlogEvent",
"{",
"length",
":=",
"8",
"\n",
"data",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"length",
")",
"\n\n",
"ev",
":=",
"s",
".",
"Packetize",
"(",
"... | // NewXIDEvent returns a XID event. We do not use the data, so keep it 0. | [
"NewXIDEvent",
"returns",
"a",
"XID",
"event",
".",
"We",
"do",
"not",
"use",
"the",
"data",
"so",
"keep",
"it",
"0",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_make.go#L223-L229 | train |
vitessio/vitess | go/mysql/binlog_event_make.go | NewIntVarEvent | func NewIntVarEvent(f BinlogFormat, s *FakeBinlogStream, typ byte, value uint64) BinlogEvent {
length := 9
data := make([]byte, length)
data[0] = typ
data[1] = byte(value)
data[2] = byte(value >> 8)
data[3] = byte(value >> 16)
data[4] = byte(value >> 24)
data[5] = byte(value >> 32)
data[6] = byte(value >> 40)... | go | func NewIntVarEvent(f BinlogFormat, s *FakeBinlogStream, typ byte, value uint64) BinlogEvent {
length := 9
data := make([]byte, length)
data[0] = typ
data[1] = byte(value)
data[2] = byte(value >> 8)
data[3] = byte(value >> 16)
data[4] = byte(value >> 24)
data[5] = byte(value >> 32)
data[6] = byte(value >> 40)... | [
"func",
"NewIntVarEvent",
"(",
"f",
"BinlogFormat",
",",
"s",
"*",
"FakeBinlogStream",
",",
"typ",
"byte",
",",
"value",
"uint64",
")",
"BinlogEvent",
"{",
"length",
":=",
"9",
"\n",
"data",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"length",
")",
"\n\... | // NewIntVarEvent returns an IntVar event. | [
"NewIntVarEvent",
"returns",
"an",
"IntVar",
"event",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_make.go#L232-L248 | train |
vitessio/vitess | go/mysql/binlog_event_make.go | NewMariaDBGTIDEvent | func NewMariaDBGTIDEvent(f BinlogFormat, s *FakeBinlogStream, gtid MariadbGTID, hasBegin bool) BinlogEvent {
length := 8 + // sequence
4 + // domain
1 // flags2
data := make([]byte, length)
data[0] = byte(gtid.Sequence)
data[1] = byte(gtid.Sequence >> 8)
data[2] = byte(gtid.Sequence >> 16)
data[3] = byte(gti... | go | func NewMariaDBGTIDEvent(f BinlogFormat, s *FakeBinlogStream, gtid MariadbGTID, hasBegin bool) BinlogEvent {
length := 8 + // sequence
4 + // domain
1 // flags2
data := make([]byte, length)
data[0] = byte(gtid.Sequence)
data[1] = byte(gtid.Sequence >> 8)
data[2] = byte(gtid.Sequence >> 16)
data[3] = byte(gti... | [
"func",
"NewMariaDBGTIDEvent",
"(",
"f",
"BinlogFormat",
",",
"s",
"*",
"FakeBinlogStream",
",",
"gtid",
"MariadbGTID",
",",
"hasBegin",
"bool",
")",
"BinlogEvent",
"{",
"length",
":=",
"8",
"+",
"// sequence",
"4",
"+",
"// domain",
"1",
"// flags2",
"\n",
... | // NewMariaDBGTIDEvent returns a MariaDB specific GTID event.
// It ignores the Server in the gtid, instead uses the FakeBinlogStream.ServerID. | [
"NewMariaDBGTIDEvent",
"returns",
"a",
"MariaDB",
"specific",
"GTID",
"event",
".",
"It",
"ignores",
"the",
"Server",
"in",
"the",
"gtid",
"instead",
"uses",
"the",
"FakeBinlogStream",
".",
"ServerID",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_make.go#L252-L280 | train |
vitessio/vitess | go/mysql/binlog_event_make.go | NewTableMapEvent | func NewTableMapEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, tm *TableMap) BinlogEvent {
if f.HeaderSize(eTableMapEvent) != 8 {
panic("Not implemented, post_header_length!=8")
}
metadataLength := metadataTotalLength(tm.Types)
length := 6 + // table_id
2 + // flags
1 + // schema name length
l... | go | func NewTableMapEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, tm *TableMap) BinlogEvent {
if f.HeaderSize(eTableMapEvent) != 8 {
panic("Not implemented, post_header_length!=8")
}
metadataLength := metadataTotalLength(tm.Types)
length := 6 + // table_id
2 + // flags
1 + // schema name length
l... | [
"func",
"NewTableMapEvent",
"(",
"f",
"BinlogFormat",
",",
"s",
"*",
"FakeBinlogStream",
",",
"tableID",
"uint64",
",",
"tm",
"*",
"TableMap",
")",
"BinlogEvent",
"{",
"if",
"f",
".",
"HeaderSize",
"(",
"eTableMapEvent",
")",
"!=",
"8",
"{",
"panic",
"(",
... | // NewTableMapEvent returns a TableMap event.
// Only works with post_header_length=8. | [
"NewTableMapEvent",
"returns",
"a",
"TableMap",
"event",
".",
"Only",
"works",
"with",
"post_header_length",
"=",
"8",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_make.go#L284-L343 | train |
vitessio/vitess | go/mysql/binlog_event_make.go | NewWriteRowsEvent | func NewWriteRowsEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, rows Rows) BinlogEvent {
return newRowsEvent(f, s, eWriteRowsEventV2, tableID, rows)
} | go | func NewWriteRowsEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, rows Rows) BinlogEvent {
return newRowsEvent(f, s, eWriteRowsEventV2, tableID, rows)
} | [
"func",
"NewWriteRowsEvent",
"(",
"f",
"BinlogFormat",
",",
"s",
"*",
"FakeBinlogStream",
",",
"tableID",
"uint64",
",",
"rows",
"Rows",
")",
"BinlogEvent",
"{",
"return",
"newRowsEvent",
"(",
"f",
",",
"s",
",",
"eWriteRowsEventV2",
",",
"tableID",
",",
"ro... | // NewWriteRowsEvent returns a WriteRows event. Uses v2. | [
"NewWriteRowsEvent",
"returns",
"a",
"WriteRows",
"event",
".",
"Uses",
"v2",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_make.go#L346-L348 | train |
vitessio/vitess | go/mysql/binlog_event_make.go | NewUpdateRowsEvent | func NewUpdateRowsEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, rows Rows) BinlogEvent {
return newRowsEvent(f, s, eUpdateRowsEventV2, tableID, rows)
} | go | func NewUpdateRowsEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, rows Rows) BinlogEvent {
return newRowsEvent(f, s, eUpdateRowsEventV2, tableID, rows)
} | [
"func",
"NewUpdateRowsEvent",
"(",
"f",
"BinlogFormat",
",",
"s",
"*",
"FakeBinlogStream",
",",
"tableID",
"uint64",
",",
"rows",
"Rows",
")",
"BinlogEvent",
"{",
"return",
"newRowsEvent",
"(",
"f",
",",
"s",
",",
"eUpdateRowsEventV2",
",",
"tableID",
",",
"... | // NewUpdateRowsEvent returns an UpdateRows event. Uses v2. | [
"NewUpdateRowsEvent",
"returns",
"an",
"UpdateRows",
"event",
".",
"Uses",
"v2",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_make.go#L351-L353 | train |
vitessio/vitess | go/mysql/binlog_event_make.go | NewDeleteRowsEvent | func NewDeleteRowsEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, rows Rows) BinlogEvent {
return newRowsEvent(f, s, eDeleteRowsEventV2, tableID, rows)
} | go | func NewDeleteRowsEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, rows Rows) BinlogEvent {
return newRowsEvent(f, s, eDeleteRowsEventV2, tableID, rows)
} | [
"func",
"NewDeleteRowsEvent",
"(",
"f",
"BinlogFormat",
",",
"s",
"*",
"FakeBinlogStream",
",",
"tableID",
"uint64",
",",
"rows",
"Rows",
")",
"BinlogEvent",
"{",
"return",
"newRowsEvent",
"(",
"f",
",",
"s",
",",
"eDeleteRowsEventV2",
",",
"tableID",
",",
"... | // NewDeleteRowsEvent returns an DeleteRows event. Uses v2. | [
"NewDeleteRowsEvent",
"returns",
"an",
"DeleteRows",
"event",
".",
"Uses",
"v2",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/binlog_event_make.go#L356-L358 | train |
vitessio/vitess | go/timer/timer.go | NewTimer | func NewTimer(interval time.Duration) *Timer {
tm := &Timer{
msg: make(chan typeAction),
}
tm.interval.Set(interval)
return tm
} | go | func NewTimer(interval time.Duration) *Timer {
tm := &Timer{
msg: make(chan typeAction),
}
tm.interval.Set(interval)
return tm
} | [
"func",
"NewTimer",
"(",
"interval",
"time",
".",
"Duration",
")",
"*",
"Timer",
"{",
"tm",
":=",
"&",
"Timer",
"{",
"msg",
":",
"make",
"(",
"chan",
"typeAction",
")",
",",
"}",
"\n",
"tm",
".",
"interval",
".",
"Set",
"(",
"interval",
")",
"\n",
... | // NewTimer creates a new Timer object | [
"NewTimer",
"creates",
"a",
"new",
"Timer",
"object"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/timer/timer.go#L70-L76 | train |
vitessio/vitess | go/timer/timer.go | Start | func (tm *Timer) Start(keephouse func()) {
tm.mu.Lock()
defer tm.mu.Unlock()
if tm.running {
return
}
tm.running = true
go tm.run(keephouse)
} | go | func (tm *Timer) Start(keephouse func()) {
tm.mu.Lock()
defer tm.mu.Unlock()
if tm.running {
return
}
tm.running = true
go tm.run(keephouse)
} | [
"func",
"(",
"tm",
"*",
"Timer",
")",
"Start",
"(",
"keephouse",
"func",
"(",
")",
")",
"{",
"tm",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"tm",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"tm",
".",
"running",
"{",
"return",
"\n... | // Start starts the timer. | [
"Start",
"starts",
"the",
"timer",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/timer/timer.go#L79-L87 | train |
vitessio/vitess | go/timer/timer.go | SetInterval | func (tm *Timer) SetInterval(ns time.Duration) {
tm.interval.Set(ns)
tm.mu.Lock()
defer tm.mu.Unlock()
if tm.running {
tm.msg <- timerReset
}
} | go | func (tm *Timer) SetInterval(ns time.Duration) {
tm.interval.Set(ns)
tm.mu.Lock()
defer tm.mu.Unlock()
if tm.running {
tm.msg <- timerReset
}
} | [
"func",
"(",
"tm",
"*",
"Timer",
")",
"SetInterval",
"(",
"ns",
"time",
".",
"Duration",
")",
"{",
"tm",
".",
"interval",
".",
"Set",
"(",
"ns",
")",
"\n",
"tm",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"tm",
".",
"mu",
".",
"Unlock",
... | // SetInterval changes the wait interval.
// It will cause the timer to restart the wait. | [
"SetInterval",
"changes",
"the",
"wait",
"interval",
".",
"It",
"will",
"cause",
"the",
"timer",
"to",
"restart",
"the",
"wait",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/timer/timer.go#L118-L125 | train |
vitessio/vitess | go/timer/timer.go | Trigger | func (tm *Timer) Trigger() {
tm.mu.Lock()
defer tm.mu.Unlock()
if tm.running {
tm.msg <- timerTrigger
}
} | go | func (tm *Timer) Trigger() {
tm.mu.Lock()
defer tm.mu.Unlock()
if tm.running {
tm.msg <- timerTrigger
}
} | [
"func",
"(",
"tm",
"*",
"Timer",
")",
"Trigger",
"(",
")",
"{",
"tm",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"tm",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"tm",
".",
"running",
"{",
"tm",
".",
"msg",
"<-",
"timerTrigger",
"\... | // Trigger will cause the timer to immediately execute the keephouse function.
// It will then cause the timer to restart the wait. | [
"Trigger",
"will",
"cause",
"the",
"timer",
"to",
"immediately",
"execute",
"the",
"keephouse",
"function",
".",
"It",
"will",
"then",
"cause",
"the",
"timer",
"to",
"restart",
"the",
"wait",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/timer/timer.go#L129-L135 | train |
vitessio/vitess | go/timer/timer.go | TriggerAfter | func (tm *Timer) TriggerAfter(duration time.Duration) {
go func() {
time.Sleep(duration)
tm.Trigger()
}()
} | go | func (tm *Timer) TriggerAfter(duration time.Duration) {
go func() {
time.Sleep(duration)
tm.Trigger()
}()
} | [
"func",
"(",
"tm",
"*",
"Timer",
")",
"TriggerAfter",
"(",
"duration",
"time",
".",
"Duration",
")",
"{",
"go",
"func",
"(",
")",
"{",
"time",
".",
"Sleep",
"(",
"duration",
")",
"\n",
"tm",
".",
"Trigger",
"(",
")",
"\n",
"}",
"(",
")",
"\n",
... | // TriggerAfter waits for the specified duration and triggers the next event. | [
"TriggerAfter",
"waits",
"for",
"the",
"specified",
"duration",
"and",
"triggers",
"the",
"next",
"event",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/timer/timer.go#L138-L143 | train |
vitessio/vitess | go/timer/timer.go | Stop | func (tm *Timer) Stop() {
tm.mu.Lock()
defer tm.mu.Unlock()
if tm.running {
tm.msg <- timerStop
tm.running = false
}
} | go | func (tm *Timer) Stop() {
tm.mu.Lock()
defer tm.mu.Unlock()
if tm.running {
tm.msg <- timerStop
tm.running = false
}
} | [
"func",
"(",
"tm",
"*",
"Timer",
")",
"Stop",
"(",
")",
"{",
"tm",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"tm",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"tm",
".",
"running",
"{",
"tm",
".",
"msg",
"<-",
"timerStop",
"\n",
... | // Stop will stop the timer. It guarantees that the timer will not execute
// any more calls to keephouse once it has returned. | [
"Stop",
"will",
"stop",
"the",
"timer",
".",
"It",
"guarantees",
"that",
"the",
"timer",
"will",
"not",
"execute",
"any",
"more",
"calls",
"to",
"keephouse",
"once",
"it",
"has",
"returned",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/timer/timer.go#L147-L154 | train |
vitessio/vitess | go/vt/topo/locks.go | newLock | func newLock(action string) *Lock {
l := &Lock{
Action: action,
HostName: "unknown",
UserName: "unknown",
Time: time.Now().Format(time.RFC3339),
Status: "Running",
}
if h, err := os.Hostname(); err == nil {
l.HostName = h
}
if u, err := user.Current(); err == nil {
l.UserName = u.Username
}
... | go | func newLock(action string) *Lock {
l := &Lock{
Action: action,
HostName: "unknown",
UserName: "unknown",
Time: time.Now().Format(time.RFC3339),
Status: "Running",
}
if h, err := os.Hostname(); err == nil {
l.HostName = h
}
if u, err := user.Current(); err == nil {
l.UserName = u.Username
}
... | [
"func",
"newLock",
"(",
"action",
"string",
")",
"*",
"Lock",
"{",
"l",
":=",
"&",
"Lock",
"{",
"Action",
":",
"action",
",",
"HostName",
":",
"\"",
"\"",
",",
"UserName",
":",
"\"",
"\"",
",",
"Time",
":",
"time",
".",
"Now",
"(",
")",
".",
"F... | // newLock creates a new Lock. | [
"newLock",
"creates",
"a",
"new",
"Lock",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/locks.go#L70-L85 | train |
vitessio/vitess | go/vt/topo/locks.go | ToJSON | func (l *Lock) ToJSON() (string, error) {
data, err := json.MarshalIndent(l, "", " ")
if err != nil {
return "", vterrors.Wrapf(err, "cannot JSON-marshal node")
}
return string(data), nil
} | go | func (l *Lock) ToJSON() (string, error) {
data, err := json.MarshalIndent(l, "", " ")
if err != nil {
return "", vterrors.Wrapf(err, "cannot JSON-marshal node")
}
return string(data), nil
} | [
"func",
"(",
"l",
"*",
"Lock",
")",
"ToJSON",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"l",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retu... | // ToJSON returns a JSON representation of the object. | [
"ToJSON",
"returns",
"a",
"JSON",
"representation",
"of",
"the",
"object",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/locks.go#L88-L94 | train |
vitessio/vitess | go/vt/topo/locks.go | CheckKeyspaceLocked | func CheckKeyspaceLocked(ctx context.Context, keyspace string) error {
// extract the locksInfo pointer
i, ok := ctx.Value(locksKey).(*locksInfo)
if !ok {
return vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "keyspace %v is not locked (no locksInfo)", keyspace)
}
i.mu.Lock()
defer i.mu.Unlock()
// find the ind... | go | func CheckKeyspaceLocked(ctx context.Context, keyspace string) error {
// extract the locksInfo pointer
i, ok := ctx.Value(locksKey).(*locksInfo)
if !ok {
return vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "keyspace %v is not locked (no locksInfo)", keyspace)
}
i.mu.Lock()
defer i.mu.Unlock()
// find the ind... | [
"func",
"CheckKeyspaceLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
"string",
")",
"error",
"{",
"// extract the locksInfo pointer",
"i",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"locksKey",
")",
".",
"(",
"*",
"locksInfo",
")",
"\n",
... | // CheckKeyspaceLocked can be called on a context to make sure we have the lock
// for a given keyspace. | [
"CheckKeyspaceLocked",
"can",
"be",
"called",
"on",
"a",
"context",
"to",
"make",
"sure",
"we",
"have",
"the",
"lock",
"for",
"a",
"given",
"keyspace",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/locks.go#L193-L213 | train |
vitessio/vitess | go/vt/topo/locks.go | lockKeyspace | func (l *Lock) lockKeyspace(ctx context.Context, ts *Server, keyspace string) (LockDescriptor, error) {
log.Infof("Locking keyspace %v for action %v", keyspace, l.Action)
ctx, cancel := context.WithTimeout(ctx, *RemoteOperationTimeout)
defer cancel()
span, ctx := trace.NewSpan(ctx, "TopoServer.LockKeyspaceForActi... | go | func (l *Lock) lockKeyspace(ctx context.Context, ts *Server, keyspace string) (LockDescriptor, error) {
log.Infof("Locking keyspace %v for action %v", keyspace, l.Action)
ctx, cancel := context.WithTimeout(ctx, *RemoteOperationTimeout)
defer cancel()
span, ctx := trace.NewSpan(ctx, "TopoServer.LockKeyspaceForActi... | [
"func",
"(",
"l",
"*",
"Lock",
")",
"lockKeyspace",
"(",
"ctx",
"context",
".",
"Context",
",",
"ts",
"*",
"Server",
",",
"keyspace",
"string",
")",
"(",
"LockDescriptor",
",",
"error",
")",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"keyspace",... | // lockKeyspace will lock the keyspace in the topology server.
// unlockKeyspace should be called if this returns no error. | [
"lockKeyspace",
"will",
"lock",
"the",
"keyspace",
"in",
"the",
"topology",
"server",
".",
"unlockKeyspace",
"should",
"be",
"called",
"if",
"this",
"returns",
"no",
"error",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/locks.go#L217-L234 | train |
vitessio/vitess | go/vt/topo/locks.go | CheckShardLocked | func CheckShardLocked(ctx context.Context, keyspace, shard string) error {
// extract the locksInfo pointer
i, ok := ctx.Value(locksKey).(*locksInfo)
if !ok {
return vterrors.Errorf(vtrpc.Code_INTERNAL, "shard %v/%v is not locked (no locksInfo)", keyspace, shard)
}
i.mu.Lock()
defer i.mu.Unlock()
// func the ... | go | func CheckShardLocked(ctx context.Context, keyspace, shard string) error {
// extract the locksInfo pointer
i, ok := ctx.Value(locksKey).(*locksInfo)
if !ok {
return vterrors.Errorf(vtrpc.Code_INTERNAL, "shard %v/%v is not locked (no locksInfo)", keyspace, shard)
}
i.mu.Lock()
defer i.mu.Unlock()
// func the ... | [
"func",
"CheckShardLocked",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyspace",
",",
"shard",
"string",
")",
"error",
"{",
"// extract the locksInfo pointer",
"i",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"locksKey",
")",
".",
"(",
"*",
"locksInfo",
... | // CheckShardLocked can be called on a context to make sure we have the lock
// for a given shard. | [
"CheckShardLocked",
"can",
"be",
"called",
"on",
"a",
"context",
"to",
"make",
"sure",
"we",
"have",
"the",
"lock",
"for",
"a",
"given",
"shard",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/locks.go#L336-L354 | train |
vitessio/vitess | go/vt/topo/locks.go | unlockShard | func (l *Lock) unlockShard(ctx context.Context, ts *Server, keyspace, shard string, lockDescriptor LockDescriptor, actionError error) error {
// Detach from the parent timeout, but copy the trace span.
// We need to still release the lock even if the parent context timed out.
// Note that we are not using the user p... | go | func (l *Lock) unlockShard(ctx context.Context, ts *Server, keyspace, shard string, lockDescriptor LockDescriptor, actionError error) error {
// Detach from the parent timeout, but copy the trace span.
// We need to still release the lock even if the parent context timed out.
// Note that we are not using the user p... | [
"func",
"(",
"l",
"*",
"Lock",
")",
"unlockShard",
"(",
"ctx",
"context",
".",
"Context",
",",
"ts",
"*",
"Server",
",",
"keyspace",
",",
"shard",
"string",
",",
"lockDescriptor",
"LockDescriptor",
",",
"actionError",
"error",
")",
"error",
"{",
"// Detach... | // unlockShard unlocks a previously locked shard. | [
"unlockShard",
"unlocks",
"a",
"previously",
"locked",
"shard",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/topo/locks.go#L379-L403 | train |
vitessio/vitess | go/vt/tableacl/role.go | Name | func (r Role) Name() string {
if r < READER || r > ADMIN {
return ""
}
return roleNames[r]
} | go | func (r Role) Name() string {
if r < READER || r > ADMIN {
return ""
}
return roleNames[r]
} | [
"func",
"(",
"r",
"Role",
")",
"Name",
"(",
")",
"string",
"{",
"if",
"r",
"<",
"READER",
"||",
"r",
">",
"ADMIN",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"roleNames",
"[",
"r",
"]",
"\n",
"}"
] | // Name returns the name of a role | [
"Name",
"returns",
"the",
"name",
"of",
"a",
"role"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/tableacl/role.go#L44-L49 | train |
vitessio/vitess | go/vt/tableacl/role.go | RoleByName | func RoleByName(s string) (Role, bool) {
for i, v := range roleNames {
if v == strings.ToUpper(s) {
return Role(i), true
}
}
return NumRoles, false
} | go | func RoleByName(s string) (Role, bool) {
for i, v := range roleNames {
if v == strings.ToUpper(s) {
return Role(i), true
}
}
return NumRoles, false
} | [
"func",
"RoleByName",
"(",
"s",
"string",
")",
"(",
"Role",
",",
"bool",
")",
"{",
"for",
"i",
",",
"v",
":=",
"range",
"roleNames",
"{",
"if",
"v",
"==",
"strings",
".",
"ToUpper",
"(",
"s",
")",
"{",
"return",
"Role",
"(",
"i",
")",
",",
"tru... | // RoleByName returns the Role corresponding to a name | [
"RoleByName",
"returns",
"the",
"Role",
"corresponding",
"to",
"a",
"name"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/tableacl/role.go#L52-L59 | train |
vitessio/vitess | go/vt/srvtopo/resilient_server.go | NewResilientServer | func NewResilientServer(base *topo.Server, counterPrefix string) *ResilientServer {
if *srvTopoCacheRefresh > *srvTopoCacheTTL {
log.Fatalf("srv_topo_cache_refresh must be less than or equal to srv_topo_cache_ttl")
}
return &ResilientServer{
topoServer: base,
cacheTTL: *srvTopoCacheTTL,
cacheRefresh: ... | go | func NewResilientServer(base *topo.Server, counterPrefix string) *ResilientServer {
if *srvTopoCacheRefresh > *srvTopoCacheTTL {
log.Fatalf("srv_topo_cache_refresh must be less than or equal to srv_topo_cache_ttl")
}
return &ResilientServer{
topoServer: base,
cacheTTL: *srvTopoCacheTTL,
cacheRefresh: ... | [
"func",
"NewResilientServer",
"(",
"base",
"*",
"topo",
".",
"Server",
",",
"counterPrefix",
"string",
")",
"*",
"ResilientServer",
"{",
"if",
"*",
"srvTopoCacheRefresh",
">",
"*",
"srvTopoCacheTTL",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
")",
"\n",
"... | // NewResilientServer creates a new ResilientServer
// based on the provided topo.Server. | [
"NewResilientServer",
"creates",
"a",
"new",
"ResilientServer",
"based",
"on",
"the",
"provided",
"topo",
".",
"Server",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/srvtopo/resilient_server.go#L209-L223 | train |
vitessio/vitess | go/vt/srvtopo/resilient_server.go | GetSrvKeyspaceNames | func (server *ResilientServer) GetSrvKeyspaceNames(ctx context.Context, cell string) ([]string, error) {
server.counts.Add(queryCategory, 1)
// find the entry in the cache, add it if not there
key := cell
server.mutex.Lock()
entry, ok := server.srvKeyspaceNamesCache[key]
if !ok {
entry = &srvKeyspaceNamesEntry... | go | func (server *ResilientServer) GetSrvKeyspaceNames(ctx context.Context, cell string) ([]string, error) {
server.counts.Add(queryCategory, 1)
// find the entry in the cache, add it if not there
key := cell
server.mutex.Lock()
entry, ok := server.srvKeyspaceNamesCache[key]
if !ok {
entry = &srvKeyspaceNamesEntry... | [
"func",
"(",
"server",
"*",
"ResilientServer",
")",
"GetSrvKeyspaceNames",
"(",
"ctx",
"context",
".",
"Context",
",",
"cell",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"server",
".",
"counts",
".",
"Add",
"(",
"queryCategory",
",",... | // GetSrvKeyspaceNames returns all keyspace names for the given cell. | [
"GetSrvKeyspaceNames",
"returns",
"all",
"keyspace",
"names",
"for",
"the",
"given",
"cell",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/srvtopo/resilient_server.go#L231-L334 | train |
vitessio/vitess | go/vt/srvtopo/resilient_server.go | GetSrvKeyspace | func (server *ResilientServer) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error) {
entry := server.getSrvKeyspaceEntry(cell, keyspace)
// If the watch is already running, return the value
entry.mutex.RLock()
if entry.watchState == watchStateRunning {
v, e := entry.value,... | go | func (server *ResilientServer) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error) {
entry := server.getSrvKeyspaceEntry(cell, keyspace)
// If the watch is already running, return the value
entry.mutex.RLock()
if entry.watchState == watchStateRunning {
v, e := entry.value,... | [
"func",
"(",
"server",
"*",
"ResilientServer",
")",
"GetSrvKeyspace",
"(",
"ctx",
"context",
".",
"Context",
",",
"cell",
",",
"keyspace",
"string",
")",
"(",
"*",
"topodatapb",
".",
"SrvKeyspace",
",",
"error",
")",
"{",
"entry",
":=",
"server",
".",
"g... | // GetSrvKeyspace returns SrvKeyspace object for the given cell and keyspace. | [
"GetSrvKeyspace",
"returns",
"SrvKeyspace",
"object",
"for",
"the",
"given",
"cell",
"and",
"keyspace",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/srvtopo/resilient_server.go#L361-L421 | train |
vitessio/vitess | go/vt/srvtopo/resilient_server.go | watchSrvKeyspace | func (server *ResilientServer) watchSrvKeyspace(callerCtx context.Context, entry *srvKeyspaceEntry, cell, keyspace string) {
// We use a background context, as starting the watch should keep going
// even if the current query context is short-lived.
newCtx := context.Background()
current, changes, cancel := server.... | go | func (server *ResilientServer) watchSrvKeyspace(callerCtx context.Context, entry *srvKeyspaceEntry, cell, keyspace string) {
// We use a background context, as starting the watch should keep going
// even if the current query context is short-lived.
newCtx := context.Background()
current, changes, cancel := server.... | [
"func",
"(",
"server",
"*",
"ResilientServer",
")",
"watchSrvKeyspace",
"(",
"callerCtx",
"context",
".",
"Context",
",",
"entry",
"*",
"srvKeyspaceEntry",
",",
"cell",
",",
"keyspace",
"string",
")",
"{",
"// We use a background context, as starting the watch should ke... | // watchSrvKeyspace is started in a separate goroutine and attempts to establish
// a watch. The caller context is provided to show in the UI in case the watch
// fails due to an error like a mistyped keyspace. | [
"watchSrvKeyspace",
"is",
"started",
"in",
"a",
"separate",
"goroutine",
"and",
"attempts",
"to",
"establish",
"a",
"watch",
".",
"The",
"caller",
"context",
"is",
"provided",
"to",
"show",
"in",
"the",
"UI",
"in",
"case",
"the",
"watch",
"fails",
"due",
"... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/srvtopo/resilient_server.go#L426-L511 | train |
vitessio/vitess | go/vt/srvtopo/resilient_server.go | StatusAsHTML | func (st *SrvKeyspaceCacheStatus) StatusAsHTML() template.HTML {
if st.Value == nil {
return template.HTML("No Data")
}
result := "<b>Partitions:</b><br>"
for _, keyspacePartition := range st.Value.Partitions {
result += " <b>" + keyspacePartition.ServedType.String() + ":</b>"
for _, shard := range keys... | go | func (st *SrvKeyspaceCacheStatus) StatusAsHTML() template.HTML {
if st.Value == nil {
return template.HTML("No Data")
}
result := "<b>Partitions:</b><br>"
for _, keyspacePartition := range st.Value.Partitions {
result += " <b>" + keyspacePartition.ServedType.String() + ":</b>"
for _, shard := range keys... | [
"func",
"(",
"st",
"*",
"SrvKeyspaceCacheStatus",
")",
"StatusAsHTML",
"(",
")",
"template",
".",
"HTML",
"{",
"if",
"st",
".",
"Value",
"==",
"nil",
"{",
"return",
"template",
".",
"HTML",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"result",
":=",
"\"... | // StatusAsHTML returns an HTML version of our status.
// It works best if there is data in the cache. | [
"StatusAsHTML",
"returns",
"an",
"HTML",
"version",
"of",
"our",
"status",
".",
"It",
"works",
"best",
"if",
"there",
"is",
"data",
"in",
"the",
"cache",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/srvtopo/resilient_server.go#L599-L626 | train |
vitessio/vitess | go/vt/srvtopo/resilient_server.go | CacheStatus | func (server *ResilientServer) CacheStatus() *ResilientServerCacheStatus {
result := &ResilientServerCacheStatus{}
server.mutex.Lock()
for _, entry := range server.srvKeyspaceNamesCache {
entry.mutex.Lock()
result.SrvKeyspaceNames = append(result.SrvKeyspaceNames, &SrvKeyspaceNamesCacheStatus{
Cell: ... | go | func (server *ResilientServer) CacheStatus() *ResilientServerCacheStatus {
result := &ResilientServerCacheStatus{}
server.mutex.Lock()
for _, entry := range server.srvKeyspaceNamesCache {
entry.mutex.Lock()
result.SrvKeyspaceNames = append(result.SrvKeyspaceNames, &SrvKeyspaceNamesCacheStatus{
Cell: ... | [
"func",
"(",
"server",
"*",
"ResilientServer",
")",
"CacheStatus",
"(",
")",
"*",
"ResilientServerCacheStatus",
"{",
"result",
":=",
"&",
"ResilientServerCacheStatus",
"{",
"}",
"\n",
"server",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n\n",
"for",
"_",
",",
... | // CacheStatus returns a displayable version of the cache | [
"CacheStatus",
"returns",
"a",
"displayable",
"version",
"of",
"the",
"cache"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/srvtopo/resilient_server.go#L654-L699 | train |
vitessio/vitess | go/vt/srvtopo/resilient_server.go | ttlTime | func ttlTime(expirationTime time.Time) template.HTML {
ttl := time.Until(expirationTime).Round(time.Second)
if ttl < 0 {
return template.HTML("<b>Expired</b>")
}
return template.HTML(ttl.String())
} | go | func ttlTime(expirationTime time.Time) template.HTML {
ttl := time.Until(expirationTime).Round(time.Second)
if ttl < 0 {
return template.HTML("<b>Expired</b>")
}
return template.HTML(ttl.String())
} | [
"func",
"ttlTime",
"(",
"expirationTime",
"time",
".",
"Time",
")",
"template",
".",
"HTML",
"{",
"ttl",
":=",
"time",
".",
"Until",
"(",
"expirationTime",
")",
".",
"Round",
"(",
"time",
".",
"Second",
")",
"\n",
"if",
"ttl",
"<",
"0",
"{",
"return"... | // Returns the ttl for the cached entry or "Expired" if it is in the past | [
"Returns",
"the",
"ttl",
"for",
"the",
"cached",
"entry",
"or",
"Expired",
"if",
"it",
"is",
"in",
"the",
"past"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/srvtopo/resilient_server.go#L702-L708 | train |
vitessio/vitess | go/vt/schemamanager/ui_controller.go | NewUIController | func NewUIController(
sqlStr string, keyspace string, writer http.ResponseWriter) *UIController {
controller := &UIController{
sqls: make([]string, 0, 32),
keyspace: keyspace,
writer: writer,
}
for _, sql := range strings.Split(sqlStr, ";") {
s := strings.TrimSpace(sql)
if s != "" {
controller.sq... | go | func NewUIController(
sqlStr string, keyspace string, writer http.ResponseWriter) *UIController {
controller := &UIController{
sqls: make([]string, 0, 32),
keyspace: keyspace,
writer: writer,
}
for _, sql := range strings.Split(sqlStr, ";") {
s := strings.TrimSpace(sql)
if s != "" {
controller.sq... | [
"func",
"NewUIController",
"(",
"sqlStr",
"string",
",",
"keyspace",
"string",
",",
"writer",
"http",
".",
"ResponseWriter",
")",
"*",
"UIController",
"{",
"controller",
":=",
"&",
"UIController",
"{",
"sqls",
":",
"make",
"(",
"[",
"]",
"string",
",",
"0"... | // NewUIController creates a UIController instance | [
"NewUIController",
"creates",
"a",
"UIController",
"instance"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/ui_controller.go#L37-L52 | train |
vitessio/vitess | go/vt/schemamanager/ui_controller.go | OnReadSuccess | func (controller *UIController) OnReadSuccess(ctx context.Context) error {
controller.writer.Write(
[]byte(fmt.Sprintf("OnReadSuccess, sqls: %v\n", controller.sqls)))
return nil
} | go | func (controller *UIController) OnReadSuccess(ctx context.Context) error {
controller.writer.Write(
[]byte(fmt.Sprintf("OnReadSuccess, sqls: %v\n", controller.sqls)))
return nil
} | [
"func",
"(",
"controller",
"*",
"UIController",
")",
"OnReadSuccess",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"controller",
".",
"writer",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
",",
... | // OnReadSuccess is no-op | [
"OnReadSuccess",
"is",
"no",
"-",
"op"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/schemamanager/ui_controller.go#L74-L78 | train |
vitessio/vitess | go/mysql/ldapauthserver/auth_server_ldap.go | ValidateHash | func (asl *AuthServerLdap) ValidateHash(salt []byte, user string, authResponse []byte, remoteAddr net.Addr) (mysql.Getter, error) {
panic("unimplemented")
} | go | func (asl *AuthServerLdap) ValidateHash(salt []byte, user string, authResponse []byte, remoteAddr net.Addr) (mysql.Getter, error) {
panic("unimplemented")
} | [
"func",
"(",
"asl",
"*",
"AuthServerLdap",
")",
"ValidateHash",
"(",
"salt",
"[",
"]",
"byte",
",",
"user",
"string",
",",
"authResponse",
"[",
"]",
"byte",
",",
"remoteAddr",
"net",
".",
"Addr",
")",
"(",
"mysql",
".",
"Getter",
",",
"error",
")",
"... | // ValidateHash is unimplemented for AuthServerLdap. | [
"ValidateHash",
"is",
"unimplemented",
"for",
"AuthServerLdap",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/ldapauthserver/auth_server_ldap.go#L98-L100 | train |
vitessio/vitess | go/mysql/ldapauthserver/auth_server_ldap.go | Negotiate | func (asl *AuthServerLdap) Negotiate(c *mysql.Conn, user string, remoteAddr net.Addr) (mysql.Getter, error) {
// Finish the negotiation.
password, err := mysql.AuthServerNegotiateClearOrDialog(c, asl.Method)
if err != nil {
return nil, err
}
return asl.validate(user, password)
} | go | func (asl *AuthServerLdap) Negotiate(c *mysql.Conn, user string, remoteAddr net.Addr) (mysql.Getter, error) {
// Finish the negotiation.
password, err := mysql.AuthServerNegotiateClearOrDialog(c, asl.Method)
if err != nil {
return nil, err
}
return asl.validate(user, password)
} | [
"func",
"(",
"asl",
"*",
"AuthServerLdap",
")",
"Negotiate",
"(",
"c",
"*",
"mysql",
".",
"Conn",
",",
"user",
"string",
",",
"remoteAddr",
"net",
".",
"Addr",
")",
"(",
"mysql",
".",
"Getter",
",",
"error",
")",
"{",
"// Finish the negotiation.",
"passw... | // Negotiate is part of the AuthServer interface. | [
"Negotiate",
"is",
"part",
"of",
"the",
"AuthServer",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/ldapauthserver/auth_server_ldap.go#L103-L110 | train |
vitessio/vitess | go/mysql/ldapauthserver/auth_server_ldap.go | getGroups | func (asl *AuthServerLdap) getGroups(username string) ([]string, error) {
err := asl.Client.Bind(asl.User, asl.Password)
if err != nil {
return nil, err
}
req := ldap.NewSearchRequest(
asl.GroupQuery,
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
fmt.Sprintf("(memberUid=%s)", username),
[]s... | go | func (asl *AuthServerLdap) getGroups(username string) ([]string, error) {
err := asl.Client.Bind(asl.User, asl.Password)
if err != nil {
return nil, err
}
req := ldap.NewSearchRequest(
asl.GroupQuery,
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
fmt.Sprintf("(memberUid=%s)", username),
[]s... | [
"func",
"(",
"asl",
"*",
"AuthServerLdap",
")",
"getGroups",
"(",
"username",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"err",
":=",
"asl",
".",
"Client",
".",
"Bind",
"(",
"asl",
".",
"User",
",",
"asl",
".",
"Password",
")",... | //this needs to be passed an already connected client...should check for this | [
"this",
"needs",
"to",
"be",
"passed",
"an",
"already",
"connected",
"client",
"...",
"should",
"check",
"for",
"this"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/ldapauthserver/auth_server_ldap.go#L128-L151 | train |
vitessio/vitess | go/mysql/ldapauthserver/auth_server_ldap.go | Get | func (lud *LdapUserData) Get() *querypb.VTGateCallerID {
if int64(time.Since(lud.lastUpdated).Seconds()) > lud.asl.RefreshSeconds {
go lud.update()
}
return &querypb.VTGateCallerID{Username: lud.username, Groups: lud.groups}
} | go | func (lud *LdapUserData) Get() *querypb.VTGateCallerID {
if int64(time.Since(lud.lastUpdated).Seconds()) > lud.asl.RefreshSeconds {
go lud.update()
}
return &querypb.VTGateCallerID{Username: lud.username, Groups: lud.groups}
} | [
"func",
"(",
"lud",
"*",
"LdapUserData",
")",
"Get",
"(",
")",
"*",
"querypb",
".",
"VTGateCallerID",
"{",
"if",
"int64",
"(",
"time",
".",
"Since",
"(",
"lud",
".",
"lastUpdated",
")",
".",
"Seconds",
"(",
")",
")",
">",
"lud",
".",
"asl",
".",
... | // Get returns wrapped username and LDAP groups and possibly updates the cache | [
"Get",
"returns",
"wrapped",
"username",
"and",
"LDAP",
"groups",
"and",
"possibly",
"updates",
"the",
"cache"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/ldapauthserver/auth_server_ldap.go#L191-L196 | train |
vitessio/vitess | go/mysql/ldapauthserver/auth_server_ldap.go | Connect | func (lci *ClientImpl) Connect(network string, config *ServerConfig) error {
conn, err := ldap.Dial(network, config.LdapServer)
if err != nil {
return err
}
lci.Conn = conn
// Reconnect with TLS ... why don't we simply DialTLS directly?
serverName, _, err := netutil.SplitHostPort(config.LdapServer)
if err != n... | go | func (lci *ClientImpl) Connect(network string, config *ServerConfig) error {
conn, err := ldap.Dial(network, config.LdapServer)
if err != nil {
return err
}
lci.Conn = conn
// Reconnect with TLS ... why don't we simply DialTLS directly?
serverName, _, err := netutil.SplitHostPort(config.LdapServer)
if err != n... | [
"func",
"(",
"lci",
"*",
"ClientImpl",
")",
"Connect",
"(",
"network",
"string",
",",
"config",
"*",
"ServerConfig",
")",
"error",
"{",
"conn",
",",
"err",
":=",
"ldap",
".",
"Dial",
"(",
"network",
",",
"config",
".",
"LdapServer",
")",
"\n",
"if",
... | // Connect calls ldap.Dial and then upgrades the connection to TLS
// This must be called before any other methods | [
"Connect",
"calls",
"ldap",
".",
"Dial",
"and",
"then",
"upgrades",
"the",
"connection",
"to",
"TLS",
"This",
"must",
"be",
"called",
"before",
"any",
"other",
"methods"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/mysql/ldapauthserver/auth_server_ldap.go#L222-L242 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_actions.go | GetPermissions | func (agent *ActionAgent) GetPermissions(ctx context.Context) (*tabletmanagerdatapb.Permissions, error) {
return mysqlctl.GetPermissions(agent.MysqlDaemon)
} | go | func (agent *ActionAgent) GetPermissions(ctx context.Context) (*tabletmanagerdatapb.Permissions, error) {
return mysqlctl.GetPermissions(agent.MysqlDaemon)
} | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"GetPermissions",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"tabletmanagerdatapb",
".",
"Permissions",
",",
"error",
")",
"{",
"return",
"mysqlctl",
".",
"GetPermissions",
"(",
"agent",
".",
"MysqlDa... | // GetPermissions returns the db permissions. | [
"GetPermissions",
"returns",
"the",
"db",
"permissions",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_actions.go#L46-L48 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_actions.go | SetReadOnly | func (agent *ActionAgent) SetReadOnly(ctx context.Context, rdonly bool) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
return agent.MysqlDaemon.SetReadOnly(rdonly)
} | go | func (agent *ActionAgent) SetReadOnly(ctx context.Context, rdonly bool) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
return agent.MysqlDaemon.SetReadOnly(rdonly)
} | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"SetReadOnly",
"(",
"ctx",
"context",
".",
"Context",
",",
"rdonly",
"bool",
")",
"error",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
... | // SetReadOnly makes the mysql instance read-only or read-write. | [
"SetReadOnly",
"makes",
"the",
"mysql",
"instance",
"read",
"-",
"only",
"or",
"read",
"-",
"write",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_actions.go#L51-L58 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_actions.go | ChangeType | func (agent *ActionAgent) ChangeType(ctx context.Context, tabletType topodatapb.TabletType) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
// We don't want to allow multiple callers to claim a tablet as drained. There is a race that could happen during
// horizontal resharding... | go | func (agent *ActionAgent) ChangeType(ctx context.Context, tabletType topodatapb.TabletType) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
// We don't want to allow multiple callers to claim a tablet as drained. There is a race that could happen during
// horizontal resharding... | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"ChangeType",
"(",
"ctx",
"context",
".",
"Context",
",",
"tabletType",
"topodatapb",
".",
"TabletType",
")",
"error",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil"... | // ChangeType changes the tablet type | [
"ChangeType",
"changes",
"the",
"tablet",
"type"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_actions.go#L61-L92 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_actions.go | Sleep | func (agent *ActionAgent) Sleep(ctx context.Context, duration time.Duration) {
if err := agent.lock(ctx); err != nil {
// client gave up
return
}
defer agent.unlock()
time.Sleep(duration)
} | go | func (agent *ActionAgent) Sleep(ctx context.Context, duration time.Duration) {
if err := agent.lock(ctx); err != nil {
// client gave up
return
}
defer agent.unlock()
time.Sleep(duration)
} | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"Sleep",
"(",
"ctx",
"context",
".",
"Context",
",",
"duration",
"time",
".",
"Duration",
")",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"// client gave... | // Sleep sleeps for the duration | [
"Sleep",
"sleeps",
"for",
"the",
"duration"
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_actions.go#L95-L103 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_actions.go | ExecuteHook | func (agent *ActionAgent) ExecuteHook(ctx context.Context, hk *hook.Hook) *hook.HookResult {
if err := agent.lock(ctx); err != nil {
// client gave up
return &hook.HookResult{}
}
defer agent.unlock()
// Execute the hooks
topotools.ConfigureTabletHook(hk, agent.TabletAlias)
hr := hk.Execute()
// We never kn... | go | func (agent *ActionAgent) ExecuteHook(ctx context.Context, hk *hook.Hook) *hook.HookResult {
if err := agent.lock(ctx); err != nil {
// client gave up
return &hook.HookResult{}
}
defer agent.unlock()
// Execute the hooks
topotools.ConfigureTabletHook(hk, agent.TabletAlias)
hr := hk.Execute()
// We never kn... | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"ExecuteHook",
"(",
"ctx",
"context",
".",
"Context",
",",
"hk",
"*",
"hook",
".",
"Hook",
")",
"*",
"hook",
".",
"HookResult",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")",
";",
"err"... | // ExecuteHook executes the provided hook locally, and returns the result. | [
"ExecuteHook",
"executes",
"the",
"provided",
"hook",
"locally",
"and",
"returns",
"the",
"result",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_actions.go#L106-L123 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_actions.go | RefreshState | func (agent *ActionAgent) RefreshState(ctx context.Context) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
return agent.refreshTablet(ctx, "RefreshState")
} | go | func (agent *ActionAgent) RefreshState(ctx context.Context) error {
if err := agent.lock(ctx); err != nil {
return err
}
defer agent.unlock()
return agent.refreshTablet(ctx, "RefreshState")
} | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"RefreshState",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"agent",
".",
"lock",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defe... | // RefreshState reload the tablet record from the topo server. | [
"RefreshState",
"reload",
"the",
"tablet",
"record",
"from",
"the",
"topo",
"server",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_actions.go#L126-L133 | train |
vitessio/vitess | go/vt/vttablet/tabletmanager/rpc_actions.go | IgnoreHealthError | func (agent *ActionAgent) IgnoreHealthError(ctx context.Context, pattern string) error {
var expr *regexp.Regexp
if pattern != "" {
var err error
if expr, err = regexp.Compile(fmt.Sprintf("^%s$", pattern)); err != nil {
return err
}
}
agent.mutex.Lock()
agent._ignoreHealthErrorExpr = expr
agent.mutex.Unl... | go | func (agent *ActionAgent) IgnoreHealthError(ctx context.Context, pattern string) error {
var expr *regexp.Regexp
if pattern != "" {
var err error
if expr, err = regexp.Compile(fmt.Sprintf("^%s$", pattern)); err != nil {
return err
}
}
agent.mutex.Lock()
agent._ignoreHealthErrorExpr = expr
agent.mutex.Unl... | [
"func",
"(",
"agent",
"*",
"ActionAgent",
")",
"IgnoreHealthError",
"(",
"ctx",
"context",
".",
"Context",
",",
"pattern",
"string",
")",
"error",
"{",
"var",
"expr",
"*",
"regexp",
".",
"Regexp",
"\n",
"if",
"pattern",
"!=",
"\"",
"\"",
"{",
"var",
"e... | // IgnoreHealthError sets the regexp for health check errors to ignore. | [
"IgnoreHealthError",
"sets",
"the",
"regexp",
"for",
"health",
"check",
"errors",
"to",
"ignore",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vttablet/tabletmanager/rpc_actions.go#L141-L153 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | Resolve | func (rb *route) Resolve() *route {
for rb.Redirect != nil {
rb = rb.Redirect
}
return rb
} | go | func (rb *route) Resolve() *route {
for rb.Redirect != nil {
rb = rb.Redirect
}
return rb
} | [
"func",
"(",
"rb",
"*",
"route",
")",
"Resolve",
"(",
")",
"*",
"route",
"{",
"for",
"rb",
".",
"Redirect",
"!=",
"nil",
"{",
"rb",
"=",
"rb",
".",
"Redirect",
"\n",
"}",
"\n",
"return",
"rb",
"\n",
"}"
] | // Resolve resolves redirects, and returns the last
// un-redirected route. | [
"Resolve",
"resolves",
"redirects",
"and",
"returns",
"the",
"last",
"un",
"-",
"redirected",
"route",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L74-L79 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | PushFilter | func (rb *route) PushFilter(pb *primitiveBuilder, filter sqlparser.Expr, whereType string, _ builder) error {
sel := rb.Select.(*sqlparser.Select)
switch whereType {
case sqlparser.WhereStr:
sel.AddWhere(filter)
case sqlparser.HavingStr:
sel.AddHaving(filter)
}
rb.UpdatePlans(pb, filter)
return nil
} | go | func (rb *route) PushFilter(pb *primitiveBuilder, filter sqlparser.Expr, whereType string, _ builder) error {
sel := rb.Select.(*sqlparser.Select)
switch whereType {
case sqlparser.WhereStr:
sel.AddWhere(filter)
case sqlparser.HavingStr:
sel.AddHaving(filter)
}
rb.UpdatePlans(pb, filter)
return nil
} | [
"func",
"(",
"rb",
"*",
"route",
")",
"PushFilter",
"(",
"pb",
"*",
"primitiveBuilder",
",",
"filter",
"sqlparser",
".",
"Expr",
",",
"whereType",
"string",
",",
"_",
"builder",
")",
"error",
"{",
"sel",
":=",
"rb",
".",
"Select",
".",
"(",
"*",
"sql... | // PushFilter satisfies the builder interface.
// The primitive will be updated if the new filter improves the plan. | [
"PushFilter",
"satisfies",
"the",
"builder",
"interface",
".",
"The",
"primitive",
"will",
"be",
"updated",
"if",
"the",
"new",
"filter",
"improves",
"the",
"plan",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L108-L118 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | MakeDistinct | func (rb *route) MakeDistinct() error {
rb.Select.(*sqlparser.Select).Distinct = sqlparser.DistinctStr
return nil
} | go | func (rb *route) MakeDistinct() error {
rb.Select.(*sqlparser.Select).Distinct = sqlparser.DistinctStr
return nil
} | [
"func",
"(",
"rb",
"*",
"route",
")",
"MakeDistinct",
"(",
")",
"error",
"{",
"rb",
".",
"Select",
".",
"(",
"*",
"sqlparser",
".",
"Select",
")",
".",
"Distinct",
"=",
"sqlparser",
".",
"DistinctStr",
"\n",
"return",
"nil",
"\n",
"}"
] | // MakeDistinct sets the DISTINCT property to the select. | [
"MakeDistinct",
"sets",
"the",
"DISTINCT",
"property",
"to",
"the",
"select",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L153-L156 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | SetGroupBy | func (rb *route) SetGroupBy(groupBy sqlparser.GroupBy) error {
rb.Select.(*sqlparser.Select).GroupBy = groupBy
return nil
} | go | func (rb *route) SetGroupBy(groupBy sqlparser.GroupBy) error {
rb.Select.(*sqlparser.Select).GroupBy = groupBy
return nil
} | [
"func",
"(",
"rb",
"*",
"route",
")",
"SetGroupBy",
"(",
"groupBy",
"sqlparser",
".",
"GroupBy",
")",
"error",
"{",
"rb",
".",
"Select",
".",
"(",
"*",
"sqlparser",
".",
"Select",
")",
".",
"GroupBy",
"=",
"groupBy",
"\n",
"return",
"nil",
"\n",
"}"
... | // SetGroupBy sets the GROUP BY clause for the route. | [
"SetGroupBy",
"sets",
"the",
"GROUP",
"BY",
"clause",
"for",
"the",
"route",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L159-L162 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | PushOrderBy | func (rb *route) PushOrderBy(order *sqlparser.Order) error {
// By this time, if any single shard options were already present,
// multi-sharded options would have already been removed. So, this
// call is only for checking if the route has single shard options.
if rb.removeMultishardOptions() {
rb.Select.AddOrde... | go | func (rb *route) PushOrderBy(order *sqlparser.Order) error {
// By this time, if any single shard options were already present,
// multi-sharded options would have already been removed. So, this
// call is only for checking if the route has single shard options.
if rb.removeMultishardOptions() {
rb.Select.AddOrde... | [
"func",
"(",
"rb",
"*",
"route",
")",
"PushOrderBy",
"(",
"order",
"*",
"sqlparser",
".",
"Order",
")",
"error",
"{",
"// By this time, if any single shard options were already present,",
"// multi-sharded options would have already been removed. So, this",
"// call is only for c... | // PushOrderBy sets the order by for the route. | [
"PushOrderBy",
"sets",
"the",
"order",
"by",
"for",
"the",
"route",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L165-L208 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | PushOrderByNull | func (rb *route) PushOrderByNull() {
rb.Select.(*sqlparser.Select).OrderBy = sqlparser.OrderBy{&sqlparser.Order{Expr: &sqlparser.NullVal{}}}
} | go | func (rb *route) PushOrderByNull() {
rb.Select.(*sqlparser.Select).OrderBy = sqlparser.OrderBy{&sqlparser.Order{Expr: &sqlparser.NullVal{}}}
} | [
"func",
"(",
"rb",
"*",
"route",
")",
"PushOrderByNull",
"(",
")",
"{",
"rb",
".",
"Select",
".",
"(",
"*",
"sqlparser",
".",
"Select",
")",
".",
"OrderBy",
"=",
"sqlparser",
".",
"OrderBy",
"{",
"&",
"sqlparser",
".",
"Order",
"{",
"Expr",
":",
"&... | // PushOrderByNull satisfies the builder interface. | [
"PushOrderByNull",
"satisfies",
"the",
"builder",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L211-L213 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | PushOrderByRand | func (rb *route) PushOrderByRand() {
rb.Select.(*sqlparser.Select).OrderBy = sqlparser.OrderBy{&sqlparser.Order{Expr: &sqlparser.FuncExpr{Name: sqlparser.NewColIdent("rand")}}}
} | go | func (rb *route) PushOrderByRand() {
rb.Select.(*sqlparser.Select).OrderBy = sqlparser.OrderBy{&sqlparser.Order{Expr: &sqlparser.FuncExpr{Name: sqlparser.NewColIdent("rand")}}}
} | [
"func",
"(",
"rb",
"*",
"route",
")",
"PushOrderByRand",
"(",
")",
"{",
"rb",
".",
"Select",
".",
"(",
"*",
"sqlparser",
".",
"Select",
")",
".",
"OrderBy",
"=",
"sqlparser",
".",
"OrderBy",
"{",
"&",
"sqlparser",
".",
"Order",
"{",
"Expr",
":",
"&... | // PushOrderByRand satisfies the builder interface. | [
"PushOrderByRand",
"satisfies",
"the",
"builder",
"interface",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L216-L218 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | SetLimit | func (rb *route) SetLimit(limit *sqlparser.Limit) {
rb.Select.SetLimit(limit)
} | go | func (rb *route) SetLimit(limit *sqlparser.Limit) {
rb.Select.SetLimit(limit)
} | [
"func",
"(",
"rb",
"*",
"route",
")",
"SetLimit",
"(",
"limit",
"*",
"sqlparser",
".",
"Limit",
")",
"{",
"rb",
".",
"Select",
".",
"SetLimit",
"(",
"limit",
")",
"\n",
"}"
] | // SetLimit adds a LIMIT clause to the route. | [
"SetLimit",
"adds",
"a",
"LIMIT",
"clause",
"to",
"the",
"route",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L221-L223 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | SetUpperLimit | func (rb *route) SetUpperLimit(count *sqlparser.SQLVal) {
rb.Select.SetLimit(&sqlparser.Limit{Rowcount: count})
} | go | func (rb *route) SetUpperLimit(count *sqlparser.SQLVal) {
rb.Select.SetLimit(&sqlparser.Limit{Rowcount: count})
} | [
"func",
"(",
"rb",
"*",
"route",
")",
"SetUpperLimit",
"(",
"count",
"*",
"sqlparser",
".",
"SQLVal",
")",
"{",
"rb",
".",
"Select",
".",
"SetLimit",
"(",
"&",
"sqlparser",
".",
"Limit",
"{",
"Rowcount",
":",
"count",
"}",
")",
"\n",
"}"
] | // SetUpperLimit satisfies the builder interface.
// The route pushes the limit regardless of the plan.
// If it's a scatter query, the rows returned will be
// more than the upper limit, but enough for the limit
// primitive to chop off where needed. | [
"SetUpperLimit",
"satisfies",
"the",
"builder",
"interface",
".",
"The",
"route",
"pushes",
"the",
"limit",
"regardless",
"of",
"the",
"plan",
".",
"If",
"it",
"s",
"a",
"scatter",
"query",
"the",
"rows",
"returned",
"will",
"be",
"more",
"than",
"the",
"u... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L230-L232 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | procureValues | func (rb *route) procureValues(bldr builder, jt *jointab, val sqlparser.Expr) (sqltypes.PlanValue, error) {
switch val := val.(type) {
case sqlparser.ValTuple:
pv := sqltypes.PlanValue{}
for _, val := range val {
v, err := rb.procureValues(bldr, jt, val)
if err != nil {
return pv, err
}
pv.Values ... | go | func (rb *route) procureValues(bldr builder, jt *jointab, val sqlparser.Expr) (sqltypes.PlanValue, error) {
switch val := val.(type) {
case sqlparser.ValTuple:
pv := sqltypes.PlanValue{}
for _, val := range val {
v, err := rb.procureValues(bldr, jt, val)
if err != nil {
return pv, err
}
pv.Values ... | [
"func",
"(",
"rb",
"*",
"route",
")",
"procureValues",
"(",
"bldr",
"builder",
",",
"jt",
"*",
"jointab",
",",
"val",
"sqlparser",
".",
"Expr",
")",
"(",
"sqltypes",
".",
"PlanValue",
",",
"error",
")",
"{",
"switch",
"val",
":=",
"val",
".",
"(",
... | // procureValues procures and converts the input into
// the expected types for rb.Values. | [
"procureValues",
"procures",
"and",
"converts",
"the",
"input",
"into",
"the",
"expected",
"types",
"for",
"rb",
".",
"Values",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L375-L393 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | generateFieldQuery | func (rb *route) generateFieldQuery(sel sqlparser.SelectStatement, jt *jointab) string {
formatter := func(buf *sqlparser.TrackedBuffer, node sqlparser.SQLNode) {
switch node := node.(type) {
case *sqlparser.ColName:
if !rb.isLocal(node) {
_, joinVar := jt.Lookup(node)
buf.Myprintf("%a", ":"+joinVar)
... | go | func (rb *route) generateFieldQuery(sel sqlparser.SelectStatement, jt *jointab) string {
formatter := func(buf *sqlparser.TrackedBuffer, node sqlparser.SQLNode) {
switch node := node.(type) {
case *sqlparser.ColName:
if !rb.isLocal(node) {
_, joinVar := jt.Lookup(node)
buf.Myprintf("%a", ":"+joinVar)
... | [
"func",
"(",
"rb",
"*",
"route",
")",
"generateFieldQuery",
"(",
"sel",
"sqlparser",
".",
"SelectStatement",
",",
"jt",
"*",
"jointab",
")",
"string",
"{",
"formatter",
":=",
"func",
"(",
"buf",
"*",
"sqlparser",
".",
"TrackedBuffer",
",",
"node",
"sqlpars... | // generateFieldQuery generates a query with an impossible where.
// This will be used on the RHS node to fetch field info if the LHS
// returns no result. | [
"generateFieldQuery",
"generates",
"a",
"query",
"with",
"an",
"impossible",
"where",
".",
"This",
"will",
"be",
"used",
"on",
"the",
"RHS",
"node",
"to",
"fetch",
"field",
"info",
"if",
"the",
"LHS",
"returns",
"no",
"result",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L402-L423 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | MergeSubquery | func (rb *route) MergeSubquery(pb *primitiveBuilder, inner *route) bool {
var mergedRouteOptions []*routeOption
outer:
for _, lro := range rb.routeOptions {
for _, rro := range inner.routeOptions {
if lro.SubqueryCanMerge(pb, rro) {
lro.MergeSubquery(rro)
mergedRouteOptions = append(mergedRouteOptions, l... | go | func (rb *route) MergeSubquery(pb *primitiveBuilder, inner *route) bool {
var mergedRouteOptions []*routeOption
outer:
for _, lro := range rb.routeOptions {
for _, rro := range inner.routeOptions {
if lro.SubqueryCanMerge(pb, rro) {
lro.MergeSubquery(rro)
mergedRouteOptions = append(mergedRouteOptions, l... | [
"func",
"(",
"rb",
"*",
"route",
")",
"MergeSubquery",
"(",
"pb",
"*",
"primitiveBuilder",
",",
"inner",
"*",
"route",
")",
"bool",
"{",
"var",
"mergedRouteOptions",
"[",
"]",
"*",
"routeOption",
"\n",
"outer",
":",
"for",
"_",
",",
"lro",
":=",
"range... | // MergeSubquery returns true if the subquery route could successfully be merged
// with the outer route. | [
"MergeSubquery",
"returns",
"true",
"if",
"the",
"subquery",
"route",
"could",
"successfully",
"be",
"merged",
"with",
"the",
"outer",
"route",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L491-L509 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | MergeUnion | func (rb *route) MergeUnion(right *route) bool {
var mergedRouteOptions []*routeOption
outer:
for _, lro := range rb.routeOptions {
for _, rro := range right.routeOptions {
if lro.UnionCanMerge(rro) {
lro.MergeUnion(rro)
mergedRouteOptions = append(mergedRouteOptions, lro)
continue outer
}
}
}
... | go | func (rb *route) MergeUnion(right *route) bool {
var mergedRouteOptions []*routeOption
outer:
for _, lro := range rb.routeOptions {
for _, rro := range right.routeOptions {
if lro.UnionCanMerge(rro) {
lro.MergeUnion(rro)
mergedRouteOptions = append(mergedRouteOptions, lro)
continue outer
}
}
}
... | [
"func",
"(",
"rb",
"*",
"route",
")",
"MergeUnion",
"(",
"right",
"*",
"route",
")",
"bool",
"{",
"var",
"mergedRouteOptions",
"[",
"]",
"*",
"routeOption",
"\n",
"outer",
":",
"for",
"_",
",",
"lro",
":=",
"range",
"rb",
".",
"routeOptions",
"{",
"f... | // MergeUnion returns true if the rhs route could successfully be merged
// with the rb route. | [
"MergeUnion",
"returns",
"true",
"if",
"the",
"rhs",
"route",
"could",
"successfully",
"be",
"merged",
"with",
"the",
"rb",
"route",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L513-L531 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | removeMultishardOptions | func (rb *route) removeMultishardOptions() bool {
return rb.removeOptions(func(ro *routeOption) bool {
switch ro.eroute.Opcode {
case engine.SelectUnsharded, engine.SelectDBA, engine.SelectNext, engine.SelectEqualUnique, engine.SelectReference:
return true
}
return false
})
} | go | func (rb *route) removeMultishardOptions() bool {
return rb.removeOptions(func(ro *routeOption) bool {
switch ro.eroute.Opcode {
case engine.SelectUnsharded, engine.SelectDBA, engine.SelectNext, engine.SelectEqualUnique, engine.SelectReference:
return true
}
return false
})
} | [
"func",
"(",
"rb",
"*",
"route",
")",
"removeMultishardOptions",
"(",
")",
"bool",
"{",
"return",
"rb",
".",
"removeOptions",
"(",
"func",
"(",
"ro",
"*",
"routeOption",
")",
"bool",
"{",
"switch",
"ro",
".",
"eroute",
".",
"Opcode",
"{",
"case",
"engi... | // removeMultishardOptions removes all multi-shard options from the
// route. It returns false if no such options exist. | [
"removeMultishardOptions",
"removes",
"all",
"multi",
"-",
"shard",
"options",
"from",
"the",
"route",
".",
"It",
"returns",
"false",
"if",
"no",
"such",
"options",
"exist",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L535-L543 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | removeShardedOptions | func (rb *route) removeShardedOptions() bool {
return rb.removeOptions(func(ro *routeOption) bool {
return ro.eroute.Opcode == engine.SelectUnsharded
})
} | go | func (rb *route) removeShardedOptions() bool {
return rb.removeOptions(func(ro *routeOption) bool {
return ro.eroute.Opcode == engine.SelectUnsharded
})
} | [
"func",
"(",
"rb",
"*",
"route",
")",
"removeShardedOptions",
"(",
")",
"bool",
"{",
"return",
"rb",
".",
"removeOptions",
"(",
"func",
"(",
"ro",
"*",
"routeOption",
")",
"bool",
"{",
"return",
"ro",
".",
"eroute",
".",
"Opcode",
"==",
"engine",
".",
... | // removeShardedOptions removes all sharded options from the
// route. It returns false if no such options exist.
// This is used for constructs that are only supported for unsharded
// keyspaces like last_insert_id. | [
"removeShardedOptions",
"removes",
"all",
"sharded",
"options",
"from",
"the",
"route",
".",
"It",
"returns",
"false",
"if",
"no",
"such",
"options",
"exist",
".",
"This",
"is",
"used",
"for",
"constructs",
"that",
"are",
"only",
"supported",
"for",
"unsharded... | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L549-L553 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | removeOptionsWithUnmatchedKeyspace | func (rb *route) removeOptionsWithUnmatchedKeyspace(keyspace string) bool {
return rb.removeOptions(func(ro *routeOption) bool {
return ro.eroute.Keyspace.Name == keyspace
})
} | go | func (rb *route) removeOptionsWithUnmatchedKeyspace(keyspace string) bool {
return rb.removeOptions(func(ro *routeOption) bool {
return ro.eroute.Keyspace.Name == keyspace
})
} | [
"func",
"(",
"rb",
"*",
"route",
")",
"removeOptionsWithUnmatchedKeyspace",
"(",
"keyspace",
"string",
")",
"bool",
"{",
"return",
"rb",
".",
"removeOptions",
"(",
"func",
"(",
"ro",
"*",
"routeOption",
")",
"bool",
"{",
"return",
"ro",
".",
"eroute",
".",... | // removeOptionsWithUnmatchedKeyspace removes all options that don't match
// the specified keyspace. It returns false if no such options exist. | [
"removeOptionsWithUnmatchedKeyspace",
"removes",
"all",
"options",
"that",
"don",
"t",
"match",
"the",
"specified",
"keyspace",
".",
"It",
"returns",
"false",
"if",
"no",
"such",
"options",
"exist",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L557-L561 | train |
vitessio/vitess | go/vt/vtgate/planbuilder/route.go | removeOptions | func (rb *route) removeOptions(match func(*routeOption) bool) bool {
var newOptions []*routeOption
for _, ro := range rb.routeOptions {
if match(ro) {
newOptions = append(newOptions, ro)
}
}
if len(newOptions) == 0 {
return false
}
rb.routeOptions = newOptions
return true
} | go | func (rb *route) removeOptions(match func(*routeOption) bool) bool {
var newOptions []*routeOption
for _, ro := range rb.routeOptions {
if match(ro) {
newOptions = append(newOptions, ro)
}
}
if len(newOptions) == 0 {
return false
}
rb.routeOptions = newOptions
return true
} | [
"func",
"(",
"rb",
"*",
"route",
")",
"removeOptions",
"(",
"match",
"func",
"(",
"*",
"routeOption",
")",
"bool",
")",
"bool",
"{",
"var",
"newOptions",
"[",
"]",
"*",
"routeOption",
"\n",
"for",
"_",
",",
"ro",
":=",
"range",
"rb",
".",
"routeOptio... | // removeOptions removes all options that don't match on
// the criteria function. It returns false if no such options exist. | [
"removeOptions",
"removes",
"all",
"options",
"that",
"don",
"t",
"match",
"on",
"the",
"criteria",
"function",
".",
"It",
"returns",
"false",
"if",
"no",
"such",
"options",
"exist",
"."
] | d568817542a413611801aa17a1c213aa95592182 | https://github.com/vitessio/vitess/blob/d568817542a413611801aa17a1c213aa95592182/go/vt/vtgate/planbuilder/route.go#L565-L577 | 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.