repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
fcavani/text
validation.go
CleanUrl
func CleanUrl(rawurl string, min, max int) (string, error) { err := CheckUrl(rawurl, min, max) if err != nil { return "", e.Forward(err) } u, err := url.Parse(rawurl) if err != nil { return "", e.Push(e.New(ErrInvUrl), err) } if u.Scheme == "" { return u.String(), e.New(ErrNoScheme) } return u.String(), ...
go
func CleanUrl(rawurl string, min, max int) (string, error) { err := CheckUrl(rawurl, min, max) if err != nil { return "", e.Forward(err) } u, err := url.Parse(rawurl) if err != nil { return "", e.Push(e.New(ErrInvUrl), err) } if u.Scheme == "" { return u.String(), e.New(ErrNoScheme) } return u.String(), ...
[ "func", "CleanUrl", "(", "rawurl", "string", ",", "min", ",", "max", "int", ")", "(", "string", ",", "error", ")", "{", "err", ":=", "CheckUrl", "(", "rawurl", ",", "min", ",", "max", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"\"", ",...
// CleanUrl check the characteres in url and parser it with url.Parse. // If url is ok return one string with it or if the scheme is missing // return the url and an error.
[ "CleanUrl", "check", "the", "characteres", "in", "url", "and", "parser", "it", "with", "url", ".", "Parse", ".", "If", "url", "is", "ok", "return", "one", "string", "with", "it", "or", "if", "the", "scheme", "is", "missing", "return", "the", "url", "an...
023e76809b57fc8cfc80c855ba59537720821cb5
https://github.com/fcavani/text/blob/023e76809b57fc8cfc80c855ba59537720821cb5/validation.go#L193-L206
test
mota/klash
parameter.go
NewParameter
func NewParameter(name string, value reflect.Value) *Parameter { parameter := Parameter{ Name: name, Value: value, } return &parameter }
go
func NewParameter(name string, value reflect.Value) *Parameter { parameter := Parameter{ Name: name, Value: value, } return &parameter }
[ "func", "NewParameter", "(", "name", "string", ",", "value", "reflect", ".", "Value", ")", "*", "Parameter", "{", "parameter", ":=", "Parameter", "{", "Name", ":", "name", ",", "Value", ":", "value", ",", "}", "\n", "return", "&", "parameter", "\n", "}...
// A capacity of 2 seems to be a good guess for the number of aliases.
[ "A", "capacity", "of", "2", "seems", "to", "be", "a", "good", "guess", "for", "the", "number", "of", "aliases", "." ]
ca6c37a4c8c2e69831c428cf0c6daac80ab56c22
https://github.com/mota/klash/blob/ca6c37a4c8c2e69831c428cf0c6daac80ab56c22/parameter.go#L21-L27
test
mota/klash
params.go
MakeParams
func MakeParams(fieldCount int) *Params { return &Params{ make(map[string]*Parameter), make([]*Parameter, 0, fieldCount), } }
go
func MakeParams(fieldCount int) *Params { return &Params{ make(map[string]*Parameter), make([]*Parameter, 0, fieldCount), } }
[ "func", "MakeParams", "(", "fieldCount", "int", ")", "*", "Params", "{", "return", "&", "Params", "{", "make", "(", "map", "[", "string", "]", "*", "Parameter", ")", ",", "make", "(", "[", "]", "*", "Parameter", ",", "0", ",", "fieldCount", ")", ",...
// Params store the mapping of ParamName -> Parameter for the given structure. // Since multiple names can be affected to a single parameter, multiple // keys can be associated with a single parameter.
[ "Params", "store", "the", "mapping", "of", "ParamName", "-", ">", "Parameter", "for", "the", "given", "structure", ".", "Since", "multiple", "names", "can", "be", "affected", "to", "a", "single", "parameter", "multiple", "keys", "can", "be", "associated", "w...
ca6c37a4c8c2e69831c428cf0c6daac80ab56c22
https://github.com/mota/klash/blob/ca6c37a4c8c2e69831c428cf0c6daac80ab56c22/params.go#L17-L22
test
mota/klash
params.go
Parse
func (p *Params) Parse(pvalue *reflect.Value) error { vtype := pvalue.Type().Elem() for idx := 0; idx < vtype.NumField(); idx++ { field := vtype.Field(idx) value := pvalue.Elem().Field(idx) if value.Kind() == reflect.Slice { value.Set(reflect.MakeSlice(value.Type(), 0, 0)) } parameter := NewParameter...
go
func (p *Params) Parse(pvalue *reflect.Value) error { vtype := pvalue.Type().Elem() for idx := 0; idx < vtype.NumField(); idx++ { field := vtype.Field(idx) value := pvalue.Elem().Field(idx) if value.Kind() == reflect.Slice { value.Set(reflect.MakeSlice(value.Type(), 0, 0)) } parameter := NewParameter...
[ "func", "(", "p", "*", "Params", ")", "Parse", "(", "pvalue", "*", "reflect", ".", "Value", ")", "error", "{", "vtype", ":=", "pvalue", ".", "Type", "(", ")", ".", "Elem", "(", ")", "\n", "for", "idx", ":=", "0", ";", "idx", "<", "vtype", ".", ...
// Parse discovers the given parameters structure and associates the structure's // field names with their values into the Params structure.
[ "Parse", "discovers", "the", "given", "parameters", "structure", "and", "associates", "the", "structure", "s", "field", "names", "with", "their", "values", "into", "the", "Params", "structure", "." ]
ca6c37a4c8c2e69831c428cf0c6daac80ab56c22
https://github.com/mota/klash/blob/ca6c37a4c8c2e69831c428cf0c6daac80ab56c22/params.go#L41-L70
test
blacksails/cgp
forwarder.go
Email
func (f Forwarder) Email() string { return fmt.Sprintf("%s@%s", f.Name, f.Domain.Name) }
go
func (f Forwarder) Email() string { return fmt.Sprintf("%s@%s", f.Name, f.Domain.Name) }
[ "func", "(", "f", "Forwarder", ")", "Email", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"%s@%s\"", ",", "f", ".", "Name", ",", "f", ".", "Domain", ".", "Name", ")", "\n", "}" ]
// Email returns the forwarder email on the primary domain
[ "Email", "returns", "the", "forwarder", "email", "on", "the", "primary", "domain" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/forwarder.go#L16-L18
test
blacksails/cgp
forwarder.go
Forwarder
func (dom *Domain) Forwarder(name, to string) *Forwarder { return &Forwarder{Domain: dom, Name: name, To: to} }
go
func (dom *Domain) Forwarder(name, to string) *Forwarder { return &Forwarder{Domain: dom, Name: name, To: to} }
[ "func", "(", "dom", "*", "Domain", ")", "Forwarder", "(", "name", ",", "to", "string", ")", "*", "Forwarder", "{", "return", "&", "Forwarder", "{", "Domain", ":", "dom", ",", "Name", ":", "name", ",", "To", ":", "to", "}", "\n", "}" ]
// Forwarder returns a forwarder type with the given from and dest
[ "Forwarder", "returns", "a", "forwarder", "type", "with", "the", "given", "from", "and", "dest" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/forwarder.go#L21-L23
test
blacksails/cgp
forwarder.go
Forwarders
func (dom *Domain) Forwarders() ([]*Forwarder, error) { var vl valueList err := dom.cgp.request(listForwarders{Param: dom.Name}, &vl) if err != nil { return []*Forwarder{}, err } vals := vl.compact() fs := make([]*Forwarder, len(vals)) for i, v := range vals { f, err := dom.GetForwarder(v) if err != nil { ...
go
func (dom *Domain) Forwarders() ([]*Forwarder, error) { var vl valueList err := dom.cgp.request(listForwarders{Param: dom.Name}, &vl) if err != nil { return []*Forwarder{}, err } vals := vl.compact() fs := make([]*Forwarder, len(vals)) for i, v := range vals { f, err := dom.GetForwarder(v) if err != nil { ...
[ "func", "(", "dom", "*", "Domain", ")", "Forwarders", "(", ")", "(", "[", "]", "*", "Forwarder", ",", "error", ")", "{", "var", "vl", "valueList", "\n", "err", ":=", "dom", ".", "cgp", ".", "request", "(", "listForwarders", "{", "Param", ":", "dom"...
// Forwarders lists the forwarders of a domain
[ "Forwarders", "lists", "the", "forwarders", "of", "a", "domain" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/forwarder.go#L31-L47
test
blacksails/cgp
forwarder.go
GetForwarder
func (dom *Domain) GetForwarder(name string) (*Forwarder, error) { var f string err := dom.cgp.request(getForwarder{Param: fmt.Sprintf("%s@%s", name, dom.Name)}, &f) if err != nil { return &Forwarder{}, err } return &Forwarder{Domain: dom, Name: name, To: f}, nil }
go
func (dom *Domain) GetForwarder(name string) (*Forwarder, error) { var f string err := dom.cgp.request(getForwarder{Param: fmt.Sprintf("%s@%s", name, dom.Name)}, &f) if err != nil { return &Forwarder{}, err } return &Forwarder{Domain: dom, Name: name, To: f}, nil }
[ "func", "(", "dom", "*", "Domain", ")", "GetForwarder", "(", "name", "string", ")", "(", "*", "Forwarder", ",", "error", ")", "{", "var", "f", "string", "\n", "err", ":=", "dom", ".", "cgp", ".", "request", "(", "getForwarder", "{", "Param", ":", "...
// GetForwarder retreives a forwarder with the given name
[ "GetForwarder", "retreives", "a", "forwarder", "with", "the", "given", "name" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/forwarder.go#L55-L62
test
blacksails/cgp
cgp.go
New
func New(url, user, pass string) *CGP { return &CGP{url: url, user: user, pass: pass} }
go
func New(url, user, pass string) *CGP { return &CGP{url: url, user: user, pass: pass} }
[ "func", "New", "(", "url", ",", "user", ",", "pass", "string", ")", "*", "CGP", "{", "return", "&", "CGP", "{", "url", ":", "url", ",", "user", ":", "user", ",", "pass", ":", "pass", "}", "\n", "}" ]
// New returns a new Communigate Pro client
[ "New", "returns", "a", "new", "Communigate", "Pro", "client" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/cgp.go#L11-L13
test
fcavani/text
escape.go
EscapeCommaSeparated
func EscapeCommaSeparated(in ...string) string { var out string for i, str := range in { escaped := strings.Replace(url.QueryEscape(str), "%2F", "%252F", -1) escaped = strings.Replace(escaped, "\"", "%22", -1) escaped = strings.Replace(escaped, " ", "%20", -1) out += escaped if i < len(in)-1 { out += ","...
go
func EscapeCommaSeparated(in ...string) string { var out string for i, str := range in { escaped := strings.Replace(url.QueryEscape(str), "%2F", "%252F", -1) escaped = strings.Replace(escaped, "\"", "%22", -1) escaped = strings.Replace(escaped, " ", "%20", -1) out += escaped if i < len(in)-1 { out += ","...
[ "func", "EscapeCommaSeparated", "(", "in", "...", "string", ")", "string", "{", "var", "out", "string", "\n", "for", "i", ",", "str", ":=", "range", "in", "{", "escaped", ":=", "strings", ".", "Replace", "(", "url", ".", "QueryEscape", "(", "str", ")",...
//EscapeCommaSeparated escapes the args and make a comma separeted list with it.
[ "EscapeCommaSeparated", "escapes", "the", "args", "and", "make", "a", "comma", "separeted", "list", "with", "it", "." ]
023e76809b57fc8cfc80c855ba59537720821cb5
https://github.com/fcavani/text/blob/023e76809b57fc8cfc80c855ba59537720821cb5/escape.go#L15-L27
test
blacksails/cgp
alias.go
Alias
func (acc *Account) Alias(name string) *Alias { return &Alias{account: acc, Name: name} }
go
func (acc *Account) Alias(name string) *Alias { return &Alias{account: acc, Name: name} }
[ "func", "(", "acc", "*", "Account", ")", "Alias", "(", "name", "string", ")", "*", "Alias", "{", "return", "&", "Alias", "{", "account", ":", "acc", ",", "Name", ":", "name", "}", "\n", "}" ]
// Alias creates an Alias type from an account
[ "Alias", "creates", "an", "Alias", "type", "from", "an", "account" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/alias.go#L15-L17
test
blacksails/cgp
alias.go
Email
func (a Alias) Email() string { return fmt.Sprintf("%s@%s", a.Name, a.account.Domain.Name) }
go
func (a Alias) Email() string { return fmt.Sprintf("%s@%s", a.Name, a.account.Domain.Name) }
[ "func", "(", "a", "Alias", ")", "Email", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"%s@%s\"", ",", "a", ".", "Name", ",", "a", ".", "account", ".", "Domain", ".", "Name", ")", "\n", "}" ]
// Email returns the alias email on the primary domain name
[ "Email", "returns", "the", "alias", "email", "on", "the", "primary", "domain", "name" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/alias.go#L20-L22
test
blacksails/cgp
alias.go
Aliases
func (acc *Account) Aliases() ([]*Alias, error) { var vl valueList err := acc.Domain.cgp.request(listAliases{Param: fmt.Sprintf("%s@%s", acc.Name, acc.Domain.Name)}, &vl) if err != nil { return []*Alias{}, err } vals := vl.compact() as := make([]*Alias, len(vals)) for i, v := range vals { as[i] = acc.Alias(v...
go
func (acc *Account) Aliases() ([]*Alias, error) { var vl valueList err := acc.Domain.cgp.request(listAliases{Param: fmt.Sprintf("%s@%s", acc.Name, acc.Domain.Name)}, &vl) if err != nil { return []*Alias{}, err } vals := vl.compact() as := make([]*Alias, len(vals)) for i, v := range vals { as[i] = acc.Alias(v...
[ "func", "(", "acc", "*", "Account", ")", "Aliases", "(", ")", "(", "[", "]", "*", "Alias", ",", "error", ")", "{", "var", "vl", "valueList", "\n", "err", ":=", "acc", ".", "Domain", ".", "cgp", ".", "request", "(", "listAliases", "{", "Param", ":...
// Aliases lists the aliases of an account
[ "Aliases", "lists", "the", "aliases", "of", "an", "account" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/alias.go#L30-L42
test
blacksails/cgp
account.go
RealName
func (a Account) RealName() (string, error) { var d dictionary err := a.Domain.cgp.request(getAccountSettings{Account: a.Email()}, &d) if err != nil { return "", err } return d.toMap()["RealName"], nil }
go
func (a Account) RealName() (string, error) { var d dictionary err := a.Domain.cgp.request(getAccountSettings{Account: a.Email()}, &d) if err != nil { return "", err } return d.toMap()["RealName"], nil }
[ "func", "(", "a", "Account", ")", "RealName", "(", ")", "(", "string", ",", "error", ")", "{", "var", "d", "dictionary", "\n", "err", ":=", "a", ".", "Domain", ".", "cgp", ".", "request", "(", "getAccountSettings", "{", "Account", ":", "a", ".", "E...
// RealName return the real name of the account as registered
[ "RealName", "return", "the", "real", "name", "of", "the", "account", "as", "registered" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/account.go#L20-L27
test
blacksails/cgp
account.go
Email
func (a Account) Email() string { return fmt.Sprintf("%s@%s", a.Name, a.Domain.Name) }
go
func (a Account) Email() string { return fmt.Sprintf("%s@%s", a.Name, a.Domain.Name) }
[ "func", "(", "a", "Account", ")", "Email", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"%s@%s\"", ",", "a", ".", "Name", ",", "a", ".", "Domain", ".", "Name", ")", "\n", "}" ]
// Email returns the primary email of the account
[ "Email", "returns", "the", "primary", "email", "of", "the", "account" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/account.go#L30-L32
test
blacksails/cgp
account.go
Account
func (dom *Domain) Account(name string) *Account { return &Account{Domain: dom, Name: name} }
go
func (dom *Domain) Account(name string) *Account { return &Account{Domain: dom, Name: name} }
[ "func", "(", "dom", "*", "Domain", ")", "Account", "(", "name", "string", ")", "*", "Account", "{", "return", "&", "Account", "{", "Domain", ":", "dom", ",", "Name", ":", "name", "}", "\n", "}" ]
// Account returns an account type with the given name
[ "Account", "returns", "an", "account", "type", "with", "the", "given", "name" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/account.go#L35-L37
test
blacksails/cgp
account.go
Accounts
func (dom *Domain) Accounts() ([]*Account, error) { var al accountList err := dom.cgp.request(listAccounts{Domain: dom.Name}, &al) if err != nil { return []*Account{}, err } keys := al.SubKeys as := make([]*Account, len(keys)) for i, k := range keys { as[i] = dom.Account(k.Name) } return as, nil }
go
func (dom *Domain) Accounts() ([]*Account, error) { var al accountList err := dom.cgp.request(listAccounts{Domain: dom.Name}, &al) if err != nil { return []*Account{}, err } keys := al.SubKeys as := make([]*Account, len(keys)) for i, k := range keys { as[i] = dom.Account(k.Name) } return as, nil }
[ "func", "(", "dom", "*", "Domain", ")", "Accounts", "(", ")", "(", "[", "]", "*", "Account", ",", "error", ")", "{", "var", "al", "accountList", "\n", "err", ":=", "dom", ".", "cgp", ".", "request", "(", "listAccounts", "{", "Domain", ":", "dom", ...
// Accounts lists the acounts of a domain
[ "Accounts", "lists", "the", "acounts", "of", "a", "domain" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/account.go#L53-L65
test
blacksails/cgp
domain.go
Exists
func (dom Domain) Exists() (bool, error) { var d dictionary err := dom.cgp.request(getDomainSettings{Domain: dom.Name}, &d) if _, ok := err.(SOAPNotFoundError); ok { return false, nil } if err != nil { return false, err } return true, nil }
go
func (dom Domain) Exists() (bool, error) { var d dictionary err := dom.cgp.request(getDomainSettings{Domain: dom.Name}, &d) if _, ok := err.(SOAPNotFoundError); ok { return false, nil } if err != nil { return false, err } return true, nil }
[ "func", "(", "dom", "Domain", ")", "Exists", "(", ")", "(", "bool", ",", "error", ")", "{", "var", "d", "dictionary", "\n", "err", ":=", "dom", ".", "cgp", ".", "request", "(", "getDomainSettings", "{", "Domain", ":", "dom", ".", "Name", "}", ",", ...
// Exists returns true if the domain
[ "Exists", "returns", "true", "if", "the", "domain" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/domain.go#L17-L27
test
blacksails/cgp
domain.go
Aliases
func (dom Domain) Aliases() ([]string, error) { var vl valueList err := dom.cgp.request(getDomainAliases{Domain: dom.Name}, &vl) if err != nil { return []string{}, err } return vl.compact(), nil }
go
func (dom Domain) Aliases() ([]string, error) { var vl valueList err := dom.cgp.request(getDomainAliases{Domain: dom.Name}, &vl) if err != nil { return []string{}, err } return vl.compact(), nil }
[ "func", "(", "dom", "Domain", ")", "Aliases", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "vl", "valueList", "\n", "err", ":=", "dom", ".", "cgp", ".", "request", "(", "getDomainAliases", "{", "Domain", ":", "dom", ".", "Name"...
// Aliases returns a list of domain aliases
[ "Aliases", "returns", "a", "list", "of", "domain", "aliases" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/domain.go#L35-L42
test
blacksails/cgp
domain.go
Domain
func (cgp *CGP) Domain(name string) *Domain { return &Domain{cgp: cgp, Name: name} }
go
func (cgp *CGP) Domain(name string) *Domain { return &Domain{cgp: cgp, Name: name} }
[ "func", "(", "cgp", "*", "CGP", ")", "Domain", "(", "name", "string", ")", "*", "Domain", "{", "return", "&", "Domain", "{", "cgp", ":", "cgp", ",", "Name", ":", "name", "}", "\n", "}" ]
// Domain creates a domain type with the given name
[ "Domain", "creates", "a", "domain", "type", "with", "the", "given", "name" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/domain.go#L49-L51
test
blacksails/cgp
domain.go
Domains
func (cgp *CGP) Domains() ([]*Domain, error) { var vl valueList err := cgp.request(listDomains{}, &vl) if err != nil { return []*Domain{}, err } vals := vl.SubValues ds := make([]*Domain, len(vals)) for i, d := range vals { ds[i] = cgp.Domain(d) } return ds, nil }
go
func (cgp *CGP) Domains() ([]*Domain, error) { var vl valueList err := cgp.request(listDomains{}, &vl) if err != nil { return []*Domain{}, err } vals := vl.SubValues ds := make([]*Domain, len(vals)) for i, d := range vals { ds[i] = cgp.Domain(d) } return ds, nil }
[ "func", "(", "cgp", "*", "CGP", ")", "Domains", "(", ")", "(", "[", "]", "*", "Domain", ",", "error", ")", "{", "var", "vl", "valueList", "\n", "err", ":=", "cgp", ".", "request", "(", "listDomains", "{", "}", ",", "&", "vl", ")", "\n", "if", ...
// Domains lists the domains on the server
[ "Domains", "lists", "the", "domains", "on", "the", "server" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/domain.go#L54-L66
test
marcuswestin/go-errs
errs.go
New
func New(info Info, publicMsg ...interface{}) Err { return newErr(debug.Stack(), nil, false, info, publicMsg) }
go
func New(info Info, publicMsg ...interface{}) Err { return newErr(debug.Stack(), nil, false, info, publicMsg) }
[ "func", "New", "(", "info", "Info", ",", "publicMsg", "...", "interface", "{", "}", ")", "Err", "{", "return", "newErr", "(", "debug", ".", "Stack", "(", ")", ",", "nil", ",", "false", ",", "info", ",", "publicMsg", ")", "\n", "}" ]
// New creates a new Err with the given Info and optional public message
[ "New", "creates", "a", "new", "Err", "with", "the", "given", "Info", "and", "optional", "public", "message" ]
b09b17aacd5a8213690bc30f9ccfe7400be7b380
https://github.com/marcuswestin/go-errs/blob/b09b17aacd5a8213690bc30f9ccfe7400be7b380/errs.go#L79-L81
test
marcuswestin/go-errs
errs.go
Wrap
func Wrap(wrapErr error, info Info, publicMsg ...interface{}) Err { if wrapErr == nil { return nil } if info == nil { info = Info{} } if errsErr, isErr := IsErr(wrapErr); isErr { if errStructErr, isErrsErr := errsErr.(*err); isErrsErr { errStructErr.mergeIn(info, publicMsg) return errStructErr } re...
go
func Wrap(wrapErr error, info Info, publicMsg ...interface{}) Err { if wrapErr == nil { return nil } if info == nil { info = Info{} } if errsErr, isErr := IsErr(wrapErr); isErr { if errStructErr, isErrsErr := errsErr.(*err); isErrsErr { errStructErr.mergeIn(info, publicMsg) return errStructErr } re...
[ "func", "Wrap", "(", "wrapErr", "error", ",", "info", "Info", ",", "publicMsg", "...", "interface", "{", "}", ")", "Err", "{", "if", "wrapErr", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "if", "info", "==", "nil", "{", "info", "=", "Info",...
// Wrap the given error in an errs.Err. If err is nil, Wrap returns nil. // Use Err.WrappedError for direct access to the wrapped error.
[ "Wrap", "the", "given", "error", "in", "an", "errs", ".", "Err", ".", "If", "err", "is", "nil", "Wrap", "returns", "nil", ".", "Use", "Err", ".", "WrappedError", "for", "direct", "access", "to", "the", "wrapped", "error", "." ]
b09b17aacd5a8213690bc30f9ccfe7400be7b380
https://github.com/marcuswestin/go-errs/blob/b09b17aacd5a8213690bc30f9ccfe7400be7b380/errs.go#L85-L100
test
marcuswestin/go-errs
errs.go
mergeIn
func (e *err) mergeIn(info Info, publicMsgParts []interface{}) { for key, val := range info { for e.info[key] != nil { key = key + "_duplicate" } e.info[key] = val } publicMsgPrefix := concatArgs(publicMsgParts...) if publicMsgPrefix == "" { // do nothing } else if e.publicMsg == "" { e.publicMsg = pu...
go
func (e *err) mergeIn(info Info, publicMsgParts []interface{}) { for key, val := range info { for e.info[key] != nil { key = key + "_duplicate" } e.info[key] = val } publicMsgPrefix := concatArgs(publicMsgParts...) if publicMsgPrefix == "" { // do nothing } else if e.publicMsg == "" { e.publicMsg = pu...
[ "func", "(", "e", "*", "err", ")", "mergeIn", "(", "info", "Info", ",", "publicMsgParts", "[", "]", "interface", "{", "}", ")", "{", "for", "key", ",", "val", ":=", "range", "info", "{", "for", "e", ".", "info", "[", "key", "]", "!=", "nil", "{...
// Merge in the given info and public message parts into this error
[ "Merge", "in", "the", "given", "info", "and", "public", "message", "parts", "into", "this", "error" ]
b09b17aacd5a8213690bc30f9ccfe7400be7b380
https://github.com/marcuswestin/go-errs/blob/b09b17aacd5a8213690bc30f9ccfe7400be7b380/errs.go#L173-L188
test
marcuswestin/go-errs
errs.go
wrappedErrStr
func (e *err) wrappedErrStr() string { if e == nil { return "" } if e.wrappedErr == nil { return "" } return e.wrappedErr.Error() }
go
func (e *err) wrappedErrStr() string { if e == nil { return "" } if e.wrappedErr == nil { return "" } return e.wrappedErr.Error() }
[ "func", "(", "e", "*", "err", ")", "wrappedErrStr", "(", ")", "string", "{", "if", "e", "==", "nil", "{", "return", "\"\"", "\n", "}", "\n", "if", "e", ".", "wrappedErr", "==", "nil", "{", "return", "\"\"", "\n", "}", "\n", "return", "e", ".", ...
// Get the string representation of the wrapper error, // or an empty string if wrappedErr is nil
[ "Get", "the", "string", "representation", "of", "the", "wrapper", "error", "or", "an", "empty", "string", "if", "wrappedErr", "is", "nil" ]
b09b17aacd5a8213690bc30f9ccfe7400be7b380
https://github.com/marcuswestin/go-errs/blob/b09b17aacd5a8213690bc30f9ccfe7400be7b380/errs.go#L192-L200
test
marcuswestin/go-errs
errs.go
concatArgs
func concatArgs(args ...interface{}) string { res := fmt.Sprintln(args...) return res[0 : len(res)-1] // Remove newline at the end }
go
func concatArgs(args ...interface{}) string { res := fmt.Sprintln(args...) return res[0 : len(res)-1] // Remove newline at the end }
[ "func", "concatArgs", "(", "args", "...", "interface", "{", "}", ")", "string", "{", "res", ":=", "fmt", ".", "Sprintln", "(", "args", "...", ")", "\n", "return", "res", "[", "0", ":", "len", "(", "res", ")", "-", "1", "]", "\n", "}" ]
// Helper to concatenate arguments into a string, // with spaces between the arguments
[ "Helper", "to", "concatenate", "arguments", "into", "a", "string", "with", "spaces", "between", "the", "arguments" ]
b09b17aacd5a8213690bc30f9ccfe7400be7b380
https://github.com/marcuswestin/go-errs/blob/b09b17aacd5a8213690bc30f9ccfe7400be7b380/errs.go#L204-L207
test
blacksails/cgp
mailing_list.go
MailingList
func (dom *Domain) MailingList(name string) *MailingList { return &MailingList{Domain: dom, Name: name} }
go
func (dom *Domain) MailingList(name string) *MailingList { return &MailingList{Domain: dom, Name: name} }
[ "func", "(", "dom", "*", "Domain", ")", "MailingList", "(", "name", "string", ")", "*", "MailingList", "{", "return", "&", "MailingList", "{", "Domain", ":", "dom", ",", "Name", ":", "name", "}", "\n", "}" ]
// MailingList creates a MailingList type from a domain, with the given name
[ "MailingList", "creates", "a", "MailingList", "type", "from", "a", "domain", "with", "the", "given", "name" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/mailing_list.go#L15-L17
test
blacksails/cgp
mailing_list.go
Subscriber
func (ml *MailingList) Subscriber(email, name string) *Subscriber { return &Subscriber{MailingList: ml, Email: email, RealName: name} }
go
func (ml *MailingList) Subscriber(email, name string) *Subscriber { return &Subscriber{MailingList: ml, Email: email, RealName: name} }
[ "func", "(", "ml", "*", "MailingList", ")", "Subscriber", "(", "email", ",", "name", "string", ")", "*", "Subscriber", "{", "return", "&", "Subscriber", "{", "MailingList", ":", "ml", ",", "Email", ":", "email", ",", "RealName", ":", "name", "}", "\n",...
// Subscriber create a Subscriber type from a MalingList, with the given email // and name
[ "Subscriber", "create", "a", "Subscriber", "type", "from", "a", "MalingList", "with", "the", "given", "email", "and", "name" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/mailing_list.go#L28-L30
test
blacksails/cgp
mailing_list.go
Subscribers
func (ml *MailingList) Subscribers() ([]*Subscriber, error) { var res readSubscribersResponse err := ml.Domain.cgp.request(readSubscribers{Name: fmt.Sprintf("%s@%s", ml.Name, ml.Domain.Name)}, &res) if err != nil { return []*Subscriber{}, err } ds := res.SubValues[1].SubValues subs := make([]*Subscriber, len(ds...
go
func (ml *MailingList) Subscribers() ([]*Subscriber, error) { var res readSubscribersResponse err := ml.Domain.cgp.request(readSubscribers{Name: fmt.Sprintf("%s@%s", ml.Name, ml.Domain.Name)}, &res) if err != nil { return []*Subscriber{}, err } ds := res.SubValues[1].SubValues subs := make([]*Subscriber, len(ds...
[ "func", "(", "ml", "*", "MailingList", ")", "Subscribers", "(", ")", "(", "[", "]", "*", "Subscriber", ",", "error", ")", "{", "var", "res", "readSubscribersResponse", "\n", "err", ":=", "ml", ".", "Domain", ".", "cgp", ".", "request", "(", "readSubscr...
// Subscribers returns a list of subscriber of a mailing list.
[ "Subscribers", "returns", "a", "list", "of", "subscriber", "of", "a", "mailing", "list", "." ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/mailing_list.go#L42-L55
test
blacksails/cgp
mailing_list.go
MailingLists
func (dom *Domain) MailingLists() ([]*MailingList, error) { var vl valueList err := dom.cgp.request(listLists{Domain: dom.Name}, &vl) if err != nil { return []*MailingList{}, err } vals := vl.compact() mls := make([]*MailingList, len(vals)) for i, v := range vals { mls[i] = dom.MailingList(v) } return mls,...
go
func (dom *Domain) MailingLists() ([]*MailingList, error) { var vl valueList err := dom.cgp.request(listLists{Domain: dom.Name}, &vl) if err != nil { return []*MailingList{}, err } vals := vl.compact() mls := make([]*MailingList, len(vals)) for i, v := range vals { mls[i] = dom.MailingList(v) } return mls,...
[ "func", "(", "dom", "*", "Domain", ")", "MailingLists", "(", ")", "(", "[", "]", "*", "MailingList", ",", "error", ")", "{", "var", "vl", "valueList", "\n", "err", ":=", "dom", ".", "cgp", ".", "request", "(", "listLists", "{", "Domain", ":", "dom"...
// MailingLists lists the mailing lists of a domain
[ "MailingLists", "lists", "the", "mailing", "lists", "of", "a", "domain" ]
570ac705cf2d7a9235d911d00b6f976ab3386c2f
https://github.com/blacksails/cgp/blob/570ac705cf2d7a9235d911d00b6f976ab3386c2f/mailing_list.go#L63-L75
test
t3rm1n4l/nitro
skiplist/item.go
NewByteKeyItem
func NewByteKeyItem(k []byte) unsafe.Pointer { itm := byteKeyItem(k) return unsafe.Pointer(&itm) }
go
func NewByteKeyItem(k []byte) unsafe.Pointer { itm := byteKeyItem(k) return unsafe.Pointer(&itm) }
[ "func", "NewByteKeyItem", "(", "k", "[", "]", "byte", ")", "unsafe", ".", "Pointer", "{", "itm", ":=", "byteKeyItem", "(", "k", ")", "\n", "return", "unsafe", ".", "Pointer", "(", "&", "itm", ")", "\n", "}" ]
// NewByteKeyItem creates a new item from bytes
[ "NewByteKeyItem", "creates", "a", "new", "item", "from", "bytes" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/item.go#L46-L49
test
t3rm1n4l/nitro
skiplist/item.go
CompareBytes
func CompareBytes(this, that unsafe.Pointer) int { thisItem := (*byteKeyItem)(this) thatItem := (*byteKeyItem)(that) return bytes.Compare([]byte(*thisItem), []byte(*thatItem)) }
go
func CompareBytes(this, that unsafe.Pointer) int { thisItem := (*byteKeyItem)(this) thatItem := (*byteKeyItem)(that) return bytes.Compare([]byte(*thisItem), []byte(*thatItem)) }
[ "func", "CompareBytes", "(", "this", ",", "that", "unsafe", ".", "Pointer", ")", "int", "{", "thisItem", ":=", "(", "*", "byteKeyItem", ")", "(", "this", ")", "\n", "thatItem", ":=", "(", "*", "byteKeyItem", ")", "(", "that", ")", "\n", "return", "by...
// CompareBytes is a byte item comparator
[ "CompareBytes", "is", "a", "byte", "item", "comparator" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/item.go#L52-L56
test
t3rm1n4l/nitro
skiplist/item.go
CompareInt
func CompareInt(this, that unsafe.Pointer) int { thisItem := (*intKeyItem)(this) thatItem := (*intKeyItem)(that) return int(*thisItem - *thatItem) }
go
func CompareInt(this, that unsafe.Pointer) int { thisItem := (*intKeyItem)(this) thatItem := (*intKeyItem)(that) return int(*thisItem - *thatItem) }
[ "func", "CompareInt", "(", "this", ",", "that", "unsafe", ".", "Pointer", ")", "int", "{", "thisItem", ":=", "(", "*", "intKeyItem", ")", "(", "this", ")", "\n", "thatItem", ":=", "(", "*", "intKeyItem", ")", "(", "that", ")", "\n", "return", "int", ...
// CompareInt is a helper integer item comparator
[ "CompareInt", "is", "a", "helper", "integer", "item", "comparator" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/item.go#L69-L73
test
t3rm1n4l/nitro
mm/malloc.go
Malloc
func Malloc(l int) unsafe.Pointer { if Debug { atomic.AddUint64(&stats.allocs, 1) } return C.mm_malloc(C.size_t(l)) }
go
func Malloc(l int) unsafe.Pointer { if Debug { atomic.AddUint64(&stats.allocs, 1) } return C.mm_malloc(C.size_t(l)) }
[ "func", "Malloc", "(", "l", "int", ")", "unsafe", ".", "Pointer", "{", "if", "Debug", "{", "atomic", ".", "AddUint64", "(", "&", "stats", ".", "allocs", ",", "1", ")", "\n", "}", "\n", "return", "C", ".", "mm_malloc", "(", "C", ".", "size_t", "("...
// Malloc implements C like memory allocator
[ "Malloc", "implements", "C", "like", "memory", "allocator" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/mm/malloc.go#L36-L41
test
t3rm1n4l/nitro
mm/malloc.go
Free
func Free(p unsafe.Pointer) { if Debug { atomic.AddUint64(&stats.frees, 1) } C.mm_free(p) }
go
func Free(p unsafe.Pointer) { if Debug { atomic.AddUint64(&stats.frees, 1) } C.mm_free(p) }
[ "func", "Free", "(", "p", "unsafe", ".", "Pointer", ")", "{", "if", "Debug", "{", "atomic", ".", "AddUint64", "(", "&", "stats", ".", "frees", ",", "1", ")", "\n", "}", "\n", "C", ".", "mm_free", "(", "p", ")", "\n", "}" ]
// Free implements C like memory deallocator
[ "Free", "implements", "C", "like", "memory", "deallocator" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/mm/malloc.go#L44-L49
test
t3rm1n4l/nitro
mm/malloc.go
Stats
func Stats() string { mu.Lock() defer mu.Unlock() buf := C.mm_stats() s := "==== Stats ====\n" if Debug { s += fmt.Sprintf("Mallocs = %d\n"+ "Frees = %d\n", stats.allocs, stats.frees) } if buf != nil { s += C.GoString(buf) C.free(unsafe.Pointer(buf)) } return s }
go
func Stats() string { mu.Lock() defer mu.Unlock() buf := C.mm_stats() s := "==== Stats ====\n" if Debug { s += fmt.Sprintf("Mallocs = %d\n"+ "Frees = %d\n", stats.allocs, stats.frees) } if buf != nil { s += C.GoString(buf) C.free(unsafe.Pointer(buf)) } return s }
[ "func", "Stats", "(", ")", "string", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n", "buf", ":=", "C", ".", "mm_stats", "(", ")", "\n", "s", ":=", "\"==== Stats ====\\n\"", "\n", "\\n", "\n", "if", "Debug", "...
// Stats returns allocator statistics // Returns jemalloc stats
[ "Stats", "returns", "allocator", "statistics", "Returns", "jemalloc", "stats" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/mm/malloc.go#L53-L70
test
t3rm1n4l/nitro
mm/malloc.go
FreeOSMemory
func FreeOSMemory() error { errCode := int(C.mm_free2os()) if errCode != 0 { return fmt.Errorf("status: %d", errCode) } return nil }
go
func FreeOSMemory() error { errCode := int(C.mm_free2os()) if errCode != 0 { return fmt.Errorf("status: %d", errCode) } return nil }
[ "func", "FreeOSMemory", "(", ")", "error", "{", "errCode", ":=", "int", "(", "C", ".", "mm_free2os", "(", ")", ")", "\n", "if", "errCode", "!=", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"status: %d\"", ",", "errCode", ")", "\n", "}", "\n", ...
// FreeOSMemory forces jemalloc to scrub memory and release back to OS
[ "FreeOSMemory", "forces", "jemalloc", "to", "scrub", "memory", "and", "release", "back", "to", "OS" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/mm/malloc.go#L78-L85
test
t3rm1n4l/nitro
skiplist/builder.go
Add
func (s *Segment) Add(itm unsafe.Pointer) { itemLevel := s.builder.store.NewLevel(s.rand.Float32) x := s.builder.store.newNode(itm, itemLevel) s.sts.AddInt64(&s.sts.nodeAllocs, 1) s.sts.AddInt64(&s.sts.levelNodesCount[itemLevel], 1) s.sts.AddInt64(&s.sts.usedBytes, int64(s.builder.store.Size(x))) for l := 0; l <...
go
func (s *Segment) Add(itm unsafe.Pointer) { itemLevel := s.builder.store.NewLevel(s.rand.Float32) x := s.builder.store.newNode(itm, itemLevel) s.sts.AddInt64(&s.sts.nodeAllocs, 1) s.sts.AddInt64(&s.sts.levelNodesCount[itemLevel], 1) s.sts.AddInt64(&s.sts.usedBytes, int64(s.builder.store.Size(x))) for l := 0; l <...
[ "func", "(", "s", "*", "Segment", ")", "Add", "(", "itm", "unsafe", ".", "Pointer", ")", "{", "itemLevel", ":=", "s", ".", "builder", ".", "store", ".", "NewLevel", "(", "s", ".", "rand", ".", "Float32", ")", "\n", "x", ":=", "s", ".", "builder",...
// Add an item into skiplist segment
[ "Add", "an", "item", "into", "skiplist", "segment" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/builder.go#L36-L55
test
t3rm1n4l/nitro
skiplist/builder.go
NewSegment
func (b *Builder) NewSegment() *Segment { seg := &Segment{tail: make([]*Node, MaxLevel+1), head: make([]*Node, MaxLevel+1), builder: b, rand: rand.New(rand.NewSource(int64(rand.Int()))), } seg.sts.IsLocal(true) return seg }
go
func (b *Builder) NewSegment() *Segment { seg := &Segment{tail: make([]*Node, MaxLevel+1), head: make([]*Node, MaxLevel+1), builder: b, rand: rand.New(rand.NewSource(int64(rand.Int()))), } seg.sts.IsLocal(true) return seg }
[ "func", "(", "b", "*", "Builder", ")", "NewSegment", "(", ")", "*", "Segment", "{", "seg", ":=", "&", "Segment", "{", "tail", ":", "make", "(", "[", "]", "*", "Node", ",", "MaxLevel", "+", "1", ")", ",", "head", ":", "make", "(", "[", "]", "*...
// NewSegment creates a new skiplist segment
[ "NewSegment", "creates", "a", "new", "skiplist", "segment" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/builder.go#L68-L76
test
t3rm1n4l/nitro
skiplist/builder.go
Assemble
func (b *Builder) Assemble(segments ...*Segment) *Skiplist { tail := make([]*Node, MaxLevel+1) head := make([]*Node, MaxLevel+1) for _, seg := range segments { for l := 0; l <= MaxLevel; l++ { if tail[l] != nil && seg.head[l] != nil { tail[l].setNext(l, seg.head[l], false) } else if head[l] == nil && se...
go
func (b *Builder) Assemble(segments ...*Segment) *Skiplist { tail := make([]*Node, MaxLevel+1) head := make([]*Node, MaxLevel+1) for _, seg := range segments { for l := 0; l <= MaxLevel; l++ { if tail[l] != nil && seg.head[l] != nil { tail[l].setNext(l, seg.head[l], false) } else if head[l] == nil && se...
[ "func", "(", "b", "*", "Builder", ")", "Assemble", "(", "segments", "...", "*", "Segment", ")", "*", "Skiplist", "{", "tail", ":=", "make", "(", "[", "]", "*", "Node", ",", "MaxLevel", "+", "1", ")", "\n", "head", ":=", "make", "(", "[", "]", "...
// Assemble multiple skiplist segments and form a parent skiplist
[ "Assemble", "multiple", "skiplist", "segments", "and", "form", "a", "parent", "skiplist" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/builder.go#L79-L112
test
t3rm1n4l/nitro
nodetable/table.go
CompareNodeTable
func CompareNodeTable(a, b unsafe.Pointer) int { return int(uintptr(a)) - int(uintptr(b)) }
go
func CompareNodeTable(a, b unsafe.Pointer) int { return int(uintptr(a)) - int(uintptr(b)) }
[ "func", "CompareNodeTable", "(", "a", ",", "b", "unsafe", ".", "Pointer", ")", "int", "{", "return", "int", "(", "uintptr", "(", "a", ")", ")", "-", "int", "(", "uintptr", "(", "b", ")", ")", "\n", "}" ]
// CompareNodeTable implements comparator for nodetable instances
[ "CompareNodeTable", "implements", "comparator", "for", "nodetable", "instances" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nodetable/table.go#L58-L60
test
t3rm1n4l/nitro
nodetable/table.go
New
func New(hfn HashFn, kfn EqualKeyFn) *NodeTable { nt := &NodeTable{ fastHT: make(map[uint32]uint64), slowHT: make(map[uint32][]uint64), hash: hfn, keyEqual: kfn, } buf := dbInstances.MakeBuf() defer dbInstances.FreeBuf(buf) dbInstances.Insert(unsafe.Pointer(nt), CompareNodeTable, buf, &dbInstances...
go
func New(hfn HashFn, kfn EqualKeyFn) *NodeTable { nt := &NodeTable{ fastHT: make(map[uint32]uint64), slowHT: make(map[uint32][]uint64), hash: hfn, keyEqual: kfn, } buf := dbInstances.MakeBuf() defer dbInstances.FreeBuf(buf) dbInstances.Insert(unsafe.Pointer(nt), CompareNodeTable, buf, &dbInstances...
[ "func", "New", "(", "hfn", "HashFn", ",", "kfn", "EqualKeyFn", ")", "*", "NodeTable", "{", "nt", ":=", "&", "NodeTable", "{", "fastHT", ":", "make", "(", "map", "[", "uint32", "]", "uint64", ")", ",", "slowHT", ":", "make", "(", "map", "[", "uint32...
// New creates a nodetable instance
[ "New", "creates", "a", "nodetable", "instance" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nodetable/table.go#L80-L93
test
t3rm1n4l/nitro
nodetable/table.go
Stats
func (nt *NodeTable) Stats() string { return fmt.Sprintf("\nFastHTCount = %d\n"+ "SlowHTCount = %d\n"+ "Conflicts = %d\n"+ "MemoryInUse = %d\n", nt.fastHTCount, nt.slowHTCount, nt.conflicts, nt.MemoryInUse()) }
go
func (nt *NodeTable) Stats() string { return fmt.Sprintf("\nFastHTCount = %d\n"+ "SlowHTCount = %d\n"+ "Conflicts = %d\n"+ "MemoryInUse = %d\n", nt.fastHTCount, nt.slowHTCount, nt.conflicts, nt.MemoryInUse()) }
[ "func", "(", "nt", "*", "NodeTable", ")", "Stats", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"\\nFastHTCount = %d\\n\"", "+", "\\n", "+", "\\n", "+", "\"SlowHTCount = %d\\n\"", ",", "\\n", ",", "\"Conflicts = %d\\n\"", ",", "\\n", ",...
// Stats returns nodetable statistics
[ "Stats", "returns", "nodetable", "statistics" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nodetable/table.go#L96-L102
test
t3rm1n4l/nitro
nodetable/table.go
MemoryInUse
func (nt *NodeTable) MemoryInUse() int64 { return int64(approxItemSize * (nt.fastHTCount + nt.slowHTCount)) }
go
func (nt *NodeTable) MemoryInUse() int64 { return int64(approxItemSize * (nt.fastHTCount + nt.slowHTCount)) }
[ "func", "(", "nt", "*", "NodeTable", ")", "MemoryInUse", "(", ")", "int64", "{", "return", "int64", "(", "approxItemSize", "*", "(", "nt", ".", "fastHTCount", "+", "nt", ".", "slowHTCount", ")", ")", "\n", "}" ]
// MemoryInUse returns memory used by nodetable instance
[ "MemoryInUse", "returns", "memory", "used", "by", "nodetable", "instance" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nodetable/table.go#L105-L107
test
t3rm1n4l/nitro
nodetable/table.go
Get
func (nt *NodeTable) Get(key []byte) unsafe.Pointer { res := nt.find(key) if res.status&ntFoundMask == ntFoundMask { if res.status == ntFoundInFast { return decodePointer(res.fastHTValue) } return decodePointer(res.slowHTValues[res.slowHTPos]) } return nil }
go
func (nt *NodeTable) Get(key []byte) unsafe.Pointer { res := nt.find(key) if res.status&ntFoundMask == ntFoundMask { if res.status == ntFoundInFast { return decodePointer(res.fastHTValue) } return decodePointer(res.slowHTValues[res.slowHTPos]) } return nil }
[ "func", "(", "nt", "*", "NodeTable", ")", "Get", "(", "key", "[", "]", "byte", ")", "unsafe", ".", "Pointer", "{", "res", ":=", "nt", ".", "find", "(", "key", ")", "\n", "if", "res", ".", "status", "&", "ntFoundMask", "==", "ntFoundMask", "{", "i...
// Get returns node pointer for the lookup key
[ "Get", "returns", "node", "pointer", "for", "the", "lookup", "key" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nodetable/table.go#L110-L120
test
t3rm1n4l/nitro
nodetable/table.go
Update
func (nt *NodeTable) Update(key []byte, nptr unsafe.Pointer) (updated bool, oldPtr unsafe.Pointer) { res := nt.find(key) if res.status&ntFoundMask == ntFoundMask { // Found key, replace old pointer value with new one updated = true if res.status == ntFoundInFast { oldPtr = decodePointer(res.fastHTValue) n...
go
func (nt *NodeTable) Update(key []byte, nptr unsafe.Pointer) (updated bool, oldPtr unsafe.Pointer) { res := nt.find(key) if res.status&ntFoundMask == ntFoundMask { // Found key, replace old pointer value with new one updated = true if res.status == ntFoundInFast { oldPtr = decodePointer(res.fastHTValue) n...
[ "func", "(", "nt", "*", "NodeTable", ")", "Update", "(", "key", "[", "]", "byte", ",", "nptr", "unsafe", ".", "Pointer", ")", "(", "updated", "bool", ",", "oldPtr", "unsafe", ".", "Pointer", ")", "{", "res", ":=", "nt", ".", "find", "(", "key", "...
// Update inserts or replaces an existing entry
[ "Update", "inserts", "or", "replaces", "an", "existing", "entry" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nodetable/table.go#L123-L159
test
t3rm1n4l/nitro
nodetable/table.go
Remove
func (nt *NodeTable) Remove(key []byte) (success bool, nptr unsafe.Pointer) { res := nt.find(key) if res.status&ntFoundMask == ntFoundMask { success = true if res.status == ntFoundInFast { nptr = decodePointer(res.fastHTValue) // Key needs to be removed from fastHT. For that we need to move // an item pr...
go
func (nt *NodeTable) Remove(key []byte) (success bool, nptr unsafe.Pointer) { res := nt.find(key) if res.status&ntFoundMask == ntFoundMask { success = true if res.status == ntFoundInFast { nptr = decodePointer(res.fastHTValue) // Key needs to be removed from fastHT. For that we need to move // an item pr...
[ "func", "(", "nt", "*", "NodeTable", ")", "Remove", "(", "key", "[", "]", "byte", ")", "(", "success", "bool", ",", "nptr", "unsafe", ".", "Pointer", ")", "{", "res", ":=", "nt", ".", "find", "(", "key", ")", "\n", "if", "res", ".", "status", "...
// Remove an item from the nodetable
[ "Remove", "an", "item", "from", "the", "nodetable" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nodetable/table.go#L162-L209
test
t3rm1n4l/nitro
nodetable/table.go
Close
func (nt *NodeTable) Close() { nt.fastHTCount = 0 nt.slowHTCount = 0 nt.conflicts = 0 nt.fastHT = make(map[uint32]uint64) nt.slowHT = make(map[uint32][]uint64) buf := dbInstances.MakeBuf() defer dbInstances.FreeBuf(buf) dbInstances.Delete(unsafe.Pointer(nt), CompareNodeTable, buf, &dbInstances.Stats) }
go
func (nt *NodeTable) Close() { nt.fastHTCount = 0 nt.slowHTCount = 0 nt.conflicts = 0 nt.fastHT = make(map[uint32]uint64) nt.slowHT = make(map[uint32][]uint64) buf := dbInstances.MakeBuf() defer dbInstances.FreeBuf(buf) dbInstances.Delete(unsafe.Pointer(nt), CompareNodeTable, buf, &dbInstances.Stats) }
[ "func", "(", "nt", "*", "NodeTable", ")", "Close", "(", ")", "{", "nt", ".", "fastHTCount", "=", "0", "\n", "nt", ".", "slowHTCount", "=", "0", "\n", "nt", ".", "conflicts", "=", "0", "\n", "nt", ".", "fastHT", "=", "make", "(", "map", "[", "ui...
// Close destroys the nodetable
[ "Close", "destroys", "the", "nodetable" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nodetable/table.go#L273-L283
test
t3rm1n4l/nitro
nodetable/table.go
MemoryInUse
func MemoryInUse() (sz int64) { buf := dbInstances.MakeBuf() defer dbInstances.FreeBuf(buf) iter := dbInstances.NewIterator(CompareNodeTable, buf) for iter.SeekFirst(); iter.Valid(); iter.Next() { db := (*NodeTable)(iter.Get()) sz += db.MemoryInUse() } return }
go
func MemoryInUse() (sz int64) { buf := dbInstances.MakeBuf() defer dbInstances.FreeBuf(buf) iter := dbInstances.NewIterator(CompareNodeTable, buf) for iter.SeekFirst(); iter.Valid(); iter.Next() { db := (*NodeTable)(iter.Get()) sz += db.MemoryInUse() } return }
[ "func", "MemoryInUse", "(", ")", "(", "sz", "int64", ")", "{", "buf", ":=", "dbInstances", ".", "MakeBuf", "(", ")", "\n", "defer", "dbInstances", ".", "FreeBuf", "(", "buf", ")", "\n", "iter", ":=", "dbInstances", ".", "NewIterator", "(", "CompareNodeTa...
// MemoryInUse returns total memory used by nodetables in a process
[ "MemoryInUse", "returns", "total", "memory", "used", "by", "nodetables", "in", "a", "process" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nodetable/table.go#L286-L296
test
t3rm1n4l/nitro
skiplist/node_alloc_amd64.go
debugMarkFree
func debugMarkFree(n *Node) { var block []byte l := int(nodeTypes[n.level].Size()) sh := (*reflect.SliceHeader)(unsafe.Pointer(&block)) sh.Data = uintptr(unsafe.Pointer(n)) sh.Len = l sh.Cap = l copy(block, freeBlockContent) }
go
func debugMarkFree(n *Node) { var block []byte l := int(nodeTypes[n.level].Size()) sh := (*reflect.SliceHeader)(unsafe.Pointer(&block)) sh.Data = uintptr(unsafe.Pointer(n)) sh.Len = l sh.Cap = l copy(block, freeBlockContent) }
[ "func", "debugMarkFree", "(", "n", "*", "Node", ")", "{", "var", "block", "[", "]", "byte", "\n", "l", ":=", "int", "(", "nodeTypes", "[", "n", ".", "level", "]", ".", "Size", "(", ")", ")", "\n", "sh", ":=", "(", "*", "reflect", ".", "SliceHea...
// Fill free blocks with a const // This can help debugging of memory reclaimer bugs
[ "Fill", "free", "blocks", "with", "a", "const", "This", "can", "help", "debugging", "of", "memory", "reclaimer", "bugs" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/node_alloc_amd64.go#L276-L285
test
t3rm1n4l/nitro
iterator.go
Seek
func (it *Iterator) Seek(bs []byte) { itm := it.snap.db.newItem(bs, false) it.iter.Seek(unsafe.Pointer(itm)) it.skipUnwanted() }
go
func (it *Iterator) Seek(bs []byte) { itm := it.snap.db.newItem(bs, false) it.iter.Seek(unsafe.Pointer(itm)) it.skipUnwanted() }
[ "func", "(", "it", "*", "Iterator", ")", "Seek", "(", "bs", "[", "]", "byte", ")", "{", "itm", ":=", "it", ".", "snap", ".", "db", ".", "newItem", "(", "bs", ",", "false", ")", "\n", "it", ".", "iter", ".", "Seek", "(", "unsafe", ".", "Pointe...
// Seek to a specified key or the next bigger one if an item with key does not // exist.
[ "Seek", "to", "a", "specified", "key", "or", "the", "next", "bigger", "one", "if", "an", "item", "with", "key", "does", "not", "exist", "." ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/iterator.go#L48-L52
test
t3rm1n4l/nitro
iterator.go
Next
func (it *Iterator) Next() { it.iter.Next() it.count++ it.skipUnwanted() if it.refreshRate > 0 && it.count > it.refreshRate { it.Refresh() it.count = 0 } }
go
func (it *Iterator) Next() { it.iter.Next() it.count++ it.skipUnwanted() if it.refreshRate > 0 && it.count > it.refreshRate { it.Refresh() it.count = 0 } }
[ "func", "(", "it", "*", "Iterator", ")", "Next", "(", ")", "{", "it", ".", "iter", ".", "Next", "(", ")", "\n", "it", ".", "count", "++", "\n", "it", ".", "skipUnwanted", "(", ")", "\n", "if", "it", ".", "refreshRate", ">", "0", "&&", "it", "...
// Next moves iterator cursor to the next item
[ "Next", "moves", "iterator", "cursor", "to", "the", "next", "item" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/iterator.go#L70-L78
test
t3rm1n4l/nitro
iterator.go
Refresh
func (it *Iterator) Refresh() { if it.Valid() { itm := it.snap.db.ptrToItem(it.GetNode().Item()) it.iter.Close() it.iter = it.snap.db.store.NewIterator(it.snap.db.iterCmp, it.buf) it.iter.Seek(unsafe.Pointer(itm)) } }
go
func (it *Iterator) Refresh() { if it.Valid() { itm := it.snap.db.ptrToItem(it.GetNode().Item()) it.iter.Close() it.iter = it.snap.db.store.NewIterator(it.snap.db.iterCmp, it.buf) it.iter.Seek(unsafe.Pointer(itm)) } }
[ "func", "(", "it", "*", "Iterator", ")", "Refresh", "(", ")", "{", "if", "it", ".", "Valid", "(", ")", "{", "itm", ":=", "it", ".", "snap", ".", "db", ".", "ptrToItem", "(", "it", ".", "GetNode", "(", ")", ".", "Item", "(", ")", ")", "\n", ...
// Refresh is a helper API to call refresh accessor tokens manually // This would enable SMR to reclaim objects faster if an iterator is // alive for a longer duration of time.
[ "Refresh", "is", "a", "helper", "API", "to", "call", "refresh", "accessor", "tokens", "manually", "This", "would", "enable", "SMR", "to", "reclaim", "objects", "faster", "if", "an", "iterator", "is", "alive", "for", "a", "longer", "duration", "of", "time", ...
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/iterator.go#L83-L90
test
t3rm1n4l/nitro
iterator.go
Close
func (it *Iterator) Close() { it.snap.Close() it.snap.db.store.FreeBuf(it.buf) it.iter.Close() }
go
func (it *Iterator) Close() { it.snap.Close() it.snap.db.store.FreeBuf(it.buf) it.iter.Close() }
[ "func", "(", "it", "*", "Iterator", ")", "Close", "(", ")", "{", "it", ".", "snap", ".", "Close", "(", ")", "\n", "it", ".", "snap", ".", "db", ".", "store", ".", "FreeBuf", "(", "it", ".", "buf", ")", "\n", "it", ".", "iter", ".", "Close", ...
// Close executes destructor for iterator
[ "Close", "executes", "destructor", "for", "iterator" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/iterator.go#L100-L104
test
t3rm1n4l/nitro
iterator.go
NewIterator
func (m *Nitro) NewIterator(snap *Snapshot) *Iterator { if !snap.Open() { return nil } buf := snap.db.store.MakeBuf() return &Iterator{ snap: snap, iter: m.store.NewIterator(m.iterCmp, buf), buf: buf, } }
go
func (m *Nitro) NewIterator(snap *Snapshot) *Iterator { if !snap.Open() { return nil } buf := snap.db.store.MakeBuf() return &Iterator{ snap: snap, iter: m.store.NewIterator(m.iterCmp, buf), buf: buf, } }
[ "func", "(", "m", "*", "Nitro", ")", "NewIterator", "(", "snap", "*", "Snapshot", ")", "*", "Iterator", "{", "if", "!", "snap", ".", "Open", "(", ")", "{", "return", "nil", "\n", "}", "\n", "buf", ":=", "snap", ".", "db", ".", "store", ".", "Ma...
// NewIterator creates an iterator for a Nitro snapshot
[ "NewIterator", "creates", "an", "iterator", "for", "a", "Nitro", "snapshot" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/iterator.go#L107-L117
test
t3rm1n4l/nitro
skiplist/merger.go
SeekFirst
func (mit *MergeIterator) SeekFirst() { for _, it := range mit.iters { it.SeekFirst() if it.Valid() { n := it.GetNode() mit.h = append(mit.h, heapItem{iter: it, n: n}) } } heap.Init(&mit.h) mit.Next() }
go
func (mit *MergeIterator) SeekFirst() { for _, it := range mit.iters { it.SeekFirst() if it.Valid() { n := it.GetNode() mit.h = append(mit.h, heapItem{iter: it, n: n}) } } heap.Init(&mit.h) mit.Next() }
[ "func", "(", "mit", "*", "MergeIterator", ")", "SeekFirst", "(", ")", "{", "for", "_", ",", "it", ":=", "range", "mit", ".", "iters", "{", "it", ".", "SeekFirst", "(", ")", "\n", "if", "it", ".", "Valid", "(", ")", "{", "n", ":=", "it", ".", ...
// SeekFirst moves cursor to the first item
[ "SeekFirst", "moves", "cursor", "to", "the", "first", "item" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/merger.go#L53-L64
test
t3rm1n4l/nitro
skiplist/merger.go
Next
func (mit *MergeIterator) Next() { mit.curr = nil if mit.h.Len() == 0 { return } o := heap.Pop(&mit.h) hi := o.(heapItem) mit.curr = hi.n hi.iter.Next() if hi.iter.Valid() { hi.n = hi.iter.GetNode() heap.Push(&mit.h, hi) } }
go
func (mit *MergeIterator) Next() { mit.curr = nil if mit.h.Len() == 0 { return } o := heap.Pop(&mit.h) hi := o.(heapItem) mit.curr = hi.n hi.iter.Next() if hi.iter.Valid() { hi.n = hi.iter.GetNode() heap.Push(&mit.h, hi) } }
[ "func", "(", "mit", "*", "MergeIterator", ")", "Next", "(", ")", "{", "mit", ".", "curr", "=", "nil", "\n", "if", "mit", ".", "h", ".", "Len", "(", ")", "==", "0", "{", "return", "\n", "}", "\n", "o", ":=", "heap", ".", "Pop", "(", "&", "mi...
// Next moves cursor to the next item
[ "Next", "moves", "cursor", "to", "the", "next", "item" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/merger.go#L72-L86
test
t3rm1n4l/nitro
skiplist/merger.go
Seek
func (mit *MergeIterator) Seek(itm unsafe.Pointer) bool { var found bool for _, it := range mit.iters { if it.Seek(itm) { found = true } if it.Valid() { n := it.GetNode() mit.h = append(mit.h, heapItem{iter: it, n: n}) } } heap.Init(&mit.h) mit.Next() return found }
go
func (mit *MergeIterator) Seek(itm unsafe.Pointer) bool { var found bool for _, it := range mit.iters { if it.Seek(itm) { found = true } if it.Valid() { n := it.GetNode() mit.h = append(mit.h, heapItem{iter: it, n: n}) } } heap.Init(&mit.h) mit.Next() return found }
[ "func", "(", "mit", "*", "MergeIterator", ")", "Seek", "(", "itm", "unsafe", ".", "Pointer", ")", "bool", "{", "var", "found", "bool", "\n", "for", "_", ",", "it", ":=", "range", "mit", ".", "iters", "{", "if", "it", ".", "Seek", "(", "itm", ")",...
// Seek moves cursor to the specified item, if present
[ "Seek", "moves", "cursor", "to", "the", "specified", "item", "if", "present" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/merger.go#L89-L105
test
t3rm1n4l/nitro
nodelist.go
Keys
func (l *NodeList) Keys() (keys [][]byte) { node := l.head for node != nil { key := (*Item)(node.Item()).Bytes() keys = append(keys, key) node = node.GetLink() } return }
go
func (l *NodeList) Keys() (keys [][]byte) { node := l.head for node != nil { key := (*Item)(node.Item()).Bytes() keys = append(keys, key) node = node.GetLink() } return }
[ "func", "(", "l", "*", "NodeList", ")", "Keys", "(", ")", "(", "keys", "[", "]", "[", "]", "byte", ")", "{", "node", ":=", "l", ".", "head", "\n", "for", "node", "!=", "nil", "{", "key", ":=", "(", "*", "Item", ")", "(", "node", ".", "Item"...
// Keys returns all keys from the node list
[ "Keys", "returns", "all", "keys", "from", "the", "node", "list" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nodelist.go#L30-L39
test
t3rm1n4l/nitro
nodelist.go
Remove
func (l *NodeList) Remove(key []byte) *skiplist.Node { var prev *skiplist.Node node := l.head for node != nil { nodeKey := (*Item)(node.Item()).Bytes() if bytes.Equal(nodeKey, key) { if prev == nil { l.head = node.GetLink() return node } prev.SetLink(node.GetLink()) return node } prev = ...
go
func (l *NodeList) Remove(key []byte) *skiplist.Node { var prev *skiplist.Node node := l.head for node != nil { nodeKey := (*Item)(node.Item()).Bytes() if bytes.Equal(nodeKey, key) { if prev == nil { l.head = node.GetLink() return node } prev.SetLink(node.GetLink()) return node } prev = ...
[ "func", "(", "l", "*", "NodeList", ")", "Remove", "(", "key", "[", "]", "byte", ")", "*", "skiplist", ".", "Node", "{", "var", "prev", "*", "skiplist", ".", "Node", "\n", "node", ":=", "l", ".", "head", "\n", "for", "node", "!=", "nil", "{", "n...
// Remove a key from the node list
[ "Remove", "a", "key", "from", "the", "node", "list" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nodelist.go#L42-L61
test
t3rm1n4l/nitro
nodelist.go
Add
func (l *NodeList) Add(node *skiplist.Node) { node.SetLink(l.head) l.head = node }
go
func (l *NodeList) Add(node *skiplist.Node) { node.SetLink(l.head) l.head = node }
[ "func", "(", "l", "*", "NodeList", ")", "Add", "(", "node", "*", "skiplist", ".", "Node", ")", "{", "node", ".", "SetLink", "(", "l", ".", "head", ")", "\n", "l", ".", "head", "=", "node", "\n", "}" ]
// Add a key into the node list
[ "Add", "a", "key", "into", "the", "node", "list" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nodelist.go#L64-L67
test
t3rm1n4l/nitro
skiplist/skiplist.go
NewWithConfig
func NewWithConfig(cfg Config) *Skiplist { if runtime.GOARCH != "amd64" { cfg.UseMemoryMgmt = false } s := &Skiplist{ Config: cfg, barrier: newAccessBarrier(cfg.UseMemoryMgmt, cfg.BarrierDestructor), } s.newNode = func(itm unsafe.Pointer, level int) *Node { return allocNode(itm, level, cfg.Malloc) } ...
go
func NewWithConfig(cfg Config) *Skiplist { if runtime.GOARCH != "amd64" { cfg.UseMemoryMgmt = false } s := &Skiplist{ Config: cfg, barrier: newAccessBarrier(cfg.UseMemoryMgmt, cfg.BarrierDestructor), } s.newNode = func(itm unsafe.Pointer, level int) *Node { return allocNode(itm, level, cfg.Malloc) } ...
[ "func", "NewWithConfig", "(", "cfg", "Config", ")", "*", "Skiplist", "{", "if", "runtime", ".", "GOARCH", "!=", "\"amd64\"", "{", "cfg", ".", "UseMemoryMgmt", "=", "false", "\n", "}", "\n", "s", ":=", "&", "Skiplist", "{", "Config", ":", "cfg", ",", ...
// NewWithConfig creates a config from given config
[ "NewWithConfig", "creates", "a", "config", "from", "given", "config" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/skiplist.go#L85-L121
test
t3rm1n4l/nitro
skiplist/skiplist.go
FreeNode
func (s *Skiplist) FreeNode(n *Node, sts *Stats) { s.freeNode(n) sts.AddInt64(&sts.nodeFrees, 1) }
go
func (s *Skiplist) FreeNode(n *Node, sts *Stats) { s.freeNode(n) sts.AddInt64(&sts.nodeFrees, 1) }
[ "func", "(", "s", "*", "Skiplist", ")", "FreeNode", "(", "n", "*", "Node", ",", "sts", "*", "Stats", ")", "{", "s", ".", "freeNode", "(", "n", ")", "\n", "sts", ".", "AddInt64", "(", "&", "sts", ".", "nodeFrees", ",", "1", ")", "\n", "}" ]
// FreeNode deallocates the skiplist node memory
[ "FreeNode", "deallocates", "the", "skiplist", "node", "memory" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/skiplist.go#L129-L132
test
t3rm1n4l/nitro
skiplist/skiplist.go
MakeBuf
func (s *Skiplist) MakeBuf() *ActionBuffer { return &ActionBuffer{ preds: make([]*Node, MaxLevel+1), succs: make([]*Node, MaxLevel+1), } }
go
func (s *Skiplist) MakeBuf() *ActionBuffer { return &ActionBuffer{ preds: make([]*Node, MaxLevel+1), succs: make([]*Node, MaxLevel+1), } }
[ "func", "(", "s", "*", "Skiplist", ")", "MakeBuf", "(", ")", "*", "ActionBuffer", "{", "return", "&", "ActionBuffer", "{", "preds", ":", "make", "(", "[", "]", "*", "Node", ",", "MaxLevel", "+", "1", ")", ",", "succs", ":", "make", "(", "[", "]",...
// MakeBuf creates an action buffer
[ "MakeBuf", "creates", "an", "action", "buffer" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/skiplist.go#L141-L146
test
t3rm1n4l/nitro
skiplist/skiplist.go
Size
func (s *Skiplist) Size(n *Node) int { return s.ItemSize(n.Item()) + n.Size() }
go
func (s *Skiplist) Size(n *Node) int { return s.ItemSize(n.Item()) + n.Size() }
[ "func", "(", "s", "*", "Skiplist", ")", "Size", "(", "n", "*", "Node", ")", "int", "{", "return", "s", ".", "ItemSize", "(", "n", ".", "Item", "(", ")", ")", "+", "n", ".", "Size", "(", ")", "\n", "}" ]
// Size returns the size of a node
[ "Size", "returns", "the", "size", "of", "a", "node" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/skiplist.go#L153-L155
test
t3rm1n4l/nitro
skiplist/skiplist.go
NewLevel
func (s *Skiplist) NewLevel(randFn func() float32) int { var nextLevel int for ; randFn() < p; nextLevel++ { } if nextLevel > MaxLevel { nextLevel = MaxLevel } level := int(atomic.LoadInt32(&s.level)) if nextLevel > level { if atomic.CompareAndSwapInt32(&s.level, int32(level), int32(level+1)) { nextLev...
go
func (s *Skiplist) NewLevel(randFn func() float32) int { var nextLevel int for ; randFn() < p; nextLevel++ { } if nextLevel > MaxLevel { nextLevel = MaxLevel } level := int(atomic.LoadInt32(&s.level)) if nextLevel > level { if atomic.CompareAndSwapInt32(&s.level, int32(level), int32(level+1)) { nextLev...
[ "func", "(", "s", "*", "Skiplist", ")", "NewLevel", "(", "randFn", "func", "(", ")", "float32", ")", "int", "{", "var", "nextLevel", "int", "\n", "for", ";", "randFn", "(", ")", "<", "p", ";", "nextLevel", "++", "{", "}", "\n", "if", "nextLevel", ...
// NewLevel returns a random level for the next node
[ "NewLevel", "returns", "a", "random", "level", "for", "the", "next", "node" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/skiplist.go#L158-L178
test
t3rm1n4l/nitro
skiplist/skiplist.go
Insert
func (s *Skiplist) Insert(itm unsafe.Pointer, cmp CompareFn, buf *ActionBuffer, sts *Stats) (success bool) { _, success = s.Insert2(itm, cmp, nil, buf, rand.Float32, sts) return }
go
func (s *Skiplist) Insert(itm unsafe.Pointer, cmp CompareFn, buf *ActionBuffer, sts *Stats) (success bool) { _, success = s.Insert2(itm, cmp, nil, buf, rand.Float32, sts) return }
[ "func", "(", "s", "*", "Skiplist", ")", "Insert", "(", "itm", "unsafe", ".", "Pointer", ",", "cmp", "CompareFn", ",", "buf", "*", "ActionBuffer", ",", "sts", "*", "Stats", ")", "(", "success", "bool", ")", "{", "_", ",", "success", "=", "s", ".", ...
// Insert adds an item into the skiplist
[ "Insert", "adds", "an", "item", "into", "the", "skiplist" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/skiplist.go#L232-L236
test
t3rm1n4l/nitro
skiplist/skiplist.go
Insert2
func (s *Skiplist) Insert2(itm unsafe.Pointer, inscmp CompareFn, eqCmp CompareFn, buf *ActionBuffer, randFn func() float32, sts *Stats) (*Node, bool) { itemLevel := s.NewLevel(randFn) return s.Insert3(itm, inscmp, eqCmp, buf, itemLevel, false, sts) }
go
func (s *Skiplist) Insert2(itm unsafe.Pointer, inscmp CompareFn, eqCmp CompareFn, buf *ActionBuffer, randFn func() float32, sts *Stats) (*Node, bool) { itemLevel := s.NewLevel(randFn) return s.Insert3(itm, inscmp, eqCmp, buf, itemLevel, false, sts) }
[ "func", "(", "s", "*", "Skiplist", ")", "Insert2", "(", "itm", "unsafe", ".", "Pointer", ",", "inscmp", "CompareFn", ",", "eqCmp", "CompareFn", ",", "buf", "*", "ActionBuffer", ",", "randFn", "func", "(", ")", "float32", ",", "sts", "*", "Stats", ")", ...
// Insert2 is a more verbose version of Insert
[ "Insert2", "is", "a", "more", "verbose", "version", "of", "Insert" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/skiplist.go#L239-L243
test
t3rm1n4l/nitro
skiplist/skiplist.go
Insert3
func (s *Skiplist) Insert3(itm unsafe.Pointer, insCmp CompareFn, eqCmp CompareFn, buf *ActionBuffer, itemLevel int, skipFindPath bool, sts *Stats) (*Node, bool) { token := s.barrier.Acquire() defer s.barrier.Release(token) x := s.newNode(itm, itemLevel) retry: if skipFindPath { skipFindPath = false } else { ...
go
func (s *Skiplist) Insert3(itm unsafe.Pointer, insCmp CompareFn, eqCmp CompareFn, buf *ActionBuffer, itemLevel int, skipFindPath bool, sts *Stats) (*Node, bool) { token := s.barrier.Acquire() defer s.barrier.Release(token) x := s.newNode(itm, itemLevel) retry: if skipFindPath { skipFindPath = false } else { ...
[ "func", "(", "s", "*", "Skiplist", ")", "Insert3", "(", "itm", "unsafe", ".", "Pointer", ",", "insCmp", "CompareFn", ",", "eqCmp", "CompareFn", ",", "buf", "*", "ActionBuffer", ",", "itemLevel", "int", ",", "skipFindPath", "bool", ",", "sts", "*", "Stats...
// Insert3 is more verbose version of Insert2
[ "Insert3", "is", "more", "verbose", "version", "of", "Insert2" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/skiplist.go#L246-L304
test
t3rm1n4l/nitro
skiplist/skiplist.go
Delete
func (s *Skiplist) Delete(itm unsafe.Pointer, cmp CompareFn, buf *ActionBuffer, sts *Stats) bool { token := s.barrier.Acquire() defer s.barrier.Release(token) found := s.findPath(itm, cmp, buf, sts) != nil if !found { return false } delNode := buf.succs[0] return s.deleteNode(delNode, cmp, buf, sts) }
go
func (s *Skiplist) Delete(itm unsafe.Pointer, cmp CompareFn, buf *ActionBuffer, sts *Stats) bool { token := s.barrier.Acquire() defer s.barrier.Release(token) found := s.findPath(itm, cmp, buf, sts) != nil if !found { return false } delNode := buf.succs[0] return s.deleteNode(delNode, cmp, buf, sts) }
[ "func", "(", "s", "*", "Skiplist", ")", "Delete", "(", "itm", "unsafe", ".", "Pointer", ",", "cmp", "CompareFn", ",", "buf", "*", "ActionBuffer", ",", "sts", "*", "Stats", ")", "bool", "{", "token", ":=", "s", ".", "barrier", ".", "Acquire", "(", "...
// Delete an item from the skiplist
[ "Delete", "an", "item", "from", "the", "skiplist" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/skiplist.go#L324-L336
test
t3rm1n4l/nitro
skiplist/skiplist.go
DeleteNode
func (s *Skiplist) DeleteNode(n *Node, cmp CompareFn, buf *ActionBuffer, sts *Stats) bool { token := s.barrier.Acquire() defer s.barrier.Release(token) return s.deleteNode(n, cmp, buf, sts) }
go
func (s *Skiplist) DeleteNode(n *Node, cmp CompareFn, buf *ActionBuffer, sts *Stats) bool { token := s.barrier.Acquire() defer s.barrier.Release(token) return s.deleteNode(n, cmp, buf, sts) }
[ "func", "(", "s", "*", "Skiplist", ")", "DeleteNode", "(", "n", "*", "Node", ",", "cmp", "CompareFn", ",", "buf", "*", "ActionBuffer", ",", "sts", "*", "Stats", ")", "bool", "{", "token", ":=", "s", ".", "barrier", ".", "Acquire", "(", ")", "\n", ...
// DeleteNode an item from the skiplist by specifying its node
[ "DeleteNode", "an", "item", "from", "the", "skiplist", "by", "specifying", "its", "node" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/skiplist.go#L339-L345
test
t3rm1n4l/nitro
skiplist/skiplist.go
GetRangeSplitItems
func (s *Skiplist) GetRangeSplitItems(nways int) []unsafe.Pointer { var deleted bool repeat: var itms []unsafe.Pointer var finished bool l := int(atomic.LoadInt32(&s.level)) for ; l >= 0; l-- { c := int(atomic.LoadInt64(&s.Stats.levelNodesCount[l]) + 1) if c >= nways { perSplit := c / nways node := s.he...
go
func (s *Skiplist) GetRangeSplitItems(nways int) []unsafe.Pointer { var deleted bool repeat: var itms []unsafe.Pointer var finished bool l := int(atomic.LoadInt32(&s.level)) for ; l >= 0; l-- { c := int(atomic.LoadInt64(&s.Stats.levelNodesCount[l]) + 1) if c >= nways { perSplit := c / nways node := s.he...
[ "func", "(", "s", "*", "Skiplist", ")", "GetRangeSplitItems", "(", "nways", "int", ")", "[", "]", "unsafe", ".", "Pointer", "{", "var", "deleted", "bool", "\n", "repeat", ":", "var", "itms", "[", "]", "unsafe", ".", "Pointer", "\n", "var", "finished", ...
// GetRangeSplitItems returns `nways` split range pivots of the skiplist items // Explicit barrier and release should be used by the caller before // and after this function call
[ "GetRangeSplitItems", "returns", "nways", "split", "range", "pivots", "of", "the", "skiplist", "items", "Explicit", "barrier", "and", "release", "should", "be", "used", "by", "the", "caller", "before", "and", "after", "this", "function", "call" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/skiplist.go#L360-L390
test
t3rm1n4l/nitro
item.go
Bytes
func (itm *Item) Bytes() (bs []byte) { l := itm.dataLen dataOffset := uintptr(unsafe.Pointer(itm)) + itemHeaderSize hdr := (*reflect.SliceHeader)(unsafe.Pointer(&bs)) hdr.Data = dataOffset hdr.Len = int(l) hdr.Cap = hdr.Len return }
go
func (itm *Item) Bytes() (bs []byte) { l := itm.dataLen dataOffset := uintptr(unsafe.Pointer(itm)) + itemHeaderSize hdr := (*reflect.SliceHeader)(unsafe.Pointer(&bs)) hdr.Data = dataOffset hdr.Len = int(l) hdr.Cap = hdr.Len return }
[ "func", "(", "itm", "*", "Item", ")", "Bytes", "(", ")", "(", "bs", "[", "]", "byte", ")", "{", "l", ":=", "itm", ".", "dataLen", "\n", "dataOffset", ":=", "uintptr", "(", "unsafe", ".", "Pointer", "(", "itm", ")", ")", "+", "itemHeaderSize", "\n...
// Bytes return item data bytes
[ "Bytes", "return", "item", "data", "bytes" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/item.go#L96-L105
test
t3rm1n4l/nitro
item.go
ItemSize
func ItemSize(p unsafe.Pointer) int { itm := (*Item)(p) return int(itemHeaderSize + uintptr(itm.dataLen)) }
go
func ItemSize(p unsafe.Pointer) int { itm := (*Item)(p) return int(itemHeaderSize + uintptr(itm.dataLen)) }
[ "func", "ItemSize", "(", "p", "unsafe", ".", "Pointer", ")", "int", "{", "itm", ":=", "(", "*", "Item", ")", "(", "p", ")", "\n", "return", "int", "(", "itemHeaderSize", "+", "uintptr", "(", "itm", ".", "dataLen", ")", ")", "\n", "}" ]
// ItemSize returns total bytes consumed by item representation
[ "ItemSize", "returns", "total", "bytes", "consumed", "by", "item", "representation" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/item.go#L108-L111
test
t3rm1n4l/nitro
item.go
KVFromBytes
func KVFromBytes(bs []byte) (k, v []byte) { klen := int(binary.LittleEndian.Uint16(bs[0:2])) return bs[2 : 2+klen], bs[2+klen:] }
go
func KVFromBytes(bs []byte) (k, v []byte) { klen := int(binary.LittleEndian.Uint16(bs[0:2])) return bs[2 : 2+klen], bs[2+klen:] }
[ "func", "KVFromBytes", "(", "bs", "[", "]", "byte", ")", "(", "k", ",", "v", "[", "]", "byte", ")", "{", "klen", ":=", "int", "(", "binary", ".", "LittleEndian", ".", "Uint16", "(", "bs", "[", "0", ":", "2", "]", ")", ")", "\n", "return", "bs...
// KVFromBytes extracts key-value pair from item bytes returned by iterator
[ "KVFromBytes", "extracts", "key", "-", "value", "pair", "from", "item", "bytes", "returned", "by", "iterator" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/item.go#L126-L129
test
t3rm1n4l/nitro
item.go
CompareKV
func CompareKV(a []byte, b []byte) int { la := int(binary.LittleEndian.Uint16(a[0:2])) lb := int(binary.LittleEndian.Uint16(b[0:2])) return bytes.Compare(a[2:2+la], b[2:2+lb]) }
go
func CompareKV(a []byte, b []byte) int { la := int(binary.LittleEndian.Uint16(a[0:2])) lb := int(binary.LittleEndian.Uint16(b[0:2])) return bytes.Compare(a[2:2+la], b[2:2+lb]) }
[ "func", "CompareKV", "(", "a", "[", "]", "byte", ",", "b", "[", "]", "byte", ")", "int", "{", "la", ":=", "int", "(", "binary", ".", "LittleEndian", ".", "Uint16", "(", "a", "[", "0", ":", "2", "]", ")", ")", "\n", "lb", ":=", "int", "(", "...
// CompareKV is a comparator for KV item
[ "CompareKV", "is", "a", "comparator", "for", "KV", "item" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/item.go#L132-L137
test
intelsdi-x/gomit
event_controller.go
Emit
func (e *EventController) Emit(b EventBody) (int, error) { // int used to count the number of Handlers fired. var i int // We build an event struct to contain the Body and generate a Header. event := Event{Header: generateHeader(), Body: b} // Fire a gorountine for each handler. // By design the is no waiting fo...
go
func (e *EventController) Emit(b EventBody) (int, error) { // int used to count the number of Handlers fired. var i int // We build an event struct to contain the Body and generate a Header. event := Event{Header: generateHeader(), Body: b} // Fire a gorountine for each handler. // By design the is no waiting fo...
[ "func", "(", "e", "*", "EventController", ")", "Emit", "(", "b", "EventBody", ")", "(", "int", ",", "error", ")", "{", "var", "i", "int", "\n", "event", ":=", "Event", "{", "Header", ":", "generateHeader", "(", ")", ",", "Body", ":", "b", "}", "\...
// Emits an Event from the EventController. Takes an EventBody which is used // to build an Event. Returns number of handlers that // received the event and error if an error was raised.
[ "Emits", "an", "Event", "from", "the", "EventController", ".", "Takes", "an", "EventBody", "which", "is", "used", "to", "build", "an", "Event", ".", "Returns", "number", "of", "handlers", "that", "received", "the", "event", "and", "error", "if", "an", "err...
286c3ad6599724faed681cd18a9ff595b00d9f3f
https://github.com/intelsdi-x/gomit/blob/286c3ad6599724faed681cd18a9ff595b00d9f3f/event_controller.go#L66-L84
test
intelsdi-x/gomit
event_controller.go
UnregisterHandler
func (e *EventController) UnregisterHandler(n string) error { e.handlerMutex.Lock() delete(e.Handlers, n) e.handlerMutex.Unlock() return nil }
go
func (e *EventController) UnregisterHandler(n string) error { e.handlerMutex.Lock() delete(e.Handlers, n) e.handlerMutex.Unlock() return nil }
[ "func", "(", "e", "*", "EventController", ")", "UnregisterHandler", "(", "n", "string", ")", "error", "{", "e", ".", "handlerMutex", ".", "Lock", "(", ")", "\n", "delete", "(", "e", ".", "Handlers", ",", "n", ")", "\n", "e", ".", "handlerMutex", ".",...
// Unregisters Handler from the EventController. This is idempotent where if a Handler is // not registered no error is returned.
[ "Unregisters", "Handler", "from", "the", "EventController", ".", "This", "is", "idempotent", "where", "if", "a", "Handler", "is", "not", "registered", "no", "error", "is", "returned", "." ]
286c3ad6599724faed681cd18a9ff595b00d9f3f
https://github.com/intelsdi-x/gomit/blob/286c3ad6599724faed681cd18a9ff595b00d9f3f/event_controller.go#L104-L111
test
intelsdi-x/gomit
event_controller.go
IsHandlerRegistered
func (e *EventController) IsHandlerRegistered(n string) bool { _, x := e.Handlers[n] return x }
go
func (e *EventController) IsHandlerRegistered(n string) bool { _, x := e.Handlers[n] return x }
[ "func", "(", "e", "*", "EventController", ")", "IsHandlerRegistered", "(", "n", "string", ")", "bool", "{", "_", ",", "x", ":=", "e", ".", "Handlers", "[", "n", "]", "\n", "return", "x", "\n", "}" ]
// Returns bool on whether the Handler is registered with this EventController.
[ "Returns", "bool", "on", "whether", "the", "Handler", "is", "registered", "with", "this", "EventController", "." ]
286c3ad6599724faed681cd18a9ff595b00d9f3f
https://github.com/intelsdi-x/gomit/blob/286c3ad6599724faed681cd18a9ff595b00d9f3f/event_controller.go#L114-L117
test
t3rm1n4l/nitro
nitro.go
CompareNitro
func CompareNitro(this unsafe.Pointer, that unsafe.Pointer) int { thisItem := (*Nitro)(this) thatItem := (*Nitro)(that) return int(thisItem.id - thatItem.id) }
go
func CompareNitro(this unsafe.Pointer, that unsafe.Pointer) int { thisItem := (*Nitro)(this) thatItem := (*Nitro)(that) return int(thisItem.id - thatItem.id) }
[ "func", "CompareNitro", "(", "this", "unsafe", ".", "Pointer", ",", "that", "unsafe", ".", "Pointer", ")", "int", "{", "thisItem", ":=", "(", "*", "Nitro", ")", "(", "this", ")", "\n", "thatItem", ":=", "(", "*", "Nitro", ")", "(", "that", ")", "\n...
// CompareNitro implements comparator for Nitro instances based on its id
[ "CompareNitro", "implements", "comparator", "for", "Nitro", "instances", "based", "on", "its", "id" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L79-L84
test
t3rm1n4l/nitro
nitro.go
DefaultConfig
func DefaultConfig() Config { var cfg Config cfg.SetKeyComparator(defaultKeyCmp) cfg.fileType = RawdbFile cfg.useMemoryMgmt = false cfg.refreshRate = defaultRefreshRate return cfg }
go
func DefaultConfig() Config { var cfg Config cfg.SetKeyComparator(defaultKeyCmp) cfg.fileType = RawdbFile cfg.useMemoryMgmt = false cfg.refreshRate = defaultRefreshRate return cfg }
[ "func", "DefaultConfig", "(", ")", "Config", "{", "var", "cfg", "Config", "\n", "cfg", ".", "SetKeyComparator", "(", "defaultKeyCmp", ")", "\n", "cfg", ".", "fileType", "=", "RawdbFile", "\n", "cfg", ".", "useMemoryMgmt", "=", "false", "\n", "cfg", ".", ...
// DefaultConfig - Nitro configuration
[ "DefaultConfig", "-", "Nitro", "configuration" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L87-L94
test
t3rm1n4l/nitro
nitro.go
Delete
func (w *Writer) Delete(bs []byte) (success bool) { _, success = w.Delete2(bs) return }
go
func (w *Writer) Delete(bs []byte) (success bool) { _, success = w.Delete2(bs) return }
[ "func", "(", "w", "*", "Writer", ")", "Delete", "(", "bs", "[", "]", "byte", ")", "(", "success", "bool", ")", "{", "_", ",", "success", "=", "w", ".", "Delete2", "(", "bs", ")", "\n", "return", "\n", "}" ]
// Delete an item // Delete always succeed if an item exists.
[ "Delete", "an", "item", "Delete", "always", "succeed", "if", "an", "item", "exists", "." ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L220-L223
test
t3rm1n4l/nitro
nitro.go
GetNode
func (w *Writer) GetNode(bs []byte) *skiplist.Node { iter := w.store.NewIterator(w.iterCmp, w.buf) defer iter.Close() x := w.newItem(bs, false) x.bornSn = w.getCurrSn() if found := iter.SeekWithCmp(unsafe.Pointer(x), w.insCmp, w.existCmp); found { return iter.GetNode() } return nil }
go
func (w *Writer) GetNode(bs []byte) *skiplist.Node { iter := w.store.NewIterator(w.iterCmp, w.buf) defer iter.Close() x := w.newItem(bs, false) x.bornSn = w.getCurrSn() if found := iter.SeekWithCmp(unsafe.Pointer(x), w.insCmp, w.existCmp); found { return iter.GetNode() } return nil }
[ "func", "(", "w", "*", "Writer", ")", "GetNode", "(", "bs", "[", "]", "byte", ")", "*", "skiplist", ".", "Node", "{", "iter", ":=", "w", ".", "store", ".", "NewIterator", "(", "w", ".", "iterCmp", ",", "w", ".", "buf", ")", "\n", "defer", "iter...
// GetNode implements lookup of an item and return its skiplist Node // This API enables to lookup an item without using a snapshot handle.
[ "GetNode", "implements", "lookup", "of", "an", "item", "and", "return", "its", "skiplist", "Node", "This", "API", "enables", "to", "lookup", "an", "item", "without", "using", "a", "snapshot", "handle", "." ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L269-L281
test
t3rm1n4l/nitro
nitro.go
SetKeyComparator
func (cfg *Config) SetKeyComparator(cmp KeyCompare) { cfg.keyCmp = cmp cfg.insCmp = newInsertCompare(cmp) cfg.iterCmp = newIterCompare(cmp) cfg.existCmp = newExistCompare(cmp) }
go
func (cfg *Config) SetKeyComparator(cmp KeyCompare) { cfg.keyCmp = cmp cfg.insCmp = newInsertCompare(cmp) cfg.iterCmp = newIterCompare(cmp) cfg.existCmp = newExistCompare(cmp) }
[ "func", "(", "cfg", "*", "Config", ")", "SetKeyComparator", "(", "cmp", "KeyCompare", ")", "{", "cfg", ".", "keyCmp", "=", "cmp", "\n", "cfg", ".", "insCmp", "=", "newInsertCompare", "(", "cmp", ")", "\n", "cfg", ".", "iterCmp", "=", "newIterCompare", ...
// SetKeyComparator provides key comparator for the Nitro item data
[ "SetKeyComparator", "provides", "key", "comparator", "for", "the", "Nitro", "item", "data" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L300-L305
test
t3rm1n4l/nitro
nitro.go
UseMemoryMgmt
func (cfg *Config) UseMemoryMgmt(malloc skiplist.MallocFn, free skiplist.FreeFn) { if runtime.GOARCH == "amd64" { cfg.useMemoryMgmt = true cfg.mallocFun = malloc cfg.freeFun = free } }
go
func (cfg *Config) UseMemoryMgmt(malloc skiplist.MallocFn, free skiplist.FreeFn) { if runtime.GOARCH == "amd64" { cfg.useMemoryMgmt = true cfg.mallocFun = malloc cfg.freeFun = free } }
[ "func", "(", "cfg", "*", "Config", ")", "UseMemoryMgmt", "(", "malloc", "skiplist", ".", "MallocFn", ",", "free", "skiplist", ".", "FreeFn", ")", "{", "if", "runtime", ".", "GOARCH", "==", "\"amd64\"", "{", "cfg", ".", "useMemoryMgmt", "=", "true", "\n",...
// UseMemoryMgmt provides custom memory allocator for Nitro items storage
[ "UseMemoryMgmt", "provides", "custom", "memory", "allocator", "for", "Nitro", "items", "storage" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L308-L314
test
t3rm1n4l/nitro
nitro.go
NewWithConfig
func NewWithConfig(cfg Config) *Nitro { m := &Nitro{ snapshots: skiplist.New(), gcsnapshots: skiplist.New(), currSn: 1, Config: cfg, gcchan: make(chan *skiplist.Node, gcchanBufSize), id: int(atomic.AddInt64(&dbInstancesCount, 1)), } m.freechan = make(chan *skiplist.Node, gcchan...
go
func NewWithConfig(cfg Config) *Nitro { m := &Nitro{ snapshots: skiplist.New(), gcsnapshots: skiplist.New(), currSn: 1, Config: cfg, gcchan: make(chan *skiplist.Node, gcchanBufSize), id: int(atomic.AddInt64(&dbInstancesCount, 1)), } m.freechan = make(chan *skiplist.Node, gcchan...
[ "func", "NewWithConfig", "(", "cfg", "Config", ")", "*", "Nitro", "{", "m", ":=", "&", "Nitro", "{", "snapshots", ":", "skiplist", ".", "New", "(", ")", ",", "gcsnapshots", ":", "skiplist", ".", "New", "(", ")", ",", "currSn", ":", "1", ",", "Confi...
// NewWithConfig creates a new Nitro instance based on provided configuration.
[ "NewWithConfig", "creates", "a", "new", "Nitro", "instance", "based", "on", "provided", "configuration", "." ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L354-L374
test
t3rm1n4l/nitro
nitro.go
MemoryInUse
func (m *Nitro) MemoryInUse() int64 { storeStats := m.aggrStoreStats() return storeStats.Memory + m.snapshots.MemoryInUse() + m.gcsnapshots.MemoryInUse() }
go
func (m *Nitro) MemoryInUse() int64 { storeStats := m.aggrStoreStats() return storeStats.Memory + m.snapshots.MemoryInUse() + m.gcsnapshots.MemoryInUse() }
[ "func", "(", "m", "*", "Nitro", ")", "MemoryInUse", "(", ")", "int64", "{", "storeStats", ":=", "m", ".", "aggrStoreStats", "(", ")", "\n", "return", "storeStats", ".", "Memory", "+", "m", ".", "snapshots", ".", "MemoryInUse", "(", ")", "+", "m", "."...
// MemoryInUse returns total memory used by the Nitro instance.
[ "MemoryInUse", "returns", "total", "memory", "used", "by", "the", "Nitro", "instance", "." ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L410-L413
test
t3rm1n4l/nitro
nitro.go
Close
func (m *Nitro) Close() { // Wait until all snapshot iterators have finished for s := m.snapshots.GetStats(); int(s.NodeCount) != 0; s = m.snapshots.GetStats() { time.Sleep(time.Millisecond) } m.hasShutdown = true // Acquire gc chan ownership // This will make sure that no other goroutine will write to gcchan...
go
func (m *Nitro) Close() { // Wait until all snapshot iterators have finished for s := m.snapshots.GetStats(); int(s.NodeCount) != 0; s = m.snapshots.GetStats() { time.Sleep(time.Millisecond) } m.hasShutdown = true // Acquire gc chan ownership // This will make sure that no other goroutine will write to gcchan...
[ "func", "(", "m", "*", "Nitro", ")", "Close", "(", ")", "{", "for", "s", ":=", "m", ".", "snapshots", ".", "GetStats", "(", ")", ";", "int", "(", "s", ".", "NodeCount", ")", "!=", "0", ";", "s", "=", "m", ".", "snapshots", ".", "GetStats", "(...
// Close shuts down the nitro instance
[ "Close", "shuts", "down", "the", "nitro", "instance" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L416-L465
test
t3rm1n4l/nitro
nitro.go
NewWriter
func (m *Nitro) NewWriter() *Writer { w := m.newWriter() w.next = m.wlist m.wlist = w w.dwrCtx.Init() m.shutdownWg1.Add(1) go m.collectionWorker(w) if m.useMemoryMgmt { m.shutdownWg2.Add(1) go m.freeWorker(w) } return w }
go
func (m *Nitro) NewWriter() *Writer { w := m.newWriter() w.next = m.wlist m.wlist = w w.dwrCtx.Init() m.shutdownWg1.Add(1) go m.collectionWorker(w) if m.useMemoryMgmt { m.shutdownWg2.Add(1) go m.freeWorker(w) } return w }
[ "func", "(", "m", "*", "Nitro", ")", "NewWriter", "(", ")", "*", "Writer", "{", "w", ":=", "m", ".", "newWriter", "(", ")", "\n", "w", ".", "next", "=", "m", ".", "wlist", "\n", "m", ".", "wlist", "=", "w", "\n", "w", ".", "dwrCtx", ".", "I...
// NewWriter creates a Nitro writer
[ "NewWriter", "creates", "a", "Nitro", "writer" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L485-L499
test
t3rm1n4l/nitro
nitro.go
SnapshotSize
func SnapshotSize(p unsafe.Pointer) int { s := (*Snapshot)(p) return int(unsafe.Sizeof(s.sn) + unsafe.Sizeof(s.refCount) + unsafe.Sizeof(s.db) + unsafe.Sizeof(s.count) + unsafe.Sizeof(s.gclist)) }
go
func SnapshotSize(p unsafe.Pointer) int { s := (*Snapshot)(p) return int(unsafe.Sizeof(s.sn) + unsafe.Sizeof(s.refCount) + unsafe.Sizeof(s.db) + unsafe.Sizeof(s.count) + unsafe.Sizeof(s.gclist)) }
[ "func", "SnapshotSize", "(", "p", "unsafe", ".", "Pointer", ")", "int", "{", "s", ":=", "(", "*", "Snapshot", ")", "(", "p", ")", "\n", "return", "int", "(", "unsafe", ".", "Sizeof", "(", "s", ".", "sn", ")", "+", "unsafe", ".", "Sizeof", "(", ...
// SnapshotSize returns the memory used by Nitro snapshot metadata
[ "SnapshotSize", "returns", "the", "memory", "used", "by", "Nitro", "snapshot", "metadata" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L512-L516
test
t3rm1n4l/nitro
nitro.go
Encode
func (s *Snapshot) Encode(buf []byte, w io.Writer) error { l := 4 if len(buf) < l { return errNotEnoughSpace } binary.BigEndian.PutUint32(buf[0:4], s.sn) if _, err := w.Write(buf[0:4]); err != nil { return err } return nil }
go
func (s *Snapshot) Encode(buf []byte, w io.Writer) error { l := 4 if len(buf) < l { return errNotEnoughSpace } binary.BigEndian.PutUint32(buf[0:4], s.sn) if _, err := w.Write(buf[0:4]); err != nil { return err } return nil }
[ "func", "(", "s", "*", "Snapshot", ")", "Encode", "(", "buf", "[", "]", "byte", ",", "w", "io", ".", "Writer", ")", "error", "{", "l", ":=", "4", "\n", "if", "len", "(", "buf", ")", "<", "l", "{", "return", "errNotEnoughSpace", "\n", "}", "\n",...
// Encode implements Binary encoder for snapshot metadata
[ "Encode", "implements", "Binary", "encoder", "for", "snapshot", "metadata" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L524-L537
test
t3rm1n4l/nitro
nitro.go
Decode
func (s *Snapshot) Decode(buf []byte, r io.Reader) error { if _, err := io.ReadFull(r, buf[0:4]); err != nil { return err } s.sn = binary.BigEndian.Uint32(buf[0:4]) return nil }
go
func (s *Snapshot) Decode(buf []byte, r io.Reader) error { if _, err := io.ReadFull(r, buf[0:4]); err != nil { return err } s.sn = binary.BigEndian.Uint32(buf[0:4]) return nil }
[ "func", "(", "s", "*", "Snapshot", ")", "Decode", "(", "buf", "[", "]", "byte", ",", "r", "io", ".", "Reader", ")", "error", "{", "if", "_", ",", "err", ":=", "io", ".", "ReadFull", "(", "r", ",", "buf", "[", "0", ":", "4", "]", ")", ";", ...
// Decode implements binary decoder for snapshot metadata
[ "Decode", "implements", "binary", "decoder", "for", "snapshot", "metadata" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L540-L546
test
t3rm1n4l/nitro
nitro.go
Open
func (s *Snapshot) Open() bool { if atomic.LoadInt32(&s.refCount) == 0 { return false } atomic.AddInt32(&s.refCount, 1) return true }
go
func (s *Snapshot) Open() bool { if atomic.LoadInt32(&s.refCount) == 0 { return false } atomic.AddInt32(&s.refCount, 1) return true }
[ "func", "(", "s", "*", "Snapshot", ")", "Open", "(", ")", "bool", "{", "if", "atomic", ".", "LoadInt32", "(", "&", "s", ".", "refCount", ")", "==", "0", "{", "return", "false", "\n", "}", "\n", "atomic", ".", "AddInt32", "(", "&", "s", ".", "re...
// Open implements reference couting and garbage collection for snapshots // When snapshots are shared by multiple threads, each thread should Open the // snapshot. This API internally tracks the reference count for the snapshot.
[ "Open", "implements", "reference", "couting", "and", "garbage", "collection", "for", "snapshots", "When", "snapshots", "are", "shared", "by", "multiple", "threads", "each", "thread", "should", "Open", "the", "snapshot", ".", "This", "API", "internally", "tracks", ...
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L551-L557
test
t3rm1n4l/nitro
nitro.go
CompareSnapshot
func CompareSnapshot(this, that unsafe.Pointer) int { thisItem := (*Snapshot)(this) thatItem := (*Snapshot)(that) return int(thisItem.sn) - int(thatItem.sn) }
go
func CompareSnapshot(this, that unsafe.Pointer) int { thisItem := (*Snapshot)(this) thatItem := (*Snapshot)(that) return int(thisItem.sn) - int(thatItem.sn) }
[ "func", "CompareSnapshot", "(", "this", ",", "that", "unsafe", ".", "Pointer", ")", "int", "{", "thisItem", ":=", "(", "*", "Snapshot", ")", "(", "this", ")", "\n", "thatItem", ":=", "(", "*", "Snapshot", ")", "(", "that", ")", "\n", "return", "int",...
// CompareSnapshot implements comparator for snapshots based on snapshot number
[ "CompareSnapshot", "implements", "comparator", "for", "snapshots", "based", "on", "snapshot", "number" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L581-L586
test
t3rm1n4l/nitro
nitro.go
GC
func (m *Nitro) GC() { if atomic.CompareAndSwapInt32(&m.isGCRunning, 0, 1) { m.collectDead() atomic.CompareAndSwapInt32(&m.isGCRunning, 1, 0) } }
go
func (m *Nitro) GC() { if atomic.CompareAndSwapInt32(&m.isGCRunning, 0, 1) { m.collectDead() atomic.CompareAndSwapInt32(&m.isGCRunning, 1, 0) } }
[ "func", "(", "m", "*", "Nitro", ")", "GC", "(", ")", "{", "if", "atomic", ".", "CompareAndSwapInt32", "(", "&", "m", ".", "isGCRunning", ",", "0", ",", "1", ")", "{", "m", ".", "collectDead", "(", ")", "\n", "atomic", ".", "CompareAndSwapInt32", "(...
// GC implements manual garbage collection of Nitro snapshots.
[ "GC", "implements", "manual", "garbage", "collection", "of", "Nitro", "snapshots", "." ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L702-L707
test
t3rm1n4l/nitro
nitro.go
GetSnapshots
func (m *Nitro) GetSnapshots() []*Snapshot { var snaps []*Snapshot buf := m.snapshots.MakeBuf() defer m.snapshots.FreeBuf(buf) iter := m.snapshots.NewIterator(CompareSnapshot, buf) iter.SeekFirst() for ; iter.Valid(); iter.Next() { snaps = append(snaps, (*Snapshot)(iter.Get())) } return snaps }
go
func (m *Nitro) GetSnapshots() []*Snapshot { var snaps []*Snapshot buf := m.snapshots.MakeBuf() defer m.snapshots.FreeBuf(buf) iter := m.snapshots.NewIterator(CompareSnapshot, buf) iter.SeekFirst() for ; iter.Valid(); iter.Next() { snaps = append(snaps, (*Snapshot)(iter.Get())) } return snaps }
[ "func", "(", "m", "*", "Nitro", ")", "GetSnapshots", "(", ")", "[", "]", "*", "Snapshot", "{", "var", "snaps", "[", "]", "*", "Snapshot", "\n", "buf", ":=", "m", ".", "snapshots", ".", "MakeBuf", "(", ")", "\n", "defer", "m", ".", "snapshots", "....
// GetSnapshots returns the list of current live snapshots // This API is mainly for debugging purpose
[ "GetSnapshots", "returns", "the", "list", "of", "current", "live", "snapshots", "This", "API", "is", "mainly", "for", "debugging", "purpose" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L711-L722
test
t3rm1n4l/nitro
nitro.go
MemoryInUse
func MemoryInUse() (sz int64) { buf := dbInstances.MakeBuf() defer dbInstances.FreeBuf(buf) iter := dbInstances.NewIterator(CompareNitro, buf) for iter.SeekFirst(); iter.Valid(); iter.Next() { db := (*Nitro)(iter.Get()) sz += db.MemoryInUse() } return }
go
func MemoryInUse() (sz int64) { buf := dbInstances.MakeBuf() defer dbInstances.FreeBuf(buf) iter := dbInstances.NewIterator(CompareNitro, buf) for iter.SeekFirst(); iter.Valid(); iter.Next() { db := (*Nitro)(iter.Get()) sz += db.MemoryInUse() } return }
[ "func", "MemoryInUse", "(", ")", "(", "sz", "int64", ")", "{", "buf", ":=", "dbInstances", ".", "MakeBuf", "(", ")", "\n", "defer", "dbInstances", ".", "FreeBuf", "(", "buf", ")", "\n", "iter", ":=", "dbInstances", ".", "NewIterator", "(", "CompareNitro"...
// MemoryInUse returns total memory used by all Nitro instances in the current process
[ "MemoryInUse", "returns", "total", "memory", "used", "by", "all", "Nitro", "instances", "in", "the", "current", "process" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/nitro.go#L1184-L1194
test
t3rm1n4l/nitro
skiplist/access_barrier.go
CompareBS
func CompareBS(this, that unsafe.Pointer) int { thisItm := (*BarrierSession)(this) thatItm := (*BarrierSession)(that) return int(thisItm.seqno) - int(thatItm.seqno) }
go
func CompareBS(this, that unsafe.Pointer) int { thisItm := (*BarrierSession)(this) thatItm := (*BarrierSession)(that) return int(thisItm.seqno) - int(thatItm.seqno) }
[ "func", "CompareBS", "(", "this", ",", "that", "unsafe", ".", "Pointer", ")", "int", "{", "thisItm", ":=", "(", "*", "BarrierSession", ")", "(", "this", ")", "\n", "thatItm", ":=", "(", "*", "BarrierSession", ")", "(", "that", ")", "\n", "return", "i...
// CompareBS is a barrier session comparator based on seqno
[ "CompareBS", "is", "a", "barrier", "session", "comparator", "based", "on", "seqno" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/access_barrier.go#L77-L82
test
t3rm1n4l/nitro
skiplist/access_barrier.go
Acquire
func (ab *AccessBarrier) Acquire() *BarrierSession { if ab.active { retry: bs := (*BarrierSession)(atomic.LoadPointer(&ab.session)) liveCount := atomic.AddInt32(bs.liveCount, 1) if liveCount > barrierFlushOffset { ab.Release(bs) goto retry } return bs } return nil }
go
func (ab *AccessBarrier) Acquire() *BarrierSession { if ab.active { retry: bs := (*BarrierSession)(atomic.LoadPointer(&ab.session)) liveCount := atomic.AddInt32(bs.liveCount, 1) if liveCount > barrierFlushOffset { ab.Release(bs) goto retry } return bs } return nil }
[ "func", "(", "ab", "*", "AccessBarrier", ")", "Acquire", "(", ")", "*", "BarrierSession", "{", "if", "ab", ".", "active", "{", "retry", ":", "bs", ":=", "(", "*", "BarrierSession", ")", "(", "atomic", ".", "LoadPointer", "(", "&", "ab", ".", "session...
// Acquire marks enter of an accessor in the skiplist
[ "Acquire", "marks", "enter", "of", "an", "accessor", "in", "the", "skiplist" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/access_barrier.go#L141-L155
test
t3rm1n4l/nitro
skiplist/access_barrier.go
Release
func (ab *AccessBarrier) Release(bs *BarrierSession) { if ab.active { liveCount := atomic.AddInt32(bs.liveCount, -1) if liveCount == barrierFlushOffset { buf := ab.freeq.MakeBuf() defer ab.freeq.FreeBuf(buf) // Accessors which entered a closed barrier session steps down automatically // But, they may ...
go
func (ab *AccessBarrier) Release(bs *BarrierSession) { if ab.active { liveCount := atomic.AddInt32(bs.liveCount, -1) if liveCount == barrierFlushOffset { buf := ab.freeq.MakeBuf() defer ab.freeq.FreeBuf(buf) // Accessors which entered a closed barrier session steps down automatically // But, they may ...
[ "func", "(", "ab", "*", "AccessBarrier", ")", "Release", "(", "bs", "*", "BarrierSession", ")", "{", "if", "ab", ".", "active", "{", "liveCount", ":=", "atomic", ".", "AddInt32", "(", "bs", ".", "liveCount", ",", "-", "1", ")", "\n", "if", "liveCount...
// Release marks leaving of an accessor in the skiplist
[ "Release", "marks", "leaving", "of", "an", "accessor", "in", "the", "skiplist" ]
937fe99f63a01a8bea7661c49e2f3f8af6541d7c
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/access_barrier.go#L158-L176
test