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
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
162,300
boltdb/bolt
tx.go
forEachPage
func (tx *Tx) forEachPage(pgid pgid, depth int, fn func(*page, int)) { p := tx.page(pgid) // Execute function. fn(p, depth) // Recursively loop over children. if (p.flags & branchPageFlag) != 0 { for i := 0; i < int(p.count); i++ { elem := p.branchPageElement(uint16(i)) tx.forEachPage(elem.pgid, depth+1,...
go
func (tx *Tx) forEachPage(pgid pgid, depth int, fn func(*page, int)) { p := tx.page(pgid) // Execute function. fn(p, depth) // Recursively loop over children. if (p.flags & branchPageFlag) != 0 { for i := 0; i < int(p.count); i++ { elem := p.branchPageElement(uint16(i)) tx.forEachPage(elem.pgid, depth+1,...
[ "func", "(", "tx", "*", "Tx", ")", "forEachPage", "(", "pgid", "pgid", ",", "depth", "int", ",", "fn", "func", "(", "*", "page", ",", "int", ")", ")", "{", "p", ":=", "tx", ".", "page", "(", "pgid", ")", "\n\n", "// Execute function.", "fn", "(",...
// forEachPage iterates over every page within a given page and executes a function.
[ "forEachPage", "iterates", "over", "every", "page", "within", "a", "given", "page", "and", "executes", "a", "function", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L584-L597
162,301
boltdb/bolt
tx.go
Page
func (tx *Tx) Page(id int) (*PageInfo, error) { if tx.db == nil { return nil, ErrTxClosed } else if pgid(id) >= tx.meta.pgid { return nil, nil } // Build the page info. p := tx.db.page(pgid(id)) info := &PageInfo{ ID: id, Count: int(p.count), OverflowCount: int(p.overflow), } // D...
go
func (tx *Tx) Page(id int) (*PageInfo, error) { if tx.db == nil { return nil, ErrTxClosed } else if pgid(id) >= tx.meta.pgid { return nil, nil } // Build the page info. p := tx.db.page(pgid(id)) info := &PageInfo{ ID: id, Count: int(p.count), OverflowCount: int(p.overflow), } // D...
[ "func", "(", "tx", "*", "Tx", ")", "Page", "(", "id", "int", ")", "(", "*", "PageInfo", ",", "error", ")", "{", "if", "tx", ".", "db", "==", "nil", "{", "return", "nil", ",", "ErrTxClosed", "\n", "}", "else", "if", "pgid", "(", "id", ")", ">=...
// Page returns page information for a given page number. // This is only safe for concurrent use when used by a writable transaction.
[ "Page", "returns", "page", "information", "for", "a", "given", "page", "number", ".", "This", "is", "only", "safe", "for", "concurrent", "use", "when", "used", "by", "a", "writable", "transaction", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L601-L624
162,302
boltdb/bolt
tx.go
Sub
func (s *TxStats) Sub(other *TxStats) TxStats { var diff TxStats diff.PageCount = s.PageCount - other.PageCount diff.PageAlloc = s.PageAlloc - other.PageAlloc diff.CursorCount = s.CursorCount - other.CursorCount diff.NodeCount = s.NodeCount - other.NodeCount diff.NodeDeref = s.NodeDeref - other.NodeDeref diff.Re...
go
func (s *TxStats) Sub(other *TxStats) TxStats { var diff TxStats diff.PageCount = s.PageCount - other.PageCount diff.PageAlloc = s.PageAlloc - other.PageAlloc diff.CursorCount = s.CursorCount - other.CursorCount diff.NodeCount = s.NodeCount - other.NodeCount diff.NodeDeref = s.NodeDeref - other.NodeDeref diff.Re...
[ "func", "(", "s", "*", "TxStats", ")", "Sub", "(", "other", "*", "TxStats", ")", "TxStats", "{", "var", "diff", "TxStats", "\n", "diff", ".", "PageCount", "=", "s", ".", "PageCount", "-", "other", ".", "PageCount", "\n", "diff", ".", "PageAlloc", "="...
// Sub calculates and returns the difference between two sets of transaction stats. // This is useful when obtaining stats at two different points and time and // you need the performance counters that occurred within that time span.
[ "Sub", "calculates", "and", "returns", "the", "difference", "between", "two", "sets", "of", "transaction", "stats", ".", "This", "is", "useful", "when", "obtaining", "stats", "at", "two", "different", "points", "and", "time", "and", "you", "need", "the", "pe...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L671-L686
162,303
boltdb/bolt
cmd/bolt/main.go
newCheckCommand
func newCheckCommand(m *Main) *CheckCommand { return &CheckCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
go
func newCheckCommand(m *Main) *CheckCommand { return &CheckCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
[ "func", "newCheckCommand", "(", "m", "*", "Main", ")", "*", "CheckCommand", "{", "return", "&", "CheckCommand", "{", "Stdin", ":", "m", ".", "Stdin", ",", "Stdout", ":", "m", ".", "Stdout", ",", "Stderr", ":", "m", ".", "Stderr", ",", "}", "\n", "}...
// NewCheckCommand returns a CheckCommand.
[ "NewCheckCommand", "returns", "a", "CheckCommand", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L153-L159
162,304
boltdb/bolt
cmd/bolt/main.go
newInfoCommand
func newInfoCommand(m *Main) *InfoCommand { return &InfoCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
go
func newInfoCommand(m *Main) *InfoCommand { return &InfoCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
[ "func", "newInfoCommand", "(", "m", "*", "Main", ")", "*", "InfoCommand", "{", "return", "&", "InfoCommand", "{", "Stdin", ":", "m", ".", "Stdin", ",", "Stdout", ":", "m", ".", "Stdout", ",", "Stderr", ":", "m", ".", "Stderr", ",", "}", "\n", "}" ]
// NewInfoCommand returns a InfoCommand.
[ "NewInfoCommand", "returns", "a", "InfoCommand", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L238-L244
162,305
boltdb/bolt
cmd/bolt/main.go
newDumpCommand
func newDumpCommand(m *Main) *DumpCommand { return &DumpCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
go
func newDumpCommand(m *Main) *DumpCommand { return &DumpCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
[ "func", "newDumpCommand", "(", "m", "*", "Main", ")", "*", "DumpCommand", "{", "return", "&", "DumpCommand", "{", "Stdin", ":", "m", ".", "Stdin", ",", "Stdout", ":", "m", ".", "Stdout", ",", "Stderr", ":", "m", ".", "Stderr", ",", "}", "\n", "}" ]
// newDumpCommand returns a DumpCommand.
[ "newDumpCommand", "returns", "a", "DumpCommand", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L297-L303
162,306
boltdb/bolt
cmd/bolt/main.go
PrintPage
func (cmd *DumpCommand) PrintPage(w io.Writer, r io.ReaderAt, pageID int, pageSize int) error { const bytesPerLineN = 16 // Read page into buffer. buf := make([]byte, pageSize) addr := pageID * pageSize if n, err := r.ReadAt(buf, int64(addr)); err != nil { return err } else if n != pageSize { return io.ErrUn...
go
func (cmd *DumpCommand) PrintPage(w io.Writer, r io.ReaderAt, pageID int, pageSize int) error { const bytesPerLineN = 16 // Read page into buffer. buf := make([]byte, pageSize) addr := pageID * pageSize if n, err := r.ReadAt(buf, int64(addr)); err != nil { return err } else if n != pageSize { return io.ErrUn...
[ "func", "(", "cmd", "*", "DumpCommand", ")", "PrintPage", "(", "w", "io", ".", "Writer", ",", "r", "io", ".", "ReaderAt", ",", "pageID", "int", ",", "pageSize", "int", ")", "error", "{", "const", "bytesPerLineN", "=", "16", "\n\n", "// Read page into buf...
// PrintPage prints a given page as hexadecimal.
[ "PrintPage", "prints", "a", "given", "page", "as", "hexadecimal", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L363-L405
162,307
boltdb/bolt
cmd/bolt/main.go
newPageCommand
func newPageCommand(m *Main) *PageCommand { return &PageCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
go
func newPageCommand(m *Main) *PageCommand { return &PageCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
[ "func", "newPageCommand", "(", "m", "*", "Main", ")", "*", "PageCommand", "{", "return", "&", "PageCommand", "{", "Stdin", ":", "m", ".", "Stdin", ",", "Stdout", ":", "m", ".", "Stdout", ",", "Stderr", ":", "m", ".", "Stderr", ",", "}", "\n", "}" ]
// newPageCommand returns a PageCommand.
[ "newPageCommand", "returns", "a", "PageCommand", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L424-L430
162,308
boltdb/bolt
cmd/bolt/main.go
PrintMeta
func (cmd *PageCommand) PrintMeta(w io.Writer, buf []byte) error { m := (*meta)(unsafe.Pointer(&buf[PageHeaderSize])) fmt.Fprintf(w, "Version: %d\n", m.version) fmt.Fprintf(w, "Page Size: %d bytes\n", m.pageSize) fmt.Fprintf(w, "Flags: %08x\n", m.flags) fmt.Fprintf(w, "Root: <pgid=%d>\n", m.root.roo...
go
func (cmd *PageCommand) PrintMeta(w io.Writer, buf []byte) error { m := (*meta)(unsafe.Pointer(&buf[PageHeaderSize])) fmt.Fprintf(w, "Version: %d\n", m.version) fmt.Fprintf(w, "Page Size: %d bytes\n", m.pageSize) fmt.Fprintf(w, "Flags: %08x\n", m.flags) fmt.Fprintf(w, "Root: <pgid=%d>\n", m.root.roo...
[ "func", "(", "cmd", "*", "PageCommand", ")", "PrintMeta", "(", "w", "io", ".", "Writer", ",", "buf", "[", "]", "byte", ")", "error", "{", "m", ":=", "(", "*", "meta", ")", "(", "unsafe", ".", "Pointer", "(", "&", "buf", "[", "PageHeaderSize", "]"...
// PrintMeta prints the data from the meta page.
[ "PrintMeta", "prints", "the", "data", "from", "the", "meta", "page", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L505-L517
162,309
boltdb/bolt
cmd/bolt/main.go
PrintLeaf
func (cmd *PageCommand) PrintLeaf(w io.Writer, buf []byte) error { p := (*page)(unsafe.Pointer(&buf[0])) // Print number of items. fmt.Fprintf(w, "Item Count: %d\n", p.count) fmt.Fprintf(w, "\n") // Print each key/value. for i := uint16(0); i < p.count; i++ { e := p.leafPageElement(i) // Format key as stri...
go
func (cmd *PageCommand) PrintLeaf(w io.Writer, buf []byte) error { p := (*page)(unsafe.Pointer(&buf[0])) // Print number of items. fmt.Fprintf(w, "Item Count: %d\n", p.count) fmt.Fprintf(w, "\n") // Print each key/value. for i := uint16(0); i < p.count; i++ { e := p.leafPageElement(i) // Format key as stri...
[ "func", "(", "cmd", "*", "PageCommand", ")", "PrintLeaf", "(", "w", "io", ".", "Writer", ",", "buf", "[", "]", "byte", ")", "error", "{", "p", ":=", "(", "*", "page", ")", "(", "unsafe", ".", "Pointer", "(", "&", "buf", "[", "0", "]", ")", ")...
// PrintLeaf prints the data for a leaf page.
[ "PrintLeaf", "prints", "the", "data", "for", "a", "leaf", "page", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L520-L554
162,310
boltdb/bolt
cmd/bolt/main.go
PrintBranch
func (cmd *PageCommand) PrintBranch(w io.Writer, buf []byte) error { p := (*page)(unsafe.Pointer(&buf[0])) // Print number of items. fmt.Fprintf(w, "Item Count: %d\n", p.count) fmt.Fprintf(w, "\n") // Print each key/value. for i := uint16(0); i < p.count; i++ { e := p.branchPageElement(i) // Format key as ...
go
func (cmd *PageCommand) PrintBranch(w io.Writer, buf []byte) error { p := (*page)(unsafe.Pointer(&buf[0])) // Print number of items. fmt.Fprintf(w, "Item Count: %d\n", p.count) fmt.Fprintf(w, "\n") // Print each key/value. for i := uint16(0); i < p.count; i++ { e := p.branchPageElement(i) // Format key as ...
[ "func", "(", "cmd", "*", "PageCommand", ")", "PrintBranch", "(", "w", "io", ".", "Writer", ",", "buf", "[", "]", "byte", ")", "error", "{", "p", ":=", "(", "*", "page", ")", "(", "unsafe", ".", "Pointer", "(", "&", "buf", "[", "0", "]", ")", ...
// PrintBranch prints the data for a leaf page.
[ "PrintBranch", "prints", "the", "data", "for", "a", "leaf", "page", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L557-L580
162,311
boltdb/bolt
cmd/bolt/main.go
PrintFreelist
func (cmd *PageCommand) PrintFreelist(w io.Writer, buf []byte) error { p := (*page)(unsafe.Pointer(&buf[0])) // Print number of items. fmt.Fprintf(w, "Item Count: %d\n", p.count) fmt.Fprintf(w, "\n") // Print each page in the freelist. ids := (*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)) for i := uint16(0); i ...
go
func (cmd *PageCommand) PrintFreelist(w io.Writer, buf []byte) error { p := (*page)(unsafe.Pointer(&buf[0])) // Print number of items. fmt.Fprintf(w, "Item Count: %d\n", p.count) fmt.Fprintf(w, "\n") // Print each page in the freelist. ids := (*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)) for i := uint16(0); i ...
[ "func", "(", "cmd", "*", "PageCommand", ")", "PrintFreelist", "(", "w", "io", ".", "Writer", ",", "buf", "[", "]", "byte", ")", "error", "{", "p", ":=", "(", "*", "page", ")", "(", "unsafe", ".", "Pointer", "(", "&", "buf", "[", "0", "]", ")", ...
// PrintFreelist prints the data for a freelist page.
[ "PrintFreelist", "prints", "the", "data", "for", "a", "freelist", "page", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L583-L597
162,312
boltdb/bolt
cmd/bolt/main.go
newPagesCommand
func newPagesCommand(m *Main) *PagesCommand { return &PagesCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
go
func newPagesCommand(m *Main) *PagesCommand { return &PagesCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
[ "func", "newPagesCommand", "(", "m", "*", "Main", ")", "*", "PagesCommand", "{", "return", "&", "PagesCommand", "{", "Stdin", ":", "m", ".", "Stdin", ",", "Stdout", ":", "m", ".", "Stdout", ",", "Stderr", ":", "m", ".", "Stderr", ",", "}", "\n", "}...
// NewPagesCommand returns a PagesCommand.
[ "NewPagesCommand", "returns", "a", "PagesCommand", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L661-L667
162,313
boltdb/bolt
cmd/bolt/main.go
newStatsCommand
func newStatsCommand(m *Main) *StatsCommand { return &StatsCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
go
func newStatsCommand(m *Main) *StatsCommand { return &StatsCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
[ "func", "newStatsCommand", "(", "m", "*", "Main", ")", "*", "StatsCommand", "{", "return", "&", "StatsCommand", "{", "Stdin", ":", "m", ".", "Stdin", ",", "Stdout", ":", "m", ".", "Stdout", ",", "Stderr", ":", "m", ".", "Stderr", ",", "}", "\n", "}...
// NewStatsCommand returns a StatsCommand.
[ "NewStatsCommand", "returns", "a", "StatsCommand", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L755-L761
162,314
boltdb/bolt
cmd/bolt/main.go
newBenchCommand
func newBenchCommand(m *Main) *BenchCommand { return &BenchCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
go
func newBenchCommand(m *Main) *BenchCommand { return &BenchCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
[ "func", "newBenchCommand", "(", "m", "*", "Main", ")", "*", "BenchCommand", "{", "return", "&", "BenchCommand", "{", "Stdin", ":", "m", ".", "Stdin", ",", "Stdout", ":", "m", ".", "Stdout", ",", "Stderr", ":", "m", ".", "Stderr", ",", "}", "\n", "}...
// NewBenchCommand returns a BenchCommand using the
[ "NewBenchCommand", "returns", "a", "BenchCommand", "using", "the" ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L892-L898
162,315
boltdb/bolt
cmd/bolt/main.go
Run
func (cmd *BenchCommand) Run(args ...string) error { // Parse CLI arguments. options, err := cmd.ParseFlags(args) if err != nil { return err } // Remove path if "-work" is not set. Otherwise keep path. if options.Work { fmt.Fprintf(cmd.Stdout, "work: %s\n", options.Path) } else { defer os.Remove(options.P...
go
func (cmd *BenchCommand) Run(args ...string) error { // Parse CLI arguments. options, err := cmd.ParseFlags(args) if err != nil { return err } // Remove path if "-work" is not set. Otherwise keep path. if options.Work { fmt.Fprintf(cmd.Stdout, "work: %s\n", options.Path) } else { defer os.Remove(options.P...
[ "func", "(", "cmd", "*", "BenchCommand", ")", "Run", "(", "args", "...", "string", ")", "error", "{", "// Parse CLI arguments.", "options", ",", "err", ":=", "cmd", ".", "ParseFlags", "(", "args", ")", "\n", "if", "err", "!=", "nil", "{", "return", "er...
// Run executes the "bench" command.
[ "Run", "executes", "the", "bench", "command", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L901-L939
162,316
boltdb/bolt
cmd/bolt/main.go
runWrites
func (cmd *BenchCommand) runWrites(db *bolt.DB, options *BenchOptions, results *BenchResults) error { // Start profiling for writes. if options.ProfileMode == "rw" || options.ProfileMode == "w" { cmd.startProfiling(options) } t := time.Now() var err error switch options.WriteMode { case "seq": err = cmd.ru...
go
func (cmd *BenchCommand) runWrites(db *bolt.DB, options *BenchOptions, results *BenchResults) error { // Start profiling for writes. if options.ProfileMode == "rw" || options.ProfileMode == "w" { cmd.startProfiling(options) } t := time.Now() var err error switch options.WriteMode { case "seq": err = cmd.ru...
[ "func", "(", "cmd", "*", "BenchCommand", ")", "runWrites", "(", "db", "*", "bolt", ".", "DB", ",", "options", "*", "BenchOptions", ",", "results", "*", "BenchResults", ")", "error", "{", "// Start profiling for writes.", "if", "options", ".", "ProfileMode", ...
// Writes to the database.
[ "Writes", "to", "the", "database", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L989-L1020
162,317
boltdb/bolt
cmd/bolt/main.go
runReads
func (cmd *BenchCommand) runReads(db *bolt.DB, options *BenchOptions, results *BenchResults) error { // Start profiling for reads. if options.ProfileMode == "r" { cmd.startProfiling(options) } t := time.Now() var err error switch options.ReadMode { case "seq": switch options.WriteMode { case "seq-nest", ...
go
func (cmd *BenchCommand) runReads(db *bolt.DB, options *BenchOptions, results *BenchResults) error { // Start profiling for reads. if options.ProfileMode == "r" { cmd.startProfiling(options) } t := time.Now() var err error switch options.ReadMode { case "seq": switch options.WriteMode { case "seq-nest", ...
[ "func", "(", "cmd", "*", "BenchCommand", ")", "runReads", "(", "db", "*", "bolt", ".", "DB", ",", "options", "*", "BenchOptions", ",", "results", "*", "BenchResults", ")", "error", "{", "// Start profiling for reads.", "if", "options", ".", "ProfileMode", "=...
// Reads from the database.
[ "Reads", "from", "the", "database", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L1115-L1145
162,318
boltdb/bolt
cmd/bolt/main.go
startProfiling
func (cmd *BenchCommand) startProfiling(options *BenchOptions) { var err error // Start CPU profiling. if options.CPUProfile != "" { cpuprofile, err = os.Create(options.CPUProfile) if err != nil { fmt.Fprintf(cmd.Stderr, "bench: could not create cpu profile %q: %v\n", options.CPUProfile, err) os.Exit(1) ...
go
func (cmd *BenchCommand) startProfiling(options *BenchOptions) { var err error // Start CPU profiling. if options.CPUProfile != "" { cpuprofile, err = os.Create(options.CPUProfile) if err != nil { fmt.Fprintf(cmd.Stderr, "bench: could not create cpu profile %q: %v\n", options.CPUProfile, err) os.Exit(1) ...
[ "func", "(", "cmd", "*", "BenchCommand", ")", "startProfiling", "(", "options", "*", "BenchOptions", ")", "{", "var", "err", "error", "\n\n", "// Start CPU profiling.", "if", "options", ".", "CPUProfile", "!=", "\"", "\"", "{", "cpuprofile", ",", "err", "=",...
// Starts all profiles set on the options.
[ "Starts", "all", "profiles", "set", "on", "the", "options", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L1218-L1250
162,319
boltdb/bolt
cmd/bolt/main.go
stopProfiling
func (cmd *BenchCommand) stopProfiling() { if cpuprofile != nil { pprof.StopCPUProfile() cpuprofile.Close() cpuprofile = nil } if memprofile != nil { pprof.Lookup("heap").WriteTo(memprofile, 0) memprofile.Close() memprofile = nil } if blockprofile != nil { pprof.Lookup("block").WriteTo(blockprofile...
go
func (cmd *BenchCommand) stopProfiling() { if cpuprofile != nil { pprof.StopCPUProfile() cpuprofile.Close() cpuprofile = nil } if memprofile != nil { pprof.Lookup("heap").WriteTo(memprofile, 0) memprofile.Close() memprofile = nil } if blockprofile != nil { pprof.Lookup("block").WriteTo(blockprofile...
[ "func", "(", "cmd", "*", "BenchCommand", ")", "stopProfiling", "(", ")", "{", "if", "cpuprofile", "!=", "nil", "{", "pprof", ".", "StopCPUProfile", "(", ")", "\n", "cpuprofile", ".", "Close", "(", ")", "\n", "cpuprofile", "=", "nil", "\n", "}", "\n\n",...
// Stops all profiles.
[ "Stops", "all", "profiles", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L1253-L1272
162,320
boltdb/bolt
cmd/bolt/main.go
WriteOpDuration
func (r *BenchResults) WriteOpDuration() time.Duration { if r.WriteOps == 0 { return 0 } return r.WriteDuration / time.Duration(r.WriteOps) }
go
func (r *BenchResults) WriteOpDuration() time.Duration { if r.WriteOps == 0 { return 0 } return r.WriteDuration / time.Duration(r.WriteOps) }
[ "func", "(", "r", "*", "BenchResults", ")", "WriteOpDuration", "(", ")", "time", ".", "Duration", "{", "if", "r", ".", "WriteOps", "==", "0", "{", "return", "0", "\n", "}", "\n", "return", "r", ".", "WriteDuration", "/", "time", ".", "Duration", "(",...
// Returns the duration for a single write operation.
[ "Returns", "the", "duration", "for", "a", "single", "write", "operation", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L1302-L1307
162,321
boltdb/bolt
cmd/bolt/main.go
WriteOpsPerSecond
func (r *BenchResults) WriteOpsPerSecond() int { var op = r.WriteOpDuration() if op == 0 { return 0 } return int(time.Second) / int(op) }
go
func (r *BenchResults) WriteOpsPerSecond() int { var op = r.WriteOpDuration() if op == 0 { return 0 } return int(time.Second) / int(op) }
[ "func", "(", "r", "*", "BenchResults", ")", "WriteOpsPerSecond", "(", ")", "int", "{", "var", "op", "=", "r", ".", "WriteOpDuration", "(", ")", "\n", "if", "op", "==", "0", "{", "return", "0", "\n", "}", "\n", "return", "int", "(", "time", ".", "...
// Returns average number of write operations that can be performed per second.
[ "Returns", "average", "number", "of", "write", "operations", "that", "can", "be", "performed", "per", "second", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L1310-L1316
162,322
boltdb/bolt
cmd/bolt/main.go
ReadOpDuration
func (r *BenchResults) ReadOpDuration() time.Duration { if r.ReadOps == 0 { return 0 } return r.ReadDuration / time.Duration(r.ReadOps) }
go
func (r *BenchResults) ReadOpDuration() time.Duration { if r.ReadOps == 0 { return 0 } return r.ReadDuration / time.Duration(r.ReadOps) }
[ "func", "(", "r", "*", "BenchResults", ")", "ReadOpDuration", "(", ")", "time", ".", "Duration", "{", "if", "r", ".", "ReadOps", "==", "0", "{", "return", "0", "\n", "}", "\n", "return", "r", ".", "ReadDuration", "/", "time", ".", "Duration", "(", ...
// Returns the duration for a single read operation.
[ "Returns", "the", "duration", "for", "a", "single", "read", "operation", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L1319-L1324
162,323
boltdb/bolt
cmd/bolt/main.go
ReadOpsPerSecond
func (r *BenchResults) ReadOpsPerSecond() int { var op = r.ReadOpDuration() if op == 0 { return 0 } return int(time.Second) / int(op) }
go
func (r *BenchResults) ReadOpsPerSecond() int { var op = r.ReadOpDuration() if op == 0 { return 0 } return int(time.Second) / int(op) }
[ "func", "(", "r", "*", "BenchResults", ")", "ReadOpsPerSecond", "(", ")", "int", "{", "var", "op", "=", "r", ".", "ReadOpDuration", "(", ")", "\n", "if", "op", "==", "0", "{", "return", "0", "\n", "}", "\n", "return", "int", "(", "time", ".", "Se...
// Returns average number of read operations that can be performed per second.
[ "Returns", "average", "number", "of", "read", "operations", "that", "can", "be", "performed", "per", "second", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L1327-L1333
162,324
boltdb/bolt
cmd/bolt/main.go
isPrintable
func isPrintable(s string) bool { if !utf8.ValidString(s) { return false } for _, ch := range s { if !unicode.IsPrint(ch) { return false } } return true }
go
func isPrintable(s string) bool { if !utf8.ValidString(s) { return false } for _, ch := range s { if !unicode.IsPrint(ch) { return false } } return true }
[ "func", "isPrintable", "(", "s", "string", ")", "bool", "{", "if", "!", "utf8", ".", "ValidString", "(", "s", ")", "{", "return", "false", "\n", "}", "\n", "for", "_", ",", "ch", ":=", "range", "s", "{", "if", "!", "unicode", ".", "IsPrint", "(",...
// isPrintable returns true if the string is valid unicode and contains only printable runes.
[ "isPrintable", "returns", "true", "if", "the", "string", "is", "valid", "unicode", "and", "contains", "only", "printable", "runes", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L1345-L1355
162,325
boltdb/bolt
cmd/bolt/main.go
ReadPage
func ReadPage(path string, pageID int) (*page, []byte, error) { // Find page size. pageSize, err := ReadPageSize(path) if err != nil { return nil, nil, fmt.Errorf("read page size: %s", err) } // Open database file. f, err := os.Open(path) if err != nil { return nil, nil, err } defer f.Close() // Read on...
go
func ReadPage(path string, pageID int) (*page, []byte, error) { // Find page size. pageSize, err := ReadPageSize(path) if err != nil { return nil, nil, fmt.Errorf("read page size: %s", err) } // Open database file. f, err := os.Open(path) if err != nil { return nil, nil, err } defer f.Close() // Read on...
[ "func", "ReadPage", "(", "path", "string", ",", "pageID", "int", ")", "(", "*", "page", ",", "[", "]", "byte", ",", "error", ")", "{", "// Find page size.", "pageSize", ",", "err", ":=", "ReadPageSize", "(", "path", ")", "\n", "if", "err", "!=", "nil...
// ReadPage reads page info & full page data from a path. // This is not transactionally safe.
[ "ReadPage", "reads", "page", "info", "&", "full", "page", "data", "from", "a", "path", ".", "This", "is", "not", "transactionally", "safe", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L1359-L1395
162,326
boltdb/bolt
cmd/bolt/main.go
ReadPageSize
func ReadPageSize(path string) (int, error) { // Open database file. f, err := os.Open(path) if err != nil { return 0, err } defer f.Close() // Read 4KB chunk. buf := make([]byte, 4096) if _, err := io.ReadFull(f, buf); err != nil { return 0, err } // Read page size from metadata. m := (*meta)(unsafe.P...
go
func ReadPageSize(path string) (int, error) { // Open database file. f, err := os.Open(path) if err != nil { return 0, err } defer f.Close() // Read 4KB chunk. buf := make([]byte, 4096) if _, err := io.ReadFull(f, buf); err != nil { return 0, err } // Read page size from metadata. m := (*meta)(unsafe.P...
[ "func", "ReadPageSize", "(", "path", "string", ")", "(", "int", ",", "error", ")", "{", "// Open database file.", "f", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}",...
// ReadPageSize reads page size a path. // This is not transactionally safe.
[ "ReadPageSize", "reads", "page", "size", "a", "path", ".", "This", "is", "not", "transactionally", "safe", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L1399-L1416
162,327
boltdb/bolt
cmd/bolt/main.go
atois
func atois(strs []string) ([]int, error) { var a []int for _, str := range strs { i, err := strconv.Atoi(str) if err != nil { return nil, err } a = append(a, i) } return a, nil }
go
func atois(strs []string) ([]int, error) { var a []int for _, str := range strs { i, err := strconv.Atoi(str) if err != nil { return nil, err } a = append(a, i) } return a, nil }
[ "func", "atois", "(", "strs", "[", "]", "string", ")", "(", "[", "]", "int", ",", "error", ")", "{", "var", "a", "[", "]", "int", "\n", "for", "_", ",", "str", ":=", "range", "strs", "{", "i", ",", "err", ":=", "strconv", ".", "Atoi", "(", ...
// atois parses a slice of strings into integers.
[ "atois", "parses", "a", "slice", "of", "strings", "into", "integers", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L1419-L1429
162,328
boltdb/bolt
cmd/bolt/main.go
newCompactCommand
func newCompactCommand(m *Main) *CompactCommand { return &CompactCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
go
func newCompactCommand(m *Main) *CompactCommand { return &CompactCommand{ Stdin: m.Stdin, Stdout: m.Stdout, Stderr: m.Stderr, } }
[ "func", "newCompactCommand", "(", "m", "*", "Main", ")", "*", "CompactCommand", "{", "return", "&", "CompactCommand", "{", "Stdin", ":", "m", ".", "Stdin", ",", "Stdout", ":", "m", ".", "Stdout", ",", "Stderr", ":", "m", ".", "Stderr", ",", "}", "\n"...
// newCompactCommand returns a CompactCommand.
[ "newCompactCommand", "returns", "a", "CompactCommand", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L1549-L1555
162,329
boltdb/bolt
cmd/bolt/main.go
walk
func (cmd *CompactCommand) walk(db *bolt.DB, walkFn walkFunc) error { return db.View(func(tx *bolt.Tx) error { return tx.ForEach(func(name []byte, b *bolt.Bucket) error { return cmd.walkBucket(b, nil, name, nil, b.Sequence(), walkFn) }) }) }
go
func (cmd *CompactCommand) walk(db *bolt.DB, walkFn walkFunc) error { return db.View(func(tx *bolt.Tx) error { return tx.ForEach(func(name []byte, b *bolt.Bucket) error { return cmd.walkBucket(b, nil, name, nil, b.Sequence(), walkFn) }) }) }
[ "func", "(", "cmd", "*", "CompactCommand", ")", "walk", "(", "db", "*", "bolt", ".", "DB", ",", "walkFn", "walkFunc", ")", "error", "{", "return", "db", ".", "View", "(", "func", "(", "tx", "*", "bolt", ".", "Tx", ")", "error", "{", "return", "tx...
// walk walks recursively the bolt database db, calling walkFn for each key it finds.
[ "walk", "walks", "recursively", "the", "bolt", "database", "db", "calling", "walkFn", "for", "each", "key", "it", "finds", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cmd/bolt/main.go#L1694-L1700
162,330
boltdb/bolt
node.go
size
func (n *node) size() int { sz, elsz := pageHeaderSize, n.pageElementSize() for i := 0; i < len(n.inodes); i++ { item := &n.inodes[i] sz += elsz + len(item.key) + len(item.value) } return sz }
go
func (n *node) size() int { sz, elsz := pageHeaderSize, n.pageElementSize() for i := 0; i < len(n.inodes); i++ { item := &n.inodes[i] sz += elsz + len(item.key) + len(item.value) } return sz }
[ "func", "(", "n", "*", "node", ")", "size", "(", ")", "int", "{", "sz", ",", "elsz", ":=", "pageHeaderSize", ",", "n", ".", "pageElementSize", "(", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "n", ".", "inodes", ")", ";", "i"...
// size returns the size of the node after serialization.
[ "size", "returns", "the", "size", "of", "the", "node", "after", "serialization", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/node.go#L40-L47
162,331
boltdb/bolt
node.go
sizeLessThan
func (n *node) sizeLessThan(v int) bool { sz, elsz := pageHeaderSize, n.pageElementSize() for i := 0; i < len(n.inodes); i++ { item := &n.inodes[i] sz += elsz + len(item.key) + len(item.value) if sz >= v { return false } } return true }
go
func (n *node) sizeLessThan(v int) bool { sz, elsz := pageHeaderSize, n.pageElementSize() for i := 0; i < len(n.inodes); i++ { item := &n.inodes[i] sz += elsz + len(item.key) + len(item.value) if sz >= v { return false } } return true }
[ "func", "(", "n", "*", "node", ")", "sizeLessThan", "(", "v", "int", ")", "bool", "{", "sz", ",", "elsz", ":=", "pageHeaderSize", ",", "n", ".", "pageElementSize", "(", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "n", ".", "ino...
// sizeLessThan returns true if the node is less than a given size. // This is an optimization to avoid calculating a large node when we only need // to know if it fits inside a certain page size.
[ "sizeLessThan", "returns", "true", "if", "the", "node", "is", "less", "than", "a", "given", "size", ".", "This", "is", "an", "optimization", "to", "avoid", "calculating", "a", "large", "node", "when", "we", "only", "need", "to", "know", "if", "it", "fits...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/node.go#L52-L62
162,332
boltdb/bolt
node.go
childAt
func (n *node) childAt(index int) *node { if n.isLeaf { panic(fmt.Sprintf("invalid childAt(%d) on a leaf node", index)) } return n.bucket.node(n.inodes[index].pgid, n) }
go
func (n *node) childAt(index int) *node { if n.isLeaf { panic(fmt.Sprintf("invalid childAt(%d) on a leaf node", index)) } return n.bucket.node(n.inodes[index].pgid, n) }
[ "func", "(", "n", "*", "node", ")", "childAt", "(", "index", "int", ")", "*", "node", "{", "if", "n", ".", "isLeaf", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "index", ")", ")", "\n", "}", "\n", "return", "n", ".", "buck...
// childAt returns the child node at a given index.
[ "childAt", "returns", "the", "child", "node", "at", "a", "given", "index", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/node.go#L73-L78
162,333
boltdb/bolt
node.go
childIndex
func (n *node) childIndex(child *node) int { index := sort.Search(len(n.inodes), func(i int) bool { return bytes.Compare(n.inodes[i].key, child.key) != -1 }) return index }
go
func (n *node) childIndex(child *node) int { index := sort.Search(len(n.inodes), func(i int) bool { return bytes.Compare(n.inodes[i].key, child.key) != -1 }) return index }
[ "func", "(", "n", "*", "node", ")", "childIndex", "(", "child", "*", "node", ")", "int", "{", "index", ":=", "sort", ".", "Search", "(", "len", "(", "n", ".", "inodes", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "bytes", "."...
// childIndex returns the index of a given child node.
[ "childIndex", "returns", "the", "index", "of", "a", "given", "child", "node", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/node.go#L81-L84
162,334
boltdb/bolt
node.go
nextSibling
func (n *node) nextSibling() *node { if n.parent == nil { return nil } index := n.parent.childIndex(n) if index >= n.parent.numChildren()-1 { return nil } return n.parent.childAt(index + 1) }
go
func (n *node) nextSibling() *node { if n.parent == nil { return nil } index := n.parent.childIndex(n) if index >= n.parent.numChildren()-1 { return nil } return n.parent.childAt(index + 1) }
[ "func", "(", "n", "*", "node", ")", "nextSibling", "(", ")", "*", "node", "{", "if", "n", ".", "parent", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "index", ":=", "n", ".", "parent", ".", "childIndex", "(", "n", ")", "\n", "if", "index...
// nextSibling returns the next node with the same parent.
[ "nextSibling", "returns", "the", "next", "node", "with", "the", "same", "parent", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/node.go#L92-L101
162,335
boltdb/bolt
node.go
prevSibling
func (n *node) prevSibling() *node { if n.parent == nil { return nil } index := n.parent.childIndex(n) if index == 0 { return nil } return n.parent.childAt(index - 1) }
go
func (n *node) prevSibling() *node { if n.parent == nil { return nil } index := n.parent.childIndex(n) if index == 0 { return nil } return n.parent.childAt(index - 1) }
[ "func", "(", "n", "*", "node", ")", "prevSibling", "(", ")", "*", "node", "{", "if", "n", ".", "parent", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "index", ":=", "n", ".", "parent", ".", "childIndex", "(", "n", ")", "\n", "if", "index...
// prevSibling returns the previous node with the same parent.
[ "prevSibling", "returns", "the", "previous", "node", "with", "the", "same", "parent", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/node.go#L104-L113
162,336
boltdb/bolt
node.go
del
func (n *node) del(key []byte) { // Find index of key. index := sort.Search(len(n.inodes), func(i int) bool { return bytes.Compare(n.inodes[i].key, key) != -1 }) // Exit if the key isn't found. if index >= len(n.inodes) || !bytes.Equal(n.inodes[index].key, key) { return } // Delete inode from the node. n.ino...
go
func (n *node) del(key []byte) { // Find index of key. index := sort.Search(len(n.inodes), func(i int) bool { return bytes.Compare(n.inodes[i].key, key) != -1 }) // Exit if the key isn't found. if index >= len(n.inodes) || !bytes.Equal(n.inodes[index].key, key) { return } // Delete inode from the node. n.ino...
[ "func", "(", "n", "*", "node", ")", "del", "(", "key", "[", "]", "byte", ")", "{", "// Find index of key.", "index", ":=", "sort", ".", "Search", "(", "len", "(", "n", ".", "inodes", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", ...
// del removes a key from the node.
[ "del", "removes", "a", "key", "from", "the", "node", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/node.go#L144-L158
162,337
boltdb/bolt
node.go
read
func (n *node) read(p *page) { n.pgid = p.id n.isLeaf = ((p.flags & leafPageFlag) != 0) n.inodes = make(inodes, int(p.count)) for i := 0; i < int(p.count); i++ { inode := &n.inodes[i] if n.isLeaf { elem := p.leafPageElement(uint16(i)) inode.flags = elem.flags inode.key = elem.key() inode.value = el...
go
func (n *node) read(p *page) { n.pgid = p.id n.isLeaf = ((p.flags & leafPageFlag) != 0) n.inodes = make(inodes, int(p.count)) for i := 0; i < int(p.count); i++ { inode := &n.inodes[i] if n.isLeaf { elem := p.leafPageElement(uint16(i)) inode.flags = elem.flags inode.key = elem.key() inode.value = el...
[ "func", "(", "n", "*", "node", ")", "read", "(", "p", "*", "page", ")", "{", "n", ".", "pgid", "=", "p", ".", "id", "\n", "n", ".", "isLeaf", "=", "(", "(", "p", ".", "flags", "&", "leafPageFlag", ")", "!=", "0", ")", "\n", "n", ".", "ino...
// read initializes the node from a page.
[ "read", "initializes", "the", "node", "from", "a", "page", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/node.go#L161-L188
162,338
boltdb/bolt
node.go
write
func (n *node) write(p *page) { // Initialize page. if n.isLeaf { p.flags |= leafPageFlag } else { p.flags |= branchPageFlag } if len(n.inodes) >= 0xFFFF { panic(fmt.Sprintf("inode overflow: %d (pgid=%d)", len(n.inodes), p.id)) } p.count = uint16(len(n.inodes)) // Stop here if there are no items to writ...
go
func (n *node) write(p *page) { // Initialize page. if n.isLeaf { p.flags |= leafPageFlag } else { p.flags |= branchPageFlag } if len(n.inodes) >= 0xFFFF { panic(fmt.Sprintf("inode overflow: %d (pgid=%d)", len(n.inodes), p.id)) } p.count = uint16(len(n.inodes)) // Stop here if there are no items to writ...
[ "func", "(", "n", "*", "node", ")", "write", "(", "p", "*", "page", ")", "{", "// Initialize page.", "if", "n", ".", "isLeaf", "{", "p", ".", "flags", "|=", "leafPageFlag", "\n", "}", "else", "{", "p", ".", "flags", "|=", "branchPageFlag", "\n", "}...
// write writes the items onto one or more pages.
[ "write", "writes", "the", "items", "onto", "one", "or", "more", "pages", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/node.go#L191-L246
162,339
boltdb/bolt
node.go
spill
func (n *node) spill() error { var tx = n.bucket.tx if n.spilled { return nil } // Spill child nodes first. Child nodes can materialize sibling nodes in // the case of split-merge so we cannot use a range loop. We have to check // the children size on every loop iteration. sort.Sort(n.children) for i := 0; i...
go
func (n *node) spill() error { var tx = n.bucket.tx if n.spilled { return nil } // Spill child nodes first. Child nodes can materialize sibling nodes in // the case of split-merge so we cannot use a range loop. We have to check // the children size on every loop iteration. sort.Sort(n.children) for i := 0; i...
[ "func", "(", "n", "*", "node", ")", "spill", "(", ")", "error", "{", "var", "tx", "=", "n", ".", "bucket", ".", "tx", "\n", "if", "n", ".", "spilled", "{", "return", "nil", "\n", "}", "\n\n", "// Spill child nodes first. Child nodes can materialize sibling...
// spill writes the nodes to dirty pages and splits nodes as it goes. // Returns an error if dirty pages cannot be allocated.
[ "spill", "writes", "the", "nodes", "to", "dirty", "pages", "and", "splits", "nodes", "as", "it", "goes", ".", "Returns", "an", "error", "if", "dirty", "pages", "cannot", "be", "allocated", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/node.go#L339-L405
162,340
boltdb/bolt
node.go
removeChild
func (n *node) removeChild(target *node) { for i, child := range n.children { if child == target { n.children = append(n.children[:i], n.children[i+1:]...) return } } }
go
func (n *node) removeChild(target *node) { for i, child := range n.children { if child == target { n.children = append(n.children[:i], n.children[i+1:]...) return } } }
[ "func", "(", "n", "*", "node", ")", "removeChild", "(", "target", "*", "node", ")", "{", "for", "i", ",", "child", ":=", "range", "n", ".", "children", "{", "if", "child", "==", "target", "{", "n", ".", "children", "=", "append", "(", "n", ".", ...
// removes a node from the list of in-memory children. // This does not affect the inodes.
[ "removes", "a", "node", "from", "the", "list", "of", "in", "-", "memory", "children", ".", "This", "does", "not", "affect", "the", "inodes", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/node.go#L512-L519
162,341
boltdb/bolt
node.go
free
func (n *node) free() { if n.pgid != 0 { n.bucket.tx.db.freelist.free(n.bucket.tx.meta.txid, n.bucket.tx.page(n.pgid)) n.pgid = 0 } }
go
func (n *node) free() { if n.pgid != 0 { n.bucket.tx.db.freelist.free(n.bucket.tx.meta.txid, n.bucket.tx.page(n.pgid)) n.pgid = 0 } }
[ "func", "(", "n", "*", "node", ")", "free", "(", ")", "{", "if", "n", ".", "pgid", "!=", "0", "{", "n", ".", "bucket", ".", "tx", ".", "db", ".", "freelist", ".", "free", "(", "n", ".", "bucket", ".", "tx", ".", "meta", ".", "txid", ",", ...
// free adds the node's underlying page to the freelist.
[ "free", "adds", "the", "node", "s", "underlying", "page", "to", "the", "freelist", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/node.go#L554-L559
162,342
boltdb/bolt
bucket.go
newBucket
func newBucket(tx *Tx) Bucket { var b = Bucket{tx: tx, FillPercent: DefaultFillPercent} if tx.writable { b.buckets = make(map[string]*Bucket) b.nodes = make(map[pgid]*node) } return b }
go
func newBucket(tx *Tx) Bucket { var b = Bucket{tx: tx, FillPercent: DefaultFillPercent} if tx.writable { b.buckets = make(map[string]*Bucket) b.nodes = make(map[pgid]*node) } return b }
[ "func", "newBucket", "(", "tx", "*", "Tx", ")", "Bucket", "{", "var", "b", "=", "Bucket", "{", "tx", ":", "tx", ",", "FillPercent", ":", "DefaultFillPercent", "}", "\n", "if", "tx", ".", "writable", "{", "b", ".", "buckets", "=", "make", "(", "map"...
// newBucket returns a new bucket associated with a transaction.
[ "newBucket", "returns", "a", "new", "bucket", "associated", "with", "a", "transaction", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L62-L69
162,343
boltdb/bolt
bucket.go
Cursor
func (b *Bucket) Cursor() *Cursor { // Update transaction statistics. b.tx.stats.CursorCount++ // Allocate and return a cursor. return &Cursor{ bucket: b, stack: make([]elemRef, 0), } }
go
func (b *Bucket) Cursor() *Cursor { // Update transaction statistics. b.tx.stats.CursorCount++ // Allocate and return a cursor. return &Cursor{ bucket: b, stack: make([]elemRef, 0), } }
[ "func", "(", "b", "*", "Bucket", ")", "Cursor", "(", ")", "*", "Cursor", "{", "// Update transaction statistics.", "b", ".", "tx", ".", "stats", ".", "CursorCount", "++", "\n\n", "// Allocate and return a cursor.", "return", "&", "Cursor", "{", "bucket", ":", ...
// Cursor creates a cursor associated with the bucket. // The cursor is only valid as long as the transaction is open. // Do not use a cursor after the transaction is closed.
[ "Cursor", "creates", "a", "cursor", "associated", "with", "the", "bucket", ".", "The", "cursor", "is", "only", "valid", "as", "long", "as", "the", "transaction", "is", "open", ".", "Do", "not", "use", "a", "cursor", "after", "the", "transaction", "is", "...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L89-L98
162,344
boltdb/bolt
bucket.go
Bucket
func (b *Bucket) Bucket(name []byte) *Bucket { if b.buckets != nil { if child := b.buckets[string(name)]; child != nil { return child } } // Move cursor to key. c := b.Cursor() k, v, flags := c.seek(name) // Return nil if the key doesn't exist or it is not a bucket. if !bytes.Equal(name, k) || (flags&bu...
go
func (b *Bucket) Bucket(name []byte) *Bucket { if b.buckets != nil { if child := b.buckets[string(name)]; child != nil { return child } } // Move cursor to key. c := b.Cursor() k, v, flags := c.seek(name) // Return nil if the key doesn't exist or it is not a bucket. if !bytes.Equal(name, k) || (flags&bu...
[ "func", "(", "b", "*", "Bucket", ")", "Bucket", "(", "name", "[", "]", "byte", ")", "*", "Bucket", "{", "if", "b", ".", "buckets", "!=", "nil", "{", "if", "child", ":=", "b", ".", "buckets", "[", "string", "(", "name", ")", "]", ";", "child", ...
// Bucket retrieves a nested bucket by name. // Returns nil if the bucket does not exist. // The bucket instance is only valid for the lifetime of the transaction.
[ "Bucket", "retrieves", "a", "nested", "bucket", "by", "name", ".", "Returns", "nil", "if", "the", "bucket", "does", "not", "exist", ".", "The", "bucket", "instance", "is", "only", "valid", "for", "the", "lifetime", "of", "the", "transaction", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L103-L126
162,345
boltdb/bolt
bucket.go
openBucket
func (b *Bucket) openBucket(value []byte) *Bucket { var child = newBucket(b.tx) // If unaligned load/stores are broken on this arch and value is // unaligned simply clone to an aligned byte array. unaligned := brokenUnaligned && uintptr(unsafe.Pointer(&value[0]))&3 != 0 if unaligned { value = cloneBytes(value)...
go
func (b *Bucket) openBucket(value []byte) *Bucket { var child = newBucket(b.tx) // If unaligned load/stores are broken on this arch and value is // unaligned simply clone to an aligned byte array. unaligned := brokenUnaligned && uintptr(unsafe.Pointer(&value[0]))&3 != 0 if unaligned { value = cloneBytes(value)...
[ "func", "(", "b", "*", "Bucket", ")", "openBucket", "(", "value", "[", "]", "byte", ")", "*", "Bucket", "{", "var", "child", "=", "newBucket", "(", "b", ".", "tx", ")", "\n\n", "// If unaligned load/stores are broken on this arch and value is", "// unaligned sim...
// Helper method that re-interprets a sub-bucket value // from a parent into a Bucket
[ "Helper", "method", "that", "re", "-", "interprets", "a", "sub", "-", "bucket", "value", "from", "a", "parent", "into", "a", "Bucket" ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L130-L156
162,346
boltdb/bolt
bucket.go
CreateBucketIfNotExists
func (b *Bucket) CreateBucketIfNotExists(key []byte) (*Bucket, error) { child, err := b.CreateBucket(key) if err == ErrBucketExists { return b.Bucket(key), nil } else if err != nil { return nil, err } return child, nil }
go
func (b *Bucket) CreateBucketIfNotExists(key []byte) (*Bucket, error) { child, err := b.CreateBucket(key) if err == ErrBucketExists { return b.Bucket(key), nil } else if err != nil { return nil, err } return child, nil }
[ "func", "(", "b", "*", "Bucket", ")", "CreateBucketIfNotExists", "(", "key", "[", "]", "byte", ")", "(", "*", "Bucket", ",", "error", ")", "{", "child", ",", "err", ":=", "b", ".", "CreateBucket", "(", "key", ")", "\n", "if", "err", "==", "ErrBucke...
// CreateBucketIfNotExists creates a new bucket if it doesn't already exist and returns a reference to it. // Returns an error if the bucket name is blank, or if the bucket name is too long. // The bucket instance is only valid for the lifetime of the transaction.
[ "CreateBucketIfNotExists", "creates", "a", "new", "bucket", "if", "it", "doesn", "t", "already", "exist", "and", "returns", "a", "reference", "to", "it", ".", "Returns", "an", "error", "if", "the", "bucket", "name", "is", "blank", "or", "if", "the", "bucke...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L205-L213
162,347
boltdb/bolt
bucket.go
DeleteBucket
func (b *Bucket) DeleteBucket(key []byte) error { if b.tx.db == nil { return ErrTxClosed } else if !b.Writable() { return ErrTxNotWritable } // Move cursor to correct position. c := b.Cursor() k, _, flags := c.seek(key) // Return an error if bucket doesn't exist or is not a bucket. if !bytes.Equal(key, k)...
go
func (b *Bucket) DeleteBucket(key []byte) error { if b.tx.db == nil { return ErrTxClosed } else if !b.Writable() { return ErrTxNotWritable } // Move cursor to correct position. c := b.Cursor() k, _, flags := c.seek(key) // Return an error if bucket doesn't exist or is not a bucket. if !bytes.Equal(key, k)...
[ "func", "(", "b", "*", "Bucket", ")", "DeleteBucket", "(", "key", "[", "]", "byte", ")", "error", "{", "if", "b", ".", "tx", ".", "db", "==", "nil", "{", "return", "ErrTxClosed", "\n", "}", "else", "if", "!", "b", ".", "Writable", "(", ")", "{"...
// DeleteBucket deletes a bucket at the given key. // Returns an error if the bucket does not exists, or if the key represents a non-bucket value.
[ "DeleteBucket", "deletes", "a", "bucket", "at", "the", "given", "key", ".", "Returns", "an", "error", "if", "the", "bucket", "does", "not", "exists", "or", "if", "the", "key", "represents", "a", "non", "-", "bucket", "value", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L217-L261
162,348
boltdb/bolt
bucket.go
Get
func (b *Bucket) Get(key []byte) []byte { k, v, flags := b.Cursor().seek(key) // Return nil if this is a bucket. if (flags & bucketLeafFlag) != 0 { return nil } // If our target node isn't the same key as what's passed in then return nil. if !bytes.Equal(key, k) { return nil } return v }
go
func (b *Bucket) Get(key []byte) []byte { k, v, flags := b.Cursor().seek(key) // Return nil if this is a bucket. if (flags & bucketLeafFlag) != 0 { return nil } // If our target node isn't the same key as what's passed in then return nil. if !bytes.Equal(key, k) { return nil } return v }
[ "func", "(", "b", "*", "Bucket", ")", "Get", "(", "key", "[", "]", "byte", ")", "[", "]", "byte", "{", "k", ",", "v", ",", "flags", ":=", "b", ".", "Cursor", "(", ")", ".", "seek", "(", "key", ")", "\n\n", "// Return nil if this is a bucket.", "i...
// Get retrieves the value for a key in the bucket. // Returns a nil value if the key does not exist or if the key is a nested bucket. // The returned value is only valid for the life of the transaction.
[ "Get", "retrieves", "the", "value", "for", "a", "key", "in", "the", "bucket", ".", "Returns", "a", "nil", "value", "if", "the", "key", "does", "not", "exist", "or", "if", "the", "key", "is", "a", "nested", "bucket", ".", "The", "returned", "value", "...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L266-L279
162,349
boltdb/bolt
bucket.go
Put
func (b *Bucket) Put(key []byte, value []byte) error { if b.tx.db == nil { return ErrTxClosed } else if !b.Writable() { return ErrTxNotWritable } else if len(key) == 0 { return ErrKeyRequired } else if len(key) > MaxKeySize { return ErrKeyTooLarge } else if int64(len(value)) > MaxValueSize { return ErrVa...
go
func (b *Bucket) Put(key []byte, value []byte) error { if b.tx.db == nil { return ErrTxClosed } else if !b.Writable() { return ErrTxNotWritable } else if len(key) == 0 { return ErrKeyRequired } else if len(key) > MaxKeySize { return ErrKeyTooLarge } else if int64(len(value)) > MaxValueSize { return ErrVa...
[ "func", "(", "b", "*", "Bucket", ")", "Put", "(", "key", "[", "]", "byte", ",", "value", "[", "]", "byte", ")", "error", "{", "if", "b", ".", "tx", ".", "db", "==", "nil", "{", "return", "ErrTxClosed", "\n", "}", "else", "if", "!", "b", ".", ...
// Put sets the value for a key in the bucket. // If the key exist then its previous value will be overwritten. // Supplied value must remain valid for the life of the transaction. // Returns an error if the bucket was created from a read-only transaction, if the key is blank, if the key is too large, or if the value i...
[ "Put", "sets", "the", "value", "for", "a", "key", "in", "the", "bucket", ".", "If", "the", "key", "exist", "then", "its", "previous", "value", "will", "be", "overwritten", ".", "Supplied", "value", "must", "remain", "valid", "for", "the", "life", "of", ...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L285-L312
162,350
boltdb/bolt
bucket.go
SetSequence
func (b *Bucket) SetSequence(v uint64) error { if b.tx.db == nil { return ErrTxClosed } else if !b.Writable() { return ErrTxNotWritable } // Materialize the root node if it hasn't been already so that the // bucket will be saved during commit. if b.rootNode == nil { _ = b.node(b.root, nil) } // Incremen...
go
func (b *Bucket) SetSequence(v uint64) error { if b.tx.db == nil { return ErrTxClosed } else if !b.Writable() { return ErrTxNotWritable } // Materialize the root node if it hasn't been already so that the // bucket will be saved during commit. if b.rootNode == nil { _ = b.node(b.root, nil) } // Incremen...
[ "func", "(", "b", "*", "Bucket", ")", "SetSequence", "(", "v", "uint64", ")", "error", "{", "if", "b", ".", "tx", ".", "db", "==", "nil", "{", "return", "ErrTxClosed", "\n", "}", "else", "if", "!", "b", ".", "Writable", "(", ")", "{", "return", ...
// SetSequence updates the sequence number for the bucket.
[ "SetSequence", "updates", "the", "sequence", "number", "for", "the", "bucket", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L343-L359
162,351
boltdb/bolt
bucket.go
Stats
func (b *Bucket) Stats() BucketStats { var s, subStats BucketStats pageSize := b.tx.db.pageSize s.BucketN += 1 if b.root == 0 { s.InlineBucketN += 1 } b.forEachPage(func(p *page, depth int) { if (p.flags & leafPageFlag) != 0 { s.KeyN += int(p.count) // used totals the used bytes for the page used :=...
go
func (b *Bucket) Stats() BucketStats { var s, subStats BucketStats pageSize := b.tx.db.pageSize s.BucketN += 1 if b.root == 0 { s.InlineBucketN += 1 } b.forEachPage(func(p *page, depth int) { if (p.flags & leafPageFlag) != 0 { s.KeyN += int(p.count) // used totals the used bytes for the page used :=...
[ "func", "(", "b", "*", "Bucket", ")", "Stats", "(", ")", "BucketStats", "{", "var", "s", ",", "subStats", "BucketStats", "\n", "pageSize", ":=", "b", ".", "tx", ".", "db", ".", "pageSize", "\n", "s", ".", "BucketN", "+=", "1", "\n", "if", "b", "....
// Stat returns stats on a bucket.
[ "Stat", "returns", "stats", "on", "a", "bucket", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L398-L477
162,352
boltdb/bolt
bucket.go
forEachPage
func (b *Bucket) forEachPage(fn func(*page, int)) { // If we have an inline page then just use that. if b.page != nil { fn(b.page, 0) return } // Otherwise traverse the page hierarchy. b.tx.forEachPage(b.root, 0, fn) }
go
func (b *Bucket) forEachPage(fn func(*page, int)) { // If we have an inline page then just use that. if b.page != nil { fn(b.page, 0) return } // Otherwise traverse the page hierarchy. b.tx.forEachPage(b.root, 0, fn) }
[ "func", "(", "b", "*", "Bucket", ")", "forEachPage", "(", "fn", "func", "(", "*", "page", ",", "int", ")", ")", "{", "// If we have an inline page then just use that.", "if", "b", ".", "page", "!=", "nil", "{", "fn", "(", "b", ".", "page", ",", "0", ...
// forEachPage iterates over every page in a bucket, including inline pages.
[ "forEachPage", "iterates", "over", "every", "page", "in", "a", "bucket", "including", "inline", "pages", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L480-L489
162,353
boltdb/bolt
bucket.go
spill
func (b *Bucket) spill() error { // Spill all child buckets first. for name, child := range b.buckets { // If the child bucket is small enough and it has no child buckets then // write it inline into the parent bucket's page. Otherwise spill it // like a normal bucket and make the parent value a pointer to the ...
go
func (b *Bucket) spill() error { // Spill all child buckets first. for name, child := range b.buckets { // If the child bucket is small enough and it has no child buckets then // write it inline into the parent bucket's page. Otherwise spill it // like a normal bucket and make the parent value a pointer to the ...
[ "func", "(", "b", "*", "Bucket", ")", "spill", "(", ")", "error", "{", "// Spill all child buckets first.", "for", "name", ",", "child", ":=", "range", "b", ".", "buckets", "{", "// If the child bucket is small enough and it has no child buckets then", "// write it inli...
// spill writes all the nodes for this bucket to dirty pages.
[ "spill", "writes", "all", "the", "nodes", "for", "this", "bucket", "to", "dirty", "pages", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L526-L582
162,354
boltdb/bolt
bucket.go
inlineable
func (b *Bucket) inlineable() bool { var n = b.rootNode // Bucket must only contain a single leaf node. if n == nil || !n.isLeaf { return false } // Bucket is not inlineable if it contains subbuckets or if it goes beyond // our threshold for inline bucket size. var size = pageHeaderSize for _, inode := rang...
go
func (b *Bucket) inlineable() bool { var n = b.rootNode // Bucket must only contain a single leaf node. if n == nil || !n.isLeaf { return false } // Bucket is not inlineable if it contains subbuckets or if it goes beyond // our threshold for inline bucket size. var size = pageHeaderSize for _, inode := rang...
[ "func", "(", "b", "*", "Bucket", ")", "inlineable", "(", ")", "bool", "{", "var", "n", "=", "b", ".", "rootNode", "\n\n", "// Bucket must only contain a single leaf node.", "if", "n", "==", "nil", "||", "!", "n", ".", "isLeaf", "{", "return", "false", "\...
// inlineable returns true if a bucket is small enough to be written inline // and if it contains no subbuckets. Otherwise returns false.
[ "inlineable", "returns", "true", "if", "a", "bucket", "is", "small", "enough", "to", "be", "written", "inline", "and", "if", "it", "contains", "no", "subbuckets", ".", "Otherwise", "returns", "false", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L586-L608
162,355
boltdb/bolt
bucket.go
write
func (b *Bucket) write() []byte { // Allocate the appropriate size. var n = b.rootNode var value = make([]byte, bucketHeaderSize+n.size()) // Write a bucket header. var bucket = (*bucket)(unsafe.Pointer(&value[0])) *bucket = *b.bucket // Convert byte slice to a fake page and write the root node. var p = (*pag...
go
func (b *Bucket) write() []byte { // Allocate the appropriate size. var n = b.rootNode var value = make([]byte, bucketHeaderSize+n.size()) // Write a bucket header. var bucket = (*bucket)(unsafe.Pointer(&value[0])) *bucket = *b.bucket // Convert byte slice to a fake page and write the root node. var p = (*pag...
[ "func", "(", "b", "*", "Bucket", ")", "write", "(", ")", "[", "]", "byte", "{", "// Allocate the appropriate size.", "var", "n", "=", "b", ".", "rootNode", "\n", "var", "value", "=", "make", "(", "[", "]", "byte", ",", "bucketHeaderSize", "+", "n", "...
// write allocates and writes a bucket to a byte slice.
[ "write", "allocates", "and", "writes", "a", "bucket", "to", "a", "byte", "slice", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L616-L630
162,356
boltdb/bolt
bucket.go
rebalance
func (b *Bucket) rebalance() { for _, n := range b.nodes { n.rebalance() } for _, child := range b.buckets { child.rebalance() } }
go
func (b *Bucket) rebalance() { for _, n := range b.nodes { n.rebalance() } for _, child := range b.buckets { child.rebalance() } }
[ "func", "(", "b", "*", "Bucket", ")", "rebalance", "(", ")", "{", "for", "_", ",", "n", ":=", "range", "b", ".", "nodes", "{", "n", ".", "rebalance", "(", ")", "\n", "}", "\n", "for", "_", ",", "child", ":=", "range", "b", ".", "buckets", "{"...
// rebalance attempts to balance all nodes.
[ "rebalance", "attempts", "to", "balance", "all", "nodes", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L633-L640
162,357
boltdb/bolt
bucket.go
node
func (b *Bucket) node(pgid pgid, parent *node) *node { _assert(b.nodes != nil, "nodes map expected") // Retrieve node if it's already been created. if n := b.nodes[pgid]; n != nil { return n } // Otherwise create a node and cache it. n := &node{bucket: b, parent: parent} if parent == nil { b.rootNode = n ...
go
func (b *Bucket) node(pgid pgid, parent *node) *node { _assert(b.nodes != nil, "nodes map expected") // Retrieve node if it's already been created. if n := b.nodes[pgid]; n != nil { return n } // Otherwise create a node and cache it. n := &node{bucket: b, parent: parent} if parent == nil { b.rootNode = n ...
[ "func", "(", "b", "*", "Bucket", ")", "node", "(", "pgid", "pgid", ",", "parent", "*", "node", ")", "*", "node", "{", "_assert", "(", "b", ".", "nodes", "!=", "nil", ",", "\"", "\"", ")", "\n\n", "// Retrieve node if it's already been created.", "if", ...
// node creates a node from a page and associates it with a given parent.
[ "node", "creates", "a", "node", "from", "a", "page", "and", "associates", "it", "with", "a", "given", "parent", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L643-L673
162,358
boltdb/bolt
bucket.go
free
func (b *Bucket) free() { if b.root == 0 { return } var tx = b.tx b.forEachPageNode(func(p *page, n *node, _ int) { if p != nil { tx.db.freelist.free(tx.meta.txid, p) } else { n.free() } }) b.root = 0 }
go
func (b *Bucket) free() { if b.root == 0 { return } var tx = b.tx b.forEachPageNode(func(p *page, n *node, _ int) { if p != nil { tx.db.freelist.free(tx.meta.txid, p) } else { n.free() } }) b.root = 0 }
[ "func", "(", "b", "*", "Bucket", ")", "free", "(", ")", "{", "if", "b", ".", "root", "==", "0", "{", "return", "\n", "}", "\n\n", "var", "tx", "=", "b", ".", "tx", "\n", "b", ".", "forEachPageNode", "(", "func", "(", "p", "*", "page", ",", ...
// free recursively frees all pages in the bucket.
[ "free", "recursively", "frees", "all", "pages", "in", "the", "bucket", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L676-L690
162,359
boltdb/bolt
bucket.go
dereference
func (b *Bucket) dereference() { if b.rootNode != nil { b.rootNode.root().dereference() } for _, child := range b.buckets { child.dereference() } }
go
func (b *Bucket) dereference() { if b.rootNode != nil { b.rootNode.root().dereference() } for _, child := range b.buckets { child.dereference() } }
[ "func", "(", "b", "*", "Bucket", ")", "dereference", "(", ")", "{", "if", "b", ".", "rootNode", "!=", "nil", "{", "b", ".", "rootNode", ".", "root", "(", ")", ".", "dereference", "(", ")", "\n", "}", "\n\n", "for", "_", ",", "child", ":=", "ran...
// dereference removes all references to the old mmap.
[ "dereference", "removes", "all", "references", "to", "the", "old", "mmap", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L693-L701
162,360
boltdb/bolt
bucket.go
pageNode
func (b *Bucket) pageNode(id pgid) (*page, *node) { // Inline buckets have a fake page embedded in their value so treat them // differently. We'll return the rootNode (if available) or the fake page. if b.root == 0 { if id != 0 { panic(fmt.Sprintf("inline bucket non-zero page access(2): %d != 0", id)) } if ...
go
func (b *Bucket) pageNode(id pgid) (*page, *node) { // Inline buckets have a fake page embedded in their value so treat them // differently. We'll return the rootNode (if available) or the fake page. if b.root == 0 { if id != 0 { panic(fmt.Sprintf("inline bucket non-zero page access(2): %d != 0", id)) } if ...
[ "func", "(", "b", "*", "Bucket", ")", "pageNode", "(", "id", "pgid", ")", "(", "*", "page", ",", "*", "node", ")", "{", "// Inline buckets have a fake page embedded in their value so treat them", "// differently. We'll return the rootNode (if available) or the fake page.", ...
// pageNode returns the in-memory node, if it exists. // Otherwise returns the underlying page.
[ "pageNode", "returns", "the", "in", "-", "memory", "node", "if", "it", "exists", ".", "Otherwise", "returns", "the", "underlying", "page", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L705-L727
162,361
boltdb/bolt
bucket.go
cloneBytes
func cloneBytes(v []byte) []byte { var clone = make([]byte, len(v)) copy(clone, v) return clone }
go
func cloneBytes(v []byte) []byte { var clone = make([]byte, len(v)) copy(clone, v) return clone }
[ "func", "cloneBytes", "(", "v", "[", "]", "byte", ")", "[", "]", "byte", "{", "var", "clone", "=", "make", "(", "[", "]", "byte", ",", "len", "(", "v", ")", ")", "\n", "copy", "(", "clone", ",", "v", ")", "\n", "return", "clone", "\n", "}" ]
// cloneBytes returns a copy of a given slice.
[ "cloneBytes", "returns", "a", "copy", "of", "a", "given", "slice", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bucket.go#L773-L777
162,362
boltdb/bolt
bolt_unix_solaris.go
mmap
func mmap(db *DB, sz int) error { // Map the data file to memory. b, err := unix.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED|db.MmapFlags) if err != nil { return err } // Advise the kernel that the mmap is accessed randomly. if err := unix.Madvise(b, syscall.MADV_RANDOM); err != nil { ...
go
func mmap(db *DB, sz int) error { // Map the data file to memory. b, err := unix.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED|db.MmapFlags) if err != nil { return err } // Advise the kernel that the mmap is accessed randomly. if err := unix.Madvise(b, syscall.MADV_RANDOM); err != nil { ...
[ "func", "mmap", "(", "db", "*", "DB", ",", "sz", "int", ")", "error", "{", "// Map the data file to memory.", "b", ",", "err", ":=", "unix", ".", "Mmap", "(", "int", "(", "db", ".", "file", ".", "Fd", "(", ")", ")", ",", "0", ",", "sz", ",", "s...
// mmap memory maps a DB's data file.
[ "mmap", "memory", "maps", "a", "DB", "s", "data", "file", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bolt_unix_solaris.go#L58-L75
162,363
boltdb/bolt
bolt_unix_solaris.go
munmap
func munmap(db *DB) error { // Ignore the unmap if we have no mapped data. if db.dataref == nil { return nil } // Unmap using the original byte slice. err := unix.Munmap(db.dataref) db.dataref = nil db.data = nil db.datasz = 0 return err }
go
func munmap(db *DB) error { // Ignore the unmap if we have no mapped data. if db.dataref == nil { return nil } // Unmap using the original byte slice. err := unix.Munmap(db.dataref) db.dataref = nil db.data = nil db.datasz = 0 return err }
[ "func", "munmap", "(", "db", "*", "DB", ")", "error", "{", "// Ignore the unmap if we have no mapped data.", "if", "db", ".", "dataref", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// Unmap using the original byte slice.", "err", ":=", "unix", ".", "M...
// munmap unmaps a DB's data file from memory.
[ "munmap", "unmaps", "a", "DB", "s", "data", "file", "from", "memory", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bolt_unix_solaris.go#L78-L90
162,364
boltdb/bolt
cursor.go
First
func (c *Cursor) First() (key []byte, value []byte) { _assert(c.bucket.tx.db != nil, "tx closed") c.stack = c.stack[:0] p, n := c.bucket.pageNode(c.bucket.root) c.stack = append(c.stack, elemRef{page: p, node: n, index: 0}) c.first() // If we land on an empty page then move to the next value. // https://github....
go
func (c *Cursor) First() (key []byte, value []byte) { _assert(c.bucket.tx.db != nil, "tx closed") c.stack = c.stack[:0] p, n := c.bucket.pageNode(c.bucket.root) c.stack = append(c.stack, elemRef{page: p, node: n, index: 0}) c.first() // If we land on an empty page then move to the next value. // https://github....
[ "func", "(", "c", "*", "Cursor", ")", "First", "(", ")", "(", "key", "[", "]", "byte", ",", "value", "[", "]", "byte", ")", "{", "_assert", "(", "c", ".", "bucket", ".", "tx", ".", "db", "!=", "nil", ",", "\"", "\"", ")", "\n", "c", ".", ...
// First moves the cursor to the first item in the bucket and returns its key and value. // If the bucket is empty then a nil key and value are returned. // The returned key and value are only valid for the life of the transaction.
[ "First", "moves", "the", "cursor", "to", "the", "first", "item", "in", "the", "bucket", "and", "returns", "its", "key", "and", "value", ".", "If", "the", "bucket", "is", "empty", "then", "a", "nil", "key", "and", "value", "are", "returned", ".", "The",...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cursor.go#L31-L50
162,365
boltdb/bolt
cursor.go
Last
func (c *Cursor) Last() (key []byte, value []byte) { _assert(c.bucket.tx.db != nil, "tx closed") c.stack = c.stack[:0] p, n := c.bucket.pageNode(c.bucket.root) ref := elemRef{page: p, node: n} ref.index = ref.count() - 1 c.stack = append(c.stack, ref) c.last() k, v, flags := c.keyValue() if (flags & uint32(buc...
go
func (c *Cursor) Last() (key []byte, value []byte) { _assert(c.bucket.tx.db != nil, "tx closed") c.stack = c.stack[:0] p, n := c.bucket.pageNode(c.bucket.root) ref := elemRef{page: p, node: n} ref.index = ref.count() - 1 c.stack = append(c.stack, ref) c.last() k, v, flags := c.keyValue() if (flags & uint32(buc...
[ "func", "(", "c", "*", "Cursor", ")", "Last", "(", ")", "(", "key", "[", "]", "byte", ",", "value", "[", "]", "byte", ")", "{", "_assert", "(", "c", ".", "bucket", ".", "tx", ".", "db", "!=", "nil", ",", "\"", "\"", ")", "\n", "c", ".", "...
// Last moves the cursor to the last item in the bucket and returns its key and value. // If the bucket is empty then a nil key and value are returned. // The returned key and value are only valid for the life of the transaction.
[ "Last", "moves", "the", "cursor", "to", "the", "last", "item", "in", "the", "bucket", "and", "returns", "its", "key", "and", "value", ".", "If", "the", "bucket", "is", "empty", "then", "a", "nil", "key", "and", "value", "are", "returned", ".", "The", ...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cursor.go#L55-L68
162,366
boltdb/bolt
cursor.go
Next
func (c *Cursor) Next() (key []byte, value []byte) { _assert(c.bucket.tx.db != nil, "tx closed") k, v, flags := c.next() if (flags & uint32(bucketLeafFlag)) != 0 { return k, nil } return k, v }
go
func (c *Cursor) Next() (key []byte, value []byte) { _assert(c.bucket.tx.db != nil, "tx closed") k, v, flags := c.next() if (flags & uint32(bucketLeafFlag)) != 0 { return k, nil } return k, v }
[ "func", "(", "c", "*", "Cursor", ")", "Next", "(", ")", "(", "key", "[", "]", "byte", ",", "value", "[", "]", "byte", ")", "{", "_assert", "(", "c", ".", "bucket", ".", "tx", ".", "db", "!=", "nil", ",", "\"", "\"", ")", "\n", "k", ",", "...
// Next moves the cursor to the next item in the bucket and returns its key and value. // If the cursor is at the end of the bucket then a nil key and value are returned. // The returned key and value are only valid for the life of the transaction.
[ "Next", "moves", "the", "cursor", "to", "the", "next", "item", "in", "the", "bucket", "and", "returns", "its", "key", "and", "value", ".", "If", "the", "cursor", "is", "at", "the", "end", "of", "the", "bucket", "then", "a", "nil", "key", "and", "valu...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cursor.go#L73-L80
162,367
boltdb/bolt
cursor.go
Prev
func (c *Cursor) Prev() (key []byte, value []byte) { _assert(c.bucket.tx.db != nil, "tx closed") // Attempt to move back one element until we're successful. // Move up the stack as we hit the beginning of each page in our stack. for i := len(c.stack) - 1; i >= 0; i-- { elem := &c.stack[i] if elem.index > 0 { ...
go
func (c *Cursor) Prev() (key []byte, value []byte) { _assert(c.bucket.tx.db != nil, "tx closed") // Attempt to move back one element until we're successful. // Move up the stack as we hit the beginning of each page in our stack. for i := len(c.stack) - 1; i >= 0; i-- { elem := &c.stack[i] if elem.index > 0 { ...
[ "func", "(", "c", "*", "Cursor", ")", "Prev", "(", ")", "(", "key", "[", "]", "byte", ",", "value", "[", "]", "byte", ")", "{", "_assert", "(", "c", ".", "bucket", ".", "tx", ".", "db", "!=", "nil", ",", "\"", "\"", ")", "\n\n", "// Attempt t...
// Prev moves the cursor to the previous item in the bucket and returns its key and value. // If the cursor is at the beginning of the bucket then a nil key and value are returned. // The returned key and value are only valid for the life of the transaction.
[ "Prev", "moves", "the", "cursor", "to", "the", "previous", "item", "in", "the", "bucket", "and", "returns", "its", "key", "and", "value", ".", "If", "the", "cursor", "is", "at", "the", "beginning", "of", "the", "bucket", "then", "a", "nil", "key", "and...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cursor.go#L85-L111
162,368
boltdb/bolt
cursor.go
Seek
func (c *Cursor) Seek(seek []byte) (key []byte, value []byte) { k, v, flags := c.seek(seek) // If we ended up after the last element of a page then move to the next one. if ref := &c.stack[len(c.stack)-1]; ref.index >= ref.count() { k, v, flags = c.next() } if k == nil { return nil, nil } else if (flags & u...
go
func (c *Cursor) Seek(seek []byte) (key []byte, value []byte) { k, v, flags := c.seek(seek) // If we ended up after the last element of a page then move to the next one. if ref := &c.stack[len(c.stack)-1]; ref.index >= ref.count() { k, v, flags = c.next() } if k == nil { return nil, nil } else if (flags & u...
[ "func", "(", "c", "*", "Cursor", ")", "Seek", "(", "seek", "[", "]", "byte", ")", "(", "key", "[", "]", "byte", ",", "value", "[", "]", "byte", ")", "{", "k", ",", "v", ",", "flags", ":=", "c", ".", "seek", "(", "seek", ")", "\n\n", "// If ...
// Seek moves the cursor to a given key and returns it. // If the key does not exist then the next key is used. If no keys // follow, a nil key is returned. // The returned key and value are only valid for the life of the transaction.
[ "Seek", "moves", "the", "cursor", "to", "a", "given", "key", "and", "returns", "it", ".", "If", "the", "key", "does", "not", "exist", "then", "the", "next", "key", "is", "used", ".", "If", "no", "keys", "follow", "a", "nil", "key", "is", "returned", ...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cursor.go#L117-L131
162,369
boltdb/bolt
cursor.go
seek
func (c *Cursor) seek(seek []byte) (key []byte, value []byte, flags uint32) { _assert(c.bucket.tx.db != nil, "tx closed") // Start from root page/node and traverse to correct page. c.stack = c.stack[:0] c.search(seek, c.bucket.root) ref := &c.stack[len(c.stack)-1] // If the cursor is pointing to the end of page...
go
func (c *Cursor) seek(seek []byte) (key []byte, value []byte, flags uint32) { _assert(c.bucket.tx.db != nil, "tx closed") // Start from root page/node and traverse to correct page. c.stack = c.stack[:0] c.search(seek, c.bucket.root) ref := &c.stack[len(c.stack)-1] // If the cursor is pointing to the end of page...
[ "func", "(", "c", "*", "Cursor", ")", "seek", "(", "seek", "[", "]", "byte", ")", "(", "key", "[", "]", "byte", ",", "value", "[", "]", "byte", ",", "flags", "uint32", ")", "{", "_assert", "(", "c", ".", "bucket", ".", "tx", ".", "db", "!=", ...
// seek moves the cursor to a given key and returns it. // If the key does not exist then the next key is used.
[ "seek", "moves", "the", "cursor", "to", "a", "given", "key", "and", "returns", "it", ".", "If", "the", "key", "does", "not", "exist", "then", "the", "next", "key", "is", "used", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cursor.go#L154-L169
162,370
boltdb/bolt
cursor.go
first
func (c *Cursor) first() { for { // Exit when we hit a leaf page. var ref = &c.stack[len(c.stack)-1] if ref.isLeaf() { break } // Keep adding pages pointing to the first element to the stack. var pgid pgid if ref.node != nil { pgid = ref.node.inodes[ref.index].pgid } else { pgid = ref.page.br...
go
func (c *Cursor) first() { for { // Exit when we hit a leaf page. var ref = &c.stack[len(c.stack)-1] if ref.isLeaf() { break } // Keep adding pages pointing to the first element to the stack. var pgid pgid if ref.node != nil { pgid = ref.node.inodes[ref.index].pgid } else { pgid = ref.page.br...
[ "func", "(", "c", "*", "Cursor", ")", "first", "(", ")", "{", "for", "{", "// Exit when we hit a leaf page.", "var", "ref", "=", "&", "c", ".", "stack", "[", "len", "(", "c", ".", "stack", ")", "-", "1", "]", "\n", "if", "ref", ".", "isLeaf", "("...
// first moves the cursor to the first leaf element under the last page in the stack.
[ "first", "moves", "the", "cursor", "to", "the", "first", "leaf", "element", "under", "the", "last", "page", "in", "the", "stack", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cursor.go#L172-L190
162,371
boltdb/bolt
cursor.go
next
func (c *Cursor) next() (key []byte, value []byte, flags uint32) { for { // Attempt to move over one element until we're successful. // Move up the stack as we hit the end of each page in our stack. var i int for i = len(c.stack) - 1; i >= 0; i-- { elem := &c.stack[i] if elem.index < elem.count()-1 { ...
go
func (c *Cursor) next() (key []byte, value []byte, flags uint32) { for { // Attempt to move over one element until we're successful. // Move up the stack as we hit the end of each page in our stack. var i int for i = len(c.stack) - 1; i >= 0; i-- { elem := &c.stack[i] if elem.index < elem.count()-1 { ...
[ "func", "(", "c", "*", "Cursor", ")", "next", "(", ")", "(", "key", "[", "]", "byte", ",", "value", "[", "]", "byte", ",", "flags", "uint32", ")", "{", "for", "{", "// Attempt to move over one element until we're successful.", "// Move up the stack as we hit the...
// next moves to the next leaf element and returns the key and value. // If the cursor is at the last leaf element then it stays there and returns nil.
[ "next", "moves", "to", "the", "next", "leaf", "element", "and", "returns", "the", "key", "and", "value", ".", "If", "the", "cursor", "is", "at", "the", "last", "leaf", "element", "then", "it", "stays", "there", "and", "returns", "nil", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cursor.go#L218-L250
162,372
boltdb/bolt
cursor.go
nsearch
func (c *Cursor) nsearch(key []byte) { e := &c.stack[len(c.stack)-1] p, n := e.page, e.node // If we have a node then search its inodes. if n != nil { index := sort.Search(len(n.inodes), func(i int) bool { return bytes.Compare(n.inodes[i].key, key) != -1 }) e.index = index return } // If we have a pa...
go
func (c *Cursor) nsearch(key []byte) { e := &c.stack[len(c.stack)-1] p, n := e.page, e.node // If we have a node then search its inodes. if n != nil { index := sort.Search(len(n.inodes), func(i int) bool { return bytes.Compare(n.inodes[i].key, key) != -1 }) e.index = index return } // If we have a pa...
[ "func", "(", "c", "*", "Cursor", ")", "nsearch", "(", "key", "[", "]", "byte", ")", "{", "e", ":=", "&", "c", ".", "stack", "[", "len", "(", "c", ".", "stack", ")", "-", "1", "]", "\n", "p", ",", "n", ":=", "e", ".", "page", ",", "e", "...
// nsearch searches the leaf node on the top of the stack for a key.
[ "nsearch", "searches", "the", "leaf", "node", "on", "the", "top", "of", "the", "stack", "for", "a", "key", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cursor.go#L318-L337
162,373
boltdb/bolt
cursor.go
keyValue
func (c *Cursor) keyValue() ([]byte, []byte, uint32) { ref := &c.stack[len(c.stack)-1] if ref.count() == 0 || ref.index >= ref.count() { return nil, nil, 0 } // Retrieve value from node. if ref.node != nil { inode := &ref.node.inodes[ref.index] return inode.key, inode.value, inode.flags } // Or retrieve ...
go
func (c *Cursor) keyValue() ([]byte, []byte, uint32) { ref := &c.stack[len(c.stack)-1] if ref.count() == 0 || ref.index >= ref.count() { return nil, nil, 0 } // Retrieve value from node. if ref.node != nil { inode := &ref.node.inodes[ref.index] return inode.key, inode.value, inode.flags } // Or retrieve ...
[ "func", "(", "c", "*", "Cursor", ")", "keyValue", "(", ")", "(", "[", "]", "byte", ",", "[", "]", "byte", ",", "uint32", ")", "{", "ref", ":=", "&", "c", ".", "stack", "[", "len", "(", "c", ".", "stack", ")", "-", "1", "]", "\n", "if", "r...
// keyValue returns the key and value of the current leaf element.
[ "keyValue", "returns", "the", "key", "and", "value", "of", "the", "current", "leaf", "element", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cursor.go#L340-L355
162,374
boltdb/bolt
cursor.go
node
func (c *Cursor) node() *node { _assert(len(c.stack) > 0, "accessing a node with a zero-length cursor stack") // If the top of the stack is a leaf node then just return it. if ref := &c.stack[len(c.stack)-1]; ref.node != nil && ref.isLeaf() { return ref.node } // Start from root and traverse down the hierarchy...
go
func (c *Cursor) node() *node { _assert(len(c.stack) > 0, "accessing a node with a zero-length cursor stack") // If the top of the stack is a leaf node then just return it. if ref := &c.stack[len(c.stack)-1]; ref.node != nil && ref.isLeaf() { return ref.node } // Start from root and traverse down the hierarchy...
[ "func", "(", "c", "*", "Cursor", ")", "node", "(", ")", "*", "node", "{", "_assert", "(", "len", "(", "c", ".", "stack", ")", ">", "0", ",", "\"", "\"", ")", "\n\n", "// If the top of the stack is a leaf node then just return it.", "if", "ref", ":=", "&"...
// node returns the node that the cursor is currently positioned on.
[ "node", "returns", "the", "node", "that", "the", "cursor", "is", "currently", "positioned", "on", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cursor.go#L358-L377
162,375
boltdb/bolt
cursor.go
count
func (r *elemRef) count() int { if r.node != nil { return len(r.node.inodes) } return int(r.page.count) }
go
func (r *elemRef) count() int { if r.node != nil { return len(r.node.inodes) } return int(r.page.count) }
[ "func", "(", "r", "*", "elemRef", ")", "count", "(", ")", "int", "{", "if", "r", ".", "node", "!=", "nil", "{", "return", "len", "(", "r", ".", "node", ".", "inodes", ")", "\n", "}", "\n", "return", "int", "(", "r", ".", "page", ".", "count",...
// count returns the number of inodes or page elements.
[ "count", "returns", "the", "number", "of", "inodes", "or", "page", "elements", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/cursor.go#L395-L400
162,376
boltdb/bolt
page.go
leafPageElements
func (p *page) leafPageElements() []leafPageElement { if p.count == 0 { return nil } return ((*[0x7FFFFFF]leafPageElement)(unsafe.Pointer(&p.ptr)))[:] }
go
func (p *page) leafPageElements() []leafPageElement { if p.count == 0 { return nil } return ((*[0x7FFFFFF]leafPageElement)(unsafe.Pointer(&p.ptr)))[:] }
[ "func", "(", "p", "*", "page", ")", "leafPageElements", "(", ")", "[", "]", "leafPageElement", "{", "if", "p", ".", "count", "==", "0", "{", "return", "nil", "\n", "}", "\n", "return", "(", "(", "*", "[", "0x7FFFFFF", "]", "leafPageElement", ")", "...
// leafPageElements retrieves a list of leaf nodes.
[ "leafPageElements", "retrieves", "a", "list", "of", "leaf", "nodes", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/page.go#L64-L69
162,377
boltdb/bolt
page.go
branchPageElements
func (p *page) branchPageElements() []branchPageElement { if p.count == 0 { return nil } return ((*[0x7FFFFFF]branchPageElement)(unsafe.Pointer(&p.ptr)))[:] }
go
func (p *page) branchPageElements() []branchPageElement { if p.count == 0 { return nil } return ((*[0x7FFFFFF]branchPageElement)(unsafe.Pointer(&p.ptr)))[:] }
[ "func", "(", "p", "*", "page", ")", "branchPageElements", "(", ")", "[", "]", "branchPageElement", "{", "if", "p", ".", "count", "==", "0", "{", "return", "nil", "\n", "}", "\n", "return", "(", "(", "*", "[", "0x7FFFFFF", "]", "branchPageElement", ")...
// branchPageElements retrieves a list of branch nodes.
[ "branchPageElements", "retrieves", "a", "list", "of", "branch", "nodes", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/page.go#L77-L82
162,378
boltdb/bolt
page.go
hexdump
func (p *page) hexdump(n int) { buf := (*[maxAllocSize]byte)(unsafe.Pointer(p))[:n] fmt.Fprintf(os.Stderr, "%x\n", buf) }
go
func (p *page) hexdump(n int) { buf := (*[maxAllocSize]byte)(unsafe.Pointer(p))[:n] fmt.Fprintf(os.Stderr, "%x\n", buf) }
[ "func", "(", "p", "*", "page", ")", "hexdump", "(", "n", "int", ")", "{", "buf", ":=", "(", "*", "[", "maxAllocSize", "]", "byte", ")", "(", "unsafe", ".", "Pointer", "(", "p", ")", ")", "[", ":", "n", "]", "\n", "fmt", ".", "Fprintf", "(", ...
// dump writes n bytes of the page to STDERR as hex output.
[ "dump", "writes", "n", "bytes", "of", "the", "page", "to", "STDERR", "as", "hex", "output", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/page.go#L85-L88
162,379
boltdb/bolt
page.go
value
func (n *leafPageElement) value() []byte { buf := (*[maxAllocSize]byte)(unsafe.Pointer(n)) return (*[maxAllocSize]byte)(unsafe.Pointer(&buf[n.pos+n.ksize]))[:n.vsize:n.vsize] }
go
func (n *leafPageElement) value() []byte { buf := (*[maxAllocSize]byte)(unsafe.Pointer(n)) return (*[maxAllocSize]byte)(unsafe.Pointer(&buf[n.pos+n.ksize]))[:n.vsize:n.vsize] }
[ "func", "(", "n", "*", "leafPageElement", ")", "value", "(", ")", "[", "]", "byte", "{", "buf", ":=", "(", "*", "[", "maxAllocSize", "]", "byte", ")", "(", "unsafe", ".", "Pointer", "(", "n", ")", ")", "\n", "return", "(", "*", "[", "maxAllocSize...
// value returns a byte slice of the node value.
[ "value", "returns", "a", "byte", "slice", "of", "the", "node", "value", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/page.go#L124-L127
162,380
boltdb/bolt
page.go
merge
func (a pgids) merge(b pgids) pgids { // Return the opposite slice if one is nil. if len(a) == 0 { return b } if len(b) == 0 { return a } merged := make(pgids, len(a)+len(b)) mergepgids(merged, a, b) return merged }
go
func (a pgids) merge(b pgids) pgids { // Return the opposite slice if one is nil. if len(a) == 0 { return b } if len(b) == 0 { return a } merged := make(pgids, len(a)+len(b)) mergepgids(merged, a, b) return merged }
[ "func", "(", "a", "pgids", ")", "merge", "(", "b", "pgids", ")", "pgids", "{", "// Return the opposite slice if one is nil.", "if", "len", "(", "a", ")", "==", "0", "{", "return", "b", "\n", "}", "\n", "if", "len", "(", "b", ")", "==", "0", "{", "r...
// merge returns the sorted union of a and b.
[ "merge", "returns", "the", "sorted", "union", "of", "a", "and", "b", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/page.go#L144-L155
162,381
boltdb/bolt
page.go
mergepgids
func mergepgids(dst, a, b pgids) { if len(dst) < len(a)+len(b) { panic(fmt.Errorf("mergepgids bad len %d < %d + %d", len(dst), len(a), len(b))) } // Copy in the opposite slice if one is nil. if len(a) == 0 { copy(dst, b) return } if len(b) == 0 { copy(dst, a) return } // Merged will hold all elements...
go
func mergepgids(dst, a, b pgids) { if len(dst) < len(a)+len(b) { panic(fmt.Errorf("mergepgids bad len %d < %d + %d", len(dst), len(a), len(b))) } // Copy in the opposite slice if one is nil. if len(a) == 0 { copy(dst, b) return } if len(b) == 0 { copy(dst, a) return } // Merged will hold all elements...
[ "func", "mergepgids", "(", "dst", ",", "a", ",", "b", "pgids", ")", "{", "if", "len", "(", "dst", ")", "<", "len", "(", "a", ")", "+", "len", "(", "b", ")", "{", "panic", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "dst", ...
// mergepgids copies the sorted union of a and b into dst. // If dst is too small, it panics.
[ "mergepgids", "copies", "the", "sorted", "union", "of", "a", "and", "b", "into", "dst", ".", "If", "dst", "is", "too", "small", "it", "panics", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/page.go#L159-L197
162,382
appleboy/gorush
gorush/version.go
PrintGoRushVersion
func PrintGoRushVersion() { fmt.Printf(`GoRush %s, Compiler: %s %s, Copyright (C) 2019 Bo-Yi Wu, Inc.`, version, runtime.Compiler, runtime.Version()) fmt.Println() }
go
func PrintGoRushVersion() { fmt.Printf(`GoRush %s, Compiler: %s %s, Copyright (C) 2019 Bo-Yi Wu, Inc.`, version, runtime.Compiler, runtime.Version()) fmt.Println() }
[ "func", "PrintGoRushVersion", "(", ")", "{", "fmt", ".", "Printf", "(", "`GoRush %s, Compiler: %s %s, Copyright (C) 2019 Bo-Yi Wu, Inc.`", ",", "version", ",", "runtime", ".", "Compiler", ",", "runtime", ".", "Version", "(", ")", ")", "\n", "fmt", ".", "Println", ...
// PrintGoRushVersion provide print server engine
[ "PrintGoRushVersion", "provide", "print", "server", "engine" ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/gorush/version.go#L23-L29
162,383
appleboy/gorush
gorush/notification_fcm.go
InitFCMClient
func InitFCMClient(key string) (*fcm.Client, error) { var err error if key == "" { return nil, errors.New("Missing Android API Key") } if key != PushConf.Android.APIKey { return fcm.NewClient(key) } if FCMClient == nil { FCMClient, err = fcm.NewClient(key) return FCMClient, err } return FCMClient, n...
go
func InitFCMClient(key string) (*fcm.Client, error) { var err error if key == "" { return nil, errors.New("Missing Android API Key") } if key != PushConf.Android.APIKey { return fcm.NewClient(key) } if FCMClient == nil { FCMClient, err = fcm.NewClient(key) return FCMClient, err } return FCMClient, n...
[ "func", "InitFCMClient", "(", "key", "string", ")", "(", "*", "fcm", ".", "Client", ",", "error", ")", "{", "var", "err", "error", "\n\n", "if", "key", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n",...
// InitFCMClient use for initialize FCM Client.
[ "InitFCMClient", "use", "for", "initialize", "FCM", "Client", "." ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/gorush/notification_fcm.go#L11-L28
162,384
appleboy/gorush
main.go
pinger
func pinger() error { resp, err := http.Get("http://localhost:" + gorush.PushConf.Core.Port + gorush.PushConf.API.HealthURI) if err != nil { return err } defer resp.Body.Close() if resp.StatusCode != 200 { return fmt.Errorf("server returned non-200 status code") } return nil }
go
func pinger() error { resp, err := http.Get("http://localhost:" + gorush.PushConf.Core.Port + gorush.PushConf.API.HealthURI) if err != nil { return err } defer resp.Body.Close() if resp.StatusCode != 200 { return fmt.Errorf("server returned non-200 status code") } return nil }
[ "func", "pinger", "(", ")", "error", "{", "resp", ",", "err", ":=", "http", ".", "Get", "(", "\"", "\"", "+", "gorush", ".", "PushConf", ".", "Core", ".", "Port", "+", "gorush", ".", "PushConf", ".", "API", ".", "HealthURI", ")", "\n", "if", "err...
// handles pinging the endpoint and returns an error if the // agent is in an unhealthy state.
[ "handles", "pinging", "the", "endpoint", "and", "returns", "an", "error", "if", "the", "agent", "is", "in", "an", "unhealthy", "state", "." ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/main.go#L297-L307
162,385
appleboy/gorush
rpc/server.go
Send
func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*proto.NotificationReply, error) { var badge = int(in.Badge) notification := gorush.PushNotification{ Platform: int(in.Platform), Tokens: in.Tokens, Message: in.Message, Title: in.Title, Topic: ...
go
func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*proto.NotificationReply, error) { var badge = int(in.Badge) notification := gorush.PushNotification{ Platform: int(in.Platform), Tokens: in.Tokens, Message: in.Message, Title: in.Title, Topic: ...
[ "func", "(", "s", "*", "Server", ")", "Send", "(", "ctx", "context", ".", "Context", ",", "in", "*", "proto", ".", "NotificationRequest", ")", "(", "*", "proto", ".", "NotificationReply", ",", "error", ")", "{", "var", "badge", "=", "int", "(", "in",...
// Send implements helloworld.GreeterServer
[ "Send", "implements", "helloworld", ".", "GreeterServer" ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/rpc/server.go#L50-L91
162,386
appleboy/gorush
rpc/server.go
RunGRPCServer
func RunGRPCServer() error { if !gorush.PushConf.GRPC.Enabled { gorush.LogAccess.Debug("gRPC server is disabled.") return nil } lis, err := net.Listen("tcp", ":"+gorush.PushConf.GRPC.Port) if err != nil { gorush.LogError.Errorf("failed to listen: %v", err) return err } s := grpc.NewServer() srv := NewSe...
go
func RunGRPCServer() error { if !gorush.PushConf.GRPC.Enabled { gorush.LogAccess.Debug("gRPC server is disabled.") return nil } lis, err := net.Listen("tcp", ":"+gorush.PushConf.GRPC.Port) if err != nil { gorush.LogError.Errorf("failed to listen: %v", err) return err } s := grpc.NewServer() srv := NewSe...
[ "func", "RunGRPCServer", "(", ")", "error", "{", "if", "!", "gorush", ".", "PushConf", ".", "GRPC", ".", "Enabled", "{", "gorush", ".", "LogAccess", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}", "\n\n", "lis", ",", "err", ":...
// RunGRPCServer run gorush grpc server
[ "RunGRPCServer", "run", "gorush", "grpc", "server" ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/rpc/server.go#L94-L118
162,387
appleboy/gorush
gorush/notification_apns.go
InitAPNSClient
func InitAPNSClient() error { if PushConf.Ios.Enabled { var err error var authKey *ecdsa.PrivateKey var certificateKey tls.Certificate var ext string if PushConf.Ios.KeyPath != "" { ext = filepath.Ext(PushConf.Ios.KeyPath) switch ext { case ".p12": certificateKey, err = certificate.FromP12File...
go
func InitAPNSClient() error { if PushConf.Ios.Enabled { var err error var authKey *ecdsa.PrivateKey var certificateKey tls.Certificate var ext string if PushConf.Ios.KeyPath != "" { ext = filepath.Ext(PushConf.Ios.KeyPath) switch ext { case ".p12": certificateKey, err = certificate.FromP12File...
[ "func", "InitAPNSClient", "(", ")", "error", "{", "if", "PushConf", ".", "Ios", ".", "Enabled", "{", "var", "err", "error", "\n", "var", "authKey", "*", "ecdsa", ".", "PrivateKey", "\n", "var", "certificateKey", "tls", ".", "Certificate", "\n", "var", "e...
// InitAPNSClient use for initialize APNs Client.
[ "InitAPNSClient", "use", "for", "initialize", "APNs", "Client", "." ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/gorush/notification_apns.go#L26-L101
162,388
appleboy/gorush
gorush/notification_apns.go
PushToIOS
func PushToIOS(req PushNotification) bool { LogAccess.Debug("Start push notification for iOS") if PushConf.Core.Sync { defer req.WaitDone() } var ( retryCount = 0 maxRetry = PushConf.Ios.MaxRetry ) if req.Retry > 0 && req.Retry < maxRetry { maxRetry = req.Retry } Retry: var ( isError = false ...
go
func PushToIOS(req PushNotification) bool { LogAccess.Debug("Start push notification for iOS") if PushConf.Core.Sync { defer req.WaitDone() } var ( retryCount = 0 maxRetry = PushConf.Ios.MaxRetry ) if req.Retry > 0 && req.Retry < maxRetry { maxRetry = req.Retry } Retry: var ( isError = false ...
[ "func", "PushToIOS", "(", "req", "PushNotification", ")", "bool", "{", "LogAccess", ".", "Debug", "(", "\"", "\"", ")", "\n", "if", "PushConf", ".", "Core", ".", "Sync", "{", "defer", "req", ".", "WaitDone", "(", ")", "\n", "}", "\n\n", "var", "(", ...
// PushToIOS provide send notification to APNs server.
[ "PushToIOS", "provide", "send", "notification", "to", "APNs", "server", "." ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/gorush/notification_apns.go#L261-L331
162,389
appleboy/gorush
gorush/status.go
InitAppStatus
func InitAppStatus() error { LogAccess.Debug("Init App Status Engine as ", PushConf.Stat.Engine) switch PushConf.Stat.Engine { case "memory": StatStorage = memory.New() case "redis": StatStorage = redis.New(PushConf) case "boltdb": StatStorage = boltdb.New(PushConf) case "buntdb": StatStorage = buntdb.New...
go
func InitAppStatus() error { LogAccess.Debug("Init App Status Engine as ", PushConf.Stat.Engine) switch PushConf.Stat.Engine { case "memory": StatStorage = memory.New() case "redis": StatStorage = redis.New(PushConf) case "boltdb": StatStorage = boltdb.New(PushConf) case "buntdb": StatStorage = buntdb.New...
[ "func", "InitAppStatus", "(", ")", "error", "{", "LogAccess", ".", "Debug", "(", "\"", "\"", ",", "PushConf", ".", "Stat", ".", "Engine", ")", "\n", "switch", "PushConf", ".", "Stat", ".", "Engine", "{", "case", "\"", "\"", ":", "StatStorage", "=", "...
// InitAppStatus for initialize app status
[ "InitAppStatus", "for", "initialize", "app", "status" ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/gorush/status.go#L43-L70
162,390
appleboy/gorush
gorush/status.go
StatMiddleware
func StatMiddleware() gin.HandlerFunc { return func(c *gin.Context) { beginning, recorder := Stats.Begin(c.Writer) c.Next() Stats.End(beginning, stats.WithRecorder(recorder)) } }
go
func StatMiddleware() gin.HandlerFunc { return func(c *gin.Context) { beginning, recorder := Stats.Begin(c.Writer) c.Next() Stats.End(beginning, stats.WithRecorder(recorder)) } }
[ "func", "StatMiddleware", "(", ")", "gin", ".", "HandlerFunc", "{", "return", "func", "(", "c", "*", "gin", ".", "Context", ")", "{", "beginning", ",", "recorder", ":=", "Stats", ".", "Begin", "(", "c", ".", "Writer", ")", "\n", "c", ".", "Next", "...
// StatMiddleware response time, status code count, etc.
[ "StatMiddleware", "response", "time", "status", "code", "count", "etc", "." ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/gorush/status.go#L92-L98
162,391
appleboy/gorush
rpc/client_grpc_health.go
NewGrpcHealthClient
func NewGrpcHealthClient(conn *grpc.ClientConn) Health { client := new(healthClient) client.client = proto.NewHealthClient(conn) client.conn = conn return client }
go
func NewGrpcHealthClient(conn *grpc.ClientConn) Health { client := new(healthClient) client.client = proto.NewHealthClient(conn) client.conn = conn return client }
[ "func", "NewGrpcHealthClient", "(", "conn", "*", "grpc", ".", "ClientConn", ")", "Health", "{", "client", ":=", "new", "(", "healthClient", ")", "\n", "client", ".", "client", "=", "proto", ".", "NewHealthClient", "(", "conn", ")", "\n", "client", ".", "...
// NewGrpcHealthClient returns a new grpc Client.
[ "NewGrpcHealthClient", "returns", "a", "new", "grpc", "Client", "." ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/rpc/client_grpc_health.go#L21-L26
162,392
appleboy/gorush
gorush/notification.go
AddLog
func (p *PushNotification) AddLog(log LogPushEntry) { if p.log != nil { *p.log = append(*p.log, log) } }
go
func (p *PushNotification) AddLog(log LogPushEntry) { if p.log != nil { *p.log = append(*p.log, log) } }
[ "func", "(", "p", "*", "PushNotification", ")", "AddLog", "(", "log", "LogPushEntry", ")", "{", "if", "p", ".", "log", "!=", "nil", "{", "*", "p", ".", "log", "=", "append", "(", "*", "p", ".", "log", ",", "log", ")", "\n", "}", "\n", "}" ]
// AddLog record fail log of notification
[ "AddLog", "record", "fail", "log", "of", "notification" ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/gorush/notification.go#L110-L114
162,393
appleboy/gorush
gorush/notification.go
CheckMessage
func CheckMessage(req PushNotification) error { var msg string // ignore send topic mesaage from FCM if !req.IsTopic() && len(req.Tokens) == 0 && len(req.To) == 0 { msg = "the message must specify at least one registration ID" LogAccess.Debug(msg) return errors.New(msg) } if len(req.Tokens) == PlatFormIos ...
go
func CheckMessage(req PushNotification) error { var msg string // ignore send topic mesaage from FCM if !req.IsTopic() && len(req.Tokens) == 0 && len(req.To) == 0 { msg = "the message must specify at least one registration ID" LogAccess.Debug(msg) return errors.New(msg) } if len(req.Tokens) == PlatFormIos ...
[ "func", "CheckMessage", "(", "req", "PushNotification", ")", "error", "{", "var", "msg", "string", "\n\n", "// ignore send topic mesaage from FCM", "if", "!", "req", ".", "IsTopic", "(", ")", "&&", "len", "(", "req", ".", "Tokens", ")", "==", "0", "&&", "l...
// CheckMessage for check request message
[ "CheckMessage", "for", "check", "request", "message" ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/gorush/notification.go#L124-L155
162,394
appleboy/gorush
gorush/notification.go
SetProxy
func SetProxy(proxy string) error { proxyURL, err := url.ParseRequestURI(proxy) if err != nil { return err } http.DefaultTransport = &http.Transport{Proxy: http.ProxyURL(proxyURL)} LogAccess.Debug("Set http proxy as " + proxy) return nil }
go
func SetProxy(proxy string) error { proxyURL, err := url.ParseRequestURI(proxy) if err != nil { return err } http.DefaultTransport = &http.Transport{Proxy: http.ProxyURL(proxyURL)} LogAccess.Debug("Set http proxy as " + proxy) return nil }
[ "func", "SetProxy", "(", "proxy", "string", ")", "error", "{", "proxyURL", ",", "err", ":=", "url", ".", "ParseRequestURI", "(", "proxy", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "http", ".", "DefaultTransport", "...
// SetProxy only working for FCM server.
[ "SetProxy", "only", "working", "for", "FCM", "server", "." ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/gorush/notification.go#L158-L170
162,395
appleboy/gorush
gorush/notification.go
CheckPushConf
func CheckPushConf() error { if !PushConf.Ios.Enabled && !PushConf.Android.Enabled { return errors.New("Please enable iOS or Android config in yml config") } if PushConf.Ios.Enabled { if PushConf.Ios.KeyPath == "" && PushConf.Ios.KeyBase64 == "" { return errors.New("Missing iOS certificate key") } // ch...
go
func CheckPushConf() error { if !PushConf.Ios.Enabled && !PushConf.Android.Enabled { return errors.New("Please enable iOS or Android config in yml config") } if PushConf.Ios.Enabled { if PushConf.Ios.KeyPath == "" && PushConf.Ios.KeyBase64 == "" { return errors.New("Missing iOS certificate key") } // ch...
[ "func", "CheckPushConf", "(", ")", "error", "{", "if", "!", "PushConf", ".", "Ios", ".", "Enabled", "&&", "!", "PushConf", ".", "Android", ".", "Enabled", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "PushConf",...
// CheckPushConf provide check your yml config.
[ "CheckPushConf", "provide", "check", "your", "yml", "config", "." ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/gorush/notification.go#L173-L198
162,396
appleboy/gorush
gorush/metrics.go
NewMetrics
func NewMetrics() Metrics { return Metrics{ TotalPushCount: prometheus.NewDesc( namespace+"total_push_count", "Number of push count", nil, nil, ), IosSuccess: prometheus.NewDesc( namespace+"ios_success", "Number of iOS success count", nil, nil, ), IosError: prometheus.NewDesc( namespace...
go
func NewMetrics() Metrics { return Metrics{ TotalPushCount: prometheus.NewDesc( namespace+"total_push_count", "Number of push count", nil, nil, ), IosSuccess: prometheus.NewDesc( namespace+"ios_success", "Number of iOS success count", nil, nil, ), IosError: prometheus.NewDesc( namespace...
[ "func", "NewMetrics", "(", ")", "Metrics", "{", "return", "Metrics", "{", "TotalPushCount", ":", "prometheus", ".", "NewDesc", "(", "namespace", "+", "\"", "\"", ",", "\"", "\"", ",", "nil", ",", "nil", ",", ")", ",", "IosSuccess", ":", "prometheus", "...
// NewMetrics returns a new Metrics with all prometheus.Desc initialized
[ "NewMetrics", "returns", "a", "new", "Metrics", "with", "all", "prometheus", ".", "Desc", "initialized" ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/gorush/metrics.go#L21-L55
162,397
appleboy/gorush
gorush/metrics.go
Describe
func (c Metrics) Describe(ch chan<- *prometheus.Desc) { ch <- c.TotalPushCount ch <- c.IosSuccess ch <- c.IosError ch <- c.AndroidSuccess ch <- c.AndroidError ch <- c.QueueUsage }
go
func (c Metrics) Describe(ch chan<- *prometheus.Desc) { ch <- c.TotalPushCount ch <- c.IosSuccess ch <- c.IosError ch <- c.AndroidSuccess ch <- c.AndroidError ch <- c.QueueUsage }
[ "func", "(", "c", "Metrics", ")", "Describe", "(", "ch", "chan", "<-", "*", "prometheus", ".", "Desc", ")", "{", "ch", "<-", "c", ".", "TotalPushCount", "\n", "ch", "<-", "c", ".", "IosSuccess", "\n", "ch", "<-", "c", ".", "IosError", "\n", "ch", ...
// Describe returns all possible prometheus.Desc
[ "Describe", "returns", "all", "possible", "prometheus", ".", "Desc" ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/gorush/metrics.go#L58-L65
162,398
appleboy/gorush
gorush/metrics.go
Collect
func (c Metrics) Collect(ch chan<- prometheus.Metric) { ch <- prometheus.MustNewConstMetric( c.TotalPushCount, prometheus.GaugeValue, float64(StatStorage.GetTotalCount()), ) ch <- prometheus.MustNewConstMetric( c.IosSuccess, prometheus.GaugeValue, float64(StatStorage.GetIosSuccess()), ) ch <- prometheu...
go
func (c Metrics) Collect(ch chan<- prometheus.Metric) { ch <- prometheus.MustNewConstMetric( c.TotalPushCount, prometheus.GaugeValue, float64(StatStorage.GetTotalCount()), ) ch <- prometheus.MustNewConstMetric( c.IosSuccess, prometheus.GaugeValue, float64(StatStorage.GetIosSuccess()), ) ch <- prometheu...
[ "func", "(", "c", "Metrics", ")", "Collect", "(", "ch", "chan", "<-", "prometheus", ".", "Metric", ")", "{", "ch", "<-", "prometheus", ".", "MustNewConstMetric", "(", "c", ".", "TotalPushCount", ",", "prometheus", ".", "GaugeValue", ",", "float64", "(", ...
// Collect returns the metrics with values
[ "Collect", "returns", "the", "metrics", "with", "values" ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/gorush/metrics.go#L68-L99
162,399
appleboy/gorush
gorush/log.go
InitLog
func InitLog() error { var err error // init logger LogAccess = logrus.New() LogError = logrus.New() LogAccess.Formatter = &logrus.TextFormatter{ TimestampFormat: "2006/01/02 - 15:04:05", FullTimestamp: true, } LogError.Formatter = &logrus.TextFormatter{ TimestampFormat: "2006/01/02 - 15:04:05", Fu...
go
func InitLog() error { var err error // init logger LogAccess = logrus.New() LogError = logrus.New() LogAccess.Formatter = &logrus.TextFormatter{ TimestampFormat: "2006/01/02 - 15:04:05", FullTimestamp: true, } LogError.Formatter = &logrus.TextFormatter{ TimestampFormat: "2006/01/02 - 15:04:05", Fu...
[ "func", "InitLog", "(", ")", "error", "{", "var", "err", "error", "\n\n", "// init logger", "LogAccess", "=", "logrus", ".", "New", "(", ")", "\n", "LogError", "=", "logrus", ".", "New", "(", ")", "\n\n", "LogAccess", ".", "Formatter", "=", "&", "logru...
// InitLog use for initial log module
[ "InitLog", "use", "for", "initial", "log", "module" ]
55ff87f96fb660b9b632289448a880f7249e4c90
https://github.com/appleboy/gorush/blob/55ff87f96fb660b9b632289448a880f7249e4c90/gorush/log.go#L51-L87