repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
google/gops
main.go
displayProcessTree
func displayProcessTree() { ps := goprocess.FindAll() pstree = make(map[int][]goprocess.P) for _, p := range ps { pstree[p.PPID] = append(pstree[p.PPID], p) } tree := treeprint.New() tree.SetValue("...") seen := map[int]bool{} for _, p := range ps { constructProcessTree(p.PPID, p, seen, tree) } fmt.Printl...
go
func displayProcessTree() { ps := goprocess.FindAll() pstree = make(map[int][]goprocess.P) for _, p := range ps { pstree[p.PPID] = append(pstree[p.PPID], p) } tree := treeprint.New() tree.SetValue("...") seen := map[int]bool{} for _, p := range ps { constructProcessTree(p.PPID, p, seen, tree) } fmt.Printl...
[ "func", "displayProcessTree", "(", ")", "{", "ps", ":=", "goprocess", ".", "FindAll", "(", ")", "\n", "pstree", "=", "make", "(", "map", "[", "int", "]", "[", "]", "goprocess", ".", "P", ")", "\n", "for", "_", ",", "p", ":=", "range", "ps", "{", ...
// displayProcessTree displays a tree of all the running Go processes.
[ "displayProcessTree", "displays", "a", "tree", "of", "all", "the", "running", "Go", "processes", "." ]
036f72c5be1f7a0970ffae4907e05dd11f49de35
https://github.com/google/gops/blob/036f72c5be1f7a0970ffae4907e05dd11f49de35/main.go#L183-L196
train
google/gops
main.go
constructProcessTree
func constructProcessTree(ppid int, process goprocess.P, seen map[int]bool, tree treeprint.Tree) { if seen[ppid] { return } seen[ppid] = true if ppid != process.PPID { output := strconv.Itoa(ppid) + " (" + process.Exec + ")" + " {" + process.BuildVersion + "}" if process.Agent { tree = tree.AddMetaBranch("...
go
func constructProcessTree(ppid int, process goprocess.P, seen map[int]bool, tree treeprint.Tree) { if seen[ppid] { return } seen[ppid] = true if ppid != process.PPID { output := strconv.Itoa(ppid) + " (" + process.Exec + ")" + " {" + process.BuildVersion + "}" if process.Agent { tree = tree.AddMetaBranch("...
[ "func", "constructProcessTree", "(", "ppid", "int", ",", "process", "goprocess", ".", "P", ",", "seen", "map", "[", "int", "]", "bool", ",", "tree", "treeprint", ".", "Tree", ")", "{", "if", "seen", "[", "ppid", "]", "{", "return", "\n", "}", "\n", ...
// constructProcessTree constructs the process tree in a depth-first fashion.
[ "constructProcessTree", "constructs", "the", "process", "tree", "in", "a", "depth", "-", "first", "fashion", "." ]
036f72c5be1f7a0970ffae4907e05dd11f49de35
https://github.com/google/gops/blob/036f72c5be1f7a0970ffae4907e05dd11f49de35/main.go#L199-L218
train
google/gops
goprocess/gp.go
FindAll
func FindAll() []P { pss, err := ps.Processes() if err != nil { return nil } var wg sync.WaitGroup wg.Add(len(pss)) found := make(chan P) for _, pr := range pss { pr := pr go func() { defer wg.Done() path, version, agent, ok, err := isGo(pr) if err != nil { // TODO(jbd): Return a list of er...
go
func FindAll() []P { pss, err := ps.Processes() if err != nil { return nil } var wg sync.WaitGroup wg.Add(len(pss)) found := make(chan P) for _, pr := range pss { pr := pr go func() { defer wg.Done() path, version, agent, ok, err := isGo(pr) if err != nil { // TODO(jbd): Return a list of er...
[ "func", "FindAll", "(", ")", "[", "]", "P", "{", "pss", ",", "err", ":=", "ps", ".", "Processes", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n\n", "var", "wg", "sync", ".", "WaitGroup", "\n", "wg", ".", "Add", ...
// FindAll returns all the Go processes currently running on this host.
[ "FindAll", "returns", "all", "the", "Go", "processes", "currently", "running", "on", "this", "host", "." ]
036f72c5be1f7a0970ffae4907e05dd11f49de35
https://github.com/google/gops/blob/036f72c5be1f7a0970ffae4907e05dd11f49de35/goprocess/gp.go#L29-L70
train
google/gops
goprocess/gp.go
Find
func Find(pid int) (p P, ok bool, err error) { pr, err := ps.FindProcess(pid) if err != nil { return P{}, false, err } path, version, agent, ok, err := isGo(pr) if !ok { return P{}, false, nil } return P{ PID: pr.Pid(), PPID: pr.PPid(), Exec: pr.Executable(), Path: pa...
go
func Find(pid int) (p P, ok bool, err error) { pr, err := ps.FindProcess(pid) if err != nil { return P{}, false, err } path, version, agent, ok, err := isGo(pr) if !ok { return P{}, false, nil } return P{ PID: pr.Pid(), PPID: pr.PPid(), Exec: pr.Executable(), Path: pa...
[ "func", "Find", "(", "pid", "int", ")", "(", "p", "P", ",", "ok", "bool", ",", "err", "error", ")", "{", "pr", ",", "err", ":=", "ps", ".", "FindProcess", "(", "pid", ")", "\n", "if", "err", "!=", "nil", "{", "return", "P", "{", "}", ",", "...
// Find finds info about the process identified with the given PID.
[ "Find", "finds", "info", "about", "the", "process", "identified", "with", "the", "given", "PID", "." ]
036f72c5be1f7a0970ffae4907e05dd11f49de35
https://github.com/google/gops/blob/036f72c5be1f7a0970ffae4907e05dd11f49de35/goprocess/gp.go#L73-L90
train
google/gops
goprocess/gp.go
isGo
func isGo(pr ps.Process) (path, version string, agent, ok bool, err error) { if pr.Pid() == 0 { // ignore system process return } path, err = pr.Path() if err != nil { return } var versionInfo goversion.Version versionInfo, err = goversion.ReadExe(path) if err != nil { return } ok = true version = ve...
go
func isGo(pr ps.Process) (path, version string, agent, ok bool, err error) { if pr.Pid() == 0 { // ignore system process return } path, err = pr.Path() if err != nil { return } var versionInfo goversion.Version versionInfo, err = goversion.ReadExe(path) if err != nil { return } ok = true version = ve...
[ "func", "isGo", "(", "pr", "ps", ".", "Process", ")", "(", "path", ",", "version", "string", ",", "agent", ",", "ok", "bool", ",", "err", "error", ")", "{", "if", "pr", ".", "Pid", "(", ")", "==", "0", "{", "// ignore system process", "return", "\n...
// isGo looks up the runtime.buildVersion symbol // in the process' binary and determines if the process // if a Go process or not. If the process is a Go process, // it reports PID, binary name and full path of the binary.
[ "isGo", "looks", "up", "the", "runtime", ".", "buildVersion", "symbol", "in", "the", "process", "binary", "and", "determines", "if", "the", "process", "if", "a", "Go", "process", "or", "not", ".", "If", "the", "process", "is", "a", "Go", "process", "it",...
036f72c5be1f7a0970ffae4907e05dd11f49de35
https://github.com/google/gops/blob/036f72c5be1f7a0970ffae4907e05dd11f49de35/goprocess/gp.go#L96-L118
train
google/gops
agent/agent.go
Close
func Close() { mu.Lock() defer mu.Unlock() if portfile != "" { os.Remove(portfile) portfile = "" } if listener != nil { listener.Close() } }
go
func Close() { mu.Lock() defer mu.Unlock() if portfile != "" { os.Remove(portfile) portfile = "" } if listener != nil { listener.Close() } }
[ "func", "Close", "(", ")", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "portfile", "!=", "\"", "\"", "{", "os", ".", "Remove", "(", "portfile", ")", "\n", "portfile", "=", "\"", "\"", "\n", "}",...
// Close closes the agent, removing temporary files and closing the TCP listener. // If no agent is listening, Close does nothing.
[ "Close", "closes", "the", "agent", "removing", "temporary", "files", "and", "closing", "the", "TCP", "listener", ".", "If", "no", "agent", "is", "listening", "Close", "does", "nothing", "." ]
036f72c5be1f7a0970ffae4907e05dd11f49de35
https://github.com/google/gops/blob/036f72c5be1f7a0970ffae4907e05dd11f49de35/agent/agent.go#L150-L161
train
mitchellh/gox
go.go
GoMainDirs
func GoMainDirs(packages []string, GoCmd string) ([]string, error) { args := make([]string, 0, len(packages)+3) args = append(args, "list", "-f", "{{.Name}}|{{.ImportPath}}") args = append(args, packages...) output, err := execGo(GoCmd, nil, "", args...) if err != nil { return nil, err } results := make([]st...
go
func GoMainDirs(packages []string, GoCmd string) ([]string, error) { args := make([]string, 0, len(packages)+3) args = append(args, "list", "-f", "{{.Name}}|{{.ImportPath}}") args = append(args, packages...) output, err := execGo(GoCmd, nil, "", args...) if err != nil { return nil, err } results := make([]st...
[ "func", "GoMainDirs", "(", "packages", "[", "]", "string", ",", "GoCmd", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "args", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "packages", ")", "+", "3", ")", "...
// GoMainDirs returns the file paths to the packages that are "main" // packages, from the list of packages given. The list of packages can // include relative paths, the special "..." Go keyword, etc.
[ "GoMainDirs", "returns", "the", "file", "paths", "to", "the", "packages", "that", "are", "main", "packages", "from", "the", "list", "of", "packages", "given", ".", "The", "list", "of", "packages", "can", "include", "relative", "paths", "the", "special", "......
d8caaff5a9dc98f4cfa1fcce6e7265a04689f641
https://github.com/mitchellh/gox/blob/d8caaff5a9dc98f4cfa1fcce6e7265a04689f641/go.go#L129-L157
train
mitchellh/gox
go.go
GoRoot
func GoRoot() (string, error) { output, err := execGo("go", nil, "", "env", "GOROOT") if err != nil { return "", err } return strings.TrimSpace(output), nil }
go
func GoRoot() (string, error) { output, err := execGo("go", nil, "", "env", "GOROOT") if err != nil { return "", err } return strings.TrimSpace(output), nil }
[ "func", "GoRoot", "(", ")", "(", "string", ",", "error", ")", "{", "output", ",", "err", ":=", "execGo", "(", "\"", "\"", ",", "nil", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"",...
// GoRoot returns the GOROOT value for the compiled `go` binary.
[ "GoRoot", "returns", "the", "GOROOT", "value", "for", "the", "compiled", "go", "binary", "." ]
d8caaff5a9dc98f4cfa1fcce6e7265a04689f641
https://github.com/mitchellh/gox/blob/d8caaff5a9dc98f4cfa1fcce6e7265a04689f641/go.go#L160-L167
train
mitchellh/gox
toolchain.go
mainBuildToolchain
func mainBuildToolchain(parallel int, platformFlag PlatformFlag, verbose bool) int { if _, err := exec.LookPath("go"); err != nil { fmt.Fprintf(os.Stderr, "You must have Go already built for your native platform\n") fmt.Fprintf(os.Stderr, "and the `go` binary on the PATH to build toolchains.\n") return 1 } //...
go
func mainBuildToolchain(parallel int, platformFlag PlatformFlag, verbose bool) int { if _, err := exec.LookPath("go"); err != nil { fmt.Fprintf(os.Stderr, "You must have Go already built for your native platform\n") fmt.Fprintf(os.Stderr, "and the `go` binary on the PATH to build toolchains.\n") return 1 } //...
[ "func", "mainBuildToolchain", "(", "parallel", "int", ",", "platformFlag", "PlatformFlag", ",", "verbose", "bool", ")", "int", "{", "if", "_", ",", "err", ":=", "exec", ".", "LookPath", "(", "\"", "\"", ")", ";", "err", "!=", "nil", "{", "fmt", ".", ...
// The "main" method for when the toolchain build is requested.
[ "The", "main", "method", "for", "when", "the", "toolchain", "build", "is", "requested", "." ]
d8caaff5a9dc98f4cfa1fcce6e7265a04689f641
https://github.com/mitchellh/gox/blob/d8caaff5a9dc98f4cfa1fcce6e7265a04689f641/toolchain.go#L17-L92
train
mitchellh/gox
platform.go
SupportedPlatforms
func SupportedPlatforms(v string) []Platform { // Use latest if we get an unexpected version string if !strings.HasPrefix(v, "go") { return PlatformsLatest } // go-version only cares about version numbers v = v[2:] current, err := version.NewVersion(v) if err != nil { log.Printf("Unable to parse current go ...
go
func SupportedPlatforms(v string) []Platform { // Use latest if we get an unexpected version string if !strings.HasPrefix(v, "go") { return PlatformsLatest } // go-version only cares about version numbers v = v[2:] current, err := version.NewVersion(v) if err != nil { log.Printf("Unable to parse current go ...
[ "func", "SupportedPlatforms", "(", "v", "string", ")", "[", "]", "Platform", "{", "// Use latest if we get an unexpected version string", "if", "!", "strings", ".", "HasPrefix", "(", "v", ",", "\"", "\"", ")", "{", "return", "PlatformsLatest", "\n", "}", "\n", ...
// SupportedPlatforms returns the full list of supported platforms for // the version of Go that is
[ "SupportedPlatforms", "returns", "the", "full", "list", "of", "supported", "platforms", "for", "the", "version", "of", "Go", "that", "is" ]
d8caaff5a9dc98f4cfa1fcce6e7265a04689f641
https://github.com/mitchellh/gox/blob/d8caaff5a9dc98f4cfa1fcce6e7265a04689f641/platform.go#L105-L149
train
skip2/go-qrcode
qrcode.go
encode
func (q *QRCode) encode(numTerminatorBits int) { q.addTerminatorBits(numTerminatorBits) q.addPadding() encoded := q.encodeBlocks() const numMasks int = 8 penalty := 0 for mask := 0; mask < numMasks; mask++ { var s *symbol var err error s, err = buildRegularSymbol(q.version, mask, encoded) if err != n...
go
func (q *QRCode) encode(numTerminatorBits int) { q.addTerminatorBits(numTerminatorBits) q.addPadding() encoded := q.encodeBlocks() const numMasks int = 8 penalty := 0 for mask := 0; mask < numMasks; mask++ { var s *symbol var err error s, err = buildRegularSymbol(q.version, mask, encoded) if err != n...
[ "func", "(", "q", "*", "QRCode", ")", "encode", "(", "numTerminatorBits", "int", ")", "{", "q", ".", "addTerminatorBits", "(", "numTerminatorBits", ")", "\n", "q", ".", "addPadding", "(", ")", "\n\n", "encoded", ":=", "q", ".", "encodeBlocks", "(", ")", ...
// encode completes the steps required to encode the QR Code. These include // adding the terminator bits and padding, splitting the data into blocks and // applying the error correction, and selecting the best data mask.
[ "encode", "completes", "the", "steps", "required", "to", "encode", "the", "QR", "Code", ".", "These", "include", "adding", "the", "terminator", "bits", "and", "padding", "splitting", "the", "data", "into", "blocks", "and", "applying", "the", "error", "correcti...
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/qrcode.go#L374-L409
train
skip2/go-qrcode
qrcode.go
addPadding
func (q *QRCode) addPadding() { numDataBits := q.version.numDataBits() if q.data.Len() == numDataBits { return } // Pad to the nearest codeword boundary. q.data.AppendNumBools(q.version.numBitsToPadToCodeword(q.data.Len()), false) // Pad codewords 0b11101100 and 0b00010001. padding := [2]*bitset.Bitset{ b...
go
func (q *QRCode) addPadding() { numDataBits := q.version.numDataBits() if q.data.Len() == numDataBits { return } // Pad to the nearest codeword boundary. q.data.AppendNumBools(q.version.numBitsToPadToCodeword(q.data.Len()), false) // Pad codewords 0b11101100 and 0b00010001. padding := [2]*bitset.Bitset{ b...
[ "func", "(", "q", "*", "QRCode", ")", "addPadding", "(", ")", "{", "numDataBits", ":=", "q", ".", "version", ".", "numDataBits", "(", ")", "\n\n", "if", "q", ".", "data", ".", "Len", "(", ")", "==", "numDataBits", "{", "return", "\n", "}", "\n\n", ...
// addPadding pads the encoded data upto the full length required.
[ "addPadding", "pads", "the", "encoded", "data", "upto", "the", "full", "length", "required", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/qrcode.go#L506-L533
train
skip2/go-qrcode
qrcode.go
ToString
func (q *QRCode) ToString(inverseColor bool) string { bits := q.Bitmap() var buf bytes.Buffer for y := range bits { for x := range bits[y] { if bits[y][x] != inverseColor { buf.WriteString(" ") } else { buf.WriteString("██") } } buf.WriteString("\n") } return buf.String() }
go
func (q *QRCode) ToString(inverseColor bool) string { bits := q.Bitmap() var buf bytes.Buffer for y := range bits { for x := range bits[y] { if bits[y][x] != inverseColor { buf.WriteString(" ") } else { buf.WriteString("██") } } buf.WriteString("\n") } return buf.String() }
[ "func", "(", "q", "*", "QRCode", ")", "ToString", "(", "inverseColor", "bool", ")", "string", "{", "bits", ":=", "q", ".", "Bitmap", "(", ")", "\n", "var", "buf", "bytes", ".", "Buffer", "\n", "for", "y", ":=", "range", "bits", "{", "for", "x", "...
// ToString produces a multi-line string that forms a QR-code image.
[ "ToString", "produces", "a", "multi", "-", "line", "string", "that", "forms", "a", "QR", "-", "code", "image", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/qrcode.go#L536-L550
train
skip2/go-qrcode
qrcode.go
ToSmallString
func (q *QRCode) ToSmallString(inverseColor bool) string { bits := q.Bitmap() var buf bytes.Buffer // if there is an odd number of rows, the last one needs special treatment for y := 0; y < len(bits)-1; y += 2 { for x := range bits[y] { if bits[y][x] == bits[y+1][x] { if bits[y][x] != inverseColor { b...
go
func (q *QRCode) ToSmallString(inverseColor bool) string { bits := q.Bitmap() var buf bytes.Buffer // if there is an odd number of rows, the last one needs special treatment for y := 0; y < len(bits)-1; y += 2 { for x := range bits[y] { if bits[y][x] == bits[y+1][x] { if bits[y][x] != inverseColor { b...
[ "func", "(", "q", "*", "QRCode", ")", "ToSmallString", "(", "inverseColor", "bool", ")", "string", "{", "bits", ":=", "q", ".", "Bitmap", "(", ")", "\n", "var", "buf", "bytes", ".", "Buffer", "\n", "// if there is an odd number of rows, the last one needs specia...
// ToSmallString produces a multi-line string that forms a QR-code image, a // factor two smaller in x and y then ToString.
[ "ToSmallString", "produces", "a", "multi", "-", "line", "string", "that", "forms", "a", "QR", "-", "code", "image", "a", "factor", "two", "smaller", "in", "x", "and", "y", "then", "ToString", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/qrcode.go#L554-L589
train
skip2/go-qrcode
bitset/bitset.go
New
func New(v ...bool) *Bitset { b := &Bitset{numBits: 0, bits: make([]byte, 0)} b.AppendBools(v...) return b }
go
func New(v ...bool) *Bitset { b := &Bitset{numBits: 0, bits: make([]byte, 0)} b.AppendBools(v...) return b }
[ "func", "New", "(", "v", "...", "bool", ")", "*", "Bitset", "{", "b", ":=", "&", "Bitset", "{", "numBits", ":", "0", ",", "bits", ":", "make", "(", "[", "]", "byte", ",", "0", ")", "}", "\n", "b", ".", "AppendBools", "(", "v", "...", ")", "...
// New returns an initialised Bitset with optional initial bits v.
[ "New", "returns", "an", "initialised", "Bitset", "with", "optional", "initial", "bits", "v", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/bitset/bitset.go#L43-L48
train
skip2/go-qrcode
bitset/bitset.go
Clone
func Clone(from *Bitset) *Bitset { return &Bitset{numBits: from.numBits, bits: from.bits[:]} }
go
func Clone(from *Bitset) *Bitset { return &Bitset{numBits: from.numBits, bits: from.bits[:]} }
[ "func", "Clone", "(", "from", "*", "Bitset", ")", "*", "Bitset", "{", "return", "&", "Bitset", "{", "numBits", ":", "from", ".", "numBits", ",", "bits", ":", "from", ".", "bits", "[", ":", "]", "}", "\n", "}" ]
// Clone returns a copy.
[ "Clone", "returns", "a", "copy", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/bitset/bitset.go#L51-L53
train
skip2/go-qrcode
bitset/bitset.go
Substr
func (b *Bitset) Substr(start int, end int) *Bitset { if start > end || end > b.numBits { log.Panicf("Out of range start=%d end=%d numBits=%d", start, end, b.numBits) } result := New() result.ensureCapacity(end - start) for i := start; i < end; i++ { if b.At(i) { result.bits[result.numBits/8] |= 0x80 >> u...
go
func (b *Bitset) Substr(start int, end int) *Bitset { if start > end || end > b.numBits { log.Panicf("Out of range start=%d end=%d numBits=%d", start, end, b.numBits) } result := New() result.ensureCapacity(end - start) for i := start; i < end; i++ { if b.At(i) { result.bits[result.numBits/8] |= 0x80 >> u...
[ "func", "(", "b", "*", "Bitset", ")", "Substr", "(", "start", "int", ",", "end", "int", ")", "*", "Bitset", "{", "if", "start", ">", "end", "||", "end", ">", "b", ".", "numBits", "{", "log", ".", "Panicf", "(", "\"", "\"", ",", "start", ",", ...
// Substr returns a substring, consisting of the bits from indexes start to end.
[ "Substr", "returns", "a", "substring", "consisting", "of", "the", "bits", "from", "indexes", "start", "to", "end", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/bitset/bitset.go#L56-L72
train
skip2/go-qrcode
bitset/bitset.go
AppendBytes
func (b *Bitset) AppendBytes(data []byte) { for _, d := range data { b.AppendByte(d, 8) } }
go
func (b *Bitset) AppendBytes(data []byte) { for _, d := range data { b.AppendByte(d, 8) } }
[ "func", "(", "b", "*", "Bitset", ")", "AppendBytes", "(", "data", "[", "]", "byte", ")", "{", "for", "_", ",", "d", ":=", "range", "data", "{", "b", ".", "AppendByte", "(", "d", ",", "8", ")", "\n", "}", "\n", "}" ]
// AppendBytes appends a list of whole bytes.
[ "AppendBytes", "appends", "a", "list", "of", "whole", "bytes", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/bitset/bitset.go#L99-L103
train
skip2/go-qrcode
bitset/bitset.go
AppendByte
func (b *Bitset) AppendByte(value byte, numBits int) { b.ensureCapacity(numBits) if numBits > 8 { log.Panicf("numBits %d out of range 0-8", numBits) } for i := numBits - 1; i >= 0; i-- { if value&(1<<uint(i)) != 0 { b.bits[b.numBits/8] |= 0x80 >> uint(b.numBits%8) } b.numBits++ } }
go
func (b *Bitset) AppendByte(value byte, numBits int) { b.ensureCapacity(numBits) if numBits > 8 { log.Panicf("numBits %d out of range 0-8", numBits) } for i := numBits - 1; i >= 0; i-- { if value&(1<<uint(i)) != 0 { b.bits[b.numBits/8] |= 0x80 >> uint(b.numBits%8) } b.numBits++ } }
[ "func", "(", "b", "*", "Bitset", ")", "AppendByte", "(", "value", "byte", ",", "numBits", "int", ")", "{", "b", ".", "ensureCapacity", "(", "numBits", ")", "\n\n", "if", "numBits", ">", "8", "{", "log", ".", "Panicf", "(", "\"", "\"", ",", "numBits...
// AppendByte appends the numBits least significant bits from value.
[ "AppendByte", "appends", "the", "numBits", "least", "significant", "bits", "from", "value", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/bitset/bitset.go#L106-L120
train
skip2/go-qrcode
bitset/bitset.go
AppendUint32
func (b *Bitset) AppendUint32(value uint32, numBits int) { b.ensureCapacity(numBits) if numBits > 32 { log.Panicf("numBits %d out of range 0-32", numBits) } for i := numBits - 1; i >= 0; i-- { if value&(1<<uint(i)) != 0 { b.bits[b.numBits/8] |= 0x80 >> uint(b.numBits%8) } b.numBits++ } }
go
func (b *Bitset) AppendUint32(value uint32, numBits int) { b.ensureCapacity(numBits) if numBits > 32 { log.Panicf("numBits %d out of range 0-32", numBits) } for i := numBits - 1; i >= 0; i-- { if value&(1<<uint(i)) != 0 { b.bits[b.numBits/8] |= 0x80 >> uint(b.numBits%8) } b.numBits++ } }
[ "func", "(", "b", "*", "Bitset", ")", "AppendUint32", "(", "value", "uint32", ",", "numBits", "int", ")", "{", "b", ".", "ensureCapacity", "(", "numBits", ")", "\n\n", "if", "numBits", ">", "32", "{", "log", ".", "Panicf", "(", "\"", "\"", ",", "nu...
// AppendUint32 appends the numBits least significant bits from value.
[ "AppendUint32", "appends", "the", "numBits", "least", "significant", "bits", "from", "value", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/bitset/bitset.go#L123-L137
train
skip2/go-qrcode
bitset/bitset.go
ensureCapacity
func (b *Bitset) ensureCapacity(numBits int) { numBits += b.numBits newNumBytes := numBits / 8 if numBits%8 != 0 { newNumBytes++ } if len(b.bits) >= newNumBytes { return } b.bits = append(b.bits, make([]byte, newNumBytes+2*len(b.bits))...) }
go
func (b *Bitset) ensureCapacity(numBits int) { numBits += b.numBits newNumBytes := numBits / 8 if numBits%8 != 0 { newNumBytes++ } if len(b.bits) >= newNumBytes { return } b.bits = append(b.bits, make([]byte, newNumBytes+2*len(b.bits))...) }
[ "func", "(", "b", "*", "Bitset", ")", "ensureCapacity", "(", "numBits", "int", ")", "{", "numBits", "+=", "b", ".", "numBits", "\n\n", "newNumBytes", ":=", "numBits", "/", "8", "\n", "if", "numBits", "%", "8", "!=", "0", "{", "newNumBytes", "++", "\n...
// ensureCapacity ensures the Bitset can store an additional |numBits|. // // The underlying array is expanded if necessary. To prevent frequent // reallocation, expanding the underlying array at least doubles its capacity.
[ "ensureCapacity", "ensures", "the", "Bitset", "can", "store", "an", "additional", "|numBits|", ".", "The", "underlying", "array", "is", "expanded", "if", "necessary", ".", "To", "prevent", "frequent", "reallocation", "expanding", "the", "underlying", "array", "at"...
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/bitset/bitset.go#L143-L156
train
skip2/go-qrcode
bitset/bitset.go
AppendBools
func (b *Bitset) AppendBools(bits ...bool) { b.ensureCapacity(len(bits)) for _, v := range bits { if v { b.bits[b.numBits/8] |= 0x80 >> uint(b.numBits%8) } b.numBits++ } }
go
func (b *Bitset) AppendBools(bits ...bool) { b.ensureCapacity(len(bits)) for _, v := range bits { if v { b.bits[b.numBits/8] |= 0x80 >> uint(b.numBits%8) } b.numBits++ } }
[ "func", "(", "b", "*", "Bitset", ")", "AppendBools", "(", "bits", "...", "bool", ")", "{", "b", ".", "ensureCapacity", "(", "len", "(", "bits", ")", ")", "\n\n", "for", "_", ",", "v", ":=", "range", "bits", "{", "if", "v", "{", "b", ".", "bits"...
// AppendBools appends bits to the Bitset.
[ "AppendBools", "appends", "bits", "to", "the", "Bitset", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/bitset/bitset.go#L173-L182
train
skip2/go-qrcode
bitset/bitset.go
AppendNumBools
func (b *Bitset) AppendNumBools(num int, value bool) { for i := 0; i < num; i++ { b.AppendBools(value) } }
go
func (b *Bitset) AppendNumBools(num int, value bool) { for i := 0; i < num; i++ { b.AppendBools(value) } }
[ "func", "(", "b", "*", "Bitset", ")", "AppendNumBools", "(", "num", "int", ",", "value", "bool", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "num", ";", "i", "++", "{", "b", ".", "AppendBools", "(", "value", ")", "\n", "}", "\n", "}" ]
// AppendNumBools appends num bits of value value.
[ "AppendNumBools", "appends", "num", "bits", "of", "value", "value", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/bitset/bitset.go#L185-L189
train
skip2/go-qrcode
bitset/bitset.go
String
func (b *Bitset) String() string { var bitString string for i := 0; i < b.numBits; i++ { if (i % 8) == 0 { bitString += " " } if (b.bits[i/8] & (0x80 >> byte(i%8))) != 0 { bitString += "1" } else { bitString += "0" } } return fmt.Sprintf("numBits=%d, bits=%s", b.numBits, bitString) }
go
func (b *Bitset) String() string { var bitString string for i := 0; i < b.numBits; i++ { if (i % 8) == 0 { bitString += " " } if (b.bits[i/8] & (0x80 >> byte(i%8))) != 0 { bitString += "1" } else { bitString += "0" } } return fmt.Sprintf("numBits=%d, bits=%s", b.numBits, bitString) }
[ "func", "(", "b", "*", "Bitset", ")", "String", "(", ")", "string", "{", "var", "bitString", "string", "\n", "for", "i", ":=", "0", ";", "i", "<", "b", ".", "numBits", ";", "i", "++", "{", "if", "(", "i", "%", "8", ")", "==", "0", "{", "bit...
// String returns a human readable representation of the Bitset's contents.
[ "String", "returns", "a", "human", "readable", "representation", "of", "the", "Bitset", "s", "contents", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/bitset/bitset.go#L192-L207
train
skip2/go-qrcode
bitset/bitset.go
Bits
func (b *Bitset) Bits() []bool { result := make([]bool, b.numBits) var i int for i = 0; i < b.numBits; i++ { result[i] = (b.bits[i/8] & (0x80 >> byte(i%8))) != 0 } return result }
go
func (b *Bitset) Bits() []bool { result := make([]bool, b.numBits) var i int for i = 0; i < b.numBits; i++ { result[i] = (b.bits[i/8] & (0x80 >> byte(i%8))) != 0 } return result }
[ "func", "(", "b", "*", "Bitset", ")", "Bits", "(", ")", "[", "]", "bool", "{", "result", ":=", "make", "(", "[", "]", "bool", ",", "b", ".", "numBits", ")", "\n\n", "var", "i", "int", "\n", "for", "i", "=", "0", ";", "i", "<", "b", ".", "...
// Bits returns the contents of the Bitset.
[ "Bits", "returns", "the", "contents", "of", "the", "Bitset", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/bitset/bitset.go#L215-L224
train
skip2/go-qrcode
bitset/bitset.go
At
func (b *Bitset) At(index int) bool { if index >= b.numBits { log.Panicf("Index %d out of range", index) } return (b.bits[index/8] & (0x80 >> byte(index%8))) != 0 }
go
func (b *Bitset) At(index int) bool { if index >= b.numBits { log.Panicf("Index %d out of range", index) } return (b.bits[index/8] & (0x80 >> byte(index%8))) != 0 }
[ "func", "(", "b", "*", "Bitset", ")", "At", "(", "index", "int", ")", "bool", "{", "if", "index", ">=", "b", ".", "numBits", "{", "log", ".", "Panicf", "(", "\"", "\"", ",", "index", ")", "\n", "}", "\n\n", "return", "(", "b", ".", "bits", "[...
// At returns the value of the bit at |index|.
[ "At", "returns", "the", "value", "of", "the", "bit", "at", "|index|", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/bitset/bitset.go#L227-L233
train
skip2/go-qrcode
bitset/bitset.go
Equals
func (b *Bitset) Equals(other *Bitset) bool { if b.numBits != other.numBits { return false } if !bytes.Equal(b.bits[0:b.numBits/8], other.bits[0:b.numBits/8]) { return false } for i := 8 * (b.numBits / 8); i < b.numBits; i++ { a := (b.bits[i/8] & (0x80 >> byte(i%8))) b := (other.bits[i/8] & (0x80 >> byte...
go
func (b *Bitset) Equals(other *Bitset) bool { if b.numBits != other.numBits { return false } if !bytes.Equal(b.bits[0:b.numBits/8], other.bits[0:b.numBits/8]) { return false } for i := 8 * (b.numBits / 8); i < b.numBits; i++ { a := (b.bits[i/8] & (0x80 >> byte(i%8))) b := (other.bits[i/8] & (0x80 >> byte...
[ "func", "(", "b", "*", "Bitset", ")", "Equals", "(", "other", "*", "Bitset", ")", "bool", "{", "if", "b", ".", "numBits", "!=", "other", ".", "numBits", "{", "return", "false", "\n", "}", "\n\n", "if", "!", "bytes", ".", "Equal", "(", "b", ".", ...
// Equals returns true if the Bitset equals other.
[ "Equals", "returns", "true", "if", "the", "Bitset", "equals", "other", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/bitset/bitset.go#L236-L255
train
skip2/go-qrcode
bitset/bitset.go
ByteAt
func (b *Bitset) ByteAt(index int) byte { if index < 0 || index >= b.numBits { log.Panicf("Index %d out of range", index) } var result byte for i := index; i < index+8 && i < b.numBits; i++ { result <<= 1 if b.At(i) { result |= 1 } } return result }
go
func (b *Bitset) ByteAt(index int) byte { if index < 0 || index >= b.numBits { log.Panicf("Index %d out of range", index) } var result byte for i := index; i < index+8 && i < b.numBits; i++ { result <<= 1 if b.At(i) { result |= 1 } } return result }
[ "func", "(", "b", "*", "Bitset", ")", "ByteAt", "(", "index", "int", ")", "byte", "{", "if", "index", "<", "0", "||", "index", ">=", "b", ".", "numBits", "{", "log", ".", "Panicf", "(", "\"", "\"", ",", "index", ")", "\n", "}", "\n\n", "var", ...
// ByteAt returns a byte consisting of upto 8 bits starting at index.
[ "ByteAt", "returns", "a", "byte", "consisting", "of", "upto", "8", "bits", "starting", "at", "index", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/bitset/bitset.go#L258-L273
train
skip2/go-qrcode
symbol.go
bitmap
func (m *symbol) bitmap() [][]bool { module := make([][]bool, len(m.module)) for i := range m.module { module[i] = m.module[i][:] } return module }
go
func (m *symbol) bitmap() [][]bool { module := make([][]bool, len(m.module)) for i := range m.module { module[i] = m.module[i][:] } return module }
[ "func", "(", "m", "*", "symbol", ")", "bitmap", "(", ")", "[", "]", "[", "]", "bool", "{", "module", ":=", "make", "(", "[", "]", "[", "]", "bool", ",", "len", "(", "m", ".", "module", ")", ")", "\n\n", "for", "i", ":=", "range", "m", ".", ...
// bitmap returns the entire symbol, including the quiet zone.
[ "bitmap", "returns", "the", "entire", "symbol", "including", "the", "quiet", "zone", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/symbol.go#L109-L117
train
skip2/go-qrcode
symbol.go
string
func (m *symbol) string() string { var result string for _, row := range m.module { for _, value := range row { switch value { case true: result += " " case false: // Unicode 'FULL BLOCK' (U+2588). result += "██" } } result += "\n" } return result }
go
func (m *symbol) string() string { var result string for _, row := range m.module { for _, value := range row { switch value { case true: result += " " case false: // Unicode 'FULL BLOCK' (U+2588). result += "██" } } result += "\n" } return result }
[ "func", "(", "m", "*", "symbol", ")", "string", "(", ")", "string", "{", "var", "result", "string", "\n\n", "for", "_", ",", "row", ":=", "range", "m", ".", "module", "{", "for", "_", ",", "value", ":=", "range", "row", "{", "switch", "value", "{...
// string returns a pictorial representation of the symbol, suitable for // printing in a TTY.
[ "string", "returns", "a", "pictorial", "representation", "of", "the", "symbol", "suitable", "for", "printing", "in", "a", "TTY", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/symbol.go#L121-L138
train
skip2/go-qrcode
symbol.go
penaltyScore
func (m *symbol) penaltyScore() int { return m.penalty1() + m.penalty2() + m.penalty3() + m.penalty4() }
go
func (m *symbol) penaltyScore() int { return m.penalty1() + m.penalty2() + m.penalty3() + m.penalty4() }
[ "func", "(", "m", "*", "symbol", ")", "penaltyScore", "(", ")", "int", "{", "return", "m", ".", "penalty1", "(", ")", "+", "m", ".", "penalty2", "(", ")", "+", "m", ".", "penalty3", "(", ")", "+", "m", ".", "penalty4", "(", ")", "\n", "}" ]
// penaltyScore returns the penalty score of the symbol. The penalty score // consists of the sum of the four individual penalty types.
[ "penaltyScore", "returns", "the", "penalty", "score", "of", "the", "symbol", ".", "The", "penalty", "score", "consists", "of", "the", "sum", "of", "the", "four", "individual", "penalty", "types", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/symbol.go#L151-L153
train
skip2/go-qrcode
symbol.go
penalty4
func (m *symbol) penalty4() int { numModules := m.symbolSize * m.symbolSize numDarkModules := 0 for x := 0; x < m.symbolSize; x++ { for y := 0; y < m.symbolSize; y++ { if v := m.get(x, y); v { numDarkModules++ } } } numDarkModuleDeviation := numModules/2 - numDarkModules if numDarkModuleDeviation ...
go
func (m *symbol) penalty4() int { numModules := m.symbolSize * m.symbolSize numDarkModules := 0 for x := 0; x < m.symbolSize; x++ { for y := 0; y < m.symbolSize; y++ { if v := m.get(x, y); v { numDarkModules++ } } } numDarkModuleDeviation := numModules/2 - numDarkModules if numDarkModuleDeviation ...
[ "func", "(", "m", "*", "symbol", ")", "penalty4", "(", ")", "int", "{", "numModules", ":=", "m", ".", "symbolSize", "*", "m", ".", "symbolSize", "\n", "numDarkModules", ":=", "0", "\n\n", "for", "x", ":=", "0", ";", "x", "<", "m", ".", "symbolSize"...
// penalty4 returns the penalty score...
[ "penalty4", "returns", "the", "penalty", "score", "..." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/symbol.go#L291-L309
train
skip2/go-qrcode
reedsolomon/gf_poly.go
gfPolyAdd
func gfPolyAdd(a, b gfPoly) gfPoly { numATerms := a.numTerms() numBTerms := b.numTerms() numTerms := numATerms if numBTerms > numTerms { numTerms = numBTerms } result := gfPoly{term: make([]gfElement, numTerms)} for i := 0; i < numTerms; i++ { switch { case numATerms > i && numBTerms > i: result.term...
go
func gfPolyAdd(a, b gfPoly) gfPoly { numATerms := a.numTerms() numBTerms := b.numTerms() numTerms := numATerms if numBTerms > numTerms { numTerms = numBTerms } result := gfPoly{term: make([]gfElement, numTerms)} for i := 0; i < numTerms; i++ { switch { case numATerms > i && numBTerms > i: result.term...
[ "func", "gfPolyAdd", "(", "a", ",", "b", "gfPoly", ")", "gfPoly", "{", "numATerms", ":=", "a", ".", "numTerms", "(", ")", "\n", "numBTerms", ":=", "b", ".", "numTerms", "(", ")", "\n\n", "numTerms", ":=", "numATerms", "\n", "if", "numBTerms", ">", "n...
// gfPolyAdd returns a + b.
[ "gfPolyAdd", "returns", "a", "+", "b", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/reedsolomon/gf_poly.go#L116-L139
train
skip2/go-qrcode
reedsolomon/gf_poly.go
equals
func (e gfPoly) equals(other gfPoly) bool { var minecPoly *gfPoly var maxecPoly *gfPoly if e.numTerms() > other.numTerms() { minecPoly = &other maxecPoly = &e } else { minecPoly = &e maxecPoly = &other } numMinTerms := minecPoly.numTerms() numMaxTerms := maxecPoly.numTerms() for i := 0; i < numMinTer...
go
func (e gfPoly) equals(other gfPoly) bool { var minecPoly *gfPoly var maxecPoly *gfPoly if e.numTerms() > other.numTerms() { minecPoly = &other maxecPoly = &e } else { minecPoly = &e maxecPoly = &other } numMinTerms := minecPoly.numTerms() numMaxTerms := maxecPoly.numTerms() for i := 0; i < numMinTer...
[ "func", "(", "e", "gfPoly", ")", "equals", "(", "other", "gfPoly", ")", "bool", "{", "var", "minecPoly", "*", "gfPoly", "\n", "var", "maxecPoly", "*", "gfPoly", "\n\n", "if", "e", ".", "numTerms", "(", ")", ">", "other", ".", "numTerms", "(", ")", ...
// equals returns true if e == other.
[ "equals", "returns", "true", "if", "e", "==", "other", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/reedsolomon/gf_poly.go#L188-L216
train
skip2/go-qrcode
encoder.go
newDataEncoder
func newDataEncoder(t dataEncoderType) *dataEncoder { d := &dataEncoder{} switch t { case dataEncoderType1To9: d = &dataEncoder{ minVersion: 1, maxVersion: 9, numericModeIndicator: bitset.New(b0, b0, b0, b1), alphanumericModeIndicator: bitset.New(b0, b0, ...
go
func newDataEncoder(t dataEncoderType) *dataEncoder { d := &dataEncoder{} switch t { case dataEncoderType1To9: d = &dataEncoder{ minVersion: 1, maxVersion: 9, numericModeIndicator: bitset.New(b0, b0, b0, b1), alphanumericModeIndicator: bitset.New(b0, b0, ...
[ "func", "newDataEncoder", "(", "t", "dataEncoderType", ")", "*", "dataEncoder", "{", "d", ":=", "&", "dataEncoder", "{", "}", "\n\n", "switch", "t", "{", "case", "dataEncoderType1To9", ":", "d", "=", "&", "dataEncoder", "{", "minVersion", ":", "1", ",", ...
// newDataEncoder constructs a dataEncoder.
[ "newDataEncoder", "constructs", "a", "dataEncoder", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/encoder.go#L118-L160
train
skip2/go-qrcode
encoder.go
encode
func (d *dataEncoder) encode(data []byte) (*bitset.Bitset, error) { d.data = data d.actual = nil d.optimised = nil if len(data) == 0 { return nil, errors.New("no data to encode") } // Classify data into unoptimised segments. d.classifyDataModes() // Optimise segments. err := d.optimiseDataModes() if err ...
go
func (d *dataEncoder) encode(data []byte) (*bitset.Bitset, error) { d.data = data d.actual = nil d.optimised = nil if len(data) == 0 { return nil, errors.New("no data to encode") } // Classify data into unoptimised segments. d.classifyDataModes() // Optimise segments. err := d.optimiseDataModes() if err ...
[ "func", "(", "d", "*", "dataEncoder", ")", "encode", "(", "data", "[", "]", "byte", ")", "(", "*", "bitset", ".", "Bitset", ",", "error", ")", "{", "d", ".", "data", "=", "data", "\n", "d", ".", "actual", "=", "nil", "\n", "d", ".", "optimised"...
// encode data as one or more segments and return the encoded data. // // The returned data does not include the terminator bit sequence.
[ "encode", "data", "as", "one", "or", "more", "segments", "and", "return", "the", "encoded", "data", ".", "The", "returned", "data", "does", "not", "include", "the", "terminator", "bit", "sequence", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/encoder.go#L165-L190
train
skip2/go-qrcode
encoder.go
encodeDataRaw
func (d *dataEncoder) encodeDataRaw(data []byte, dataMode dataMode, encoded *bitset.Bitset) { modeIndicator := d.modeIndicator(dataMode) charCountBits := d.charCountBits(dataMode) // Append mode indicator. encoded.Append(modeIndicator) // Append character count. encoded.AppendUint32(uint32(len(data)), charCount...
go
func (d *dataEncoder) encodeDataRaw(data []byte, dataMode dataMode, encoded *bitset.Bitset) { modeIndicator := d.modeIndicator(dataMode) charCountBits := d.charCountBits(dataMode) // Append mode indicator. encoded.Append(modeIndicator) // Append character count. encoded.AppendUint32(uint32(len(data)), charCount...
[ "func", "(", "d", "*", "dataEncoder", ")", "encodeDataRaw", "(", "data", "[", "]", "byte", ",", "dataMode", "dataMode", ",", "encoded", "*", "bitset", ".", "Bitset", ")", "{", "modeIndicator", ":=", "d", ".", "modeIndicator", "(", "dataMode", ")", "\n", ...
// encodeDataRaw encodes data in dataMode. The encoded data is appended to // encoded.
[ "encodeDataRaw", "encodes", "data", "in", "dataMode", ".", "The", "encoded", "data", "is", "appended", "to", "encoded", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/encoder.go#L291-L339
train
skip2/go-qrcode
encoder.go
modeIndicator
func (d *dataEncoder) modeIndicator(dataMode dataMode) *bitset.Bitset { switch dataMode { case dataModeNumeric: return d.numericModeIndicator case dataModeAlphanumeric: return d.alphanumericModeIndicator case dataModeByte: return d.byteModeIndicator default: log.Panic("Unknown data mode") } return nil }
go
func (d *dataEncoder) modeIndicator(dataMode dataMode) *bitset.Bitset { switch dataMode { case dataModeNumeric: return d.numericModeIndicator case dataModeAlphanumeric: return d.alphanumericModeIndicator case dataModeByte: return d.byteModeIndicator default: log.Panic("Unknown data mode") } return nil }
[ "func", "(", "d", "*", "dataEncoder", ")", "modeIndicator", "(", "dataMode", "dataMode", ")", "*", "bitset", ".", "Bitset", "{", "switch", "dataMode", "{", "case", "dataModeNumeric", ":", "return", "d", ".", "numericModeIndicator", "\n", "case", "dataModeAlpha...
// modeIndicator returns the segment header bits for a segment of type dataMode.
[ "modeIndicator", "returns", "the", "segment", "header", "bits", "for", "a", "segment", "of", "type", "dataMode", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/encoder.go#L342-L355
train
skip2/go-qrcode
encoder.go
charCountBits
func (d *dataEncoder) charCountBits(dataMode dataMode) int { switch dataMode { case dataModeNumeric: return d.numNumericCharCountBits case dataModeAlphanumeric: return d.numAlphanumericCharCountBits case dataModeByte: return d.numByteCharCountBits default: log.Panic("Unknown data mode") } return 0 }
go
func (d *dataEncoder) charCountBits(dataMode dataMode) int { switch dataMode { case dataModeNumeric: return d.numNumericCharCountBits case dataModeAlphanumeric: return d.numAlphanumericCharCountBits case dataModeByte: return d.numByteCharCountBits default: log.Panic("Unknown data mode") } return 0 }
[ "func", "(", "d", "*", "dataEncoder", ")", "charCountBits", "(", "dataMode", "dataMode", ")", "int", "{", "switch", "dataMode", "{", "case", "dataModeNumeric", ":", "return", "d", ".", "numNumericCharCountBits", "\n", "case", "dataModeAlphanumeric", ":", "return...
// charCountBits returns the number of bits used to encode the length of a data // segment of type dataMode.
[ "charCountBits", "returns", "the", "number", "of", "bits", "used", "to", "encode", "the", "length", "of", "a", "data", "segment", "of", "type", "dataMode", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/encoder.go#L359-L372
train
skip2/go-qrcode
version.go
formatInfo
func (v qrCodeVersion) formatInfo(maskPattern int) *bitset.Bitset { formatID := 0 switch v.level { case Low: formatID = 0x08 // 0b01000 case Medium: formatID = 0x00 // 0b00000 case High: formatID = 0x18 // 0b11000 case Highest: formatID = 0x10 // 0b10000 default: log.Panicf("Invalid level %d", v.level...
go
func (v qrCodeVersion) formatInfo(maskPattern int) *bitset.Bitset { formatID := 0 switch v.level { case Low: formatID = 0x08 // 0b01000 case Medium: formatID = 0x00 // 0b00000 case High: formatID = 0x18 // 0b11000 case Highest: formatID = 0x10 // 0b10000 default: log.Panicf("Invalid level %d", v.level...
[ "func", "(", "v", "qrCodeVersion", ")", "formatInfo", "(", "maskPattern", "int", ")", "*", "bitset", ".", "Bitset", "{", "formatID", ":=", "0", "\n\n", "switch", "v", ".", "level", "{", "case", "Low", ":", "formatID", "=", "0x08", "// 0b01000", "\n", "...
// formatInfo returns the 15-bit Format Information value for a QR // code.
[ "formatInfo", "returns", "the", "15", "-", "bit", "Format", "Information", "value", "for", "a", "QR", "code", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/version.go#L2905-L2932
train
skip2/go-qrcode
version.go
versionInfo
func (v qrCodeVersion) versionInfo() *bitset.Bitset { if v.version < 7 { return nil } result := bitset.New() result.AppendUint32(versionBitSequence[v.version], 18) return result }
go
func (v qrCodeVersion) versionInfo() *bitset.Bitset { if v.version < 7 { return nil } result := bitset.New() result.AppendUint32(versionBitSequence[v.version], 18) return result }
[ "func", "(", "v", "qrCodeVersion", ")", "versionInfo", "(", ")", "*", "bitset", ".", "Bitset", "{", "if", "v", ".", "version", "<", "7", "{", "return", "nil", "\n", "}", "\n\n", "result", ":=", "bitset", ".", "New", "(", ")", "\n", "result", ".", ...
// versionInfo returns the 18-bit Version Information value for a QR Code. // // Version Information is applicable only to QR Codes versions 7-40 inclusive. // nil is returned if Version Information is not required.
[ "versionInfo", "returns", "the", "18", "-", "bit", "Version", "Information", "value", "for", "a", "QR", "Code", ".", "Version", "Information", "is", "applicable", "only", "to", "QR", "Codes", "versions", "7", "-", "40", "inclusive", ".", "nil", "is", "retu...
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/version.go#L2938-L2947
train
skip2/go-qrcode
version.go
numDataBits
func (v qrCodeVersion) numDataBits() int { numDataBits := 0 for _, b := range v.block { numDataBits += 8 * b.numBlocks * b.numDataCodewords // 8 bits in a byte } return numDataBits }
go
func (v qrCodeVersion) numDataBits() int { numDataBits := 0 for _, b := range v.block { numDataBits += 8 * b.numBlocks * b.numDataCodewords // 8 bits in a byte } return numDataBits }
[ "func", "(", "v", "qrCodeVersion", ")", "numDataBits", "(", ")", "int", "{", "numDataBits", ":=", "0", "\n", "for", "_", ",", "b", ":=", "range", "v", ".", "block", "{", "numDataBits", "+=", "8", "*", "b", ".", "numBlocks", "*", "b", ".", "numDataC...
// numDataBits returns the data capacity in bits.
[ "numDataBits", "returns", "the", "data", "capacity", "in", "bits", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/version.go#L2950-L2957
train
skip2/go-qrcode
version.go
chooseQRCodeVersion
func chooseQRCodeVersion(level RecoveryLevel, encoder *dataEncoder, numDataBits int) *qrCodeVersion { var chosenVersion *qrCodeVersion for _, v := range versions { if v.level != level { continue } else if v.version < encoder.minVersion { continue } else if v.version > encoder.maxVersion { break } ...
go
func chooseQRCodeVersion(level RecoveryLevel, encoder *dataEncoder, numDataBits int) *qrCodeVersion { var chosenVersion *qrCodeVersion for _, v := range versions { if v.level != level { continue } else if v.version < encoder.minVersion { continue } else if v.version > encoder.maxVersion { break } ...
[ "func", "chooseQRCodeVersion", "(", "level", "RecoveryLevel", ",", "encoder", "*", "dataEncoder", ",", "numDataBits", "int", ")", "*", "qrCodeVersion", "{", "var", "chosenVersion", "*", "qrCodeVersion", "\n\n", "for", "_", ",", "v", ":=", "range", "versions", ...
// chooseQRCodeVersion chooses the most suitable QR Code version for a stated // data length in bits, the error recovery level required, and the data encoder // used. // // The chosen QR Code version is the smallest version able to fit numDataBits // and the optional terminator bits required by the specified encoder. /...
[ "chooseQRCodeVersion", "chooses", "the", "most", "suitable", "QR", "Code", "version", "for", "a", "stated", "data", "length", "in", "bits", "the", "error", "recovery", "level", "required", "and", "the", "data", "encoder", "used", ".", "The", "chosen", "QR", ...
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/version.go#L2967-L2988
train
skip2/go-qrcode
version.go
numBlocks
func (v qrCodeVersion) numBlocks() int { numBlocks := 0 for _, b := range v.block { numBlocks += b.numBlocks } return numBlocks }
go
func (v qrCodeVersion) numBlocks() int { numBlocks := 0 for _, b := range v.block { numBlocks += b.numBlocks } return numBlocks }
[ "func", "(", "v", "qrCodeVersion", ")", "numBlocks", "(", ")", "int", "{", "numBlocks", ":=", "0", "\n\n", "for", "_", ",", "b", ":=", "range", "v", ".", "block", "{", "numBlocks", "+=", "b", ".", "numBlocks", "\n", "}", "\n\n", "return", "numBlocks"...
// numBlocks returns the number of blocks.
[ "numBlocks", "returns", "the", "number", "of", "blocks", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/version.go#L3006-L3014
train
skip2/go-qrcode
version.go
numBitsToPadToCodeword
func (v qrCodeVersion) numBitsToPadToCodeword(numDataBits int) int { if numDataBits == v.numDataBits() { return 0 } return (8 - numDataBits%8) % 8 }
go
func (v qrCodeVersion) numBitsToPadToCodeword(numDataBits int) int { if numDataBits == v.numDataBits() { return 0 } return (8 - numDataBits%8) % 8 }
[ "func", "(", "v", "qrCodeVersion", ")", "numBitsToPadToCodeword", "(", "numDataBits", "int", ")", "int", "{", "if", "numDataBits", "==", "v", ".", "numDataBits", "(", ")", "{", "return", "0", "\n", "}", "\n\n", "return", "(", "8", "-", "numDataBits", "%"...
// numBitsToPadToCodeword returns the number of bits required to pad data of // length numDataBits upto the nearest codeword size.
[ "numBitsToPadToCodeword", "returns", "the", "number", "of", "bits", "required", "to", "pad", "data", "of", "length", "numDataBits", "upto", "the", "nearest", "codeword", "size", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/version.go#L3018-L3024
train
skip2/go-qrcode
version.go
getQRCodeVersion
func getQRCodeVersion(level RecoveryLevel, version int) *qrCodeVersion { for _, v := range versions { if v.level == level && v.version == version { return &v } } return nil }
go
func getQRCodeVersion(level RecoveryLevel, version int) *qrCodeVersion { for _, v := range versions { if v.level == level && v.version == version { return &v } } return nil }
[ "func", "getQRCodeVersion", "(", "level", "RecoveryLevel", ",", "version", "int", ")", "*", "qrCodeVersion", "{", "for", "_", ",", "v", ":=", "range", "versions", "{", "if", "v", ".", "level", "==", "level", "&&", "v", ".", "version", "==", "version", ...
// getQRCodeVersion returns the QR Code version by version number and recovery // level. Returns nil if the requested combination is not defined.
[ "getQRCodeVersion", "returns", "the", "QR", "Code", "version", "by", "version", "number", "and", "recovery", "level", ".", "Returns", "nil", "if", "the", "requested", "combination", "is", "not", "defined", "." ]
dc11ecdae0a9889dc81a343585516404e8dc6ead
https://github.com/skip2/go-qrcode/blob/dc11ecdae0a9889dc81a343585516404e8dc6ead/version.go#L3042-L3050
train
tidwall/buntdb
buntdb.go
Open
func Open(path string) (*DB, error) { db := &DB{} // initialize trees and indexes db.keys = btree.New(btreeDegrees, nil) db.exps = btree.New(btreeDegrees, &exctx{db}) db.idxs = make(map[string]*index) // initialize default configuration db.config = Config{ SyncPolicy: EverySecond, AutoShrinkPercent...
go
func Open(path string) (*DB, error) { db := &DB{} // initialize trees and indexes db.keys = btree.New(btreeDegrees, nil) db.exps = btree.New(btreeDegrees, &exctx{db}) db.idxs = make(map[string]*index) // initialize default configuration db.config = Config{ SyncPolicy: EverySecond, AutoShrinkPercent...
[ "func", "Open", "(", "path", "string", ")", "(", "*", "DB", ",", "error", ")", "{", "db", ":=", "&", "DB", "{", "}", "\n", "// initialize trees and indexes", "db", ".", "keys", "=", "btree", ".", "New", "(", "btreeDegrees", ",", "nil", ")", "\n", "...
// Open opens a database at the provided path. // If the file does not exist then it will be created automatically.
[ "Open", "opens", "a", "database", "at", "the", "provided", "path", ".", "If", "the", "file", "does", "not", "exist", "then", "it", "will", "be", "created", "automatically", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L142-L173
train
tidwall/buntdb
buntdb.go
match
func (idx *index) match(key string) bool { if idx.pattern == "*" { return true } if idx.opts.CaseInsensitiveKeyMatching { for i := 0; i < len(key); i++ { if key[i] >= 'A' && key[i] <= 'Z' { key = strings.ToLower(key) break } } } return match.Match(key, idx.pattern) }
go
func (idx *index) match(key string) bool { if idx.pattern == "*" { return true } if idx.opts.CaseInsensitiveKeyMatching { for i := 0; i < len(key); i++ { if key[i] >= 'A' && key[i] <= 'Z' { key = strings.ToLower(key) break } } } return match.Match(key, idx.pattern) }
[ "func", "(", "idx", "*", "index", ")", "match", "(", "key", "string", ")", "bool", "{", "if", "idx", ".", "pattern", "==", "\"", "\"", "{", "return", "true", "\n", "}", "\n", "if", "idx", ".", "opts", ".", "CaseInsensitiveKeyMatching", "{", "for", ...
// match matches the pattern to the key
[ "match", "matches", "the", "pattern", "to", "the", "key" ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L260-L273
train
tidwall/buntdb
buntdb.go
clearCopy
func (idx *index) clearCopy() *index { // copy the index meta information nidx := &index{ name: idx.name, pattern: idx.pattern, db: idx.db, less: idx.less, rect: idx.rect, opts: idx.opts, } // initialize with empty trees if nidx.less != nil { nidx.btr = btree.New(btreeDegrees, nidx) ...
go
func (idx *index) clearCopy() *index { // copy the index meta information nidx := &index{ name: idx.name, pattern: idx.pattern, db: idx.db, less: idx.less, rect: idx.rect, opts: idx.opts, } // initialize with empty trees if nidx.less != nil { nidx.btr = btree.New(btreeDegrees, nidx) ...
[ "func", "(", "idx", "*", "index", ")", "clearCopy", "(", ")", "*", "index", "{", "// copy the index meta information", "nidx", ":=", "&", "index", "{", "name", ":", "idx", ".", "name", ",", "pattern", ":", "idx", ".", "pattern", ",", "db", ":", "idx", ...
// clearCopy creates a copy of the index, but with an empty dataset.
[ "clearCopy", "creates", "a", "copy", "of", "the", "index", "but", "with", "an", "empty", "dataset", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L276-L294
train
tidwall/buntdb
buntdb.go
rebuild
func (idx *index) rebuild() { // initialize trees if idx.less != nil { idx.btr = btree.New(btreeDegrees, idx) } if idx.rect != nil { idx.rtr = rtree.New(idx) } // iterate through all keys and fill the index idx.db.keys.Ascend(func(item btree.Item) bool { dbi := item.(*dbItem) if !idx.match(dbi.key) { ...
go
func (idx *index) rebuild() { // initialize trees if idx.less != nil { idx.btr = btree.New(btreeDegrees, idx) } if idx.rect != nil { idx.rtr = rtree.New(idx) } // iterate through all keys and fill the index idx.db.keys.Ascend(func(item btree.Item) bool { dbi := item.(*dbItem) if !idx.match(dbi.key) { ...
[ "func", "(", "idx", "*", "index", ")", "rebuild", "(", ")", "{", "// initialize trees", "if", "idx", ".", "less", "!=", "nil", "{", "idx", ".", "btr", "=", "btree", ".", "New", "(", "btreeDegrees", ",", "idx", ")", "\n", "}", "\n", "if", "idx", "...
// rebuild rebuilds the index
[ "rebuild", "rebuilds", "the", "index" ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L297-L320
train
tidwall/buntdb
buntdb.go
ReadConfig
func (db *DB) ReadConfig(config *Config) error { db.mu.RLock() defer db.mu.RUnlock() if db.closed { return ErrDatabaseClosed } *config = db.config return nil }
go
func (db *DB) ReadConfig(config *Config) error { db.mu.RLock() defer db.mu.RUnlock() if db.closed { return ErrDatabaseClosed } *config = db.config return nil }
[ "func", "(", "db", "*", "DB", ")", "ReadConfig", "(", "config", "*", "Config", ")", "error", "{", "db", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "db", ".", "mu", ".", "RUnlock", "(", ")", "\n", "if", "db", ".", "closed", "{", "return",...
// ReadConfig returns the database configuration.
[ "ReadConfig", "returns", "the", "database", "configuration", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L440-L448
train
tidwall/buntdb
buntdb.go
SetConfig
func (db *DB) SetConfig(config Config) error { db.mu.Lock() defer db.mu.Unlock() if db.closed { return ErrDatabaseClosed } switch config.SyncPolicy { default: return ErrInvalidSyncPolicy case Never, EverySecond, Always: } db.config = config return nil }
go
func (db *DB) SetConfig(config Config) error { db.mu.Lock() defer db.mu.Unlock() if db.closed { return ErrDatabaseClosed } switch config.SyncPolicy { default: return ErrInvalidSyncPolicy case Never, EverySecond, Always: } db.config = config return nil }
[ "func", "(", "db", "*", "DB", ")", "SetConfig", "(", "config", "Config", ")", "error", "{", "db", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "db", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "db", ".", "closed", "{", "return", "ErrDat...
// SetConfig updates the database configuration.
[ "SetConfig", "updates", "the", "database", "configuration", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L451-L464
train
tidwall/buntdb
buntdb.go
insertIntoDatabase
func (db *DB) insertIntoDatabase(item *dbItem) *dbItem { var pdbi *dbItem prev := db.keys.ReplaceOrInsert(item) if prev != nil { // A previous item was removed from the keys tree. Let's // fully delete this item from all indexes. pdbi = prev.(*dbItem) if pdbi.opts != nil && pdbi.opts.ex { // Remove it fro...
go
func (db *DB) insertIntoDatabase(item *dbItem) *dbItem { var pdbi *dbItem prev := db.keys.ReplaceOrInsert(item) if prev != nil { // A previous item was removed from the keys tree. Let's // fully delete this item from all indexes. pdbi = prev.(*dbItem) if pdbi.opts != nil && pdbi.opts.ex { // Remove it fro...
[ "func", "(", "db", "*", "DB", ")", "insertIntoDatabase", "(", "item", "*", "dbItem", ")", "*", "dbItem", "{", "var", "pdbi", "*", "dbItem", "\n", "prev", ":=", "db", ".", "keys", ".", "ReplaceOrInsert", "(", "item", ")", "\n", "if", "prev", "!=", "...
// insertIntoDatabase performs inserts an item in to the database and updates // all indexes. If a previous item with the same key already exists, that item // will be replaced with the new one, and return the previous item.
[ "insertIntoDatabase", "performs", "inserts", "an", "item", "in", "to", "the", "database", "and", "updates", "all", "indexes", ".", "If", "a", "previous", "item", "with", "the", "same", "key", "already", "exists", "that", "item", "will", "be", "replaced", "wi...
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L469-L511
train
tidwall/buntdb
buntdb.go
managed
func (db *DB) managed(writable bool, fn func(tx *Tx) error) (err error) { var tx *Tx tx, err = db.Begin(writable) if err != nil { return } defer func() { if err != nil { // The caller returned an error. We must rollback. _ = tx.Rollback() return } if writable { // Everything went well. Lets Com...
go
func (db *DB) managed(writable bool, fn func(tx *Tx) error) (err error) { var tx *Tx tx, err = db.Begin(writable) if err != nil { return } defer func() { if err != nil { // The caller returned an error. We must rollback. _ = tx.Rollback() return } if writable { // Everything went well. Lets Com...
[ "func", "(", "db", "*", "DB", ")", "managed", "(", "writable", "bool", ",", "fn", "func", "(", "tx", "*", "Tx", ")", "error", ")", "(", "err", "error", ")", "{", "var", "tx", "*", "Tx", "\n", "tx", ",", "err", "=", "db", ".", "Begin", "(", ...
// managed calls a block of code that is fully contained in a transaction. // This method is intended to be wrapped by Update and View
[ "managed", "calls", "a", "block", "of", "code", "that", "is", "fully", "contained", "in", "a", "transaction", ".", "This", "method", "is", "intended", "to", "be", "wrapped", "by", "Update", "and", "View" ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L937-L963
train
tidwall/buntdb
buntdb.go
get
func (db *DB) get(key string) *dbItem { item := db.keys.Get(&dbItem{key: key}) if item != nil { return item.(*dbItem) } return nil }
go
func (db *DB) get(key string) *dbItem { item := db.keys.Get(&dbItem{key: key}) if item != nil { return item.(*dbItem) } return nil }
[ "func", "(", "db", "*", "DB", ")", "get", "(", "key", "string", ")", "*", "dbItem", "{", "item", ":=", "db", ".", "keys", ".", "Get", "(", "&", "dbItem", "{", "key", ":", "key", "}", ")", "\n", "if", "item", "!=", "nil", "{", "return", "item"...
// get return an item or nil if not found.
[ "get", "return", "an", "item", "or", "nil", "if", "not", "found", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L988-L994
train
tidwall/buntdb
buntdb.go
DeleteAll
func (tx *Tx) DeleteAll() error { if tx.db == nil { return ErrTxClosed } else if !tx.writable { return ErrTxNotWritable } else if tx.wc.itercount > 0 { return ErrTxIterating } // check to see if we've already deleted everything if tx.wc.rbkeys == nil { // we need to backup the live data in case of a roll...
go
func (tx *Tx) DeleteAll() error { if tx.db == nil { return ErrTxClosed } else if !tx.writable { return ErrTxNotWritable } else if tx.wc.itercount > 0 { return ErrTxIterating } // check to see if we've already deleted everything if tx.wc.rbkeys == nil { // we need to backup the live data in case of a roll...
[ "func", "(", "tx", "*", "Tx", ")", "DeleteAll", "(", ")", "error", "{", "if", "tx", ".", "db", "==", "nil", "{", "return", "ErrTxClosed", "\n", "}", "else", "if", "!", "tx", ".", "writable", "{", "return", "ErrTxNotWritable", "\n", "}", "else", "if...
// DeleteAll deletes all items from the database.
[ "DeleteAll", "deletes", "all", "items", "from", "the", "database", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1022-L1053
train
tidwall/buntdb
buntdb.go
lock
func (tx *Tx) lock() { if tx.writable { tx.db.mu.Lock() } else { tx.db.mu.RLock() } }
go
func (tx *Tx) lock() { if tx.writable { tx.db.mu.Lock() } else { tx.db.mu.RLock() } }
[ "func", "(", "tx", "*", "Tx", ")", "lock", "(", ")", "{", "if", "tx", ".", "writable", "{", "tx", ".", "db", ".", "mu", ".", "Lock", "(", ")", "\n", "}", "else", "{", "tx", ".", "db", ".", "mu", ".", "RLock", "(", ")", "\n", "}", "\n", ...
// lock locks the database based on the transaction type.
[ "lock", "locks", "the", "database", "based", "on", "the", "transaction", "type", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1086-L1092
train
tidwall/buntdb
buntdb.go
unlock
func (tx *Tx) unlock() { if tx.writable { tx.db.mu.Unlock() } else { tx.db.mu.RUnlock() } }
go
func (tx *Tx) unlock() { if tx.writable { tx.db.mu.Unlock() } else { tx.db.mu.RUnlock() } }
[ "func", "(", "tx", "*", "Tx", ")", "unlock", "(", ")", "{", "if", "tx", ".", "writable", "{", "tx", ".", "db", ".", "mu", ".", "Unlock", "(", ")", "\n", "}", "else", "{", "tx", ".", "db", ".", "mu", ".", "RUnlock", "(", ")", "\n", "}", "\...
// unlock unlocks the database based on the transaction type.
[ "unlock", "unlocks", "the", "database", "based", "on", "the", "transaction", "type", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1095-L1101
train
tidwall/buntdb
buntdb.go
writeSetTo
func (dbi *dbItem) writeSetTo(buf []byte) []byte { if dbi.opts != nil && dbi.opts.ex { ex := dbi.opts.exat.Sub(time.Now()) / time.Second buf = appendArray(buf, 5) buf = appendBulkString(buf, "set") buf = appendBulkString(buf, dbi.key) buf = appendBulkString(buf, dbi.val) buf = appendBulkString(buf, "ex") ...
go
func (dbi *dbItem) writeSetTo(buf []byte) []byte { if dbi.opts != nil && dbi.opts.ex { ex := dbi.opts.exat.Sub(time.Now()) / time.Second buf = appendArray(buf, 5) buf = appendBulkString(buf, "set") buf = appendBulkString(buf, dbi.key) buf = appendBulkString(buf, dbi.val) buf = appendBulkString(buf, "ex") ...
[ "func", "(", "dbi", "*", "dbItem", ")", "writeSetTo", "(", "buf", "[", "]", "byte", ")", "[", "]", "byte", "{", "if", "dbi", ".", "opts", "!=", "nil", "&&", "dbi", ".", "opts", ".", "ex", "{", "ex", ":=", "dbi", ".", "opts", ".", "exat", ".",...
// writeSetTo writes an item as a single SET record to the a bufio Writer.
[ "writeSetTo", "writes", "an", "item", "as", "a", "single", "SET", "record", "to", "the", "a", "bufio", "Writer", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1228-L1244
train
tidwall/buntdb
buntdb.go
writeDeleteTo
func (dbi *dbItem) writeDeleteTo(buf []byte) []byte { buf = appendArray(buf, 2) buf = appendBulkString(buf, "del") buf = appendBulkString(buf, dbi.key) return buf }
go
func (dbi *dbItem) writeDeleteTo(buf []byte) []byte { buf = appendArray(buf, 2) buf = appendBulkString(buf, "del") buf = appendBulkString(buf, dbi.key) return buf }
[ "func", "(", "dbi", "*", "dbItem", ")", "writeDeleteTo", "(", "buf", "[", "]", "byte", ")", "[", "]", "byte", "{", "buf", "=", "appendArray", "(", "buf", ",", "2", ")", "\n", "buf", "=", "appendBulkString", "(", "buf", ",", "\"", "\"", ")", "\n",...
// writeSetTo writes an item as a single DEL record to the a bufio Writer.
[ "writeSetTo", "writes", "an", "item", "as", "a", "single", "DEL", "record", "to", "the", "a", "bufio", "Writer", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1247-L1252
train
tidwall/buntdb
buntdb.go
expired
func (dbi *dbItem) expired() bool { return dbi.opts != nil && dbi.opts.ex && time.Now().After(dbi.opts.exat) }
go
func (dbi *dbItem) expired() bool { return dbi.opts != nil && dbi.opts.ex && time.Now().After(dbi.opts.exat) }
[ "func", "(", "dbi", "*", "dbItem", ")", "expired", "(", ")", "bool", "{", "return", "dbi", ".", "opts", "!=", "nil", "&&", "dbi", ".", "opts", ".", "ex", "&&", "time", ".", "Now", "(", ")", ".", "After", "(", "dbi", ".", "opts", ".", "exat", ...
// expired evaluates id the item has expired. This will always return false when // the item does not have `opts.ex` set to true.
[ "expired", "evaluates", "id", "the", "item", "has", "expired", ".", "This", "will", "always", "return", "false", "when", "the", "item", "does", "not", "have", "opts", ".", "ex", "set", "to", "true", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1256-L1258
train
tidwall/buntdb
buntdb.go
expiresAt
func (dbi *dbItem) expiresAt() time.Time { if dbi.opts == nil || !dbi.opts.ex { return maxTime } return dbi.opts.exat }
go
func (dbi *dbItem) expiresAt() time.Time { if dbi.opts == nil || !dbi.opts.ex { return maxTime } return dbi.opts.exat }
[ "func", "(", "dbi", "*", "dbItem", ")", "expiresAt", "(", ")", "time", ".", "Time", "{", "if", "dbi", ".", "opts", "==", "nil", "||", "!", "dbi", ".", "opts", ".", "ex", "{", "return", "maxTime", "\n", "}", "\n", "return", "dbi", ".", "opts", "...
// expiresAt will return the time when the item will expire. When an item does // not expire `maxTime` is used.
[ "expiresAt", "will", "return", "the", "time", "when", "the", "item", "will", "expire", ".", "When", "an", "item", "does", "not", "expire", "maxTime", "is", "used", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1267-L1272
train
tidwall/buntdb
buntdb.go
Less
func (dbi *dbItem) Less(item btree.Item, ctx interface{}) bool { dbi2 := item.(*dbItem) switch ctx := ctx.(type) { case *exctx: // The expires b-tree formula if dbi2.expiresAt().After(dbi.expiresAt()) { return true } if dbi.expiresAt().After(dbi2.expiresAt()) { return false } case *index: if ctx.l...
go
func (dbi *dbItem) Less(item btree.Item, ctx interface{}) bool { dbi2 := item.(*dbItem) switch ctx := ctx.(type) { case *exctx: // The expires b-tree formula if dbi2.expiresAt().After(dbi.expiresAt()) { return true } if dbi.expiresAt().After(dbi2.expiresAt()) { return false } case *index: if ctx.l...
[ "func", "(", "dbi", "*", "dbItem", ")", "Less", "(", "item", "btree", ".", "Item", ",", "ctx", "interface", "{", "}", ")", "bool", "{", "dbi2", ":=", "item", ".", "(", "*", "dbItem", ")", "\n", "switch", "ctx", ":=", "ctx", ".", "(", "type", ")...
// Less determines if a b-tree item is less than another. This is required // for ordering, inserting, and deleting items from a b-tree. It's important // to note that the ctx parameter is used to help with determine which // formula to use on an item. Each b-tree should use a different ctx when // sharing the same ite...
[ "Less", "determines", "if", "a", "b", "-", "tree", "item", "is", "less", "than", "another", ".", "This", "is", "required", "for", "ordering", "inserting", "and", "deleting", "items", "from", "a", "b", "-", "tree", ".", "It", "s", "important", "to", "no...
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1279-L1308
train
tidwall/buntdb
buntdb.go
Rect
func (dbi *dbItem) Rect(ctx interface{}) (min, max []float64) { switch ctx := ctx.(type) { case *index: return ctx.rect(dbi.val) } return nil, nil }
go
func (dbi *dbItem) Rect(ctx interface{}) (min, max []float64) { switch ctx := ctx.(type) { case *index: return ctx.rect(dbi.val) } return nil, nil }
[ "func", "(", "dbi", "*", "dbItem", ")", "Rect", "(", "ctx", "interface", "{", "}", ")", "(", "min", ",", "max", "[", "]", "float64", ")", "{", "switch", "ctx", ":=", "ctx", ".", "(", "type", ")", "{", "case", "*", "index", ":", "return", "ctx",...
// Rect converts a string to a rectangle. // An invalid rectangle will cause a panic.
[ "Rect", "converts", "a", "string", "to", "a", "rectangle", ".", "An", "invalid", "rectangle", "will", "cause", "a", "panic", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1312-L1318
train
tidwall/buntdb
buntdb.go
GetLess
func (tx *Tx) GetLess(index string) (func(a, b string) bool, error) { if tx.db == nil { return nil, ErrTxClosed } idx, ok := tx.db.idxs[index] if !ok || idx.less == nil { return nil, ErrNotFound } return idx.less, nil }
go
func (tx *Tx) GetLess(index string) (func(a, b string) bool, error) { if tx.db == nil { return nil, ErrTxClosed } idx, ok := tx.db.idxs[index] if !ok || idx.less == nil { return nil, ErrNotFound } return idx.less, nil }
[ "func", "(", "tx", "*", "Tx", ")", "GetLess", "(", "index", "string", ")", "(", "func", "(", "a", ",", "b", "string", ")", "bool", ",", "error", ")", "{", "if", "tx", ".", "db", "==", "nil", "{", "return", "nil", ",", "ErrTxClosed", "\n", "}", ...
// GetLess returns the less function for an index. This is handy for // doing ad-hoc compares inside a transaction. // Returns ErrNotFound if the index is not found or there is no less // function bound to the index
[ "GetLess", "returns", "the", "less", "function", "for", "an", "index", ".", "This", "is", "handy", "for", "doing", "ad", "-", "hoc", "compares", "inside", "a", "transaction", ".", "Returns", "ErrNotFound", "if", "the", "index", "is", "not", "found", "or", ...
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1334-L1343
train
tidwall/buntdb
buntdb.go
GetRect
func (tx *Tx) GetRect(index string) (func(s string) (min, max []float64), error) { if tx.db == nil { return nil, ErrTxClosed } idx, ok := tx.db.idxs[index] if !ok || idx.rect == nil { return nil, ErrNotFound } return idx.rect, nil }
go
func (tx *Tx) GetRect(index string) (func(s string) (min, max []float64), error) { if tx.db == nil { return nil, ErrTxClosed } idx, ok := tx.db.idxs[index] if !ok || idx.rect == nil { return nil, ErrNotFound } return idx.rect, nil }
[ "func", "(", "tx", "*", "Tx", ")", "GetRect", "(", "index", "string", ")", "(", "func", "(", "s", "string", ")", "(", "min", ",", "max", "[", "]", "float64", ")", ",", "error", ")", "{", "if", "tx", ".", "db", "==", "nil", "{", "return", "nil...
// GetRect returns the rect function for an index. This is handy for // doing ad-hoc searches inside a transaction. // Returns ErrNotFound if the index is not found or there is no rect // function bound to the index
[ "GetRect", "returns", "the", "rect", "function", "for", "an", "index", ".", "This", "is", "handy", "for", "doing", "ad", "-", "hoc", "searches", "inside", "a", "transaction", ".", "Returns", "ErrNotFound", "if", "the", "index", "is", "not", "found", "or", ...
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1349-L1359
train
tidwall/buntdb
buntdb.go
Get
func (tx *Tx) Get(key string, ignoreExpired ...bool) (val string, err error) { if tx.db == nil { return "", ErrTxClosed } var ignore bool if len(ignoreExpired) != 0 { ignore = ignoreExpired[0] } item := tx.db.get(key) if item == nil || (item.expired() && !ignore) { // The item does not exists or has expire...
go
func (tx *Tx) Get(key string, ignoreExpired ...bool) (val string, err error) { if tx.db == nil { return "", ErrTxClosed } var ignore bool if len(ignoreExpired) != 0 { ignore = ignoreExpired[0] } item := tx.db.get(key) if item == nil || (item.expired() && !ignore) { // The item does not exists or has expire...
[ "func", "(", "tx", "*", "Tx", ")", "Get", "(", "key", "string", ",", "ignoreExpired", "...", "bool", ")", "(", "val", "string", ",", "err", "error", ")", "{", "if", "tx", ".", "db", "==", "nil", "{", "return", "\"", "\"", ",", "ErrTxClosed", "\n"...
// Get returns a value for a key. If the item does not exist or if the item // has expired then ErrNotFound is returned. If ignoreExpired is true, then // the found value will be returned even if it is expired.
[ "Get", "returns", "a", "value", "for", "a", "key", ".", "If", "the", "item", "does", "not", "exist", "or", "if", "the", "item", "has", "expired", "then", "ErrNotFound", "is", "returned", ".", "If", "ignoreExpired", "is", "true", "then", "the", "found", ...
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1424-L1439
train
tidwall/buntdb
buntdb.go
TTL
func (tx *Tx) TTL(key string) (time.Duration, error) { if tx.db == nil { return 0, ErrTxClosed } item := tx.db.get(key) if item == nil { return 0, ErrNotFound } else if item.opts == nil || !item.opts.ex { return -1, nil } dur := item.opts.exat.Sub(time.Now()) if dur < 0 { return 0, ErrNotFound } retur...
go
func (tx *Tx) TTL(key string) (time.Duration, error) { if tx.db == nil { return 0, ErrTxClosed } item := tx.db.get(key) if item == nil { return 0, ErrNotFound } else if item.opts == nil || !item.opts.ex { return -1, nil } dur := item.opts.exat.Sub(time.Now()) if dur < 0 { return 0, ErrNotFound } retur...
[ "func", "(", "tx", "*", "Tx", ")", "TTL", "(", "key", "string", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "if", "tx", ".", "db", "==", "nil", "{", "return", "0", ",", "ErrTxClosed", "\n", "}", "\n", "item", ":=", "tx", ".", "...
// TTL returns the remaining time-to-live for an item. // A negative duration will be returned for items that do not have an // expiration.
[ "TTL", "returns", "the", "remaining", "time", "-", "to", "-", "live", "for", "an", "item", ".", "A", "negative", "duration", "will", "be", "returned", "for", "items", "that", "do", "not", "have", "an", "expiration", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1480-L1495
train
tidwall/buntdb
buntdb.go
scan
func (tx *Tx) scan(desc, gt, lt bool, index, start, stop string, iterator func(key, value string) bool) error { if tx.db == nil { return ErrTxClosed } // wrap a btree specific iterator around the user-defined iterator. iter := func(item btree.Item) bool { dbi := item.(*dbItem) return iterator(dbi.key, dbi.va...
go
func (tx *Tx) scan(desc, gt, lt bool, index, start, stop string, iterator func(key, value string) bool) error { if tx.db == nil { return ErrTxClosed } // wrap a btree specific iterator around the user-defined iterator. iter := func(item btree.Item) bool { dbi := item.(*dbItem) return iterator(dbi.key, dbi.va...
[ "func", "(", "tx", "*", "Tx", ")", "scan", "(", "desc", ",", "gt", ",", "lt", "bool", ",", "index", ",", "start", ",", "stop", "string", ",", "iterator", "func", "(", "key", ",", "value", "string", ")", "bool", ")", "error", "{", "if", "tx", "....
// scan iterates through a specified index and calls user-defined iterator // function for each item encountered. // The desc param indicates that the iterator should descend. // The gt param indicates that there is a greaterThan limit. // The lt param indicates that there is a lessThan limit. // The index param tells ...
[ "scan", "iterates", "through", "a", "specified", "index", "and", "calls", "user", "-", "defined", "iterator", "function", "for", "each", "item", "encountered", ".", "The", "desc", "param", "indicates", "that", "the", "iterator", "should", "descend", ".", "The"...
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1507-L1580
train
tidwall/buntdb
buntdb.go
AscendKeys
func (tx *Tx) AscendKeys(pattern string, iterator func(key, value string) bool) error { if pattern == "" { return nil } if pattern[0] == '*' { if pattern == "*" { return tx.Ascend("", iterator) } return tx.Ascend("", func(key, value string) bool { if match.Match(key, pattern) { if !iterator(key, v...
go
func (tx *Tx) AscendKeys(pattern string, iterator func(key, value string) bool) error { if pattern == "" { return nil } if pattern[0] == '*' { if pattern == "*" { return tx.Ascend("", iterator) } return tx.Ascend("", func(key, value string) bool { if match.Match(key, pattern) { if !iterator(key, v...
[ "func", "(", "tx", "*", "Tx", ")", "AscendKeys", "(", "pattern", "string", ",", "iterator", "func", "(", "key", ",", "value", "string", ")", "bool", ")", "error", "{", "if", "pattern", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n", "if", ...
// AscendKeys allows for iterating through keys based on the specified pattern.
[ "AscendKeys", "allows", "for", "iterating", "through", "keys", "based", "on", "the", "specified", "pattern", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1590-L1620
train
tidwall/buntdb
buntdb.go
DescendKeys
func (tx *Tx) DescendKeys(pattern string, iterator func(key, value string) bool) error { if pattern == "" { return nil } if pattern[0] == '*' { if pattern == "*" { return tx.Descend("", iterator) } return tx.Descend("", func(key, value string) bool { if match.Match(key, pattern) { if !iterator(key...
go
func (tx *Tx) DescendKeys(pattern string, iterator func(key, value string) bool) error { if pattern == "" { return nil } if pattern[0] == '*' { if pattern == "*" { return tx.Descend("", iterator) } return tx.Descend("", func(key, value string) bool { if match.Match(key, pattern) { if !iterator(key...
[ "func", "(", "tx", "*", "Tx", ")", "DescendKeys", "(", "pattern", "string", ",", "iterator", "func", "(", "key", ",", "value", "string", ")", "bool", ")", "error", "{", "if", "pattern", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n", "if",...
// DescendKeys allows for iterating through keys based on the specified pattern.
[ "DescendKeys", "allows", "for", "iterating", "through", "keys", "based", "on", "the", "specified", "pattern", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1623-L1653
train
tidwall/buntdb
buntdb.go
Len
func (tx *Tx) Len() (int, error) { if tx.db == nil { return 0, ErrTxClosed } return tx.db.keys.Len(), nil }
go
func (tx *Tx) Len() (int, error) { if tx.db == nil { return 0, ErrTxClosed } return tx.db.keys.Len(), nil }
[ "func", "(", "tx", "*", "Tx", ")", "Len", "(", ")", "(", "int", ",", "error", ")", "{", "if", "tx", ".", "db", "==", "nil", "{", "return", "0", ",", "ErrTxClosed", "\n", "}", "\n", "return", "tx", ".", "db", ".", "keys", ".", "Len", "(", ")...
// Len returns the number of items in the database
[ "Len", "returns", "the", "number", "of", "items", "in", "the", "database" ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1892-L1897
train
tidwall/buntdb
buntdb.go
CreateIndexOptions
func (tx *Tx) CreateIndexOptions(name, pattern string, opts *IndexOptions, less ...func(a, b string) bool) error { return tx.createIndex(name, pattern, less, nil, opts) }
go
func (tx *Tx) CreateIndexOptions(name, pattern string, opts *IndexOptions, less ...func(a, b string) bool) error { return tx.createIndex(name, pattern, less, nil, opts) }
[ "func", "(", "tx", "*", "Tx", ")", "CreateIndexOptions", "(", "name", ",", "pattern", "string", ",", "opts", "*", "IndexOptions", ",", "less", "...", "func", "(", "a", ",", "b", "string", ")", "bool", ")", "error", "{", "return", "tx", ".", "createIn...
// CreateIndexOptions is the same as CreateIndex except that it allows // for additional options.
[ "CreateIndexOptions", "is", "the", "same", "as", "CreateIndex", "except", "that", "it", "allows", "for", "additional", "options", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1929-L1933
train
tidwall/buntdb
buntdb.go
CreateSpatialIndexOptions
func (tx *Tx) CreateSpatialIndexOptions(name, pattern string, opts *IndexOptions, rect func(item string) (min, max []float64)) error { return tx.createIndex(name, pattern, nil, rect, nil) }
go
func (tx *Tx) CreateSpatialIndexOptions(name, pattern string, opts *IndexOptions, rect func(item string) (min, max []float64)) error { return tx.createIndex(name, pattern, nil, rect, nil) }
[ "func", "(", "tx", "*", "Tx", ")", "CreateSpatialIndexOptions", "(", "name", ",", "pattern", "string", ",", "opts", "*", "IndexOptions", ",", "rect", "func", "(", "item", "string", ")", "(", "min", ",", "max", "[", "]", "float64", ")", ")", "error", ...
// CreateSpatialIndexOptions is the same as CreateSpatialIndex except that // it allows for additional options.
[ "CreateSpatialIndexOptions", "is", "the", "same", "as", "CreateSpatialIndex", "except", "that", "it", "allows", "for", "additional", "options", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L1956-L1960
train
tidwall/buntdb
buntdb.go
DropIndex
func (tx *Tx) DropIndex(name string) error { if tx.db == nil { return ErrTxClosed } else if !tx.writable { return ErrTxNotWritable } else if tx.wc.itercount > 0 { return ErrTxIterating } if name == "" { // cannot drop the default "keys" index return ErrInvalidOperation } idx, ok := tx.db.idxs[name] if...
go
func (tx *Tx) DropIndex(name string) error { if tx.db == nil { return ErrTxClosed } else if !tx.writable { return ErrTxNotWritable } else if tx.wc.itercount > 0 { return ErrTxIterating } if name == "" { // cannot drop the default "keys" index return ErrInvalidOperation } idx, ok := tx.db.idxs[name] if...
[ "func", "(", "tx", "*", "Tx", ")", "DropIndex", "(", "name", "string", ")", "error", "{", "if", "tx", ".", "db", "==", "nil", "{", "return", "ErrTxClosed", "\n", "}", "else", "if", "!", "tx", ".", "writable", "{", "return", "ErrTxNotWritable", "\n", ...
// DropIndex removes an index.
[ "DropIndex", "removes", "an", "index", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L2037-L2065
train
tidwall/buntdb
buntdb.go
Indexes
func (tx *Tx) Indexes() ([]string, error) { if tx.db == nil { return nil, ErrTxClosed } names := make([]string, 0, len(tx.db.idxs)) for name := range tx.db.idxs { names = append(names, name) } sort.Strings(names) return names, nil }
go
func (tx *Tx) Indexes() ([]string, error) { if tx.db == nil { return nil, ErrTxClosed } names := make([]string, 0, len(tx.db.idxs)) for name := range tx.db.idxs { names = append(names, name) } sort.Strings(names) return names, nil }
[ "func", "(", "tx", "*", "Tx", ")", "Indexes", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "if", "tx", ".", "db", "==", "nil", "{", "return", "nil", ",", "ErrTxClosed", "\n", "}", "\n", "names", ":=", "make", "(", "[", "]", "str...
// Indexes returns a list of index names.
[ "Indexes", "returns", "a", "list", "of", "index", "names", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L2068-L2078
train
tidwall/buntdb
buntdb.go
IndexInt
func IndexInt(a, b string) bool { ia, _ := strconv.ParseInt(a, 10, 64) ib, _ := strconv.ParseInt(b, 10, 64) return ia < ib }
go
func IndexInt(a, b string) bool { ia, _ := strconv.ParseInt(a, 10, 64) ib, _ := strconv.ParseInt(b, 10, 64) return ia < ib }
[ "func", "IndexInt", "(", "a", ",", "b", "string", ")", "bool", "{", "ia", ",", "_", ":=", "strconv", ".", "ParseInt", "(", "a", ",", "10", ",", "64", ")", "\n", "ib", ",", "_", ":=", "strconv", ".", "ParseInt", "(", "b", ",", "10", ",", "64",...
// IndexInt is a helper function that returns true if 'a' is less than 'b'.
[ "IndexInt", "is", "a", "helper", "function", "that", "returns", "true", "if", "a", "is", "less", "than", "b", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L2149-L2153
train
tidwall/buntdb
buntdb.go
IndexJSON
func IndexJSON(path string) func(a, b string) bool { return func(a, b string) bool { return gjson.Get(a, path).Less(gjson.Get(b, path), false) } }
go
func IndexJSON(path string) func(a, b string) bool { return func(a, b string) bool { return gjson.Get(a, path).Less(gjson.Get(b, path), false) } }
[ "func", "IndexJSON", "(", "path", "string", ")", "func", "(", "a", ",", "b", "string", ")", "bool", "{", "return", "func", "(", "a", ",", "b", "string", ")", "bool", "{", "return", "gjson", ".", "Get", "(", "a", ",", "path", ")", ".", "Less", "...
// IndexJSON provides for the ability to create an index on any JSON field. // When the field is a string, the comparison will be case-insensitive. // It returns a helper function used by CreateIndex.
[ "IndexJSON", "provides", "for", "the", "ability", "to", "create", "an", "index", "on", "any", "JSON", "field", ".", "When", "the", "field", "is", "a", "string", "the", "comparison", "will", "be", "case", "-", "insensitive", ".", "It", "returns", "a", "he...
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L2176-L2180
train
tidwall/buntdb
buntdb.go
IndexJSONCaseSensitive
func IndexJSONCaseSensitive(path string) func(a, b string) bool { return func(a, b string) bool { return gjson.Get(a, path).Less(gjson.Get(b, path), true) } }
go
func IndexJSONCaseSensitive(path string) func(a, b string) bool { return func(a, b string) bool { return gjson.Get(a, path).Less(gjson.Get(b, path), true) } }
[ "func", "IndexJSONCaseSensitive", "(", "path", "string", ")", "func", "(", "a", ",", "b", "string", ")", "bool", "{", "return", "func", "(", "a", ",", "b", "string", ")", "bool", "{", "return", "gjson", ".", "Get", "(", "a", ",", "path", ")", ".", ...
// IndexJSONCaseSensitive provides for the ability to create an index on // any JSON field. // When the field is a string, the comparison will be case-sensitive. // It returns a helper function used by CreateIndex.
[ "IndexJSONCaseSensitive", "provides", "for", "the", "ability", "to", "create", "an", "index", "on", "any", "JSON", "field", ".", "When", "the", "field", "is", "a", "string", "the", "comparison", "will", "be", "case", "-", "sensitive", ".", "It", "returns", ...
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L2186-L2190
train
tidwall/buntdb
buntdb.go
Desc
func Desc(less func(a, b string) bool) func(a, b string) bool { return func(a, b string) bool { return less(b, a) } }
go
func Desc(less func(a, b string) bool) func(a, b string) bool { return func(a, b string) bool { return less(b, a) } }
[ "func", "Desc", "(", "less", "func", "(", "a", ",", "b", "string", ")", "bool", ")", "func", "(", "a", ",", "b", "string", ")", "bool", "{", "return", "func", "(", "a", ",", "b", "string", ")", "bool", "{", "return", "less", "(", "b", ",", "a...
// Desc is a helper function that changes the order of an index.
[ "Desc", "is", "a", "helper", "function", "that", "changes", "the", "order", "of", "an", "index", "." ]
6249481c29c2cd96f53b691b74ac1893f72774c2
https://github.com/tidwall/buntdb/blob/6249481c29c2cd96f53b691b74ac1893f72774c2/buntdb.go#L2193-L2195
train
asdine/storm
q/tree.go
Eq
func Eq(field string, v interface{}) Matcher { return NewFieldMatcher(field, &cmp{value: v, token: token.EQL}) }
go
func Eq(field string, v interface{}) Matcher { return NewFieldMatcher(field, &cmp{value: v, token: token.EQL}) }
[ "func", "Eq", "(", "field", "string", ",", "v", "interface", "{", "}", ")", "Matcher", "{", "return", "NewFieldMatcher", "(", "field", ",", "&", "cmp", "{", "value", ":", "v", ",", "token", ":", "token", ".", "EQL", "}", ")", "\n", "}" ]
// Eq matcher, checks if the given field is equal to the given value
[ "Eq", "matcher", "checks", "if", "the", "given", "field", "is", "equal", "to", "the", "given", "value" ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/q/tree.go#L177-L179
train
asdine/storm
q/tree.go
EqF
func EqF(field1, field2 string) Matcher { return NewField2FieldMatcher(field1, field2, token.EQL) }
go
func EqF(field1, field2 string) Matcher { return NewField2FieldMatcher(field1, field2, token.EQL) }
[ "func", "EqF", "(", "field1", ",", "field2", "string", ")", "Matcher", "{", "return", "NewField2FieldMatcher", "(", "field1", ",", "field2", ",", "token", ".", "EQL", ")", "\n", "}" ]
// EqF matcher, checks if the given field is equal to the given field
[ "EqF", "matcher", "checks", "if", "the", "given", "field", "is", "equal", "to", "the", "given", "field" ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/q/tree.go#L182-L184
train
asdine/storm
q/tree.go
StrictEq
func StrictEq(field string, v interface{}) Matcher { return NewFieldMatcher(field, &strictEq{value: v}) }
go
func StrictEq(field string, v interface{}) Matcher { return NewFieldMatcher(field, &strictEq{value: v}) }
[ "func", "StrictEq", "(", "field", "string", ",", "v", "interface", "{", "}", ")", "Matcher", "{", "return", "NewFieldMatcher", "(", "field", ",", "&", "strictEq", "{", "value", ":", "v", "}", ")", "\n", "}" ]
// StrictEq matcher, checks if the given field is deeply equal to the given value
[ "StrictEq", "matcher", "checks", "if", "the", "given", "field", "is", "deeply", "equal", "to", "the", "given", "value" ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/q/tree.go#L187-L189
train
asdine/storm
q/tree.go
Gt
func Gt(field string, v interface{}) Matcher { return NewFieldMatcher(field, &cmp{value: v, token: token.GTR}) }
go
func Gt(field string, v interface{}) Matcher { return NewFieldMatcher(field, &cmp{value: v, token: token.GTR}) }
[ "func", "Gt", "(", "field", "string", ",", "v", "interface", "{", "}", ")", "Matcher", "{", "return", "NewFieldMatcher", "(", "field", ",", "&", "cmp", "{", "value", ":", "v", ",", "token", ":", "token", ".", "GTR", "}", ")", "\n", "}" ]
// Gt matcher, checks if the given field is greater than the given value
[ "Gt", "matcher", "checks", "if", "the", "given", "field", "is", "greater", "than", "the", "given", "value" ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/q/tree.go#L192-L194
train
asdine/storm
q/tree.go
GtF
func GtF(field1, field2 string) Matcher { return NewField2FieldMatcher(field1, field2, token.GTR) }
go
func GtF(field1, field2 string) Matcher { return NewField2FieldMatcher(field1, field2, token.GTR) }
[ "func", "GtF", "(", "field1", ",", "field2", "string", ")", "Matcher", "{", "return", "NewField2FieldMatcher", "(", "field1", ",", "field2", ",", "token", ".", "GTR", ")", "\n", "}" ]
// GtF matcher, checks if the given field is greater than the given field
[ "GtF", "matcher", "checks", "if", "the", "given", "field", "is", "greater", "than", "the", "given", "field" ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/q/tree.go#L197-L199
train
asdine/storm
q/tree.go
Gte
func Gte(field string, v interface{}) Matcher { return NewFieldMatcher(field, &cmp{value: v, token: token.GEQ}) }
go
func Gte(field string, v interface{}) Matcher { return NewFieldMatcher(field, &cmp{value: v, token: token.GEQ}) }
[ "func", "Gte", "(", "field", "string", ",", "v", "interface", "{", "}", ")", "Matcher", "{", "return", "NewFieldMatcher", "(", "field", ",", "&", "cmp", "{", "value", ":", "v", ",", "token", ":", "token", ".", "GEQ", "}", ")", "\n", "}" ]
// Gte matcher, checks if the given field is greater than or equal to the given value
[ "Gte", "matcher", "checks", "if", "the", "given", "field", "is", "greater", "than", "or", "equal", "to", "the", "given", "value" ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/q/tree.go#L202-L204
train
asdine/storm
q/tree.go
GteF
func GteF(field1, field2 string) Matcher { return NewField2FieldMatcher(field1, field2, token.GEQ) }
go
func GteF(field1, field2 string) Matcher { return NewField2FieldMatcher(field1, field2, token.GEQ) }
[ "func", "GteF", "(", "field1", ",", "field2", "string", ")", "Matcher", "{", "return", "NewField2FieldMatcher", "(", "field1", ",", "field2", ",", "token", ".", "GEQ", ")", "\n", "}" ]
// GteF matcher, checks if the given field is greater than or equal to the given field
[ "GteF", "matcher", "checks", "if", "the", "given", "field", "is", "greater", "than", "or", "equal", "to", "the", "given", "field" ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/q/tree.go#L207-L209
train
asdine/storm
q/tree.go
Lt
func Lt(field string, v interface{}) Matcher { return NewFieldMatcher(field, &cmp{value: v, token: token.LSS}) }
go
func Lt(field string, v interface{}) Matcher { return NewFieldMatcher(field, &cmp{value: v, token: token.LSS}) }
[ "func", "Lt", "(", "field", "string", ",", "v", "interface", "{", "}", ")", "Matcher", "{", "return", "NewFieldMatcher", "(", "field", ",", "&", "cmp", "{", "value", ":", "v", ",", "token", ":", "token", ".", "LSS", "}", ")", "\n", "}" ]
// Lt matcher, checks if the given field is lesser than the given value
[ "Lt", "matcher", "checks", "if", "the", "given", "field", "is", "lesser", "than", "the", "given", "value" ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/q/tree.go#L212-L214
train
asdine/storm
q/tree.go
LtF
func LtF(field1, field2 string) Matcher { return NewField2FieldMatcher(field1, field2, token.LSS) }
go
func LtF(field1, field2 string) Matcher { return NewField2FieldMatcher(field1, field2, token.LSS) }
[ "func", "LtF", "(", "field1", ",", "field2", "string", ")", "Matcher", "{", "return", "NewField2FieldMatcher", "(", "field1", ",", "field2", ",", "token", ".", "LSS", ")", "\n", "}" ]
// LtF matcher, checks if the given field is lesser than the given field
[ "LtF", "matcher", "checks", "if", "the", "given", "field", "is", "lesser", "than", "the", "given", "field" ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/q/tree.go#L217-L219
train
asdine/storm
q/tree.go
Lte
func Lte(field string, v interface{}) Matcher { return NewFieldMatcher(field, &cmp{value: v, token: token.LEQ}) }
go
func Lte(field string, v interface{}) Matcher { return NewFieldMatcher(field, &cmp{value: v, token: token.LEQ}) }
[ "func", "Lte", "(", "field", "string", ",", "v", "interface", "{", "}", ")", "Matcher", "{", "return", "NewFieldMatcher", "(", "field", ",", "&", "cmp", "{", "value", ":", "v", ",", "token", ":", "token", ".", "LEQ", "}", ")", "\n", "}" ]
// Lte matcher, checks if the given field is lesser than or equal to the given value
[ "Lte", "matcher", "checks", "if", "the", "given", "field", "is", "lesser", "than", "or", "equal", "to", "the", "given", "value" ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/q/tree.go#L222-L224
train
asdine/storm
q/tree.go
LteF
func LteF(field1, field2 string) Matcher { return NewField2FieldMatcher(field1, field2, token.LEQ) }
go
func LteF(field1, field2 string) Matcher { return NewField2FieldMatcher(field1, field2, token.LEQ) }
[ "func", "LteF", "(", "field1", ",", "field2", "string", ")", "Matcher", "{", "return", "NewField2FieldMatcher", "(", "field1", ",", "field2", ",", "token", ".", "LEQ", ")", "\n", "}" ]
// LteF matcher, checks if the given field is lesser than or equal to the given field
[ "LteF", "matcher", "checks", "if", "the", "given", "field", "is", "lesser", "than", "or", "equal", "to", "the", "given", "field" ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/q/tree.go#L227-L229
train
asdine/storm
q/tree.go
In
func In(field string, v interface{}) Matcher { return NewFieldMatcher(field, &in{list: v}) }
go
func In(field string, v interface{}) Matcher { return NewFieldMatcher(field, &in{list: v}) }
[ "func", "In", "(", "field", "string", ",", "v", "interface", "{", "}", ")", "Matcher", "{", "return", "NewFieldMatcher", "(", "field", ",", "&", "in", "{", "list", ":", "v", "}", ")", "\n", "}" ]
// In matcher, checks if the given field matches one of the value of the given slice. // v must be a slice.
[ "In", "matcher", "checks", "if", "the", "given", "field", "matches", "one", "of", "the", "value", "of", "the", "given", "slice", ".", "v", "must", "be", "a", "slice", "." ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/q/tree.go#L233-L235
train
asdine/storm
scan.go
PrefixScan
func (n *node) PrefixScan(prefix string) []Node { if n.tx != nil { return n.prefixScan(n.tx, prefix) } var nodes []Node n.readTx(func(tx *bolt.Tx) error { nodes = n.prefixScan(tx, prefix) return nil }) return nodes }
go
func (n *node) PrefixScan(prefix string) []Node { if n.tx != nil { return n.prefixScan(n.tx, prefix) } var nodes []Node n.readTx(func(tx *bolt.Tx) error { nodes = n.prefixScan(tx, prefix) return nil }) return nodes }
[ "func", "(", "n", "*", "node", ")", "PrefixScan", "(", "prefix", "string", ")", "[", "]", "Node", "{", "if", "n", ".", "tx", "!=", "nil", "{", "return", "n", ".", "prefixScan", "(", "n", ".", "tx", ",", "prefix", ")", "\n", "}", "\n\n", "var", ...
// PrefixScan scans the buckets in this node for keys matching the given prefix.
[ "PrefixScan", "scans", "the", "buckets", "in", "this", "node", "for", "keys", "matching", "the", "given", "prefix", "." ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/scan.go#L18-L31
train
asdine/storm
scan.go
RangeScan
func (n *node) RangeScan(min, max string) []Node { if n.tx != nil { return n.rangeScan(n.tx, min, max) } var nodes []Node n.readTx(func(tx *bolt.Tx) error { nodes = n.rangeScan(tx, min, max) return nil }) return nodes }
go
func (n *node) RangeScan(min, max string) []Node { if n.tx != nil { return n.rangeScan(n.tx, min, max) } var nodes []Node n.readTx(func(tx *bolt.Tx) error { nodes = n.rangeScan(tx, min, max) return nil }) return nodes }
[ "func", "(", "n", "*", "node", ")", "RangeScan", "(", "min", ",", "max", "string", ")", "[", "]", "Node", "{", "if", "n", ".", "tx", "!=", "nil", "{", "return", "n", ".", "rangeScan", "(", "n", ".", "tx", ",", "min", ",", "max", ")", "\n", ...
// RangeScan scans the buckets in this node over a range such as a sortable time range.
[ "RangeScan", "scans", "the", "buckets", "in", "this", "node", "over", "a", "range", "such", "as", "a", "sortable", "time", "range", "." ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/scan.go#L53-L66
train
asdine/storm
bucket.go
CreateBucketIfNotExists
func (n *node) CreateBucketIfNotExists(tx *bolt.Tx, bucket string) (*bolt.Bucket, error) { var b *bolt.Bucket var err error bucketNames := append(n.rootBucket, bucket) for _, bucketName := range bucketNames { if b != nil { if b, err = b.CreateBucketIfNotExists([]byte(bucketName)); err != nil { return nil...
go
func (n *node) CreateBucketIfNotExists(tx *bolt.Tx, bucket string) (*bolt.Bucket, error) { var b *bolt.Bucket var err error bucketNames := append(n.rootBucket, bucket) for _, bucketName := range bucketNames { if b != nil { if b, err = b.CreateBucketIfNotExists([]byte(bucketName)); err != nil { return nil...
[ "func", "(", "n", "*", "node", ")", "CreateBucketIfNotExists", "(", "tx", "*", "bolt", ".", "Tx", ",", "bucket", "string", ")", "(", "*", "bolt", ".", "Bucket", ",", "error", ")", "{", "var", "b", "*", "bolt", ".", "Bucket", "\n", "var", "err", "...
// CreateBucketIfNotExists creates the bucket below the current node if it doesn't // already exist.
[ "CreateBucketIfNotExists", "creates", "the", "bucket", "below", "the", "current", "node", "if", "it", "doesn", "t", "already", "exist", "." ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/bucket.go#L7-L27
train
asdine/storm
bucket.go
GetBucket
func (n *node) GetBucket(tx *bolt.Tx, children ...string) *bolt.Bucket { var b *bolt.Bucket bucketNames := append(n.rootBucket, children...) for _, bucketName := range bucketNames { if b != nil { if b = b.Bucket([]byte(bucketName)); b == nil { return nil } } else { if b = tx.Bucket([]byte(bucketNam...
go
func (n *node) GetBucket(tx *bolt.Tx, children ...string) *bolt.Bucket { var b *bolt.Bucket bucketNames := append(n.rootBucket, children...) for _, bucketName := range bucketNames { if b != nil { if b = b.Bucket([]byte(bucketName)); b == nil { return nil } } else { if b = tx.Bucket([]byte(bucketNam...
[ "func", "(", "n", "*", "node", ")", "GetBucket", "(", "tx", "*", "bolt", ".", "Tx", ",", "children", "...", "string", ")", "*", "bolt", ".", "Bucket", "{", "var", "b", "*", "bolt", ".", "Bucket", "\n\n", "bucketNames", ":=", "append", "(", "n", "...
// GetBucket returns the given bucket below the current node.
[ "GetBucket", "returns", "the", "given", "bucket", "below", "the", "current", "node", "." ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/bucket.go#L30-L47
train
asdine/storm
transaction.go
Begin
func (n node) Begin(writable bool) (Node, error) { var err error n.tx, err = n.s.Bolt.Begin(writable) if err != nil { return nil, err } return &n, nil }
go
func (n node) Begin(writable bool) (Node, error) { var err error n.tx, err = n.s.Bolt.Begin(writable) if err != nil { return nil, err } return &n, nil }
[ "func", "(", "n", "node", ")", "Begin", "(", "writable", "bool", ")", "(", "Node", ",", "error", ")", "{", "var", "err", "error", "\n\n", "n", ".", "tx", ",", "err", "=", "n", ".", "s", ".", "Bolt", ".", "Begin", "(", "writable", ")", "\n", "...
// Begin starts a new transaction.
[ "Begin", "starts", "a", "new", "transaction", "." ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/transaction.go#L15-L24
train
asdine/storm
transaction.go
Rollback
func (n *node) Rollback() error { if n.tx == nil { return ErrNotInTransaction } err := n.tx.Rollback() if err == bolt.ErrTxClosed { return ErrNotInTransaction } return err }
go
func (n *node) Rollback() error { if n.tx == nil { return ErrNotInTransaction } err := n.tx.Rollback() if err == bolt.ErrTxClosed { return ErrNotInTransaction } return err }
[ "func", "(", "n", "*", "node", ")", "Rollback", "(", ")", "error", "{", "if", "n", ".", "tx", "==", "nil", "{", "return", "ErrNotInTransaction", "\n", "}", "\n\n", "err", ":=", "n", ".", "tx", ".", "Rollback", "(", ")", "\n", "if", "err", "==", ...
// Rollback closes the transaction and ignores all previous updates.
[ "Rollback", "closes", "the", "transaction", "and", "ignores", "all", "previous", "updates", "." ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/transaction.go#L27-L38
train
asdine/storm
q/fieldmatcher.go
NewFieldMatcher
func NewFieldMatcher(field string, fm FieldMatcher) Matcher { return fieldMatcherDelegate{Field: field, FieldMatcher: fm} }
go
func NewFieldMatcher(field string, fm FieldMatcher) Matcher { return fieldMatcherDelegate{Field: field, FieldMatcher: fm} }
[ "func", "NewFieldMatcher", "(", "field", "string", ",", "fm", "FieldMatcher", ")", "Matcher", "{", "return", "fieldMatcherDelegate", "{", "Field", ":", "field", ",", "FieldMatcher", ":", "fm", "}", "\n", "}" ]
// NewFieldMatcher creates a Matcher for a given field.
[ "NewFieldMatcher", "creates", "a", "Matcher", "for", "a", "given", "field", "." ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/q/fieldmatcher.go#L18-L20
train
asdine/storm
q/fieldmatcher.go
NewField2FieldMatcher
func NewField2FieldMatcher(field1, field2 string, tok token.Token) Matcher { return field2fieldMatcherDelegate{Field1: field1, Field2: field2, Tok: tok} }
go
func NewField2FieldMatcher(field1, field2 string, tok token.Token) Matcher { return field2fieldMatcherDelegate{Field1: field1, Field2: field2, Tok: tok} }
[ "func", "NewField2FieldMatcher", "(", "field1", ",", "field2", "string", ",", "tok", "token", ".", "Token", ")", "Matcher", "{", "return", "field2fieldMatcherDelegate", "{", "Field1", ":", "field1", ",", "Field2", ":", "field2", ",", "Tok", ":", "tok", "}", ...
// NewField2FieldMatcher creates a Matcher for a given field1 and field2.
[ "NewField2FieldMatcher", "creates", "a", "Matcher", "for", "a", "given", "field1", "and", "field2", "." ]
e0f77eada154c7c2670527a8566d3c045880224f
https://github.com/asdine/storm/blob/e0f77eada154c7c2670527a8566d3c045880224f/q/fieldmatcher.go#L43-L45
train