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
12,300
peco/peco
pipeline/pipeline.go
SetDestination
func (p *Pipeline) SetDestination(d Destination) { p.mutex.Lock() defer p.mutex.Unlock() p.dst = d }
go
func (p *Pipeline) SetDestination(d Destination) { p.mutex.Lock() defer p.mutex.Unlock() p.dst = d }
[ "func", "(", "p", "*", "Pipeline", ")", "SetDestination", "(", "d", "Destination", ")", "{", "p", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "p", ".", "dst", "=", "d", "\n", "}" ]
// SetDestination sets the destination. // If called during `Run`, this method will block.
[ "SetDestination", "sets", "the", "destination", ".", "If", "called", "during", "Run", "this", "method", "will", "block", "." ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/pipeline/pipeline.go#L102-L107
12,301
peco/peco
pipeline/pipeline.go
Run
func (p *Pipeline) Run(ctx context.Context) (err error) { if pdebug.Enabled { g := pdebug.Marker("Pipeline.Run (%s)", ctx.Value("query")).BindError(&err) defer g.End() } p.mutex.Lock() defer p.mutex.Unlock() defer close(p.done) if p.src == nil { return errors.New("source must be non-nil") } if p.dst == ...
go
func (p *Pipeline) Run(ctx context.Context) (err error) { if pdebug.Enabled { g := pdebug.Marker("Pipeline.Run (%s)", ctx.Value("query")).BindError(&err) defer g.End() } p.mutex.Lock() defer p.mutex.Unlock() defer close(p.done) if p.src == nil { return errors.New("source must be non-nil") } if p.dst == ...
[ "func", "(", "p", "*", "Pipeline", ")", "Run", "(", "ctx", "context", ".", "Context", ")", "(", "err", "error", ")", "{", "if", "pdebug", ".", "Enabled", "{", "g", ":=", "pdebug", ".", "Marker", "(", "\"", "\"", ",", "ctx", ".", "Value", "(", "...
// Run starts the processing. Mutator methods for `Pipeline` cannot be // called while `Run` is running.
[ "Run", "starts", "the", "processing", ".", "Mutator", "methods", "for", "Pipeline", "cannot", "be", "called", "while", "Run", "is", "running", "." ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/pipeline/pipeline.go#L111-L155
12,302
peco/peco
selection.go
Add
func (s *Selection) Add(l line.Line) { s.mutex.Lock() defer s.mutex.Unlock() s.tree.ReplaceOrInsert(l) }
go
func (s *Selection) Add(l line.Line) { s.mutex.Lock() defer s.mutex.Unlock() s.tree.ReplaceOrInsert(l) }
[ "func", "(", "s", "*", "Selection", ")", "Add", "(", "l", "line", ".", "Line", ")", "{", "s", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "Unlock", "(", ")", "\n", "s", ".", "tree", ".", "ReplaceOrInsert", "(", ...
// Add adds a new line to the selection. If the line already // exists in the selection, it is silently ignored
[ "Add", "adds", "a", "new", "line", "to", "the", "selection", ".", "If", "the", "line", "already", "exists", "in", "the", "selection", "it", "is", "silently", "ignored" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/selection.go#L17-L21
12,303
peco/peco
selection.go
Remove
func (s *Selection) Remove(l line.Line) { s.mutex.Lock() defer s.mutex.Unlock() s.tree.Delete(l) }
go
func (s *Selection) Remove(l line.Line) { s.mutex.Lock() defer s.mutex.Unlock() s.tree.Delete(l) }
[ "func", "(", "s", "*", "Selection", ")", "Remove", "(", "l", "line", ".", "Line", ")", "{", "s", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "Unlock", "(", ")", "\n", "s", ".", "tree", ".", "Delete", "(", "l", ...
// Remove removes the specified line from the selection
[ "Remove", "removes", "the", "specified", "line", "from", "the", "selection" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/selection.go#L31-L35
12,304
peco/peco
layout.go
NewAnchorSettings
func NewAnchorSettings(screen Screen, anchor VerticalAnchor, offset int) *AnchorSettings { if !IsValidVerticalAnchor(anchor) { panic("Invalid vertical anchor specified") } return &AnchorSettings{ anchor: anchor, anchorOffset: offset, screen: screen, } }
go
func NewAnchorSettings(screen Screen, anchor VerticalAnchor, offset int) *AnchorSettings { if !IsValidVerticalAnchor(anchor) { panic("Invalid vertical anchor specified") } return &AnchorSettings{ anchor: anchor, anchorOffset: offset, screen: screen, } }
[ "func", "NewAnchorSettings", "(", "screen", "Screen", ",", "anchor", "VerticalAnchor", ",", "offset", "int", ")", "*", "AnchorSettings", "{", "if", "!", "IsValidVerticalAnchor", "(", "anchor", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "re...
// NewAnchorSettings creates a new AnchorSetting struct. Panics if // an unknown VerticalAnchor is sent
[ "NewAnchorSettings", "creates", "a", "new", "AnchorSetting", "struct", ".", "Panics", "if", "an", "unknown", "VerticalAnchor", "is", "sent" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/layout.go#L39-L49
12,305
peco/peco
layout.go
AnchorPosition
func (as AnchorSettings) AnchorPosition() int { var pos int switch as.anchor { case AnchorTop: pos = as.anchorOffset case AnchorBottom: _, h := as.screen.Size() pos = int(h) - as.anchorOffset - 1 // -1 is required because y is 0 base, but h is 1 base default: panic("Unknown anchor type!") } return pos }
go
func (as AnchorSettings) AnchorPosition() int { var pos int switch as.anchor { case AnchorTop: pos = as.anchorOffset case AnchorBottom: _, h := as.screen.Size() pos = int(h) - as.anchorOffset - 1 // -1 is required because y is 0 base, but h is 1 base default: panic("Unknown anchor type!") } return pos }
[ "func", "(", "as", "AnchorSettings", ")", "AnchorPosition", "(", ")", "int", "{", "var", "pos", "int", "\n", "switch", "as", ".", "anchor", "{", "case", "AnchorTop", ":", "pos", "=", "as", ".", "anchorOffset", "\n", "case", "AnchorBottom", ":", "_", ",...
// AnchorPosition returns the starting y-offset, based on the // anchor type and offset
[ "AnchorPosition", "returns", "the", "starting", "y", "-", "offset", "based", "on", "the", "anchor", "type", "and", "offset" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/layout.go#L53-L66
12,306
peco/peco
layout.go
NewUserPrompt
func NewUserPrompt(screen Screen, anchor VerticalAnchor, anchorOffset int, prompt string, styles *StyleSet) *UserPrompt { if len(prompt) <= 0 { // default prompt = "QUERY>" } promptLen := runewidth.StringWidth(prompt) return &UserPrompt{ AnchorSettings: NewAnchorSettings(screen, anchor, anchorOffset), prompt...
go
func NewUserPrompt(screen Screen, anchor VerticalAnchor, anchorOffset int, prompt string, styles *StyleSet) *UserPrompt { if len(prompt) <= 0 { // default prompt = "QUERY>" } promptLen := runewidth.StringWidth(prompt) return &UserPrompt{ AnchorSettings: NewAnchorSettings(screen, anchor, anchorOffset), prompt...
[ "func", "NewUserPrompt", "(", "screen", "Screen", ",", "anchor", "VerticalAnchor", ",", "anchorOffset", "int", ",", "prompt", "string", ",", "styles", "*", "StyleSet", ")", "*", "UserPrompt", "{", "if", "len", "(", "prompt", ")", "<=", "0", "{", "// defaul...
// NewUserPrompt creates a new UserPrompt struct
[ "NewUserPrompt", "creates", "a", "new", "UserPrompt", "struct" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/layout.go#L69-L81
12,307
peco/peco
layout.go
NewStatusBar
func NewStatusBar(screen Screen, anchor VerticalAnchor, anchorOffset int, styles *StyleSet) *StatusBar { return &StatusBar{ AnchorSettings: NewAnchorSettings(screen, anchor, anchorOffset), clearTimer: nil, styles: styles, } }
go
func NewStatusBar(screen Screen, anchor VerticalAnchor, anchorOffset int, styles *StyleSet) *StatusBar { return &StatusBar{ AnchorSettings: NewAnchorSettings(screen, anchor, anchorOffset), clearTimer: nil, styles: styles, } }
[ "func", "NewStatusBar", "(", "screen", "Screen", ",", "anchor", "VerticalAnchor", ",", "anchorOffset", "int", ",", "styles", "*", "StyleSet", ")", "*", "StatusBar", "{", "return", "&", "StatusBar", "{", "AnchorSettings", ":", "NewAnchorSettings", "(", "screen", ...
// NewStatusBar creates a new StatusBar struct
[ "NewStatusBar", "creates", "a", "new", "StatusBar", "struct" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/layout.go#L207-L213
12,308
peco/peco
layout.go
NewListArea
func NewListArea(screen Screen, anchor VerticalAnchor, anchorOffset int, sortTopDown bool, styles *StyleSet) *ListArea { return &ListArea{ AnchorSettings: NewAnchorSettings(screen, anchor, anchorOffset), displayCache: []line.Line{}, dirty: false, sortTopDown: sortTopDown, styles: styles...
go
func NewListArea(screen Screen, anchor VerticalAnchor, anchorOffset int, sortTopDown bool, styles *StyleSet) *ListArea { return &ListArea{ AnchorSettings: NewAnchorSettings(screen, anchor, anchorOffset), displayCache: []line.Line{}, dirty: false, sortTopDown: sortTopDown, styles: styles...
[ "func", "NewListArea", "(", "screen", "Screen", ",", "anchor", "VerticalAnchor", ",", "anchorOffset", "int", ",", "sortTopDown", "bool", ",", "styles", "*", "StyleSet", ")", "*", "ListArea", "{", "return", "&", "ListArea", "{", "AnchorSettings", ":", "NewAncho...
// NewListArea creates a new ListArea struct
[ "NewListArea", "creates", "a", "new", "ListArea", "struct" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/layout.go#L291-L299
12,309
peco/peco
layout.go
NewBottomUpLayout
func NewBottomUpLayout(state *Peco) *BasicLayout { return &BasicLayout{ StatusBar: NewStatusBar(state.Screen(), AnchorBottom, 0+extraOffset, state.Styles()), // The prompt is at the bottom, above the status bar prompt: NewUserPrompt(state.Screen(), AnchorBottom, 1+extraOffset, state.Prompt(), state.Styles()), ...
go
func NewBottomUpLayout(state *Peco) *BasicLayout { return &BasicLayout{ StatusBar: NewStatusBar(state.Screen(), AnchorBottom, 0+extraOffset, state.Styles()), // The prompt is at the bottom, above the status bar prompt: NewUserPrompt(state.Screen(), AnchorBottom, 1+extraOffset, state.Prompt(), state.Styles()), ...
[ "func", "NewBottomUpLayout", "(", "state", "*", "Peco", ")", "*", "BasicLayout", "{", "return", "&", "BasicLayout", "{", "StatusBar", ":", "NewStatusBar", "(", "state", ".", "Screen", "(", ")", ",", "AnchorBottom", ",", "0", "+", "extraOffset", ",", "state...
// NewBottomUpLayout creates a new Layout in bottom-up format
[ "NewBottomUpLayout", "creates", "a", "new", "Layout", "in", "bottom", "-", "up", "format" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/layout.go#L625-L634
12,310
peco/peco
layout.go
CalculatePage
func (l *BasicLayout) CalculatePage(state *Peco, perPage int) error { if pdebug.Enabled { g := pdebug.Marker("BasicLayout.Calculate %d", perPage) defer g.End() } buf := state.CurrentLineBuffer() loc := state.Location() loc.SetPage((loc.LineNumber() / perPage) + 1) loc.SetOffset((loc.Page() - 1) * perPage) lo...
go
func (l *BasicLayout) CalculatePage(state *Peco, perPage int) error { if pdebug.Enabled { g := pdebug.Marker("BasicLayout.Calculate %d", perPage) defer g.End() } buf := state.CurrentLineBuffer() loc := state.Location() loc.SetPage((loc.LineNumber() / perPage) + 1) loc.SetOffset((loc.Page() - 1) * perPage) lo...
[ "func", "(", "l", "*", "BasicLayout", ")", "CalculatePage", "(", "state", "*", "Peco", ",", "perPage", "int", ")", "error", "{", "if", "pdebug", ".", "Enabled", "{", "g", ":=", "pdebug", ".", "Marker", "(", "\"", "\"", ",", "perPage", ")", "\n", "d...
// CalculatePage calculates which page we're displaying
[ "CalculatePage", "calculates", "which", "page", "we", "re", "displaying" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/layout.go#L641-L668
12,311
peco/peco
layout.go
DrawScreen
func (l *BasicLayout) DrawScreen(state *Peco, options *DrawOptions) { if pdebug.Enabled { g := pdebug.Marker("BasicLayout.DrawScreen") defer g.End() } perPage := l.linesPerPage() if err := l.CalculatePage(state, perPage); err != nil { return } l.DrawPrompt(state) l.list.Draw(state, l, perPage, options) ...
go
func (l *BasicLayout) DrawScreen(state *Peco, options *DrawOptions) { if pdebug.Enabled { g := pdebug.Marker("BasicLayout.DrawScreen") defer g.End() } perPage := l.linesPerPage() if err := l.CalculatePage(state, perPage); err != nil { return } l.DrawPrompt(state) l.list.Draw(state, l, perPage, options) ...
[ "func", "(", "l", "*", "BasicLayout", ")", "DrawScreen", "(", "state", "*", "Peco", ",", "options", "*", "DrawOptions", ")", "{", "if", "pdebug", ".", "Enabled", "{", "g", ":=", "pdebug", ".", "Marker", "(", "\"", "\"", ")", "\n", "defer", "g", "."...
// DrawScreen draws the entire screen
[ "DrawScreen", "draws", "the", "entire", "screen" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/layout.go#L676-L694
12,312
peco/peco
layout.go
MovePage
func (l *BasicLayout) MovePage(state *Peco, p PagingRequest) (moved bool) { switch p.Type() { case ToScrollLeft, ToScrollRight: moved = horizontalScroll(state, l, p) default: moved = verticalScroll(state, l, p) } return }
go
func (l *BasicLayout) MovePage(state *Peco, p PagingRequest) (moved bool) { switch p.Type() { case ToScrollLeft, ToScrollRight: moved = horizontalScroll(state, l, p) default: moved = verticalScroll(state, l, p) } return }
[ "func", "(", "l", "*", "BasicLayout", ")", "MovePage", "(", "state", "*", "Peco", ",", "p", "PagingRequest", ")", "(", "moved", "bool", ")", "{", "switch", "p", ".", "Type", "(", ")", "{", "case", "ToScrollLeft", ",", "ToScrollRight", ":", "moved", "...
// MovePage scrolls the screen
[ "MovePage", "scrolls", "the", "screen" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/layout.go#L720-L728
12,313
peco/peco
layout.go
horizontalScroll
func horizontalScroll(state *Peco, l *BasicLayout, p PagingRequest) bool { width, _ := state.screen.Size() loc := state.Location() if p.Type() == ToScrollRight { loc.SetColumn(loc.Column() + width/2) } else if loc.Column() > 0 { loc.SetColumn(loc.Column() - width/2) if loc.Column() < 0 { loc.SetColumn(0) ...
go
func horizontalScroll(state *Peco, l *BasicLayout, p PagingRequest) bool { width, _ := state.screen.Size() loc := state.Location() if p.Type() == ToScrollRight { loc.SetColumn(loc.Column() + width/2) } else if loc.Column() > 0 { loc.SetColumn(loc.Column() - width/2) if loc.Column() < 0 { loc.SetColumn(0) ...
[ "func", "horizontalScroll", "(", "state", "*", "Peco", ",", "l", "*", "BasicLayout", ",", "p", "PagingRequest", ")", "bool", "{", "width", ",", "_", ":=", "state", ".", "screen", ".", "Size", "(", ")", "\n", "loc", ":=", "state", ".", "Location", "("...
// horizontalScroll scrolls screen horizontal
[ "horizontalScroll", "scrolls", "screen", "horizontal" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/layout.go#L861-L878
12,314
peco/peco
internal/util/tty_windows.go
TtyReady
func TtyReady() error { var err error _stdin, err := os.Open("CONIN$") if err != nil { return err } stdin = os.Stdin os.Stdin = _stdin syscall.Stdin = syscall.Handle(os.Stdin.Fd()) return errors.Wrap(setStdHandle(syscall.STD_INPUT_HANDLE, syscall.Stdin), "failed to check for TtyReady") }
go
func TtyReady() error { var err error _stdin, err := os.Open("CONIN$") if err != nil { return err } stdin = os.Stdin os.Stdin = _stdin syscall.Stdin = syscall.Handle(os.Stdin.Fd()) return errors.Wrap(setStdHandle(syscall.STD_INPUT_HANDLE, syscall.Stdin), "failed to check for TtyReady") }
[ "func", "TtyReady", "(", ")", "error", "{", "var", "err", "error", "\n\n", "_stdin", ",", "err", ":=", "os", ".", "Open", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "stdin", "=", "os", ".", "Std...
// TtyReady checks if the tty is ready to go
[ "TtyReady", "checks", "if", "the", "tty", "is", "ready", "to", "go" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/internal/util/tty_windows.go#L47-L59
12,315
peco/peco
internal/util/tty_windows.go
TtyTerm
func TtyTerm() { os.Stdin = stdin syscall.Stdin = syscall.Handle(os.Stdin.Fd()) setStdHandle(syscall.STD_INPUT_HANDLE, syscall.Stdin) }
go
func TtyTerm() { os.Stdin = stdin syscall.Stdin = syscall.Handle(os.Stdin.Fd()) setStdHandle(syscall.STD_INPUT_HANDLE, syscall.Stdin) }
[ "func", "TtyTerm", "(", ")", "{", "os", ".", "Stdin", "=", "stdin", "\n", "syscall", ".", "Stdin", "=", "syscall", ".", "Handle", "(", "os", ".", "Stdin", ".", "Fd", "(", ")", ")", "\n", "setStdHandle", "(", "syscall", ".", "STD_INPUT_HANDLE", ",", ...
// TtyTerm restores any state, if necessary
[ "TtyTerm", "restores", "any", "state", "if", "necessary" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/internal/util/tty_windows.go#L62-L66
12,316
peco/peco
filter/regexp.go
NewRegexp
func NewRegexp() *Regexp { return &Regexp{ factory: &regexpQueryFactory{ compiled: make(map[string]regexpQuery), threshold: time.Minute, }, flags: regexpFlagList(defaultFlags), quotemeta: false, name: "Regexp", outCh: pipeline.ChanOutput(make(chan interface{})), } }
go
func NewRegexp() *Regexp { return &Regexp{ factory: &regexpQueryFactory{ compiled: make(map[string]regexpQuery), threshold: time.Minute, }, flags: regexpFlagList(defaultFlags), quotemeta: false, name: "Regexp", outCh: pipeline.ChanOutput(make(chan interface{})), } }
[ "func", "NewRegexp", "(", ")", "*", "Regexp", "{", "return", "&", "Regexp", "{", "factory", ":", "&", "regexpQueryFactory", "{", "compiled", ":", "make", "(", "map", "[", "string", "]", "regexpQuery", ")", ",", "threshold", ":", "time", ".", "Minute", ...
// NewRegexp creates a new regexp based filter
[ "NewRegexp", "creates", "a", "new", "regexp", "based", "filter" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/filter/regexp.go#L62-L73
12,317
peco/peco
filter/regexp.go
NewSmartCase
func NewSmartCase() *Regexp { rf := NewRegexp() rf.quotemeta = true rf.name = "SmartCase" rf.flags = regexpFlagFunc(func(q string) []string { if util.ContainsUpper(q) { return defaultFlags } return []string{"i"} }) return rf }
go
func NewSmartCase() *Regexp { rf := NewRegexp() rf.quotemeta = true rf.name = "SmartCase" rf.flags = regexpFlagFunc(func(q string) []string { if util.ContainsUpper(q) { return defaultFlags } return []string{"i"} }) return rf }
[ "func", "NewSmartCase", "(", ")", "*", "Regexp", "{", "rf", ":=", "NewRegexp", "(", ")", "\n", "rf", ".", "quotemeta", "=", "true", "\n", "rf", ".", "name", "=", "\"", "\"", "\n", "rf", ".", "flags", "=", "regexpFlagFunc", "(", "func", "(", "q", ...
// SmartCase turns ON the ignore-case flag in the regexp // if the query contains a upper-case character
[ "SmartCase", "turns", "ON", "the", "ignore", "-", "case", "flag", "in", "the", "regexp", "if", "the", "query", "contains", "a", "upper", "-", "case", "character" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/filter/regexp.go#L187-L198
12,318
peco/peco
line/raw.go
NewRaw
func NewRaw(id uint64, v string, enableSep bool) *Raw { rl := &Raw{ id: id, buf: v, sepLoc: -1, displayString: "", dirty: false, } if !enableSep { return rl } if i := strings.IndexByte(rl.buf, '\000'); i != -1 { rl.sepLoc = i } return rl }
go
func NewRaw(id uint64, v string, enableSep bool) *Raw { rl := &Raw{ id: id, buf: v, sepLoc: -1, displayString: "", dirty: false, } if !enableSep { return rl } if i := strings.IndexByte(rl.buf, '\000'); i != -1 { rl.sepLoc = i } return rl }
[ "func", "NewRaw", "(", "id", "uint64", ",", "v", "string", ",", "enableSep", "bool", ")", "*", "Raw", "{", "rl", ":=", "&", "Raw", "{", "id", ":", "id", ",", "buf", ":", "v", ",", "sepLoc", ":", "-", "1", ",", "displayString", ":", "\"", "\"", ...
// NewRaw creates a new Raw. The `enableSep` flag tells // it if we should search for a null character to split the // string to display and the string to emit upon selection of // of said line
[ "NewRaw", "creates", "a", "new", "Raw", ".", "The", "enableSep", "flag", "tells", "it", "if", "we", "should", "search", "for", "a", "null", "character", "to", "split", "the", "string", "to", "display", "and", "the", "string", "to", "emit", "upon", "selec...
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/line/raw.go#L14-L31
12,319
peco/peco
line/raw.go
Less
func (rl *Raw) Less(b btree.Item) bool { return rl.id < b.(Line).ID() }
go
func (rl *Raw) Less(b btree.Item) bool { return rl.id < b.(Line).ID() }
[ "func", "(", "rl", "*", "Raw", ")", "Less", "(", "b", "btree", ".", "Item", ")", "bool", "{", "return", "rl", ".", "id", "<", "b", ".", "(", "Line", ")", ".", "ID", "(", ")", "\n", "}" ]
// Less implements the btree.Item interface
[ "Less", "implements", "the", "btree", ".", "Item", "interface" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/line/raw.go#L34-L36
12,320
peco/peco
line/raw.go
DisplayString
func (rl Raw) DisplayString() string { if rl.displayString != "" { return rl.displayString } if i := rl.sepLoc; i > -1 { rl.displayString = util.StripANSISequence(rl.buf[:i]) } else { rl.displayString = util.StripANSISequence(rl.buf) } return rl.displayString }
go
func (rl Raw) DisplayString() string { if rl.displayString != "" { return rl.displayString } if i := rl.sepLoc; i > -1 { rl.displayString = util.StripANSISequence(rl.buf[:i]) } else { rl.displayString = util.StripANSISequence(rl.buf) } return rl.displayString }
[ "func", "(", "rl", "Raw", ")", "DisplayString", "(", ")", "string", "{", "if", "rl", ".", "displayString", "!=", "\"", "\"", "{", "return", "rl", ".", "displayString", "\n", "}", "\n\n", "if", "i", ":=", "rl", ".", "sepLoc", ";", "i", ">", "-", "...
// DisplayString returns the string to be displayed
[ "DisplayString", "returns", "the", "string", "to", "be", "displayed" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/line/raw.go#L59-L70
12,321
peco/peco
config.go
Init
func (c *Config) Init() error { c.Keymap = make(map[string]string) c.InitialMatcher = IgnoreCaseMatch c.Style.Init() c.Prompt = "QUERY>" c.Layout = LayoutTypeTopDown return nil }
go
func (c *Config) Init() error { c.Keymap = make(map[string]string) c.InitialMatcher = IgnoreCaseMatch c.Style.Init() c.Prompt = "QUERY>" c.Layout = LayoutTypeTopDown return nil }
[ "func", "(", "c", "*", "Config", ")", "Init", "(", ")", "error", "{", "c", ".", "Keymap", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "c", ".", "InitialMatcher", "=", "IgnoreCaseMatch", "\n", "c", ".", "Style", ".", "Init", ...
// NewConfig creates a new Config
[ "NewConfig", "creates", "a", "new", "Config" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/config.go#L19-L26
12,322
peco/peco
config.go
ReadFilename
func (c *Config) ReadFilename(filename string) error { f, err := os.Open(filename) if err != nil { return errors.Wrapf(err, "failed to open file %s", filename) } defer f.Close() err = json.NewDecoder(f).Decode(c) if err != nil { return errors.Wrap(err, "failed to decode JSON") } if !IsValidLayoutType(Layo...
go
func (c *Config) ReadFilename(filename string) error { f, err := os.Open(filename) if err != nil { return errors.Wrapf(err, "failed to open file %s", filename) } defer f.Close() err = json.NewDecoder(f).Decode(c) if err != nil { return errors.Wrap(err, "failed to decode JSON") } if !IsValidLayoutType(Layo...
[ "func", "(", "c", "*", "Config", ")", "ReadFilename", "(", "filename", "string", ")", "error", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrapf", "(", "err", ...
// ReadFilename reads the config from the given file, and // does the appropriate processing, if any
[ "ReadFilename", "reads", "the", "config", "from", "the", "given", "file", "and", "does", "the", "appropriate", "processing", "if", "any" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/config.go#L30-L63
12,323
peco/peco
config.go
UnmarshalJSON
func (s *Style) UnmarshalJSON(buf []byte) error { raw := []string{} if err := json.Unmarshal(buf, &raw); err != nil { return errors.Wrapf(err, "failed to unmarshal Style") } return stringsToStyle(s, raw) }
go
func (s *Style) UnmarshalJSON(buf []byte) error { raw := []string{} if err := json.Unmarshal(buf, &raw); err != nil { return errors.Wrapf(err, "failed to unmarshal Style") } return stringsToStyle(s, raw) }
[ "func", "(", "s", "*", "Style", ")", "UnmarshalJSON", "(", "buf", "[", "]", "byte", ")", "error", "{", "raw", ":=", "[", "]", "string", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "buf", ",", "&", "raw", ")", ";", "err", ...
// UnmarshalJSON satisfies json.RawMessage.
[ "UnmarshalJSON", "satisfies", "json", ".", "RawMessage", "." ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/config.go#L119-L125
12,324
peco/peco
config.go
LocateRcfile
func LocateRcfile(locater configLocateFunc) (string, error) { // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html // // Try in this order: // $XDG_CONFIG_HOME/peco/config.json // $XDG_CONFIG_DIR/peco/config.json (where XDG_CONFIG_DIR is listed in $XDG_CONFIG_DIRS) // ~/.peco/config.js...
go
func LocateRcfile(locater configLocateFunc) (string, error) { // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html // // Try in this order: // $XDG_CONFIG_HOME/peco/config.json // $XDG_CONFIG_DIR/peco/config.json (where XDG_CONFIG_DIR is listed in $XDG_CONFIG_DIRS) // ~/.peco/config.js...
[ "func", "LocateRcfile", "(", "locater", "configLocateFunc", ")", "(", "string", ",", "error", ")", "{", "// http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html", "//", "// Try in this order:", "//\t $XDG_CONFIG_HOME/peco/config.json", "// $XDG_CONFIG_DIR/peco/c...
// LocateRcfile attempts to find the config file in various locations
[ "LocateRcfile", "attempts", "to", "find", "the", "config", "file", "in", "various", "locations" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/config.go#L170-L210
12,325
peco/peco
filter.go
flusher
func flusher(ctx context.Context, f filter.Filter, incoming chan []line.Line, done chan struct{}, out pipeline.ChanOutput) { if pdebug.Enabled { g := pdebug.Marker("flusher goroutine") defer g.End() } defer close(done) defer out.SendEndMark("end of filter") for { select { case <-ctx.Done(): return c...
go
func flusher(ctx context.Context, f filter.Filter, incoming chan []line.Line, done chan struct{}, out pipeline.ChanOutput) { if pdebug.Enabled { g := pdebug.Marker("flusher goroutine") defer g.End() } defer close(done) defer out.SendEndMark("end of filter") for { select { case <-ctx.Done(): return c...
[ "func", "flusher", "(", "ctx", "context", ".", "Context", ",", "f", "filter", ".", "Filter", ",", "incoming", "chan", "[", "]", "line", ".", "Line", ",", "done", "chan", "struct", "{", "}", ",", "out", "pipeline", ".", "ChanOutput", ")", "{", "if", ...
// This flusher is run in a separate goroutine so that the filter can // run separately from accepting incoming messages
[ "This", "flusher", "is", "run", "in", "a", "separate", "goroutine", "so", "that", "the", "filter", "can", "run", "separately", "from", "accepting", "incoming", "messages" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/filter.go#L30-L52
12,326
peco/peco
filter.go
Loop
func (f *Filter) Loop(ctx context.Context, cancel func()) error { defer cancel() // previous holds the function that can cancel the previous // query. This is used when multiple queries come in succession // and the previous query is discarded anyway var mutex sync.Mutex var previous func() for { select { c...
go
func (f *Filter) Loop(ctx context.Context, cancel func()) error { defer cancel() // previous holds the function that can cancel the previous // query. This is used when multiple queries come in succession // and the previous query is discarded anyway var mutex sync.Mutex var previous func() for { select { c...
[ "func", "(", "f", "*", "Filter", ")", "Loop", "(", "ctx", "context", ".", "Context", ",", "cancel", "func", "(", ")", ")", "error", "{", "defer", "cancel", "(", ")", "\n\n", "// previous holds the function that can cancel the previous", "// query. This is used whe...
// Loop keeps watching for incoming queries, and upon receiving // a query, spawns a goroutine to do the heavy work. It also // checks for previously running queries, so we can avoid // running many goroutines doing the grep at the same time
[ "Loop", "keeps", "watching", "for", "incoming", "queries", "and", "upon", "receiving", "a", "query", "spawns", "a", "goroutine", "to", "do", "the", "heavy", "work", ".", "It", "also", "checks", "for", "previously", "running", "queries", "so", "we", "can", ...
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/filter.go#L196-L226
12,327
peco/peco
page.go
Crop
func (pf PageCrop) Crop(in Buffer) *FilteredBuffer { return NewFilteredBuffer(in, pf.currentPage, pf.perPage) }
go
func (pf PageCrop) Crop(in Buffer) *FilteredBuffer { return NewFilteredBuffer(in, pf.currentPage, pf.perPage) }
[ "func", "(", "pf", "PageCrop", ")", "Crop", "(", "in", "Buffer", ")", "*", "FilteredBuffer", "{", "return", "NewFilteredBuffer", "(", "in", ",", "pf", ".", "currentPage", ",", "pf", ".", "perPage", ")", "\n", "}" ]
// Crop returns a new Buffer whose contents are // bound within the given range
[ "Crop", "returns", "a", "new", "Buffer", "whose", "contents", "are", "bound", "within", "the", "given", "range" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/page.go#L68-L70
12,328
peco/peco
source.go
Setup
func (s *Source) Setup(ctx context.Context, state *Peco) { s.setupOnce.Do(func() { done := make(chan struct{}) refresh := make(chan struct{}, 1) defer close(done) defer close(refresh) // And also, close the done channel so we can tell the consumers // we have finished reading everything defer close(s.set...
go
func (s *Source) Setup(ctx context.Context, state *Peco) { s.setupOnce.Do(func() { done := make(chan struct{}) refresh := make(chan struct{}, 1) defer close(done) defer close(refresh) // And also, close the done channel so we can tell the consumers // we have finished reading everything defer close(s.set...
[ "func", "(", "s", "*", "Source", ")", "Setup", "(", "ctx", "context", ".", "Context", ",", "state", "*", "Peco", ")", "{", "s", ".", "setupOnce", ".", "Do", "(", "func", "(", ")", "{", "done", ":=", "make", "(", "chan", "struct", "{", "}", ")",...
// Setup reads from the input os.File.
[ "Setup", "reads", "from", "the", "input", "os", ".", "File", "." ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/source.go#L39-L143
12,329
peco/peco
source.go
Reset
func (s *Source) Reset() { if pdebug.Enabled { g := pdebug.Marker("Source.Reset") defer g.End() } s.ChanOutput = pipeline.ChanOutput(make(chan interface{})) }
go
func (s *Source) Reset() { if pdebug.Enabled { g := pdebug.Marker("Source.Reset") defer g.End() } s.ChanOutput = pipeline.ChanOutput(make(chan interface{})) }
[ "func", "(", "s", "*", "Source", ")", "Reset", "(", ")", "{", "if", "pdebug", ".", "Enabled", "{", "g", ":=", "pdebug", ".", "Marker", "(", "\"", "\"", ")", "\n", "defer", "g", ".", "End", "(", ")", "\n", "}", "\n", "s", ".", "ChanOutput", "=...
// Reset resets the state of the source object so that it // is ready to feed the filters
[ "Reset", "resets", "the", "state", "of", "the", "source", "object", "so", "that", "it", "is", "ready", "to", "feed", "the", "filters" ]
967233e25328cb5d7065a5abb23cc8ed650a09b6
https://github.com/peco/peco/blob/967233e25328cb5d7065a5abb23cc8ed650a09b6/source.go#L223-L229
12,330
qor/worker
scheduler.go
GetScheduleTime
func (schedule Schedule) GetScheduleTime() *time.Time { if scheduleTime := schedule.ScheduleTime; scheduleTime != nil { if scheduleTime.After(time.Now().Add(time.Minute)) { return scheduleTime } } return nil }
go
func (schedule Schedule) GetScheduleTime() *time.Time { if scheduleTime := schedule.ScheduleTime; scheduleTime != nil { if scheduleTime.After(time.Now().Add(time.Minute)) { return scheduleTime } } return nil }
[ "func", "(", "schedule", "Schedule", ")", "GetScheduleTime", "(", ")", "*", "time", ".", "Time", "{", "if", "scheduleTime", ":=", "schedule", ".", "ScheduleTime", ";", "scheduleTime", "!=", "nil", "{", "if", "scheduleTime", ".", "After", "(", "time", ".", ...
// GetScheduleTime get scheduled time
[ "GetScheduleTime", "get", "scheduled", "time" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/scheduler.go#L16-L23
12,331
qor/worker
cron.go
Add
func (cron *Cron) Add(job QorJobInterface) (err error) { cron.parseJobs() defer cron.writeCronJob() var binaryFile string if binaryFile, err = filepath.Abs(os.Args[0]); err == nil { var jobs []*cronJob for _, cronJob := range cron.Jobs { if cronJob.JobID != job.GetJobID() { jobs = append(jobs, cronJob) ...
go
func (cron *Cron) Add(job QorJobInterface) (err error) { cron.parseJobs() defer cron.writeCronJob() var binaryFile string if binaryFile, err = filepath.Abs(os.Args[0]); err == nil { var jobs []*cronJob for _, cronJob := range cron.Jobs { if cronJob.JobID != job.GetJobID() { jobs = append(jobs, cronJob) ...
[ "func", "(", "cron", "*", "Cron", ")", "Add", "(", "job", "QorJobInterface", ")", "(", "err", "error", ")", "{", "cron", ".", "parseJobs", "(", ")", "\n", "defer", "cron", ".", "writeCronJob", "(", ")", "\n\n", "var", "binaryFile", "string", "\n", "i...
// Add a job to cron queue
[ "Add", "a", "job", "to", "cron", "queue" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/cron.go#L93-L126
12,332
qor/worker
cron.go
Run
func (cron *Cron) Run(qorJob QorJobInterface) error { job := qorJob.GetJob() if job.Handler != nil { go func() { sigint := make(chan os.Signal, 1) // interrupt signal sent from terminal signal.Notify(sigint, syscall.SIGINT) // sigterm signal sent from kubernetes signal.Notify(sigint, syscall.SIGTER...
go
func (cron *Cron) Run(qorJob QorJobInterface) error { job := qorJob.GetJob() if job.Handler != nil { go func() { sigint := make(chan os.Signal, 1) // interrupt signal sent from terminal signal.Notify(sigint, syscall.SIGINT) // sigterm signal sent from kubernetes signal.Notify(sigint, syscall.SIGTER...
[ "func", "(", "cron", "*", "Cron", ")", "Run", "(", "qorJob", "QorJobInterface", ")", "error", "{", "job", ":=", "qorJob", ".", "GetJob", "(", ")", "\n\n", "if", "job", ".", "Handler", "!=", "nil", "{", "go", "func", "(", ")", "{", "sigint", ":=", ...
// Run a job from cron queue
[ "Run", "a", "job", "from", "cron", "queue" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/cron.go#L129-L167
12,333
qor/worker
cron.go
Kill
func (cron *Cron) Kill(job QorJobInterface) (err error) { cron.parseJobs() defer cron.writeCronJob() for _, cronJob := range cron.Jobs { if cronJob.JobID == job.GetJobID() { if process, err := os.FindProcess(cronJob.Pid); err == nil { if err = process.Kill(); err == nil { cronJob.Delete = true re...
go
func (cron *Cron) Kill(job QorJobInterface) (err error) { cron.parseJobs() defer cron.writeCronJob() for _, cronJob := range cron.Jobs { if cronJob.JobID == job.GetJobID() { if process, err := os.FindProcess(cronJob.Pid); err == nil { if err = process.Kill(); err == nil { cronJob.Delete = true re...
[ "func", "(", "cron", "*", "Cron", ")", "Kill", "(", "job", "QorJobInterface", ")", "(", "err", "error", ")", "{", "cron", ".", "parseJobs", "(", ")", "\n", "defer", "cron", ".", "writeCronJob", "(", ")", "\n\n", "for", "_", ",", "cronJob", ":=", "r...
// Kill a job from cron queue
[ "Kill", "a", "job", "from", "cron", "queue" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/cron.go#L170-L186
12,334
qor/worker
cron.go
Remove
func (cron *Cron) Remove(job QorJobInterface) error { cron.parseJobs() defer cron.writeCronJob() for _, cronJob := range cron.Jobs { if cronJob.JobID == job.GetJobID() { if cronJob.Pid == 0 { cronJob.Delete = true return nil } return errors.New("failed to remove current job as it is running") }...
go
func (cron *Cron) Remove(job QorJobInterface) error { cron.parseJobs() defer cron.writeCronJob() for _, cronJob := range cron.Jobs { if cronJob.JobID == job.GetJobID() { if cronJob.Pid == 0 { cronJob.Delete = true return nil } return errors.New("failed to remove current job as it is running") }...
[ "func", "(", "cron", "*", "Cron", ")", "Remove", "(", "job", "QorJobInterface", ")", "error", "{", "cron", ".", "parseJobs", "(", ")", "\n", "defer", "cron", ".", "writeCronJob", "(", ")", "\n\n", "for", "_", ",", "cronJob", ":=", "range", "cron", "....
// Remove a job from cron queue
[ "Remove", "a", "job", "from", "cron", "queue" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/cron.go#L189-L203
12,335
qor/worker
worker.go
New
func New(config ...*Config) *Worker { var cfg = &Config{} if len(config) > 0 { cfg = config[0] } if cfg.Job == nil { cfg.Job = &QorJob{} } if cfg.Queue == nil { cfg.Queue = NewCronQueue() } return &Worker{Config: cfg} }
go
func New(config ...*Config) *Worker { var cfg = &Config{} if len(config) > 0 { cfg = config[0] } if cfg.Job == nil { cfg.Job = &QorJob{} } if cfg.Queue == nil { cfg.Queue = NewCronQueue() } return &Worker{Config: cfg} }
[ "func", "New", "(", "config", "...", "*", "Config", ")", "*", "Worker", "{", "var", "cfg", "=", "&", "Config", "{", "}", "\n", "if", "len", "(", "config", ")", ">", "0", "{", "cfg", "=", "config", "[", "0", "]", "\n", "}", "\n\n", "if", "cfg"...
// New create Worker with Config
[ "New", "create", "Worker", "with", "Config" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/worker.go#L35-L50
12,336
qor/worker
worker.go
ConfigureQorResourceBeforeInitialize
func (worker *Worker) ConfigureQorResourceBeforeInitialize(res resource.Resourcer) { if res, ok := res.(*admin.Resource); ok { res.GetAdmin().RegisterViewPath("github.com/qor/worker/views") res.UseTheme("worker") worker.Admin = res.GetAdmin() worker.JobResource = worker.Admin.NewResource(worker.Config.Job) ...
go
func (worker *Worker) ConfigureQorResourceBeforeInitialize(res resource.Resourcer) { if res, ok := res.(*admin.Resource); ok { res.GetAdmin().RegisterViewPath("github.com/qor/worker/views") res.UseTheme("worker") worker.Admin = res.GetAdmin() worker.JobResource = worker.Admin.NewResource(worker.Config.Job) ...
[ "func", "(", "worker", "*", "Worker", ")", "ConfigureQorResourceBeforeInitialize", "(", "res", "resource", ".", "Resourcer", ")", "{", "if", "res", ",", "ok", ":=", "res", ".", "(", "*", "admin", ".", "Resource", ")", ";", "ok", "{", "res", ".", "GetAd...
// ConfigureQorResourceBeforeInitialize a method used to config Worker for qor admin
[ "ConfigureQorResourceBeforeInitialize", "a", "method", "used", "to", "config", "Worker", "for", "qor", "admin" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/worker.go#L68-L134
12,337
qor/worker
worker.go
RegisterJob
func (worker *Worker) RegisterJob(job *Job) error { if worker.mounted { debug.PrintStack() fmt.Printf("Job should be registered before Worker mounted into admin, but %v is registered after that", job.Name) } job.Worker = worker worker.Jobs = append(worker.Jobs, job) return nil }
go
func (worker *Worker) RegisterJob(job *Job) error { if worker.mounted { debug.PrintStack() fmt.Printf("Job should be registered before Worker mounted into admin, but %v is registered after that", job.Name) } job.Worker = worker worker.Jobs = append(worker.Jobs, job) return nil }
[ "func", "(", "worker", "*", "Worker", ")", "RegisterJob", "(", "job", "*", "Job", ")", "error", "{", "if", "worker", ".", "mounted", "{", "debug", ".", "PrintStack", "(", ")", "\n", "fmt", ".", "Printf", "(", "\"", "\"", ",", "job", ".", "Name", ...
// RegisterJob register a job into Worker
[ "RegisterJob", "register", "a", "job", "into", "Worker" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/worker.go#L204-L213
12,338
qor/worker
worker.go
GetRegisteredJob
func (worker *Worker) GetRegisteredJob(name string) *Job { for _, job := range worker.Jobs { if job.Name == name { return job } } return nil }
go
func (worker *Worker) GetRegisteredJob(name string) *Job { for _, job := range worker.Jobs { if job.Name == name { return job } } return nil }
[ "func", "(", "worker", "*", "Worker", ")", "GetRegisteredJob", "(", "name", "string", ")", "*", "Job", "{", "for", "_", ",", "job", ":=", "range", "worker", ".", "Jobs", "{", "if", "job", ".", "Name", "==", "name", "{", "return", "job", "\n", "}", ...
// GetRegisteredJob register a job into Worker
[ "GetRegisteredJob", "register", "a", "job", "into", "Worker" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/worker.go#L216-L223
12,339
qor/worker
worker.go
GetJob
func (worker *Worker) GetJob(jobID string) (QorJobInterface, error) { qorJob := worker.JobResource.NewStruct().(QorJobInterface) context := worker.Admin.NewContext(nil, nil) context.ResourceID = jobID context.Resource = worker.JobResource if err := worker.JobResource.FindOneHandler(qorJob, nil, context.Context);...
go
func (worker *Worker) GetJob(jobID string) (QorJobInterface, error) { qorJob := worker.JobResource.NewStruct().(QorJobInterface) context := worker.Admin.NewContext(nil, nil) context.ResourceID = jobID context.Resource = worker.JobResource if err := worker.JobResource.FindOneHandler(qorJob, nil, context.Context);...
[ "func", "(", "worker", "*", "Worker", ")", "GetJob", "(", "jobID", "string", ")", "(", "QorJobInterface", ",", "error", ")", "{", "qorJob", ":=", "worker", ".", "JobResource", ".", "NewStruct", "(", ")", ".", "(", "QorJobInterface", ")", "\n\n", "context...
// GetJob get job with id
[ "GetJob", "get", "job", "with", "id" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/worker.go#L226-L243
12,340
qor/worker
worker.go
AddJob
func (worker *Worker) AddJob(qorJob QorJobInterface) error { return worker.Queue.Add(qorJob) }
go
func (worker *Worker) AddJob(qorJob QorJobInterface) error { return worker.Queue.Add(qorJob) }
[ "func", "(", "worker", "*", "Worker", ")", "AddJob", "(", "qorJob", "QorJobInterface", ")", "error", "{", "return", "worker", ".", "Queue", ".", "Add", "(", "qorJob", ")", "\n", "}" ]
// AddJob add job to worker
[ "AddJob", "add", "job", "to", "worker" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/worker.go#L246-L248
12,341
qor/worker
worker.go
RunJob
func (worker *Worker) RunJob(jobID string) error { qorJob, err := worker.GetJob(jobID) if qorJob != nil && err == nil { defer func() { if r := recover(); r != nil { qorJob.AddLog(string(debug.Stack())) qorJob.SetProgressText(fmt.Sprint(r)) qorJob.SetStatus(JobStatusException) } }() if qorJob...
go
func (worker *Worker) RunJob(jobID string) error { qorJob, err := worker.GetJob(jobID) if qorJob != nil && err == nil { defer func() { if r := recover(); r != nil { qorJob.AddLog(string(debug.Stack())) qorJob.SetProgressText(fmt.Sprint(r)) qorJob.SetStatus(JobStatusException) } }() if qorJob...
[ "func", "(", "worker", "*", "Worker", ")", "RunJob", "(", "jobID", "string", ")", "error", "{", "qorJob", ",", "err", ":=", "worker", ".", "GetJob", "(", "jobID", ")", "\n\n", "if", "qorJob", "!=", "nil", "&&", "err", "==", "nil", "{", "defer", "fu...
// RunJob run job with job id
[ "RunJob", "run", "job", "with", "job", "id" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/worker.go#L251-L278
12,342
qor/worker
worker.go
KillJob
func (worker *Worker) KillJob(jobID string) error { if qorJob, err := worker.GetJob(jobID); err == nil { if qorJob.GetStatus() == JobStatusRunning { if err = qorJob.GetJob().GetQueue().Kill(qorJob); err == nil { qorJob.SetStatus(JobStatusKilled) return nil } return err } else if qorJob.GetStatus()...
go
func (worker *Worker) KillJob(jobID string) error { if qorJob, err := worker.GetJob(jobID); err == nil { if qorJob.GetStatus() == JobStatusRunning { if err = qorJob.GetJob().GetQueue().Kill(qorJob); err == nil { qorJob.SetStatus(JobStatusKilled) return nil } return err } else if qorJob.GetStatus()...
[ "func", "(", "worker", "*", "Worker", ")", "KillJob", "(", "jobID", "string", ")", "error", "{", "if", "qorJob", ",", "err", ":=", "worker", ".", "GetJob", "(", "jobID", ")", ";", "err", "==", "nil", "{", "if", "qorJob", ".", "GetStatus", "(", ")",...
// KillJob kill job with job id
[ "KillJob", "kill", "job", "with", "job", "id" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/worker.go#L297-L314
12,343
qor/worker
worker.go
RemoveJob
func (worker *Worker) RemoveJob(jobID string) error { qorJob, err := worker.GetJob(jobID) if err == nil { return qorJob.GetJob().GetQueue().Remove(qorJob) } return err }
go
func (worker *Worker) RemoveJob(jobID string) error { qorJob, err := worker.GetJob(jobID) if err == nil { return qorJob.GetJob().GetQueue().Remove(qorJob) } return err }
[ "func", "(", "worker", "*", "Worker", ")", "RemoveJob", "(", "jobID", "string", ")", "error", "{", "qorJob", ",", "err", ":=", "worker", ".", "GetJob", "(", "jobID", ")", "\n", "if", "err", "==", "nil", "{", "return", "qorJob", ".", "GetJob", "(", ...
// RemoveJob remove job with job id
[ "RemoveJob", "remove", "job", "with", "job", "id" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/worker.go#L317-L323
12,344
qor/worker
job.go
NewStruct
func (job *Job) NewStruct() interface{} { qorJobInterface := job.Worker.JobResource.NewStruct().(QorJobInterface) qorJobInterface.SetJob(job) return qorJobInterface }
go
func (job *Job) NewStruct() interface{} { qorJobInterface := job.Worker.JobResource.NewStruct().(QorJobInterface) qorJobInterface.SetJob(job) return qorJobInterface }
[ "func", "(", "job", "*", "Job", ")", "NewStruct", "(", ")", "interface", "{", "}", "{", "qorJobInterface", ":=", "job", ".", "Worker", ".", "JobResource", ".", "NewStruct", "(", ")", ".", "(", "QorJobInterface", ")", "\n", "qorJobInterface", ".", "SetJob...
// NewStruct initialize job struct
[ "NewStruct", "initialize", "job", "struct" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/job.go#L21-L25
12,345
qor/worker
job.go
GetQueue
func (job *Job) GetQueue() Queue { if job.Queue != nil { return job.Queue } return job.Worker.Queue }
go
func (job *Job) GetQueue() Queue { if job.Queue != nil { return job.Queue } return job.Worker.Queue }
[ "func", "(", "job", "*", "Job", ")", "GetQueue", "(", ")", "Queue", "{", "if", "job", ".", "Queue", "!=", "nil", "{", "return", "job", ".", "Queue", "\n", "}", "\n", "return", "job", ".", "Worker", ".", "Queue", "\n", "}" ]
// GetQueue get defined job's queue
[ "GetQueue", "get", "defined", "job", "s", "queue" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/job.go#L28-L33
12,346
qor/worker
queue/kubernetes/kubernetes.go
New
func New(config *Config) (*Kubernetes, error) { var err error if config == nil { config = &Config{} } if config.ClusterConfig == nil { config.ClusterConfig, err = rest.InClusterConfig() } if err != nil { return nil, err } clientset, err := kubernetes.NewForConfig(config.ClusterConfig) if err != nil {...
go
func New(config *Config) (*Kubernetes, error) { var err error if config == nil { config = &Config{} } if config.ClusterConfig == nil { config.ClusterConfig, err = rest.InClusterConfig() } if err != nil { return nil, err } clientset, err := kubernetes.NewForConfig(config.ClusterConfig) if err != nil {...
[ "func", "New", "(", "config", "*", "Config", ")", "(", "*", "Kubernetes", ",", "error", ")", "{", "var", "err", "error", "\n\n", "if", "config", "==", "nil", "{", "config", "=", "&", "Config", "{", "}", "\n", "}", "\n\n", "if", "config", ".", "Cl...
// New initialize Kubernetes
[ "New", "initialize", "Kubernetes" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/queue/kubernetes/kubernetes.go#L36-L57
12,347
qor/worker
queue/kubernetes/kubernetes.go
GetCurrentPod
func (k8s *Kubernetes) GetCurrentPod() *corev1.Pod { var ( podlist, err = k8s.Clientset.Core().Pods("").List(metav1.ListOptions{}) localeIP = GetLocalIP() ) if err == nil { for _, item := range podlist.Items { if item.Status.PodIP == localeIP { return &item } } } return nil }
go
func (k8s *Kubernetes) GetCurrentPod() *corev1.Pod { var ( podlist, err = k8s.Clientset.Core().Pods("").List(metav1.ListOptions{}) localeIP = GetLocalIP() ) if err == nil { for _, item := range podlist.Items { if item.Status.PodIP == localeIP { return &item } } } return nil }
[ "func", "(", "k8s", "*", "Kubernetes", ")", "GetCurrentPod", "(", ")", "*", "corev1", ".", "Pod", "{", "var", "(", "podlist", ",", "err", "=", "k8s", ".", "Clientset", ".", "Core", "(", ")", ".", "Pods", "(", "\"", "\"", ")", ".", "List", "(", ...
// GetCurrentPod get current pod
[ "GetCurrentPod", "get", "current", "pod" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/queue/kubernetes/kubernetes.go#L60-L74
12,348
qor/worker
queue/kubernetes/kubernetes.go
GetJobSpec
func (k8s *Kubernetes) GetJobSpec(qorJob worker.QorJobInterface) (*v1.Job, error) { var ( k8sJob = &v1.Job{} currentPod = k8s.GetCurrentPod() namespace = currentPod.GetNamespace() ) if k8s.Config.Namespace != "" { namespace = k8s.Config.Namespace } if k8s.Config.JobTemplateMaker != nil { if err :=...
go
func (k8s *Kubernetes) GetJobSpec(qorJob worker.QorJobInterface) (*v1.Job, error) { var ( k8sJob = &v1.Job{} currentPod = k8s.GetCurrentPod() namespace = currentPod.GetNamespace() ) if k8s.Config.Namespace != "" { namespace = k8s.Config.Namespace } if k8s.Config.JobTemplateMaker != nil { if err :=...
[ "func", "(", "k8s", "*", "Kubernetes", ")", "GetJobSpec", "(", "qorJob", "worker", ".", "QorJobInterface", ")", "(", "*", "v1", ".", "Job", ",", "error", ")", "{", "var", "(", "k8sJob", "=", "&", "v1", ".", "Job", "{", "}", "\n", "currentPod", "=",...
// GetJobSpec get job spec
[ "GetJobSpec", "get", "job", "spec" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/queue/kubernetes/kubernetes.go#L77-L118
12,349
qor/worker
queue/kubernetes/kubernetes.go
Add
func (k8s *Kubernetes) Add(qorJob worker.QorJobInterface) error { var ( jobName = fmt.Sprintf("qor-job-%v", qorJob.GetJobID()) k8sJob, err = k8s.GetJobSpec(qorJob) currentPath, _ = os.Getwd() binaryFile, _ = filepath.Abs(os.Args[0]) ) if err == nil { k8sJob.ObjectMeta.Name = jobName k8sJob.Sp...
go
func (k8s *Kubernetes) Add(qorJob worker.QorJobInterface) error { var ( jobName = fmt.Sprintf("qor-job-%v", qorJob.GetJobID()) k8sJob, err = k8s.GetJobSpec(qorJob) currentPath, _ = os.Getwd() binaryFile, _ = filepath.Abs(os.Args[0]) ) if err == nil { k8sJob.ObjectMeta.Name = jobName k8sJob.Sp...
[ "func", "(", "k8s", "*", "Kubernetes", ")", "Add", "(", "qorJob", "worker", ".", "QorJobInterface", ")", "error", "{", "var", "(", "jobName", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "qorJob", ".", "GetJobID", "(", ")", ")", "\n", "k8sJob", ...
// Add a job to k8s queue
[ "Add", "a", "job", "to", "k8s", "queue" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/queue/kubernetes/kubernetes.go#L121-L151
12,350
qor/worker
queue/kubernetes/kubernetes.go
Run
func (k8s *Kubernetes) Run(qorJob worker.QorJobInterface) error { job := qorJob.GetJob() if job.Handler != nil { return job.Handler(qorJob.GetSerializableArgument(qorJob), qorJob) } return errors.New("no handler found for job " + job.Name) }
go
func (k8s *Kubernetes) Run(qorJob worker.QorJobInterface) error { job := qorJob.GetJob() if job.Handler != nil { return job.Handler(qorJob.GetSerializableArgument(qorJob), qorJob) } return errors.New("no handler found for job " + job.Name) }
[ "func", "(", "k8s", "*", "Kubernetes", ")", "Run", "(", "qorJob", "worker", ".", "QorJobInterface", ")", "error", "{", "job", ":=", "qorJob", ".", "GetJob", "(", ")", "\n\n", "if", "job", ".", "Handler", "!=", "nil", "{", "return", "job", ".", "Handl...
// Run a job from k8s queue
[ "Run", "a", "job", "from", "k8s", "queue" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/queue/kubernetes/kubernetes.go#L154-L162
12,351
qor/worker
queue/kubernetes/kubernetes.go
Kill
func (k8s *Kubernetes) Kill(qorJob worker.QorJobInterface) error { var ( k8sJob, err = k8s.GetJobSpec(qorJob) jobName = fmt.Sprintf("qor-job-%v", qorJob.GetJobID()) ) if err == nil { return k8s.Clientset.Batch().Jobs(k8sJob.ObjectMeta.GetNamespace()).Delete(jobName, &metav1.DeleteOptions{}) } return err...
go
func (k8s *Kubernetes) Kill(qorJob worker.QorJobInterface) error { var ( k8sJob, err = k8s.GetJobSpec(qorJob) jobName = fmt.Sprintf("qor-job-%v", qorJob.GetJobID()) ) if err == nil { return k8s.Clientset.Batch().Jobs(k8sJob.ObjectMeta.GetNamespace()).Delete(jobName, &metav1.DeleteOptions{}) } return err...
[ "func", "(", "k8s", "*", "Kubernetes", ")", "Kill", "(", "qorJob", "worker", ".", "QorJobInterface", ")", "error", "{", "var", "(", "k8sJob", ",", "err", "=", "k8s", ".", "GetJobSpec", "(", "qorJob", ")", "\n", "jobName", "=", "fmt", ".", "Sprintf", ...
// Kill a job from k8s queue
[ "Kill", "a", "job", "from", "k8s", "queue" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/queue/kubernetes/kubernetes.go#L165-L175
12,352
qor/worker
qor_job.go
Scan
func (resultsTable *ResultsTable) Scan(data interface{}) error { switch values := data.(type) { case []byte: return json.Unmarshal(values, resultsTable) case string: return resultsTable.Scan([]byte(values)) default: return errors.New("unsupported data type for Qor Job error table") } }
go
func (resultsTable *ResultsTable) Scan(data interface{}) error { switch values := data.(type) { case []byte: return json.Unmarshal(values, resultsTable) case string: return resultsTable.Scan([]byte(values)) default: return errors.New("unsupported data type for Qor Job error table") } }
[ "func", "(", "resultsTable", "*", "ResultsTable", ")", "Scan", "(", "data", "interface", "{", "}", ")", "error", "{", "switch", "values", ":=", "data", ".", "(", "type", ")", "{", "case", "[", "]", "byte", ":", "return", "json", ".", "Unmarshal", "("...
// Scan used to scan value from database into itself
[ "Scan", "used", "to", "scan", "value", "from", "database", "into", "itself" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/qor_job.go#L51-L60
12,353
qor/worker
qor_job.go
Value
func (resultsTable ResultsTable) Value() (driver.Value, error) { result, err := json.Marshal(resultsTable) return string(result), err }
go
func (resultsTable ResultsTable) Value() (driver.Value, error) { result, err := json.Marshal(resultsTable) return string(result), err }
[ "func", "(", "resultsTable", "ResultsTable", ")", "Value", "(", ")", "(", "driver", ".", "Value", ",", "error", ")", "{", "result", ",", "err", ":=", "json", ".", "Marshal", "(", "resultsTable", ")", "\n", "return", "string", "(", "result", ")", ",", ...
// Value used to read value from itself and save it into databae
[ "Value", "used", "to", "read", "value", "from", "itself", "and", "save", "it", "into", "databae" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/qor_job.go#L63-L66
12,354
qor/worker
qor_job.go
SetStatus
func (job *QorJob) SetStatus(status string) error { job.mutex.Lock() defer job.mutex.Unlock() job.Status = status if status == JobStatusDone { job.Progress = 100 } if job.shouldCallSave() { return job.callSave() } return nil }
go
func (job *QorJob) SetStatus(status string) error { job.mutex.Lock() defer job.mutex.Unlock() job.Status = status if status == JobStatusDone { job.Progress = 100 } if job.shouldCallSave() { return job.callSave() } return nil }
[ "func", "(", "job", "*", "QorJob", ")", "SetStatus", "(", "status", "string", ")", "error", "{", "job", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "job", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "job", ".", "Status", "=", "status", ...
// SetStatus set job's status to a qor job instance
[ "SetStatus", "set", "job", "s", "status", "to", "a", "qor", "job", "instance" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/qor_job.go#L114-L128
12,355
qor/worker
qor_job.go
SetJob
func (job *QorJob) SetJob(j *Job) { job.Kind = j.Name job.Job = j }
go
func (job *QorJob) SetJob(j *Job) { job.Kind = j.Name job.Job = j }
[ "func", "(", "job", "*", "QorJob", ")", "SetJob", "(", "j", "*", "Job", ")", "{", "job", ".", "Kind", "=", "j", ".", "Name", "\n", "job", ".", "Job", "=", "j", "\n", "}" ]
// SetJob set `Job` for a qor job instance
[ "SetJob", "set", "Job", "for", "a", "qor", "job", "instance" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/qor_job.go#L183-L186
12,356
qor/worker
qor_job.go
GetJob
func (job *QorJob) GetJob() *Job { if job.Job != nil { return job.Job } return nil }
go
func (job *QorJob) GetJob() *Job { if job.Job != nil { return job.Job } return nil }
[ "func", "(", "job", "*", "QorJob", ")", "GetJob", "(", ")", "*", "Job", "{", "if", "job", ".", "Job", "!=", "nil", "{", "return", "job", ".", "Job", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// GetJob get predefined job for a qor job instance
[ "GetJob", "get", "predefined", "job", "for", "a", "qor", "job", "instance" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/qor_job.go#L189-L194
12,357
qor/worker
qor_job.go
GetSerializableArgumentResource
func (job *QorJob) GetSerializableArgumentResource() *admin.Resource { if j := job.GetJob(); j != nil { return j.Resource } return nil }
go
func (job *QorJob) GetSerializableArgumentResource() *admin.Resource { if j := job.GetJob(); j != nil { return j.Resource } return nil }
[ "func", "(", "job", "*", "QorJob", ")", "GetSerializableArgumentResource", "(", ")", "*", "admin", ".", "Resource", "{", "if", "j", ":=", "job", ".", "GetJob", "(", ")", ";", "j", "!=", "nil", "{", "return", "j", ".", "Resource", "\n", "}", "\n", "...
// GetSerializableArgumentResource get job's argument's resource
[ "GetSerializableArgumentResource", "get", "job", "s", "argument", "s", "resource" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/qor_job.go#L202-L207
12,358
qor/worker
qor_job.go
SetProgress
func (job *QorJob) SetProgress(progress uint) error { job.mutex.Lock() defer job.mutex.Unlock() if progress > 100 { progress = 100 } job.Progress = progress if job.shouldCallSave() { return job.callSave() } return nil }
go
func (job *QorJob) SetProgress(progress uint) error { job.mutex.Lock() defer job.mutex.Unlock() if progress > 100 { progress = 100 } job.Progress = progress if job.shouldCallSave() { return job.callSave() } return nil }
[ "func", "(", "job", "*", "QorJob", ")", "SetProgress", "(", "progress", "uint", ")", "error", "{", "job", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "job", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "if", "progress", ">", "100", "{", ...
// SetProgress set qor job's progress
[ "SetProgress", "set", "qor", "job", "s", "progress" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/qor_job.go#L215-L229
12,359
qor/worker
qor_job.go
SetProgressText
func (job *QorJob) SetProgressText(str string) error { job.mutex.Lock() defer job.mutex.Unlock() job.ProgressText = str if job.shouldCallSave() { return job.callSave() } return nil }
go
func (job *QorJob) SetProgressText(str string) error { job.mutex.Lock() defer job.mutex.Unlock() job.ProgressText = str if job.shouldCallSave() { return job.callSave() } return nil }
[ "func", "(", "job", "*", "QorJob", ")", "SetProgressText", "(", "str", "string", ")", "error", "{", "job", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "job", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "job", ".", "ProgressText", "=", "s...
// SetProgressText set qor job's progress text
[ "SetProgressText", "set", "qor", "job", "s", "progress", "text" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/qor_job.go#L237-L247
12,360
qor/worker
qor_job.go
AddLog
func (job *QorJob) AddLog(log string) error { job.mutex.Lock() defer job.mutex.Unlock() fmt.Println(log) job.Log += "\n" + log if job.shouldCallSave() { return job.callSave() } return nil }
go
func (job *QorJob) AddLog(log string) error { job.mutex.Lock() defer job.mutex.Unlock() fmt.Println(log) job.Log += "\n" + log if job.shouldCallSave() { return job.callSave() } return nil }
[ "func", "(", "job", "*", "QorJob", ")", "AddLog", "(", "log", "string", ")", "error", "{", "job", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "job", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "fmt", ".", "Println", "(", "log", ")", ...
// AddLog add a log to qor job
[ "AddLog", "add", "a", "log", "to", "qor", "job" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/qor_job.go#L255-L266
12,361
qor/worker
qor_job.go
AddResultsRow
func (job *QorJob) AddResultsRow(cells ...TableCell) error { job.mutex.Lock() defer job.mutex.Unlock() job.ResultsTable.TableCells = append(job.ResultsTable.TableCells, cells) if job.shouldCallSave() { return job.callSave() } return nil }
go
func (job *QorJob) AddResultsRow(cells ...TableCell) error { job.mutex.Lock() defer job.mutex.Unlock() job.ResultsTable.TableCells = append(job.ResultsTable.TableCells, cells) if job.shouldCallSave() { return job.callSave() } return nil }
[ "func", "(", "job", "*", "QorJob", ")", "AddResultsRow", "(", "cells", "...", "TableCell", ")", "error", "{", "job", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "job", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "job", ".", "ResultsTable",...
// AddResultsRow add a row of process results to a job
[ "AddResultsRow", "add", "a", "row", "of", "process", "results", "to", "a", "job" ]
5c9381791cdc76758df130894aa232d2e62a2ba7
https://github.com/qor/worker/blob/5c9381791cdc76758df130894aa232d2e62a2ba7/qor_job.go#L274-L284
12,362
google/badwolf
tools/vcli/bw/common/common.go
ParseChannelSizeFlag
func ParseChannelSizeFlag(flag string) (int, error) { ss := strings.Split(flag, "=") if len(ss) != 2 { return 0, fmt.Errorf("Failed split flag %s", flag) } if ss[0] != "--channel_size" { return 0, fmt.Errorf("Unknown flag %s", flag) } return strconv.Atoi(ss[1]) }
go
func ParseChannelSizeFlag(flag string) (int, error) { ss := strings.Split(flag, "=") if len(ss) != 2 { return 0, fmt.Errorf("Failed split flag %s", flag) } if ss[0] != "--channel_size" { return 0, fmt.Errorf("Unknown flag %s", flag) } return strconv.Atoi(ss[1]) }
[ "func", "ParseChannelSizeFlag", "(", "flag", "string", ")", "(", "int", ",", "error", ")", "{", "ss", ":=", "strings", ".", "Split", "(", "flag", ",", "\"", "\"", ")", "\n", "if", "len", "(", "ss", ")", "!=", "2", "{", "return", "0", ",", "fmt", ...
// ParseChannelSizeFlag attempts to parse the "channel_size" flag.
[ "ParseChannelSizeFlag", "attempts", "to", "parse", "the", "channel_size", "flag", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/common/common.go#L41-L50
12,363
google/badwolf
tools/vcli/bw/common/common.go
Help
func Help(args []string, cmds []*command.Command) int { var ( cmd string ) if len(args) >= 3 { cmd = args[2] } // Prints the help if the command exist. for _, c := range cmds { if c.Name() == cmd { return c.Usage() } } if cmd == "" { fmt.Fprintf(os.Stderr, "missing help command. Usage:\n\n\t$ bw he...
go
func Help(args []string, cmds []*command.Command) int { var ( cmd string ) if len(args) >= 3 { cmd = args[2] } // Prints the help if the command exist. for _, c := range cmds { if c.Name() == cmd { return c.Usage() } } if cmd == "" { fmt.Fprintf(os.Stderr, "missing help command. Usage:\n\n\t$ bw he...
[ "func", "Help", "(", "args", "[", "]", "string", ",", "cmds", "[", "]", "*", "command", ".", "Command", ")", "int", "{", "var", "(", "cmd", "string", "\n", ")", "\n", "if", "len", "(", "args", ")", ">=", "3", "{", "cmd", "=", "args", "[", "2"...
// Help prints the requested help
[ "Help", "prints", "the", "requested", "help" ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/common/common.go#L53-L85
12,364
google/badwolf
tools/vcli/bw/common/common.go
InitializeDriver
func InitializeDriver(driverName string, drivers map[string]StoreGenerator) (storage.Store, error) { f, ok := drivers[driverName] if !ok { var ds []string for k := range drivers { ds = append(ds, k) } return nil, fmt.Errorf("unknown driver name %q; valid drivers [%q]", driverName, strings.Join(ds, ", ")) ...
go
func InitializeDriver(driverName string, drivers map[string]StoreGenerator) (storage.Store, error) { f, ok := drivers[driverName] if !ok { var ds []string for k := range drivers { ds = append(ds, k) } return nil, fmt.Errorf("unknown driver name %q; valid drivers [%q]", driverName, strings.Join(ds, ", ")) ...
[ "func", "InitializeDriver", "(", "driverName", "string", ",", "drivers", "map", "[", "string", "]", "StoreGenerator", ")", "(", "storage", ".", "Store", ",", "error", ")", "{", "f", ",", "ok", ":=", "drivers", "[", "driverName", "]", "\n", "if", "!", "...
// InitializeDriver attempts to initialize the driver.
[ "InitializeDriver", "attempts", "to", "initialize", "the", "driver", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/common/common.go#L91-L101
12,365
google/badwolf
tools/vcli/bw/common/common.go
InitializeCommands
func InitializeCommands(driver storage.Store, chanSize, bulkTripleOpSize, builderSize int, rl repl.ReadLiner, done chan bool) []*command.Command { return []*command.Command{ assert.New(driver, literal.DefaultBuilder(), chanSize, bulkTripleOpSize), benchmark.New(driver, chanSize, bulkTripleOpSize), export.New(dri...
go
func InitializeCommands(driver storage.Store, chanSize, bulkTripleOpSize, builderSize int, rl repl.ReadLiner, done chan bool) []*command.Command { return []*command.Command{ assert.New(driver, literal.DefaultBuilder(), chanSize, bulkTripleOpSize), benchmark.New(driver, chanSize, bulkTripleOpSize), export.New(dri...
[ "func", "InitializeCommands", "(", "driver", "storage", ".", "Store", ",", "chanSize", ",", "bulkTripleOpSize", ",", "builderSize", "int", ",", "rl", "repl", ".", "ReadLiner", ",", "done", "chan", "bool", ")", "[", "]", "*", "command", ".", "Command", "{",...
// InitializeCommands initializes the available commands with the given storage // instance.
[ "InitializeCommands", "initializes", "the", "available", "commands", "with", "the", "given", "storage", "instance", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/common/common.go#L105-L116
12,366
google/badwolf
tools/vcli/bw/common/common.go
Eval
func Eval(ctx context.Context, args []string, cmds []*command.Command) int { // Retrieve the provided command. if len(args) < 1 { return Help(args, cmds) } cmd := args[0] // Check for help request. if cmd == "help" { return Help(args, cmds) } // Run the requested command. for _, c := range cmds { if c.Na...
go
func Eval(ctx context.Context, args []string, cmds []*command.Command) int { // Retrieve the provided command. if len(args) < 1 { return Help(args, cmds) } cmd := args[0] // Check for help request. if cmd == "help" { return Help(args, cmds) } // Run the requested command. for _, c := range cmds { if c.Na...
[ "func", "Eval", "(", "ctx", "context", ".", "Context", ",", "args", "[", "]", "string", ",", "cmds", "[", "]", "*", "command", ".", "Command", ")", "int", "{", "// Retrieve the provided command.", "if", "len", "(", "args", ")", "<", "1", "{", "return",...
// Eval of the command line version tool. This allows injecting multiple // drivers.
[ "Eval", "of", "the", "command", "line", "version", "tool", ".", "This", "allows", "injecting", "multiple", "drivers", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/common/common.go#L120-L141
12,367
google/badwolf
tools/vcli/bw/common/common.go
Run
func Run(driverName string, args []string, drivers map[string]StoreGenerator, chanSize, bulkTripleOpSize, builderSize int, rl repl.ReadLiner) int { driver, err := InitializeDriver(driverName, drivers) if err != nil { fmt.Fprintln(os.Stderr, err) return 2 } return Eval(context.Background(), args, InitializeComma...
go
func Run(driverName string, args []string, drivers map[string]StoreGenerator, chanSize, bulkTripleOpSize, builderSize int, rl repl.ReadLiner) int { driver, err := InitializeDriver(driverName, drivers) if err != nil { fmt.Fprintln(os.Stderr, err) return 2 } return Eval(context.Background(), args, InitializeComma...
[ "func", "Run", "(", "driverName", "string", ",", "args", "[", "]", "string", ",", "drivers", "map", "[", "string", "]", "StoreGenerator", ",", "chanSize", ",", "bulkTripleOpSize", ",", "builderSize", "int", ",", "rl", "repl", ".", "ReadLiner", ")", "int", ...
// Run executes the main of the command line tool.
[ "Run", "executes", "the", "main", "of", "the", "command", "line", "tool", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/common/common.go#L144-L151
12,368
google/badwolf
storage/memoization/memoization.go
Name
func (s *storeMemoizer) Name(ctx context.Context) string { return s.s.Name(ctx) }
go
func (s *storeMemoizer) Name(ctx context.Context) string { return s.s.Name(ctx) }
[ "func", "(", "s", "*", "storeMemoizer", ")", "Name", "(", "ctx", "context", ".", "Context", ")", "string", "{", "return", "s", ".", "s", ".", "Name", "(", "ctx", ")", "\n", "}" ]
// Name returns the ID of the backend being used.
[ "Name", "returns", "the", "ID", "of", "the", "backend", "being", "used", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/storage/memoization/memoization.go#L46-L48
12,369
google/badwolf
storage/memoization/memoization.go
Version
func (s *storeMemoizer) Version(ctx context.Context) string { return s.s.Version(ctx) }
go
func (s *storeMemoizer) Version(ctx context.Context) string { return s.s.Version(ctx) }
[ "func", "(", "s", "*", "storeMemoizer", ")", "Version", "(", "ctx", "context", ".", "Context", ")", "string", "{", "return", "s", ".", "s", ".", "Version", "(", "ctx", ")", "\n", "}" ]
// Version returns the version of the driver implementation.
[ "Version", "returns", "the", "version", "of", "the", "driver", "implementation", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/storage/memoization/memoization.go#L51-L53
12,370
google/badwolf
storage/memoization/memoization.go
NewGraph
func (s *storeMemoizer) NewGraph(ctx context.Context, id string) (storage.Graph, error) { g, err := s.s.NewGraph(ctx, id) if err != nil { return nil, err } return &graphMemoizer{ g: g, memN: make(map[string][]*node.Node), memP: make(map[string][]*predicate.Predicate), memO: make(map[string][]*triple.Ob...
go
func (s *storeMemoizer) NewGraph(ctx context.Context, id string) (storage.Graph, error) { g, err := s.s.NewGraph(ctx, id) if err != nil { return nil, err } return &graphMemoizer{ g: g, memN: make(map[string][]*node.Node), memP: make(map[string][]*predicate.Predicate), memO: make(map[string][]*triple.Ob...
[ "func", "(", "s", "*", "storeMemoizer", ")", "NewGraph", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "(", "storage", ".", "Graph", ",", "error", ")", "{", "g", ",", "err", ":=", "s", ".", "s", ".", "NewGraph", "(", "ctx", ","...
// NewGraph creates a new graph. Creating an already existing graph // should return an error.
[ "NewGraph", "creates", "a", "new", "graph", ".", "Creating", "an", "already", "existing", "graph", "should", "return", "an", "error", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/storage/memoization/memoization.go#L57-L70
12,371
google/badwolf
storage/memoization/memoization.go
ID
func (g *graphMemoizer) ID(ctx context.Context) string { return g.g.ID(ctx) }
go
func (g *graphMemoizer) ID(ctx context.Context) string { return g.g.ID(ctx) }
[ "func", "(", "g", "*", "graphMemoizer", ")", "ID", "(", "ctx", "context", ".", "Context", ")", "string", "{", "return", "g", ".", "g", ".", "ID", "(", "ctx", ")", "\n", "}" ]
// ID returns the id for this graph.
[ "ID", "returns", "the", "id", "for", "this", "graph", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/storage/memoization/memoization.go#L113-L115
12,372
google/badwolf
storage/memoization/memoization.go
AddTriples
func (g *graphMemoizer) AddTriples(ctx context.Context, ts []*triple.Triple) error { g.mu.Lock() // Update operations reset the memoization. g.memN = make(map[string][]*node.Node) g.memP = make(map[string][]*predicate.Predicate) g.memO = make(map[string][]*triple.Object) g.memT = make(map[string][]*triple.Triple)...
go
func (g *graphMemoizer) AddTriples(ctx context.Context, ts []*triple.Triple) error { g.mu.Lock() // Update operations reset the memoization. g.memN = make(map[string][]*node.Node) g.memP = make(map[string][]*predicate.Predicate) g.memO = make(map[string][]*triple.Object) g.memT = make(map[string][]*triple.Triple)...
[ "func", "(", "g", "*", "graphMemoizer", ")", "AddTriples", "(", "ctx", "context", ".", "Context", ",", "ts", "[", "]", "*", "triple", ".", "Triple", ")", "error", "{", "g", ".", "mu", ".", "Lock", "(", ")", "\n", "// Update operations reset the memoizati...
// AddTriples adds the triples to the storage. Adding a triple that already // exists should not fail.
[ "AddTriples", "adds", "the", "triples", "to", "the", "storage", ".", "Adding", "a", "triple", "that", "already", "exists", "should", "not", "fail", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/storage/memoization/memoization.go#L119-L130
12,373
google/badwolf
storage/memoization/memoization.go
Objects
func (g *graphMemoizer) Objects(ctx context.Context, s *node.Node, p *predicate.Predicate, lo *storage.LookupOptions, objs chan<- *triple.Object) error { k := combinedUUID("Objects", lo, s.UUID(), p.UUID()) g.mu.RLock() v := g.memO[k] g.mu.RUnlock() if v != nil { // Return the memoized results. defer close(obj...
go
func (g *graphMemoizer) Objects(ctx context.Context, s *node.Node, p *predicate.Predicate, lo *storage.LookupOptions, objs chan<- *triple.Object) error { k := combinedUUID("Objects", lo, s.UUID(), p.UUID()) g.mu.RLock() v := g.memO[k] g.mu.RUnlock() if v != nil { // Return the memoized results. defer close(obj...
[ "func", "(", "g", "*", "graphMemoizer", ")", "Objects", "(", "ctx", "context", ".", "Context", ",", "s", "*", "node", ".", "Node", ",", "p", "*", "predicate", ".", "Predicate", ",", "lo", "*", "storage", ".", "LookupOptions", ",", "objs", "chan", "<-...
// Objects pushes to the provided channel the objects for the given object and // predicate. The function does not return immediately. // // Given a subject and a predicate, this method retrieves the objects of // triples that match them. By default, if does not limit the maximum number // of possible objects returned,...
[ "Objects", "pushes", "to", "the", "provided", "channel", "the", "objects", "for", "the", "given", "object", "and", "predicate", ".", "The", "function", "does", "not", "return", "immediately", ".", "Given", "a", "subject", "and", "a", "predicate", "this", "me...
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/storage/memoization/memoization.go#L173-L221
12,374
google/badwolf
storage/memoization/memoization.go
Subjects
func (g *graphMemoizer) Subjects(ctx context.Context, p *predicate.Predicate, o *triple.Object, lo *storage.LookupOptions, subs chan<- *node.Node) error { k := combinedUUID("Subjects", lo, p.UUID(), o.UUID()) g.mu.RLock() v := g.memN[k] g.mu.RUnlock() if v != nil { // Return the memoized results. defer close(s...
go
func (g *graphMemoizer) Subjects(ctx context.Context, p *predicate.Predicate, o *triple.Object, lo *storage.LookupOptions, subs chan<- *node.Node) error { k := combinedUUID("Subjects", lo, p.UUID(), o.UUID()) g.mu.RLock() v := g.memN[k] g.mu.RUnlock() if v != nil { // Return the memoized results. defer close(s...
[ "func", "(", "g", "*", "graphMemoizer", ")", "Subjects", "(", "ctx", "context", ".", "Context", ",", "p", "*", "predicate", ".", "Predicate", ",", "o", "*", "triple", ".", "Object", ",", "lo", "*", "storage", ".", "LookupOptions", ",", "subs", "chan", ...
// Subject pushes to the provided channel the subjects for the give predicate // and object. The function does not return immediately. The caller is // expected to detach them into a go routine. // // Given a predicate and an object, this method retrieves the subjects of // triples that matches them. By default, it doe...
[ "Subject", "pushes", "to", "the", "provided", "channel", "the", "subjects", "for", "the", "give", "predicate", "and", "object", ".", "The", "function", "does", "not", "return", "immediately", ".", "The", "caller", "is", "expected", "to", "detach", "them", "i...
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/storage/memoization/memoization.go#L242-L290
12,375
google/badwolf
storage/memoization/memoization.go
PredicatesForSubjectAndObject
func (g *graphMemoizer) PredicatesForSubjectAndObject(ctx context.Context, s *node.Node, o *triple.Object, lo *storage.LookupOptions, prds chan<- *predicate.Predicate) error { k := combinedUUID("PredicatesForSubjectAndObject", lo, s.UUID(), o.UUID()) g.mu.RLock() v := g.memP[k] g.mu.RUnlock() if v != nil { // Re...
go
func (g *graphMemoizer) PredicatesForSubjectAndObject(ctx context.Context, s *node.Node, o *triple.Object, lo *storage.LookupOptions, prds chan<- *predicate.Predicate) error { k := combinedUUID("PredicatesForSubjectAndObject", lo, s.UUID(), o.UUID()) g.mu.RLock() v := g.memP[k] g.mu.RUnlock() if v != nil { // Re...
[ "func", "(", "g", "*", "graphMemoizer", ")", "PredicatesForSubjectAndObject", "(", "ctx", "context", ".", "Context", ",", "s", "*", "node", ".", "Node", ",", "o", "*", "triple", ".", "Object", ",", "lo", "*", "storage", ".", "LookupOptions", ",", "prds",...
// PredicatesForSubjectAndObject pushes to the provided channel all predicates // available for the given subject and object. The function does not return // immediately. The caller is expected to detach them into a go routine. // // If the lookup options provide a max number of elements the function will // return a s...
[ "PredicatesForSubjectAndObject", "pushes", "to", "the", "provided", "channel", "all", "predicates", "available", "for", "the", "given", "subject", "and", "object", ".", "The", "function", "does", "not", "return", "immediately", ".", "The", "caller", "is", "expecte...
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/storage/memoization/memoization.go#L419-L467
12,376
google/badwolf
storage/memoization/memoization.go
TriplesForSubject
func (g *graphMemoizer) TriplesForSubject(ctx context.Context, s *node.Node, lo *storage.LookupOptions, trpls chan<- *triple.Triple) error { k := combinedUUID("TriplesForSubject", lo, s.UUID()) g.mu.RLock() v := g.memT[k] g.mu.RUnlock() if v != nil { // Return the memoized results. defer close(trpls) for _, ...
go
func (g *graphMemoizer) TriplesForSubject(ctx context.Context, s *node.Node, lo *storage.LookupOptions, trpls chan<- *triple.Triple) error { k := combinedUUID("TriplesForSubject", lo, s.UUID()) g.mu.RLock() v := g.memT[k] g.mu.RUnlock() if v != nil { // Return the memoized results. defer close(trpls) for _, ...
[ "func", "(", "g", "*", "graphMemoizer", ")", "TriplesForSubject", "(", "ctx", "context", ".", "Context", ",", "s", "*", "node", ".", "Node", ",", "lo", "*", "storage", ".", "LookupOptions", ",", "trpls", "chan", "<-", "*", "triple", ".", "Triple", ")",...
// TriplesForSubject pushes to the provided channel all triples available for // the given subject. The function does not return immediately. The caller // is expected to detach them into a go routine. // // If the lookup options provide a max number of elements the function will // return a sample of the available tri...
[ "TriplesForSubject", "pushes", "to", "the", "provided", "channel", "all", "triples", "available", "for", "the", "given", "subject", ".", "The", "function", "does", "not", "return", "immediately", ".", "The", "caller", "is", "expected", "to", "detach", "them", ...
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/storage/memoization/memoization.go#L478-L526
12,377
google/badwolf
bql/planner/planner.go
Execute
func (p *createPlan) Execute(ctx context.Context) (*table.Table, error) { t, err := table.New([]string{}) if err != nil { return nil, err } errs := []string{} for _, g := range p.stm.GraphNames() { tracer.Trace(p.tracer, func() []string { return []string{"Creating new graph \"" + g + "\""} }) if _, err ...
go
func (p *createPlan) Execute(ctx context.Context) (*table.Table, error) { t, err := table.New([]string{}) if err != nil { return nil, err } errs := []string{} for _, g := range p.stm.GraphNames() { tracer.Trace(p.tracer, func() []string { return []string{"Creating new graph \"" + g + "\""} }) if _, err ...
[ "func", "(", "p", "*", "createPlan", ")", "Execute", "(", "ctx", "context", ".", "Context", ")", "(", "*", "table", ".", "Table", ",", "error", ")", "{", "t", ",", "err", ":=", "table", ".", "New", "(", "[", "]", "string", "{", "}", ")", "\n", ...
// Execute creates the indicated graphs.
[ "Execute", "creates", "the", "indicated", "graphs", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/planner.go#L66-L84
12,378
google/badwolf
bql/planner/planner.go
Execute
func (p *insertPlan) Execute(ctx context.Context) (*table.Table, error) { t, err := table.New([]string{}) if err != nil { return nil, err } return t, update(ctx, p.stm.Data(), p.stm.OutputGraphNames(), p.store, func(g storage.Graph, d []*triple.Triple) error { tracer.Trace(p.tracer, func() []string { return ...
go
func (p *insertPlan) Execute(ctx context.Context) (*table.Table, error) { t, err := table.New([]string{}) if err != nil { return nil, err } return t, update(ctx, p.stm.Data(), p.stm.OutputGraphNames(), p.store, func(g storage.Graph, d []*triple.Triple) error { tracer.Trace(p.tracer, func() []string { return ...
[ "func", "(", "p", "*", "insertPlan", ")", "Execute", "(", "ctx", "context", ".", "Context", ")", "(", "*", "table", ".", "Table", ",", "error", ")", "{", "t", ",", "err", ":=", "table", ".", "New", "(", "[", "]", "string", "{", "}", ")", "\n", ...
// Execute inserts the provided data into the indicated graphs.
[ "Execute", "inserts", "the", "provided", "data", "into", "the", "indicated", "graphs", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/planner.go#L180-L191
12,379
google/badwolf
bql/planner/planner.go
newQueryPlan
func newQueryPlan(ctx context.Context, store storage.Store, stm *semantic.Statement, chanSize int, w io.Writer) (*queryPlan, error) { bs := []string{} for _, b := range stm.Bindings() { bs = append(bs, b) } t, err := table.New([]string{}) if err != nil { return nil, err } return &queryPlan{ stm: stm,...
go
func newQueryPlan(ctx context.Context, store storage.Store, stm *semantic.Statement, chanSize int, w io.Writer) (*queryPlan, error) { bs := []string{} for _, b := range stm.Bindings() { bs = append(bs, b) } t, err := table.New([]string{}) if err != nil { return nil, err } return &queryPlan{ stm: stm,...
[ "func", "newQueryPlan", "(", "ctx", "context", ".", "Context", ",", "store", "storage", ".", "Store", ",", "stm", "*", "semantic", ".", "Statement", ",", "chanSize", "int", ",", "w", "io", ".", "Writer", ")", "(", "*", "queryPlan", ",", "error", ")", ...
// newQueryPlan returns a new query plan ready to be executed.
[ "newQueryPlan", "returns", "a", "new", "query", "plan", "ready", "to", "be", "executed", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/planner.go#L272-L291
12,380
google/badwolf
bql/planner/planner.go
processClause
func (p *queryPlan) processClause(ctx context.Context, cls *semantic.GraphClause, lo *storage.LookupOptions) (bool, error) { // This method decides how to process the clause based on the current // list of bindings solved and data available. if cls.Specificity() == 3 { tracer.Trace(p.tracer, func() []string { r...
go
func (p *queryPlan) processClause(ctx context.Context, cls *semantic.GraphClause, lo *storage.LookupOptions) (bool, error) { // This method decides how to process the clause based on the current // list of bindings solved and data available. if cls.Specificity() == 3 { tracer.Trace(p.tracer, func() []string { r...
[ "func", "(", "p", "*", "queryPlan", ")", "processClause", "(", "ctx", "context", ".", "Context", ",", "cls", "*", "semantic", ".", "GraphClause", ",", "lo", "*", "storage", ".", "LookupOptions", ")", "(", "bool", ",", "error", ")", "{", "// This method d...
// processClause retrieves the triples for the provided triple given the // information available.
[ "processClause", "retrieves", "the", "triples", "for", "the", "provided", "triple", "given", "the", "information", "available", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/planner.go#L295-L349
12,381
google/badwolf
bql/planner/planner.go
getBoundValueForComponent
func getBoundValueForComponent(r table.Row, bs []string) *table.Cell { var cs []*table.Cell for _, b := range bs { if v, ok := r[b]; ok { cs = append(cs, v) } } if len(cs) == 1 || len(cs) == 2 && reflect.DeepEqual(cs[0], cs[1]) { return cs[0] } return nil }
go
func getBoundValueForComponent(r table.Row, bs []string) *table.Cell { var cs []*table.Cell for _, b := range bs { if v, ok := r[b]; ok { cs = append(cs, v) } } if len(cs) == 1 || len(cs) == 2 && reflect.DeepEqual(cs[0], cs[1]) { return cs[0] } return nil }
[ "func", "getBoundValueForComponent", "(", "r", "table", ".", "Row", ",", "bs", "[", "]", "string", ")", "*", "table", ".", "Cell", "{", "var", "cs", "[", "]", "*", "table", ".", "Cell", "\n", "for", "_", ",", "b", ":=", "range", "bs", "{", "if", ...
// getBoundValueForComponent return the unique bound value if available on // the provided row.
[ "getBoundValueForComponent", "return", "the", "unique", "bound", "value", "if", "available", "on", "the", "provided", "row", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/planner.go#L353-L364
12,382
google/badwolf
bql/planner/planner.go
specifyClauseWithTable
func (p *queryPlan) specifyClauseWithTable(ctx context.Context, cls *semantic.GraphClause, lo *storage.LookupOptions) error { rws := p.tbl.Rows() p.tbl.Truncate() var ( gErr error mu sync.Mutex wg sync.WaitGroup ) for _, tmpRow := range rws { wg.Add(1) go func(r table.Row) { defer wg.Done() var...
go
func (p *queryPlan) specifyClauseWithTable(ctx context.Context, cls *semantic.GraphClause, lo *storage.LookupOptions) error { rws := p.tbl.Rows() p.tbl.Truncate() var ( gErr error mu sync.Mutex wg sync.WaitGroup ) for _, tmpRow := range rws { wg.Add(1) go func(r table.Row) { defer wg.Done() var...
[ "func", "(", "p", "*", "queryPlan", ")", "specifyClauseWithTable", "(", "ctx", "context", ".", "Context", ",", "cls", "*", "semantic", ".", "GraphClause", ",", "lo", "*", "storage", ".", "LookupOptions", ")", "error", "{", "rws", ":=", "p", ".", "tbl", ...
// specifyClauseWithTable runs the clause, but it specifies it further based on // the current row being processed.
[ "specifyClauseWithTable", "runs", "the", "clause", "but", "it", "specifies", "it", "further", "based", "on", "the", "current", "row", "being", "processed", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/planner.go#L447-L470
12,383
google/badwolf
bql/planner/planner.go
cellToObject
func cellToObject(c *table.Cell) (*triple.Object, error) { if c == nil { return nil, errors.New("cannot create an object out of and empty cell") } if c.N != nil { return triple.NewNodeObject(c.N), nil } if c.P != nil { return triple.NewPredicateObject(c.P), nil } if c.L != nil { return triple.NewLiteralO...
go
func cellToObject(c *table.Cell) (*triple.Object, error) { if c == nil { return nil, errors.New("cannot create an object out of and empty cell") } if c.N != nil { return triple.NewNodeObject(c.N), nil } if c.P != nil { return triple.NewPredicateObject(c.P), nil } if c.L != nil { return triple.NewLiteralO...
[ "func", "cellToObject", "(", "c", "*", "table", ".", "Cell", ")", "(", "*", "triple", ".", "Object", ",", "error", ")", "{", "if", "c", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", ...
// cellToObject returns an object for the given cell.
[ "cellToObject", "returns", "an", "object", "for", "the", "given", "cell", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/planner.go#L473-L494
12,384
google/badwolf
bql/planner/planner.go
processGraphPattern
func (p *queryPlan) processGraphPattern(ctx context.Context, lo *storage.LookupOptions) error { tracer.Trace(p.tracer, func() []string { var res []string for i, cls := range p.cls { res = append(res, fmt.Sprintf("Clause %d to process: %v", i, cls)) } return res }) for i, c := range p.cls { i, cls := i, ...
go
func (p *queryPlan) processGraphPattern(ctx context.Context, lo *storage.LookupOptions) error { tracer.Trace(p.tracer, func() []string { var res []string for i, cls := range p.cls { res = append(res, fmt.Sprintf("Clause %d to process: %v", i, cls)) } return res }) for i, c := range p.cls { i, cls := i, ...
[ "func", "(", "p", "*", "queryPlan", ")", "processGraphPattern", "(", "ctx", "context", ".", "Context", ",", "lo", "*", "storage", ".", "LookupOptions", ")", "error", "{", "tracer", ".", "Trace", "(", "p", ".", "tracer", ",", "func", "(", ")", "[", "]...
// processGraphPattern process the query graph pattern to retrieve the // data from the specified graphs.
[ "processGraphPattern", "process", "the", "query", "graph", "pattern", "to", "retrieve", "the", "data", "from", "the", "specified", "graphs", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/planner.go#L663-L688
12,385
google/badwolf
bql/planner/planner.go
orderBy
func (p *queryPlan) orderBy() { order := p.stm.OrderByConfig() if len(order) <= 0 { return } tracer.Trace(p.tracer, func() []string { return []string{"Ordering by " + order.String()} }) p.tbl.Sort(order) }
go
func (p *queryPlan) orderBy() { order := p.stm.OrderByConfig() if len(order) <= 0 { return } tracer.Trace(p.tracer, func() []string { return []string{"Ordering by " + order.String()} }) p.tbl.Sort(order) }
[ "func", "(", "p", "*", "queryPlan", ")", "orderBy", "(", ")", "{", "order", ":=", "p", ".", "stm", ".", "OrderByConfig", "(", ")", "\n", "if", "len", "(", "order", ")", "<=", "0", "{", "return", "\n", "}", "\n", "tracer", ".", "Trace", "(", "p"...
// orderBy takes the resulting table and sorts its contents according to the // specifications of the ORDER BY clause.
[ "orderBy", "takes", "the", "resulting", "table", "and", "sorts", "its", "contents", "according", "to", "the", "specifications", "of", "the", "ORDER", "BY", "clause", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/planner.go#L784-L793
12,386
google/badwolf
bql/planner/planner.go
having
func (p *queryPlan) having() error { if p.stm.HasHavingClause() { tracer.Trace(p.tracer, func() []string { return []string{"Having filtering"} }) eval := p.stm.HavingEvaluator() ok := true var eErr error p.tbl.Filter(func(r table.Row) bool { b, err := eval.Evaluate(r) if err != nil { ok, eErr ...
go
func (p *queryPlan) having() error { if p.stm.HasHavingClause() { tracer.Trace(p.tracer, func() []string { return []string{"Having filtering"} }) eval := p.stm.HavingEvaluator() ok := true var eErr error p.tbl.Filter(func(r table.Row) bool { b, err := eval.Evaluate(r) if err != nil { ok, eErr ...
[ "func", "(", "p", "*", "queryPlan", ")", "having", "(", ")", "error", "{", "if", "p", ".", "stm", ".", "HasHavingClause", "(", ")", "{", "tracer", ".", "Trace", "(", "p", ".", "tracer", ",", "func", "(", ")", "[", "]", "string", "{", "return", ...
// having runs the filtering based on the having clause if needed.
[ "having", "runs", "the", "filtering", "based", "on", "the", "having", "clause", "if", "needed", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/planner.go#L796-L816
12,387
google/badwolf
bql/planner/planner.go
limit
func (p *queryPlan) limit() { if p.stm.IsLimitSet() { tracer.Trace(p.tracer, func() []string { return []string{"Limit results to " + strconv.Itoa(int(p.stm.Limit()))} }) p.tbl.Limit(p.stm.Limit()) } }
go
func (p *queryPlan) limit() { if p.stm.IsLimitSet() { tracer.Trace(p.tracer, func() []string { return []string{"Limit results to " + strconv.Itoa(int(p.stm.Limit()))} }) p.tbl.Limit(p.stm.Limit()) } }
[ "func", "(", "p", "*", "queryPlan", ")", "limit", "(", ")", "{", "if", "p", ".", "stm", ".", "IsLimitSet", "(", ")", "{", "tracer", ".", "Trace", "(", "p", ".", "tracer", ",", "func", "(", ")", "[", "]", "string", "{", "return", "[", "]", "st...
// limit truncates the table if the limit clause if available.
[ "limit", "truncates", "the", "table", "if", "the", "limit", "clause", "if", "available", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/planner.go#L819-L826
12,388
google/badwolf
bql/planner/planner.go
Execute
func (p *queryPlan) Execute(ctx context.Context) (*table.Table, error) { // Fetch and cache graph instances. tracer.Trace(p.tracer, func() []string { return []string{fmt.Sprintf("Caching graph instances for graphs %v", p.stm.InputGraphNames())} }) if err := p.stm.Init(ctx, p.store); err != nil { return nil, err...
go
func (p *queryPlan) Execute(ctx context.Context) (*table.Table, error) { // Fetch and cache graph instances. tracer.Trace(p.tracer, func() []string { return []string{fmt.Sprintf("Caching graph instances for graphs %v", p.stm.InputGraphNames())} }) if err := p.stm.Init(ctx, p.store); err != nil { return nil, err...
[ "func", "(", "p", "*", "queryPlan", ")", "Execute", "(", "ctx", "context", ".", "Context", ")", "(", "*", "table", ".", "Table", ",", "error", ")", "{", "// Fetch and cache graph instances.", "tracer", ".", "Trace", "(", "p", ".", "tracer", ",", "func", ...
// Execute queries the indicated graphs.
[ "Execute", "queries", "the", "indicated", "graphs", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/planner.go#L829-L864
12,389
google/badwolf
bql/planner/planner.go
Execute
func (p *showPlan) Execute(ctx context.Context) (*table.Table, error) { t, err := table.New([]string{"?graph_id"}) if err != nil { return nil, err } errs := make(chan error) names := make(chan string) go func() { errs <- p.store.GraphNames(ctx, names) close(errs) }() for name := range names { id := nam...
go
func (p *showPlan) Execute(ctx context.Context) (*table.Table, error) { t, err := table.New([]string{"?graph_id"}) if err != nil { return nil, err } errs := make(chan error) names := make(chan string) go func() { errs <- p.store.GraphNames(ctx, names) close(errs) }() for name := range names { id := nam...
[ "func", "(", "p", "*", "showPlan", ")", "Execute", "(", "ctx", "context", ".", "Context", ")", "(", "*", "table", ".", "Table", ",", "error", ")", "{", "t", ",", "err", ":=", "table", ".", "New", "(", "[", "]", "string", "{", "\"", "\"", "}", ...
// Execute the show statement.
[ "Execute", "the", "show", "statement", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/planner.go#L1123-L1147
12,390
google/badwolf
bql/planner/planner.go
New
func New(ctx context.Context, store storage.Store, stm *semantic.Statement, chanSize, bulkSize int, w io.Writer) (Executor, error) { switch stm.Type() { case semantic.Query: return newQueryPlan(ctx, store, stm, chanSize, w) case semantic.Insert: return &insertPlan{ stm: stm, store: store, tracer: w,...
go
func New(ctx context.Context, store storage.Store, stm *semantic.Statement, chanSize, bulkSize int, w io.Writer) (Executor, error) { switch stm.Type() { case semantic.Query: return newQueryPlan(ctx, store, stm, chanSize, w) case semantic.Insert: return &insertPlan{ stm: stm, store: store, tracer: w,...
[ "func", "New", "(", "ctx", "context", ".", "Context", ",", "store", "storage", ".", "Store", ",", "stm", "*", "semantic", ".", "Statement", ",", "chanSize", ",", "bulkSize", "int", ",", "w", "io", ".", "Writer", ")", "(", "Executor", ",", "error", ")...
// New create a new executable plan given a semantic BQL statement.
[ "New", "create", "a", "new", "executable", "plan", "given", "a", "semantic", "BQL", "statement", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/planner.go#L1155-L1212
12,391
google/badwolf
bql/grammar/llk.go
NewLLk
func NewLLk(input string, k int) *LLk { c := lexer.New(input, 2*k) // +2 to keep a bit of buffer available. l := &LLk{ k: k, c: c, } for i := 0; i < k+1; i++ { appendNextToken(l) } return l }
go
func NewLLk(input string, k int) *LLk { c := lexer.New(input, 2*k) // +2 to keep a bit of buffer available. l := &LLk{ k: k, c: c, } for i := 0; i < k+1; i++ { appendNextToken(l) } return l }
[ "func", "NewLLk", "(", "input", "string", ",", "k", "int", ")", "*", "LLk", "{", "c", ":=", "lexer", ".", "New", "(", "input", ",", "2", "*", "k", ")", "// +2 to keep a bit of buffer available.", "\n", "l", ":=", "&", "LLk", "{", "k", ":", "k", ","...
// NewLLk creates a LLk structure for the given string to parse and the // indicated k lookahead.
[ "NewLLk", "creates", "a", "LLk", "structure", "for", "the", "given", "string", "to", "parse", "and", "the", "indicated", "k", "lookahead", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/grammar/llk.go#L33-L43
12,392
google/badwolf
bql/grammar/llk.go
appendNextToken
func appendNextToken(l *LLk) { for t := range l.c { l.tkns = append(l.tkns, t) return } l.tkns = append(l.tkns, lexer.Token{Type: lexer.ItemEOF}) }
go
func appendNextToken(l *LLk) { for t := range l.c { l.tkns = append(l.tkns, t) return } l.tkns = append(l.tkns, lexer.Token{Type: lexer.ItemEOF}) }
[ "func", "appendNextToken", "(", "l", "*", "LLk", ")", "{", "for", "t", ":=", "range", "l", ".", "c", "{", "l", ".", "tkns", "=", "append", "(", "l", ".", "tkns", ",", "t", ")", "\n", "return", "\n", "}", "\n", "l", ".", "tkns", "=", "append",...
// appendNextToken tries to append a new token. If not tokens are available // it appends ItemEOF token.
[ "appendNextToken", "tries", "to", "append", "a", "new", "token", ".", "If", "not", "tokens", "are", "available", "it", "appends", "ItemEOF", "token", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/grammar/llk.go#L47-L53
12,393
google/badwolf
bql/grammar/llk.go
Peek
func (l *LLk) Peek(k int) (*lexer.Token, error) { if k > l.k { return nil, fmt.Errorf("grammar.LLk: cannot look ahead %v beyond defined %v", k, l.k) } if k <= 0 { return nil, fmt.Errorf("grammar.LLk: invalid look ahead value %v", k) } return &l.tkns[k], nil }
go
func (l *LLk) Peek(k int) (*lexer.Token, error) { if k > l.k { return nil, fmt.Errorf("grammar.LLk: cannot look ahead %v beyond defined %v", k, l.k) } if k <= 0 { return nil, fmt.Errorf("grammar.LLk: invalid look ahead value %v", k) } return &l.tkns[k], nil }
[ "func", "(", "l", "*", "LLk", ")", "Peek", "(", "k", "int", ")", "(", "*", "lexer", ".", "Token", ",", "error", ")", "{", "if", "k", ">", "l", ".", "k", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "k", ",", "l",...
// Peek returns the token for the k look ahead. It will return nil and failed // fail with an error if the provided k is bigger than the declared look ahead // on creation.
[ "Peek", "returns", "the", "token", "for", "the", "k", "look", "ahead", ".", "It", "will", "return", "nil", "and", "failed", "fail", "with", "an", "error", "if", "the", "provided", "k", "is", "bigger", "than", "the", "declared", "look", "ahead", "on", "...
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/grammar/llk.go#L63-L71
12,394
google/badwolf
bql/grammar/llk.go
CanAccept
func (l *LLk) CanAccept(tt lexer.TokenType) bool { return l.tkns[0].Type == tt }
go
func (l *LLk) CanAccept(tt lexer.TokenType) bool { return l.tkns[0].Type == tt }
[ "func", "(", "l", "*", "LLk", ")", "CanAccept", "(", "tt", "lexer", ".", "TokenType", ")", "bool", "{", "return", "l", ".", "tkns", "[", "0", "]", ".", "Type", "==", "tt", "\n", "}" ]
// CanAccept returns true if the provided token matches the current on being // processed, false otherwise.
[ "CanAccept", "returns", "true", "if", "the", "provided", "token", "matches", "the", "current", "on", "being", "processed", "false", "otherwise", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/grammar/llk.go#L75-L77
12,395
google/badwolf
bql/grammar/llk.go
Consume
func (l *LLk) Consume(tt lexer.TokenType) bool { if l.tkns[0].Type != tt { return false } l.tkns = l.tkns[1:] appendNextToken(l) return true }
go
func (l *LLk) Consume(tt lexer.TokenType) bool { if l.tkns[0].Type != tt { return false } l.tkns = l.tkns[1:] appendNextToken(l) return true }
[ "func", "(", "l", "*", "LLk", ")", "Consume", "(", "tt", "lexer", ".", "TokenType", ")", "bool", "{", "if", "l", ".", "tkns", "[", "0", "]", ".", "Type", "!=", "tt", "{", "return", "false", "\n", "}", "\n", "l", ".", "tkns", "=", "l", ".", ...
// Consume will consume the current token and move to the next one if it matches // the provided token, false otherwise.
[ "Consume", "will", "consume", "the", "current", "token", "and", "move", "to", "the", "next", "one", "if", "it", "matches", "the", "provided", "token", "false", "otherwise", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/grammar/llk.go#L81-L88
12,396
google/badwolf
tools/benchmark/runtime/runtime.go
TrackDuration
func TrackDuration(f func() error) (time.Duration, error) { ts := timeNow() err := f() d := timeNow().Sub(ts) return d, err }
go
func TrackDuration(f func() error) (time.Duration, error) { ts := timeNow() err := f() d := timeNow().Sub(ts) return d, err }
[ "func", "TrackDuration", "(", "f", "func", "(", ")", "error", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "ts", ":=", "timeNow", "(", ")", "\n", "err", ":=", "f", "(", ")", "\n", "d", ":=", "timeNow", "(", ")", ".", "Sub", "(", ...
// TrackDuration measure the duration of the run time function using the // wall clock. You should not consider the returned duration in the presence // or an error since it will likely have shortcut the execution of the // function being executed.
[ "TrackDuration", "measure", "the", "duration", "of", "the", "run", "time", "function", "using", "the", "wall", "clock", ".", "You", "should", "not", "consider", "the", "returned", "duration", "in", "the", "presence", "or", "an", "error", "since", "it", "will...
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/benchmark/runtime/runtime.go#L33-L38
12,397
google/badwolf
tools/benchmark/runtime/runtime.go
RepetitionDurationStats
func RepetitionDurationStats(reps int, setup, f, teardown func() error) (time.Duration, time.Duration, error) { if reps < 1 { return time.Duration(0), 0, fmt.Errorf("repetions need to be %d >= 1", reps) } if setup == nil { return time.Duration(0), 0, errors.New("setup function is required") } if f == nil { r...
go
func RepetitionDurationStats(reps int, setup, f, teardown func() error) (time.Duration, time.Duration, error) { if reps < 1 { return time.Duration(0), 0, fmt.Errorf("repetions need to be %d >= 1", reps) } if setup == nil { return time.Duration(0), 0, errors.New("setup function is required") } if f == nil { r...
[ "func", "RepetitionDurationStats", "(", "reps", "int", ",", "setup", ",", "f", ",", "teardown", "func", "(", ")", "error", ")", "(", "time", ".", "Duration", ",", "time", ".", "Duration", ",", "error", ")", "{", "if", "reps", "<", "1", "{", "return",...
// RepetitionDurationStats extracts some duration stats by repeatedly execution // and measuring runtime. Returns the mean and deviation of the run duration of // the provided function. If an error is return by the function it will shortcut // the execution and return just the error.
[ "RepetitionDurationStats", "extracts", "some", "duration", "stats", "by", "repeatedly", "execution", "and", "measuring", "runtime", ".", "Returns", "the", "mean", "and", "deviation", "of", "the", "run", "duration", "of", "the", "provided", "function", ".", "If", ...
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/benchmark/runtime/runtime.go#L44-L82
12,398
google/badwolf
tools/benchmark/runtime/runtime.go
RunBenchmarkBatterySequentially
func RunBenchmarkBatterySequentially(entries []*BenchEntry) []*BenchResult { var res []*BenchResult for _, entry := range entries { m, d, err := RepetitionDurationStats(entry.Reps, entry.Setup, entry.F, entry.TearDown) res = append(res, &BenchResult{ BatteryID: entry.BatteryID, ID: entry.ID, Tripl...
go
func RunBenchmarkBatterySequentially(entries []*BenchEntry) []*BenchResult { var res []*BenchResult for _, entry := range entries { m, d, err := RepetitionDurationStats(entry.Reps, entry.Setup, entry.F, entry.TearDown) res = append(res, &BenchResult{ BatteryID: entry.BatteryID, ID: entry.ID, Tripl...
[ "func", "RunBenchmarkBatterySequentially", "(", "entries", "[", "]", "*", "BenchEntry", ")", "[", "]", "*", "BenchResult", "{", "var", "res", "[", "]", "*", "BenchResult", "\n", "for", "_", ",", "entry", ":=", "range", "entries", "{", "m", ",", "d", ",...
// RunBenchmarkBatterySequentially runs all the bench entries and returns the // timing results.
[ "RunBenchmarkBatterySequentially", "runs", "all", "the", "bench", "entries", "and", "returns", "the", "timing", "results", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/benchmark/runtime/runtime.go#L108-L122
12,399
google/badwolf
tools/benchmark/runtime/runtime.go
RunBenchmarkBatteryConcurrently
func RunBenchmarkBatteryConcurrently(entries []*BenchEntry) []*BenchResult { var ( mu sync.Mutex wg sync.WaitGroup res []*BenchResult ) for _, entry := range entries { wg.Add(1) go func(entry *BenchEntry) { m, d, err := RepetitionDurationStats(entry.Reps, entry.Setup, entry.F, entry.TearDown) mu.Lo...
go
func RunBenchmarkBatteryConcurrently(entries []*BenchEntry) []*BenchResult { var ( mu sync.Mutex wg sync.WaitGroup res []*BenchResult ) for _, entry := range entries { wg.Add(1) go func(entry *BenchEntry) { m, d, err := RepetitionDurationStats(entry.Reps, entry.Setup, entry.F, entry.TearDown) mu.Lo...
[ "func", "RunBenchmarkBatteryConcurrently", "(", "entries", "[", "]", "*", "BenchEntry", ")", "[", "]", "*", "BenchResult", "{", "var", "(", "mu", "sync", ".", "Mutex", "\n", "wg", "sync", ".", "WaitGroup", "\n", "res", "[", "]", "*", "BenchResult", "\n",...
// RunBenchmarkBatteryConcurrently runs all the bench entries and returns the // timing results concurrently. The benchmarks will all be run concurrently.
[ "RunBenchmarkBatteryConcurrently", "runs", "all", "the", "bench", "entries", "and", "returns", "the", "timing", "results", "concurrently", ".", "The", "benchmarks", "will", "all", "be", "run", "concurrently", "." ]
f6c3103546450641440a719b2ed52cc74bae6237
https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/benchmark/runtime/runtime.go#L126-L151