repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
chrislusf/gleam | instruction/utils.go | newChannelOfValuesWithSameKey | func newChannelOfValuesWithSameKey(name string, sortedChan io.Reader, indexes []int) chan util.Row {
writer := make(chan util.Row, 1024)
go func() {
defer close(writer)
firstRow, err := util.ReadRow(sortedChan)
if err != nil {
if err != io.EOF {
fmt.Fprintf(os.Stderr, "%s join read first row error: %v\... | go | func newChannelOfValuesWithSameKey(name string, sortedChan io.Reader, indexes []int) chan util.Row {
writer := make(chan util.Row, 1024)
go func() {
defer close(writer)
firstRow, err := util.ReadRow(sortedChan)
if err != nil {
if err != io.EOF {
fmt.Fprintf(os.Stderr, "%s join read first row error: %v\... | [
"func",
"newChannelOfValuesWithSameKey",
"(",
"name",
"string",
",",
"sortedChan",
"io",
".",
"Reader",
",",
"indexes",
"[",
"]",
"int",
")",
"chan",
"util",
".",
"Row",
"{",
"writer",
":=",
"make",
"(",
"chan",
"util",
".",
"Row",
",",
"1024",
")",
"\... | // create a channel to aggregate values of the same key
// automatically close original sorted channel | [
"create",
"a",
"channel",
"to",
"aggregate",
"values",
"of",
"the",
"same",
"key",
"automatically",
"close",
"original",
"sorted",
"channel"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/instruction/utils.go#L32-L78 | train |
chrislusf/gleam | sql/util/printer/printer.go | GetPrintResult | func GetPrintResult(cols []string, datas [][]string) (string, bool) {
if !checkValidity(cols, datas) {
return "", false
}
var value []byte
maxColLen := getMaxColLen(cols, datas)
value = append(value, getPrintDivLine(maxColLen)...)
value = append(value, getPrintCol(cols, maxColLen)...)
value = append(value, g... | go | func GetPrintResult(cols []string, datas [][]string) (string, bool) {
if !checkValidity(cols, datas) {
return "", false
}
var value []byte
maxColLen := getMaxColLen(cols, datas)
value = append(value, getPrintDivLine(maxColLen)...)
value = append(value, getPrintCol(cols, maxColLen)...)
value = append(value, g... | [
"func",
"GetPrintResult",
"(",
"cols",
"[",
"]",
"string",
",",
"datas",
"[",
"]",
"[",
"]",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"!",
"checkValidity",
"(",
"cols",
",",
"datas",
")",
"{",
"return",
"\"",
"\"",
",",
"false",
... | // GetPrintResult gets a result with a formatted string. | [
"GetPrintResult",
"gets",
"a",
"result",
"with",
"a",
"formatted",
"string",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/printer/printer.go#L122-L136 | train |
chrislusf/gleam | sql/expression/helper.go | IsCurrentTimeExpr | func IsCurrentTimeExpr(e ast.ExprNode) bool {
x, ok := e.(*ast.FuncCallExpr)
if !ok {
return false
}
return x.FnName.L == currentTimestampL
} | go | func IsCurrentTimeExpr(e ast.ExprNode) bool {
x, ok := e.(*ast.FuncCallExpr)
if !ok {
return false
}
return x.FnName.L == currentTimestampL
} | [
"func",
"IsCurrentTimeExpr",
"(",
"e",
"ast",
".",
"ExprNode",
")",
"bool",
"{",
"x",
",",
"ok",
":=",
"e",
".",
"(",
"*",
"ast",
".",
"FuncCallExpr",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"x",
".",
"FnNam... | // IsCurrentTimeExpr returns whether e is CurrentTimeExpr. | [
"IsCurrentTimeExpr",
"returns",
"whether",
"e",
"is",
"CurrentTimeExpr",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/helper.go#L129-L135 | train |
chrislusf/gleam | distributed/plan/plan_physical.go | translateToTaskGroups | func translateToTaskGroups(stepId2StepGroup []*StepGroup) (ret []*TaskGroup) {
for _, stepGroup := range stepId2StepGroup {
assertSameNumberOfTasks(stepGroup.Steps)
count := len(stepGroup.Steps[0].Tasks)
// println("dealing with", stepGroup.Steps[0].Name, "tasks:", len(stepGroup.Steps[0].Tasks))
for i := 0; i ... | go | func translateToTaskGroups(stepId2StepGroup []*StepGroup) (ret []*TaskGroup) {
for _, stepGroup := range stepId2StepGroup {
assertSameNumberOfTasks(stepGroup.Steps)
count := len(stepGroup.Steps[0].Tasks)
// println("dealing with", stepGroup.Steps[0].Name, "tasks:", len(stepGroup.Steps[0].Tasks))
for i := 0; i ... | [
"func",
"translateToTaskGroups",
"(",
"stepId2StepGroup",
"[",
"]",
"*",
"StepGroup",
")",
"(",
"ret",
"[",
"]",
"*",
"TaskGroup",
")",
"{",
"for",
"_",
",",
"stepGroup",
":=",
"range",
"stepId2StepGroup",
"{",
"assertSameNumberOfTasks",
"(",
"stepGroup",
".",... | // group local tasks into one task group | [
"group",
"local",
"tasks",
"into",
"one",
"task",
"group"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/plan/plan_physical.go#L10-L29 | train |
chrislusf/gleam | sql/plan/planbuilder.go | splitWhere | func splitWhere(where ast.ExprNode) []ast.ExprNode {
var conditions []ast.ExprNode
switch x := where.(type) {
case nil:
case *ast.BinaryOperationExpr:
if x.Op == opcode.AndAnd {
conditions = append(conditions, splitWhere(x.L)...)
conditions = append(conditions, splitWhere(x.R)...)
} else {
conditions =... | go | func splitWhere(where ast.ExprNode) []ast.ExprNode {
var conditions []ast.ExprNode
switch x := where.(type) {
case nil:
case *ast.BinaryOperationExpr:
if x.Op == opcode.AndAnd {
conditions = append(conditions, splitWhere(x.L)...)
conditions = append(conditions, splitWhere(x.R)...)
} else {
conditions =... | [
"func",
"splitWhere",
"(",
"where",
"ast",
".",
"ExprNode",
")",
"[",
"]",
"ast",
".",
"ExprNode",
"{",
"var",
"conditions",
"[",
"]",
"ast",
".",
"ExprNode",
"\n",
"switch",
"x",
":=",
"where",
".",
"(",
"type",
")",
"{",
"case",
"nil",
":",
"case... | // splitWhere split a where expression to a list of AND conditions. | [
"splitWhere",
"split",
"a",
"where",
"expression",
"to",
"a",
"list",
"of",
"AND",
"conditions",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/planbuilder.go#L250-L267 | train |
chrislusf/gleam | sql/util/types/datum_eval.go | CoerceArithmetic | func CoerceArithmetic(sc *variable.StatementContext, a Datum) (d Datum, err error) {
switch a.Kind() {
case KindString, KindBytes:
// MySQL will convert string to float for arithmetic operation
f, err := StrToFloat(sc, a.GetString())
if err != nil {
return d, errors.Trace(err)
}
d.SetFloat64(f)
return ... | go | func CoerceArithmetic(sc *variable.StatementContext, a Datum) (d Datum, err error) {
switch a.Kind() {
case KindString, KindBytes:
// MySQL will convert string to float for arithmetic operation
f, err := StrToFloat(sc, a.GetString())
if err != nil {
return d, errors.Trace(err)
}
d.SetFloat64(f)
return ... | [
"func",
"CoerceArithmetic",
"(",
"sc",
"*",
"variable",
".",
"StatementContext",
",",
"a",
"Datum",
")",
"(",
"d",
"Datum",
",",
"err",
"error",
")",
"{",
"switch",
"a",
".",
"Kind",
"(",
")",
"{",
"case",
"KindString",
",",
"KindBytes",
":",
"// MySQL... | // CoerceArithmetic converts datum to appropriate datum for arithmetic computing. | [
"CoerceArithmetic",
"converts",
"datum",
"to",
"appropriate",
"datum",
"for",
"arithmetic",
"computing",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum_eval.go#L25-L72 | train |
chrislusf/gleam | sql/util/types/datum_eval.go | ComputePlus | func ComputePlus(a, b Datum) (d Datum, err error) {
switch a.Kind() {
case KindInt64:
switch b.Kind() {
case KindInt64:
r, err1 := AddInt64(a.GetInt64(), b.GetInt64())
d.SetInt64(r)
return d, errors.Trace(err1)
case KindUint64:
r, err1 := AddInteger(b.GetUint64(), a.GetInt64())
d.SetUint64(r)
... | go | func ComputePlus(a, b Datum) (d Datum, err error) {
switch a.Kind() {
case KindInt64:
switch b.Kind() {
case KindInt64:
r, err1 := AddInt64(a.GetInt64(), b.GetInt64())
d.SetInt64(r)
return d, errors.Trace(err1)
case KindUint64:
r, err1 := AddInteger(b.GetUint64(), a.GetInt64())
d.SetUint64(r)
... | [
"func",
"ComputePlus",
"(",
"a",
",",
"b",
"Datum",
")",
"(",
"d",
"Datum",
",",
"err",
"error",
")",
"{",
"switch",
"a",
".",
"Kind",
"(",
")",
"{",
"case",
"KindInt64",
":",
"switch",
"b",
".",
"Kind",
"(",
")",
"{",
"case",
"KindInt64",
":",
... | // ComputePlus computes the result of a+b. | [
"ComputePlus",
"computes",
"the",
"result",
"of",
"a",
"+",
"b",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum_eval.go#L75-L117 | train |
chrislusf/gleam | sql/util/types/datum_eval.go | ComputeMinus | func ComputeMinus(a, b Datum) (d Datum, err error) {
switch a.Kind() {
case KindInt64:
switch b.Kind() {
case KindInt64:
r, err1 := SubInt64(a.GetInt64(), b.GetInt64())
d.SetInt64(r)
return d, errors.Trace(err1)
case KindUint64:
r, err1 := SubIntWithUint(a.GetInt64(), b.GetUint64())
d.SetUint64(r... | go | func ComputeMinus(a, b Datum) (d Datum, err error) {
switch a.Kind() {
case KindInt64:
switch b.Kind() {
case KindInt64:
r, err1 := SubInt64(a.GetInt64(), b.GetInt64())
d.SetInt64(r)
return d, errors.Trace(err1)
case KindUint64:
r, err1 := SubIntWithUint(a.GetInt64(), b.GetUint64())
d.SetUint64(r... | [
"func",
"ComputeMinus",
"(",
"a",
",",
"b",
"Datum",
")",
"(",
"d",
"Datum",
",",
"err",
"error",
")",
"{",
"switch",
"a",
".",
"Kind",
"(",
")",
"{",
"case",
"KindInt64",
":",
"switch",
"b",
".",
"Kind",
"(",
")",
"{",
"case",
"KindInt64",
":",
... | // ComputeMinus computes the result of a-b. | [
"ComputeMinus",
"computes",
"the",
"result",
"of",
"a",
"-",
"b",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum_eval.go#L120-L162 | train |
chrislusf/gleam | sql/util/types/datum_eval.go | ComputeMod | func ComputeMod(sc *variable.StatementContext, a, b Datum) (d Datum, err error) {
switch a.Kind() {
case KindInt64:
x := a.GetInt64()
switch b.Kind() {
case KindInt64:
y := b.GetInt64()
if y == 0 {
return d, nil
}
d.SetInt64(x % y)
return d, nil
case KindUint64:
y := b.GetUint64()
if ... | go | func ComputeMod(sc *variable.StatementContext, a, b Datum) (d Datum, err error) {
switch a.Kind() {
case KindInt64:
x := a.GetInt64()
switch b.Kind() {
case KindInt64:
y := b.GetInt64()
if y == 0 {
return d, nil
}
d.SetInt64(x % y)
return d, nil
case KindUint64:
y := b.GetUint64()
if ... | [
"func",
"ComputeMod",
"(",
"sc",
"*",
"variable",
".",
"StatementContext",
",",
"a",
",",
"b",
"Datum",
")",
"(",
"d",
"Datum",
",",
"err",
"error",
")",
"{",
"switch",
"a",
".",
"Kind",
"(",
")",
"{",
"case",
"KindInt64",
":",
"x",
":=",
"a",
".... | // ComputeMod computes the result of a mod b. | [
"ComputeMod",
"computes",
"the",
"result",
"of",
"a",
"mod",
"b",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum_eval.go#L255-L330 | train |
chrislusf/gleam | sql/util/types/datum_eval.go | decimal2RoundUint | func decimal2RoundUint(x *MyDecimal) (uint64, error) {
roundX := new(MyDecimal)
x.Round(roundX, 0)
var (
uintX uint64
err error
)
if roundX.IsNegative() {
intX, err := roundX.ToInt()
if err != nil && err != ErrTruncated {
return 0, errors.Trace(err)
}
uintX = uint64(intX)
} else {
uintX, err = ... | go | func decimal2RoundUint(x *MyDecimal) (uint64, error) {
roundX := new(MyDecimal)
x.Round(roundX, 0)
var (
uintX uint64
err error
)
if roundX.IsNegative() {
intX, err := roundX.ToInt()
if err != nil && err != ErrTruncated {
return 0, errors.Trace(err)
}
uintX = uint64(intX)
} else {
uintX, err = ... | [
"func",
"decimal2RoundUint",
"(",
"x",
"*",
"MyDecimal",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"roundX",
":=",
"new",
"(",
"MyDecimal",
")",
"\n",
"x",
".",
"Round",
"(",
"roundX",
",",
"0",
")",
"\n",
"var",
"(",
"uintX",
"uint64",
"\n",
"er... | // decimal2RoundUint converts a MyDecimal to an uint64 after rounding. | [
"decimal2RoundUint",
"converts",
"a",
"MyDecimal",
"to",
"an",
"uint64",
"after",
"rounding",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum_eval.go#L400-L421 | train |
chrislusf/gleam | sql/util/types/datum_eval.go | ComputeBitNeg | func ComputeBitNeg(sc *variable.StatementContext, a Datum) (d Datum, err error) {
aKind := a.Kind()
if aKind == KindInt64 || aKind == KindUint64 {
d.SetUint64(^a.GetUint64())
return
}
// If either is not integer, we round the operands and then use uint64 to calculate.
x, err := convertNonInt2RoundUint64(sc, a)... | go | func ComputeBitNeg(sc *variable.StatementContext, a Datum) (d Datum, err error) {
aKind := a.Kind()
if aKind == KindInt64 || aKind == KindUint64 {
d.SetUint64(^a.GetUint64())
return
}
// If either is not integer, we round the operands and then use uint64 to calculate.
x, err := convertNonInt2RoundUint64(sc, a)... | [
"func",
"ComputeBitNeg",
"(",
"sc",
"*",
"variable",
".",
"StatementContext",
",",
"a",
"Datum",
")",
"(",
"d",
"Datum",
",",
"err",
"error",
")",
"{",
"aKind",
":=",
"a",
".",
"Kind",
"(",
")",
"\n",
"if",
"aKind",
"==",
"KindInt64",
"||",
"aKind",
... | // ComputeBitNeg computes the result of ~a. | [
"ComputeBitNeg",
"computes",
"the",
"result",
"of",
"~a",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum_eval.go#L468-L482 | train |
chrislusf/gleam | sql/util/types/datum_eval.go | ComputeBitXor | func ComputeBitXor(sc *variable.StatementContext, a, b Datum) (d Datum, err error) {
aKind, bKind := a.Kind(), b.Kind()
if (aKind == KindInt64 || aKind == KindUint64) && (bKind == KindInt64 || bKind == KindUint64) {
d.SetUint64(a.GetUint64() ^ b.GetUint64())
return
}
// If either is not integer, we round the op... | go | func ComputeBitXor(sc *variable.StatementContext, a, b Datum) (d Datum, err error) {
aKind, bKind := a.Kind(), b.Kind()
if (aKind == KindInt64 || aKind == KindUint64) && (bKind == KindInt64 || bKind == KindUint64) {
d.SetUint64(a.GetUint64() ^ b.GetUint64())
return
}
// If either is not integer, we round the op... | [
"func",
"ComputeBitXor",
"(",
"sc",
"*",
"variable",
".",
"StatementContext",
",",
"a",
",",
"b",
"Datum",
")",
"(",
"d",
"Datum",
",",
"err",
"error",
")",
"{",
"aKind",
",",
"bKind",
":=",
"a",
".",
"Kind",
"(",
")",
",",
"b",
".",
"Kind",
"(",... | // ComputeBitXor computes the result of a ^ b. | [
"ComputeBitXor",
"computes",
"the",
"result",
"of",
"a",
"^",
"b",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum_eval.go#L485-L504 | train |
chrislusf/gleam | sql/util/types/datum_eval.go | convertNonInt2RoundUint64 | func convertNonInt2RoundUint64(sc *variable.StatementContext, x Datum) (d uint64, err error) {
decimalX, err := x.ToDecimal(sc)
if err != nil {
return d, errors.Trace(err)
}
d, err = decimal2RoundUint(decimalX)
if err != nil {
return d, errors.Trace(err)
}
return
} | go | func convertNonInt2RoundUint64(sc *variable.StatementContext, x Datum) (d uint64, err error) {
decimalX, err := x.ToDecimal(sc)
if err != nil {
return d, errors.Trace(err)
}
d, err = decimal2RoundUint(decimalX)
if err != nil {
return d, errors.Trace(err)
}
return
} | [
"func",
"convertNonInt2RoundUint64",
"(",
"sc",
"*",
"variable",
".",
"StatementContext",
",",
"x",
"Datum",
")",
"(",
"d",
"uint64",
",",
"err",
"error",
")",
"{",
"decimalX",
",",
"err",
":=",
"x",
".",
"ToDecimal",
"(",
"sc",
")",
"\n",
"if",
"err",... | // covertNonIntegerToUint64 coverts a non-integer to an uint64 | [
"covertNonIntegerToUint64",
"coverts",
"a",
"non",
"-",
"integer",
"to",
"an",
"uint64"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/datum_eval.go#L551-L561 | train |
chrislusf/gleam | sql/expression/util.go | calculateSum | func calculateSum(sc *variable.StatementContext, sum, v types.Datum) (data types.Datum, err error) {
// for avg and sum calculation
// avg and sum use decimal for integer and decimal type, use float for others
// see https://dev.mysql.com/doc/refman/5.7/en/group-by-functions.html
switch v.Kind() {
case types.Kind... | go | func calculateSum(sc *variable.StatementContext, sum, v types.Datum) (data types.Datum, err error) {
// for avg and sum calculation
// avg and sum use decimal for integer and decimal type, use float for others
// see https://dev.mysql.com/doc/refman/5.7/en/group-by-functions.html
switch v.Kind() {
case types.Kind... | [
"func",
"calculateSum",
"(",
"sc",
"*",
"variable",
".",
"StatementContext",
",",
"sum",
",",
"v",
"types",
".",
"Datum",
")",
"(",
"data",
"types",
".",
"Datum",
",",
"err",
"error",
")",
"{",
"// for avg and sum calculation",
"// avg and sum use decimal for in... | // calculateSum adds v to sum. | [
"calculateSum",
"adds",
"v",
"to",
"sum",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/util.go#L73-L110 | train |
chrislusf/gleam | util/channel_util.go | CopyMultipleReaders | func CopyMultipleReaders(readers []io.Reader, writer io.Writer) (inCounter int64, outCounter int64, e error) {
writerChan := make(chan []byte, 16*len(readers))
errChan := make(chan error, len(readers))
defer close(errChan)
var wg sync.WaitGroup
for _, reader := range readers {
wg.Add(1)
go func(reader io.Re... | go | func CopyMultipleReaders(readers []io.Reader, writer io.Writer) (inCounter int64, outCounter int64, e error) {
writerChan := make(chan []byte, 16*len(readers))
errChan := make(chan error, len(readers))
defer close(errChan)
var wg sync.WaitGroup
for _, reader := range readers {
wg.Add(1)
go func(reader io.Re... | [
"func",
"CopyMultipleReaders",
"(",
"readers",
"[",
"]",
"io",
".",
"Reader",
",",
"writer",
"io",
".",
"Writer",
")",
"(",
"inCounter",
"int64",
",",
"outCounter",
"int64",
",",
"e",
"error",
")",
"{",
"writerChan",
":=",
"make",
"(",
"chan",
"[",
"]"... | // setup asynchronously to merge multiple channels into one channel | [
"setup",
"asynchronously",
"to",
"merge",
"multiple",
"channels",
"into",
"one",
"channel"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/util/channel_util.go#L58-L101 | train |
chrislusf/gleam | flow/dataset_pipe.go | Pipe | func (d *Dataset) Pipe(name, code string) *Dataset {
ret, step := add1ShardTo1Step(d)
step.Name = name
step.Description = code
step.IsPipe = true
step.Command = script.NewShellScript().Pipe(code).GetCommand()
return ret
} | go | func (d *Dataset) Pipe(name, code string) *Dataset {
ret, step := add1ShardTo1Step(d)
step.Name = name
step.Description = code
step.IsPipe = true
step.Command = script.NewShellScript().Pipe(code).GetCommand()
return ret
} | [
"func",
"(",
"d",
"*",
"Dataset",
")",
"Pipe",
"(",
"name",
",",
"code",
"string",
")",
"*",
"Dataset",
"{",
"ret",
",",
"step",
":=",
"add1ShardTo1Step",
"(",
"d",
")",
"\n",
"step",
".",
"Name",
"=",
"name",
"\n",
"step",
".",
"Description",
"=",... | // Pipe runs the code as an external program, which processes the
// tab-separated input from the program's stdin, and outout to
// stdout also in tab-separated lines. | [
"Pipe",
"runs",
"the",
"code",
"as",
"an",
"external",
"program",
"which",
"processes",
"the",
"tab",
"-",
"separated",
"input",
"from",
"the",
"program",
"s",
"stdin",
"and",
"outout",
"to",
"stdout",
"also",
"in",
"tab",
"-",
"separated",
"lines",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_pipe.go#L11-L18 | train |
chrislusf/gleam | instruction/local_top.go | DoLocalTop | func DoLocalTop(reader io.Reader, writer io.Writer, n int, orderBys []OrderBy, stats *pb.InstructionStat) error {
pq := newMinQueueOfPairs(orderBys)
err := util.ProcessRow(reader, nil, func(row *util.Row) error {
stats.InputCounter++
if pq.Len() >= n {
if lessThan(orderBys, pq.Top().(*util.Row), row) {
... | go | func DoLocalTop(reader io.Reader, writer io.Writer, n int, orderBys []OrderBy, stats *pb.InstructionStat) error {
pq := newMinQueueOfPairs(orderBys)
err := util.ProcessRow(reader, nil, func(row *util.Row) error {
stats.InputCounter++
if pq.Len() >= n {
if lessThan(orderBys, pq.Top().(*util.Row), row) {
... | [
"func",
"DoLocalTop",
"(",
"reader",
"io",
".",
"Reader",
",",
"writer",
"io",
".",
"Writer",
",",
"n",
"int",
",",
"orderBys",
"[",
"]",
"OrderBy",
",",
"stats",
"*",
"pb",
".",
"InstructionStat",
")",
"error",
"{",
"pq",
":=",
"newMinQueueOfPairs",
"... | // DoLocalTop streamingly compare and get the top n items | [
"DoLocalTop",
"streamingly",
"compare",
"and",
"get",
"the",
"top",
"n",
"items"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/instruction/local_top.go#L56-L92 | train |
chrislusf/gleam | sql/ast/expressions.go | NewValueExpr | func NewValueExpr(value interface{}) *ValueExpr {
if ve, ok := value.(*ValueExpr); ok {
return ve
}
ve := &ValueExpr{}
ve.SetValue(value)
types.DefaultTypeForValue(value, &ve.Type)
return ve
} | go | func NewValueExpr(value interface{}) *ValueExpr {
if ve, ok := value.(*ValueExpr); ok {
return ve
}
ve := &ValueExpr{}
ve.SetValue(value)
types.DefaultTypeForValue(value, &ve.Type)
return ve
} | [
"func",
"NewValueExpr",
"(",
"value",
"interface",
"{",
"}",
")",
"*",
"ValueExpr",
"{",
"if",
"ve",
",",
"ok",
":=",
"value",
".",
"(",
"*",
"ValueExpr",
")",
";",
"ok",
"{",
"return",
"ve",
"\n",
"}",
"\n",
"ve",
":=",
"&",
"ValueExpr",
"{",
"}... | // NewValueExpr creates a ValueExpr with value, and sets default field type. | [
"NewValueExpr",
"creates",
"a",
"ValueExpr",
"with",
"value",
"and",
"sets",
"default",
"field",
"type",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/ast/expressions.go#L58-L66 | train |
chrislusf/gleam | distributed/option.go | SetProfiling | func (o *DistributedOption) SetProfiling(isProfiling bool) *DistributedOption {
o.IsProfiling = isProfiling
return o
} | go | func (o *DistributedOption) SetProfiling(isProfiling bool) *DistributedOption {
o.IsProfiling = isProfiling
return o
} | [
"func",
"(",
"o",
"*",
"DistributedOption",
")",
"SetProfiling",
"(",
"isProfiling",
"bool",
")",
"*",
"DistributedOption",
"{",
"o",
".",
"IsProfiling",
"=",
"isProfiling",
"\n",
"return",
"o",
"\n",
"}"
] | // SetProfiling profiling will generate cpu and memory profile files when the executors are completed. | [
"SetProfiling",
"profiling",
"will",
"generate",
"cpu",
"and",
"memory",
"profile",
"files",
"when",
"the",
"executors",
"are",
"completed",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/option.go#L55-L58 | train |
chrislusf/gleam | distributed/option.go | WithFile | func (o *DistributedOption) WithFile(relatedFile, toFolder string) *DistributedOption {
relativePath, err := filepath.Rel(".", relatedFile)
if err != nil {
relativePath = relatedFile
}
o.RequiredFiles = append(o.RequiredFiles, resource.FileResource{relativePath, toFolder})
return o
} | go | func (o *DistributedOption) WithFile(relatedFile, toFolder string) *DistributedOption {
relativePath, err := filepath.Rel(".", relatedFile)
if err != nil {
relativePath = relatedFile
}
o.RequiredFiles = append(o.RequiredFiles, resource.FileResource{relativePath, toFolder})
return o
} | [
"func",
"(",
"o",
"*",
"DistributedOption",
")",
"WithFile",
"(",
"relatedFile",
",",
"toFolder",
"string",
")",
"*",
"DistributedOption",
"{",
"relativePath",
",",
"err",
":=",
"filepath",
".",
"Rel",
"(",
"\"",
"\"",
",",
"relatedFile",
")",
"\n",
"if",
... | // WithFile sends any related file over to gleam agents
// so the task can still access these files on gleam agents.
// The files are placed on the executed task's current working directory. | [
"WithFile",
"sends",
"any",
"related",
"file",
"over",
"to",
"gleam",
"agents",
"so",
"the",
"task",
"can",
"still",
"access",
"these",
"files",
"on",
"gleam",
"agents",
".",
"The",
"files",
"are",
"placed",
"on",
"the",
"executed",
"task",
"s",
"current",... | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/option.go#L63-L70 | train |
chrislusf/gleam | util/row_read_write.go | WriteTo | func (row Row) WriteTo(writer io.Writer) (err error) {
encoded, err := encodeRow(row)
if err != nil {
return fmt.Errorf("WriteTo encoding error: %v", err)
}
return WriteMessage(writer, encoded)
} | go | func (row Row) WriteTo(writer io.Writer) (err error) {
encoded, err := encodeRow(row)
if err != nil {
return fmt.Errorf("WriteTo encoding error: %v", err)
}
return WriteMessage(writer, encoded)
} | [
"func",
"(",
"row",
"Row",
")",
"WriteTo",
"(",
"writer",
"io",
".",
"Writer",
")",
"(",
"err",
"error",
")",
"{",
"encoded",
",",
"err",
":=",
"encodeRow",
"(",
"row",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"("... | // WriteTo encode and write a row of data to the writer | [
"WriteTo",
"encode",
"and",
"write",
"a",
"row",
"of",
"data",
"to",
"the",
"writer"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/util/row_read_write.go#L12-L18 | train |
chrislusf/gleam | util/row_read_write.go | ReadRow | func ReadRow(reader io.Reader) (row *Row, err error) {
encodedBytes, hasErr := ReadMessage(reader)
if hasErr != nil {
if hasErr != io.EOF {
return row, fmt.Errorf("ReadRow ReadMessage: %v", hasErr)
}
return row, io.EOF
}
if row, err = DecodeRow(encodedBytes); err != nil {
return row, fmt.Errorf("ReadRow ... | go | func ReadRow(reader io.Reader) (row *Row, err error) {
encodedBytes, hasErr := ReadMessage(reader)
if hasErr != nil {
if hasErr != io.EOF {
return row, fmt.Errorf("ReadRow ReadMessage: %v", hasErr)
}
return row, io.EOF
}
if row, err = DecodeRow(encodedBytes); err != nil {
return row, fmt.Errorf("ReadRow ... | [
"func",
"ReadRow",
"(",
"reader",
"io",
".",
"Reader",
")",
"(",
"row",
"*",
"Row",
",",
"err",
"error",
")",
"{",
"encodedBytes",
",",
"hasErr",
":=",
"ReadMessage",
"(",
"reader",
")",
"\n",
"if",
"hasErr",
"!=",
"nil",
"{",
"if",
"hasErr",
"!=",
... | // ReadRow read and decode one row of data | [
"ReadRow",
"read",
"and",
"decode",
"one",
"row",
"of",
"data"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/util/row_read_write.go#L21-L33 | train |
chrislusf/gleam | util/row_read_write.go | EncodeKeys | func EncodeKeys(anyObject ...interface{}) ([]byte, error) {
var buf bytes.Buffer
en := msgp.NewWriter(&buf)
for _, obj := range anyObject {
if err := en.WriteIntf(obj); err != nil {
return nil, fmt.Errorf("Failed to encode key: %v", err)
}
}
return buf.Bytes(), nil
} | go | func EncodeKeys(anyObject ...interface{}) ([]byte, error) {
var buf bytes.Buffer
en := msgp.NewWriter(&buf)
for _, obj := range anyObject {
if err := en.WriteIntf(obj); err != nil {
return nil, fmt.Errorf("Failed to encode key: %v", err)
}
}
return buf.Bytes(), nil
} | [
"func",
"EncodeKeys",
"(",
"anyObject",
"...",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"en",
":=",
"msgp",
".",
"NewWriter",
"(",
"&",
"buf",
")",
"\n",
"for",
"_",
",... | // EncodeKeys encode keys to a blob, for comparing or sorting | [
"EncodeKeys",
"encode",
"keys",
"to",
"a",
"blob",
"for",
"comparing",
"or",
"sorting"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/util/row_read_write.go#L41-L50 | train |
chrislusf/gleam | util/row_read_write.go | DecodeRow | func DecodeRow(encodedBytes []byte) (*Row, error) {
row := &Row{}
_, err := row.UnmarshalMsg(encodedBytes)
if err != nil {
err = fmt.Errorf("decode row error %v: %s\n", err, string(encodedBytes))
}
return row, err
} | go | func DecodeRow(encodedBytes []byte) (*Row, error) {
row := &Row{}
_, err := row.UnmarshalMsg(encodedBytes)
if err != nil {
err = fmt.Errorf("decode row error %v: %s\n", err, string(encodedBytes))
}
return row, err
} | [
"func",
"DecodeRow",
"(",
"encodedBytes",
"[",
"]",
"byte",
")",
"(",
"*",
"Row",
",",
"error",
")",
"{",
"row",
":=",
"&",
"Row",
"{",
"}",
"\n",
"_",
",",
"err",
":=",
"row",
".",
"UnmarshalMsg",
"(",
"encodedBytes",
")",
"\n",
"if",
"err",
"!=... | // DecodeRow decodes one row of data from a blob | [
"DecodeRow",
"decodes",
"one",
"row",
"of",
"data",
"from",
"a",
"blob"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/util/row_read_write.go#L53-L60 | train |
chrislusf/gleam | util/row_read_write.go | ProcessRow | func ProcessRow(reader io.Reader, indexes []int, f func(*Row) error) (err error) {
return ProcessMessage(reader, func(input []byte) error {
// read the row
row, err := DecodeRow(input)
if err != nil {
return fmt.Errorf("DoLocalDistinct error %v: %+v", err, input)
}
row.UseKeys(indexes)
return f(row)
})... | go | func ProcessRow(reader io.Reader, indexes []int, f func(*Row) error) (err error) {
return ProcessMessage(reader, func(input []byte) error {
// read the row
row, err := DecodeRow(input)
if err != nil {
return fmt.Errorf("DoLocalDistinct error %v: %+v", err, input)
}
row.UseKeys(indexes)
return f(row)
})... | [
"func",
"ProcessRow",
"(",
"reader",
"io",
".",
"Reader",
",",
"indexes",
"[",
"]",
"int",
",",
"f",
"func",
"(",
"*",
"Row",
")",
"error",
")",
"(",
"err",
"error",
")",
"{",
"return",
"ProcessMessage",
"(",
"reader",
",",
"func",
"(",
"input",
"[... | // ProcessRow Reads and processes rows until EOF | [
"ProcessRow",
"Reads",
"and",
"processes",
"rows",
"until",
"EOF"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/util/row_read_write.go#L63-L73 | train |
chrislusf/gleam | pb/resource_proto_helper.go | Distance | func (a *Location) Distance(b *Location) float64 {
if a.DataCenter != b.DataCenter {
return 1000
}
if a.Rack != b.Rack {
return 100
}
if a.Server != b.Server {
return 10
}
return 1
} | go | func (a *Location) Distance(b *Location) float64 {
if a.DataCenter != b.DataCenter {
return 1000
}
if a.Rack != b.Rack {
return 100
}
if a.Server != b.Server {
return 10
}
return 1
} | [
"func",
"(",
"a",
"*",
"Location",
")",
"Distance",
"(",
"b",
"*",
"Location",
")",
"float64",
"{",
"if",
"a",
".",
"DataCenter",
"!=",
"b",
".",
"DataCenter",
"{",
"return",
"1000",
"\n",
"}",
"\n",
"if",
"a",
".",
"Rack",
"!=",
"b",
".",
"Rack"... | // the distance is a relative value, similar to network lantency | [
"the",
"distance",
"is",
"a",
"relative",
"value",
"similar",
"to",
"network",
"lantency"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/pb/resource_proto_helper.go#L12-L23 | train |
chrislusf/gleam | sql/resolver/resolver.go | ResolveName | func ResolveName(node ast.Node, info infoschema.InfoSchema, ctx context.Context) error {
defaultSchema := ctx.GetSessionVars().CurrentDB
resolver := nameResolver{Info: info, Ctx: ctx, DefaultSchema: model.NewCIStr(defaultSchema)}
node.Accept(&resolver)
return errors.Trace(resolver.Err)
} | go | func ResolveName(node ast.Node, info infoschema.InfoSchema, ctx context.Context) error {
defaultSchema := ctx.GetSessionVars().CurrentDB
resolver := nameResolver{Info: info, Ctx: ctx, DefaultSchema: model.NewCIStr(defaultSchema)}
node.Accept(&resolver)
return errors.Trace(resolver.Err)
} | [
"func",
"ResolveName",
"(",
"node",
"ast",
".",
"Node",
",",
"info",
"infoschema",
".",
"InfoSchema",
",",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"defaultSchema",
":=",
"ctx",
".",
"GetSessionVars",
"(",
")",
".",
"CurrentDB",
"\n",
"resolver... | // ResolveName resolves table name and column name.
// It generates ResultFields for ResultSetNode and resolves ColumnNameExpr to a ResultField. | [
"ResolveName",
"resolves",
"table",
"name",
"and",
"column",
"name",
".",
"It",
"generates",
"ResultFields",
"for",
"ResultSetNode",
"and",
"resolves",
"ColumnNameExpr",
"to",
"a",
"ResultField",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/resolver/resolver.go#L30-L35 | train |
chrislusf/gleam | sql/resolver/resolver.go | currentContext | func (nr *nameResolver) currentContext() *resolverContext {
stackLen := len(nr.contextStack)
if stackLen == 0 {
return nil
}
return nr.contextStack[stackLen-1]
} | go | func (nr *nameResolver) currentContext() *resolverContext {
stackLen := len(nr.contextStack)
if stackLen == 0 {
return nil
}
return nr.contextStack[stackLen-1]
} | [
"func",
"(",
"nr",
"*",
"nameResolver",
")",
"currentContext",
"(",
")",
"*",
"resolverContext",
"{",
"stackLen",
":=",
"len",
"(",
"nr",
".",
"contextStack",
")",
"\n",
"if",
"stackLen",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"nr"... | // currentContext gets the current resolverContext. | [
"currentContext",
"gets",
"the",
"current",
"resolverContext",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/resolver/resolver.go#L104-L110 | train |
chrislusf/gleam | sql/resolver/resolver.go | pushContext | func (nr *nameResolver) pushContext() {
nr.contextStack = append(nr.contextStack, &resolverContext{
tableMap: map[string]int{},
derivedTableMap: map[string]int{},
})
} | go | func (nr *nameResolver) pushContext() {
nr.contextStack = append(nr.contextStack, &resolverContext{
tableMap: map[string]int{},
derivedTableMap: map[string]int{},
})
} | [
"func",
"(",
"nr",
"*",
"nameResolver",
")",
"pushContext",
"(",
")",
"{",
"nr",
".",
"contextStack",
"=",
"append",
"(",
"nr",
".",
"contextStack",
",",
"&",
"resolverContext",
"{",
"tableMap",
":",
"map",
"[",
"string",
"]",
"int",
"{",
"}",
",",
"... | // pushContext is called when we enter a statement. | [
"pushContext",
"is",
"called",
"when",
"we",
"enter",
"a",
"statement",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/resolver/resolver.go#L113-L118 | train |
chrislusf/gleam | sql/resolver/resolver.go | popContext | func (nr *nameResolver) popContext() {
nr.contextStack = nr.contextStack[:len(nr.contextStack)-1]
} | go | func (nr *nameResolver) popContext() {
nr.contextStack = nr.contextStack[:len(nr.contextStack)-1]
} | [
"func",
"(",
"nr",
"*",
"nameResolver",
")",
"popContext",
"(",
")",
"{",
"nr",
".",
"contextStack",
"=",
"nr",
".",
"contextStack",
"[",
":",
"len",
"(",
"nr",
".",
"contextStack",
")",
"-",
"1",
"]",
"\n",
"}"
] | // popContext is called when we leave a statement. | [
"popContext",
"is",
"called",
"when",
"we",
"leave",
"a",
"statement",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/resolver/resolver.go#L121-L123 | train |
chrislusf/gleam | sql/resolver/resolver.go | pushJoin | func (nr *nameResolver) pushJoin(j *ast.Join) {
ctx := nr.currentContext()
ctx.joinNodeStack = append(ctx.joinNodeStack, j)
} | go | func (nr *nameResolver) pushJoin(j *ast.Join) {
ctx := nr.currentContext()
ctx.joinNodeStack = append(ctx.joinNodeStack, j)
} | [
"func",
"(",
"nr",
"*",
"nameResolver",
")",
"pushJoin",
"(",
"j",
"*",
"ast",
".",
"Join",
")",
"{",
"ctx",
":=",
"nr",
".",
"currentContext",
"(",
")",
"\n",
"ctx",
".",
"joinNodeStack",
"=",
"append",
"(",
"ctx",
".",
"joinNodeStack",
",",
"j",
... | // pushJoin is called when we enter a join node. | [
"pushJoin",
"is",
"called",
"when",
"we",
"enter",
"a",
"join",
"node",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/resolver/resolver.go#L126-L129 | train |
chrislusf/gleam | sql/resolver/resolver.go | popJoin | func (nr *nameResolver) popJoin() {
ctx := nr.currentContext()
ctx.joinNodeStack = ctx.joinNodeStack[:len(ctx.joinNodeStack)-1]
} | go | func (nr *nameResolver) popJoin() {
ctx := nr.currentContext()
ctx.joinNodeStack = ctx.joinNodeStack[:len(ctx.joinNodeStack)-1]
} | [
"func",
"(",
"nr",
"*",
"nameResolver",
")",
"popJoin",
"(",
")",
"{",
"ctx",
":=",
"nr",
".",
"currentContext",
"(",
")",
"\n",
"ctx",
".",
"joinNodeStack",
"=",
"ctx",
".",
"joinNodeStack",
"[",
":",
"len",
"(",
"ctx",
".",
"joinNodeStack",
")",
"-... | // popJoin is called when we leave a join node. | [
"popJoin",
"is",
"called",
"when",
"we",
"leave",
"a",
"join",
"node",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/resolver/resolver.go#L132-L135 | train |
chrislusf/gleam | sql/resolver/resolver.go | handleTableName | func (nr *nameResolver) handleTableName(tn *ast.TableName) {
if tn.Schema.L == "" {
tn.Schema = nr.DefaultSchema
}
ctx := nr.currentContext()
if ctx.inCreateOrDropTable {
// The table may not exist in create table or drop table statement.
// Skip resolving the table to avoid error.
return
}
if ctx.inDelet... | go | func (nr *nameResolver) handleTableName(tn *ast.TableName) {
if tn.Schema.L == "" {
tn.Schema = nr.DefaultSchema
}
ctx := nr.currentContext()
if ctx.inCreateOrDropTable {
// The table may not exist in create table or drop table statement.
// Skip resolving the table to avoid error.
return
}
if ctx.inDelet... | [
"func",
"(",
"nr",
"*",
"nameResolver",
")",
"handleTableName",
"(",
"tn",
"*",
"ast",
".",
"TableName",
")",
"{",
"if",
"tn",
".",
"Schema",
".",
"L",
"==",
"\"",
"\"",
"{",
"tn",
".",
"Schema",
"=",
"nr",
".",
"DefaultSchema",
"\n",
"}",
"\n",
... | // handleTableName looks up and sets the schema information and result fields for table name. | [
"handleTableName",
"looks",
"up",
"and",
"sets",
"the",
"schema",
"information",
"and",
"result",
"fields",
"for",
"table",
"name",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/resolver/resolver.go#L334-L386 | train |
chrislusf/gleam | sql/resolver/resolver.go | handleJoin | func (nr *nameResolver) handleJoin(j *ast.Join) {
if j.Right == nil {
j.SetResultFields(j.Left.GetResultFields())
return
}
leftLen := len(j.Left.GetResultFields())
rightLen := len(j.Right.GetResultFields())
rfs := make([]*ast.ResultField, leftLen+rightLen)
copy(rfs, j.Left.GetResultFields())
copy(rfs[leftLen... | go | func (nr *nameResolver) handleJoin(j *ast.Join) {
if j.Right == nil {
j.SetResultFields(j.Left.GetResultFields())
return
}
leftLen := len(j.Left.GetResultFields())
rightLen := len(j.Right.GetResultFields())
rfs := make([]*ast.ResultField, leftLen+rightLen)
copy(rfs, j.Left.GetResultFields())
copy(rfs[leftLen... | [
"func",
"(",
"nr",
"*",
"nameResolver",
")",
"handleJoin",
"(",
"j",
"*",
"ast",
".",
"Join",
")",
"{",
"if",
"j",
".",
"Right",
"==",
"nil",
"{",
"j",
".",
"SetResultFields",
"(",
"j",
".",
"Left",
".",
"GetResultFields",
"(",
")",
")",
"\n",
"r... | // handleJoin sets result fields for join. | [
"handleJoin",
"sets",
"result",
"fields",
"for",
"join",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/resolver/resolver.go#L440-L451 | train |
chrislusf/gleam | sql/resolver/resolver.go | handleColumnName | func (nr *nameResolver) handleColumnName(cn *ast.ColumnNameExpr) {
ctx := nr.currentContext()
if ctx.inOnCondition {
// In on condition, only tables within current join is available.
nr.resolveColumnNameInOnCondition(cn)
return
}
// Try to resolve the column name form top to bottom in the context stack.
for... | go | func (nr *nameResolver) handleColumnName(cn *ast.ColumnNameExpr) {
ctx := nr.currentContext()
if ctx.inOnCondition {
// In on condition, only tables within current join is available.
nr.resolveColumnNameInOnCondition(cn)
return
}
// Try to resolve the column name form top to bottom in the context stack.
for... | [
"func",
"(",
"nr",
"*",
"nameResolver",
")",
"handleColumnName",
"(",
"cn",
"*",
"ast",
".",
"ColumnNameExpr",
")",
"{",
"ctx",
":=",
"nr",
".",
"currentContext",
"(",
")",
"\n",
"if",
"ctx",
".",
"inOnCondition",
"{",
"// In on condition, only tables within c... | // handleColumnName looks up and sets ResultField for
// the column name. | [
"handleColumnName",
"looks",
"up",
"and",
"sets",
"ResultField",
"for",
"the",
"column",
"name",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/resolver/resolver.go#L455-L475 | train |
chrislusf/gleam | sql/resolver/resolver.go | resolveColumnNameInContext | func (nr *nameResolver) resolveColumnNameInContext(ctx *resolverContext, cn *ast.ColumnNameExpr) bool {
if ctx.inTableRefs {
// In TableRefsClause, column reference only in join on condition which is handled before.
return false
}
if ctx.inFieldList {
// only resolve column using tables.
return nr.resolveCol... | go | func (nr *nameResolver) resolveColumnNameInContext(ctx *resolverContext, cn *ast.ColumnNameExpr) bool {
if ctx.inTableRefs {
// In TableRefsClause, column reference only in join on condition which is handled before.
return false
}
if ctx.inFieldList {
// only resolve column using tables.
return nr.resolveCol... | [
"func",
"(",
"nr",
"*",
"nameResolver",
")",
"resolveColumnNameInContext",
"(",
"ctx",
"*",
"resolverContext",
",",
"cn",
"*",
"ast",
".",
"ColumnNameExpr",
")",
"bool",
"{",
"if",
"ctx",
".",
"inTableRefs",
"{",
"// In TableRefsClause, column reference only in join... | // resolveColumnNameInContext looks up and sets ResultField for a column with the ctx. | [
"resolveColumnNameInContext",
"looks",
"up",
"and",
"sets",
"ResultField",
"for",
"a",
"column",
"with",
"the",
"ctx",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/resolver/resolver.go#L478-L566 | train |
chrislusf/gleam | sql/resolver/resolver.go | resolveColumnNameInOnCondition | func (nr *nameResolver) resolveColumnNameInOnCondition(cn *ast.ColumnNameExpr) {
ctx := nr.currentContext()
join := ctx.joinNodeStack[len(ctx.joinNodeStack)-1]
tableSources := appendTableSources(nil, join)
if !nr.resolveColumnInTableSources(cn, tableSources) {
nr.Err = errors.Errorf("unknown column name %s", cn.N... | go | func (nr *nameResolver) resolveColumnNameInOnCondition(cn *ast.ColumnNameExpr) {
ctx := nr.currentContext()
join := ctx.joinNodeStack[len(ctx.joinNodeStack)-1]
tableSources := appendTableSources(nil, join)
if !nr.resolveColumnInTableSources(cn, tableSources) {
nr.Err = errors.Errorf("unknown column name %s", cn.N... | [
"func",
"(",
"nr",
"*",
"nameResolver",
")",
"resolveColumnNameInOnCondition",
"(",
"cn",
"*",
"ast",
".",
"ColumnNameExpr",
")",
"{",
"ctx",
":=",
"nr",
".",
"currentContext",
"(",
")",
"\n",
"join",
":=",
"ctx",
".",
"joinNodeStack",
"[",
"len",
"(",
"... | // resolveColumnNameInOnCondition resolves the column name in current join. | [
"resolveColumnNameInOnCondition",
"resolves",
"the",
"column",
"name",
"in",
"current",
"join",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/resolver/resolver.go#L569-L576 | train |
chrislusf/gleam | sql/resolver/resolver.go | handleFieldList | func (nr *nameResolver) handleFieldList(fieldList *ast.FieldList) {
var resultFields []*ast.ResultField
for _, v := range fieldList.Fields {
resultFields = append(resultFields, nr.createResultFields(v)...)
}
nr.currentContext().fieldList = resultFields
} | go | func (nr *nameResolver) handleFieldList(fieldList *ast.FieldList) {
var resultFields []*ast.ResultField
for _, v := range fieldList.Fields {
resultFields = append(resultFields, nr.createResultFields(v)...)
}
nr.currentContext().fieldList = resultFields
} | [
"func",
"(",
"nr",
"*",
"nameResolver",
")",
"handleFieldList",
"(",
"fieldList",
"*",
"ast",
".",
"FieldList",
")",
"{",
"var",
"resultFields",
"[",
"]",
"*",
"ast",
".",
"ResultField",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"fieldList",
".",
"Fie... | // handleFieldList expands wild card field and sets fieldList in current context. | [
"handleFieldList",
"expands",
"wild",
"card",
"field",
"and",
"sets",
"fieldList",
"in",
"current",
"context",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/resolver/resolver.go#L685-L691 | train |
chrislusf/gleam | sql/util/charset/charset.go | GetAllCharsets | func GetAllCharsets() []*Desc {
descs := make([]*Desc, 0, len(charsets))
// The charsetInfos is an array, so the iterate order will be stable.
for _, ci := range charsetInfos {
c, ok := charsets[ci.Name]
if !ok {
continue
}
desc := &Desc{
Name: c.Name,
DefaultCollation: c.DefaultCollatio... | go | func GetAllCharsets() []*Desc {
descs := make([]*Desc, 0, len(charsets))
// The charsetInfos is an array, so the iterate order will be stable.
for _, ci := range charsetInfos {
c, ok := charsets[ci.Name]
if !ok {
continue
}
desc := &Desc{
Name: c.Name,
DefaultCollation: c.DefaultCollatio... | [
"func",
"GetAllCharsets",
"(",
")",
"[",
"]",
"*",
"Desc",
"{",
"descs",
":=",
"make",
"(",
"[",
"]",
"*",
"Desc",
",",
"0",
",",
"len",
"(",
"charsets",
")",
")",
"\n",
"// The charsetInfos is an array, so the iterate order will be stable.",
"for",
"_",
","... | // GetAllCharsets gets all charset descriptions in the local charsets. | [
"GetAllCharsets",
"gets",
"all",
"charset",
"descriptions",
"in",
"the",
"local",
"charsets",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/charset/charset.go#L77-L94 | train |
chrislusf/gleam | sql/util/charset/charset.go | ValidCharsetAndCollation | func ValidCharsetAndCollation(cs string, co string) bool {
// We will use utf8 as a default charset.
if cs == "" {
cs = "utf8"
}
c, ok := charsets[cs]
if !ok {
return false
}
if co == "" {
return true
}
_, ok = c.Collations[co]
if !ok {
return false
}
return true
} | go | func ValidCharsetAndCollation(cs string, co string) bool {
// We will use utf8 as a default charset.
if cs == "" {
cs = "utf8"
}
c, ok := charsets[cs]
if !ok {
return false
}
if co == "" {
return true
}
_, ok = c.Collations[co]
if !ok {
return false
}
return true
} | [
"func",
"ValidCharsetAndCollation",
"(",
"cs",
"string",
",",
"co",
"string",
")",
"bool",
"{",
"// We will use utf8 as a default charset.",
"if",
"cs",
"==",
"\"",
"\"",
"{",
"cs",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"c",
",",
"ok",
":=",
"charsets",
"[",... | // ValidCharsetAndCollation checks the charset and the collation validity
// and returns a boolean. | [
"ValidCharsetAndCollation",
"checks",
"the",
"charset",
"and",
"the",
"collation",
"validity",
"and",
"returns",
"a",
"boolean",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/charset/charset.go#L98-L118 | train |
chrislusf/gleam | sql/util/charset/charset.go | GetDefaultCollation | func GetDefaultCollation(charset string) (string, error) {
charset = strings.ToLower(charset)
if charset == CharsetBin {
return CollationBin, nil
}
c, ok := charsets[charset]
if !ok {
return "", errors.Errorf("Unknown charset %s", charset)
}
return c.DefaultCollation.Name, nil
} | go | func GetDefaultCollation(charset string) (string, error) {
charset = strings.ToLower(charset)
if charset == CharsetBin {
return CollationBin, nil
}
c, ok := charsets[charset]
if !ok {
return "", errors.Errorf("Unknown charset %s", charset)
}
return c.DefaultCollation.Name, nil
} | [
"func",
"GetDefaultCollation",
"(",
"charset",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"charset",
"=",
"strings",
".",
"ToLower",
"(",
"charset",
")",
"\n",
"if",
"charset",
"==",
"CharsetBin",
"{",
"return",
"CollationBin",
",",
"nil",
"\n",... | // GetDefaultCollation returns the default collation for charset. | [
"GetDefaultCollation",
"returns",
"the",
"default",
"collation",
"for",
"charset",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/charset/charset.go#L121-L131 | train |
chrislusf/gleam | sql/util/charset/charset.go | GetCharsetInfo | func GetCharsetInfo(cs string) (string, string, error) {
c, ok := charsets[strings.ToLower(cs)]
if !ok {
return "", "", errors.Errorf("Unknown charset %s", cs)
}
return c.Name, c.DefaultCollation.Name, nil
} | go | func GetCharsetInfo(cs string) (string, string, error) {
c, ok := charsets[strings.ToLower(cs)]
if !ok {
return "", "", errors.Errorf("Unknown charset %s", cs)
}
return c.Name, c.DefaultCollation.Name, nil
} | [
"func",
"GetCharsetInfo",
"(",
"cs",
"string",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"c",
",",
"ok",
":=",
"charsets",
"[",
"strings",
".",
"ToLower",
"(",
"cs",
")",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
","... | // GetCharsetInfo returns charset and collation for cs as name. | [
"GetCharsetInfo",
"returns",
"charset",
"and",
"collation",
"for",
"cs",
"as",
"name",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/charset/charset.go#L134-L140 | train |
chrislusf/gleam | sql/plan/aggregation_push_down.go | tryToPushDownAgg | func (a *aggPushDownSolver) tryToPushDownAgg(aggFuncs []expression.AggregationFunction, gbyCols []*expression.Column, join *Join, childIdx int) LogicalPlan {
child := join.GetChildByIndex(childIdx).(LogicalPlan)
if a.allFirstRow(aggFuncs) {
return child
}
agg := a.makeNewAgg(aggFuncs, gbyCols)
child.SetParents(a... | go | func (a *aggPushDownSolver) tryToPushDownAgg(aggFuncs []expression.AggregationFunction, gbyCols []*expression.Column, join *Join, childIdx int) LogicalPlan {
child := join.GetChildByIndex(childIdx).(LogicalPlan)
if a.allFirstRow(aggFuncs) {
return child
}
agg := a.makeNewAgg(aggFuncs, gbyCols)
child.SetParents(a... | [
"func",
"(",
"a",
"*",
"aggPushDownSolver",
")",
"tryToPushDownAgg",
"(",
"aggFuncs",
"[",
"]",
"expression",
".",
"AggregationFunction",
",",
"gbyCols",
"[",
"]",
"*",
"expression",
".",
"Column",
",",
"join",
"*",
"Join",
",",
"childIdx",
"int",
")",
"Lo... | // tryToPushDownAgg tries to push down an aggregate function into a join path. If all aggFuncs are first row, we won't
// process it temporarily. If not, We will add additional group by columns and first row functions. We make a new aggregation
// operator. | [
"tryToPushDownAgg",
"tries",
"to",
"push",
"down",
"an",
"aggregate",
"function",
"into",
"a",
"join",
"path",
".",
"If",
"all",
"aggFuncs",
"are",
"first",
"row",
"we",
"won",
"t",
"process",
"it",
"temporarily",
".",
"If",
"not",
"We",
"will",
"add",
"... | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/aggregation_push_down.go#L202-L225 | train |
chrislusf/gleam | distributed/master/ui/svg_writer_layout.go | toStepGroupLayers | func toStepGroupLayers(status *pb.FlowExecutionStatus) (layers [][]int) {
// how many step groups depenend on this step group
dependencyCount := make([]int, len(status.StepGroups))
isUsed := make([]bool, len(status.StepGroups))
for _, stepGroup := range status.StepGroups {
for _, parentId := range stepGroup.GetP... | go | func toStepGroupLayers(status *pb.FlowExecutionStatus) (layers [][]int) {
// how many step groups depenend on this step group
dependencyCount := make([]int, len(status.StepGroups))
isUsed := make([]bool, len(status.StepGroups))
for _, stepGroup := range status.StepGroups {
for _, parentId := range stepGroup.GetP... | [
"func",
"toStepGroupLayers",
"(",
"status",
"*",
"pb",
".",
"FlowExecutionStatus",
")",
"(",
"layers",
"[",
"]",
"[",
"]",
"int",
")",
"{",
"// how many step groups depenend on this step group",
"dependencyCount",
":=",
"make",
"(",
"[",
"]",
"int",
",",
"len",
... | // separate step groups into layers of step group ids via depencency analysis | [
"separate",
"step",
"groups",
"into",
"layers",
"of",
"step",
"group",
"ids",
"via",
"depencency",
"analysis"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/master/ui/svg_writer_layout.go#L8-L35 | train |
chrislusf/gleam | sql/expression/builtin_string.go | argsToSpecifiedType | func argsToSpecifiedType(args []types.Datum, allString bool, allNumber bool, ctx context.Context) (newArgs []types.Datum, err error) {
if allNumber { // If all arguments are numbers, they can be compared directly without type converting.
return args, nil
}
sc := ctx.GetSessionVars().StmtCtx
newArgs = make([]types... | go | func argsToSpecifiedType(args []types.Datum, allString bool, allNumber bool, ctx context.Context) (newArgs []types.Datum, err error) {
if allNumber { // If all arguments are numbers, they can be compared directly without type converting.
return args, nil
}
sc := ctx.GetSessionVars().StmtCtx
newArgs = make([]types... | [
"func",
"argsToSpecifiedType",
"(",
"args",
"[",
"]",
"types",
".",
"Datum",
",",
"allString",
"bool",
",",
"allNumber",
"bool",
",",
"ctx",
"context",
".",
"Context",
")",
"(",
"newArgs",
"[",
"]",
"types",
".",
"Datum",
",",
"err",
"error",
")",
"{",... | // argsToSpecifiedType converts the type of all arguments in args into string type or double type. | [
"argsToSpecifiedType",
"converts",
"the",
"type",
"of",
"all",
"arguments",
"in",
"args",
"into",
"string",
"type",
"or",
"double",
"type",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/builtin_string.go#L1437-L1457 | train |
chrislusf/gleam | distributed/executor/executor_grpc_server.go | CollectExecutionStatistics | func (exe *Executor) CollectExecutionStatistics(stream pb.GleamExecutor_CollectExecutionStatisticsServer) error {
for {
stats, err := stream.Recv()
if err == io.EOF {
return nil
}
if err != nil {
return err
}
for _, stat := range stats.Stats {
for i, current := range exe.stats {
if current.S... | go | func (exe *Executor) CollectExecutionStatistics(stream pb.GleamExecutor_CollectExecutionStatisticsServer) error {
for {
stats, err := stream.Recv()
if err == io.EOF {
return nil
}
if err != nil {
return err
}
for _, stat := range stats.Stats {
for i, current := range exe.stats {
if current.S... | [
"func",
"(",
"exe",
"*",
"Executor",
")",
"CollectExecutionStatistics",
"(",
"stream",
"pb",
".",
"GleamExecutor_CollectExecutionStatisticsServer",
")",
"error",
"{",
"for",
"{",
"stats",
",",
"err",
":=",
"stream",
".",
"Recv",
"(",
")",
"\n",
"if",
"err",
... | // Collect stat from "gleam execute" started mapper reducer process | [
"Collect",
"stat",
"from",
"gleam",
"execute",
"started",
"mapper",
"reducer",
"process"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/executor/executor_grpc_server.go#L19-L41 | train |
chrislusf/gleam | sql/util/charset/encoding_table.go | Lookup | func Lookup(label string) (e encoding.Encoding, name string) {
label = strings.ToLower(strings.Trim(label, "\t\n\r\f "))
enc := encodings[label]
return enc.e, enc.name
} | go | func Lookup(label string) (e encoding.Encoding, name string) {
label = strings.ToLower(strings.Trim(label, "\t\n\r\f "))
enc := encodings[label]
return enc.e, enc.name
} | [
"func",
"Lookup",
"(",
"label",
"string",
")",
"(",
"e",
"encoding",
".",
"Encoding",
",",
"name",
"string",
")",
"{",
"label",
"=",
"strings",
".",
"ToLower",
"(",
"strings",
".",
"Trim",
"(",
"label",
",",
"\"",
"\\t",
"\\n",
"\\r",
"\\f",
"\"",
... | // Lookup returns the encoding with the specified label, and its canonical
// name. It returns nil and the empty string if label is not one of the
// standard encodings for HTML. Matching is case-insensitive and ignores
// leading and trailing whitespace. | [
"Lookup",
"returns",
"the",
"encoding",
"with",
"the",
"specified",
"label",
"and",
"its",
"canonical",
"name",
".",
"It",
"returns",
"nil",
"and",
"the",
"empty",
"string",
"if",
"label",
"is",
"not",
"one",
"of",
"the",
"standard",
"encodings",
"for",
"H... | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/charset/encoding_table.go#L32-L36 | train |
chrislusf/gleam | plugins/file/file_source.go | SetHasHeader | func (q *FileSource) SetHasHeader(hasHeader bool) *FileSource {
q.HasHeader = hasHeader
return q
} | go | func (q *FileSource) SetHasHeader(hasHeader bool) *FileSource {
q.HasHeader = hasHeader
return q
} | [
"func",
"(",
"q",
"*",
"FileSource",
")",
"SetHasHeader",
"(",
"hasHeader",
"bool",
")",
"*",
"FileSource",
"{",
"q",
".",
"HasHeader",
"=",
"hasHeader",
"\n",
"return",
"q",
"\n",
"}"
] | // SetHasHeader sets whether the data contains header | [
"SetHasHeader",
"sets",
"whether",
"the",
"data",
"contains",
"header"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/plugins/file/file_source.go#L38-L41 | train |
chrislusf/gleam | sql/util/codec/decimal.go | EncodeDecimal | func EncodeDecimal(b []byte, d types.Datum) []byte {
dec := d.GetMysqlDecimal()
precision := d.Length()
frac := d.Frac()
if precision == 0 {
precision, frac = dec.PrecisionAndFrac()
}
b = append(b, byte(precision), byte(frac))
bin, err := dec.ToBin(precision, frac)
if err != nil {
log.Printf("should not hap... | go | func EncodeDecimal(b []byte, d types.Datum) []byte {
dec := d.GetMysqlDecimal()
precision := d.Length()
frac := d.Frac()
if precision == 0 {
precision, frac = dec.PrecisionAndFrac()
}
b = append(b, byte(precision), byte(frac))
bin, err := dec.ToBin(precision, frac)
if err != nil {
log.Printf("should not hap... | [
"func",
"EncodeDecimal",
"(",
"b",
"[",
"]",
"byte",
",",
"d",
"types",
".",
"Datum",
")",
"[",
"]",
"byte",
"{",
"dec",
":=",
"d",
".",
"GetMysqlDecimal",
"(",
")",
"\n",
"precision",
":=",
"d",
".",
"Length",
"(",
")",
"\n",
"frac",
":=",
"d",
... | // EncodeDecimal encodes a decimal d into a byte slice which can be sorted lexicographically later. | [
"EncodeDecimal",
"encodes",
"a",
"decimal",
"d",
"into",
"a",
"byte",
"slice",
"which",
"can",
"be",
"sorted",
"lexicographically",
"later",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/codec/decimal.go#L24-L39 | train |
chrislusf/gleam | sql/plan/logical_plan_builder.go | buildInnerApply | func (b *planBuilder) buildInnerApply(outerPlan, innerPlan LogicalPlan) LogicalPlan {
join := &Join{
JoinType: InnerJoin,
baseLogicalPlan: newBaseLogicalPlan(Jn, b.allocator),
}
ap := &Apply{Join: *join}
ap.initIDAndContext(b.ctx)
ap.self = ap
addChild(ap, outerPlan)
addChild(ap, innerPlan)
ap.SetSch... | go | func (b *planBuilder) buildInnerApply(outerPlan, innerPlan LogicalPlan) LogicalPlan {
join := &Join{
JoinType: InnerJoin,
baseLogicalPlan: newBaseLogicalPlan(Jn, b.allocator),
}
ap := &Apply{Join: *join}
ap.initIDAndContext(b.ctx)
ap.self = ap
addChild(ap, outerPlan)
addChild(ap, innerPlan)
ap.SetSch... | [
"func",
"(",
"b",
"*",
"planBuilder",
")",
"buildInnerApply",
"(",
"outerPlan",
",",
"innerPlan",
"LogicalPlan",
")",
"LogicalPlan",
"{",
"join",
":=",
"&",
"Join",
"{",
"JoinType",
":",
"InnerJoin",
",",
"baseLogicalPlan",
":",
"newBaseLogicalPlan",
"(",
"Jn"... | // buildInnerApply builds apply plan with outerPlan and innerPlan, which apply inner-join for every row from outerPlan and the whole innerPlan. | [
"buildInnerApply",
"builds",
"apply",
"plan",
"with",
"outerPlan",
"and",
"innerPlan",
"which",
"apply",
"inner",
"-",
"join",
"for",
"every",
"row",
"from",
"outerPlan",
"and",
"the",
"whole",
"innerPlan",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/logical_plan_builder.go#L959-L975 | train |
chrislusf/gleam | sql/plan/refiner.go | detachTableScanConditions | func detachTableScanConditions(conditions []expression.Expression, table *model.TableInfo) ([]expression.Expression, []expression.Expression) {
var pkName model.CIStr
for _, colInfo := range table.Columns {
if mysql.HasPriKeyFlag(colInfo.Flag) {
pkName = colInfo.Name
break
}
}
if pkName.L == "" {
return... | go | func detachTableScanConditions(conditions []expression.Expression, table *model.TableInfo) ([]expression.Expression, []expression.Expression) {
var pkName model.CIStr
for _, colInfo := range table.Columns {
if mysql.HasPriKeyFlag(colInfo.Flag) {
pkName = colInfo.Name
break
}
}
if pkName.L == "" {
return... | [
"func",
"detachTableScanConditions",
"(",
"conditions",
"[",
"]",
"expression",
".",
"Expression",
",",
"table",
"*",
"model",
".",
"TableInfo",
")",
"(",
"[",
"]",
"expression",
".",
"Expression",
",",
"[",
"]",
"expression",
".",
"Expression",
")",
"{",
... | // detachTableScanConditions distinguishes between access conditions and filter conditions from conditions. | [
"detachTableScanConditions",
"distinguishes",
"between",
"access",
"conditions",
"and",
"filter",
"conditions",
"from",
"conditions",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/refiner.go#L70-L101 | train |
chrislusf/gleam | sql/util/types/bit.go | ToString | func (b Bit) ToString() string {
byteSize := (b.Width + 7) / 8
buf := make([]byte, byteSize)
for i := byteSize - 1; i >= 0; i-- {
buf[byteSize-i-1] = byte(b.Value >> uint(i*8))
}
return string(buf)
} | go | func (b Bit) ToString() string {
byteSize := (b.Width + 7) / 8
buf := make([]byte, byteSize)
for i := byteSize - 1; i >= 0; i-- {
buf[byteSize-i-1] = byte(b.Value >> uint(i*8))
}
return string(buf)
} | [
"func",
"(",
"b",
"Bit",
")",
"ToString",
"(",
")",
"string",
"{",
"byteSize",
":=",
"(",
"b",
".",
"Width",
"+",
"7",
")",
"/",
"8",
"\n",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"byteSize",
")",
"\n",
"for",
"i",
":=",
"byteSize",
... | // ToString returns the binary string for bit type. | [
"ToString",
"returns",
"the",
"binary",
"string",
"for",
"bit",
"type",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/bit.go#L47-L54 | train |
chrislusf/gleam | sql/terror/terror.go | Equal | func (e *Error) Equal(err error) bool {
originErr := errors.Cause(err)
if originErr == nil {
return false
}
inErr, ok := originErr.(*Error)
return ok && e.class == inErr.class && e.code == inErr.code
} | go | func (e *Error) Equal(err error) bool {
originErr := errors.Cause(err)
if originErr == nil {
return false
}
inErr, ok := originErr.(*Error)
return ok && e.class == inErr.class && e.code == inErr.code
} | [
"func",
"(",
"e",
"*",
"Error",
")",
"Equal",
"(",
"err",
"error",
")",
"bool",
"{",
"originErr",
":=",
"errors",
".",
"Cause",
"(",
"err",
")",
"\n",
"if",
"originErr",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"inErr",
",",
"ok",
":... | // Equal checks if err is equal to e. | [
"Equal",
"checks",
"if",
"err",
"is",
"equal",
"to",
"e",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/terror/terror.go#L249-L256 | train |
chrislusf/gleam | sql/terror/terror.go | ToSQLError | func (e *Error) ToSQLError() *mysql.SQLError {
code := e.getMySQLErrorCode()
return mysql.NewErrf(code, e.getMsg())
} | go | func (e *Error) ToSQLError() *mysql.SQLError {
code := e.getMySQLErrorCode()
return mysql.NewErrf(code, e.getMsg())
} | [
"func",
"(",
"e",
"*",
"Error",
")",
"ToSQLError",
"(",
")",
"*",
"mysql",
".",
"SQLError",
"{",
"code",
":=",
"e",
".",
"getMySQLErrorCode",
"(",
")",
"\n",
"return",
"mysql",
".",
"NewErrf",
"(",
"code",
",",
"e",
".",
"getMsg",
"(",
")",
")",
... | // ToSQLError convert Error to mysql.SQLError. | [
"ToSQLError",
"convert",
"Error",
"to",
"mysql",
".",
"SQLError",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/terror/terror.go#L264-L267 | train |
chrislusf/gleam | sql/terror/terror.go | ErrorEqual | func ErrorEqual(err1, err2 error) bool {
e1 := errors.Cause(err1)
e2 := errors.Cause(err2)
if e1 == e2 {
return true
}
if e1 == nil || e2 == nil {
return e1 == e2
}
te1, ok1 := e1.(*Error)
te2, ok2 := e2.(*Error)
if ok1 && ok2 {
return te1.class == te2.class && te1.code == te2.code
}
return e1.Erro... | go | func ErrorEqual(err1, err2 error) bool {
e1 := errors.Cause(err1)
e2 := errors.Cause(err2)
if e1 == e2 {
return true
}
if e1 == nil || e2 == nil {
return e1 == e2
}
te1, ok1 := e1.(*Error)
te2, ok2 := e2.(*Error)
if ok1 && ok2 {
return te1.class == te2.class && te1.code == te2.code
}
return e1.Erro... | [
"func",
"ErrorEqual",
"(",
"err1",
",",
"err2",
"error",
")",
"bool",
"{",
"e1",
":=",
"errors",
".",
"Cause",
"(",
"err1",
")",
"\n",
"e2",
":=",
"errors",
".",
"Cause",
"(",
"err2",
")",
"\n\n",
"if",
"e1",
"==",
"e2",
"{",
"return",
"true",
"\... | // ErrorEqual returns a boolean indicating whether err1 is equal to err2. | [
"ErrorEqual",
"returns",
"a",
"boolean",
"indicating",
"whether",
"err1",
"is",
"equal",
"to",
"err2",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/terror/terror.go#L296-L315 | train |
chrislusf/gleam | flow/context.go | AddOneToOneStep | func (f *Flow) AddOneToOneStep(input *Dataset, output *Dataset) (step *Step) {
step = f.NewStep()
step.NetworkType = OneShardToOneShard
fromStepToDataset(step, output)
fromDatasetToStep(input, step)
if input == nil {
task := step.NewTask()
if output != nil && output.Shards != nil {
fromTaskToDatasetShard(t... | go | func (f *Flow) AddOneToOneStep(input *Dataset, output *Dataset) (step *Step) {
step = f.NewStep()
step.NetworkType = OneShardToOneShard
fromStepToDataset(step, output)
fromDatasetToStep(input, step)
if input == nil {
task := step.NewTask()
if output != nil && output.Shards != nil {
fromTaskToDatasetShard(t... | [
"func",
"(",
"f",
"*",
"Flow",
")",
"AddOneToOneStep",
"(",
"input",
"*",
"Dataset",
",",
"output",
"*",
"Dataset",
")",
"(",
"step",
"*",
"Step",
")",
"{",
"step",
"=",
"f",
".",
"NewStep",
"(",
")",
"\n",
"step",
".",
"NetworkType",
"=",
"OneShar... | // the tasks should run on the source dataset shard | [
"the",
"tasks",
"should",
"run",
"on",
"the",
"source",
"dataset",
"shard"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/context.go#L52-L75 | train |
chrislusf/gleam | flow/context.go | AddAllToOneStep | func (f *Flow) AddAllToOneStep(input *Dataset, output *Dataset) (step *Step) {
step = f.NewStep()
step.NetworkType = AllShardToOneShard
fromStepToDataset(step, output)
fromDatasetToStep(input, step)
// setup the network
task := step.NewTask()
if output != nil {
fromTaskToDatasetShard(task, output.GetShards()[... | go | func (f *Flow) AddAllToOneStep(input *Dataset, output *Dataset) (step *Step) {
step = f.NewStep()
step.NetworkType = AllShardToOneShard
fromStepToDataset(step, output)
fromDatasetToStep(input, step)
// setup the network
task := step.NewTask()
if output != nil {
fromTaskToDatasetShard(task, output.GetShards()[... | [
"func",
"(",
"f",
"*",
"Flow",
")",
"AddAllToOneStep",
"(",
"input",
"*",
"Dataset",
",",
"output",
"*",
"Dataset",
")",
"(",
"step",
"*",
"Step",
")",
"{",
"step",
"=",
"f",
".",
"NewStep",
"(",
")",
"\n",
"step",
".",
"NetworkType",
"=",
"AllShar... | // the task should run on the destination dataset shard | [
"the",
"task",
"should",
"run",
"on",
"the",
"destination",
"dataset",
"shard"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/context.go#L78-L93 | train |
chrislusf/gleam | flow/context.go | MergeDatasets1ShardTo1Step | func (f *Flow) MergeDatasets1ShardTo1Step(inputs []*Dataset, output *Dataset) (step *Step) {
step = f.NewStep()
step.NetworkType = MergeTwoShardToOneShard
fromStepToDataset(step, output)
for _, input := range inputs {
fromDatasetToStep(input, step)
}
// setup the network
if output != nil {
for shardId, outS... | go | func (f *Flow) MergeDatasets1ShardTo1Step(inputs []*Dataset, output *Dataset) (step *Step) {
step = f.NewStep()
step.NetworkType = MergeTwoShardToOneShard
fromStepToDataset(step, output)
for _, input := range inputs {
fromDatasetToStep(input, step)
}
// setup the network
if output != nil {
for shardId, outS... | [
"func",
"(",
"f",
"*",
"Flow",
")",
"MergeDatasets1ShardTo1Step",
"(",
"inputs",
"[",
"]",
"*",
"Dataset",
",",
"output",
"*",
"Dataset",
")",
"(",
"step",
"*",
"Step",
")",
"{",
"step",
"=",
"f",
".",
"NewStep",
"(",
")",
"\n",
"step",
".",
"Netwo... | // All dataset should have the same number of shards. | [
"All",
"dataset",
"should",
"have",
"the",
"same",
"number",
"of",
"shards",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/context.go#L167-L186 | train |
chrislusf/gleam | sql/plan/plans.go | IsPoint | func (ir *IndexRange) IsPoint(sc *variable.StatementContext) bool {
if len(ir.LowVal) != len(ir.HighVal) {
return false
}
for i := range ir.LowVal {
a := ir.LowVal[i]
b := ir.HighVal[i]
if a.Kind() == types.KindMinNotNull || b.Kind() == types.KindMaxValue {
return false
}
cmp, err := a.CompareDatum(sc... | go | func (ir *IndexRange) IsPoint(sc *variable.StatementContext) bool {
if len(ir.LowVal) != len(ir.HighVal) {
return false
}
for i := range ir.LowVal {
a := ir.LowVal[i]
b := ir.HighVal[i]
if a.Kind() == types.KindMinNotNull || b.Kind() == types.KindMaxValue {
return false
}
cmp, err := a.CompareDatum(sc... | [
"func",
"(",
"ir",
"*",
"IndexRange",
")",
"IsPoint",
"(",
"sc",
"*",
"variable",
".",
"StatementContext",
")",
"bool",
"{",
"if",
"len",
"(",
"ir",
".",
"LowVal",
")",
"!=",
"len",
"(",
"ir",
".",
"HighVal",
")",
"{",
"return",
"false",
"\n",
"}",... | // IsPoint returns if the index range is a point. | [
"IsPoint",
"returns",
"if",
"the",
"index",
"range",
"is",
"a",
"point",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/plans.go#L54-L73 | train |
chrislusf/gleam | flow/dataset_source.go | Read | func (fc *Flow) Read(s Sourcer) (ret *Dataset) {
return s.Generate(fc)
} | go | func (fc *Flow) Read(s Sourcer) (ret *Dataset) {
return s.Generate(fc)
} | [
"func",
"(",
"fc",
"*",
"Flow",
")",
"Read",
"(",
"s",
"Sourcer",
")",
"(",
"ret",
"*",
"Dataset",
")",
"{",
"return",
"s",
".",
"Generate",
"(",
"fc",
")",
"\n",
"}"
] | // Read accepts a function to read data into the flow, creating a new dataset.
// This allows custom complicated pre-built logic for new data sources. | [
"Read",
"accepts",
"a",
"function",
"to",
"read",
"data",
"into",
"the",
"flow",
"creating",
"a",
"new",
"dataset",
".",
"This",
"allows",
"custom",
"complicated",
"pre",
"-",
"built",
"logic",
"for",
"new",
"data",
"sources",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_source.go#L18-L20 | train |
chrislusf/gleam | flow/dataset_source.go | Listen | func (fc *Flow) Listen(network, address string) (ret *Dataset) {
fn := func(writer io.Writer, stats *pb.InstructionStat) error {
listener, err := net.Listen(network, address)
if err != nil {
return fmt.Errorf("Fail to listen on %s %s: %v", network, address, err)
}
conn, err := listener.Accept()
if err != ... | go | func (fc *Flow) Listen(network, address string) (ret *Dataset) {
fn := func(writer io.Writer, stats *pb.InstructionStat) error {
listener, err := net.Listen(network, address)
if err != nil {
return fmt.Errorf("Fail to listen on %s %s: %v", network, address, err)
}
conn, err := listener.Accept()
if err != ... | [
"func",
"(",
"fc",
"*",
"Flow",
")",
"Listen",
"(",
"network",
",",
"address",
"string",
")",
"(",
"ret",
"*",
"Dataset",
")",
"{",
"fn",
":=",
"func",
"(",
"writer",
"io",
".",
"Writer",
",",
"stats",
"*",
"pb",
".",
"InstructionStat",
")",
"error... | // Listen receives textual inputs via a socket.
// Multiple parameters are separated via tab. | [
"Listen",
"receives",
"textual",
"inputs",
"via",
"a",
"socket",
".",
"Multiple",
"parameters",
"are",
"separated",
"via",
"tab",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_source.go#L24-L48 | train |
chrislusf/gleam | flow/context_hint.go | Hint | func (d *Flow) Hint(options ...FlowHintOption) {
var config FlowConfig
for _, option := range options {
option(&config)
}
} | go | func (d *Flow) Hint(options ...FlowHintOption) {
var config FlowConfig
for _, option := range options {
option(&config)
}
} | [
"func",
"(",
"d",
"*",
"Flow",
")",
"Hint",
"(",
"options",
"...",
"FlowHintOption",
")",
"{",
"var",
"config",
"FlowConfig",
"\n",
"for",
"_",
",",
"option",
":=",
"range",
"options",
"{",
"option",
"(",
"&",
"config",
")",
"\n",
"}",
"\n",
"}"
] | // Hint adds hints to the flow. | [
"Hint",
"adds",
"hints",
"to",
"the",
"flow",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/context_hint.go#L10-L15 | train |
chrislusf/gleam | flow/context_hint.go | GetTotalSize | func (d *Dataset) GetTotalSize() int64 {
if d.Meta.TotalSize >= 0 {
return d.Meta.TotalSize
}
var currentDatasetTotalSize int64
for _, ds := range d.Step.InputDatasets {
currentDatasetTotalSize += ds.GetTotalSize()
}
d.Meta.TotalSize = currentDatasetTotalSize
return currentDatasetTotalSize
} | go | func (d *Dataset) GetTotalSize() int64 {
if d.Meta.TotalSize >= 0 {
return d.Meta.TotalSize
}
var currentDatasetTotalSize int64
for _, ds := range d.Step.InputDatasets {
currentDatasetTotalSize += ds.GetTotalSize()
}
d.Meta.TotalSize = currentDatasetTotalSize
return currentDatasetTotalSize
} | [
"func",
"(",
"d",
"*",
"Dataset",
")",
"GetTotalSize",
"(",
")",
"int64",
"{",
"if",
"d",
".",
"Meta",
".",
"TotalSize",
">=",
"0",
"{",
"return",
"d",
".",
"Meta",
".",
"TotalSize",
"\n",
"}",
"\n",
"var",
"currentDatasetTotalSize",
"int64",
"\n",
"... | // GetTotalSize returns the total size in MB for the dataset.
// This is based on the given hint. | [
"GetTotalSize",
"returns",
"the",
"total",
"size",
"in",
"MB",
"for",
"the",
"dataset",
".",
"This",
"is",
"based",
"on",
"the",
"given",
"hint",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/context_hint.go#L19-L29 | train |
chrislusf/gleam | flow/context_hint.go | GetPartitionSize | func (d *Dataset) GetPartitionSize() int64 {
return d.GetTotalSize() / int64(len(d.Shards))
} | go | func (d *Dataset) GetPartitionSize() int64 {
return d.GetTotalSize() / int64(len(d.Shards))
} | [
"func",
"(",
"d",
"*",
"Dataset",
")",
"GetPartitionSize",
"(",
")",
"int64",
"{",
"return",
"d",
".",
"GetTotalSize",
"(",
")",
"/",
"int64",
"(",
"len",
"(",
"d",
".",
"Shards",
")",
")",
"\n",
"}"
] | // GetPartitionSize returns the size in MB for each partition of
// the dataset. This is based on the hinted total size divided by
// the number of partitions. | [
"GetPartitionSize",
"returns",
"the",
"size",
"in",
"MB",
"for",
"each",
"partition",
"of",
"the",
"dataset",
".",
"This",
"is",
"based",
"on",
"the",
"hinted",
"total",
"size",
"divided",
"by",
"the",
"number",
"of",
"partitions",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/context_hint.go#L34-L36 | train |
chrislusf/gleam | sql/util/types/time.go | CompareString | func (t Time) CompareString(str string) (int, error) {
// use MaxFsp to parse the string
o, err := ParseTime(str, t.Type, MaxFsp)
if err != nil {
return 0, errors.Trace(err)
}
return t.Compare(o), nil
} | go | func (t Time) CompareString(str string) (int, error) {
// use MaxFsp to parse the string
o, err := ParseTime(str, t.Type, MaxFsp)
if err != nil {
return 0, errors.Trace(err)
}
return t.Compare(o), nil
} | [
"func",
"(",
"t",
"Time",
")",
"CompareString",
"(",
"str",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"// use MaxFsp to parse the string",
"o",
",",
"err",
":=",
"ParseTime",
"(",
"str",
",",
"t",
".",
"Type",
",",
"MaxFsp",
")",
"\n",
"if",
... | // CompareString is like Compare,
// but parses string to Time then compares. | [
"CompareString",
"is",
"like",
"Compare",
"but",
"parses",
"string",
"to",
"Time",
"then",
"compares",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/time.go#L297-L305 | train |
chrislusf/gleam | sql/util/types/time.go | AdjustYear | func AdjustYear(y int64) (int64, error) {
y = int64(adjustYear(int(y)))
if y < int64(MinYear) || y > int64(MaxYear) {
return 0, errors.Trace(ErrInvalidYear)
}
return y, nil
} | go | func AdjustYear(y int64) (int64, error) {
y = int64(adjustYear(int(y)))
if y < int64(MinYear) || y > int64(MaxYear) {
return 0, errors.Trace(ErrInvalidYear)
}
return y, nil
} | [
"func",
"AdjustYear",
"(",
"y",
"int64",
")",
"(",
"int64",
",",
"error",
")",
"{",
"y",
"=",
"int64",
"(",
"adjustYear",
"(",
"int",
"(",
"y",
")",
")",
")",
"\n",
"if",
"y",
"<",
"int64",
"(",
"MinYear",
")",
"||",
"y",
">",
"int64",
"(",
"... | // AdjustYear is used for adjusting year and checking its validation. | [
"AdjustYear",
"is",
"used",
"for",
"adjusting",
"year",
"and",
"checking",
"its",
"validation",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/time.go#L662-L669 | train |
chrislusf/gleam | sql/util/types/time.go | extractSecondMicrosecond | func extractSecondMicrosecond(format string) (int64, int64, int64, gotime.Duration, error) {
fields := strings.Split(format, ".")
if len(fields) != 2 {
return 0, 0, 0, 0, errors.Errorf("invalid time format - %s", format)
}
seconds, err := strconv.ParseInt(fields[0], 10, 64)
if err != nil {
return 0, 0, 0, 0, ... | go | func extractSecondMicrosecond(format string) (int64, int64, int64, gotime.Duration, error) {
fields := strings.Split(format, ".")
if len(fields) != 2 {
return 0, 0, 0, 0, errors.Errorf("invalid time format - %s", format)
}
seconds, err := strconv.ParseInt(fields[0], 10, 64)
if err != nil {
return 0, 0, 0, 0, ... | [
"func",
"extractSecondMicrosecond",
"(",
"format",
"string",
")",
"(",
"int64",
",",
"int64",
",",
"int64",
",",
"gotime",
".",
"Duration",
",",
"error",
")",
"{",
"fields",
":=",
"strings",
".",
"Split",
"(",
"format",
",",
"\"",
"\"",
")",
"\n",
"if"... | // Format is `SS.FFFFFF`. | [
"Format",
"is",
"SS",
".",
"FFFFFF",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/time.go#L1342-L1359 | train |
chrislusf/gleam | sql/util/types/time.go | extractDayHour | func extractDayHour(format string) (int64, int64, int64, gotime.Duration, error) {
fields := strings.Split(format, " ")
if len(fields) != 2 {
return 0, 0, 0, 0, errors.Errorf("invalid time format - %s", format)
}
days, err := strconv.ParseInt(fields[0], 10, 64)
if err != nil {
return 0, 0, 0, 0, errors.Errorf... | go | func extractDayHour(format string) (int64, int64, int64, gotime.Duration, error) {
fields := strings.Split(format, " ")
if len(fields) != 2 {
return 0, 0, 0, 0, errors.Errorf("invalid time format - %s", format)
}
days, err := strconv.ParseInt(fields[0], 10, 64)
if err != nil {
return 0, 0, 0, 0, errors.Errorf... | [
"func",
"extractDayHour",
"(",
"format",
"string",
")",
"(",
"int64",
",",
"int64",
",",
"int64",
",",
"gotime",
".",
"Duration",
",",
"error",
")",
"{",
"fields",
":=",
"strings",
".",
"Split",
"(",
"format",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",... | // Format is `DD HH`. | [
"Format",
"is",
"DD",
"HH",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/time.go#L1532-L1549 | train |
chrislusf/gleam | sql/util/types/time.go | extractYearMonth | func extractYearMonth(format string) (int64, int64, int64, gotime.Duration, error) {
fields := strings.Split(format, "-")
if len(fields) != 2 {
return 0, 0, 0, 0, errors.Errorf("invalid time format - %s", format)
}
years, err := strconv.ParseInt(fields[0], 10, 64)
if err != nil {
return 0, 0, 0, 0, errors.Err... | go | func extractYearMonth(format string) (int64, int64, int64, gotime.Duration, error) {
fields := strings.Split(format, "-")
if len(fields) != 2 {
return 0, 0, 0, 0, errors.Errorf("invalid time format - %s", format)
}
years, err := strconv.ParseInt(fields[0], 10, 64)
if err != nil {
return 0, 0, 0, 0, errors.Err... | [
"func",
"extractYearMonth",
"(",
"format",
"string",
")",
"(",
"int64",
",",
"int64",
",",
"int64",
",",
"gotime",
".",
"Duration",
",",
"error",
")",
"{",
"fields",
":=",
"strings",
".",
"Split",
"(",
"format",
",",
"\"",
"\"",
")",
"\n",
"if",
"len... | // Format is `YYYY-MM`. | [
"Format",
"is",
"YYYY",
"-",
"MM",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/time.go#L1552-L1569 | train |
chrislusf/gleam | sql/util/types/time.go | mysqlTimeFix | func mysqlTimeFix(t *mysqlTime, ctx map[string]int) error {
// Key of the ctx is the format char, such as `%j` `%p` and so on.
if yearOfDay, ok := ctx["%j"]; ok {
// TODO: Implement the function that converts day of year to yy:mm:dd.
_ = yearOfDay
}
if valueAMorPm, ok := ctx["%p"]; ok {
if t.hour == 0 {
re... | go | func mysqlTimeFix(t *mysqlTime, ctx map[string]int) error {
// Key of the ctx is the format char, such as `%j` `%p` and so on.
if yearOfDay, ok := ctx["%j"]; ok {
// TODO: Implement the function that converts day of year to yy:mm:dd.
_ = yearOfDay
}
if valueAMorPm, ok := ctx["%p"]; ok {
if t.hour == 0 {
re... | [
"func",
"mysqlTimeFix",
"(",
"t",
"*",
"mysqlTime",
",",
"ctx",
"map",
"[",
"string",
"]",
"int",
")",
"error",
"{",
"// Key of the ctx is the format char, such as `%j` `%p` and so on.",
"if",
"yearOfDay",
",",
"ok",
":=",
"ctx",
"[",
"\"",
"\"",
"]",
";",
"ok... | // mysqlTimeFix fixes the mysqlTime use the values in the context. | [
"mysqlTimeFix",
"fixes",
"the",
"mysqlTime",
"use",
"the",
"values",
"in",
"the",
"context",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/time.go#L1821-L1846 | train |
chrislusf/gleam | sql/util/types/time.go | strToDate | func strToDate(t *mysqlTime, date string, format string, ctx map[string]int) bool {
date = skipWhiteSpace(date)
format = skipWhiteSpace(format)
token, formatRemain, succ := getFormatToken(format)
if !succ {
return false
}
if token == "" {
// Extra characters at the end of date are ignored.
return true
}
... | go | func strToDate(t *mysqlTime, date string, format string, ctx map[string]int) bool {
date = skipWhiteSpace(date)
format = skipWhiteSpace(format)
token, formatRemain, succ := getFormatToken(format)
if !succ {
return false
}
if token == "" {
// Extra characters at the end of date are ignored.
return true
}
... | [
"func",
"strToDate",
"(",
"t",
"*",
"mysqlTime",
",",
"date",
"string",
",",
"format",
"string",
",",
"ctx",
"map",
"[",
"string",
"]",
"int",
")",
"bool",
"{",
"date",
"=",
"skipWhiteSpace",
"(",
"date",
")",
"\n",
"format",
"=",
"skipWhiteSpace",
"("... | // strToDate converts date string according to format, returns true on success,
// the value will be stored in argument t or ctx. | [
"strToDate",
"converts",
"date",
"string",
"according",
"to",
"format",
"returns",
"true",
"on",
"success",
"the",
"value",
"will",
"be",
"stored",
"in",
"argument",
"t",
"or",
"ctx",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/time.go#L1850-L1870 | train |
chrislusf/gleam | sql/util/types/time.go | dayOfMonthWithSuffix | func dayOfMonthWithSuffix(t *mysqlTime, input string, ctx map[string]int) (string, bool) {
month, remain := parseOrdinalNumbers(input)
if month >= 0 {
t.month = uint8(month)
return remain, true
}
return input, false
} | go | func dayOfMonthWithSuffix(t *mysqlTime, input string, ctx map[string]int) (string, bool) {
month, remain := parseOrdinalNumbers(input)
if month >= 0 {
t.month = uint8(month)
return remain, true
}
return input, false
} | [
"func",
"dayOfMonthWithSuffix",
"(",
"t",
"*",
"mysqlTime",
",",
"input",
"string",
",",
"ctx",
"map",
"[",
"string",
"]",
"int",
")",
"(",
"string",
",",
"bool",
")",
"{",
"month",
",",
"remain",
":=",
"parseOrdinalNumbers",
"(",
"input",
")",
"\n",
"... | // 0th 1st 2nd 3rd ... | [
"0th",
"1st",
"2nd",
"3rd",
"..."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/time.go#L2240-L2247 | train |
chrislusf/gleam | gio/emit.go | TsEmit | func TsEmit(ts int64, anyObject ...interface{}) error {
stat.Stats[0].OutputCounter++
return util.NewRow(ts, anyObject...).WriteTo(os.Stdout)
} | go | func TsEmit(ts int64, anyObject ...interface{}) error {
stat.Stats[0].OutputCounter++
return util.NewRow(ts, anyObject...).WriteTo(os.Stdout)
} | [
"func",
"TsEmit",
"(",
"ts",
"int64",
",",
"anyObject",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"stat",
".",
"Stats",
"[",
"0",
"]",
".",
"OutputCounter",
"++",
"\n",
"return",
"util",
".",
"NewRow",
"(",
"ts",
",",
"anyObject",
"...",
")",
... | // TsEmit encode and write a row of data to os.Stdout
// with ts in milliseconds epoch time | [
"TsEmit",
"encode",
"and",
"write",
"a",
"row",
"of",
"data",
"to",
"os",
".",
"Stdout",
"with",
"ts",
"in",
"milliseconds",
"epoch",
"time"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/gio/emit.go#L16-L19 | train |
chrislusf/gleam | sql/parser/yy_parser.go | Parse | func (parser *Parser) Parse(sql, charset, collation string) ([]ast.StmtNode, error) {
if charset == "" {
charset = mysql.DefaultCharset
}
if collation == "" {
collation = mysql.DefaultCollationName
}
parser.charset = charset
parser.collation = collation
parser.src = sql
parser.result = parser.result[:0]
v... | go | func (parser *Parser) Parse(sql, charset, collation string) ([]ast.StmtNode, error) {
if charset == "" {
charset = mysql.DefaultCharset
}
if collation == "" {
collation = mysql.DefaultCollationName
}
parser.charset = charset
parser.collation = collation
parser.src = sql
parser.result = parser.result[:0]
v... | [
"func",
"(",
"parser",
"*",
"Parser",
")",
"Parse",
"(",
"sql",
",",
"charset",
",",
"collation",
"string",
")",
"(",
"[",
"]",
"ast",
".",
"StmtNode",
",",
"error",
")",
"{",
"if",
"charset",
"==",
"\"",
"\"",
"{",
"charset",
"=",
"mysql",
".",
... | // Parse parses a query string to raw ast.StmtNode.
// If charset or collation is "", default charset and collation will be used. | [
"Parse",
"parses",
"a",
"query",
"string",
"to",
"raw",
"ast",
".",
"StmtNode",
".",
"If",
"charset",
"or",
"collation",
"is",
"default",
"charset",
"and",
"collation",
"will",
"be",
"used",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/parser/yy_parser.go#L78-L102 | train |
chrislusf/gleam | sql/parser/yy_parser.go | ParseOneStmt | func (parser *Parser) ParseOneStmt(sql, charset, collation string) (ast.StmtNode, error) {
stmts, err := parser.Parse(sql, charset, collation)
if err != nil {
return nil, errors.Trace(err)
}
if len(stmts) != 1 {
return nil, ErrSyntax
}
ast.SetFlag(stmts[0])
return stmts[0], nil
} | go | func (parser *Parser) ParseOneStmt(sql, charset, collation string) (ast.StmtNode, error) {
stmts, err := parser.Parse(sql, charset, collation)
if err != nil {
return nil, errors.Trace(err)
}
if len(stmts) != 1 {
return nil, ErrSyntax
}
ast.SetFlag(stmts[0])
return stmts[0], nil
} | [
"func",
"(",
"parser",
"*",
"Parser",
")",
"ParseOneStmt",
"(",
"sql",
",",
"charset",
",",
"collation",
"string",
")",
"(",
"ast",
".",
"StmtNode",
",",
"error",
")",
"{",
"stmts",
",",
"err",
":=",
"parser",
".",
"Parse",
"(",
"sql",
",",
"charset"... | // ParseOneStmt parses a query and returns an ast.StmtNode.
// The query must have one statement, otherwise ErrSyntax is returned. | [
"ParseOneStmt",
"parses",
"a",
"query",
"and",
"returns",
"an",
"ast",
".",
"StmtNode",
".",
"The",
"query",
"must",
"have",
"one",
"statement",
"otherwise",
"ErrSyntax",
"is",
"returned",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/parser/yy_parser.go#L106-L116 | train |
chrislusf/gleam | sql/parser/yy_parser.go | setLastSelectFieldText | func (parser *Parser) setLastSelectFieldText(st *ast.SelectStmt, lastEnd int) {
lastField := st.Fields.Fields[len(st.Fields.Fields)-1]
if lastField.Offset+len(lastField.Text()) >= len(parser.src)-1 {
lastField.SetText(parser.src[lastField.Offset:lastEnd])
}
} | go | func (parser *Parser) setLastSelectFieldText(st *ast.SelectStmt, lastEnd int) {
lastField := st.Fields.Fields[len(st.Fields.Fields)-1]
if lastField.Offset+len(lastField.Text()) >= len(parser.src)-1 {
lastField.SetText(parser.src[lastField.Offset:lastEnd])
}
} | [
"func",
"(",
"parser",
"*",
"Parser",
")",
"setLastSelectFieldText",
"(",
"st",
"*",
"ast",
".",
"SelectStmt",
",",
"lastEnd",
"int",
")",
"{",
"lastField",
":=",
"st",
".",
"Fields",
".",
"Fields",
"[",
"len",
"(",
"st",
".",
"Fields",
".",
"Fields",
... | // The select statement is not at the end of the whole statement, if the last
// field text was set from its offset to the end of the src string, update
// the last field text. | [
"The",
"select",
"statement",
"is",
"not",
"at",
"the",
"end",
"of",
"the",
"whole",
"statement",
"if",
"the",
"last",
"field",
"text",
"was",
"set",
"from",
"its",
"offset",
"to",
"the",
"end",
"of",
"the",
"src",
"string",
"update",
"the",
"last",
"f... | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/parser/yy_parser.go#L121-L126 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.