id
int32
0
167k
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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
28,400
topfreegames/pitaya
tracing/jaeger/config.go
Configure
func Configure(options Options) (io.Closer, error) { cfg := config.Configuration{ Disabled: options.Disabled, Sampler: &config.SamplerConfig{ Type: jaeger.SamplerTypeProbabilistic, Param: options.Probability, }, } return cfg.InitGlobalTracer(options.ServiceName) }
go
func Configure(options Options) (io.Closer, error) { cfg := config.Configuration{ Disabled: options.Disabled, Sampler: &config.SamplerConfig{ Type: jaeger.SamplerTypeProbabilistic, Param: options.Probability, }, } return cfg.InitGlobalTracer(options.ServiceName) }
[ "func", "Configure", "(", "options", "Options", ")", "(", "io", ".", "Closer", ",", "error", ")", "{", "cfg", ":=", "config", ".", "Configuration", "{", "Disabled", ":", "options", ".", "Disabled", ",", "Sampler", ":", "&", "config", ".", "SamplerConfig"...
// Configure configures a global Jaeger tracer
[ "Configure", "configures", "a", "global", "Jaeger", "tracer" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/tracing/jaeger/config.go#L40-L50
28,401
topfreegames/pitaya
config/config.go
NewConfig
func NewConfig(cfgs ...*viper.Viper) *Config { var cfg *viper.Viper if len(cfgs) > 0 { cfg = cfgs[0] } else { cfg = viper.New() } cfg.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) cfg.AutomaticEnv() c := &Config{config: cfg} c.fillDefaultValues() return c }
go
func NewConfig(cfgs ...*viper.Viper) *Config { var cfg *viper.Viper if len(cfgs) > 0 { cfg = cfgs[0] } else { cfg = viper.New() } cfg.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) cfg.AutomaticEnv() c := &Config{config: cfg} c.fillDefaultValues() return c }
[ "func", "NewConfig", "(", "cfgs", "...", "*", "viper", ".", "Viper", ")", "*", "Config", "{", "var", "cfg", "*", "viper", ".", "Viper", "\n", "if", "len", "(", "cfgs", ")", ">", "0", "{", "cfg", "=", "cfgs", "[", "0", "]", "\n", "}", "else", ...
// NewConfig creates a new config with a given viper config if given
[ "NewConfig", "creates", "a", "new", "config", "with", "a", "given", "viper", "config", "if", "given" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/config/config.go#L36-L49
28,402
topfreegames/pitaya
config/config.go
GetDuration
func (c *Config) GetDuration(s string) time.Duration { return c.config.GetDuration(s) }
go
func (c *Config) GetDuration(s string) time.Duration { return c.config.GetDuration(s) }
[ "func", "(", "c", "*", "Config", ")", "GetDuration", "(", "s", "string", ")", "time", ".", "Duration", "{", "return", "c", ".", "config", ".", "GetDuration", "(", "s", ")", "\n", "}" ]
// GetDuration returns a duration from the inner config
[ "GetDuration", "returns", "a", "duration", "from", "the", "inner", "config" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/config/config.go#L128-L130
28,403
topfreegames/pitaya
config/config.go
GetString
func (c *Config) GetString(s string) string { return c.config.GetString(s) }
go
func (c *Config) GetString(s string) string { return c.config.GetString(s) }
[ "func", "(", "c", "*", "Config", ")", "GetString", "(", "s", "string", ")", "string", "{", "return", "c", ".", "config", ".", "GetString", "(", "s", ")", "\n", "}" ]
// GetString returns a string from the inner config
[ "GetString", "returns", "a", "string", "from", "the", "inner", "config" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/config/config.go#L133-L135
28,404
topfreegames/pitaya
config/config.go
GetInt
func (c *Config) GetInt(s string) int { return c.config.GetInt(s) }
go
func (c *Config) GetInt(s string) int { return c.config.GetInt(s) }
[ "func", "(", "c", "*", "Config", ")", "GetInt", "(", "s", "string", ")", "int", "{", "return", "c", ".", "config", ".", "GetInt", "(", "s", ")", "\n", "}" ]
// GetInt returns an int from the inner config
[ "GetInt", "returns", "an", "int", "from", "the", "inner", "config" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/config/config.go#L138-L140
28,405
topfreegames/pitaya
config/config.go
GetBool
func (c *Config) GetBool(s string) bool { return c.config.GetBool(s) }
go
func (c *Config) GetBool(s string) bool { return c.config.GetBool(s) }
[ "func", "(", "c", "*", "Config", ")", "GetBool", "(", "s", "string", ")", "bool", "{", "return", "c", ".", "config", ".", "GetBool", "(", "s", ")", "\n", "}" ]
// GetBool returns an boolean from the inner config
[ "GetBool", "returns", "an", "boolean", "from", "the", "inner", "config" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/config/config.go#L143-L145
28,406
topfreegames/pitaya
config/config.go
GetStringSlice
func (c *Config) GetStringSlice(s string) []string { return c.config.GetStringSlice(s) }
go
func (c *Config) GetStringSlice(s string) []string { return c.config.GetStringSlice(s) }
[ "func", "(", "c", "*", "Config", ")", "GetStringSlice", "(", "s", "string", ")", "[", "]", "string", "{", "return", "c", ".", "config", ".", "GetStringSlice", "(", "s", ")", "\n", "}" ]
// GetStringSlice returns a string slice from the inner config
[ "GetStringSlice", "returns", "a", "string", "slice", "from", "the", "inner", "config" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/config/config.go#L148-L150
28,407
topfreegames/pitaya
config/config.go
GetStringMapString
func (c *Config) GetStringMapString(s string) map[string]string { return c.config.GetStringMapString(s) }
go
func (c *Config) GetStringMapString(s string) map[string]string { return c.config.GetStringMapString(s) }
[ "func", "(", "c", "*", "Config", ")", "GetStringMapString", "(", "s", "string", ")", "map", "[", "string", "]", "string", "{", "return", "c", ".", "config", ".", "GetStringMapString", "(", "s", ")", "\n", "}" ]
// GetStringMapString returns a string map string from the inner config
[ "GetStringMapString", "returns", "a", "string", "map", "string", "from", "the", "inner", "config" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/config/config.go#L158-L160
28,408
topfreegames/pitaya
config/config.go
UnmarshalKey
func (c *Config) UnmarshalKey(s string, v interface{}) error { return c.config.UnmarshalKey(s, v) }
go
func (c *Config) UnmarshalKey(s string, v interface{}) error { return c.config.UnmarshalKey(s, v) }
[ "func", "(", "c", "*", "Config", ")", "UnmarshalKey", "(", "s", "string", ",", "v", "interface", "{", "}", ")", "error", "{", "return", "c", ".", "config", ".", "UnmarshalKey", "(", "s", ",", "v", ")", "\n", "}" ]
// UnmarshalKey unmarshals key into v
[ "UnmarshalKey", "unmarshals", "key", "into", "v" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/config/config.go#L163-L165
28,409
topfreegames/pitaya
groups/etcd_group_service.go
NewEtcdGroupService
func NewEtcdGroupService(conf *config.Config, clientOrNil *clientv3.Client) (*EtcdGroupService, error) { err := initClientInstance(conf, clientOrNil) if err != nil { return nil, err } return &EtcdGroupService{}, err }
go
func NewEtcdGroupService(conf *config.Config, clientOrNil *clientv3.Client) (*EtcdGroupService, error) { err := initClientInstance(conf, clientOrNil) if err != nil { return nil, err } return &EtcdGroupService{}, err }
[ "func", "NewEtcdGroupService", "(", "conf", "*", "config", ".", "Config", ",", "clientOrNil", "*", "clientv3", ".", "Client", ")", "(", "*", "EtcdGroupService", ",", "error", ")", "{", "err", ":=", "initClientInstance", "(", "conf", ",", "clientOrNil", ")", ...
// NewEtcdGroupService returns a new group instance
[ "NewEtcdGroupService", "returns", "a", "new", "group", "instance" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/etcd_group_service.go#L28-L34
28,410
topfreegames/pitaya
groups/etcd_group_service.go
GroupCreate
func (c *EtcdGroupService) GroupCreate(ctx context.Context, groupName string) error { return c.createGroup(ctx, groupName, 0) }
go
func (c *EtcdGroupService) GroupCreate(ctx context.Context, groupName string) error { return c.createGroup(ctx, groupName, 0) }
[ "func", "(", "c", "*", "EtcdGroupService", ")", "GroupCreate", "(", "ctx", "context", ".", "Context", ",", "groupName", "string", ")", "error", "{", "return", "c", ".", "createGroup", "(", "ctx", ",", "groupName", ",", "0", ")", "\n", "}" ]
// GroupCreate creates a group struct inside ETCD, without TTL
[ "GroupCreate", "creates", "a", "group", "struct", "inside", "ETCD", "without", "TTL" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/etcd_group_service.go#L114-L116
28,411
topfreegames/pitaya
groups/etcd_group_service.go
GroupCreateWithTTL
func (c *EtcdGroupService) GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error { ctxT, cancel := context.WithTimeout(ctx, transactionTimeout) defer cancel() lease, err := clientInstance.Grant(ctxT, int64(ttlTime.Seconds())) if err != nil { return err } return c.createGroup(ctx...
go
func (c *EtcdGroupService) GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error { ctxT, cancel := context.WithTimeout(ctx, transactionTimeout) defer cancel() lease, err := clientInstance.Grant(ctxT, int64(ttlTime.Seconds())) if err != nil { return err } return c.createGroup(ctx...
[ "func", "(", "c", "*", "EtcdGroupService", ")", "GroupCreateWithTTL", "(", "ctx", "context", ".", "Context", ",", "groupName", "string", ",", "ttlTime", "time", ".", "Duration", ")", "error", "{", "ctxT", ",", "cancel", ":=", "context", ".", "WithTimeout", ...
// GroupCreateWithTTL creates a group struct inside ETCD, with TTL, using leaseID
[ "GroupCreateWithTTL", "creates", "a", "group", "struct", "inside", "ETCD", "with", "TTL", "using", "leaseID" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/etcd_group_service.go#L119-L127
28,412
topfreegames/pitaya
groups/etcd_group_service.go
GroupContainsMember
func (c *EtcdGroupService) GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error) { ctxT, cancel := context.WithTimeout(ctx, transactionTimeout) defer cancel() etcdRes, err := clientInstance.Txn(ctxT). If(clientv3.Compare(clientv3.CreateRevision(groupKey(groupName)), ">", 0)). Then(clientv...
go
func (c *EtcdGroupService) GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error) { ctxT, cancel := context.WithTimeout(ctx, transactionTimeout) defer cancel() etcdRes, err := clientInstance.Txn(ctxT). If(clientv3.Compare(clientv3.CreateRevision(groupKey(groupName)), ">", 0)). Then(clientv...
[ "func", "(", "c", "*", "EtcdGroupService", ")", "GroupContainsMember", "(", "ctx", "context", ".", "Context", ",", "groupName", ",", "uid", "string", ")", "(", "bool", ",", "error", ")", "{", "ctxT", ",", "cancel", ":=", "context", ".", "WithTimeout", "(...
// GroupContainsMember checks whether a UID is contained in current group or not
[ "GroupContainsMember", "checks", "whether", "a", "UID", "is", "contained", "in", "current", "group", "or", "not" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/etcd_group_service.go#L155-L170
28,413
topfreegames/pitaya
groups/etcd_group_service.go
GroupRemoveAll
func (c *EtcdGroupService) GroupRemoveAll(ctx context.Context, groupName string) error { ctxT, cancel := context.WithTimeout(ctx, transactionTimeout) defer cancel() etcdRes, err := clientInstance.Txn(ctxT). If(clientv3.Compare(clientv3.CreateRevision(groupKey(groupName)), ">", 0)). Then(clientv3.OpDelete(memberK...
go
func (c *EtcdGroupService) GroupRemoveAll(ctx context.Context, groupName string) error { ctxT, cancel := context.WithTimeout(ctx, transactionTimeout) defer cancel() etcdRes, err := clientInstance.Txn(ctxT). If(clientv3.Compare(clientv3.CreateRevision(groupKey(groupName)), ">", 0)). Then(clientv3.OpDelete(memberK...
[ "func", "(", "c", "*", "EtcdGroupService", ")", "GroupRemoveAll", "(", "ctx", "context", ".", "Context", ",", "groupName", "string", ")", "error", "{", "ctxT", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "ctx", ",", "transactionTimeout", ")", ...
// GroupRemoveAll clears all UIDs in the group
[ "GroupRemoveAll", "clears", "all", "UIDs", "in", "the", "group" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/etcd_group_service.go#L224-L239
28,414
topfreegames/pitaya
groups/etcd_group_service.go
GroupRenewTTL
func (c *EtcdGroupService) GroupRenewTTL(ctx context.Context, groupName string) error { kv, err := getGroupKV(ctx, groupName) if err != nil { return err } if kv.Lease != 0 { ctxT, cancel := context.WithTimeout(ctx, transactionTimeout) defer cancel() _, err = clientInstance.KeepAliveOnce(ctxT, clientv3.Lease...
go
func (c *EtcdGroupService) GroupRenewTTL(ctx context.Context, groupName string) error { kv, err := getGroupKV(ctx, groupName) if err != nil { return err } if kv.Lease != 0 { ctxT, cancel := context.WithTimeout(ctx, transactionTimeout) defer cancel() _, err = clientInstance.KeepAliveOnce(ctxT, clientv3.Lease...
[ "func", "(", "c", "*", "EtcdGroupService", ")", "GroupRenewTTL", "(", "ctx", "context", ".", "Context", ",", "groupName", "string", ")", "error", "{", "kv", ",", "err", ":=", "getGroupKV", "(", "ctx", ",", "groupName", ")", "\n", "if", "err", "!=", "ni...
// GroupRenewTTL will renew ETCD lease TTL
[ "GroupRenewTTL", "will", "renew", "ETCD", "lease", "TTL" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/etcd_group_service.go#L272-L284
28,415
topfreegames/pitaya
worker/report.go
Report
func Report(reporters []metrics.Reporter, period time.Duration) { for { time.Sleep(period) workerStats := workers.GetStats() for _, r := range reporters { reportJobsRetry(r, workerStats.Retries) reportQueueSizes(r, workerStats.Enqueued) reportJobsTotal(r, workerStats.Failed, workerStats.Processed) } ...
go
func Report(reporters []metrics.Reporter, period time.Duration) { for { time.Sleep(period) workerStats := workers.GetStats() for _, r := range reporters { reportJobsRetry(r, workerStats.Retries) reportQueueSizes(r, workerStats.Enqueued) reportJobsTotal(r, workerStats.Failed, workerStats.Processed) } ...
[ "func", "Report", "(", "reporters", "[", "]", "metrics", ".", "Reporter", ",", "period", "time", ".", "Duration", ")", "{", "for", "{", "time", ".", "Sleep", "(", "period", ")", "\n\n", "workerStats", ":=", "workers", ".", "GetStats", "(", ")", "\n", ...
// Report sends periodic of worker reports
[ "Report", "sends", "periodic", "of", "worker", "reports" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/worker/report.go#L14-L25
28,416
topfreegames/pitaya
util/util.go
Pcall
func Pcall(method reflect.Method, args []reflect.Value) (rets interface{}, err error) { defer func() { if rec := recover(); rec != nil { // Try to use logger from context here to help trace error cause log := getLoggerFromArgs(args) log.Errorf("panic - pitaya/dispatch: %s: %v", method.Name, rec) log.Debu...
go
func Pcall(method reflect.Method, args []reflect.Value) (rets interface{}, err error) { defer func() { if rec := recover(); rec != nil { // Try to use logger from context here to help trace error cause log := getLoggerFromArgs(args) log.Errorf("panic - pitaya/dispatch: %s: %v", method.Name, rec) log.Debu...
[ "func", "Pcall", "(", "method", "reflect", ".", "Method", ",", "args", "[", "]", "reflect", ".", "Value", ")", "(", "rets", "interface", "{", "}", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "if", "rec", ":=", "recover", "(", "...
// Pcall calls a method that returns an interface and an error and recovers in case of panic
[ "Pcall", "calls", "a", "method", "that", "returns", "an", "interface", "and", "an", "error", "and", "recovers", "in", "case", "of", "panic" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/util/util.go#L61-L89
28,417
topfreegames/pitaya
util/util.go
SliceContainsString
func SliceContainsString(slice []string, str string) bool { for _, value := range slice { if value == str { return true } } return false }
go
func SliceContainsString(slice []string, str string) bool { for _, value := range slice { if value == str { return true } } return false }
[ "func", "SliceContainsString", "(", "slice", "[", "]", "string", ",", "str", "string", ")", "bool", "{", "for", "_", ",", "value", ":=", "range", "slice", "{", "if", "value", "==", "str", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", ...
// SliceContainsString returns true if a slice contains the string
[ "SliceContainsString", "returns", "true", "if", "a", "slice", "contains", "the", "string" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/util/util.go#L92-L99
28,418
topfreegames/pitaya
util/util.go
SerializeOrRaw
func SerializeOrRaw(serializer serialize.Serializer, v interface{}) ([]byte, error) { if data, ok := v.([]byte); ok { return data, nil } data, err := serializer.Marshal(v) if err != nil { return nil, err } return data, nil }
go
func SerializeOrRaw(serializer serialize.Serializer, v interface{}) ([]byte, error) { if data, ok := v.([]byte); ok { return data, nil } data, err := serializer.Marshal(v) if err != nil { return nil, err } return data, nil }
[ "func", "SerializeOrRaw", "(", "serializer", "serialize", ".", "Serializer", ",", "v", "interface", "{", "}", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "data", ",", "ok", ":=", "v", ".", "(", "[", "]", "byte", ")", ";", "ok", "{",...
// SerializeOrRaw serializes the interface if its not an array of bytes already
[ "SerializeOrRaw", "serializes", "the", "interface", "if", "its", "not", "an", "array", "of", "bytes", "already" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/util/util.go#L102-L111
28,419
topfreegames/pitaya
util/util.go
GetErrorPayload
func GetErrorPayload(serializer serialize.Serializer, err error) ([]byte, error) { code := e.ErrUnknownCode msg := err.Error() metadata := map[string]string{} if val, ok := err.(*e.Error); ok { code = val.Code metadata = val.Metadata } errPayload := &protos.Error{ Code: code, Msg: msg, } if len(metadat...
go
func GetErrorPayload(serializer serialize.Serializer, err error) ([]byte, error) { code := e.ErrUnknownCode msg := err.Error() metadata := map[string]string{} if val, ok := err.(*e.Error); ok { code = val.Code metadata = val.Metadata } errPayload := &protos.Error{ Code: code, Msg: msg, } if len(metadat...
[ "func", "GetErrorPayload", "(", "serializer", "serialize", ".", "Serializer", ",", "err", "error", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "code", ":=", "e", ".", "ErrUnknownCode", "\n", "msg", ":=", "err", ".", "Error", "(", ")", "\n", "...
// GetErrorPayload creates and serializes an error payload
[ "GetErrorPayload", "creates", "and", "serializes", "an", "error", "payload" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/util/util.go#L120-L136
28,420
topfreegames/pitaya
util/util.go
ConvertProtoToMessageType
func ConvertProtoToMessageType(protoMsgType protos.MsgType) message.Type { var msgType message.Type switch protoMsgType { case protos.MsgType_MsgRequest: msgType = message.Request case protos.MsgType_MsgNotify: msgType = message.Notify } return msgType }
go
func ConvertProtoToMessageType(protoMsgType protos.MsgType) message.Type { var msgType message.Type switch protoMsgType { case protos.MsgType_MsgRequest: msgType = message.Request case protos.MsgType_MsgNotify: msgType = message.Notify } return msgType }
[ "func", "ConvertProtoToMessageType", "(", "protoMsgType", "protos", ".", "MsgType", ")", "message", ".", "Type", "{", "var", "msgType", "message", ".", "Type", "\n", "switch", "protoMsgType", "{", "case", "protos", ".", "MsgType_MsgRequest", ":", "msgType", "=",...
// ConvertProtoToMessageType converts a protos.MsgType to a message.Type
[ "ConvertProtoToMessageType", "converts", "a", "protos", ".", "MsgType", "to", "a", "message", ".", "Type" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/util/util.go#L139-L148
28,421
topfreegames/pitaya
util/util.go
CtxWithDefaultLogger
func CtxWithDefaultLogger(ctx context.Context, route, userID string) context.Context { var defaultLogger logger.Logger logrusLogger, ok := logger.Log.(logrus.FieldLogger) if ok { requestID := pcontext.GetFromPropagateCtx(ctx, constants.RequestIDKey) if rID, ok := requestID.(string); ok { if rID == "" { re...
go
func CtxWithDefaultLogger(ctx context.Context, route, userID string) context.Context { var defaultLogger logger.Logger logrusLogger, ok := logger.Log.(logrus.FieldLogger) if ok { requestID := pcontext.GetFromPropagateCtx(ctx, constants.RequestIDKey) if rID, ok := requestID.(string); ok { if rID == "" { re...
[ "func", "CtxWithDefaultLogger", "(", "ctx", "context", ".", "Context", ",", "route", ",", "userID", "string", ")", "context", ".", "Context", "{", "var", "defaultLogger", "logger", ".", "Logger", "\n", "logrusLogger", ",", "ok", ":=", "logger", ".", "Log", ...
// CtxWithDefaultLogger inserts a default logger on ctx to be used on handlers and remotes. // If using logrus, userId, route and requestId will be added as fields. // Otherwise the pitaya logger will be used as it is.
[ "CtxWithDefaultLogger", "inserts", "a", "default", "logger", "on", "ctx", "to", "be", "used", "on", "handlers", "and", "remotes", ".", "If", "using", "logrus", "userId", "route", "and", "requestId", "will", "be", "added", "as", "fields", ".", "Otherwise", "t...
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/util/util.go#L153-L176
28,422
topfreegames/pitaya
util/util.go
GetContextFromRequest
func GetContextFromRequest(req *protos.Request, serverID string) (context.Context, error) { ctx, err := pcontext.Decode(req.GetMetadata()) if err != nil { return nil, err } if ctx == nil { return nil, constants.ErrNoContextFound } tags := opentracing.Tags{ "local.id": serverID, "span.kind": "server...
go
func GetContextFromRequest(req *protos.Request, serverID string) (context.Context, error) { ctx, err := pcontext.Decode(req.GetMetadata()) if err != nil { return nil, err } if ctx == nil { return nil, constants.ErrNoContextFound } tags := opentracing.Tags{ "local.id": serverID, "span.kind": "server...
[ "func", "GetContextFromRequest", "(", "req", "*", "protos", ".", "Request", ",", "serverID", "string", ")", "(", "context", ".", "Context", ",", "error", ")", "{", "ctx", ",", "err", ":=", "pcontext", ".", "Decode", "(", "req", ".", "GetMetadata", "(", ...
// GetContextFromRequest gets the context from a request
[ "GetContextFromRequest", "gets", "the", "context", "from", "a", "request" ]
b92161d7a48c87a7759ac9cabcc23e7d56f9eebd
https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/util/util.go#L179-L201
28,423
chrislusf/gleam
sql/sessionctx/variable/session.go
SetStatusFlag
func (s *SessionVars) SetStatusFlag(flag uint16, on bool) { if on { s.Status |= flag return } s.Status &= (^flag) }
go
func (s *SessionVars) SetStatusFlag(flag uint16, on bool) { if on { s.Status |= flag return } s.Status &= (^flag) }
[ "func", "(", "s", "*", "SessionVars", ")", "SetStatusFlag", "(", "flag", "uint16", ",", "on", "bool", ")", "{", "if", "on", "{", "s", ".", "Status", "|=", "flag", "\n", "return", "\n", "}", "\n", "s", ".", "Status", "&=", "(", "^", "flag", ")", ...
// SetStatusFlag sets the session server status variable. // If on is ture sets the flag in session status, // otherwise removes the flag.
[ "SetStatusFlag", "sets", "the", "session", "server", "status", "variable", ".", "If", "on", "is", "ture", "sets", "the", "flag", "in", "session", "status", "otherwise", "removes", "the", "flag", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/sessionctx/variable/session.go#L160-L166
28,424
chrislusf/gleam
sql/sessionctx/variable/session.go
GetWarnings
func (sc *StatementContext) GetWarnings() []error { sc.mu.Lock() warns := make([]error, len(sc.mu.warnings)) copy(warns, sc.mu.warnings) sc.mu.Unlock() return warns }
go
func (sc *StatementContext) GetWarnings() []error { sc.mu.Lock() warns := make([]error, len(sc.mu.warnings)) copy(warns, sc.mu.warnings) sc.mu.Unlock() return warns }
[ "func", "(", "sc", "*", "StatementContext", ")", "GetWarnings", "(", ")", "[", "]", "error", "{", "sc", ".", "mu", ".", "Lock", "(", ")", "\n", "warns", ":=", "make", "(", "[", "]", "error", ",", "len", "(", "sc", ".", "mu", ".", "warnings", ")...
// GetWarnings gets warnings.
[ "GetWarnings", "gets", "warnings", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/sessionctx/variable/session.go#L240-L246
28,425
chrislusf/gleam
sql/sessionctx/variable/session.go
AppendWarning
func (sc *StatementContext) AppendWarning(warn error) { sc.mu.Lock() sc.mu.warnings = append(sc.mu.warnings, warn) sc.mu.Unlock() }
go
func (sc *StatementContext) AppendWarning(warn error) { sc.mu.Lock() sc.mu.warnings = append(sc.mu.warnings, warn) sc.mu.Unlock() }
[ "func", "(", "sc", "*", "StatementContext", ")", "AppendWarning", "(", "warn", "error", ")", "{", "sc", ".", "mu", ".", "Lock", "(", ")", "\n", "sc", ".", "mu", ".", "warnings", "=", "append", "(", "sc", ".", "mu", ".", "warnings", ",", "warn", "...
// AppendWarning appends a warning.
[ "AppendWarning", "appends", "a", "warning", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/sessionctx/variable/session.go#L256-L260
28,426
chrislusf/gleam
sql/model/model.go
Clone
func (t *TableInfo) Clone() *TableInfo { nt := *t nt.Columns = make([]*ColumnInfo, len(t.Columns)) nt.Indices = make([]*IndexInfo, len(t.Indices)) for i := range t.Columns { nt.Columns[i] = t.Columns[i].Clone() } for i := range t.Indices { nt.Indices[i] = t.Indices[i].Clone() } return &nt }
go
func (t *TableInfo) Clone() *TableInfo { nt := *t nt.Columns = make([]*ColumnInfo, len(t.Columns)) nt.Indices = make([]*IndexInfo, len(t.Indices)) for i := range t.Columns { nt.Columns[i] = t.Columns[i].Clone() } for i := range t.Indices { nt.Indices[i] = t.Indices[i].Clone() } return &nt }
[ "func", "(", "t", "*", "TableInfo", ")", "Clone", "(", ")", "*", "TableInfo", "{", "nt", ":=", "*", "t", "\n", "nt", ".", "Columns", "=", "make", "(", "[", "]", "*", "ColumnInfo", ",", "len", "(", "t", ".", "Columns", ")", ")", "\n", "nt", "....
// Clone clones TableInfo.
[ "Clone", "clones", "TableInfo", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/model/model.go#L46-L60
28,427
chrislusf/gleam
sql/model/model.go
Clone
func (index *IndexInfo) Clone() *IndexInfo { ni := *index ni.Columns = make([]*IndexColumn, len(index.Columns)) for i := range index.Columns { ni.Columns[i] = index.Columns[i].Clone() } return &ni }
go
func (index *IndexInfo) Clone() *IndexInfo { ni := *index ni.Columns = make([]*IndexColumn, len(index.Columns)) for i := range index.Columns { ni.Columns[i] = index.Columns[i].Clone() } return &ni }
[ "func", "(", "index", "*", "IndexInfo", ")", "Clone", "(", ")", "*", "IndexInfo", "{", "ni", ":=", "*", "index", "\n", "ni", ".", "Columns", "=", "make", "(", "[", "]", "*", "IndexColumn", ",", "len", "(", "index", ".", "Columns", ")", ")", "\n",...
// Clone clones IndexInfo.
[ "Clone", "clones", "IndexInfo", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/model/model.go#L107-L114
28,428
chrislusf/gleam
sql/model/model.go
Clone
func (db *DBInfo) Clone() *DBInfo { newInfo := *db newInfo.Tables = make([]*TableInfo, len(db.Tables)) for i := range db.Tables { newInfo.Tables[i] = db.Tables[i].Clone() } return &newInfo }
go
func (db *DBInfo) Clone() *DBInfo { newInfo := *db newInfo.Tables = make([]*TableInfo, len(db.Tables)) for i := range db.Tables { newInfo.Tables[i] = db.Tables[i].Clone() } return &newInfo }
[ "func", "(", "db", "*", "DBInfo", ")", "Clone", "(", ")", "*", "DBInfo", "{", "newInfo", ":=", "*", "db", "\n", "newInfo", ".", "Tables", "=", "make", "(", "[", "]", "*", "TableInfo", ",", "len", "(", "db", ".", "Tables", ")", ")", "\n", "for",...
// Clone clones DBInfo.
[ "Clone", "clones", "DBInfo", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/model/model.go#L123-L130
28,429
chrislusf/gleam
sql/model/model.go
NewCIStr
func NewCIStr(s string) (cs CIStr) { cs.O = s cs.L = strings.ToLower(s) return }
go
func NewCIStr(s string) (cs CIStr) { cs.O = s cs.L = strings.ToLower(s) return }
[ "func", "NewCIStr", "(", "s", "string", ")", "(", "cs", "CIStr", ")", "{", "cs", ".", "O", "=", "s", "\n", "cs", ".", "L", "=", "strings", ".", "ToLower", "(", "s", ")", "\n", "return", "\n", "}" ]
// NewCIStr creates a new CIStr.
[ "NewCIStr", "creates", "a", "new", "CIStr", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/model/model.go#L144-L148
28,430
chrislusf/gleam
flow/dataset_output.go
Output
func (d *Dataset) Output(f func(io.Reader) error) *Dataset { step := d.Flow.AddAllToOneStep(d, nil) step.IsOnDriverSide = true step.Name = "Output" step.Function = func(readers []io.Reader, writers []io.Writer, stat *pb.InstructionStat) error { errChan := make(chan error, len(readers)) for i, reader := range re...
go
func (d *Dataset) Output(f func(io.Reader) error) *Dataset { step := d.Flow.AddAllToOneStep(d, nil) step.IsOnDriverSide = true step.Name = "Output" step.Function = func(readers []io.Reader, writers []io.Writer, stat *pb.InstructionStat) error { errChan := make(chan error, len(readers)) for i, reader := range re...
[ "func", "(", "d", "*", "Dataset", ")", "Output", "(", "f", "func", "(", "io", ".", "Reader", ")", "error", ")", "*", "Dataset", "{", "step", ":=", "d", ".", "Flow", ".", "AddAllToOneStep", "(", "d", ",", "nil", ")", "\n", "step", ".", "IsOnDriver...
// Output concurrently collects outputs from previous step to the driver.
[ "Output", "concurrently", "collects", "outputs", "from", "previous", "step", "to", "the", "driver", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_output.go#L17-L38
28,431
chrislusf/gleam
flow/dataset_output.go
Fprintf
func (d *Dataset) Fprintf(writer io.Writer, format string) *Dataset { fn := func(r io.Reader) error { w := bufio.NewWriter(writer) defer w.Flush() return util.Fprintf(w, r, format) } return d.Output(fn) }
go
func (d *Dataset) Fprintf(writer io.Writer, format string) *Dataset { fn := func(r io.Reader) error { w := bufio.NewWriter(writer) defer w.Flush() return util.Fprintf(w, r, format) } return d.Output(fn) }
[ "func", "(", "d", "*", "Dataset", ")", "Fprintf", "(", "writer", "io", ".", "Writer", ",", "format", "string", ")", "*", "Dataset", "{", "fn", ":=", "func", "(", "r", "io", ".", "Reader", ")", "error", "{", "w", ":=", "bufio", ".", "NewWriter", "...
// Fprintf formats using the format for each row and writes to writer.
[ "Fprintf", "formats", "using", "the", "format", "for", "each", "row", "and", "writes", "to", "writer", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_output.go#L41-L48
28,432
chrislusf/gleam
flow/dataset_output.go
Fprintlnf
func (d *Dataset) Fprintlnf(writer io.Writer, format string) *Dataset { return d.Fprintf(writer, format+"\n") }
go
func (d *Dataset) Fprintlnf(writer io.Writer, format string) *Dataset { return d.Fprintf(writer, format+"\n") }
[ "func", "(", "d", "*", "Dataset", ")", "Fprintlnf", "(", "writer", "io", ".", "Writer", ",", "format", "string", ")", "*", "Dataset", "{", "return", "d", ".", "Fprintf", "(", "writer", ",", "format", "+", "\"", "\\n", "\"", ")", "\n", "}" ]
// Fprintlnf add "\n" at the end of each format
[ "Fprintlnf", "add", "\\", "n", "at", "the", "end", "of", "each", "format" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_output.go#L51-L53
28,433
chrislusf/gleam
flow/dataset_output.go
Printf
func (d *Dataset) Printf(format string) *Dataset { return d.Fprintf(os.Stdout, format) }
go
func (d *Dataset) Printf(format string) *Dataset { return d.Fprintf(os.Stdout, format) }
[ "func", "(", "d", "*", "Dataset", ")", "Printf", "(", "format", "string", ")", "*", "Dataset", "{", "return", "d", ".", "Fprintf", "(", "os", ".", "Stdout", ",", "format", ")", "\n", "}" ]
// Printf prints to os.Stdout in the specified format
[ "Printf", "prints", "to", "os", ".", "Stdout", "in", "the", "specified", "format" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_output.go#L56-L58
28,434
chrislusf/gleam
flow/dataset_output.go
Printlnf
func (d *Dataset) Printlnf(format string) *Dataset { return d.Fprintf(os.Stdout, format+"\n") }
go
func (d *Dataset) Printlnf(format string) *Dataset { return d.Fprintf(os.Stdout, format+"\n") }
[ "func", "(", "d", "*", "Dataset", ")", "Printlnf", "(", "format", "string", ")", "*", "Dataset", "{", "return", "d", ".", "Fprintf", "(", "os", ".", "Stdout", ",", "format", "+", "\"", "\\n", "\"", ")", "\n", "}" ]
// Printlnf prints to os.Stdout in the specified format, // adding an "\n" at the end of each format
[ "Printlnf", "prints", "to", "os", ".", "Stdout", "in", "the", "specified", "format", "adding", "an", "\\", "n", "at", "the", "end", "of", "each", "format" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_output.go#L62-L64
28,435
chrislusf/gleam
flow/dataset_output.go
SaveFirstRowTo
func (d *Dataset) SaveFirstRowTo(decodedObjects ...interface{}) *Dataset { fn := func(reader io.Reader) error { return util.TakeMessage(reader, 1, func(encodedBytes []byte) error { row, err := util.DecodeRow(encodedBytes) if err != nil { fmt.Fprintf(os.Stderr, "Failed to decode byte: %v\n", err) return...
go
func (d *Dataset) SaveFirstRowTo(decodedObjects ...interface{}) *Dataset { fn := func(reader io.Reader) error { return util.TakeMessage(reader, 1, func(encodedBytes []byte) error { row, err := util.DecodeRow(encodedBytes) if err != nil { fmt.Fprintf(os.Stderr, "Failed to decode byte: %v\n", err) return...
[ "func", "(", "d", "*", "Dataset", ")", "SaveFirstRowTo", "(", "decodedObjects", "...", "interface", "{", "}", ")", "*", "Dataset", "{", "fn", ":=", "func", "(", "reader", "io", ".", "Reader", ")", "error", "{", "return", "util", ".", "TakeMessage", "("...
// SaveFirstRowTo saves the first row's values into the operands.
[ "SaveFirstRowTo", "saves", "the", "first", "row", "s", "values", "into", "the", "operands", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_output.go#L67-L93
28,436
chrislusf/gleam
sql/session.go
runStmt
func runStmt(ctx context.Context, s ast.Statement) (ast.RecordSet, error) { var err error var rs ast.RecordSet rs, err = s.Exec(ctx) return rs, errors.Trace(err) }
go
func runStmt(ctx context.Context, s ast.Statement) (ast.RecordSet, error) { var err error var rs ast.RecordSet rs, err = s.Exec(ctx) return rs, errors.Trace(err) }
[ "func", "runStmt", "(", "ctx", "context", ".", "Context", ",", "s", "ast", ".", "Statement", ")", "(", "ast", ".", "RecordSet", ",", "error", ")", "{", "var", "err", "error", "\n", "var", "rs", "ast", ".", "RecordSet", "\n", "rs", ",", "err", "=", ...
// runStmt executes the ast.Statement and commit or rollback the current transaction.
[ "runStmt", "executes", "the", "ast", ".", "Statement", "and", "commit", "or", "rollback", "the", "current", "transaction", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/session.go#L209-L214
28,437
chrislusf/gleam
flow/dataset_cogroup.go
CoGroupPartitionedSorted
func (this *Dataset) CoGroupPartitionedSorted(name string, that *Dataset, indexes []int) (ret *Dataset) { ret = this.Flow.NewNextDataset(len(this.Shards)) ret.IsPartitionedBy = indexes inputs := []*Dataset{this, that} step := this.Flow.MergeDatasets1ShardTo1Step(inputs, ret) step.SetInstruction(name, instruction....
go
func (this *Dataset) CoGroupPartitionedSorted(name string, that *Dataset, indexes []int) (ret *Dataset) { ret = this.Flow.NewNextDataset(len(this.Shards)) ret.IsPartitionedBy = indexes inputs := []*Dataset{this, that} step := this.Flow.MergeDatasets1ShardTo1Step(inputs, ret) step.SetInstruction(name, instruction....
[ "func", "(", "this", "*", "Dataset", ")", "CoGroupPartitionedSorted", "(", "name", "string", ",", "that", "*", "Dataset", ",", "indexes", "[", "]", "int", ")", "(", "ret", "*", "Dataset", ")", "{", "ret", "=", "this", ".", "Flow", ".", "NewNextDataset"...
// CoGroupPartitionedSorted joins 2 datasets that are sharded // by the same key and already locally sorted within each shard.
[ "CoGroupPartitionedSorted", "joins", "2", "datasets", "that", "are", "sharded", "by", "the", "same", "key", "and", "already", "locally", "sorted", "within", "each", "shard", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_cogroup.go#L24-L32
28,438
chrislusf/gleam
sql/expression/aggregation.go
NewAggFunction
func NewAggFunction(funcType string, funcArgs []Expression, distinct bool) AggregationFunction { switch tp := strings.ToLower(funcType); tp { case ast.AggFuncSum: return &sumFunction{aggFunction: newAggFunc(tp, funcArgs, distinct)} case ast.AggFuncCount: return &countFunction{aggFunction: newAggFunc(tp, funcArgs...
go
func NewAggFunction(funcType string, funcArgs []Expression, distinct bool) AggregationFunction { switch tp := strings.ToLower(funcType); tp { case ast.AggFuncSum: return &sumFunction{aggFunction: newAggFunc(tp, funcArgs, distinct)} case ast.AggFuncCount: return &countFunction{aggFunction: newAggFunc(tp, funcArgs...
[ "func", "NewAggFunction", "(", "funcType", "string", ",", "funcArgs", "[", "]", "Expression", ",", "distinct", "bool", ")", "AggregationFunction", "{", "switch", "tp", ":=", "strings", ".", "ToLower", "(", "funcType", ")", ";", "tp", "{", "case", "ast", "....
// NewAggFunction creates a new AggregationFunction.
[ "NewAggFunction", "creates", "a", "new", "AggregationFunction", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/aggregation.go#L98-L116
28,439
chrislusf/gleam
sql/expression/aggregation.go
Equal
func (af *aggFunction) Equal(b AggregationFunction, ctx context.Context) bool { if af.GetName() != b.GetName() { return false } if af.Distinct != b.IsDistinct() { return false } if len(af.GetArgs()) == len(b.GetArgs()) { for i, argA := range af.GetArgs() { if !argA.Equal(b.GetArgs()[i], ctx) { return ...
go
func (af *aggFunction) Equal(b AggregationFunction, ctx context.Context) bool { if af.GetName() != b.GetName() { return false } if af.Distinct != b.IsDistinct() { return false } if len(af.GetArgs()) == len(b.GetArgs()) { for i, argA := range af.GetArgs() { if !argA.Equal(b.GetArgs()[i], ctx) { return ...
[ "func", "(", "af", "*", "aggFunction", ")", "Equal", "(", "b", "AggregationFunction", ",", "ctx", "context", ".", "Context", ")", "bool", "{", "if", "af", ".", "GetName", "(", ")", "!=", "b", ".", "GetName", "(", ")", "{", "return", "false", "\n", ...
// Equal implements AggregationFunction interface.
[ "Equal", "implements", "AggregationFunction", "interface", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/aggregation.go#L140-L155
28,440
chrislusf/gleam
sql/expression/aggregation.go
Clear
func (af *aggFunction) Clear() { af.resultMapper = make(aggCtxMapper, 0) af.streamCtx = nil }
go
func (af *aggFunction) Clear() { af.resultMapper = make(aggCtxMapper, 0) af.streamCtx = nil }
[ "func", "(", "af", "*", "aggFunction", ")", "Clear", "(", ")", "{", "af", ".", "resultMapper", "=", "make", "(", "aggCtxMapper", ",", "0", ")", "\n", "af", ".", "streamCtx", "=", "nil", "\n", "}" ]
// Clear implements AggregationFunction interface.
[ "Clear", "implements", "AggregationFunction", "interface", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/aggregation.go#L196-L199
28,441
chrislusf/gleam
sql/mysql/error.go
Error
func (e *SQLError) Error() string { return fmt.Sprintf("ERROR %d (%s): %s", e.Code, e.State, e.Message) }
go
func (e *SQLError) Error() string { return fmt.Sprintf("ERROR %d (%s): %s", e.Code, e.State, e.Message) }
[ "func", "(", "e", "*", "SQLError", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "Code", ",", "e", ".", "State", ",", "e", ".", "Message", ")", "\n", "}" ]
// Error prints errors, with a formatted string.
[ "Error", "prints", "errors", "with", "a", "formatted", "string", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/mysql/error.go#L35-L37
28,442
chrislusf/gleam
sql/mysql/error.go
NewErr
func NewErr(errCode uint16, args ...interface{}) *SQLError { e := &SQLError{Code: errCode} if s, ok := MySQLState[errCode]; ok { e.State = s } else { e.State = DefaultMySQLState } if format, ok := MySQLErrName[errCode]; ok { e.Message = fmt.Sprintf(format, args...) } else { e.Message = fmt.Sprint(args.....
go
func NewErr(errCode uint16, args ...interface{}) *SQLError { e := &SQLError{Code: errCode} if s, ok := MySQLState[errCode]; ok { e.State = s } else { e.State = DefaultMySQLState } if format, ok := MySQLErrName[errCode]; ok { e.Message = fmt.Sprintf(format, args...) } else { e.Message = fmt.Sprint(args.....
[ "func", "NewErr", "(", "errCode", "uint16", ",", "args", "...", "interface", "{", "}", ")", "*", "SQLError", "{", "e", ":=", "&", "SQLError", "{", "Code", ":", "errCode", "}", "\n\n", "if", "s", ",", "ok", ":=", "MySQLState", "[", "errCode", "]", "...
// NewErr generates a SQL error, with an error code and default format specifier defined in MySQLErrName.
[ "NewErr", "generates", "a", "SQL", "error", "with", "an", "error", "code", "and", "default", "format", "specifier", "defined", "in", "MySQLErrName", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/mysql/error.go#L40-L56
28,443
chrislusf/gleam
sql/mysql/error.go
NewErrf
func NewErrf(errCode uint16, format string, args ...interface{}) *SQLError { e := &SQLError{Code: errCode} if s, ok := MySQLState[errCode]; ok { e.State = s } else { e.State = DefaultMySQLState } e.Message = fmt.Sprintf(format, args...) return e }
go
func NewErrf(errCode uint16, format string, args ...interface{}) *SQLError { e := &SQLError{Code: errCode} if s, ok := MySQLState[errCode]; ok { e.State = s } else { e.State = DefaultMySQLState } e.Message = fmt.Sprintf(format, args...) return e }
[ "func", "NewErrf", "(", "errCode", "uint16", ",", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "*", "SQLError", "{", "e", ":=", "&", "SQLError", "{", "Code", ":", "errCode", "}", "\n\n", "if", "s", ",", "ok", ":=", "MySQLState"...
// NewErrf creates a SQL error, with an error code and a format specifier.
[ "NewErrf", "creates", "a", "SQL", "error", "with", "an", "error", "code", "and", "a", "format", "specifier", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/mysql/error.go#L59-L71
28,444
chrislusf/gleam
instruction/local_limit.go
DoLocalLimit
func DoLocalLimit(reader io.Reader, writer io.Writer, n int, offset int, stats *pb.InstructionStat) error { return util.ProcessRow(reader, nil, func(row *util.Row) error { stats.InputCounter++ if offset > 0 { offset-- } else { if n > 0 { row.WriteTo(writer) stats.OutputCounter++ } n-- } ...
go
func DoLocalLimit(reader io.Reader, writer io.Writer, n int, offset int, stats *pb.InstructionStat) error { return util.ProcessRow(reader, nil, func(row *util.Row) error { stats.InputCounter++ if offset > 0 { offset-- } else { if n > 0 { row.WriteTo(writer) stats.OutputCounter++ } n-- } ...
[ "func", "DoLocalLimit", "(", "reader", "io", ".", "Reader", ",", "writer", "io", ".", "Writer", ",", "n", "int", ",", "offset", "int", ",", "stats", "*", "pb", ".", "InstructionStat", ")", "error", "{", "return", "util", ".", "ProcessRow", "(", "reader...
// DoLocalLimit streamingly get the n items starting from offset
[ "DoLocalLimit", "streamingly", "get", "the", "n", "items", "starting", "from", "offset" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/instruction/local_limit.go#L55-L73
28,445
chrislusf/gleam
sql/plan/column_pruning.go
exprHasSetVar
func exprHasSetVar(expr expression.Expression) bool { if fun, ok := expr.(*expression.ScalarFunction); ok { canPrune := true if fun.FuncName.L == ast.SetVar { return false } for _, arg := range fun.GetArgs() { canPrune = canPrune && exprHasSetVar(arg) if !canPrune { return false } } } retur...
go
func exprHasSetVar(expr expression.Expression) bool { if fun, ok := expr.(*expression.ScalarFunction); ok { canPrune := true if fun.FuncName.L == ast.SetVar { return false } for _, arg := range fun.GetArgs() { canPrune = canPrune && exprHasSetVar(arg) if !canPrune { return false } } } retur...
[ "func", "exprHasSetVar", "(", "expr", "expression", ".", "Expression", ")", "bool", "{", "if", "fun", ",", "ok", ":=", "expr", ".", "(", "*", "expression", ".", "ScalarFunction", ")", ";", "ok", "{", "canPrune", ":=", "true", "\n", "if", "fun", ".", ...
// exprHasSetVar checks if the expression has set-var function. If do, we should not prune it.
[ "exprHasSetVar", "checks", "if", "the", "expression", "has", "set", "-", "var", "function", ".", "If", "do", "we", "should", "not", "prune", "it", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/column_pruning.go#L35-L49
28,446
chrislusf/gleam
sql/util/segmentmap/segmentmap.go
NewSegmentMap
func NewSegmentMap(size int64) (*SegmentMap, error) { if size <= 0 { return nil, errors.Errorf("Invalid size: %d", size) } sm := &SegmentMap{ maps: make([]map[string]interface{}, size), size: size, } for i := int64(0); i < size; i++ { sm.maps[i] = make(map[string]interface{}) } sm.crcTable = crc32.Make...
go
func NewSegmentMap(size int64) (*SegmentMap, error) { if size <= 0 { return nil, errors.Errorf("Invalid size: %d", size) } sm := &SegmentMap{ maps: make([]map[string]interface{}, size), size: size, } for i := int64(0); i < size; i++ { sm.maps[i] = make(map[string]interface{}) } sm.crcTable = crc32.Make...
[ "func", "NewSegmentMap", "(", "size", "int64", ")", "(", "*", "SegmentMap", ",", "error", ")", "{", "if", "size", "<=", "0", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "size", ")", "\n", "}", "\n\n", "sm", ":=", "&"...
// NewSegmentMap creates a new SegmentMap.
[ "NewSegmentMap", "creates", "a", "new", "SegmentMap", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/segmentmap/segmentmap.go#L32-L47
28,447
chrislusf/gleam
sql/util/segmentmap/segmentmap.go
GetSegment
func (sm *SegmentMap) GetSegment(index int64) (map[string]interface{}, error) { if index >= sm.size || index < 0 { return nil, errors.Errorf("index out of bound: %d", index) } return sm.maps[index], nil }
go
func (sm *SegmentMap) GetSegment(index int64) (map[string]interface{}, error) { if index >= sm.size || index < 0 { return nil, errors.Errorf("index out of bound: %d", index) } return sm.maps[index], nil }
[ "func", "(", "sm", "*", "SegmentMap", ")", "GetSegment", "(", "index", "int64", ")", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "if", "index", ">=", "sm", ".", "size", "||", "index", "<", "0", "{", "return", "n...
// GetSegment gets the map specific by index.
[ "GetSegment", "gets", "the", "map", "specific", "by", "index", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/segmentmap/segmentmap.go#L57-L63
28,448
chrislusf/gleam
sql/util/segmentmap/segmentmap.go
Set
func (sm *SegmentMap) Set(key []byte, value interface{}, force bool) bool { idx := int64(crc32.Checksum(key, sm.crcTable)) % sm.size k := string(key) _, exist := sm.maps[idx][k] if exist && !force { return exist } sm.maps[idx][k] = value return exist }
go
func (sm *SegmentMap) Set(key []byte, value interface{}, force bool) bool { idx := int64(crc32.Checksum(key, sm.crcTable)) % sm.size k := string(key) _, exist := sm.maps[idx][k] if exist && !force { return exist } sm.maps[idx][k] = value return exist }
[ "func", "(", "sm", "*", "SegmentMap", ")", "Set", "(", "key", "[", "]", "byte", ",", "value", "interface", "{", "}", ",", "force", "bool", ")", "bool", "{", "idx", ":=", "int64", "(", "crc32", ".", "Checksum", "(", "key", ",", "sm", ".", "crcTabl...
// Set if key not exists, returns whether already exists.
[ "Set", "if", "key", "not", "exists", "returns", "whether", "already", "exists", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/segmentmap/segmentmap.go#L66-L76
28,449
chrislusf/gleam
sql/sessionctx/variable/statusvar.go
GetStatusVars
func GetStatusVars() (map[string]*StatusVal, error) { statusVars := make(map[string]*StatusVal) for _, statistics := range statisticsList { vals, err := statistics.Stats() if err != nil { return nil, errors.Trace(err) } for name, val := range vals { scope := statistics.GetScope(name) statusVars[nam...
go
func GetStatusVars() (map[string]*StatusVal, error) { statusVars := make(map[string]*StatusVal) for _, statistics := range statisticsList { vals, err := statistics.Stats() if err != nil { return nil, errors.Trace(err) } for name, val := range vals { scope := statistics.GetScope(name) statusVars[nam...
[ "func", "GetStatusVars", "(", ")", "(", "map", "[", "string", "]", "*", "StatusVal", ",", "error", ")", "{", "statusVars", ":=", "make", "(", "map", "[", "string", "]", "*", "StatusVal", ")", "\n\n", "for", "_", ",", "statistics", ":=", "range", "sta...
// GetStatusVars gets registered statistics status variables.
[ "GetStatusVars", "gets", "registered", "statistics", "status", "variables", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/sessionctx/variable/statusvar.go#L46-L62
28,450
chrislusf/gleam
sql/plan/join_reorder.go
tryToGetJoinGroup
func tryToGetJoinGroup(j *Join) ([]LogicalPlan, bool) { if j.reordered || !j.cartesianJoin { return nil, false } lChild := j.GetChildByIndex(0).(LogicalPlan) rChild := j.GetChildByIndex(1).(LogicalPlan) if nj, ok := lChild.(*Join); ok { plans, valid := tryToGetJoinGroup(nj) return append(plans, rChild), vali...
go
func tryToGetJoinGroup(j *Join) ([]LogicalPlan, bool) { if j.reordered || !j.cartesianJoin { return nil, false } lChild := j.GetChildByIndex(0).(LogicalPlan) rChild := j.GetChildByIndex(1).(LogicalPlan) if nj, ok := lChild.(*Join); ok { plans, valid := tryToGetJoinGroup(nj) return append(plans, rChild), vali...
[ "func", "tryToGetJoinGroup", "(", "j", "*", "Join", ")", "(", "[", "]", "LogicalPlan", ",", "bool", ")", "{", "if", "j", ".", "reordered", "||", "!", "j", ".", "cartesianJoin", "{", "return", "nil", ",", "false", "\n", "}", "\n", "lChild", ":=", "j...
// tryToGetJoinGroup tries to fetch a whole join group, which all joins is cartesian join.
[ "tryToGetJoinGroup", "tries", "to", "fetch", "a", "whole", "join", "group", "which", "all", "joins", "is", "cartesian", "join", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/join_reorder.go#L25-L36
28,451
chrislusf/gleam
sql/plan/join_reorder.go
walkGraphAndComposeJoin
func (e *joinReOrderSolver) walkGraphAndComposeJoin(u int) { e.visited[u] = true for _, edge := range e.graph[u] { v := edge.nodeID if !e.visited[v] { e.resultJoin = e.newJoin(e.resultJoin, e.group[v]) e.walkGraphAndComposeJoin(v) } } }
go
func (e *joinReOrderSolver) walkGraphAndComposeJoin(u int) { e.visited[u] = true for _, edge := range e.graph[u] { v := edge.nodeID if !e.visited[v] { e.resultJoin = e.newJoin(e.resultJoin, e.group[v]) e.walkGraphAndComposeJoin(v) } } }
[ "func", "(", "e", "*", "joinReOrderSolver", ")", "walkGraphAndComposeJoin", "(", "u", "int", ")", "{", "e", ".", "visited", "[", "u", "]", "=", "true", "\n", "for", "_", ",", "edge", ":=", "range", "e", ".", "graph", "[", "u", "]", "{", "v", ":="...
// walkGraph implements a dfs algorithm. Each time it picks a edge with lowest rate, which has been sorted before.
[ "walkGraph", "implements", "a", "dfs", "algorithm", ".", "Each", "time", "it", "picks", "a", "edge", "with", "lowest", "rate", "which", "has", "been", "sorted", "before", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/join_reorder.go#L198-L207
28,452
chrislusf/gleam
sql/table/column.go
FindCols
func FindCols(cols []*Column, names []string) ([]*Column, error) { var rcols []*Column for _, name := range names { col := FindCol(cols, name) if col != nil { rcols = append(rcols, col) } else { return nil, errUnknownColumn.Gen("unknown column %s", name) } } return rcols, nil }
go
func FindCols(cols []*Column, names []string) ([]*Column, error) { var rcols []*Column for _, name := range names { col := FindCol(cols, name) if col != nil { rcols = append(rcols, col) } else { return nil, errUnknownColumn.Gen("unknown column %s", name) } } return rcols, nil }
[ "func", "FindCols", "(", "cols", "[", "]", "*", "Column", ",", "names", "[", "]", "string", ")", "(", "[", "]", "*", "Column", ",", "error", ")", "{", "var", "rcols", "[", "]", "*", "Column", "\n", "for", "_", ",", "name", ":=", "range", "names...
// FindCols finds columns in cols by names.
[ "FindCols", "finds", "columns", "in", "cols", "by", "names", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/table/column.go#L68-L80
28,453
chrislusf/gleam
sql/table/column.go
CheckOnce
func CheckOnce(cols []*Column) error { m := map[string]struct{}{} for _, col := range cols { name := col.Name _, ok := m[name.L] if ok { return errDuplicateColumn.Gen("column specified twice - %s", name) } m[name.L] = struct{}{} } return nil }
go
func CheckOnce(cols []*Column) error { m := map[string]struct{}{} for _, col := range cols { name := col.Name _, ok := m[name.L] if ok { return errDuplicateColumn.Gen("column specified twice - %s", name) } m[name.L] = struct{}{} } return nil }
[ "func", "CheckOnce", "(", "cols", "[", "]", "*", "Column", ")", "error", "{", "m", ":=", "map", "[", "string", "]", "struct", "{", "}", "{", "}", "\n", "for", "_", ",", "col", ":=", "range", "cols", "{", "name", ":=", "col", ".", "Name", "\n", ...
// CheckOnce checks if there are duplicated column names in cols.
[ "CheckOnce", "checks", "if", "there", "are", "duplicated", "column", "names", "in", "cols", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/table/column.go#L201-L214
28,454
chrislusf/gleam
sql/plan/range.go
buildIndexRanges
func (r *rangeBuilder) buildIndexRanges(rangePoints []rangePoint, tp *types.FieldType) []*IndexRange { indexRanges := make([]*IndexRange, 0, len(rangePoints)/2) for i := 0; i < len(rangePoints); i += 2 { startPoint := r.convertPoint(rangePoints[i], tp) endPoint := r.convertPoint(rangePoints[i+1], tp) less, err ...
go
func (r *rangeBuilder) buildIndexRanges(rangePoints []rangePoint, tp *types.FieldType) []*IndexRange { indexRanges := make([]*IndexRange, 0, len(rangePoints)/2) for i := 0; i < len(rangePoints); i += 2 { startPoint := r.convertPoint(rangePoints[i], tp) endPoint := r.convertPoint(rangePoints[i+1], tp) less, err ...
[ "func", "(", "r", "*", "rangeBuilder", ")", "buildIndexRanges", "(", "rangePoints", "[", "]", "rangePoint", ",", "tp", "*", "types", ".", "FieldType", ")", "[", "]", "*", "IndexRange", "{", "indexRanges", ":=", "make", "(", "[", "]", "*", "IndexRange", ...
// buildIndexRanges build index ranges from range points. // Only the first column in the index is built, extra column ranges will be appended by // appendIndexRanges.
[ "buildIndexRanges", "build", "index", "ranges", "from", "range", "points", ".", "Only", "the", "first", "column", "in", "the", "index", "is", "built", "extra", "column", "ranges", "will", "be", "appended", "by", "appendIndexRanges", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/range.go#L450-L471
28,455
chrislusf/gleam
sql/util/filesort/filesort.go
Less
func (fs *FileSorter) Less(i, j int) bool { l := fs.buf[i].key r := fs.buf[j].key ret, err := lessThan(fs.sc, l, r, fs.byDesc) if fs.err == nil { fs.err = err } return ret }
go
func (fs *FileSorter) Less(i, j int) bool { l := fs.buf[i].key r := fs.buf[j].key ret, err := lessThan(fs.sc, l, r, fs.byDesc) if fs.err == nil { fs.err = err } return ret }
[ "func", "(", "fs", "*", "FileSorter", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "l", ":=", "fs", ".", "buf", "[", "i", "]", ".", "key", "\n", "r", ":=", "fs", ".", "buf", "[", "j", "]", ".", "key", "\n", "ret", ",", "err",...
// Less implements sort.Interface Less interface.
[ "Less", "implements", "sort", ".", "Interface", "Less", "interface", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/filesort/filesort.go#L216-L224
28,456
chrislusf/gleam
sql/util/filesort/filesort.go
flushToFile
func (fs *FileSorter) flushToFile() error { var ( err error outputFile *os.File outputByte []byte ) sort.Sort(fs) if fs.err != nil { return errors.Trace(fs.err) } fileName := fs.getUniqueFileName() outputFile, err = os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) if err != nil ...
go
func (fs *FileSorter) flushToFile() error { var ( err error outputFile *os.File outputByte []byte ) sort.Sort(fs) if fs.err != nil { return errors.Trace(fs.err) } fileName := fs.getUniqueFileName() outputFile, err = os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) if err != nil ...
[ "func", "(", "fs", "*", "FileSorter", ")", "flushToFile", "(", ")", "error", "{", "var", "(", "err", "error", "\n", "outputFile", "*", "os", ".", "File", "\n", "outputByte", "[", "]", "byte", "\n", ")", "\n\n", "sort", ".", "Sort", "(", "fs", ")", ...
// Flush the buffer to file if it is full.
[ "Flush", "the", "buffer", "to", "file", "if", "it", "is", "full", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/filesort/filesort.go#L233-L284
28,457
chrislusf/gleam
sql/util/filesort/filesort.go
fetchNextRow
func (fs *FileSorter) fetchNextRow(index int) (*comparableRow, error) { var ( err error n int head = make([]byte, 8) dcod = make([]types.Datum, 0, fs.keySize+fs.valSize+1) ) n, err = fs.fds[index].Read(head) if err == io.EOF { return nil, nil } if err != nil { return nil, errors.Trace(err) } if ...
go
func (fs *FileSorter) fetchNextRow(index int) (*comparableRow, error) { var ( err error n int head = make([]byte, 8) dcod = make([]types.Datum, 0, fs.keySize+fs.valSize+1) ) n, err = fs.fds[index].Read(head) if err == io.EOF { return nil, nil } if err != nil { return nil, errors.Trace(err) } if ...
[ "func", "(", "fs", "*", "FileSorter", ")", "fetchNextRow", "(", "index", "int", ")", "(", "*", "comparableRow", ",", "error", ")", "{", "var", "(", "err", "error", "\n", "n", "int", "\n", "head", "=", "make", "(", "[", "]", "byte", ",", "8", ")",...
// Fetch the next row given the source file index.
[ "Fetch", "the", "next", "row", "given", "the", "source", "file", "index", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/filesort/filesort.go#L321-L360
28,458
chrislusf/gleam
sql/util/filesort/filesort.go
externalSort
func (fs *FileSorter) externalSort() (*comparableRow, error) { if !fs.fetched { if len(fs.buf) > 0 { err := fs.flushToFile() if err != nil { return nil, errors.Trace(err) } } heap.Init(fs.rowHeap) if fs.rowHeap.err != nil { return nil, errors.Trace(fs.rowHeap.err) } err := fs.openAllFiles...
go
func (fs *FileSorter) externalSort() (*comparableRow, error) { if !fs.fetched { if len(fs.buf) > 0 { err := fs.flushToFile() if err != nil { return nil, errors.Trace(err) } } heap.Init(fs.rowHeap) if fs.rowHeap.err != nil { return nil, errors.Trace(fs.rowHeap.err) } err := fs.openAllFiles...
[ "func", "(", "fs", "*", "FileSorter", ")", "externalSort", "(", ")", "(", "*", "comparableRow", ",", "error", ")", "{", "if", "!", "fs", ".", "fetched", "{", "if", "len", "(", "fs", ".", "buf", ")", ">", "0", "{", "err", ":=", "fs", ".", "flush...
// Perform external file sort.
[ "Perform", "external", "file", "sort", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/filesort/filesort.go#L446-L514
28,459
chrislusf/gleam
sql/util/types/hex.go
ToString
func (h Hex) ToString() string { s := fmt.Sprintf("%x", h.Value) if len(s)%2 != 0 { s = "0" + s } // should never error. b, _ := hex.DecodeString(s) return string(b) }
go
func (h Hex) ToString() string { s := fmt.Sprintf("%x", h.Value) if len(s)%2 != 0 { s = "0" + s } // should never error. b, _ := hex.DecodeString(s) return string(b) }
[ "func", "(", "h", "Hex", ")", "ToString", "(", ")", "string", "{", "s", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "h", ".", "Value", ")", "\n", "if", "len", "(", "s", ")", "%", "2", "!=", "0", "{", "s", "=", "\"", "\"", "+", "s",...
// ToString returns the string representation for hexadecimal literal.
[ "ToString", "returns", "the", "string", "representation", "for", "hexadecimal", "literal", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/hex.go#L48-L57
28,460
chrislusf/gleam
sql/executor/adapter.go
Exec
func (a *Statement) Exec(ctx context.Context) (*flow.Dataset, error) { a.startTime = time.Now() b := newExecutorBuilder(ctx, a.InfoSchema) exe := b.build(a.Plan) if b.err != nil { return nil, errors.Trace(b.err) } if exe == nil { return nil, fmt.Errorf("Failed to build execution plan %v", plan.ToString(a.P...
go
func (a *Statement) Exec(ctx context.Context) (*flow.Dataset, error) { a.startTime = time.Now() b := newExecutorBuilder(ctx, a.InfoSchema) exe := b.build(a.Plan) if b.err != nil { return nil, errors.Trace(b.err) } if exe == nil { return nil, fmt.Errorf("Failed to build execution plan %v", plan.ToString(a.P...
[ "func", "(", "a", "*", "Statement", ")", "Exec", "(", "ctx", "context", ".", "Context", ")", "(", "*", "flow", ".", "Dataset", ",", "error", ")", "{", "a", ".", "startTime", "=", "time", ".", "Now", "(", ")", "\n\n", "b", ":=", "newExecutorBuilder"...
// Exec implements the ast.Statement Exec interface. // This function builds an Executor from a plan. If the Executor doesn't return result, // like the INSERT, UPDATE statements, it executes in this function, if the Executor returns // result, execution is done after this function returns, in the returned ast.RecordSe...
[ "Exec", "implements", "the", "ast", ".", "Statement", "Exec", "interface", ".", "This", "function", "builds", "an", "Executor", "from", "a", "plan", ".", "If", "the", "Executor", "doesn", "t", "return", "result", "like", "the", "INSERT", "UPDATE", "statement...
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/executor/adapter.go#L32-L47
28,461
chrislusf/gleam
flow/dataset_union.go
Union
func (this *Dataset) Union(name string, others []*Dataset, isParallel bool) *Dataset { ret := this.Flow.NewNextDataset(len(this.Shards)) inputs := []*Dataset{this} inputs = append(inputs, others...) step := this.Flow.MergeDatasets1ShardTo1Step(inputs, ret) step.SetInstruction(name, instruction.NewUnion(isParallel)...
go
func (this *Dataset) Union(name string, others []*Dataset, isParallel bool) *Dataset { ret := this.Flow.NewNextDataset(len(this.Shards)) inputs := []*Dataset{this} inputs = append(inputs, others...) step := this.Flow.MergeDatasets1ShardTo1Step(inputs, ret) step.SetInstruction(name, instruction.NewUnion(isParallel)...
[ "func", "(", "this", "*", "Dataset", ")", "Union", "(", "name", "string", ",", "others", "[", "]", "*", "Dataset", ",", "isParallel", "bool", ")", "*", "Dataset", "{", "ret", ":=", "this", ".", "Flow", ".", "NewNextDataset", "(", "len", "(", "this", ...
// Union union multiple Datasets as one Dataset
[ "Union", "union", "multiple", "Datasets", "as", "one", "Dataset" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_union.go#L8-L15
28,462
chrislusf/gleam
distributed/agent/agent_grpc_server.go
Cleanup
func (as *AgentServer) Cleanup(ctx context.Context, cleanupRequest *pb.CleanupRequest) (*pb.CleanupResponse, error) { log.Println("cleaning up", cleanupRequest.GetFlowHashCode()) dir := path.Join(*as.Option.Dir, fmt.Sprintf("%d", cleanupRequest.GetFlowHashCode())) os.RemoveAll(dir) return &pb.CleanupResponse{}, n...
go
func (as *AgentServer) Cleanup(ctx context.Context, cleanupRequest *pb.CleanupRequest) (*pb.CleanupResponse, error) { log.Println("cleaning up", cleanupRequest.GetFlowHashCode()) dir := path.Join(*as.Option.Dir, fmt.Sprintf("%d", cleanupRequest.GetFlowHashCode())) os.RemoveAll(dir) return &pb.CleanupResponse{}, n...
[ "func", "(", "as", "*", "AgentServer", ")", "Cleanup", "(", "ctx", "context", ".", "Context", ",", "cleanupRequest", "*", "pb", ".", "CleanupRequest", ")", "(", "*", "pb", ".", "CleanupResponse", ",", "error", ")", "{", "log", ".", "Println", "(", "\""...
// Cleanup remove all files related to a particular flow
[ "Cleanup", "remove", "all", "files", "related", "to", "a", "particular", "flow" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/agent/agent_grpc_server.go#L82-L89
28,463
chrislusf/gleam
distributed/agent/agent_grpc_server.go
Execute
func (as *AgentServer) Execute(request *pb.ExecutionRequest, stream pb.GleamAgent_ExecuteServer) error { dir := path.Join(*as.Option.Dir, fmt.Sprintf("%d", request.GetInstructionSet().GetFlowHashCode()), request.GetDir()) os.MkdirAll(dir, 0755) allocated := *request.GetResource() as.plusAllocated(allocated) def...
go
func (as *AgentServer) Execute(request *pb.ExecutionRequest, stream pb.GleamAgent_ExecuteServer) error { dir := path.Join(*as.Option.Dir, fmt.Sprintf("%d", request.GetInstructionSet().GetFlowHashCode()), request.GetDir()) os.MkdirAll(dir, 0755) allocated := *request.GetResource() as.plusAllocated(allocated) def...
[ "func", "(", "as", "*", "AgentServer", ")", "Execute", "(", "request", "*", "pb", ".", "ExecutionRequest", ",", "stream", "pb", ".", "GleamAgent_ExecuteServer", ")", "error", "{", "dir", ":=", "path", ".", "Join", "(", "*", "as", ".", "Option", ".", "D...
// Execute executes a request and stream stdout and stderr back
[ "Execute", "executes", "a", "request", "and", "stream", "stdout", "and", "stderr", "back" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/agent/agent_grpc_server.go#L92-L110
28,464
chrislusf/gleam
distributed/agent/agent_grpc_server.go
CollectExecutionStatistics
func (as *AgentServer) CollectExecutionStatistics(stream pb.GleamAgent_CollectExecutionStatisticsServer) error { var statsChan chan *pb.ExecutionStat for { stats, err := stream.Recv() if err == io.EOF { return nil } if err != nil { return err } if statsChan == nil { statsChan = getStatsChan(stat...
go
func (as *AgentServer) CollectExecutionStatistics(stream pb.GleamAgent_CollectExecutionStatisticsServer) error { var statsChan chan *pb.ExecutionStat for { stats, err := stream.Recv() if err == io.EOF { return nil } if err != nil { return err } if statsChan == nil { statsChan = getStatsChan(stat...
[ "func", "(", "as", "*", "AgentServer", ")", "CollectExecutionStatistics", "(", "stream", "pb", ".", "GleamAgent_CollectExecutionStatisticsServer", ")", "error", "{", "var", "statsChan", "chan", "*", "pb", ".", "ExecutionStat", "\n\n", "for", "{", "stats", ",", "...
// Collect stat from "gleam execute" process
[ "Collect", "stat", "from", "gleam", "execute", "process" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/agent/agent_grpc_server.go#L113-L132
28,465
chrislusf/gleam
distributed/agent/agent_grpc_server.go
Delete
func (as *AgentServer) Delete(ctx context.Context, deleteRequest *pb.DeleteDatasetShardRequest) (*pb.DeleteDatasetShardResponse, error) { log.Println("deleting", deleteRequest.Name) as.storageBackend.DeleteNamedDatasetShard(deleteRequest.Name) as.inMemoryChannels.Cleanup(deleteRequest.Name) return &pb.DeleteDatas...
go
func (as *AgentServer) Delete(ctx context.Context, deleteRequest *pb.DeleteDatasetShardRequest) (*pb.DeleteDatasetShardResponse, error) { log.Println("deleting", deleteRequest.Name) as.storageBackend.DeleteNamedDatasetShard(deleteRequest.Name) as.inMemoryChannels.Cleanup(deleteRequest.Name) return &pb.DeleteDatas...
[ "func", "(", "as", "*", "AgentServer", ")", "Delete", "(", "ctx", "context", ".", "Context", ",", "deleteRequest", "*", "pb", ".", "DeleteDatasetShardRequest", ")", "(", "*", "pb", ".", "DeleteDatasetShardResponse", ",", "error", ")", "{", "log", ".", "Pri...
// Delete deletes a particular dataset shard
[ "Delete", "deletes", "a", "particular", "dataset", "shard" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/agent/agent_grpc_server.go#L135-L142
28,466
chrislusf/gleam
distributed/master/ui/svg_writer.go
collectStepOutputDatasetSize
func collectStepOutputDatasetSize(status *pb.FlowExecutionStatus, stepId int32) (counter int64) { for _, tg := range status.TaskGroups { for _, execution := range tg.Executions { if execution.ExecutionStat == nil { continue } for _, stat := range execution.ExecutionStat.Stats { if stat.StepId == ste...
go
func collectStepOutputDatasetSize(status *pb.FlowExecutionStatus, stepId int32) (counter int64) { for _, tg := range status.TaskGroups { for _, execution := range tg.Executions { if execution.ExecutionStat == nil { continue } for _, stat := range execution.ExecutionStat.Stats { if stat.StepId == ste...
[ "func", "collectStepOutputDatasetSize", "(", "status", "*", "pb", ".", "FlowExecutionStatus", ",", "stepId", "int32", ")", "(", "counter", "int64", ")", "{", "for", "_", ",", "tg", ":=", "range", "status", ".", "TaskGroups", "{", "for", "_", ",", "executio...
// may be more efficient to map stepId=>size
[ "may", "be", "more", "efficient", "to", "map", "stepId", "=", ">", "size" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/master/ui/svg_writer.go#L185-L199
28,467
chrislusf/gleam
sql/util/types/mytime.go
DateDiff
func DateDiff(startTime, endTime TimeInternal) int { return calcDaynr(startTime.Year(), startTime.Month(), startTime.Day()) - calcDaynr(endTime.Year(), endTime.Month(), endTime.Day()) }
go
func DateDiff(startTime, endTime TimeInternal) int { return calcDaynr(startTime.Year(), startTime.Month(), startTime.Day()) - calcDaynr(endTime.Year(), endTime.Month(), endTime.Day()) }
[ "func", "DateDiff", "(", "startTime", ",", "endTime", "TimeInternal", ")", "int", "{", "return", "calcDaynr", "(", "startTime", ".", "Year", "(", ")", ",", "startTime", ".", "Month", "(", ")", ",", "startTime", ".", "Day", "(", ")", ")", "-", "calcDayn...
// DateDiff calculates number of days between two days.
[ "DateDiff", "calculates", "number", "of", "days", "between", "two", "days", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/mytime.go#L188-L190
28,468
chrislusf/gleam
sql/expression/builtin_like.go
compilePattern
func compilePattern(pattern string, escape byte) (patChars, patTypes []byte) { var lastAny bool patChars = make([]byte, len(pattern)) patTypes = make([]byte, len(pattern)) patLen := 0 for i := 0; i < len(pattern); i++ { var tp byte var c = pattern[i] switch c { case escape: lastAny = false tp = patMa...
go
func compilePattern(pattern string, escape byte) (patChars, patTypes []byte) { var lastAny bool patChars = make([]byte, len(pattern)) patTypes = make([]byte, len(pattern)) patLen := 0 for i := 0; i < len(pattern); i++ { var tp byte var c = pattern[i] switch c { case escape: lastAny = false tp = patMa...
[ "func", "compilePattern", "(", "pattern", "string", ",", "escape", "byte", ")", "(", "patChars", ",", "patTypes", "[", "]", "byte", ")", "{", "var", "lastAny", "bool", "\n", "patChars", "=", "make", "(", "[", "]", "byte", ",", "len", "(", "pattern", ...
// Handle escapes and wild cards convert pattern characters and pattern types.
[ "Handle", "escapes", "and", "wild", "cards", "convert", "pattern", "characters", "and", "pattern", "types", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/builtin_like.go#L41-L95
28,469
chrislusf/gleam
sql/util/codec/codec.go
peek
func peek(b []byte) (length int, err error) { if len(b) < 1 { return 0, errors.New("invalid encoded key") } flag := b[0] length++ b = b[1:] var l int switch flag { case NilFlag: case intFlag, uintFlag, floatFlag, durationFlag: // Those types are stored in 8 bytes. l = 8 case bytesFlag: l, err = peekBy...
go
func peek(b []byte) (length int, err error) { if len(b) < 1 { return 0, errors.New("invalid encoded key") } flag := b[0] length++ b = b[1:] var l int switch flag { case NilFlag: case intFlag, uintFlag, floatFlag, durationFlag: // Those types are stored in 8 bytes. l = 8 case bytesFlag: l, err = peekBy...
[ "func", "peek", "(", "b", "[", "]", "byte", ")", "(", "length", "int", ",", "err", "error", ")", "{", "if", "len", "(", "b", ")", "<", "1", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "flag", ":=", ...
// peeks the first encoded value from b and returns its length.
[ "peeks", "the", "first", "encoded", "value", "from", "b", "and", "returns", "its", "length", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/codec/codec.go#L226-L257
28,470
chrislusf/gleam
flow/dataset_hint.go
Hint
func (d *Dataset) Hint(options ...DasetsetHint) *Dataset { for _, option := range options { option(d) } return d }
go
func (d *Dataset) Hint(options ...DasetsetHint) *Dataset { for _, option := range options { option(d) } return d }
[ "func", "(", "d", "*", "Dataset", ")", "Hint", "(", "options", "...", "DasetsetHint", ")", "*", "Dataset", "{", "for", "_", ",", "option", ":=", "range", "options", "{", "option", "(", "d", ")", "\n", "}", "\n", "return", "d", "\n", "}" ]
// Hint adds options for previous dataset.
[ "Hint", "adds", "options", "for", "previous", "dataset", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_hint.go#L6-L11
28,471
chrislusf/gleam
flow/dataset_hint.go
TotalSize
func TotalSize(n int64) DasetsetHint { return func(d *Dataset) { d.Meta.TotalSize = n } }
go
func TotalSize(n int64) DasetsetHint { return func(d *Dataset) { d.Meta.TotalSize = n } }
[ "func", "TotalSize", "(", "n", "int64", ")", "DasetsetHint", "{", "return", "func", "(", "d", "*", "Dataset", ")", "{", "d", ".", "Meta", ".", "TotalSize", "=", "n", "\n", "}", "\n", "}" ]
// TotalSize hints the total size in MB for all the partitions. // This is usually used when sorting is needed.
[ "TotalSize", "hints", "the", "total", "size", "in", "MB", "for", "all", "the", "partitions", ".", "This", "is", "usually", "used", "when", "sorting", "is", "needed", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_hint.go#L15-L19
28,472
chrislusf/gleam
flow/dataset_hint.go
PartitionSize
func PartitionSize(n int64) DasetsetHint { return func(d *Dataset) { d.Meta.TotalSize = n * int64(len(d.GetShards())) } }
go
func PartitionSize(n int64) DasetsetHint { return func(d *Dataset) { d.Meta.TotalSize = n * int64(len(d.GetShards())) } }
[ "func", "PartitionSize", "(", "n", "int64", ")", "DasetsetHint", "{", "return", "func", "(", "d", "*", "Dataset", ")", "{", "d", ".", "Meta", ".", "TotalSize", "=", "n", "*", "int64", "(", "len", "(", "d", ".", "GetShards", "(", ")", ")", ")", "\...
// PartitionSize hints the partition size in MB. // This is usually used when sorting is needed.
[ "PartitionSize", "hints", "the", "partition", "size", "in", "MB", ".", "This", "is", "usually", "used", "when", "sorting", "is", "needed", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_hint.go#L23-L27
28,473
chrislusf/gleam
flow/dataset_hint.go
OnDisk
func (d *Dataset) OnDisk(fn func(*Dataset) *Dataset) *Dataset { ret := fn(d) var parents, currents []*Dataset currents = append(currents, ret) for { for _, t := range currents { isFirstDataset, isLastDataset := false, false if t == ret { isLastDataset = true } else if t.Step.OutputDataset != nil { ...
go
func (d *Dataset) OnDisk(fn func(*Dataset) *Dataset) *Dataset { ret := fn(d) var parents, currents []*Dataset currents = append(currents, ret) for { for _, t := range currents { isFirstDataset, isLastDataset := false, false if t == ret { isLastDataset = true } else if t.Step.OutputDataset != nil { ...
[ "func", "(", "d", "*", "Dataset", ")", "OnDisk", "(", "fn", "func", "(", "*", "Dataset", ")", "*", "Dataset", ")", "*", "Dataset", "{", "ret", ":=", "fn", "(", "d", ")", "\n\n", "var", "parents", ",", "currents", "[", "]", "*", "Dataset", "\n", ...
// OnDisk ensure the intermediate dataset are persisted to disk. // This allows executors to run not in parallel if executors are limited.
[ "OnDisk", "ensure", "the", "intermediate", "dataset", "are", "persisted", "to", "disk", ".", "This", "allows", "executors", "to", "run", "not", "in", "parallel", "if", "executors", "are", "limited", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_hint.go#L31-L63
28,474
chrislusf/gleam
sql/ast/misc.go
Accept
func (n *AdminStmt) Accept(v Visitor) (Node, bool) { newNode, skipChildren := v.Enter(n) if skipChildren { return v.Leave(newNode) } n = newNode.(*AdminStmt) for i, val := range n.Tables { node, ok := val.Accept(v) if !ok { return n, false } n.Tables[i] = node.(*TableName) } return v.Leave(n) }
go
func (n *AdminStmt) Accept(v Visitor) (Node, bool) { newNode, skipChildren := v.Enter(n) if skipChildren { return v.Leave(newNode) } n = newNode.(*AdminStmt) for i, val := range n.Tables { node, ok := val.Accept(v) if !ok { return n, false } n.Tables[i] = node.(*TableName) } return v.Leave(n) }
[ "func", "(", "n", "*", "AdminStmt", ")", "Accept", "(", "v", "Visitor", ")", "(", "Node", ",", "bool", ")", "{", "newNode", ",", "skipChildren", ":=", "v", ".", "Enter", "(", "n", ")", "\n", "if", "skipChildren", "{", "return", "v", ".", "Leave", ...
// Accept implements Node Accpet interface.
[ "Accept", "implements", "Node", "Accpet", "interface", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/ast/misc.go#L475-L491
28,475
chrislusf/gleam
sql/ast/misc.go
Full
func (i Ident) Full(ctx context.Context) (full Ident) { full.Name = i.Name if i.Schema.O != "" { full.Schema = i.Schema } else { full.Schema = model.NewCIStr(ctx.GetSessionVars().CurrentDB) } return }
go
func (i Ident) Full(ctx context.Context) (full Ident) { full.Name = i.Name if i.Schema.O != "" { full.Schema = i.Schema } else { full.Schema = model.NewCIStr(ctx.GetSessionVars().CurrentDB) } return }
[ "func", "(", "i", "Ident", ")", "Full", "(", "ctx", "context", ".", "Context", ")", "(", "full", "Ident", ")", "{", "full", ".", "Name", "=", "i", ".", "Name", "\n", "if", "i", ".", "Schema", ".", "O", "!=", "\"", "\"", "{", "full", ".", "Sch...
// Full returns an Ident which set schema to the current schema if it is empty.
[ "Full", "returns", "an", "Ident", "which", "set", "schema", "to", "the", "current", "schema", "if", "it", "is", "empty", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/ast/misc.go#L583-L591
28,476
chrislusf/gleam
sql/ast/misc.go
String
func (i Ident) String() string { if i.Schema.O == "" { return i.Name.O } return fmt.Sprintf("%s.%s", i.Schema, i.Name) }
go
func (i Ident) String() string { if i.Schema.O == "" { return i.Name.O } return fmt.Sprintf("%s.%s", i.Schema, i.Name) }
[ "func", "(", "i", "Ident", ")", "String", "(", ")", "string", "{", "if", "i", ".", "Schema", ".", "O", "==", "\"", "\"", "{", "return", "i", ".", "Name", ".", "O", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "i", ...
// String implements fmt.Stringer interface
[ "String", "implements", "fmt", ".", "Stringer", "interface" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/ast/misc.go#L594-L599
28,477
chrislusf/gleam
plugins/file/csv/generic_csv_reader.go
error
func (r *Reader) error(err error) error { return &ParseError{ Line: r.line, Column: r.column, Err: err, } }
go
func (r *Reader) error(err error) error { return &ParseError{ Line: r.line, Column: r.column, Err: err, } }
[ "func", "(", "r", "*", "Reader", ")", "error", "(", "err", "error", ")", "error", "{", "return", "&", "ParseError", "{", "Line", ":", "r", ".", "line", ",", "Column", ":", "r", ".", "column", ",", "Err", ":", "err", ",", "}", "\n", "}" ]
// error creates a new ParseError based on err.
[ "error", "creates", "a", "new", "ParseError", "based", "on", "err", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/plugins/file/csv/generic_csv_reader.go#L129-L135
28,478
chrislusf/gleam
plugins/file/csv/generic_csv_reader.go
ReadAll
func (r *Reader) ReadAll() (records [][]string, err error) { for { record, err := r.Read() if err == io.EOF { return records, nil } if err != nil { return nil, err } records = append(records, record) } }
go
func (r *Reader) ReadAll() (records [][]string, err error) { for { record, err := r.Read() if err == io.EOF { return records, nil } if err != nil { return nil, err } records = append(records, record) } }
[ "func", "(", "r", "*", "Reader", ")", "ReadAll", "(", ")", "(", "records", "[", "]", "[", "]", "string", ",", "err", "error", ")", "{", "for", "{", "record", ",", "err", ":=", "r", ".", "Read", "(", ")", "\n", "if", "err", "==", "io", ".", ...
// ReadAll reads all the remaining records from r. // Each record is a slice of fields. // A successful call returns err == nil, not err == EOF. Because ReadAll is // defined to read until EOF, it does not treat end of file as an error to be // reported.
[ "ReadAll", "reads", "all", "the", "remaining", "records", "from", "r", ".", "Each", "record", "is", "a", "slice", "of", "fields", ".", "A", "successful", "call", "returns", "err", "==", "nil", "not", "err", "==", "EOF", ".", "Because", "ReadAll", "is", ...
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/plugins/file/csv/generic_csv_reader.go#L166-L177
28,479
chrislusf/gleam
plugins/file/csv/generic_csv_reader.go
readRune
func (r *Reader) readRune() (rune, error) { r1, _, err := r.r.ReadRune() // Handle \r\n here. We make the simplifying assumption that // anytime \r is followed by \n that it can be folded to \n. // We will not detect files which contain both \r\n and bare \n. if r1 == '\r' { r1, _, err = r.r.ReadRune() if er...
go
func (r *Reader) readRune() (rune, error) { r1, _, err := r.r.ReadRune() // Handle \r\n here. We make the simplifying assumption that // anytime \r is followed by \n that it can be folded to \n. // We will not detect files which contain both \r\n and bare \n. if r1 == '\r' { r1, _, err = r.r.ReadRune() if er...
[ "func", "(", "r", "*", "Reader", ")", "readRune", "(", ")", "(", "rune", ",", "error", ")", "{", "r1", ",", "_", ",", "err", ":=", "r", ".", "r", ".", "ReadRune", "(", ")", "\n\n", "// Handle \\r\\n here. We make the simplifying assumption that", "// anyt...
// readRune reads one rune from r, folding \r\n to \n and keeping track // of how far into the line we have read. r.column will point to the start // of this rune, not the end of this rune.
[ "readRune", "reads", "one", "rune", "from", "r", "folding", "\\", "r", "\\", "n", "to", "\\", "n", "and", "keeping", "track", "of", "how", "far", "into", "the", "line", "we", "have", "read", ".", "r", ".", "column", "will", "point", "to", "the", "s...
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/plugins/file/csv/generic_csv_reader.go#L182-L199
28,480
chrislusf/gleam
plugins/file/csv/generic_csv_reader.go
skip
func (r *Reader) skip(delim rune) error { for { r1, err := r.readRune() if err != nil { return err } if r1 == delim { return nil } } }
go
func (r *Reader) skip(delim rune) error { for { r1, err := r.readRune() if err != nil { return err } if r1 == delim { return nil } } }
[ "func", "(", "r", "*", "Reader", ")", "skip", "(", "delim", "rune", ")", "error", "{", "for", "{", "r1", ",", "err", ":=", "r", ".", "readRune", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "r1", "=="...
// skip reads runes up to and including the rune delim or until error.
[ "skip", "reads", "runes", "up", "to", "and", "including", "the", "rune", "delim", "or", "until", "error", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/plugins/file/csv/generic_csv_reader.go#L202-L212
28,481
chrislusf/gleam
plugins/file/csv/generic_csv_reader.go
parseRecord
func (r *Reader) parseRecord() (fields []string, err error) { // Each record starts on a new line. We increment our line // number (lines start at 1, not 0) and set column to -1 // so as we increment in readRune it points to the character we read. r.line++ r.column = -1 // Peek at the first rune. If it is an e...
go
func (r *Reader) parseRecord() (fields []string, err error) { // Each record starts on a new line. We increment our line // number (lines start at 1, not 0) and set column to -1 // so as we increment in readRune it points to the character we read. r.line++ r.column = -1 // Peek at the first rune. If it is an e...
[ "func", "(", "r", "*", "Reader", ")", "parseRecord", "(", ")", "(", "fields", "[", "]", "string", ",", "err", "error", ")", "{", "// Each record starts on a new line. We increment our line", "// number (lines start at 1, not 0) and set column to -1", "// so as we increment...
// parseRecord reads and parses a single csv record from r.
[ "parseRecord", "reads", "and", "parses", "a", "single", "csv", "record", "from", "r", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/plugins/file/csv/generic_csv_reader.go#L215-L248
28,482
chrislusf/gleam
sql/expression/scalar_function.go
NewFunction
func NewFunction(ctx context.Context, funcName string, retType *types.FieldType, args ...Expression) (Expression, error) { fc, ok := funcs[funcName] if !ok { return nil, errFunctionNotExists.GenByArgs(funcName) } funcArgs := make([]Expression, len(args)) copy(funcArgs, args) f, err := fc.getFunction(funcArgs, c...
go
func NewFunction(ctx context.Context, funcName string, retType *types.FieldType, args ...Expression) (Expression, error) { fc, ok := funcs[funcName] if !ok { return nil, errFunctionNotExists.GenByArgs(funcName) } funcArgs := make([]Expression, len(args)) copy(funcArgs, args) f, err := fc.getFunction(funcArgs, c...
[ "func", "NewFunction", "(", "ctx", "context", ".", "Context", ",", "funcName", "string", ",", "retType", "*", "types", ".", "FieldType", ",", "args", "...", "Expression", ")", "(", "Expression", ",", "error", ")", "{", "fc", ",", "ok", ":=", "funcs", "...
// NewFunction creates a new scalar function or constant.
[ "NewFunction", "creates", "a", "new", "scalar", "function", "or", "constant", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/scalar_function.go#L65-L81
28,483
chrislusf/gleam
distributed/driver/scheduler/market/cda_market.go
AddDemand
func (m *Market) AddDemand(r Requirement, bid float64, retChan chan Supply) { m.Lock.Lock() defer m.Lock.Unlock() if len(m.Supplies) > 0 { supply, matched := m.pickBestSupplyFor(r) if matched { retChan <- supply close(retChan) return } } m.Demands = append(m.Demands, Demand{ Requirement: r, Bid...
go
func (m *Market) AddDemand(r Requirement, bid float64, retChan chan Supply) { m.Lock.Lock() defer m.Lock.Unlock() if len(m.Supplies) > 0 { supply, matched := m.pickBestSupplyFor(r) if matched { retChan <- supply close(retChan) return } } m.Demands = append(m.Demands, Demand{ Requirement: r, Bid...
[ "func", "(", "m", "*", "Market", ")", "AddDemand", "(", "r", "Requirement", ",", "bid", "float64", ",", "retChan", "chan", "Supply", ")", "{", "m", ".", "Lock", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Lock", ".", "Unlock", "(", ")", "\n\...
// retChan should be a buffered channel
[ "retChan", "should", "be", "a", "buffered", "channel" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/driver/scheduler/market/cda_market.go#L63-L81
28,484
chrislusf/gleam
util/printf.go
TsvPrintf
func TsvPrintf(writer io.Writer, reader io.Reader, format string) error { return TakeTsv(reader, -1, func(args []string) error { var objects []interface{} for _, arg := range args { objects = append(objects, arg) } if len(objects) > 0 { _, err := fmt.Fprintf(writer, format, objects...) return err } ...
go
func TsvPrintf(writer io.Writer, reader io.Reader, format string) error { return TakeTsv(reader, -1, func(args []string) error { var objects []interface{} for _, arg := range args { objects = append(objects, arg) } if len(objects) > 0 { _, err := fmt.Fprintf(writer, format, objects...) return err } ...
[ "func", "TsvPrintf", "(", "writer", "io", ".", "Writer", ",", "reader", "io", ".", "Reader", ",", "format", "string", ")", "error", "{", "return", "TakeTsv", "(", "reader", ",", "-", "1", ",", "func", "(", "args", "[", "]", "string", ")", "error", ...
// TsvPrintf reads TSV lines from reader, // and formats according to a format specifier and writes to writer.
[ "TsvPrintf", "reads", "TSV", "lines", "from", "reader", "and", "formats", "according", "to", "a", "format", "specifier", "and", "writes", "to", "writer", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/util/printf.go#L12-L24
28,485
chrislusf/gleam
util/printf.go
Fprintf
func Fprintf(writer io.Writer, reader io.Reader, format string) error { return ProcessMessage(reader, func(encodedBytes []byte) error { var decodedObjects []interface{} var row *Row var err error // fmt.Printf("chan input encoded: %s\n", string(encodedBytes)) if row, err = DecodeRow(encodedBytes); err != ni...
go
func Fprintf(writer io.Writer, reader io.Reader, format string) error { return ProcessMessage(reader, func(encodedBytes []byte) error { var decodedObjects []interface{} var row *Row var err error // fmt.Printf("chan input encoded: %s\n", string(encodedBytes)) if row, err = DecodeRow(encodedBytes); err != ni...
[ "func", "Fprintf", "(", "writer", "io", ".", "Writer", ",", "reader", "io", ".", "Reader", ",", "format", "string", ")", "error", "{", "return", "ProcessMessage", "(", "reader", ",", "func", "(", "encodedBytes", "[", "]", "byte", ")", "error", "{", "va...
// Fprintf reads MessagePack encoded messages from reader, // and formats according to a format specifier and writes to writer.
[ "Fprintf", "reads", "MessagePack", "encoded", "messages", "from", "reader", "and", "formats", "according", "to", "a", "format", "specifier", "and", "writes", "to", "writer", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/util/printf.go#L28-L45
28,486
chrislusf/gleam
util/printf.go
PrintDelimited
func PrintDelimited(stat *pb.InstructionStat, reader io.Reader, writer io.Writer, delimiter string, lineSperator string) error { return ProcessMessage(reader, func(encodedBytes []byte) error { var row *Row var err error // fmt.Printf("chan input encoded: %s\n", string(encodedBytes)) if row, err = DecodeRow(enc...
go
func PrintDelimited(stat *pb.InstructionStat, reader io.Reader, writer io.Writer, delimiter string, lineSperator string) error { return ProcessMessage(reader, func(encodedBytes []byte) error { var row *Row var err error // fmt.Printf("chan input encoded: %s\n", string(encodedBytes)) if row, err = DecodeRow(enc...
[ "func", "PrintDelimited", "(", "stat", "*", "pb", ".", "InstructionStat", ",", "reader", "io", ".", "Reader", ",", "writer", "io", ".", "Writer", ",", "delimiter", "string", ",", "lineSperator", "string", ")", "error", "{", "return", "ProcessMessage", "(", ...
// PrintDelimited Reads and formats MessagePack encoded messages // with delimiter and lineSeparator.
[ "PrintDelimited", "Reads", "and", "formats", "MessagePack", "encoded", "messages", "with", "delimiter", "and", "lineSeparator", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/util/printf.go#L49-L75
28,487
chrislusf/gleam
sql/plan/match_property.go
matchPropColumn
func matchPropColumn(prop *requiredProperty, matchedIdx int, idxCol *model.IndexColumn) int { if matchedIdx < prop.sortKeyLen { // When walking through the first sorKeyLen column, // we should make sure to match them as the columns order exactly. // So we must check the column in position of matchedIdx. propCo...
go
func matchPropColumn(prop *requiredProperty, matchedIdx int, idxCol *model.IndexColumn) int { if matchedIdx < prop.sortKeyLen { // When walking through the first sorKeyLen column, // we should make sure to match them as the columns order exactly. // So we must check the column in position of matchedIdx. propCo...
[ "func", "matchPropColumn", "(", "prop", "*", "requiredProperty", ",", "matchedIdx", "int", ",", "idxCol", "*", "model", ".", "IndexColumn", ")", "int", "{", "if", "matchedIdx", "<", "prop", ".", "sortKeyLen", "{", "// When walking through the first sorKeyLen column,...
// matchPropColumn checks if the idxCol match one of columns in required property and return the matched index. // If no column is matched, return -1.
[ "matchPropColumn", "checks", "if", "the", "idxCol", "match", "one", "of", "columns", "in", "required", "property", "and", "return", "the", "matched", "index", ".", "If", "no", "column", "is", "matched", "return", "-", "1", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/match_property.go#L79-L97
28,488
chrislusf/gleam
sql/util/types/datum.go
SetRow
func (d *Datum) SetRow(ds []Datum) { d.k = KindRow d.x = ds }
go
func (d *Datum) SetRow(ds []Datum) { d.k = KindRow d.x = ds }
[ "func", "(", "d", "*", "Datum", ")", "SetRow", "(", "ds", "[", "]", "Datum", ")", "{", "d", ".", "k", "=", "KindRow", "\n", "d", ".", "x", "=", "ds", "\n", "}" ]
// SetRow sets row value.
[ "SetRow", "sets", "row", "value", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum.go#L198-L201
28,489
chrislusf/gleam
sql/util/types/datum.go
GetMysqlBit
func (d *Datum) GetMysqlBit() Bit { width := int(d.length) value := uint64(d.i) return Bit{Value: value, Width: width} }
go
func (d *Datum) GetMysqlBit() Bit { width := int(d.length) value := uint64(d.i) return Bit{Value: value, Width: width} }
[ "func", "(", "d", "*", "Datum", ")", "GetMysqlBit", "(", ")", "Bit", "{", "width", ":=", "int", "(", "d", ".", "length", ")", "\n", "value", ":=", "uint64", "(", "d", ".", "i", ")", "\n", "return", "Bit", "{", "Value", ":", "value", ",", "Width...
// GetMysqlBit gets Bit value
[ "GetMysqlBit", "gets", "Bit", "value" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum.go#L210-L214
28,490
chrislusf/gleam
sql/util/types/datum.go
SetMysqlBit
func (d *Datum) SetMysqlBit(b Bit) { d.k = KindMysqlBit d.length = uint32(b.Width) d.i = int64(b.Value) }
go
func (d *Datum) SetMysqlBit(b Bit) { d.k = KindMysqlBit d.length = uint32(b.Width) d.i = int64(b.Value) }
[ "func", "(", "d", "*", "Datum", ")", "SetMysqlBit", "(", "b", "Bit", ")", "{", "d", ".", "k", "=", "KindMysqlBit", "\n", "d", ".", "length", "=", "uint32", "(", "b", ".", "Width", ")", "\n", "d", ".", "i", "=", "int64", "(", "b", ".", "Value"...
// SetMysqlBit sets Bit value
[ "SetMysqlBit", "sets", "Bit", "value" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum.go#L217-L221
28,491
chrislusf/gleam
sql/util/types/datum.go
GetMysqlEnum
func (d *Datum) GetMysqlEnum() Enum { return Enum{Value: uint64(d.i), Name: hack.String(d.b)} }
go
func (d *Datum) GetMysqlEnum() Enum { return Enum{Value: uint64(d.i), Name: hack.String(d.b)} }
[ "func", "(", "d", "*", "Datum", ")", "GetMysqlEnum", "(", ")", "Enum", "{", "return", "Enum", "{", "Value", ":", "uint64", "(", "d", ".", "i", ")", ",", "Name", ":", "hack", ".", "String", "(", "d", ".", "b", ")", "}", "\n", "}" ]
// GetMysqlEnum gets Enum value
[ "GetMysqlEnum", "gets", "Enum", "value" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum.go#L247-L249
28,492
chrislusf/gleam
sql/util/types/datum.go
SetMysqlHex
func (d *Datum) SetMysqlHex(b Hex) { d.k = KindMysqlHex d.i = b.Value }
go
func (d *Datum) SetMysqlHex(b Hex) { d.k = KindMysqlHex d.i = b.Value }
[ "func", "(", "d", "*", "Datum", ")", "SetMysqlHex", "(", "b", "Hex", ")", "{", "d", ".", "k", "=", "KindMysqlHex", "\n", "d", ".", "i", "=", "b", ".", "Value", "\n", "}" ]
// SetMysqlHex sets Hex value
[ "SetMysqlHex", "sets", "Hex", "value" ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum.go#L265-L268
28,493
chrislusf/gleam
sql/util/types/datum.go
Cast
func (d *Datum) Cast(sc *variable.StatementContext, target *FieldType) (ad Datum, err error) { if !isCastType(target.Tp) { return ad, errors.Errorf("unknown cast type - %v", target) } return d.ConvertTo(sc, target) }
go
func (d *Datum) Cast(sc *variable.StatementContext, target *FieldType) (ad Datum, err error) { if !isCastType(target.Tp) { return ad, errors.Errorf("unknown cast type - %v", target) } return d.ConvertTo(sc, target) }
[ "func", "(", "d", "*", "Datum", ")", "Cast", "(", "sc", "*", "variable", ".", "StatementContext", ",", "target", "*", "FieldType", ")", "(", "ad", "Datum", ",", "err", "error", ")", "{", "if", "!", "isCastType", "(", "target", ".", "Tp", ")", "{", ...
// Cast casts datum to certain types.
[ "Cast", "casts", "datum", "to", "certain", "types", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum.go#L636-L641
28,494
chrislusf/gleam
sql/util/types/datum.go
ToString
func (d *Datum) ToString() (string, error) { switch d.Kind() { case KindInt64: return strconv.FormatInt(d.GetInt64(), 10), nil case KindUint64: return strconv.FormatUint(d.GetUint64(), 10), nil case KindFloat32: return strconv.FormatFloat(float64(d.GetFloat32()), 'f', -1, 32), nil case KindFloat64: return ...
go
func (d *Datum) ToString() (string, error) { switch d.Kind() { case KindInt64: return strconv.FormatInt(d.GetInt64(), 10), nil case KindUint64: return strconv.FormatUint(d.GetUint64(), 10), nil case KindFloat32: return strconv.FormatFloat(float64(d.GetFloat32()), 'f', -1, 32), nil case KindFloat64: return ...
[ "func", "(", "d", "*", "Datum", ")", "ToString", "(", ")", "(", "string", ",", "error", ")", "{", "switch", "d", ".", "Kind", "(", ")", "{", "case", "KindInt64", ":", "return", "strconv", ".", "FormatInt", "(", "d", ".", "GetInt64", "(", ")", ","...
// ToString gets the string representation of the datum.
[ "ToString", "gets", "the", "string", "representation", "of", "the", "datum", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum.go#L1299-L1330
28,495
chrislusf/gleam
sql/util/types/datum.go
CoerceDatum
func CoerceDatum(sc *variable.StatementContext, a, b Datum) (x, y Datum, err error) { if a.IsNull() || b.IsNull() { return x, y, nil } var ( hasUint bool hasDecimal bool hasFloat bool ) x = a.convergeType(&hasUint, &hasDecimal, &hasFloat) y = b.convergeType(&hasUint, &hasDecimal, &hasFloat) if hasFl...
go
func CoerceDatum(sc *variable.StatementContext, a, b Datum) (x, y Datum, err error) { if a.IsNull() || b.IsNull() { return x, y, nil } var ( hasUint bool hasDecimal bool hasFloat bool ) x = a.convergeType(&hasUint, &hasDecimal, &hasFloat) y = b.convergeType(&hasUint, &hasDecimal, &hasFloat) if hasFl...
[ "func", "CoerceDatum", "(", "sc", "*", "variable", ".", "StatementContext", ",", "a", ",", "b", "Datum", ")", "(", "x", ",", "y", "Datum", ",", "err", "error", ")", "{", "if", "a", ".", "IsNull", "(", ")", "||", "b", ".", "IsNull", "(", ")", "{...
// CoerceDatum changes type. // If a or b is Float, changes the both to Float. // Else if a or b is Decimal, changes the both to Decimal. // Else if a or b is Uint and op is not div, mod, or intDiv changes the both to Uint.
[ "CoerceDatum", "changes", "type", ".", "If", "a", "or", "b", "is", "Float", "changes", "the", "both", "to", "Float", ".", "Else", "if", "a", "or", "b", "is", "Decimal", "changes", "the", "both", "to", "Decimal", ".", "Else", "if", "a", "or", "b", "...
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum.go#L1357-L1423
28,496
chrislusf/gleam
sql/util/types/datum.go
DatumsToInterfaces
func DatumsToInterfaces(datums []Datum) []interface{} { ins := make([]interface{}, len(datums)) for i, v := range datums { ins[i] = v.GetValue() } return ins }
go
func DatumsToInterfaces(datums []Datum) []interface{} { ins := make([]interface{}, len(datums)) for i, v := range datums { ins[i] = v.GetValue() } return ins }
[ "func", "DatumsToInterfaces", "(", "datums", "[", "]", "Datum", ")", "[", "]", "interface", "{", "}", "{", "ins", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "len", "(", "datums", ")", ")", "\n", "for", "i", ",", "v", ":=", "range", ...
// DatumsToInterfaces converts a datum slice to interface slice.
[ "DatumsToInterfaces", "converts", "a", "datum", "slice", "to", "interface", "slice", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum.go#L1494-L1500
28,497
chrislusf/gleam
sql/util/types/datum.go
SortDatums
func SortDatums(sc *variable.StatementContext, datums []Datum) error { sorter := datumsSorter{datums: datums, sc: sc} sort.Sort(&sorter) return sorter.err }
go
func SortDatums(sc *variable.StatementContext, datums []Datum) error { sorter := datumsSorter{datums: datums, sc: sc} sort.Sort(&sorter) return sorter.err }
[ "func", "SortDatums", "(", "sc", "*", "variable", ".", "StatementContext", ",", "datums", "[", "]", "Datum", ")", "error", "{", "sorter", ":=", "datumsSorter", "{", "datums", ":", "datums", ",", "sc", ":", "sc", "}", "\n", "sort", ".", "Sort", "(", "...
// SortDatums sorts a slice of datum.
[ "SortDatums", "sorts", "a", "slice", "of", "datum", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum.go#L1536-L1540
28,498
chrislusf/gleam
sql/expression/builtin_time.go
errorOrWarning
func errorOrWarning(err error, ctx context.Context) error { sc := ctx.GetSessionVars().StmtCtx // TODO: Use better name, such as sc.IsInsert instead of sc.IgnoreTruncate. if ctx.GetSessionVars().StrictSQLMode && !sc.IgnoreTruncate { return errors.Trace(types.ErrInvalidTimeFormat) } sc.AppendWarning(err) return ...
go
func errorOrWarning(err error, ctx context.Context) error { sc := ctx.GetSessionVars().StmtCtx // TODO: Use better name, such as sc.IsInsert instead of sc.IgnoreTruncate. if ctx.GetSessionVars().StrictSQLMode && !sc.IgnoreTruncate { return errors.Trace(types.ErrInvalidTimeFormat) } sc.AppendWarning(err) return ...
[ "func", "errorOrWarning", "(", "err", "error", ",", "ctx", "context", ".", "Context", ")", "error", "{", "sc", ":=", "ctx", ".", "GetSessionVars", "(", ")", ".", "StmtCtx", "\n", "// TODO: Use better name, such as sc.IsInsert instead of sc.IgnoreTruncate.", "if", "c...
// errorOrWarning reports error or warning depend on the context.
[ "errorOrWarning", "reports", "error", "or", "warning", "depend", "on", "the", "context", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/builtin_time.go#L1516-L1524
28,499
chrislusf/gleam
sql/expression/builtin_other.go
BuiltinValuesFactory
func BuiltinValuesFactory(offset int) BuiltinFunc { return func(_ []types.Datum, ctx context.Context) (d types.Datum, err error) { values := ctx.GetSessionVars().CurrInsertValues if values == nil { err = errors.New("Session current insert values is nil") return } row := values.([]types.Datum) if len(ro...
go
func BuiltinValuesFactory(offset int) BuiltinFunc { return func(_ []types.Datum, ctx context.Context) (d types.Datum, err error) { values := ctx.GetSessionVars().CurrInsertValues if values == nil { err = errors.New("Session current insert values is nil") return } row := values.([]types.Datum) if len(ro...
[ "func", "BuiltinValuesFactory", "(", "offset", "int", ")", "BuiltinFunc", "{", "return", "func", "(", "_", "[", "]", "types", ".", "Datum", ",", "ctx", "context", ".", "Context", ")", "(", "d", "types", ".", "Datum", ",", "err", "error", ")", "{", "v...
// BuiltinValuesFactory generates values builtin function.
[ "BuiltinValuesFactory", "generates", "values", "builtin", "function", "." ]
a7aa467b545f5e5e452aaf818299a5f6e6b23760
https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/builtin_other.go#L391-L405