id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
20,400
uniplaces/carbon
carbon.go
DiffInMinutes
func (c *Carbon) DiffInMinutes(d *Carbon, abs bool) int64 { return c.DiffInSeconds(d, abs) / secondsPerMinute }
go
func (c *Carbon) DiffInMinutes(d *Carbon, abs bool) int64 { return c.DiffInSeconds(d, abs) / secondsPerMinute }
[ "func", "(", "c", "*", "Carbon", ")", "DiffInMinutes", "(", "d", "*", "Carbon", ",", "abs", "bool", ")", "int64", "{", "return", "c", ".", "DiffInSeconds", "(", "d", ",", "abs", ")", "/", "secondsPerMinute", "\n", "}" ]
// DiffInMinutes returns the difference in minutes
[ "DiffInMinutes", "returns", "the", "difference", "in", "minutes" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1356-L1358
20,401
uniplaces/carbon
carbon.go
DiffInSeconds
func (c *Carbon) DiffInSeconds(carb *Carbon, abs bool) int64 { if carb == nil { carb = nowIn(c.Location()) } diff := carb.Timestamp() - c.Timestamp() return absValue(abs, diff) }
go
func (c *Carbon) DiffInSeconds(carb *Carbon, abs bool) int64 { if carb == nil { carb = nowIn(c.Location()) } diff := carb.Timestamp() - c.Timestamp() return absValue(abs, diff) }
[ "func", "(", "c", "*", "Carbon", ")", "DiffInSeconds", "(", "carb", "*", "Carbon", ",", "abs", "bool", ")", "int64", "{", "if", "carb", "==", "nil", "{", "carb", "=", "nowIn", "(", "c", ".", "Location", "(", ")", ")", "\n", "}", "\n", "diff", "...
// DiffInSeconds returns the difference in seconds
[ "DiffInSeconds", "returns", "the", "difference", "in", "seconds" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1361-L1368
20,402
uniplaces/carbon
carbon.go
SecondsSinceMidnight
func (c *Carbon) SecondsSinceMidnight() int { startOfDay := c.StartOfDay() return int(c.DiffInSeconds(startOfDay, true)) }
go
func (c *Carbon) SecondsSinceMidnight() int { startOfDay := c.StartOfDay() return int(c.DiffInSeconds(startOfDay, true)) }
[ "func", "(", "c", "*", "Carbon", ")", "SecondsSinceMidnight", "(", ")", "int", "{", "startOfDay", ":=", "c", ".", "StartOfDay", "(", ")", "\n\n", "return", "int", "(", "c", ".", "DiffInSeconds", "(", "startOfDay", ",", "true", ")", ")", "\n", "}" ]
// SecondsSinceMidnight returns the number of seconds since midnight.
[ "SecondsSinceMidnight", "returns", "the", "number", "of", "seconds", "since", "midnight", "." ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1371-L1375
20,403
uniplaces/carbon
carbon.go
absValue
func absValue(needsAbs bool, value int64) int64 { if needsAbs && value < 0 { return -value } return value }
go
func absValue(needsAbs bool, value int64) int64 { if needsAbs && value < 0 { return -value } return value }
[ "func", "absValue", "(", "needsAbs", "bool", ",", "value", "int64", ")", "int64", "{", "if", "needsAbs", "&&", "value", "<", "0", "{", "return", "-", "value", "\n", "}", "\n\n", "return", "value", "\n", "}" ]
// absValue returns the abs value if needed
[ "absValue", "returns", "the", "abs", "value", "if", "needed" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1385-L1391
20,404
uniplaces/carbon
carbon.go
Next
func (c *Carbon) Next(wd time.Weekday) *Carbon { c = c.AddDay() for c.Weekday() != wd { c = c.AddDay() } return c.StartOfDay() }
go
func (c *Carbon) Next(wd time.Weekday) *Carbon { c = c.AddDay() for c.Weekday() != wd { c = c.AddDay() } return c.StartOfDay() }
[ "func", "(", "c", "*", "Carbon", ")", "Next", "(", "wd", "time", ".", "Weekday", ")", "*", "Carbon", "{", "c", "=", "c", ".", "AddDay", "(", ")", "\n", "for", "c", ".", "Weekday", "(", ")", "!=", "wd", "{", "c", "=", "c", ".", "AddDay", "("...
// Next changes the time to the next occurrence of a given day of the week
[ "Next", "changes", "the", "time", "to", "the", "next", "occurrence", "of", "a", "given", "day", "of", "the", "week" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1609-L1616
20,405
uniplaces/carbon
carbon.go
NextWeekendDay
func (c *Carbon) NextWeekendDay() *Carbon { c = c.AddDay() for !c.IsWeekend() { c = c.AddDay() } return c }
go
func (c *Carbon) NextWeekendDay() *Carbon { c = c.AddDay() for !c.IsWeekend() { c = c.AddDay() } return c }
[ "func", "(", "c", "*", "Carbon", ")", "NextWeekendDay", "(", ")", "*", "Carbon", "{", "c", "=", "c", ".", "AddDay", "(", ")", "\n", "for", "!", "c", ".", "IsWeekend", "(", ")", "{", "c", "=", "c", ".", "AddDay", "(", ")", "\n", "}", "\n\n", ...
// NextWeekendDay goes forward to the next weekend day
[ "NextWeekendDay", "goes", "forward", "to", "the", "next", "weekend", "day" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1629-L1636
20,406
uniplaces/carbon
carbon.go
PreviousWeekendDay
func (c *Carbon) PreviousWeekendDay() *Carbon { c = c.SubDay() for !c.IsWeekend() { c = c.SubDay() } return c }
go
func (c *Carbon) PreviousWeekendDay() *Carbon { c = c.SubDay() for !c.IsWeekend() { c = c.SubDay() } return c }
[ "func", "(", "c", "*", "Carbon", ")", "PreviousWeekendDay", "(", ")", "*", "Carbon", "{", "c", "=", "c", ".", "SubDay", "(", ")", "\n", "for", "!", "c", ".", "IsWeekend", "(", ")", "{", "c", "=", "c", ".", "SubDay", "(", ")", "\n", "}", "\n\n...
// PreviousWeekendDay goes back to the previous weekend day
[ "PreviousWeekendDay", "goes", "back", "to", "the", "previous", "weekend", "day" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1639-L1646
20,407
uniplaces/carbon
carbon.go
Previous
func (c *Carbon) Previous(wd time.Weekday) *Carbon { c = c.SubDay() for c.Weekday() != wd { c = c.SubDay() } return c.StartOfDay() }
go
func (c *Carbon) Previous(wd time.Weekday) *Carbon { c = c.SubDay() for c.Weekday() != wd { c = c.SubDay() } return c.StartOfDay() }
[ "func", "(", "c", "*", "Carbon", ")", "Previous", "(", "wd", "time", ".", "Weekday", ")", "*", "Carbon", "{", "c", "=", "c", ".", "SubDay", "(", ")", "\n", "for", "c", ".", "Weekday", "(", ")", "!=", "wd", "{", "c", "=", "c", ".", "SubDay", ...
// Previous changes the time to the previous occurrence of a given day of the week
[ "Previous", "changes", "the", "time", "to", "the", "previous", "occurrence", "of", "a", "given", "day", "of", "the", "week" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1649-L1656
20,408
uniplaces/carbon
carbon.go
FirstOfMonth
func (c *Carbon) FirstOfMonth(wd time.Weekday) *Carbon { d := c.StartOfMonth() if d.Weekday() != wd { return d.Next(wd) } return d }
go
func (c *Carbon) FirstOfMonth(wd time.Weekday) *Carbon { d := c.StartOfMonth() if d.Weekday() != wd { return d.Next(wd) } return d }
[ "func", "(", "c", "*", "Carbon", ")", "FirstOfMonth", "(", "wd", "time", ".", "Weekday", ")", "*", "Carbon", "{", "d", ":=", "c", ".", "StartOfMonth", "(", ")", "\n", "if", "d", ".", "Weekday", "(", ")", "!=", "wd", "{", "return", "d", ".", "Ne...
// FirstOfMonth returns the first occurrence of a given day of the week in the current month
[ "FirstOfMonth", "returns", "the", "first", "occurrence", "of", "a", "given", "day", "of", "the", "week", "in", "the", "current", "month" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1659-L1666
20,409
uniplaces/carbon
carbon.go
LastOfMonth
func (c *Carbon) LastOfMonth(wd time.Weekday) *Carbon { d := c.EndOfMonth() if d.Weekday() != wd { return d.Previous(wd) } return d.StartOfDay() }
go
func (c *Carbon) LastOfMonth(wd time.Weekday) *Carbon { d := c.EndOfMonth() if d.Weekday() != wd { return d.Previous(wd) } return d.StartOfDay() }
[ "func", "(", "c", "*", "Carbon", ")", "LastOfMonth", "(", "wd", "time", ".", "Weekday", ")", "*", "Carbon", "{", "d", ":=", "c", ".", "EndOfMonth", "(", ")", "\n", "if", "d", ".", "Weekday", "(", ")", "!=", "wd", "{", "return", "d", ".", "Previ...
// LastOfMonth returns the last occurrence of a given day of the week in the current month
[ "LastOfMonth", "returns", "the", "last", "occurrence", "of", "a", "given", "day", "of", "the", "week", "in", "the", "current", "month" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1669-L1676
20,410
uniplaces/carbon
carbon.go
LastDayOfMonth
func (c *Carbon) LastDayOfMonth() *Carbon { return NewCarbon(time.Date(c.Year(), c.Month(), c.DaysInMonth(), 0, 0, 0, 0, time.UTC)) }
go
func (c *Carbon) LastDayOfMonth() *Carbon { return NewCarbon(time.Date(c.Year(), c.Month(), c.DaysInMonth(), 0, 0, 0, 0, time.UTC)) }
[ "func", "(", "c", "*", "Carbon", ")", "LastDayOfMonth", "(", ")", "*", "Carbon", "{", "return", "NewCarbon", "(", "time", ".", "Date", "(", "c", ".", "Year", "(", ")", ",", "c", ".", "Month", "(", ")", ",", "c", ".", "DaysInMonth", "(", ")", ",...
// LastDayOfMonth returns a new carbon instance with the last day of current month
[ "LastDayOfMonth", "returns", "a", "new", "carbon", "instance", "with", "the", "last", "day", "of", "current", "month" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1679-L1681
20,411
uniplaces/carbon
carbon.go
FirstDayOfMonth
func (c *Carbon) FirstDayOfMonth() *Carbon { return NewCarbon(time.Date(c.Year(), c.Month(), 1, 0, 0, 0, 0, time.UTC)) }
go
func (c *Carbon) FirstDayOfMonth() *Carbon { return NewCarbon(time.Date(c.Year(), c.Month(), 1, 0, 0, 0, 0, time.UTC)) }
[ "func", "(", "c", "*", "Carbon", ")", "FirstDayOfMonth", "(", ")", "*", "Carbon", "{", "return", "NewCarbon", "(", "time", ".", "Date", "(", "c", ".", "Year", "(", ")", ",", "c", ".", "Month", "(", ")", ",", "1", ",", "0", ",", "0", ",", "0",...
// FirstDayOfMonth returns a new carbon instance with the first day of current month
[ "FirstDayOfMonth", "returns", "a", "new", "carbon", "instance", "with", "the", "first", "day", "of", "current", "month" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1684-L1686
20,412
uniplaces/carbon
carbon.go
NthOfMonth
func (c *Carbon) NthOfMonth(nth int, wd time.Weekday) *Carbon { cp := c.Copy().StartOfMonth() i := 0 if cp.Weekday() == wd { i++ } for i < nth { cp = cp.Next(wd) i++ } if cp.Gt(c.EndOfMonth()) { return c } return cp }
go
func (c *Carbon) NthOfMonth(nth int, wd time.Weekday) *Carbon { cp := c.Copy().StartOfMonth() i := 0 if cp.Weekday() == wd { i++ } for i < nth { cp = cp.Next(wd) i++ } if cp.Gt(c.EndOfMonth()) { return c } return cp }
[ "func", "(", "c", "*", "Carbon", ")", "NthOfMonth", "(", "nth", "int", ",", "wd", "time", ".", "Weekday", ")", "*", "Carbon", "{", "cp", ":=", "c", ".", "Copy", "(", ")", ".", "StartOfMonth", "(", ")", "\n", "i", ":=", "0", "\n", "if", "cp", ...
// NthOfMonth returns the given occurrence of a given day of the week in the current month // If the calculated occurrence is outside the scope of current month, no modifications are made
[ "NthOfMonth", "returns", "the", "given", "occurrence", "of", "a", "given", "day", "of", "the", "week", "in", "the", "current", "month", "If", "the", "calculated", "occurrence", "is", "outside", "the", "scope", "of", "current", "month", "no", "modifications", ...
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1690-L1705
20,413
uniplaces/carbon
carbon.go
FirstOfQuarter
func (c *Carbon) FirstOfQuarter(wd time.Weekday) *Carbon { d := c.StartOfQuarter() if d.Weekday() != wd { return d.Next(wd) } return d }
go
func (c *Carbon) FirstOfQuarter(wd time.Weekday) *Carbon { d := c.StartOfQuarter() if d.Weekday() != wd { return d.Next(wd) } return d }
[ "func", "(", "c", "*", "Carbon", ")", "FirstOfQuarter", "(", "wd", "time", ".", "Weekday", ")", "*", "Carbon", "{", "d", ":=", "c", ".", "StartOfQuarter", "(", ")", "\n", "if", "d", ".", "Weekday", "(", ")", "!=", "wd", "{", "return", "d", ".", ...
// FirstOfQuarter returns the first occurrence of a given day of the week in the current quarter
[ "FirstOfQuarter", "returns", "the", "first", "occurrence", "of", "a", "given", "day", "of", "the", "week", "in", "the", "current", "quarter" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1708-L1715
20,414
uniplaces/carbon
carbon.go
LastOfQuarter
func (c *Carbon) LastOfQuarter(wd time.Weekday) *Carbon { d := c.EndOfQuarter() if d.Weekday() != wd { return d.Previous(wd) } return d.StartOfDay() }
go
func (c *Carbon) LastOfQuarter(wd time.Weekday) *Carbon { d := c.EndOfQuarter() if d.Weekday() != wd { return d.Previous(wd) } return d.StartOfDay() }
[ "func", "(", "c", "*", "Carbon", ")", "LastOfQuarter", "(", "wd", "time", ".", "Weekday", ")", "*", "Carbon", "{", "d", ":=", "c", ".", "EndOfQuarter", "(", ")", "\n", "if", "d", ".", "Weekday", "(", ")", "!=", "wd", "{", "return", "d", ".", "P...
// LastOfQuarter returns the last occurrence of a given day of the week in the current quarter
[ "LastOfQuarter", "returns", "the", "last", "occurrence", "of", "a", "given", "day", "of", "the", "week", "in", "the", "current", "quarter" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1718-L1725
20,415
uniplaces/carbon
carbon.go
NthOfQuarter
func (c *Carbon) NthOfQuarter(nth int, wd time.Weekday) *Carbon { cp := c.Copy().StartOfQuarter() i := 0 if cp.Weekday() == wd { i++ } for i < nth { cp = cp.Next(wd) i++ } if cp.Gt(c.EndOfQuarter()) { return c } return cp }
go
func (c *Carbon) NthOfQuarter(nth int, wd time.Weekday) *Carbon { cp := c.Copy().StartOfQuarter() i := 0 if cp.Weekday() == wd { i++ } for i < nth { cp = cp.Next(wd) i++ } if cp.Gt(c.EndOfQuarter()) { return c } return cp }
[ "func", "(", "c", "*", "Carbon", ")", "NthOfQuarter", "(", "nth", "int", ",", "wd", "time", ".", "Weekday", ")", "*", "Carbon", "{", "cp", ":=", "c", ".", "Copy", "(", ")", ".", "StartOfQuarter", "(", ")", "\n", "i", ":=", "0", "\n", "if", "cp"...
// NthOfQuarter returns the given occurrence of a given day of the week in the current quarter // If the calculated occurrence is outside the scope of current quarter, no modifications are made
[ "NthOfQuarter", "returns", "the", "given", "occurrence", "of", "a", "given", "day", "of", "the", "week", "in", "the", "current", "quarter", "If", "the", "calculated", "occurrence", "is", "outside", "the", "scope", "of", "current", "quarter", "no", "modificatio...
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1729-L1744
20,416
uniplaces/carbon
carbon.go
FirstOfYear
func (c *Carbon) FirstOfYear(wd time.Weekday) *Carbon { d := c.StartOfYear() if d.Weekday() != wd { return d.Next(wd) } return d }
go
func (c *Carbon) FirstOfYear(wd time.Weekday) *Carbon { d := c.StartOfYear() if d.Weekday() != wd { return d.Next(wd) } return d }
[ "func", "(", "c", "*", "Carbon", ")", "FirstOfYear", "(", "wd", "time", ".", "Weekday", ")", "*", "Carbon", "{", "d", ":=", "c", ".", "StartOfYear", "(", ")", "\n", "if", "d", ".", "Weekday", "(", ")", "!=", "wd", "{", "return", "d", ".", "Next...
// FirstOfYear returns the first occurrence of a given day of the week in the current year
[ "FirstOfYear", "returns", "the", "first", "occurrence", "of", "a", "given", "day", "of", "the", "week", "in", "the", "current", "year" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1747-L1754
20,417
uniplaces/carbon
carbon.go
LastOfYear
func (c *Carbon) LastOfYear(wd time.Weekday) *Carbon { d := c.EndOfYear() if d.Weekday() != wd { return d.Previous(wd) } return d.StartOfDay() }
go
func (c *Carbon) LastOfYear(wd time.Weekday) *Carbon { d := c.EndOfYear() if d.Weekday() != wd { return d.Previous(wd) } return d.StartOfDay() }
[ "func", "(", "c", "*", "Carbon", ")", "LastOfYear", "(", "wd", "time", ".", "Weekday", ")", "*", "Carbon", "{", "d", ":=", "c", ".", "EndOfYear", "(", ")", "\n", "if", "d", ".", "Weekday", "(", ")", "!=", "wd", "{", "return", "d", ".", "Previou...
// LastOfYear returns the last occurrence of a given day of the week in the current year
[ "LastOfYear", "returns", "the", "last", "occurrence", "of", "a", "given", "day", "of", "the", "week", "in", "the", "current", "year" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1757-L1764
20,418
uniplaces/carbon
carbon.go
NthOfYear
func (c *Carbon) NthOfYear(nth int, wd time.Weekday) *Carbon { cp := c.Copy().StartOfYear() i := 0 if cp.Weekday() == wd { i++ } for i < nth { cp = cp.Next(wd) i++ } if cp.Gt(c.EndOfYear()) { return c } return cp }
go
func (c *Carbon) NthOfYear(nth int, wd time.Weekday) *Carbon { cp := c.Copy().StartOfYear() i := 0 if cp.Weekday() == wd { i++ } for i < nth { cp = cp.Next(wd) i++ } if cp.Gt(c.EndOfYear()) { return c } return cp }
[ "func", "(", "c", "*", "Carbon", ")", "NthOfYear", "(", "nth", "int", ",", "wd", "time", ".", "Weekday", ")", "*", "Carbon", "{", "cp", ":=", "c", ".", "Copy", "(", ")", ".", "StartOfYear", "(", ")", "\n", "i", ":=", "0", "\n", "if", "cp", "....
// NthOfYear returns the given occurrence of a given day of the week in the current year // If the calculated occurrence is outside the scope of current year, no modifications are made
[ "NthOfYear", "returns", "the", "given", "occurrence", "of", "a", "given", "day", "of", "the", "week", "in", "the", "current", "year", "If", "the", "calculated", "occurrence", "is", "outside", "the", "scope", "of", "current", "year", "no", "modifications", "a...
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1768-L1783
20,419
uniplaces/carbon
carbon.go
Average
func (c *Carbon) Average(carb *Carbon) *Carbon { if carb == nil { carb = nowIn(c.Location()) } if c.Eq(carb) { return c.Copy() } average := int(c.DiffInSeconds(carb, false) / 2) return c.AddSeconds(average) }
go
func (c *Carbon) Average(carb *Carbon) *Carbon { if carb == nil { carb = nowIn(c.Location()) } if c.Eq(carb) { return c.Copy() } average := int(c.DiffInSeconds(carb, false) / 2) return c.AddSeconds(average) }
[ "func", "(", "c", "*", "Carbon", ")", "Average", "(", "carb", "*", "Carbon", ")", "*", "Carbon", "{", "if", "carb", "==", "nil", "{", "carb", "=", "nowIn", "(", "c", ".", "Location", "(", ")", ")", "\n", "}", "\n", "if", "c", ".", "Eq", "(", ...
// Average returns the average between a given carbon date and the current date
[ "Average", "returns", "the", "average", "between", "a", "given", "carbon", "date", "and", "the", "current", "date" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1786-L1796
20,420
uniplaces/carbon
carbon.go
GetTranslator
func (c *Carbon) GetTranslator() (*Translator, error) { if c.Translator == nil { c.Translator = translator() } return c.Translator, nil }
go
func (c *Carbon) GetTranslator() (*Translator, error) { if c.Translator == nil { c.Translator = translator() } return c.Translator, nil }
[ "func", "(", "c", "*", "Carbon", ")", "GetTranslator", "(", ")", "(", "*", "Translator", ",", "error", ")", "{", "if", "c", ".", "Translator", "==", "nil", "{", "c", ".", "Translator", "=", "translator", "(", ")", "\n", "}", "\n\n", "return", "c", ...
// Localization // GetTranslator returns Translator inside a Carbon instance if exist, // otherwise it creates a new Translator with "en" as default locale
[ "Localization", "GetTranslator", "returns", "Translator", "inside", "a", "Carbon", "instance", "if", "exist", "otherwise", "it", "creates", "a", "new", "Translator", "with", "en", "as", "default", "locale" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1802-L1808
20,421
uniplaces/carbon
carbon.go
SetLocale
func (c *Carbon) SetLocale(l string) error { err := c.Translator.SetLocale(l) if err != nil { return err } return nil }
go
func (c *Carbon) SetLocale(l string) error { err := c.Translator.SetLocale(l) if err != nil { return err } return nil }
[ "func", "(", "c", "*", "Carbon", ")", "SetLocale", "(", "l", "string", ")", "error", "{", "err", ":=", "c", ".", "Translator", ".", "SetLocale", "(", "l", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "ni...
// SetLocale sets locale for the Translator of Carbon
[ "SetLocale", "sets", "locale", "for", "the", "Translator", "of", "Carbon" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1828-L1835
20,422
uniplaces/carbon
carboninterval.go
NewCarbonInterval
func NewCarbonInterval(start, end *Carbon) (*CarbonInterval, error) { if start.Gte(end) { return nil, errors.New("The end date must be greater than the start date.") } return &CarbonInterval{ Start: start, End: end, }, nil }
go
func NewCarbonInterval(start, end *Carbon) (*CarbonInterval, error) { if start.Gte(end) { return nil, errors.New("The end date must be greater than the start date.") } return &CarbonInterval{ Start: start, End: end, }, nil }
[ "func", "NewCarbonInterval", "(", "start", ",", "end", "*", "Carbon", ")", "(", "*", "CarbonInterval", ",", "error", ")", "{", "if", "start", ".", "Gte", "(", "end", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", ...
// NewCarbonInterval returns a pointer to a new CarbonInterval instance
[ "NewCarbonInterval", "returns", "a", "pointer", "to", "a", "new", "CarbonInterval", "instance" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carboninterval.go#L14-L23
20,423
uniplaces/carbon
carboninterval.go
DiffInHours
func (ci *CarbonInterval) DiffInHours() int64 { return ci.End.DiffInHours(ci.Start, true) }
go
func (ci *CarbonInterval) DiffInHours() int64 { return ci.End.DiffInHours(ci.Start, true) }
[ "func", "(", "ci", "*", "CarbonInterval", ")", "DiffInHours", "(", ")", "int64", "{", "return", "ci", ".", "End", ".", "DiffInHours", "(", "ci", ".", "Start", ",", "true", ")", "\n", "}" ]
// DiffInHours return the difference in hours between start and end date
[ "DiffInHours", "return", "the", "difference", "in", "hours", "between", "start", "and", "end", "date" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carboninterval.go#L26-L28
20,424
uniplaces/carbon
translator.go
SetLocale
func (t *Translator) SetLocale(l string) error { err := t.AssertValidLocale(l) if err != nil { return err } err = t.loadResource(l) if err != nil { return err } t.locale = l return nil }
go
func (t *Translator) SetLocale(l string) error { err := t.AssertValidLocale(l) if err != nil { return err } err = t.loadResource(l) if err != nil { return err } t.locale = l return nil }
[ "func", "(", "t", "*", "Translator", ")", "SetLocale", "(", "l", "string", ")", "error", "{", "err", ":=", "t", ".", "AssertValidLocale", "(", "l", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "err", "=", "t", "."...
// SetLocale will set locale on a Translator
[ "SetLocale", "will", "set", "locale", "on", "a", "Translator" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/translator.go#L33-L47
20,425
uniplaces/carbon
translator.go
AssertValidLocale
func (t *Translator) AssertValidLocale(l string) error { matched, err := regexp.MatchString("^(?:[a-z]{2}|[a-z]{2}(([_-]{1})([a-zA-Z]{2}){1,2}))$", l) if err != nil { return errors.New("unable to match locale code : " + err.Error()) } if !matched { return errors.New("invalid locale code : " + l) } return nil...
go
func (t *Translator) AssertValidLocale(l string) error { matched, err := regexp.MatchString("^(?:[a-z]{2}|[a-z]{2}(([_-]{1})([a-zA-Z]{2}){1,2}))$", l) if err != nil { return errors.New("unable to match locale code : " + err.Error()) } if !matched { return errors.New("invalid locale code : " + l) } return nil...
[ "func", "(", "t", "*", "Translator", ")", "AssertValidLocale", "(", "l", "string", ")", "error", "{", "matched", ",", "err", ":=", "regexp", ".", "MatchString", "(", "\"", "\"", ",", "l", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ...
// AssertValidLocale checks if the locale is valid or not
[ "AssertValidLocale", "checks", "if", "the", "locale", "is", "valid", "or", "not" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/translator.go#L50-L60
20,426
uniplaces/carbon
translator.go
loadResource
func (t *Translator) loadResource(l string) error { ltext, err := lang.LoadLocaleText(l) if err != nil { return err } err = json.Unmarshal(ltext, &t.resources) if err != nil { return errors.New("unable to unmarshall locale data : " + err.Error()) } return nil }
go
func (t *Translator) loadResource(l string) error { ltext, err := lang.LoadLocaleText(l) if err != nil { return err } err = json.Unmarshal(ltext, &t.resources) if err != nil { return errors.New("unable to unmarshall locale data : " + err.Error()) } return nil }
[ "func", "(", "t", "*", "Translator", ")", "loadResource", "(", "l", "string", ")", "error", "{", "ltext", ",", "err", ":=", "lang", ".", "LoadLocaleText", "(", "l", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "err"...
// loadResource loads the translations according to the locale
[ "loadResource", "loads", "the", "translations", "according", "to", "the", "locale" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/translator.go#L63-L75
20,427
uniplaces/carbon
translator.go
chooseUnit
func (t *Translator) chooseUnit(unit string, count int64) (string, error) { s := strings.Split(t.resources[unit], "|") if count > 1 { return strings.Replace(s[1], ":count", strconv.FormatInt(int64(count), 10), 1), nil } return s[0], nil }
go
func (t *Translator) chooseUnit(unit string, count int64) (string, error) { s := strings.Split(t.resources[unit], "|") if count > 1 { return strings.Replace(s[1], ":count", strconv.FormatInt(int64(count), 10), 1), nil } return s[0], nil }
[ "func", "(", "t", "*", "Translator", ")", "chooseUnit", "(", "unit", "string", ",", "count", "int64", ")", "(", "string", ",", "error", ")", "{", "s", ":=", "strings", ".", "Split", "(", "t", ".", "resources", "[", "unit", "]", ",", "\"", "\"", "...
// chooseUnit will choose unit of translations according to the count
[ "chooseUnit", "will", "choose", "unit", "of", "translations", "according", "to", "the", "count" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/translator.go#L78-L85
20,428
uniplaces/carbon
translator.go
chooseTrans
func (t *Translator) chooseTrans(transID, time string) string { return strings.Replace(t.resources[transID], ":time", time, 1) }
go
func (t *Translator) chooseTrans(transID, time string) string { return strings.Replace(t.resources[transID], ":time", time, 1) }
[ "func", "(", "t", "*", "Translator", ")", "chooseTrans", "(", "transID", ",", "time", "string", ")", "string", "{", "return", "strings", ".", "Replace", "(", "t", ".", "resources", "[", "transID", "]", ",", "\"", "\"", ",", "time", ",", "1", ")", "...
// chooseTrans will choose the word to make a diffForHumans statement
[ "chooseTrans", "will", "choose", "the", "word", "to", "make", "a", "diffForHumans", "statement" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/translator.go#L88-L90
20,429
uniplaces/carbon
lang/loader.go
LoadLocaleText
func LoadLocaleText(l string) ([]byte, error) { lText, err := ioutil.ReadFile("./lang/" + l + ".json") if err != nil { return nil, errors.New("not able to read the lang file:" + err.Error()) } return lText, nil }
go
func LoadLocaleText(l string) ([]byte, error) { lText, err := ioutil.ReadFile("./lang/" + l + ".json") if err != nil { return nil, errors.New("not able to read the lang file:" + err.Error()) } return lText, nil }
[ "func", "LoadLocaleText", "(", "l", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "lText", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "\"", "\"", "+", "l", "+", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "retur...
// LoadLocaleText will load the translations from the locale json files according to the locale
[ "LoadLocaleText", "will", "load", "the", "translations", "from", "the", "locale", "json", "files", "according", "to", "the", "locale" ]
223a8652664c690cc91a950eba4cbbc579defb71
https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/lang/loader.go#L9-L16
20,430
matryer/is
is.go
New
func New(t T) *I { return &I{t, t.FailNow, os.Stdout, !noColorFlag} }
go
func New(t T) *I { return &I{t, t.FailNow, os.Stdout, !noColorFlag} }
[ "func", "New", "(", "t", "T", ")", "*", "I", "{", "return", "&", "I", "{", "t", ",", "t", ".", "FailNow", ",", "os", ".", "Stdout", ",", "!", "noColorFlag", "}", "\n", "}" ]
// New makes a new testing helper using the specified // T through which failures will be reported. // In strict mode, failures call T.FailNow causing the test // to be aborted. See NewRelaxed for alternative behavior.
[ "New", "makes", "a", "new", "testing", "helper", "using", "the", "specified", "T", "through", "which", "failures", "will", "be", "reported", ".", "In", "strict", "mode", "failures", "call", "T", ".", "FailNow", "causing", "the", "test", "to", "be", "aborte...
2eb2c933a79e268369b74caa16ac7f4b84bba0ab
https://github.com/matryer/is/blob/2eb2c933a79e268369b74caa16ac7f4b84bba0ab/is.go#L84-L86
20,431
matryer/is
is.go
NewRelaxed
func NewRelaxed(t T) *I { return &I{t, t.Fail, os.Stdout, !noColorFlag} }
go
func NewRelaxed(t T) *I { return &I{t, t.Fail, os.Stdout, !noColorFlag} }
[ "func", "NewRelaxed", "(", "t", "T", ")", "*", "I", "{", "return", "&", "I", "{", "t", ",", "t", ".", "Fail", ",", "os", ".", "Stdout", ",", "!", "noColorFlag", "}", "\n", "}" ]
// NewRelaxed makes a new testing helper using the specified // T through which failures will be reported. // In relaxed mode, failures call T.Fail allowing // multiple failures per test.
[ "NewRelaxed", "makes", "a", "new", "testing", "helper", "using", "the", "specified", "T", "through", "which", "failures", "will", "be", "reported", ".", "In", "relaxed", "mode", "failures", "call", "T", ".", "Fail", "allowing", "multiple", "failures", "per", ...
2eb2c933a79e268369b74caa16ac7f4b84bba0ab
https://github.com/matryer/is/blob/2eb2c933a79e268369b74caa16ac7f4b84bba0ab/is.go#L92-L94
20,432
matryer/is
is.go
loadComment
func loadComment(path string, line int) (string, bool) { f, err := os.Open(path) if err != nil { return "", false } defer f.Close() s := bufio.NewScanner(f) i := 1 for s.Scan() { if i == line { text := s.Text() commentI := strings.Index(text, "//") if commentI == -1 { return "", false // no comm...
go
func loadComment(path string, line int) (string, bool) { f, err := os.Open(path) if err != nil { return "", false } defer f.Close() s := bufio.NewScanner(f) i := 1 for s.Scan() { if i == line { text := s.Text() commentI := strings.Index(text, "//") if commentI == -1 { return "", false // no comm...
[ "func", "loadComment", "(", "path", "string", ",", "line", "int", ")", "(", "string", ",", "bool", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "false", "\...
// loadComment gets the Go comment from the specified line // in the specified file.
[ "loadComment", "gets", "the", "Go", "comment", "from", "the", "specified", "line", "in", "the", "specified", "file", "." ]
2eb2c933a79e268369b74caa16ac7f4b84bba0ab
https://github.com/matryer/is/blob/2eb2c933a79e268369b74caa16ac7f4b84bba0ab/is.go#L272-L294
20,433
matryer/is
is.go
loadArguments
func loadArguments(path string, line int) (string, bool) { f, err := os.Open(path) if err != nil { return "", false } defer f.Close() s := bufio.NewScanner(f) i := 1 for s.Scan() { if i == line { text := s.Text() braceI := strings.Index(text, "(") if braceI == -1 { return "", false } text ...
go
func loadArguments(path string, line int) (string, bool) { f, err := os.Open(path) if err != nil { return "", false } defer f.Close() s := bufio.NewScanner(f) i := 1 for s.Scan() { if i == line { text := s.Text() braceI := strings.Index(text, "(") if braceI == -1 { return "", false } text ...
[ "func", "loadArguments", "(", "path", "string", ",", "line", "int", ")", "(", "string", ",", "bool", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "false", ...
// loadArguments gets the arguments from the function call // on the specified line of the file.
[ "loadArguments", "gets", "the", "arguments", "from", "the", "function", "call", "on", "the", "specified", "line", "of", "the", "file", "." ]
2eb2c933a79e268369b74caa16ac7f4b84bba0ab
https://github.com/matryer/is/blob/2eb2c933a79e268369b74caa16ac7f4b84bba0ab/is.go#L298-L336
20,434
matryer/is
is.go
decorate
func (is *I) decorate(s string) string { path, lineNumber, ok := callerinfo() // decorate + log + public function. file := filepath.Base(path) if ok { // Truncate file name at last file name separator. if index := strings.LastIndex(file, "/"); index >= 0 { file = file[index+1:] } else if index = strings.Las...
go
func (is *I) decorate(s string) string { path, lineNumber, ok := callerinfo() // decorate + log + public function. file := filepath.Base(path) if ok { // Truncate file name at last file name separator. if index := strings.LastIndex(file, "/"); index >= 0 { file = file[index+1:] } else if index = strings.Las...
[ "func", "(", "is", "*", "I", ")", "decorate", "(", "s", "string", ")", "string", "{", "path", ",", "lineNumber", ",", "ok", ":=", "callerinfo", "(", ")", "// decorate + log + public function.", "\n", "file", ":=", "filepath", ".", "Base", "(", "path", ")...
// decorate prefixes the string with the file and line of the call site // and inserts the final newline if needed and indentation tabs for formatting. // this function was copied from the testing framework and modified.
[ "decorate", "prefixes", "the", "string", "with", "the", "file", "and", "line", "of", "the", "call", "site", "and", "inserts", "the", "final", "newline", "if", "needed", "and", "indentation", "tabs", "for", "formatting", ".", "this", "function", "was", "copie...
2eb2c933a79e268369b74caa16ac7f4b84bba0ab
https://github.com/matryer/is/blob/2eb2c933a79e268369b74caa16ac7f4b84bba0ab/is.go#L341-L394
20,435
araddon/qlbridge
lex/dialect_sql.go
LexEndOfSubStatement
func LexEndOfSubStatement(l *Lexer) StateFn { l.SkipWhiteSpaces() if strings.ToLower(l.PeekX(2)) == "as" { return nil } l.backup() return l.errorToken("Unexpected token:" + l.current()) }
go
func LexEndOfSubStatement(l *Lexer) StateFn { l.SkipWhiteSpaces() if strings.ToLower(l.PeekX(2)) == "as" { return nil } l.backup() return l.errorToken("Unexpected token:" + l.current()) }
[ "func", "LexEndOfSubStatement", "(", "l", "*", "Lexer", ")", "StateFn", "{", "l", ".", "SkipWhiteSpaces", "(", ")", "\n", "if", "strings", ".", "ToLower", "(", "l", ".", "PeekX", "(", "2", ")", ")", "==", "\"", "\"", "{", "return", "nil", "\n", "}"...
// LexEndOfSubStatement Look for end of statement defined by either // a semicolon or end of file.
[ "LexEndOfSubStatement", "Look", "for", "end", "of", "statement", "defined", "by", "either", "a", "semicolon", "or", "end", "of", "file", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/lex/dialect_sql.go#L238-L245
20,436
araddon/qlbridge
lex/dialect_sql.go
LexLimit
func LexLimit(l *Lexer) StateFn { l.SkipWhiteSpaces() keyWord := strings.ToLower(l.PeekWord()) //u.Debugf("LexLimit r= '%v'", string(keyWord)) switch keyWord { case "offset": return nil case "", ";": return nil case ",": l.ConsumeWord(keyWord) l.Emit(TokenComma) return LexNumber default: if isDig...
go
func LexLimit(l *Lexer) StateFn { l.SkipWhiteSpaces() keyWord := strings.ToLower(l.PeekWord()) //u.Debugf("LexLimit r= '%v'", string(keyWord)) switch keyWord { case "offset": return nil case "", ";": return nil case ",": l.ConsumeWord(keyWord) l.Emit(TokenComma) return LexNumber default: if isDig...
[ "func", "LexLimit", "(", "l", "*", "Lexer", ")", "StateFn", "{", "l", ".", "SkipWhiteSpaces", "(", ")", "\n", "keyWord", ":=", "strings", ".", "ToLower", "(", "l", ".", "PeekWord", "(", ")", ")", "\n", "//u.Debugf(\"LexLimit r= '%v'\", string(keyWord))", "s...
// LexLimit clause // // LIMIT 1000 OFFSET 100 // LIMIT 0, 1000 // LIMIT 1000
[ "LexLimit", "clause", "LIMIT", "1000", "OFFSET", "100", "LIMIT", "0", "1000", "LIMIT", "1000" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/lex/dialect_sql.go#L366-L388
20,437
araddon/qlbridge
lex/dialect_sql.go
LexDdlTable
func LexDdlTable(l *Lexer) StateFn { /* CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name (create_definition,...) [table_options] [partition_options] CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)] [table_options] [partition_options] [IGNORE |...
go
func LexDdlTable(l *Lexer) StateFn { /* CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name (create_definition,...) [table_options] [partition_options] CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)] [table_options] [partition_options] [IGNORE |...
[ "func", "LexDdlTable", "(", "l", "*", "Lexer", ")", "StateFn", "{", "/*\n\t\tCREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n\t\t (create_definition,...)\n\t\t [table_options]\n\t\t [partition_options]\n\n\t\tCREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n\t\t [(create_definitio...
// LexDdlTable data definition language table
[ "LexDdlTable", "data", "definition", "language", "table" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/lex/dialect_sql.go#L556-L634
20,438
araddon/qlbridge
datasource/sqlite/source.go
Setup
func (m *Source) Setup(s *schema.Schema) error { m.mu.Lock() defer m.mu.Unlock() u.Debugf("got new sqlite schema %s", s.Name) m.schema = s if m.db != nil { return nil } m.file = s.Conf.Settings.String("file") if m.file == "" { m.file = fmt.Sprintf("/tmp/%s.sql.db", s.Name) u.Warnf("using tmp? %q", m.fil...
go
func (m *Source) Setup(s *schema.Schema) error { m.mu.Lock() defer m.mu.Unlock() u.Debugf("got new sqlite schema %s", s.Name) m.schema = s if m.db != nil { return nil } m.file = s.Conf.Settings.String("file") if m.file == "" { m.file = fmt.Sprintf("/tmp/%s.sql.db", s.Name) u.Warnf("using tmp? %q", m.fil...
[ "func", "(", "m", "*", "Source", ")", "Setup", "(", "s", "*", "schema", ".", "Schema", ")", "error", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "u", ".", "Debugf", "(", "\"", ...
// Setup this source with schema from parent.
[ "Setup", "this", "source", "with", "schema", "from", "parent", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/datasource/sqlite/source.go#L62-L113
20,439
araddon/qlbridge
datasource/sqlite/source.go
Open
func (m *Source) Open(table string) (schema.Conn, error) { //u.Infof("Open conn=%q", table) m.tblmu.Lock() t, ok := m.tables[table] m.tblmu.Unlock() if !ok { return nil, schema.ErrNotFound } m.mu.Lock() //u.Infof("after open lock") qc := newQueryConn(t, m) m.qryconns[table] = qc return qc, nil }
go
func (m *Source) Open(table string) (schema.Conn, error) { //u.Infof("Open conn=%q", table) m.tblmu.Lock() t, ok := m.tables[table] m.tblmu.Unlock() if !ok { return nil, schema.ErrNotFound } m.mu.Lock() //u.Infof("after open lock") qc := newQueryConn(t, m) m.qryconns[table] = qc return qc, nil }
[ "func", "(", "m", "*", "Source", ")", "Open", "(", "table", "string", ")", "(", "schema", ".", "Conn", ",", "error", ")", "{", "//u.Infof(\"Open conn=%q\", table)", "m", ".", "tblmu", ".", "Lock", "(", ")", "\n", "t", ",", "ok", ":=", "m", ".", "ta...
// Open a connection, since sqlite is not threadsafe, this is locked.
[ "Open", "a", "connection", "since", "sqlite", "is", "not", "threadsafe", "this", "is", "locked", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/datasource/sqlite/source.go#L119-L132
20,440
araddon/qlbridge
datasource/sqlite/source.go
Table
func (m *Source) Table(table string) (*schema.Table, error) { u.Infof("source.Table(%q)", table) m.tblmu.Lock() t, ok := m.tables[table] m.tblmu.Unlock() if !ok { return nil, schema.ErrNotFound } return t, nil }
go
func (m *Source) Table(table string) (*schema.Table, error) { u.Infof("source.Table(%q)", table) m.tblmu.Lock() t, ok := m.tables[table] m.tblmu.Unlock() if !ok { return nil, schema.ErrNotFound } return t, nil }
[ "func", "(", "m", "*", "Source", ")", "Table", "(", "table", "string", ")", "(", "*", "schema", ".", "Table", ",", "error", ")", "{", "u", ".", "Infof", "(", "\"", "\"", ",", "table", ")", "\n", "m", ".", "tblmu", ".", "Lock", "(", ")", "\n",...
// Table gets table schema for given table
[ "Table", "gets", "table", "schema", "for", "given", "table" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/datasource/sqlite/source.go#L135-L144
20,441
araddon/qlbridge
datasource/sqlite/source.go
Close
func (m *Source) Close() error { if m.db != nil { err := m.db.Close() if err != nil { return err } m.db = nil } return nil }
go
func (m *Source) Close() error { if m.db != nil { err := m.db.Close() if err != nil { return err } m.db = nil } return nil }
[ "func", "(", "m", "*", "Source", ")", "Close", "(", ")", "error", "{", "if", "m", ".", "db", "!=", "nil", "{", "err", ":=", "m", ".", "db", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "m", ...
// Close this source, closing the underlying sqlite db file
[ "Close", "this", "source", "closing", "the", "underlying", "sqlite", "db", "file" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/datasource/sqlite/source.go#L150-L159
20,442
araddon/qlbridge
vm/vm.go
errRecover
func errRecover(errp *error) { e := recover() if e != nil { switch err := e.(type) { case runtime.Error: panic(e) case error: *errp = err default: panic(e) } } }
go
func errRecover(errp *error) { e := recover() if e != nil { switch err := e.(type) { case runtime.Error: panic(e) case error: *errp = err default: panic(e) } } }
[ "func", "errRecover", "(", "errp", "*", "error", ")", "{", "e", ":=", "recover", "(", ")", "\n", "if", "e", "!=", "nil", "{", "switch", "err", ":=", "e", ".", "(", "type", ")", "{", "case", "runtime", ".", "Error", ":", "panic", "(", "e", ")", ...
// errRecover is the handler that turns panics into returns from the top
[ "errRecover", "is", "the", "handler", "that", "turns", "panics", "into", "returns", "from", "the", "top" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/vm/vm.go#L48-L60
20,443
araddon/qlbridge
vm/vm.go
numberNodeToValue
func numberNodeToValue(t *expr.NumberNode) (value.Value, bool) { if t.IsInt { return value.NewIntValue(t.Int64), true } else if t.IsFloat { fv, ok := value.StringToFloat64(t.Text) if !ok { u.Debugf("Could not perform numeric conversion for %q", t.Text) return value.NilValueVal, false } return value.Ne...
go
func numberNodeToValue(t *expr.NumberNode) (value.Value, bool) { if t.IsInt { return value.NewIntValue(t.Int64), true } else if t.IsFloat { fv, ok := value.StringToFloat64(t.Text) if !ok { u.Debugf("Could not perform numeric conversion for %q", t.Text) return value.NilValueVal, false } return value.Ne...
[ "func", "numberNodeToValue", "(", "t", "*", "expr", ".", "NumberNode", ")", "(", "value", ".", "Value", ",", "bool", ")", "{", "if", "t", ".", "IsInt", "{", "return", "value", ".", "NewIntValue", "(", "t", ".", "Int64", ")", ",", "true", "\n", "}",...
// creates a new Value with a nil group and given value.
[ "creates", "a", "new", "Value", "with", "a", "nil", "group", "and", "given", "value", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/vm/vm.go#L63-L76
20,444
araddon/qlbridge
vm/vm.go
ResolveIncludes
func ResolveIncludes(ctx expr.Includer, arg expr.Node) error { return resolveIncludesDepth(ctx, arg, 0) }
go
func ResolveIncludes(ctx expr.Includer, arg expr.Node) error { return resolveIncludesDepth(ctx, arg, 0) }
[ "func", "ResolveIncludes", "(", "ctx", "expr", ".", "Includer", ",", "arg", "expr", ".", "Node", ")", "error", "{", "return", "resolveIncludesDepth", "(", "ctx", ",", "arg", ",", "0", ")", "\n", "}" ]
// ResolveIncludes take an expression and resolve any includes so that // it does not have to be resolved at runtime. There is also a // InlineIncludes alternative in expr pkg which actually re-writes the expression // to remove includes and embed the expressions they refer to as part of this expression.
[ "ResolveIncludes", "take", "an", "expression", "and", "resolve", "any", "includes", "so", "that", "it", "does", "not", "have", "to", "be", "resolved", "at", "runtime", ".", "There", "is", "also", "a", "InlineIncludes", "alternative", "in", "expr", "pkg", "wh...
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/vm/vm.go#L82-L84
20,445
araddon/qlbridge
vm/vm.go
walkTernary
func walkTernary(ctx expr.EvalContext, node *expr.TriNode, depth int) (value.Value, bool) { a, aok := Eval(ctx, node.Args[0]) b, bok := Eval(ctx, node.Args[1]) c, cok := Eval(ctx, node.Args[2]) //u.Infof("tri: %T:%v %v %T:%v %T:%v", a, a, node.Operator, b, b, c, c) if !aok { return nil, false } if !bok |...
go
func walkTernary(ctx expr.EvalContext, node *expr.TriNode, depth int) (value.Value, bool) { a, aok := Eval(ctx, node.Args[0]) b, bok := Eval(ctx, node.Args[1]) c, cok := Eval(ctx, node.Args[2]) //u.Infof("tri: %T:%v %v %T:%v %T:%v", a, a, node.Operator, b, b, c, c) if !aok { return nil, false } if !bok |...
[ "func", "walkTernary", "(", "ctx", "expr", ".", "EvalContext", ",", "node", "*", "expr", ".", "TriNode", ",", "depth", "int", ")", "(", "value", ".", "Value", ",", "bool", ")", "{", "a", ",", "aok", ":=", "Eval", "(", "ctx", ",", "node", ".", "Ar...
// walkTernary ternary evaluator // // A BETWEEN B AND C //
[ "walkTernary", "ternary", "evaluator", "A", "BETWEEN", "B", "AND", "C" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/vm/vm.go#L893-L969
20,446
araddon/qlbridge
vm/vm.go
walkFunc
func walkFunc(ctx expr.EvalContext, node *expr.FuncNode, depth int) (value.Value, bool) { if node.F.CustomFunc == nil { return nil, false } if node.Eval == nil { u.LogThrottle(u.WARN, 10, "No Eval() for %s", node.Name) return nil, false } args := make([]value.Value, len(node.Args)) for i, a := range node...
go
func walkFunc(ctx expr.EvalContext, node *expr.FuncNode, depth int) (value.Value, bool) { if node.F.CustomFunc == nil { return nil, false } if node.Eval == nil { u.LogThrottle(u.WARN, 10, "No Eval() for %s", node.Name) return nil, false } args := make([]value.Value, len(node.Args)) for i, a := range node...
[ "func", "walkFunc", "(", "ctx", "expr", ".", "EvalContext", ",", "node", "*", "expr", ".", "FuncNode", ",", "depth", "int", ")", "(", "value", ".", "Value", ",", "bool", ")", "{", "if", "node", ".", "F", ".", "CustomFunc", "==", "nil", "{", "return...
// walkFunc evaluates a function
[ "walkFunc", "evaluates", "a", "function" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/vm/vm.go#L989-L1009
20,447
araddon/qlbridge
vm/vm.go
LikeCompare
func LikeCompare(a, b string) (value.BoolValue, bool) { // Do we want to always do this replacement? Or do this at parse time or config? if strings.Contains(b, "%") { b = strings.Replace(b, "%", "*", -1) } match, err := glob.Match(b, a) if err != nil { return value.BoolValueFalse, false } if match { retu...
go
func LikeCompare(a, b string) (value.BoolValue, bool) { // Do we want to always do this replacement? Or do this at parse time or config? if strings.Contains(b, "%") { b = strings.Replace(b, "%", "*", -1) } match, err := glob.Match(b, a) if err != nil { return value.BoolValueFalse, false } if match { retu...
[ "func", "LikeCompare", "(", "a", ",", "b", "string", ")", "(", "value", ".", "BoolValue", ",", "bool", ")", "{", "// Do we want to always do this replacement? Or do this at parse time or config?", "if", "strings", ".", "Contains", "(", "b", ",", "\"", "\"", ")",...
// LikeCompare takes two strings and evaluates them for like equality
[ "LikeCompare", "takes", "two", "strings", "and", "evaluates", "them", "for", "like", "equality" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/vm/vm.go#L1172-L1185
20,448
araddon/qlbridge
datasource/datatypes.go
UnmarshalJSON
func (m *JsonHelperScannable) UnmarshalJSON(data []byte) error { if m == nil { return errors.New("JsonHelperScannable must not be nil") } jh := make(u.JsonHelper) if err := json.Unmarshal(data, &jh); err != nil { return err } *m = JsonHelperScannable(jh) return nil }
go
func (m *JsonHelperScannable) UnmarshalJSON(data []byte) error { if m == nil { return errors.New("JsonHelperScannable must not be nil") } jh := make(u.JsonHelper) if err := json.Unmarshal(data, &jh); err != nil { return err } *m = JsonHelperScannable(jh) return nil }
[ "func", "(", "m", "*", "JsonHelperScannable", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "jh", ":=", "make", "(", "u"...
// UnmarshalJSON bytes into this typed struct
[ "UnmarshalJSON", "bytes", "into", "this", "typed", "struct" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/datasource/datatypes.go#L139-L149
20,449
araddon/qlbridge
datasource/datatypes.go
Value
func (m StringArray) Value() (driver.Value, error) { by, err := json.Marshal(m) return by, err }
go
func (m StringArray) Value() (driver.Value, error) { by, err := json.Marshal(m) return by, err }
[ "func", "(", "m", "StringArray", ")", "Value", "(", ")", "(", "driver", ".", "Value", ",", "error", ")", "{", "by", ",", "err", ":=", "json", ".", "Marshal", "(", "m", ")", "\n", "return", "by", ",", "err", "\n", "}" ]
// Value convert string to json values
[ "Value", "convert", "string", "to", "json", "values" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/datasource/datatypes.go#L199-L202
20,450
araddon/qlbridge
expr/include.go
InlineIncludes
func InlineIncludes(ctx Includer, n Node) (Node, error) { return doInlineIncludes(ctx, n, 0) }
go
func InlineIncludes(ctx Includer, n Node) (Node, error) { return doInlineIncludes(ctx, n, 0) }
[ "func", "InlineIncludes", "(", "ctx", "Includer", ",", "n", "Node", ")", "(", "Node", ",", "error", ")", "{", "return", "doInlineIncludes", "(", "ctx", ",", "n", ",", "0", ")", "\n", "}" ]
// InlineIncludes take an expression and resolve any includes so that // the included expression is "Inline"
[ "InlineIncludes", "take", "an", "expression", "and", "resolve", "any", "includes", "so", "that", "the", "included", "expression", "is", "Inline" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/expr/include.go#L25-L27
20,451
araddon/qlbridge
plan/plan.go
WalkStmt
func WalkStmt(ctx *Context, stmt rel.SqlStatement, planner Planner) (Task, error) { var p Task base := NewPlanBase(false) switch st := stmt.(type) { case *rel.SqlSelect: p = &Select{Stmt: st, PlanBase: base, Ctx: ctx} case *rel.SqlInsert: p = &Insert{Stmt: st, PlanBase: base} case *rel.SqlUpsert: p = &Upser...
go
func WalkStmt(ctx *Context, stmt rel.SqlStatement, planner Planner) (Task, error) { var p Task base := NewPlanBase(false) switch st := stmt.(type) { case *rel.SqlSelect: p = &Select{Stmt: st, PlanBase: base, Ctx: ctx} case *rel.SqlInsert: p = &Insert{Stmt: st, PlanBase: base} case *rel.SqlUpsert: p = &Upser...
[ "func", "WalkStmt", "(", "ctx", "*", "Context", ",", "stmt", "rel", ".", "SqlStatement", ",", "planner", "Planner", ")", "(", "Task", ",", "error", ")", "{", "var", "p", "Task", "\n", "base", ":=", "NewPlanBase", "(", "false", ")", "\n", "switch", "s...
// WalkStmt Walk given statement for given Planner to produce a query plan // which is a plan.Task and children, ie a DAG of tasks
[ "WalkStmt", "Walk", "given", "statement", "for", "given", "Planner", "to", "produce", "a", "query", "plan", "which", "is", "a", "plan", ".", "Task", "and", "children", "ie", "a", "DAG", "of", "tasks" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L272-L314
20,452
araddon/qlbridge
plan/plan.go
SelectPlanFromPbBytes
func SelectPlanFromPbBytes(pb []byte, loader SchemaLoader) (*Select, error) { p := &PlanPb{} if err := proto.Unmarshal(pb, p); err != nil { u.Errorf("error reading protobuf select: %v \n%s", err, pb) return nil, err } switch { case p.Select != nil: return SelectFromPB(p, loader) } return nil, ErrNotImplem...
go
func SelectPlanFromPbBytes(pb []byte, loader SchemaLoader) (*Select, error) { p := &PlanPb{} if err := proto.Unmarshal(pb, p); err != nil { u.Errorf("error reading protobuf select: %v \n%s", err, pb) return nil, err } switch { case p.Select != nil: return SelectFromPB(p, loader) } return nil, ErrNotImplem...
[ "func", "SelectPlanFromPbBytes", "(", "pb", "[", "]", "byte", ",", "loader", "SchemaLoader", ")", "(", "*", "Select", ",", "error", ")", "{", "p", ":=", "&", "PlanPb", "{", "}", "\n", "if", "err", ":=", "proto", ".", "Unmarshal", "(", "pb", ",", "p...
// SelectPlanFromPbBytes Create a sql plan from pb.
[ "SelectPlanFromPbBytes", "Create", "a", "sql", "plan", "from", "pb", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L317-L328
20,453
araddon/qlbridge
plan/plan.go
SelectTaskFromTaskPb
func SelectTaskFromTaskPb(pb *PlanPb, ctx *Context, sel *rel.SqlSelect) (Task, error) { switch { case pb.Source != nil: return SourceFromPB(pb, ctx) case pb.Where != nil: return WhereFromPB(pb), nil case pb.Having != nil: return HavingFromPB(pb), nil case pb.GroupBy != nil: return GroupByFromPB(pb), nil c...
go
func SelectTaskFromTaskPb(pb *PlanPb, ctx *Context, sel *rel.SqlSelect) (Task, error) { switch { case pb.Source != nil: return SourceFromPB(pb, ctx) case pb.Where != nil: return WhereFromPB(pb), nil case pb.Having != nil: return HavingFromPB(pb), nil case pb.GroupBy != nil: return GroupByFromPB(pb), nil c...
[ "func", "SelectTaskFromTaskPb", "(", "pb", "*", "PlanPb", ",", "ctx", "*", "Context", ",", "sel", "*", "rel", ".", "SqlSelect", ")", "(", "Task", ",", "error", ")", "{", "switch", "{", "case", "pb", ".", "Source", "!=", "nil", ":", "return", "SourceF...
// SelectTaskFromTaskPb create plan task for SqlSelect from pb.
[ "SelectTaskFromTaskPb", "create", "plan", "task", "for", "SqlSelect", "from", "pb", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L331-L353
20,454
araddon/qlbridge
plan/plan.go
NewCreate
func NewCreate(ctx *Context, stmt *rel.SqlCreate) *Create { return &Create{Stmt: stmt, PlanBase: NewPlanBase(false), Ctx: ctx} }
go
func NewCreate(ctx *Context, stmt *rel.SqlCreate) *Create { return &Create{Stmt: stmt, PlanBase: NewPlanBase(false), Ctx: ctx} }
[ "func", "NewCreate", "(", "ctx", "*", "Context", ",", "stmt", "*", "rel", ".", "SqlCreate", ")", "*", "Create", "{", "return", "&", "Create", "{", "Stmt", ":", "stmt", ",", "PlanBase", ":", "NewPlanBase", "(", "false", ")", ",", "Ctx", ":", "ctx", ...
// NewCreate creates a new Create Task plan.
[ "NewCreate", "creates", "a", "new", "Create", "Task", "plan", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L418-L420
20,455
araddon/qlbridge
plan/plan.go
NewDrop
func NewDrop(ctx *Context, stmt *rel.SqlDrop) *Drop { return &Drop{Stmt: stmt, PlanBase: NewPlanBase(false), Ctx: ctx} }
go
func NewDrop(ctx *Context, stmt *rel.SqlDrop) *Drop { return &Drop{Stmt: stmt, PlanBase: NewPlanBase(false), Ctx: ctx} }
[ "func", "NewDrop", "(", "ctx", "*", "Context", ",", "stmt", "*", "rel", ".", "SqlDrop", ")", "*", "Drop", "{", "return", "&", "Drop", "{", "Stmt", ":", "stmt", ",", "PlanBase", ":", "NewPlanBase", "(", "false", ")", ",", "Ctx", ":", "ctx", "}", "...
// NewDrop create Drop plan task.
[ "NewDrop", "create", "Drop", "plan", "task", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L423-L425
20,456
araddon/qlbridge
plan/plan.go
NewAlter
func NewAlter(ctx *Context, stmt *rel.SqlAlter) *Alter { return &Alter{Stmt: stmt, PlanBase: NewPlanBase(false), Ctx: ctx} }
go
func NewAlter(ctx *Context, stmt *rel.SqlAlter) *Alter { return &Alter{Stmt: stmt, PlanBase: NewPlanBase(false), Ctx: ctx} }
[ "func", "NewAlter", "(", "ctx", "*", "Context", ",", "stmt", "*", "rel", ".", "SqlAlter", ")", "*", "Alter", "{", "return", "&", "Alter", "{", "Stmt", ":", "stmt", ",", "PlanBase", ":", "NewPlanBase", "(", "false", ")", ",", "Ctx", ":", "ctx", "}",...
// NewAlter create Alter plan task.
[ "NewAlter", "create", "Alter", "plan", "task", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L428-L430
20,457
araddon/qlbridge
plan/plan.go
NewSource
func NewSource(ctx *Context, stmt *rel.SqlSource, isFinal bool) (*Source, error) { s := &Source{Stmt: stmt, ctx: ctx, SourcePb: &SourcePb{Final: isFinal}, PlanBase: NewPlanBase(false)} err := s.load() if err != nil { return nil, err } return s, nil }
go
func NewSource(ctx *Context, stmt *rel.SqlSource, isFinal bool) (*Source, error) { s := &Source{Stmt: stmt, ctx: ctx, SourcePb: &SourcePb{Final: isFinal}, PlanBase: NewPlanBase(false)} err := s.load() if err != nil { return nil, err } return s, nil }
[ "func", "NewSource", "(", "ctx", "*", "Context", ",", "stmt", "*", "rel", ".", "SqlSource", ",", "isFinal", "bool", ")", "(", "*", "Source", ",", "error", ")", "{", "s", ":=", "&", "Source", "{", "Stmt", ":", "stmt", ",", "ctx", ":", "ctx", ",", ...
// NewSource create a new plan Task for data source
[ "NewSource", "create", "a", "new", "plan", "Task", "for", "data", "source" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L625-L632
20,458
araddon/qlbridge
plan/plan.go
Equal
func (m *Projection) Equal(t Task) bool { if m == nil && t == nil { return true } if m == nil && t != nil { return false } if m != nil && t == nil { return false } s, ok := t.(*Projection) if !ok { return false } if m.Final != s.Final { return false } if !m.Proj.Equal(s.Proj) { return false } ...
go
func (m *Projection) Equal(t Task) bool { if m == nil && t == nil { return true } if m == nil && t != nil { return false } if m != nil && t == nil { return false } s, ok := t.(*Projection) if !ok { return false } if m.Final != s.Final { return false } if !m.Proj.Equal(s.Proj) { return false } ...
[ "func", "(", "m", "*", "Projection", ")", "Equal", "(", "t", "Task", ")", "bool", "{", "if", "m", "==", "nil", "&&", "t", "==", "nil", "{", "return", "true", "\n", "}", "\n", "if", "m", "==", "nil", "&&", "t", "!=", "nil", "{", "return", "fal...
// Equal checks if two tasks are equal.
[ "Equal", "checks", "if", "two", "tasks", "are", "equal", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L792-L816
20,459
araddon/qlbridge
plan/plan.go
ToPb
func (m *Projection) ToPb() (*PlanPb, error) { pbp, err := m.PlanBase.ToPb() if err != nil { return nil, err } ppbptr := m.Proj.ToPB() ppcpy := *ppbptr ppcpy.Final = m.Final pbp.Projection = &ppcpy return pbp, nil }
go
func (m *Projection) ToPb() (*PlanPb, error) { pbp, err := m.PlanBase.ToPb() if err != nil { return nil, err } ppbptr := m.Proj.ToPB() ppcpy := *ppbptr ppcpy.Final = m.Final pbp.Projection = &ppcpy return pbp, nil }
[ "func", "(", "m", "*", "Projection", ")", "ToPb", "(", ")", "(", "*", "PlanPb", ",", "error", ")", "{", "pbp", ",", "err", ":=", "m", ".", "PlanBase", ".", "ToPb", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\...
// ToPb to protobuf.
[ "ToPb", "to", "protobuf", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L819-L829
20,460
araddon/qlbridge
plan/plan.go
ProjectionFromPB
func ProjectionFromPB(pb *PlanPb, sel *rel.SqlSelect) *Projection { m := Projection{ Proj: rel.ProjectionFromPb(pb.Projection), } m.Final = pb.Projection.Final m.PlanBase = NewPlanBase(pb.Parallel) m.Stmt = sel return &m }
go
func ProjectionFromPB(pb *PlanPb, sel *rel.SqlSelect) *Projection { m := Projection{ Proj: rel.ProjectionFromPb(pb.Projection), } m.Final = pb.Projection.Final m.PlanBase = NewPlanBase(pb.Parallel) m.Stmt = sel return &m }
[ "func", "ProjectionFromPB", "(", "pb", "*", "PlanPb", ",", "sel", "*", "rel", ".", "SqlSelect", ")", "*", "Projection", "{", "m", ":=", "Projection", "{", "Proj", ":", "rel", ".", "ProjectionFromPb", "(", "pb", ".", "Projection", ")", ",", "}", "\n", ...
// ProjectionFromPB create Projection from Protobuf.
[ "ProjectionFromPB", "create", "Projection", "from", "Protobuf", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L832-L840
20,461
araddon/qlbridge
plan/plan.go
NewJoinKey
func NewJoinKey(s *Source) *JoinKey { return &JoinKey{Source: s, PlanBase: NewPlanBase(false)} }
go
func NewJoinKey(s *Source) *JoinKey { return &JoinKey{Source: s, PlanBase: NewPlanBase(false)} }
[ "func", "NewJoinKey", "(", "s", "*", "Source", ")", "*", "JoinKey", "{", "return", "&", "JoinKey", "{", "Source", ":", "s", ",", "PlanBase", ":", "NewPlanBase", "(", "false", ")", "}", "\n", "}" ]
// NewJoinKey creates JoinKey from Source.
[ "NewJoinKey", "creates", "JoinKey", "from", "Source", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L880-L882
20,462
araddon/qlbridge
plan/plan.go
NewWhere
func NewWhere(stmt *rel.SqlSelect) *Where { return &Where{Stmt: stmt, PlanBase: NewPlanBase(false)} }
go
func NewWhere(stmt *rel.SqlSelect) *Where { return &Where{Stmt: stmt, PlanBase: NewPlanBase(false)} }
[ "func", "NewWhere", "(", "stmt", "*", "rel", ".", "SqlSelect", ")", "*", "Where", "{", "return", "&", "Where", "{", "Stmt", ":", "stmt", ",", "PlanBase", ":", "NewPlanBase", "(", "false", ")", "}", "\n", "}" ]
// NewWhere new Where Task from SqlSelect statement.
[ "NewWhere", "new", "Where", "Task", "from", "SqlSelect", "statement", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L885-L887
20,463
araddon/qlbridge
plan/plan.go
NewWhereFinal
func NewWhereFinal(stmt *rel.SqlSelect) *Where { return &Where{Stmt: stmt, Final: true, PlanBase: NewPlanBase(false)} }
go
func NewWhereFinal(stmt *rel.SqlSelect) *Where { return &Where{Stmt: stmt, Final: true, PlanBase: NewPlanBase(false)} }
[ "func", "NewWhereFinal", "(", "stmt", "*", "rel", ".", "SqlSelect", ")", "*", "Where", "{", "return", "&", "Where", "{", "Stmt", ":", "stmt", ",", "Final", ":", "true", ",", "PlanBase", ":", "NewPlanBase", "(", "false", ")", "}", "\n", "}" ]
// NewWhereFinal from SqlSelect statement.
[ "NewWhereFinal", "from", "SqlSelect", "statement", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L890-L892
20,464
araddon/qlbridge
plan/plan.go
NewHaving
func NewHaving(stmt *rel.SqlSelect) *Having { return &Having{Stmt: stmt, PlanBase: NewPlanBase(false)} }
go
func NewHaving(stmt *rel.SqlSelect) *Having { return &Having{Stmt: stmt, PlanBase: NewPlanBase(false)} }
[ "func", "NewHaving", "(", "stmt", "*", "rel", ".", "SqlSelect", ")", "*", "Having", "{", "return", "&", "Having", "{", "Stmt", ":", "stmt", ",", "PlanBase", ":", "NewPlanBase", "(", "false", ")", "}", "\n", "}" ]
// NewHaving from SqlSelect statement.
[ "NewHaving", "from", "SqlSelect", "statement", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L895-L897
20,465
araddon/qlbridge
plan/plan.go
NewGroupBy
func NewGroupBy(stmt *rel.SqlSelect) *GroupBy { return &GroupBy{Stmt: stmt, PlanBase: NewPlanBase(false)} }
go
func NewGroupBy(stmt *rel.SqlSelect) *GroupBy { return &GroupBy{Stmt: stmt, PlanBase: NewPlanBase(false)} }
[ "func", "NewGroupBy", "(", "stmt", "*", "rel", ".", "SqlSelect", ")", "*", "GroupBy", "{", "return", "&", "GroupBy", "{", "Stmt", ":", "stmt", ",", "PlanBase", ":", "NewPlanBase", "(", "false", ")", "}", "\n", "}" ]
// NewGroupBy from SqlSelect statement.
[ "NewGroupBy", "from", "SqlSelect", "statement", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L900-L902
20,466
araddon/qlbridge
plan/plan.go
NewOrder
func NewOrder(stmt *rel.SqlSelect) *Order { return &Order{Stmt: stmt, PlanBase: NewPlanBase(false)} }
go
func NewOrder(stmt *rel.SqlSelect) *Order { return &Order{Stmt: stmt, PlanBase: NewPlanBase(false)} }
[ "func", "NewOrder", "(", "stmt", "*", "rel", ".", "SqlSelect", ")", "*", "Order", "{", "return", "&", "Order", "{", "Stmt", ":", "stmt", ",", "PlanBase", ":", "NewPlanBase", "(", "false", ")", "}", "\n", "}" ]
// NewOrder from SqlSelect statement.
[ "NewOrder", "from", "SqlSelect", "statement", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L905-L907
20,467
araddon/qlbridge
plan/plan.go
Equal
func (m *Into) Equal(t Task) bool { if m == nil && t == nil { return true } if m == nil && t != nil { return false } if m != nil && t == nil { return false } s, ok := t.(*Into) if !ok { return false } if !m.PlanBase.EqualBase(s.PlanBase) { return false } return true }
go
func (m *Into) Equal(t Task) bool { if m == nil && t == nil { return true } if m == nil && t != nil { return false } if m != nil && t == nil { return false } s, ok := t.(*Into) if !ok { return false } if !m.PlanBase.EqualBase(s.PlanBase) { return false } return true }
[ "func", "(", "m", "*", "Into", ")", "Equal", "(", "t", "Task", ")", "bool", "{", "if", "m", "==", "nil", "&&", "t", "==", "nil", "{", "return", "true", "\n", "}", "\n", "if", "m", "==", "nil", "&&", "t", "!=", "nil", "{", "return", "false", ...
// Equal compares equality of two tasks.
[ "Equal", "compares", "equality", "of", "two", "tasks", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/plan.go#L910-L929
20,468
araddon/qlbridge
datasource/sqlite/sqlrewrite.go
rewrite
func (m *rewrite) rewrite() (string, error) { var err error if m.sel.Where != nil { m.result.Where = m.sel.Where m.result.Where.Expr, err = m.walkNode(m.sel.Where.Expr) if err != nil { return "", err } } // Evaluate the Select columns make sure we can pass them down or polyfill err = m.walkSelectList...
go
func (m *rewrite) rewrite() (string, error) { var err error if m.sel.Where != nil { m.result.Where = m.sel.Where m.result.Where.Expr, err = m.walkNode(m.sel.Where.Expr) if err != nil { return "", err } } // Evaluate the Select columns make sure we can pass them down or polyfill err = m.walkSelectList...
[ "func", "(", "m", "*", "rewrite", ")", "rewrite", "(", ")", "(", "string", ",", "error", ")", "{", "var", "err", "error", "\n\n", "if", "m", ".", "sel", ".", "Where", "!=", "nil", "{", "m", ".", "result", ".", "Where", "=", "m", ".", "sel", "...
// WalkSourceSelect An interface implemented by this connection allowing the planner // to push down as much logic into mongo as possible
[ "WalkSourceSelect", "An", "interface", "implemented", "by", "this", "connection", "allowing", "the", "planner", "to", "push", "down", "as", "much", "logic", "into", "mongo", "as", "possible" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/datasource/sqlite/sqlrewrite.go#L32-L66
20,469
araddon/qlbridge
rel/sql_rewrite.go
RewriteSelect
func RewriteSelect(m *SqlSelect) { originalCols := m.Columns m.Columns = make(Columns, 0, len(originalCols)+5) rewriteIntoProjection(m, originalCols) rewriteIntoProjection(m, m.GroupBy) if m.Where != nil { colsToAdd := expr.FindAllIdentityField(m.Where.Expr) addIntoProjection(m, colsToAdd) } rewriteIntoProje...
go
func RewriteSelect(m *SqlSelect) { originalCols := m.Columns m.Columns = make(Columns, 0, len(originalCols)+5) rewriteIntoProjection(m, originalCols) rewriteIntoProjection(m, m.GroupBy) if m.Where != nil { colsToAdd := expr.FindAllIdentityField(m.Where.Expr) addIntoProjection(m, colsToAdd) } rewriteIntoProje...
[ "func", "RewriteSelect", "(", "m", "*", "SqlSelect", ")", "{", "originalCols", ":=", "m", ".", "Columns", "\n", "m", ".", "Columns", "=", "make", "(", "Columns", ",", "0", ",", "len", "(", "originalCols", ")", "+", "5", ")", "\n", "rewriteIntoProjectio...
// RewriteSelect We are removing Column Aliases "user_id as uid" // as well as functions - used when we are going to defer projection, aggs
[ "RewriteSelect", "We", "are", "removing", "Column", "Aliases", "user_id", "as", "uid", "as", "well", "as", "functions", "-", "used", "when", "we", "are", "going", "to", "defer", "projection", "aggs" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/rel/sql_rewrite.go#L13-L23
20,470
araddon/qlbridge
rel/sql_rewrite.go
RewriteSqlSource
func RewriteSqlSource(m *SqlSource, parentStmt *SqlSelect) *SqlSelect { if m.Source != nil { return m.Source } // Rewrite this SqlSource for the given parent, ie // 1) find the column names we need to request from source including those used in join/where // 2) rewrite the where for this partial query //...
go
func RewriteSqlSource(m *SqlSource, parentStmt *SqlSelect) *SqlSelect { if m.Source != nil { return m.Source } // Rewrite this SqlSource for the given parent, ie // 1) find the column names we need to request from source including those used in join/where // 2) rewrite the where for this partial query //...
[ "func", "RewriteSqlSource", "(", "m", "*", "SqlSource", ",", "parentStmt", "*", "SqlSelect", ")", "*", "SqlSelect", "{", "if", "m", ".", "Source", "!=", "nil", "{", "return", "m", ".", "Source", "\n", "}", "\n", "// Rewrite this SqlSource for the given parent,...
// RewriteSqlSource this Source to act as a stand-alone query to backend // @parentStmt = the parent statement that this a partial source to
[ "RewriteSqlSource", "this", "Source", "to", "act", "as", "a", "stand", "-", "alone", "query", "to", "backend" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/rel/sql_rewrite.go#L27-L106
20,471
araddon/qlbridge
rel/sql_rewrite.go
rewriteNode
func rewriteNode(from *SqlSource, node expr.Node) expr.Node { switch nt := node.(type) { case *expr.IdentityNode: if left, right, ok := nt.LeftRight(); ok { //u.Debugf("rewriteNode from.Name:%v l:%v r:%v", from.alias, left, right) if left == from.alias { in := expr.IdentityNode{Text: right} //u.Warnf...
go
func rewriteNode(from *SqlSource, node expr.Node) expr.Node { switch nt := node.(type) { case *expr.IdentityNode: if left, right, ok := nt.LeftRight(); ok { //u.Debugf("rewriteNode from.Name:%v l:%v r:%v", from.alias, left, right) if left == from.alias { in := expr.IdentityNode{Text: right} //u.Warnf...
[ "func", "rewriteNode", "(", "from", "*", "SqlSource", ",", "node", "expr", ".", "Node", ")", "expr", ".", "Node", "{", "switch", "nt", ":=", "node", ".", "(", "type", ")", "{", "case", "*", "expr", ".", "IdentityNode", ":", "if", "left", ",", "righ...
// Remove any aliases
[ "Remove", "any", "aliases" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/rel/sql_rewrite.go#L378-L427
20,472
araddon/qlbridge
expr/builtins/filter.go
FiltersFromArgs
func FiltersFromArgs(filterVals []value.Value) []string { filters := make([]string, 0, len(filterVals)) for _, fv := range filterVals { switch fv := fv.(type) { case value.Slice: for _, fv := range fv.SliceValue() { matchKey := fv.ToString() if strings.Contains(matchKey, "%") { matchKey = strings....
go
func FiltersFromArgs(filterVals []value.Value) []string { filters := make([]string, 0, len(filterVals)) for _, fv := range filterVals { switch fv := fv.(type) { case value.Slice: for _, fv := range fv.SliceValue() { matchKey := fv.ToString() if strings.Contains(matchKey, "%") { matchKey = strings....
[ "func", "FiltersFromArgs", "(", "filterVals", "[", "]", "value", ".", "Value", ")", "[", "]", "string", "{", "filters", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "filterVals", ")", ")", "\n", "for", "_", ",", "fv", ":=", "...
// FilterFromArgs given set of values
[ "FilterFromArgs", "given", "set", "of", "values" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/expr/builtins/filter.go#L37-L58
20,473
araddon/qlbridge
generators/elasticsearch/es2gen/bridgeutil.go
scalar
func scalar(node expr.Node) (interface{}, bool) { switch n := node.(type) { case *expr.StringNode: return n.Text, true case *expr.NumberNode: if n.IsInt { // ES supports string encoded ints return n.Int64, true } return n.Float64, true case *expr.ValueNode: // Make sure this is a scalar value nod...
go
func scalar(node expr.Node) (interface{}, bool) { switch n := node.(type) { case *expr.StringNode: return n.Text, true case *expr.NumberNode: if n.IsInt { // ES supports string encoded ints return n.Int64, true } return n.Float64, true case *expr.ValueNode: // Make sure this is a scalar value nod...
[ "func", "scalar", "(", "node", "expr", ".", "Node", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "switch", "n", ":=", "node", ".", "(", "type", ")", "{", "case", "*", "expr", ".", "StringNode", ":", "return", "n", ".", "Text", ",", "...
// scalar returns a JSONable representation of a scalar node type for use in ES // filters. // // Does not support Null. //
[ "scalar", "returns", "a", "JSONable", "representation", "of", "a", "scalar", "node", "type", "for", "use", "in", "ES", "filters", ".", "Does", "not", "support", "Null", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/generators/elasticsearch/es2gen/bridgeutil.go#L26-L58
20,474
araddon/qlbridge
plan/sql_rewrite.go
Eval
func (m *defaultTypeWriter) Eval(ctx expr.EvalContext, vals []value.Value) (value.Value, bool) { if len(vals) == 0 || vals[0] == nil || vals[0].Nil() { return nil, false } switch sv := vals[0].(type) { case value.StringValue: return sv, true } return value.NewStringValue(""), false }
go
func (m *defaultTypeWriter) Eval(ctx expr.EvalContext, vals []value.Value) (value.Value, bool) { if len(vals) == 0 || vals[0] == nil || vals[0].Nil() { return nil, false } switch sv := vals[0].(type) { case value.StringValue: return sv, true } return value.NewStringValue(""), false }
[ "func", "(", "m", "*", "defaultTypeWriter", ")", "Eval", "(", "ctx", "expr", ".", "EvalContext", ",", "vals", "[", "]", "value", ".", "Value", ")", "(", "value", ".", "Value", ",", "bool", ")", "{", "if", "len", "(", "vals", ")", "==", "0", "||",...
// defaultTypeWriter Convert a qlbridge value type to qlbridge value type
[ "defaultTypeWriter", "Convert", "a", "qlbridge", "value", "type", "to", "qlbridge", "value", "type" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/plan/sql_rewrite.go#L26-L36
20,475
araddon/qlbridge
schema/apply_schema.go
Drop
func (m *InMemApplyer) Drop(s *Schema, v interface{}) error { // Find the type of operation being updated. switch v := v.(type) { case *Table: u.Debugf("%p:%s InfoSchema P:%p dropping table %q from %v", s, s.Name, s.InfoSchema, v.Name, s.Tables()) // s==v means schema is being dropped m.reg.mu.Lock() s.mu....
go
func (m *InMemApplyer) Drop(s *Schema, v interface{}) error { // Find the type of operation being updated. switch v := v.(type) { case *Table: u.Debugf("%p:%s InfoSchema P:%p dropping table %q from %v", s, s.Name, s.InfoSchema, v.Name, s.Tables()) // s==v means schema is being dropped m.reg.mu.Lock() s.mu....
[ "func", "(", "m", "*", "InMemApplyer", ")", "Drop", "(", "s", "*", "Schema", ",", "v", "interface", "{", "}", ")", "error", "{", "// Find the type of operation being updated.", "switch", "v", ":=", "v", ".", "(", "type", ")", "{", "case", "*", "Table", ...
// Drop we have a schema change to apply.
[ "Drop", "we", "have", "a", "schema", "change", "to", "apply", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/schema/apply_schema.go#L108-L148
20,476
araddon/qlbridge
datasource/csv.go
NewCsvSource
func NewCsvSource(table string, indexCol int, ior io.Reader, exit <-chan bool) (*CsvDataSource, error) { m := CsvDataSource{table: table, indexCol: indexCol} if rc, ok := ior.(io.ReadCloser); ok { m.rc = rc } buf := bufio.NewReader(ior) first2, err := buf.Peek(2) if err != nil { u.Errorf("Error opening buf...
go
func NewCsvSource(table string, indexCol int, ior io.Reader, exit <-chan bool) (*CsvDataSource, error) { m := CsvDataSource{table: table, indexCol: indexCol} if rc, ok := ior.(io.ReadCloser); ok { m.rc = rc } buf := bufio.NewReader(ior) first2, err := buf.Peek(2) if err != nil { u.Errorf("Error opening buf...
[ "func", "NewCsvSource", "(", "table", "string", ",", "indexCol", "int", ",", "ior", "io", ".", "Reader", ",", "exit", "<-", "chan", "bool", ")", "(", "*", "CsvDataSource", ",", "error", ")", "{", "m", ":=", "CsvDataSource", "{", "table", ":", "table", ...
// NewCsvSource reader assumes we are getting first row as headers // - optionally may be gzipped
[ "NewCsvSource", "reader", "assumes", "we", "are", "getting", "first", "row", "as", "headers", "-", "optionally", "may", "be", "gzipped" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/datasource/csv.go#L48-L98
20,477
araddon/qlbridge
datasource/memdb/db.go
NewMemDbData
func NewMemDbData(name string, data [][]driver.Value, cols []string) (*MemDb, error) { m, err := NewMemDb(name, cols) if err != nil { return nil, err } // Insert initial values conn := newDbConn(m) defer conn.Close() for _, row := range data { conn.Put(nil, nil, row) } // we are going to look at ~10 rows...
go
func NewMemDbData(name string, data [][]driver.Value, cols []string) (*MemDb, error) { m, err := NewMemDb(name, cols) if err != nil { return nil, err } // Insert initial values conn := newDbConn(m) defer conn.Close() for _, row := range data { conn.Put(nil, nil, row) } // we are going to look at ~10 rows...
[ "func", "NewMemDbData", "(", "name", "string", ",", "data", "[", "]", "[", "]", "driver", ".", "Value", ",", "cols", "[", "]", "string", ")", "(", "*", "MemDb", ",", "error", ")", "{", "m", ",", "err", ":=", "NewMemDb", "(", "name", ",", "cols", ...
// NewMemDbData creates a MemDb with given indexes, columns, and values
[ "NewMemDbData", "creates", "a", "MemDb", "with", "given", "indexes", "columns", "and", "values" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/datasource/memdb/db.go#L57-L76
20,478
araddon/qlbridge
datasource/memdb/db.go
NewMemDb
func NewMemDb(name string, cols []string) (*MemDb, error) { return NewMemDbForSchema(name, cols) }
go
func NewMemDb(name string, cols []string) (*MemDb, error) { return NewMemDbForSchema(name, cols) }
[ "func", "NewMemDb", "(", "name", "string", ",", "cols", "[", "]", "string", ")", "(", "*", "MemDb", ",", "error", ")", "{", "return", "NewMemDbForSchema", "(", "name", ",", "cols", ")", "\n", "}" ]
// NewMemDb creates a MemDb with given indexes, columns
[ "NewMemDb", "creates", "a", "MemDb", "with", "given", "indexes", "columns" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/datasource/memdb/db.go#L79-L81
20,479
araddon/qlbridge
datasource/memdb/db.go
NewMemDbForSchema
func NewMemDbForSchema(name string, cols []string) (*MemDb, error) { if len(cols) < 1 { return nil, fmt.Errorf("must have columns provided") } m := &MemDb{} m.exit = make(chan bool, 1) var err error m.tbl = schema.NewTable(name) m.tbl.SetColumns(cols) m.buildDefaultIndexes() mdbSchema := makeMemDbSchema(m) ...
go
func NewMemDbForSchema(name string, cols []string) (*MemDb, error) { if len(cols) < 1 { return nil, fmt.Errorf("must have columns provided") } m := &MemDb{} m.exit = make(chan bool, 1) var err error m.tbl = schema.NewTable(name) m.tbl.SetColumns(cols) m.buildDefaultIndexes() mdbSchema := makeMemDbSchema(m) ...
[ "func", "NewMemDbForSchema", "(", "name", "string", ",", "cols", "[", "]", "string", ")", "(", "*", "MemDb", ",", "error", ")", "{", "if", "len", "(", "cols", ")", "<", "1", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ...
// NewMemDbForSchema creates a MemDb with given indexes, columns
[ "NewMemDbForSchema", "creates", "a", "MemDb", "with", "given", "indexes", "columns" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/datasource/memdb/db.go#L84-L98
20,480
araddon/qlbridge
datasource/memdb/db.go
DeleteExpression
func (m *dbConn) DeleteExpression(p interface{}, where expr.Node) (int, error) { var deletedKeys []schema.Key txn := m.db.Txn(true) iter, err := txn.Get(m.md.tbl.Name, m.md.primaryIndex) if err != nil { txn.Abort() u.Errorf("could not get values %v", err) return 0, err } deleteLoop: for { item := iter.Ne...
go
func (m *dbConn) DeleteExpression(p interface{}, where expr.Node) (int, error) { var deletedKeys []schema.Key txn := m.db.Txn(true) iter, err := txn.Get(m.md.tbl.Name, m.md.primaryIndex) if err != nil { txn.Abort() u.Errorf("could not get values %v", err) return 0, err } deleteLoop: for { item := iter.Ne...
[ "func", "(", "m", "*", "dbConn", ")", "DeleteExpression", "(", "p", "interface", "{", "}", ",", "where", "expr", ".", "Node", ")", "(", "int", ",", "error", ")", "{", "var", "deletedKeys", "[", "]", "schema", ".", "Key", "\n", "txn", ":=", "m", "...
// Delete using a Where Expression
[ "Delete", "using", "a", "Where", "Expression" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/datasource/memdb/db.go#L269-L326
20,481
araddon/qlbridge
value/value.go
ValueFromString
func ValueFromString(vt string) ValueType { switch vt { case "nil", "null": return NilType case "error": return ErrorType case "unknown": return UnknownType case "value": return ValueInterfaceType case "number": return NumberType case "int": return IntType case "bool": return BoolType case "time"...
go
func ValueFromString(vt string) ValueType { switch vt { case "nil", "null": return NilType case "error": return ErrorType case "unknown": return UnknownType case "value": return ValueInterfaceType case "number": return NumberType case "int": return IntType case "bool": return BoolType case "time"...
[ "func", "ValueFromString", "(", "vt", "string", ")", "ValueType", "{", "switch", "vt", "{", "case", "\"", "\"", ",", "\"", "\"", ":", "return", "NilType", "\n", "case", "\"", "\"", ":", "return", "ErrorType", "\n", "case", "\"", "\"", ":", "return", ...
// ValueFromString Given a string, convert to valuetype
[ "ValueFromString", "Given", "a", "string", "convert", "to", "valuetype" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/value/value.go#L241-L286
20,482
araddon/qlbridge
expr/node.go
FindAllIdentities
func FindAllIdentities(node Node) IdentityNodes { in := make(IdentityNodes, 0) return findIdentities(node, in) }
go
func FindAllIdentities(node Node) IdentityNodes { in := make(IdentityNodes, 0) return findIdentities(node, in) }
[ "func", "FindAllIdentities", "(", "node", "Node", ")", "IdentityNodes", "{", "in", ":=", "make", "(", "IdentityNodes", ",", "0", ")", "\n", "return", "findIdentities", "(", "node", ",", "in", ")", "\n", "}" ]
// FindAllIdentities gets all identity
[ "FindAllIdentities", "gets", "all", "identity" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/expr/node.go#L368-L371
20,483
araddon/qlbridge
expr/node.go
Strings
func (m IdentityNodes) Strings() []string { s := make([]string, len(m)) for i, in := range m { s[i] = in.Text } return s }
go
func (m IdentityNodes) Strings() []string { s := make([]string, len(m)) for i, in := range m { s[i] = in.Text } return s }
[ "func", "(", "m", "IdentityNodes", ")", "Strings", "(", ")", "[", "]", "string", "{", "s", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "m", ")", ")", "\n", "for", "i", ",", "in", ":=", "range", "m", "{", "s", "[", "i", "]", "=",...
// Strings get all identity strings
[ "Strings", "get", "all", "identity", "strings" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/expr/node.go#L418-L424
20,484
araddon/qlbridge
expr/node.go
LeftStrings
func (m IdentityNodes) LeftStrings() []string { s := make([]string, len(m)) for i, in := range m { l, r, hasLr := in.LeftRight() if hasLr { s[i] = l } else { s[i] = r } } return s }
go
func (m IdentityNodes) LeftStrings() []string { s := make([]string, len(m)) for i, in := range m { l, r, hasLr := in.LeftRight() if hasLr { s[i] = l } else { s[i] = r } } return s }
[ "func", "(", "m", "IdentityNodes", ")", "LeftStrings", "(", ")", "[", "]", "string", "{", "s", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "m", ")", ")", "\n", "for", "i", ",", "in", ":=", "range", "m", "{", "l", ",", "r", ",", ...
// LeftStrings get all Left Identity fields.
[ "LeftStrings", "get", "all", "Left", "Identity", "fields", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/expr/node.go#L427-L438
20,485
araddon/qlbridge
expr/node.go
ValueTypeFromNode
func ValueTypeFromNode(n Node) value.ValueType { switch nt := n.(type) { case *FuncNode: if nt == nil { return value.UnknownType } if nt.F.CustomFunc == nil { return value.UnknownType } return nt.F.Type() case *StringNode: return value.StringType case *IdentityNode: // Identity types will draw t...
go
func ValueTypeFromNode(n Node) value.ValueType { switch nt := n.(type) { case *FuncNode: if nt == nil { return value.UnknownType } if nt.F.CustomFunc == nil { return value.UnknownType } return nt.F.Type() case *StringNode: return value.StringType case *IdentityNode: // Identity types will draw t...
[ "func", "ValueTypeFromNode", "(", "n", "Node", ")", "value", ".", "ValueType", "{", "switch", "nt", ":=", "n", ".", "(", "type", ")", "{", "case", "*", "FuncNode", ":", "if", "nt", "==", "nil", "{", "return", "value", ".", "UnknownType", "\n", "}", ...
// ValueTypeFromNode Infer Value type from Node
[ "ValueTypeFromNode", "Infer", "Value", "type", "from", "Node" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/expr/node.go#L483-L516
20,486
araddon/qlbridge
expr/node.go
NewFuncNode
func NewFuncNode(name string, f Func) *FuncNode { return &FuncNode{Name: name, F: f} }
go
func NewFuncNode(name string, f Func) *FuncNode { return &FuncNode{Name: name, F: f} }
[ "func", "NewFuncNode", "(", "name", "string", ",", "f", "Func", ")", "*", "FuncNode", "{", "return", "&", "FuncNode", "{", "Name", ":", "name", ",", "F", ":", "f", "}", "\n", "}" ]
// NewFuncNode create new Function Expression Node.
[ "NewFuncNode", "create", "new", "Function", "Expression", "Node", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/expr/node.go#L519-L521
20,487
araddon/qlbridge
expr/node.go
Expr
func (m *FuncNode) Expr() *Expr { fe := &Expr{Op: lex.TokenUdfExpr.String()} if len(m.Args) > 0 { fe.Args = []*Expr{{Identity: m.Name}} fe.Args = append(fe.Args, ExprsFromNodes(m.Args)...) } return fe }
go
func (m *FuncNode) Expr() *Expr { fe := &Expr{Op: lex.TokenUdfExpr.String()} if len(m.Args) > 0 { fe.Args = []*Expr{{Identity: m.Name}} fe.Args = append(fe.Args, ExprsFromNodes(m.Args)...) } return fe }
[ "func", "(", "m", "*", "FuncNode", ")", "Expr", "(", ")", "*", "Expr", "{", "fe", ":=", "&", "Expr", "{", "Op", ":", "lex", ".", "TokenUdfExpr", ".", "String", "(", ")", "}", "\n", "if", "len", "(", "m", ".", "Args", ")", ">", "0", "{", "fe...
// Expr convert the FuncNode to Expr
[ "Expr", "convert", "the", "FuncNode", "to", "Expr" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/expr/node.go#L600-L607
20,488
araddon/qlbridge
expr/node.go
NewNumberStr
func NewNumberStr(text string) (*NumberNode, error) { n := &NumberNode{Text: text} return n, n.load() }
go
func NewNumberStr(text string) (*NumberNode, error) { n := &NumberNode{Text: text} return n, n.load() }
[ "func", "NewNumberStr", "(", "text", "string", ")", "(", "*", "NumberNode", ",", "error", ")", "{", "n", ":=", "&", "NumberNode", "{", "Text", ":", "text", "}", "\n", "return", "n", ",", "n", ".", "load", "(", ")", "\n", "}" ]
// NewNumberStr is a little weird in that this Node accepts string @text // and uses go to parse into Int, AND Float.
[ "NewNumberStr", "is", "a", "little", "weird", "in", "that", "this", "Node", "accepts", "string" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/expr/node.go#L672-L675
20,489
araddon/qlbridge
expr/node.go
NewBooleanNode
func NewBooleanNode(operator lex.Token, args ...Node) *BooleanNode { //u.Debugf("NewBinaryNode: %v %v %v", lhArg, operator, rhArg) return &BooleanNode{Args: args, Operator: operator} }
go
func NewBooleanNode(operator lex.Token, args ...Node) *BooleanNode { //u.Debugf("NewBinaryNode: %v %v %v", lhArg, operator, rhArg) return &BooleanNode{Args: args, Operator: operator} }
[ "func", "NewBooleanNode", "(", "operator", "lex", ".", "Token", ",", "args", "...", "Node", ")", "*", "BooleanNode", "{", "//u.Debugf(\"NewBinaryNode: %v %v %v\", lhArg, operator, rhArg)", "return", "&", "BooleanNode", "{", "Args", ":", "args", ",", "Operator", ":",...
// NewBooleanNode Create a boolean node // @operator = AND, OR // @args = nodes
[ "NewBooleanNode", "Create", "a", "boolean", "node" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/expr/node.go#L1409-L1412
20,490
araddon/qlbridge
expr/node.go
NewTriNode
func NewTriNode(operator lex.Token, arg1, arg2, arg3 Node) *TriNode { return &TriNode{Args: []Node{arg1, arg2, arg3}, Operator: operator} }
go
func NewTriNode(operator lex.Token, arg1, arg2, arg3 Node) *TriNode { return &TriNode{Args: []Node{arg1, arg2, arg3}, Operator: operator} }
[ "func", "NewTriNode", "(", "operator", "lex", ".", "Token", ",", "arg1", ",", "arg2", ",", "arg3", "Node", ")", "*", "TriNode", "{", "return", "&", "TriNode", "{", "Args", ":", "[", "]", "Node", "{", "arg1", ",", "arg2", ",", "arg3", "}", ",", "O...
// Create a Tri node // // @arg1 [NOT] BETWEEN @arg2 AND @arg3 //
[ "Create", "a", "Tri", "node" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/expr/node.go#L1555-L1557
20,491
araddon/qlbridge
expr/node.go
NodeFromPb
func NodeFromPb(pb []byte) (Node, error) { n := &NodePb{} if err := proto.Unmarshal(pb, n); err != nil { return nil, err } return NodeFromNodePb(n), nil }
go
func NodeFromPb(pb []byte) (Node, error) { n := &NodePb{} if err := proto.Unmarshal(pb, n); err != nil { return nil, err } return NodeFromNodePb(n), nil }
[ "func", "NodeFromPb", "(", "pb", "[", "]", "byte", ")", "(", "Node", ",", "error", ")", "{", "n", ":=", "&", "NodePb", "{", "}", "\n", "if", "err", ":=", "proto", ".", "Unmarshal", "(", "pb", ",", "n", ")", ";", "err", "!=", "nil", "{", "retu...
// NodeFromPb Create a node from pb
[ "NodeFromPb", "Create", "a", "node", "from", "pb" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/expr/node.go#L2032-L2038
20,492
araddon/qlbridge
expr/node.go
NodeFromNodePb
func NodeFromNodePb(n *NodePb) Node { if n == nil { return nil } switch { case n.Bn != nil: var bn *BinaryNode return bn.FromPB(n) case n.Booln != nil: var bn *BooleanNode return bn.FromPB(n) case n.Un != nil: var un *UnaryNode return un.FromPB(n) case n.Fn != nil: var fn *FuncNode return fn.Fr...
go
func NodeFromNodePb(n *NodePb) Node { if n == nil { return nil } switch { case n.Bn != nil: var bn *BinaryNode return bn.FromPB(n) case n.Booln != nil: var bn *BooleanNode return bn.FromPB(n) case n.Un != nil: var un *UnaryNode return un.FromPB(n) case n.Fn != nil: var fn *FuncNode return fn.Fr...
[ "func", "NodeFromNodePb", "(", "n", "*", "NodePb", ")", "Node", "{", "if", "n", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "switch", "{", "case", "n", ".", "Bn", "!=", "nil", ":", "var", "bn", "*", "BinaryNode", "\n", "return", "bn", "."...
// NodeFromNodePb Create a node from pb
[ "NodeFromNodePb", "Create", "a", "node", "from", "pb" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/expr/node.go#L2041-L2083
20,493
araddon/qlbridge
lex/lexer.go
NewLexer
func NewLexer(input string, dialect *Dialect) *Lexer { // Three tokens of buffering is sufficient for all state functions. l := &Lexer{ input: input, state: LexDialectForStatement, tokens: make(chan Token, 3), stack: make([]NamedStateFn, 0, 10), dialect: dialect, } if len(dialect.IdentityQuoting) >...
go
func NewLexer(input string, dialect *Dialect) *Lexer { // Three tokens of buffering is sufficient for all state functions. l := &Lexer{ input: input, state: LexDialectForStatement, tokens: make(chan Token, 3), stack: make([]NamedStateFn, 0, 10), dialect: dialect, } if len(dialect.IdentityQuoting) >...
[ "func", "NewLexer", "(", "input", "string", ",", "dialect", "*", "Dialect", ")", "*", "Lexer", "{", "// Three tokens of buffering is sufficient for all state functions.", "l", ":=", "&", "Lexer", "{", "input", ":", "input", ",", "state", ":", "LexDialectForStatement...
// NewLexer Creates a new lexer for the input string
[ "NewLexer", "Creates", "a", "new", "lexer", "for", "the", "input", "string" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/lex/lexer.go#L65-L81
20,494
araddon/qlbridge
lex/lexer.go
ErrMsg
func (l *Lexer) ErrMsg(t Token, msg string) error { raw := l.RawInput() if len(raw) == l.pos { raw = "" } else if len(raw) > t.Pos { if t.Pos > 0 { raw = raw[t.Pos-1:] } else { raw = raw[t.Pos:] } if len(raw) > 20 { raw = raw[:19] } } else { raw = "" } if len(msg) > 0 { return fmt.Errorf...
go
func (l *Lexer) ErrMsg(t Token, msg string) error { raw := l.RawInput() if len(raw) == l.pos { raw = "" } else if len(raw) > t.Pos { if t.Pos > 0 { raw = raw[t.Pos-1:] } else { raw = raw[t.Pos:] } if len(raw) > 20 { raw = raw[:19] } } else { raw = "" } if len(msg) > 0 { return fmt.Errorf...
[ "func", "(", "l", "*", "Lexer", ")", "ErrMsg", "(", "t", "Token", ",", "msg", "string", ")", "error", "{", "raw", ":=", "l", ".", "RawInput", "(", ")", "\n", "if", "len", "(", "raw", ")", "==", "l", ".", "pos", "{", "raw", "=", "\"", "\"", ...
// ErrMsg an error message helper which provides context of where in input string // the error is occuring, line, column, current token info.
[ "ErrMsg", "an", "error", "message", "helper", "which", "provides", "context", "of", "where", "in", "input", "string", "the", "error", "is", "occuring", "line", "column", "current", "token", "info", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/lex/lexer.go#L120-L141
20,495
araddon/qlbridge
lex/lexer.go
NextToken
func (l *Lexer) NextToken() Token { for { //u.Debugf("token: start=%v pos=%v peek5=%s", l.start, l.pos, l.PeekX(5)) select { case token := <-l.tokens: return token default: if l.state == nil && len(l.stack) > 0 { l.state = l.pop() } else if l.state == nil { return Token{T: TokenEOF, V: ""} ...
go
func (l *Lexer) NextToken() Token { for { //u.Debugf("token: start=%v pos=%v peek5=%s", l.start, l.pos, l.PeekX(5)) select { case token := <-l.tokens: return token default: if l.state == nil && len(l.stack) > 0 { l.state = l.pop() } else if l.state == nil { return Token{T: TokenEOF, V: ""} ...
[ "func", "(", "l", "*", "Lexer", ")", "NextToken", "(", ")", "Token", "{", "for", "{", "//u.Debugf(\"token: start=%v pos=%v peek5=%s\", l.start, l.pos, l.PeekX(5))", "select", "{", "case", "token", ":=", "<-", "l", ".", "tokens", ":", "return", "token", "\n", "...
// NextToken returns the next token from the input.
[ "NextToken", "returns", "the", "next", "token", "from", "the", "input", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/lex/lexer.go#L144-L159
20,496
araddon/qlbridge
lex/lexer.go
Push
func (l *Lexer) Push(name string, state StateFn) { debugf("push %d %v", len(l.stack)+1, name) if len(l.stack) < 500 { l.stack = append(l.stack, NamedStateFn{name, state}) } else { out := "" if len(l.input) > 200 { out = strings.Replace(l.input[0:199], "\n", " ", -1) } else { out = strings.Replace(l.inp...
go
func (l *Lexer) Push(name string, state StateFn) { debugf("push %d %v", len(l.stack)+1, name) if len(l.stack) < 500 { l.stack = append(l.stack, NamedStateFn{name, state}) } else { out := "" if len(l.input) > 200 { out = strings.Replace(l.input[0:199], "\n", " ", -1) } else { out = strings.Replace(l.inp...
[ "func", "(", "l", "*", "Lexer", ")", "Push", "(", "name", "string", ",", "state", "StateFn", ")", "{", "debugf", "(", "\"", "\"", ",", "len", "(", "l", ".", "stack", ")", "+", "1", ",", "name", ")", "\n", "if", "len", "(", "l", ".", "stack", ...
// Push a named StateFn onto stack.
[ "Push", "a", "named", "StateFn", "onto", "stack", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/lex/lexer.go#L162-L175
20,497
araddon/qlbridge
lex/lexer.go
Peek
func (l *Lexer) Peek() rune { r := l.Next() l.backup() return r }
go
func (l *Lexer) Peek() rune { r := l.Next() l.backup() return r }
[ "func", "(", "l", "*", "Lexer", ")", "Peek", "(", ")", "rune", "{", "r", ":=", "l", ".", "Next", "(", ")", "\n", "l", ".", "backup", "(", ")", "\n", "return", "r", "\n", "}" ]
// Peek returns but does not consume the next rune in the input.
[ "Peek", "returns", "but", "does", "not", "consume", "the", "next", "rune", "in", "the", "input", "." ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/lex/lexer.go#L234-L238
20,498
araddon/qlbridge
lex/lexer.go
PeekX
func (l *Lexer) PeekX(x int) string { if l.pos+x > len(l.input) { return l.input[l.pos:] } return l.input[l.pos : l.pos+x] }
go
func (l *Lexer) PeekX(x int) string { if l.pos+x > len(l.input) { return l.input[l.pos:] } return l.input[l.pos : l.pos+x] }
[ "func", "(", "l", "*", "Lexer", ")", "PeekX", "(", "x", "int", ")", "string", "{", "if", "l", ".", "pos", "+", "x", ">", "len", "(", "l", ".", "input", ")", "{", "return", "l", ".", "input", "[", "l", ".", "pos", ":", "]", "\n", "}", "\n"...
// PeekX grab the next x characters without consuming
[ "PeekX", "grab", "the", "next", "x", "characters", "without", "consuming" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/lex/lexer.go#L241-L246
20,499
araddon/qlbridge
lex/lexer.go
peekRunePast
func (l *Lexer) peekRunePast(skip int) rune { if l.pos+skip+1 > len(l.input) { return rune(0) } for ; skip < len(l.input)-l.pos; skip++ { r, ri := utf8.DecodeRuneInString(l.input[l.pos+skip:]) if ri != 1 { skip += (ri - 1) } if !unicode.IsSpace(r) { return r } } return rune(0) }
go
func (l *Lexer) peekRunePast(skip int) rune { if l.pos+skip+1 > len(l.input) { return rune(0) } for ; skip < len(l.input)-l.pos; skip++ { r, ri := utf8.DecodeRuneInString(l.input[l.pos+skip:]) if ri != 1 { skip += (ri - 1) } if !unicode.IsSpace(r) { return r } } return rune(0) }
[ "func", "(", "l", "*", "Lexer", ")", "peekRunePast", "(", "skip", "int", ")", "rune", "{", "if", "l", ".", "pos", "+", "skip", "+", "1", ">", "len", "(", "l", ".", "input", ")", "{", "return", "rune", "(", "0", ")", "\n", "}", "\n\n", "for", ...
// get single character PAST
[ "get", "single", "character", "PAST" ]
23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac
https://github.com/araddon/qlbridge/blob/23bb6a4e8c9e82ba86952b8a1469ccff1bb296ac/lex/lexer.go#L249-L264