id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
29,300
hashicorp/go-memdb
filter.go
Next
func (f *FilterIterator) Next() interface{} { for { if value := f.iter.Next(); value == nil || !f.filter(value) { return value } } }
go
func (f *FilterIterator) Next() interface{} { for { if value := f.iter.Next(); value == nil || !f.filter(value) { return value } } }
[ "func", "(", "f", "*", "FilterIterator", ")", "Next", "(", ")", "interface", "{", "}", "{", "for", "{", "if", "value", ":=", "f", ".", "iter", ".", "Next", "(", ")", ";", "value", "==", "nil", "||", "!", "f", ".", "filter", "(", "value", ")", ...
// Next returns the next non-filtered result from the wrapped iterator
[ "Next", "returns", "the", "next", "non", "-", "filtered", "result", "from", "the", "wrapped", "iterator" ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/filter.go#L27-L33
29,301
hashicorp/go-memdb
watch-gen/main.go
render
func render() error { tmpl, err := template.New("watch").Parse(source) if err != nil { return err } if err := tmpl.Execute(os.Stdout, make([]struct{}, aFew)); err != nil { return err } return nil }
go
func render() error { tmpl, err := template.New("watch").Parse(source) if err != nil { return err } if err := tmpl.Execute(os.Stdout, make([]struct{}, aFew)); err != nil { return err } return nil }
[ "func", "render", "(", ")", "error", "{", "tmpl", ",", "err", ":=", "template", ".", "New", "(", "\"", "\"", ")", ".", "Parse", "(", "source", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "tmpl"...
// render prints the template to stdout.
[ "render", "prints", "the", "template", "to", "stdout", "." ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/watch-gen/main.go#L47-L56
29,302
hashicorp/go-memdb
schema.go
Validate
func (s *DBSchema) Validate() error { if s == nil { return fmt.Errorf("schema is nil") } if len(s.Tables) == 0 { return fmt.Errorf("schema has no tables defined") } for name, table := range s.Tables { if name != table.Name { return fmt.Errorf("table name mis-match for '%s'", name) } if err := table...
go
func (s *DBSchema) Validate() error { if s == nil { return fmt.Errorf("schema is nil") } if len(s.Tables) == 0 { return fmt.Errorf("schema has no tables defined") } for name, table := range s.Tables { if name != table.Name { return fmt.Errorf("table name mis-match for '%s'", name) } if err := table...
[ "func", "(", "s", "*", "DBSchema", ")", "Validate", "(", ")", "error", "{", "if", "s", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "len", "(", "s", ".", "Tables", ")", "==", "0", "{", "retu...
// Validate validates the schema.
[ "Validate", "validates", "the", "schema", "." ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/schema.go#L16-L36
29,303
hashicorp/go-memdb
schema.go
Validate
func (s *TableSchema) Validate() error { if s.Name == "" { return fmt.Errorf("missing table name") } if len(s.Indexes) == 0 { return fmt.Errorf("missing table indexes for '%s'", s.Name) } if _, ok := s.Indexes["id"]; !ok { return fmt.Errorf("must have id index") } if !s.Indexes["id"].Unique { return f...
go
func (s *TableSchema) Validate() error { if s.Name == "" { return fmt.Errorf("missing table name") } if len(s.Indexes) == 0 { return fmt.Errorf("missing table indexes for '%s'", s.Name) } if _, ok := s.Indexes["id"]; !ok { return fmt.Errorf("must have id index") } if !s.Indexes["id"].Unique { return f...
[ "func", "(", "s", "*", "TableSchema", ")", "Validate", "(", ")", "error", "{", "if", "s", ".", "Name", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "len", "(", "s", ".", "Indexes", ")", ...
// Validate is used to validate the table schema
[ "Validate", "is", "used", "to", "validate", "the", "table", "schema" ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/schema.go#L50-L82
29,304
hashicorp/go-memdb
memdb.go
NewMemDB
func NewMemDB(schema *DBSchema) (*MemDB, error) { // Validate the schema if err := schema.Validate(); err != nil { return nil, err } // Create the MemDB db := &MemDB{ schema: schema, root: unsafe.Pointer(iradix.New()), primary: true, } if err := db.initialize(); err != nil { return nil, err } r...
go
func NewMemDB(schema *DBSchema) (*MemDB, error) { // Validate the schema if err := schema.Validate(); err != nil { return nil, err } // Create the MemDB db := &MemDB{ schema: schema, root: unsafe.Pointer(iradix.New()), primary: true, } if err := db.initialize(); err != nil { return nil, err } r...
[ "func", "NewMemDB", "(", "schema", "*", "DBSchema", ")", "(", "*", "MemDB", ",", "error", ")", "{", "// Validate the schema", "if", "err", ":=", "schema", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}"...
// NewMemDB creates a new MemDB with the given schema
[ "NewMemDB", "creates", "a", "new", "MemDB", "with", "the", "given", "schema" ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/memdb.go#L28-L45
29,305
hashicorp/go-memdb
memdb.go
getRoot
func (db *MemDB) getRoot() *iradix.Tree { root := (*iradix.Tree)(atomic.LoadPointer(&db.root)) return root }
go
func (db *MemDB) getRoot() *iradix.Tree { root := (*iradix.Tree)(atomic.LoadPointer(&db.root)) return root }
[ "func", "(", "db", "*", "MemDB", ")", "getRoot", "(", ")", "*", "iradix", ".", "Tree", "{", "root", ":=", "(", "*", "iradix", ".", "Tree", ")", "(", "atomic", ".", "LoadPointer", "(", "&", "db", ".", "root", ")", ")", "\n", "return", "root", "\...
// getRoot is used to do an atomic load of the root pointer
[ "getRoot", "is", "used", "to", "do", "an", "atomic", "load", "of", "the", "root", "pointer" ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/memdb.go#L48-L51
29,306
hashicorp/go-memdb
memdb.go
Txn
func (db *MemDB) Txn(write bool) *Txn { if write { db.writer.Lock() } txn := &Txn{ db: db, write: write, rootTxn: db.getRoot().Txn(), } return txn }
go
func (db *MemDB) Txn(write bool) *Txn { if write { db.writer.Lock() } txn := &Txn{ db: db, write: write, rootTxn: db.getRoot().Txn(), } return txn }
[ "func", "(", "db", "*", "MemDB", ")", "Txn", "(", "write", "bool", ")", "*", "Txn", "{", "if", "write", "{", "db", ".", "writer", ".", "Lock", "(", ")", "\n", "}", "\n", "txn", ":=", "&", "Txn", "{", "db", ":", "db", ",", "write", ":", "wri...
// Txn is used to start a new transaction, in either read or write mode. // There can only be a single concurrent writer, but any number of readers.
[ "Txn", "is", "used", "to", "start", "a", "new", "transaction", "in", "either", "read", "or", "write", "mode", ".", "There", "can", "only", "be", "a", "single", "concurrent", "writer", "but", "any", "number", "of", "readers", "." ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/memdb.go#L55-L65
29,307
hashicorp/go-memdb
memdb.go
Snapshot
func (db *MemDB) Snapshot() *MemDB { clone := &MemDB{ schema: db.schema, root: unsafe.Pointer(db.getRoot()), primary: false, } return clone }
go
func (db *MemDB) Snapshot() *MemDB { clone := &MemDB{ schema: db.schema, root: unsafe.Pointer(db.getRoot()), primary: false, } return clone }
[ "func", "(", "db", "*", "MemDB", ")", "Snapshot", "(", ")", "*", "MemDB", "{", "clone", ":=", "&", "MemDB", "{", "schema", ":", "db", ".", "schema", ",", "root", ":", "unsafe", ".", "Pointer", "(", "db", ".", "getRoot", "(", ")", ")", ",", "pri...
// Snapshot is used to capture a point-in-time snapshot // of the database that will not be affected by any write // operations to the existing DB.
[ "Snapshot", "is", "used", "to", "capture", "a", "point", "-", "in", "-", "time", "snapshot", "of", "the", "database", "that", "will", "not", "be", "affected", "by", "any", "write", "operations", "to", "the", "existing", "DB", "." ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/memdb.go#L70-L77
29,308
hashicorp/go-memdb
memdb.go
initialize
func (db *MemDB) initialize() error { root := db.getRoot() for tName, tableSchema := range db.schema.Tables { for iName := range tableSchema.Indexes { index := iradix.New() path := indexPath(tName, iName) root, _, _ = root.Insert(path, index) } } db.root = unsafe.Pointer(root) return nil }
go
func (db *MemDB) initialize() error { root := db.getRoot() for tName, tableSchema := range db.schema.Tables { for iName := range tableSchema.Indexes { index := iradix.New() path := indexPath(tName, iName) root, _, _ = root.Insert(path, index) } } db.root = unsafe.Pointer(root) return nil }
[ "func", "(", "db", "*", "MemDB", ")", "initialize", "(", ")", "error", "{", "root", ":=", "db", ".", "getRoot", "(", ")", "\n", "for", "tName", ",", "tableSchema", ":=", "range", "db", ".", "schema", ".", "Tables", "{", "for", "iName", ":=", "range...
// initialize is used to setup the DB for use after creation. This should // be called only once after allocating a MemDB.
[ "initialize", "is", "used", "to", "setup", "the", "DB", "for", "use", "after", "creation", ".", "This", "should", "be", "called", "only", "once", "after", "allocating", "a", "MemDB", "." ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/memdb.go#L81-L92
29,309
hashicorp/go-memdb
index.go
IsIntType
func IsIntType(k reflect.Kind) (size int, okay bool) { switch k { case reflect.Int: return binary.MaxVarintLen64, true case reflect.Int8: return 2, true case reflect.Int16: return binary.MaxVarintLen16, true case reflect.Int32: return binary.MaxVarintLen32, true case reflect.Int64: return binary.MaxVari...
go
func IsIntType(k reflect.Kind) (size int, okay bool) { switch k { case reflect.Int: return binary.MaxVarintLen64, true case reflect.Int8: return 2, true case reflect.Int16: return binary.MaxVarintLen16, true case reflect.Int32: return binary.MaxVarintLen32, true case reflect.Int64: return binary.MaxVari...
[ "func", "IsIntType", "(", "k", "reflect", ".", "Kind", ")", "(", "size", "int", ",", "okay", "bool", ")", "{", "switch", "k", "{", "case", "reflect", ".", "Int", ":", "return", "binary", ".", "MaxVarintLen64", ",", "true", "\n", "case", "reflect", "....
// IsIntType returns whether the passed type is a type of int and the number // of bytes needed to encode the type.
[ "IsIntType", "returns", "whether", "the", "passed", "type", "is", "a", "type", "of", "int", "and", "the", "number", "of", "bytes", "needed", "to", "encode", "the", "type", "." ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/index.go#L328-L343
29,310
hashicorp/go-memdb
index.go
IsUintType
func IsUintType(k reflect.Kind) (size int, okay bool) { switch k { case reflect.Uint: return binary.MaxVarintLen64, true case reflect.Uint8: return 2, true case reflect.Uint16: return binary.MaxVarintLen16, true case reflect.Uint32: return binary.MaxVarintLen32, true case reflect.Uint64: return binary.M...
go
func IsUintType(k reflect.Kind) (size int, okay bool) { switch k { case reflect.Uint: return binary.MaxVarintLen64, true case reflect.Uint8: return 2, true case reflect.Uint16: return binary.MaxVarintLen16, true case reflect.Uint32: return binary.MaxVarintLen32, true case reflect.Uint64: return binary.M...
[ "func", "IsUintType", "(", "k", "reflect", ".", "Kind", ")", "(", "size", "int", ",", "okay", "bool", ")", "{", "switch", "k", "{", "case", "reflect", ".", "Uint", ":", "return", "binary", ".", "MaxVarintLen64", ",", "true", "\n", "case", "reflect", ...
// IsUintType returns whether the passed type is a type of uint and the number // of bytes needed to encode the type.
[ "IsUintType", "returns", "whether", "the", "passed", "type", "is", "a", "type", "of", "uint", "and", "the", "number", "of", "bytes", "needed", "to", "encode", "the", "type", "." ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/index.go#L401-L416
29,311
hashicorp/go-memdb
index.go
parseString
func (u *UUIDFieldIndex) parseString(s string, enforceLength bool) ([]byte, error) { // Verify the length l := len(s) if enforceLength && l != 36 { return nil, fmt.Errorf("UUID must be 36 characters") } else if l > 36 { return nil, fmt.Errorf("Invalid UUID length. UUID have 36 characters; got %d", l) } hyphe...
go
func (u *UUIDFieldIndex) parseString(s string, enforceLength bool) ([]byte, error) { // Verify the length l := len(s) if enforceLength && l != 36 { return nil, fmt.Errorf("UUID must be 36 characters") } else if l > 36 { return nil, fmt.Errorf("Invalid UUID length. UUID have 36 characters; got %d", l) } hyphe...
[ "func", "(", "u", "*", "UUIDFieldIndex", ")", "parseString", "(", "s", "string", ",", "enforceLength", "bool", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Verify the length", "l", ":=", "len", "(", "s", ")", "\n", "if", "enforceLength", "&&...
// parseString parses a UUID from the string. If enforceLength is false, it will // parse a partial UUID. An error is returned if the input, stripped of hyphens, // is not even length.
[ "parseString", "parses", "a", "UUID", "from", "the", "string", ".", "If", "enforceLength", "is", "false", "it", "will", "parse", "a", "partial", "UUID", ".", "An", "error", "is", "returned", "if", "the", "input", "stripped", "of", "hyphens", "is", "not", ...
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/index.go#L481-L508
29,312
hashicorp/go-memdb
index.go
fromBoolArgs
func fromBoolArgs(args []interface{}) ([]byte, error) { if len(args) != 1 { return nil, fmt.Errorf("must provide only a single argument") } if val, ok := args[0].(bool); !ok { return nil, fmt.Errorf("argument must be a boolean type: %#v", args[0]) } else if val { return []byte{1}, nil } return []byte{0}, ...
go
func fromBoolArgs(args []interface{}) ([]byte, error) { if len(args) != 1 { return nil, fmt.Errorf("must provide only a single argument") } if val, ok := args[0].(bool); !ok { return nil, fmt.Errorf("argument must be a boolean type: %#v", args[0]) } else if val { return []byte{1}, nil } return []byte{0}, ...
[ "func", "fromBoolArgs", "(", "args", "[", "]", "interface", "{", "}", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "len", "(", "args", ")", "!=", "1", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "...
// fromBoolArgs is a helper that expects only a single boolean argument and // returns a single length byte array containing either a one or zero depending // on whether the passed input is true or false respectively.
[ "fromBoolArgs", "is", "a", "helper", "that", "expects", "only", "a", "single", "boolean", "argument", "and", "returns", "a", "single", "length", "byte", "array", "containing", "either", "a", "one", "or", "zero", "depending", "on", "whether", "the", "passed", ...
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/index.go#L570-L582
29,313
hashicorp/go-memdb
watch_few.go
watchFew
func watchFew(ctx context.Context, ch []<-chan struct{}) error { select { case <-ch[0]: return nil case <-ch[1]: return nil case <-ch[2]: return nil case <-ch[3]: return nil case <-ch[4]: return nil case <-ch[5]: return nil case <-ch[6]: return nil case <-ch[7]: return nil case <-ch[8...
go
func watchFew(ctx context.Context, ch []<-chan struct{}) error { select { case <-ch[0]: return nil case <-ch[1]: return nil case <-ch[2]: return nil case <-ch[3]: return nil case <-ch[4]: return nil case <-ch[5]: return nil case <-ch[6]: return nil case <-ch[7]: return nil case <-ch[8...
[ "func", "watchFew", "(", "ctx", "context", ".", "Context", ",", "ch", "[", "]", "<-", "chan", "struct", "{", "}", ")", "error", "{", "select", "{", "case", "<-", "ch", "[", "0", "]", ":", "return", "nil", "\n\n", "case", "<-", "ch", "[", "1", "...
// watchFew is used if there are only a few watchers as a performance // optimization.
[ "watchFew", "is", "used", "if", "there", "are", "only", "a", "few", "watchers", "as", "a", "performance", "optimization", "." ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/watch_few.go#L15-L117
29,314
hashicorp/go-memdb
watch.go
Add
func (w WatchSet) Add(watchCh <-chan struct{}) { if w == nil { return } if _, ok := w[watchCh]; !ok { w[watchCh] = struct{}{} } }
go
func (w WatchSet) Add(watchCh <-chan struct{}) { if w == nil { return } if _, ok := w[watchCh]; !ok { w[watchCh] = struct{}{} } }
[ "func", "(", "w", "WatchSet", ")", "Add", "(", "watchCh", "<-", "chan", "struct", "{", "}", ")", "{", "if", "w", "==", "nil", "{", "return", "\n", "}", "\n\n", "if", "_", ",", "ok", ":=", "w", "[", "watchCh", "]", ";", "!", "ok", "{", "w", ...
// Add appends a watchCh to the WatchSet if non-nil.
[ "Add", "appends", "a", "watchCh", "to", "the", "WatchSet", "if", "non", "-", "nil", "." ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/watch.go#L17-L25
29,315
hashicorp/go-memdb
watch.go
Watch
func (w WatchSet) Watch(timeoutCh <-chan time.Time) bool { if w == nil { return false } // Create a context that gets cancelled when the timeout is triggered ctx, cancel := context.WithCancel(context.Background()) defer cancel() go func() { select { case <-timeoutCh: cancel() case <-ctx.Done(): } ...
go
func (w WatchSet) Watch(timeoutCh <-chan time.Time) bool { if w == nil { return false } // Create a context that gets cancelled when the timeout is triggered ctx, cancel := context.WithCancel(context.Background()) defer cancel() go func() { select { case <-timeoutCh: cancel() case <-ctx.Done(): } ...
[ "func", "(", "w", "WatchSet", ")", "Watch", "(", "timeoutCh", "<-", "chan", "time", ".", "Time", ")", "bool", "{", "if", "w", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "// Create a context that gets cancelled when the timeout is triggered", "ctx", ...
// Watch is used to wait for either the watch set to trigger or a timeout. // Returns true on timeout.
[ "Watch", "is", "used", "to", "wait", "for", "either", "the", "watch", "set", "to", "trigger", "or", "a", "timeout", ".", "Returns", "true", "on", "timeout", "." ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/watch.go#L47-L65
29,316
hashicorp/go-memdb
watch.go
WatchCtx
func (w WatchSet) WatchCtx(ctx context.Context) error { if w == nil { return nil } if n := len(w); n <= aFew { idx := 0 chunk := make([]<-chan struct{}, aFew) for watchCh := range w { chunk[idx] = watchCh idx++ } return watchFew(ctx, chunk) } return w.watchMany(ctx) }
go
func (w WatchSet) WatchCtx(ctx context.Context) error { if w == nil { return nil } if n := len(w); n <= aFew { idx := 0 chunk := make([]<-chan struct{}, aFew) for watchCh := range w { chunk[idx] = watchCh idx++ } return watchFew(ctx, chunk) } return w.watchMany(ctx) }
[ "func", "(", "w", "WatchSet", ")", "WatchCtx", "(", "ctx", "context", ".", "Context", ")", "error", "{", "if", "w", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "n", ":=", "len", "(", "w", ")", ";", "n", "<=", "aFew", "{", "idx",...
// WatchCtx is used to wait for either the watch set to trigger or for the // context to be cancelled. Watch with a timeout channel can be mimicked by // creating a context with a deadline. WatchCtx should be preferred over Watch.
[ "WatchCtx", "is", "used", "to", "wait", "for", "either", "the", "watch", "set", "to", "trigger", "or", "for", "the", "context", "to", "be", "cancelled", ".", "Watch", "with", "a", "timeout", "channel", "can", "be", "mimicked", "by", "creating", "a", "con...
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/watch.go#L70-L86
29,317
hashicorp/go-memdb
watch.go
watchMany
func (w WatchSet) watchMany(ctx context.Context) error { // Set up a goroutine for each watcher. triggerCh := make(chan struct{}, 1) watcher := func(chunk []<-chan struct{}) { if err := watchFew(ctx, chunk); err == nil { select { case triggerCh <- struct{}{}: default: } } } // Apportion the watch ...
go
func (w WatchSet) watchMany(ctx context.Context) error { // Set up a goroutine for each watcher. triggerCh := make(chan struct{}, 1) watcher := func(chunk []<-chan struct{}) { if err := watchFew(ctx, chunk); err == nil { select { case triggerCh <- struct{}{}: default: } } } // Apportion the watch ...
[ "func", "(", "w", "WatchSet", ")", "watchMany", "(", "ctx", "context", ".", "Context", ")", "error", "{", "// Set up a goroutine for each watcher.", "triggerCh", ":=", "make", "(", "chan", "struct", "{", "}", ",", "1", ")", "\n", "watcher", ":=", "func", "...
// watchMany is used if there are many watchers.
[ "watchMany", "is", "used", "if", "there", "are", "many", "watchers", "." ]
10278d3759e27502b741e52c7d8115d892e7723a
https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/watch.go#L89-L129
29,318
google/codesearch
index/regexp.go
and
func (q *Query) and(r *Query) *Query { return q.andOr(r, QAnd) }
go
func (q *Query) and(r *Query) *Query { return q.andOr(r, QAnd) }
[ "func", "(", "q", "*", "Query", ")", "and", "(", "r", "*", "Query", ")", "*", "Query", "{", "return", "q", ".", "andOr", "(", "r", ",", "QAnd", ")", "\n", "}" ]
// and returns the query q AND r, possibly reusing q's and r's storage.
[ "and", "returns", "the", "query", "q", "AND", "r", "possibly", "reusing", "q", "s", "and", "r", "s", "storage", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L41-L43
29,319
google/codesearch
index/regexp.go
or
func (q *Query) or(r *Query) *Query { return q.andOr(r, QOr) }
go
func (q *Query) or(r *Query) *Query { return q.andOr(r, QOr) }
[ "func", "(", "q", "*", "Query", ")", "or", "(", "r", "*", "Query", ")", "*", "Query", "{", "return", "q", ".", "andOr", "(", "r", ",", "QOr", ")", "\n", "}" ]
// or returns the query q OR r, possibly reusing q's and r's storage.
[ "or", "returns", "the", "query", "q", "OR", "r", "possibly", "reusing", "q", "s", "and", "r", "s", "storage", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L46-L48
29,320
google/codesearch
index/regexp.go
implies
func (q *Query) implies(r *Query) bool { if q.Op == QNone || r.Op == QAll { // False implies everything. // Everything implies True. return true } if q.Op == QAll || r.Op == QNone { // True implies nothing. // Nothing implies False. return false } if q.Op == QAnd || (q.Op == QOr && len(q.Trigram) == 1...
go
func (q *Query) implies(r *Query) bool { if q.Op == QNone || r.Op == QAll { // False implies everything. // Everything implies True. return true } if q.Op == QAll || r.Op == QNone { // True implies nothing. // Nothing implies False. return false } if q.Op == QAnd || (q.Op == QOr && len(q.Trigram) == 1...
[ "func", "(", "q", "*", "Query", ")", "implies", "(", "r", "*", "Query", ")", "bool", "{", "if", "q", ".", "Op", "==", "QNone", "||", "r", ".", "Op", "==", "QAll", "{", "// False implies everything.", "// Everything implies True.", "return", "true", "\n",...
// implies reports whether q implies r. // It is okay for it to return false negatives.
[ "implies", "reports", "whether", "q", "implies", "r", ".", "It", "is", "okay", "for", "it", "to", "return", "false", "negatives", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L174-L196
29,321
google/codesearch
index/regexp.go
maybeRewrite
func (q *Query) maybeRewrite(op QueryOp) { if q.Op != QAnd && q.Op != QOr { return } // AND/OR doing real work? Can't rewrite. n := len(q.Sub) + len(q.Trigram) if n > 1 { return } // Nothing left in the AND/OR? if n == 0 { if q.Op == QAnd { q.Op = QAll } else { q.Op = QNone } return } //...
go
func (q *Query) maybeRewrite(op QueryOp) { if q.Op != QAnd && q.Op != QOr { return } // AND/OR doing real work? Can't rewrite. n := len(q.Sub) + len(q.Trigram) if n > 1 { return } // Nothing left in the AND/OR? if n == 0 { if q.Op == QAnd { q.Op = QAll } else { q.Op = QNone } return } //...
[ "func", "(", "q", "*", "Query", ")", "maybeRewrite", "(", "op", "QueryOp", ")", "{", "if", "q", ".", "Op", "!=", "QAnd", "&&", "q", ".", "Op", "!=", "QOr", "{", "return", "\n", "}", "\n\n", "// AND/OR doing real work? Can't rewrite.", "n", ":=", "len"...
// maybeRewrite rewrites q to use op if it is possible to do so // without changing the meaning. It also simplifies if the node // is an empty OR or AND.
[ "maybeRewrite", "rewrites", "q", "to", "use", "op", "if", "it", "is", "possible", "to", "do", "so", "without", "changing", "the", "meaning", ".", "It", "also", "simplifies", "if", "the", "node", "is", "an", "empty", "OR", "or", "AND", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L229-L257
29,322
google/codesearch
index/regexp.go
andTrigrams
func (q *Query) andTrigrams(t stringSet) *Query { if t.minLen() < 3 { // If there is a short string, we can't guarantee // that any trigrams must be present, so use ALL. // q AND ALL = q. return q } //println("andtrigrams", strings.Join(t, ",")) or := noneQuery for _, tt := range t { var trig stringSet ...
go
func (q *Query) andTrigrams(t stringSet) *Query { if t.minLen() < 3 { // If there is a short string, we can't guarantee // that any trigrams must be present, so use ALL. // q AND ALL = q. return q } //println("andtrigrams", strings.Join(t, ",")) or := noneQuery for _, tt := range t { var trig stringSet ...
[ "func", "(", "q", "*", "Query", ")", "andTrigrams", "(", "t", "stringSet", ")", "*", "Query", "{", "if", "t", ".", "minLen", "(", ")", "<", "3", "{", "// If there is a short string, we can't guarantee", "// that any trigrams must be present, so use ALL.", "// q AND ...
// andTrigrams returns q AND the OR of the AND of the trigrams present in each string.
[ "andTrigrams", "returns", "q", "AND", "the", "OR", "of", "the", "AND", "of", "the", "trigrams", "present", "in", "each", "string", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L260-L281
29,323
google/codesearch
index/regexp.go
RegexpQuery
func RegexpQuery(re *syntax.Regexp) *Query { info := analyze(re) info.simplify(true) info.addExact() return info.match }
go
func RegexpQuery(re *syntax.Regexp) *Query { info := analyze(re) info.simplify(true) info.addExact() return info.match }
[ "func", "RegexpQuery", "(", "re", "*", "syntax", ".", "Regexp", ")", "*", "Query", "{", "info", ":=", "analyze", "(", "re", ")", "\n", "info", ".", "simplify", "(", "true", ")", "\n", "info", ".", "addExact", "(", ")", "\n", "return", "info", ".", ...
// RegexpQuery returns a Query for the given regexp.
[ "RegexpQuery", "returns", "a", "Query", "for", "the", "given", "regexp", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L333-L338
29,324
google/codesearch
index/regexp.go
anyMatch
func anyMatch() regexpInfo { return regexpInfo{ canEmpty: true, prefix: []string{""}, suffix: []string{""}, match: allQuery, } }
go
func anyMatch() regexpInfo { return regexpInfo{ canEmpty: true, prefix: []string{""}, suffix: []string{""}, match: allQuery, } }
[ "func", "anyMatch", "(", ")", "regexpInfo", "{", "return", "regexpInfo", "{", "canEmpty", ":", "true", ",", "prefix", ":", "[", "]", "string", "{", "\"", "\"", "}", ",", "suffix", ":", "[", "]", "string", "{", "\"", "\"", "}", ",", "match", ":", ...
// anyMatch returns the regexpInfo describing a regexp that // matches any string.
[ "anyMatch", "returns", "the", "regexpInfo", "describing", "a", "regexp", "that", "matches", "any", "string", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L382-L389
29,325
google/codesearch
index/regexp.go
fold
func fold(f func(x, y regexpInfo) regexpInfo, sub []*syntax.Regexp, zero regexpInfo) regexpInfo { if len(sub) == 0 { return zero } if len(sub) == 1 { return analyze(sub[0]) } info := f(analyze(sub[0]), analyze(sub[1])) for i := 2; i < len(sub); i++ { info = f(info, analyze(sub[i])) } return info }
go
func fold(f func(x, y regexpInfo) regexpInfo, sub []*syntax.Regexp, zero regexpInfo) regexpInfo { if len(sub) == 0 { return zero } if len(sub) == 1 { return analyze(sub[0]) } info := f(analyze(sub[0]), analyze(sub[1])) for i := 2; i < len(sub); i++ { info = f(info, analyze(sub[i])) } return info }
[ "func", "fold", "(", "f", "func", "(", "x", ",", "y", "regexpInfo", ")", "regexpInfo", ",", "sub", "[", "]", "*", "syntax", ".", "Regexp", ",", "zero", "regexpInfo", ")", "regexpInfo", "{", "if", "len", "(", "sub", ")", "==", "0", "{", "return", ...
// fold is the usual higher-order function.
[ "fold", "is", "the", "usual", "higher", "-", "order", "function", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L543-L555
29,326
google/codesearch
index/regexp.go
concat
func concat(x, y regexpInfo) (out regexpInfo) { //println("concat", x.String(), "...", y.String()) //defer func() { println("->", out.String()) }() var xy regexpInfo xy.match = x.match.and(y.match) if x.exact.have() && y.exact.have() { xy.exact = x.exact.cross(y.exact, false) } else { if x.exact.have() { x...
go
func concat(x, y regexpInfo) (out regexpInfo) { //println("concat", x.String(), "...", y.String()) //defer func() { println("->", out.String()) }() var xy regexpInfo xy.match = x.match.and(y.match) if x.exact.have() && y.exact.have() { xy.exact = x.exact.cross(y.exact, false) } else { if x.exact.have() { x...
[ "func", "concat", "(", "x", ",", "y", "regexpInfo", ")", "(", "out", "regexpInfo", ")", "{", "//println(\"concat\", x.String(), \"...\", y.String())", "//defer func() { println(\"->\", out.String()) }()", "var", "xy", "regexpInfo", "\n", "xy", ".", "match", "=", "x", ...
// concat returns the regexp info for xy given x and y.
[ "concat", "returns", "the", "regexp", "info", "for", "xy", "given", "x", "and", "y", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L558-L597
29,327
google/codesearch
index/regexp.go
alternate
func alternate(x, y regexpInfo) (out regexpInfo) { //println("alternate", x.String(), "...", y.String()) //defer func() { println("->", out.String()) }() var xy regexpInfo if x.exact.have() && y.exact.have() { xy.exact = x.exact.union(y.exact, false) } else if x.exact.have() { xy.prefix = x.exact.union(y.prefi...
go
func alternate(x, y regexpInfo) (out regexpInfo) { //println("alternate", x.String(), "...", y.String()) //defer func() { println("->", out.String()) }() var xy regexpInfo if x.exact.have() && y.exact.have() { xy.exact = x.exact.union(y.exact, false) } else if x.exact.have() { xy.prefix = x.exact.union(y.prefi...
[ "func", "alternate", "(", "x", ",", "y", "regexpInfo", ")", "(", "out", "regexpInfo", ")", "{", "//println(\"alternate\", x.String(), \"...\", y.String())", "//defer func() { println(\"->\", out.String()) }()", "var", "xy", "regexpInfo", "\n", "if", "x", ".", "exact", "...
// alternate returns the regexpInfo for x|y given x and y.
[ "alternate", "returns", "the", "regexpInfo", "for", "x|y", "given", "x", "and", "y", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L600-L623
29,328
google/codesearch
index/regexp.go
addExact
func (info *regexpInfo) addExact() { if info.exact.have() { info.match = info.match.andTrigrams(info.exact) } }
go
func (info *regexpInfo) addExact() { if info.exact.have() { info.match = info.match.andTrigrams(info.exact) } }
[ "func", "(", "info", "*", "regexpInfo", ")", "addExact", "(", ")", "{", "if", "info", ".", "exact", ".", "have", "(", ")", "{", "info", ".", "match", "=", "info", ".", "match", ".", "andTrigrams", "(", "info", ".", "exact", ")", "\n", "}", "\n", ...
// addExact adds to the match query the trigrams for matching info.exact.
[ "addExact", "adds", "to", "the", "match", "query", "the", "trigrams", "for", "matching", "info", ".", "exact", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L626-L630
29,329
google/codesearch
index/regexp.go
simplify
func (info *regexpInfo) simplify(force bool) { //println(" simplify", info.String(), " force=", force) //defer func() { println(" ->", info.String()) }() // If there are now too many exact strings, // loop over them, adding trigrams and moving // the relevant pieces into prefix and suffix. info.exact.clean(fals...
go
func (info *regexpInfo) simplify(force bool) { //println(" simplify", info.String(), " force=", force) //defer func() { println(" ->", info.String()) }() // If there are now too many exact strings, // loop over them, adding trigrams and moving // the relevant pieces into prefix and suffix. info.exact.clean(fals...
[ "func", "(", "info", "*", "regexpInfo", ")", "simplify", "(", "force", "bool", ")", "{", "//println(\" simplify\", info.String(), \" force=\", force)", "//defer func() { println(\" ->\", info.String()) }()", "// If there are now too many exact strings,", "// loop over them, adding tr...
// simplify simplifies the regexpInfo when the exact set gets too large.
[ "simplify", "simplifies", "the", "regexpInfo", "when", "the", "exact", "set", "gets", "too", "large", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L633-L659
29,330
google/codesearch
index/regexp.go
contains
func (s stringSet) contains(str string) bool { for _, ss := range s { if ss == str { return true } } return false }
go
func (s stringSet) contains(str string) bool { for _, ss := range s { if ss == str { return true } } return false }
[ "func", "(", "s", "stringSet", ")", "contains", "(", "str", "string", ")", "bool", "{", "for", "_", ",", "ss", ":=", "range", "s", "{", "if", "ss", "==", "str", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// contains reports whether s contains str.
[ "contains", "reports", "whether", "s", "contains", "str", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L739-L746
29,331
google/codesearch
index/regexp.go
clean
func (s *stringSet) clean(isSuffix bool) { t := *s if isSuffix { sort.Sort((*bySuffix)(s)) } else { sort.Sort((*byPrefix)(s)) } w := 0 for _, str := range t { if w == 0 || t[w-1] != str { t[w] = str w++ } } *s = t[:w] }
go
func (s *stringSet) clean(isSuffix bool) { t := *s if isSuffix { sort.Sort((*bySuffix)(s)) } else { sort.Sort((*byPrefix)(s)) } w := 0 for _, str := range t { if w == 0 || t[w-1] != str { t[w] = str w++ } } *s = t[:w] }
[ "func", "(", "s", "*", "stringSet", ")", "clean", "(", "isSuffix", "bool", ")", "{", "t", ":=", "*", "s", "\n", "if", "isSuffix", "{", "sort", ".", "Sort", "(", "(", "*", "bySuffix", ")", "(", "s", ")", ")", "\n", "}", "else", "{", "sort", "....
// clean removes duplicates from the stringSet.
[ "clean", "removes", "duplicates", "from", "the", "stringSet", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L780-L795
29,332
google/codesearch
index/regexp.go
minLen
func (s stringSet) minLen() int { if len(s) == 0 { return 0 } m := len(s[0]) for _, str := range s { if m > len(str) { m = len(str) } } return m }
go
func (s stringSet) minLen() int { if len(s) == 0 { return 0 } m := len(s[0]) for _, str := range s { if m > len(str) { m = len(str) } } return m }
[ "func", "(", "s", "stringSet", ")", "minLen", "(", ")", "int", "{", "if", "len", "(", "s", ")", "==", "0", "{", "return", "0", "\n", "}", "\n", "m", ":=", "len", "(", "s", "[", "0", "]", ")", "\n", "for", "_", ",", "str", ":=", "range", "...
// minLen returns the length of the shortest string in s.
[ "minLen", "returns", "the", "length", "of", "the", "shortest", "string", "in", "s", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L803-L814
29,333
google/codesearch
index/regexp.go
maxLen
func (s stringSet) maxLen() int { if len(s) == 0 { return 0 } m := len(s[0]) for _, str := range s { if m < len(str) { m = len(str) } } return m }
go
func (s stringSet) maxLen() int { if len(s) == 0 { return 0 } m := len(s[0]) for _, str := range s { if m < len(str) { m = len(str) } } return m }
[ "func", "(", "s", "stringSet", ")", "maxLen", "(", ")", "int", "{", "if", "len", "(", "s", ")", "==", "0", "{", "return", "0", "\n", "}", "\n", "m", ":=", "len", "(", "s", "[", "0", "]", ")", "\n", "for", "_", ",", "str", ":=", "range", "...
// maxLen returns the length of the longest string in s.
[ "maxLen", "returns", "the", "length", "of", "the", "longest", "string", "in", "s", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L817-L828
29,334
google/codesearch
index/regexp.go
union
func (s stringSet) union(t stringSet, isSuffix bool) stringSet { s = append(s, t...) s.clean(isSuffix) return s }
go
func (s stringSet) union(t stringSet, isSuffix bool) stringSet { s = append(s, t...) s.clean(isSuffix) return s }
[ "func", "(", "s", "stringSet", ")", "union", "(", "t", "stringSet", ",", "isSuffix", "bool", ")", "stringSet", "{", "s", "=", "append", "(", "s", ",", "t", "...", ")", "\n", "s", ".", "clean", "(", "isSuffix", ")", "\n", "return", "s", "\n", "}" ...
// union returns the union of s and t, reusing s's storage.
[ "union", "returns", "the", "union", "of", "s", "and", "t", "reusing", "s", "s", "storage", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L831-L835
29,335
google/codesearch
index/regexp.go
cross
func (s stringSet) cross(t stringSet, isSuffix bool) stringSet { p := stringSet{} for _, ss := range s { for _, tt := range t { p.add(ss + tt) } } p.clean(isSuffix) return p }
go
func (s stringSet) cross(t stringSet, isSuffix bool) stringSet { p := stringSet{} for _, ss := range s { for _, tt := range t { p.add(ss + tt) } } p.clean(isSuffix) return p }
[ "func", "(", "s", "stringSet", ")", "cross", "(", "t", "stringSet", ",", "isSuffix", "bool", ")", "stringSet", "{", "p", ":=", "stringSet", "{", "}", "\n", "for", "_", ",", "ss", ":=", "range", "s", "{", "for", "_", ",", "tt", ":=", "range", "t",...
// cross returns the cross product of s and t.
[ "cross", "returns", "the", "cross", "product", "of", "s", "and", "t", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L838-L847
29,336
google/codesearch
index/regexp.go
isSubsetOf
func (s stringSet) isSubsetOf(t stringSet) bool { j := 0 for _, ss := range s { for j < len(t) && t[j] < ss { j++ } if j >= len(t) || t[j] != ss { return false } } return true }
go
func (s stringSet) isSubsetOf(t stringSet) bool { j := 0 for _, ss := range s { for j < len(t) && t[j] < ss { j++ } if j >= len(t) || t[j] != ss { return false } } return true }
[ "func", "(", "s", "stringSet", ")", "isSubsetOf", "(", "t", "stringSet", ")", "bool", "{", "j", ":=", "0", "\n", "for", "_", ",", "ss", ":=", "range", "s", "{", "for", "j", "<", "len", "(", "t", ")", "&&", "t", "[", "j", "]", "<", "ss", "{"...
// isSubsetOf returns true if all strings in s are also in t. // It assumes both sets are sorted.
[ "isSubsetOf", "returns", "true", "if", "all", "strings", "in", "s", "are", "also", "in", "t", ".", "It", "assumes", "both", "sets", "are", "sorted", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/regexp.go#L861-L872
29,337
google/codesearch
regexp/copy.go
appendRange
func appendRange(r []rune, lo, hi rune) []rune { // Expand last range or next to last range if it overlaps or abuts. // Checking two ranges helps when appending case-folded // alphabets, so that one range can be expanding A-Z and the // other expanding a-z. n := len(r) for i := 2; i <= 4; i += 2 { // twice, using...
go
func appendRange(r []rune, lo, hi rune) []rune { // Expand last range or next to last range if it overlaps or abuts. // Checking two ranges helps when appending case-folded // alphabets, so that one range can be expanding A-Z and the // other expanding a-z. n := len(r) for i := 2; i <= 4; i += 2 { // twice, using...
[ "func", "appendRange", "(", "r", "[", "]", "rune", ",", "lo", ",", "hi", "rune", ")", "[", "]", "rune", "{", "// Expand last range or next to last range if it overlaps or abuts.", "// Checking two ranges helps when appending case-folded", "// alphabets, so that one range can be...
// appendRange returns the result of appending the range lo-hi to the class r.
[ "appendRange", "returns", "the", "result", "of", "appending", "the", "range", "lo", "-", "hi", "to", "the", "class", "r", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/regexp/copy.go#L52-L74
29,338
google/codesearch
regexp/copy.go
appendFoldedRange
func appendFoldedRange(r []rune, lo, hi rune) []rune { // Optimizations. if lo <= minFold && hi >= maxFold { // Range is full: folding can't add more. return appendRange(r, lo, hi) } if hi < minFold || lo > maxFold { // Range is outside folding possibilities. return appendRange(r, lo, hi) } if lo < minFol...
go
func appendFoldedRange(r []rune, lo, hi rune) []rune { // Optimizations. if lo <= minFold && hi >= maxFold { // Range is full: folding can't add more. return appendRange(r, lo, hi) } if hi < minFold || lo > maxFold { // Range is outside folding possibilities. return appendRange(r, lo, hi) } if lo < minFol...
[ "func", "appendFoldedRange", "(", "r", "[", "]", "rune", ",", "lo", ",", "hi", "rune", ")", "[", "]", "rune", "{", "// Optimizations.", "if", "lo", "<=", "minFold", "&&", "hi", ">=", "maxFold", "{", "// Range is full: folding can't add more.", "return", "app...
// appendFoldedRange returns the result of appending the range lo-hi // and its case folding-equivalent runes to the class r.
[ "appendFoldedRange", "returns", "the", "result", "of", "appending", "the", "range", "lo", "-", "hi", "and", "its", "case", "folding", "-", "equivalent", "runes", "to", "the", "class", "r", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/regexp/copy.go#L85-L116
29,339
google/codesearch
regexp/regexp.go
Compile
func Compile(expr string) (*Regexp, error) { re, err := syntax.Parse(expr, syntax.Perl) if err != nil { return nil, err } sre := re.Simplify() prog, err := syntax.Compile(sre) if err != nil { return nil, err } if err := toByteProg(prog); err != nil { return nil, err } r := &Regexp{ Syntax: re, expr:...
go
func Compile(expr string) (*Regexp, error) { re, err := syntax.Parse(expr, syntax.Perl) if err != nil { return nil, err } sre := re.Simplify() prog, err := syntax.Compile(sre) if err != nil { return nil, err } if err := toByteProg(prog); err != nil { return nil, err } r := &Regexp{ Syntax: re, expr:...
[ "func", "Compile", "(", "expr", "string", ")", "(", "*", "Regexp", ",", "error", ")", "{", "re", ",", "err", ":=", "syntax", ".", "Parse", "(", "expr", ",", "syntax", ".", "Perl", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// Compile parses a regular expression and returns, if successful, // a Regexp object that can be used to match against lines of text.
[ "Compile", "parses", "a", "regular", "expression", "and", "returns", "if", "successful", "a", "Regexp", "object", "that", "can", "be", "used", "to", "match", "against", "lines", "of", "text", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/regexp/regexp.go#L30-L51
29,340
google/codesearch
sparse/set.go
Add
func (s *Set) Add(x uint32) { v := s.sparse[x] if v < uint32(len(s.dense)) && s.dense[v] == x { return } n := len(s.dense) s.sparse[x] = uint32(n) s.dense = append(s.dense, x) }
go
func (s *Set) Add(x uint32) { v := s.sparse[x] if v < uint32(len(s.dense)) && s.dense[v] == x { return } n := len(s.dense) s.sparse[x] = uint32(n) s.dense = append(s.dense, x) }
[ "func", "(", "s", "*", "Set", ")", "Add", "(", "x", "uint32", ")", "{", "v", ":=", "s", ".", "sparse", "[", "x", "]", "\n", "if", "v", "<", "uint32", "(", "len", "(", "s", ".", "dense", ")", ")", "&&", "s", ".", "dense", "[", "v", "]", ...
// Add adds x to the set if it is not already there.
[ "Add", "adds", "x", "to", "the", "set", "if", "it", "is", "not", "already", "there", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/sparse/set.go#L39-L47
29,341
google/codesearch
sparse/set.go
Has
func (s *Set) Has(x uint32) bool { v := s.sparse[x] return v < uint32(len(s.dense)) && s.dense[v] == x }
go
func (s *Set) Has(x uint32) bool { v := s.sparse[x] return v < uint32(len(s.dense)) && s.dense[v] == x }
[ "func", "(", "s", "*", "Set", ")", "Has", "(", "x", "uint32", ")", "bool", "{", "v", ":=", "s", ".", "sparse", "[", "x", "]", "\n", "return", "v", "<", "uint32", "(", "len", "(", "s", ".", "dense", ")", ")", "&&", "s", ".", "dense", "[", ...
// Has reports whether x is in the set.
[ "Has", "reports", "whether", "x", "is", "in", "the", "set", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/sparse/set.go#L50-L53
29,342
google/codesearch
regexp/match.go
stepEmpty
func (m *matcher) stepEmpty(runq, nextq *sparse.Set, flag syntax.EmptyOp) { nextq.Reset() for _, id := range runq.Dense() { m.addq(nextq, id, flag) } }
go
func (m *matcher) stepEmpty(runq, nextq *sparse.Set, flag syntax.EmptyOp) { nextq.Reset() for _, id := range runq.Dense() { m.addq(nextq, id, flag) } }
[ "func", "(", "m", "*", "matcher", ")", "stepEmpty", "(", "runq", ",", "nextq", "*", "sparse", ".", "Set", ",", "flag", "syntax", ".", "EmptyOp", ")", "{", "nextq", ".", "Reset", "(", ")", "\n", "for", "_", ",", "id", ":=", "range", "runq", ".", ...
// stepEmpty steps runq to nextq expanding according to flag.
[ "stepEmpty", "steps", "runq", "to", "nextq", "expanding", "according", "to", "flag", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/regexp/match.go#L148-L153
29,343
google/codesearch
regexp/match.go
stepByte
func (m *matcher) stepByte(runq, nextq *sparse.Set, c int, flag syntax.EmptyOp) (match bool) { nextq.Reset() m.addq(nextq, uint32(m.prog.Start), flag) for _, id := range runq.Dense() { i := &m.prog.Inst[id] switch i.Op { default: continue case syntax.InstMatch: match = true continue case instByteR...
go
func (m *matcher) stepByte(runq, nextq *sparse.Set, c int, flag syntax.EmptyOp) (match bool) { nextq.Reset() m.addq(nextq, uint32(m.prog.Start), flag) for _, id := range runq.Dense() { i := &m.prog.Inst[id] switch i.Op { default: continue case syntax.InstMatch: match = true continue case instByteR...
[ "func", "(", "m", "*", "matcher", ")", "stepByte", "(", "runq", ",", "nextq", "*", "sparse", ".", "Set", ",", "c", "int", ",", "flag", "syntax", ".", "EmptyOp", ")", "(", "match", "bool", ")", "{", "nextq", ".", "Reset", "(", ")", "\n", "m", "....
// stepByte steps runq to nextq consuming c and then expanding according to flag. // It returns true if a match ends immediately before c. // c is either an input byte or endText.
[ "stepByte", "steps", "runq", "to", "nextq", "consuming", "c", "and", "then", "expanding", "according", "to", "flag", ".", "It", "returns", "true", "if", "a", "match", "ends", "immediately", "before", "c", ".", "c", "is", "either", "an", "input", "byte", ...
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/regexp/match.go#L158-L185
29,344
google/codesearch
regexp/match.go
addq
func (m *matcher) addq(q *sparse.Set, id uint32, flag syntax.EmptyOp) { if q.Has(id) { return } q.Add(id) i := &m.prog.Inst[id] switch i.Op { case syntax.InstCapture, syntax.InstNop: m.addq(q, i.Out, flag) case syntax.InstAlt, syntax.InstAltMatch: m.addq(q, i.Out, flag) m.addq(q, i.Arg, flag) case synta...
go
func (m *matcher) addq(q *sparse.Set, id uint32, flag syntax.EmptyOp) { if q.Has(id) { return } q.Add(id) i := &m.prog.Inst[id] switch i.Op { case syntax.InstCapture, syntax.InstNop: m.addq(q, i.Out, flag) case syntax.InstAlt, syntax.InstAltMatch: m.addq(q, i.Out, flag) m.addq(q, i.Arg, flag) case synta...
[ "func", "(", "m", "*", "matcher", ")", "addq", "(", "q", "*", "sparse", ".", "Set", ",", "id", "uint32", ",", "flag", "syntax", ".", "EmptyOp", ")", "{", "if", "q", ".", "Has", "(", "id", ")", "{", "return", "\n", "}", "\n", "q", ".", "Add", ...
// addq adds id to the queue, expanding according to flag.
[ "addq", "adds", "id", "to", "the", "queue", "expanding", "according", "to", "flag", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/regexp/match.go#L188-L205
29,345
google/codesearch
index/read.go
slice
func (ix *Index) slice(off uint32, n int) []byte { o := int(off) if uint32(o) != off || n >= 0 && o+n > len(ix.data.d) { corrupt() } if n < 0 { return ix.data.d[o:] } return ix.data.d[o : o+n] }
go
func (ix *Index) slice(off uint32, n int) []byte { o := int(off) if uint32(o) != off || n >= 0 && o+n > len(ix.data.d) { corrupt() } if n < 0 { return ix.data.d[o:] } return ix.data.d[o : o+n] }
[ "func", "(", "ix", "*", "Index", ")", "slice", "(", "off", "uint32", ",", "n", "int", ")", "[", "]", "byte", "{", "o", ":=", "int", "(", "off", ")", "\n", "if", "uint32", "(", "o", ")", "!=", "off", "||", "n", ">=", "0", "&&", "o", "+", "...
// slice returns the slice of index data starting at the given byte offset. // If n >= 0, the slice must have length at least n and is truncated to length n.
[ "slice", "returns", "the", "slice", "of", "index", "data", "starting", "at", "the", "given", "byte", "offset", ".", "If", "n", ">", "=", "0", "the", "slice", "must", "have", "length", "at", "least", "n", "and", "is", "truncated", "to", "length", "n", ...
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/read.go#L116-L125
29,346
google/codesearch
index/read.go
uint32
func (ix *Index) uint32(off uint32) uint32 { return binary.BigEndian.Uint32(ix.slice(off, 4)) }
go
func (ix *Index) uint32(off uint32) uint32 { return binary.BigEndian.Uint32(ix.slice(off, 4)) }
[ "func", "(", "ix", "*", "Index", ")", "uint32", "(", "off", "uint32", ")", "uint32", "{", "return", "binary", ".", "BigEndian", ".", "Uint32", "(", "ix", ".", "slice", "(", "off", ",", "4", ")", ")", "\n", "}" ]
// uint32 returns the uint32 value at the given offset in the index data.
[ "uint32", "returns", "the", "uint32", "value", "at", "the", "given", "offset", "in", "the", "index", "data", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/read.go#L128-L130
29,347
google/codesearch
index/read.go
uvarint
func (ix *Index) uvarint(off uint32) uint32 { v, n := binary.Uvarint(ix.slice(off, -1)) if n <= 0 { corrupt() } return uint32(v) }
go
func (ix *Index) uvarint(off uint32) uint32 { v, n := binary.Uvarint(ix.slice(off, -1)) if n <= 0 { corrupt() } return uint32(v) }
[ "func", "(", "ix", "*", "Index", ")", "uvarint", "(", "off", "uint32", ")", "uint32", "{", "v", ",", "n", ":=", "binary", ".", "Uvarint", "(", "ix", ".", "slice", "(", "off", ",", "-", "1", ")", ")", "\n", "if", "n", "<=", "0", "{", "corrupt"...
// uvarint returns the varint value at the given offset in the index data.
[ "uvarint", "returns", "the", "varint", "value", "at", "the", "given", "offset", "in", "the", "index", "data", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/read.go#L133-L139
29,348
google/codesearch
index/read.go
Paths
func (ix *Index) Paths() []string { off := ix.pathData var x []string for { s := ix.str(off) if len(s) == 0 { break } x = append(x, string(s)) off += uint32(len(s) + 1) } return x }
go
func (ix *Index) Paths() []string { off := ix.pathData var x []string for { s := ix.str(off) if len(s) == 0 { break } x = append(x, string(s)) off += uint32(len(s) + 1) } return x }
[ "func", "(", "ix", "*", "Index", ")", "Paths", "(", ")", "[", "]", "string", "{", "off", ":=", "ix", ".", "pathData", "\n", "var", "x", "[", "]", "string", "\n", "for", "{", "s", ":=", "ix", ".", "str", "(", "off", ")", "\n", "if", "len", "...
// Paths returns the list of indexed paths.
[ "Paths", "returns", "the", "list", "of", "indexed", "paths", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/read.go#L142-L154
29,349
google/codesearch
index/read.go
NameBytes
func (ix *Index) NameBytes(fileid uint32) []byte { off := ix.uint32(ix.nameIndex + 4*fileid) return ix.str(ix.nameData + off) }
go
func (ix *Index) NameBytes(fileid uint32) []byte { off := ix.uint32(ix.nameIndex + 4*fileid) return ix.str(ix.nameData + off) }
[ "func", "(", "ix", "*", "Index", ")", "NameBytes", "(", "fileid", "uint32", ")", "[", "]", "byte", "{", "off", ":=", "ix", ".", "uint32", "(", "ix", ".", "nameIndex", "+", "4", "*", "fileid", ")", "\n", "return", "ix", ".", "str", "(", "ix", "....
// NameBytes returns the name corresponding to the given fileid.
[ "NameBytes", "returns", "the", "name", "corresponding", "to", "the", "given", "fileid", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/read.go#L157-L160
29,350
google/codesearch
index/read.go
Name
func (ix *Index) Name(fileid uint32) string { return string(ix.NameBytes(fileid)) }
go
func (ix *Index) Name(fileid uint32) string { return string(ix.NameBytes(fileid)) }
[ "func", "(", "ix", "*", "Index", ")", "Name", "(", "fileid", "uint32", ")", "string", "{", "return", "string", "(", "ix", ".", "NameBytes", "(", "fileid", ")", ")", "\n", "}" ]
// Name returns the name corresponding to the given fileid.
[ "Name", "returns", "the", "name", "corresponding", "to", "the", "given", "fileid", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/read.go#L172-L174
29,351
google/codesearch
index/read.go
listAt
func (ix *Index) listAt(off uint32) (trigram, count, offset uint32) { d := ix.slice(ix.postIndex+off, postEntrySize) trigram = uint32(d[0])<<16 | uint32(d[1])<<8 | uint32(d[2]) count = binary.BigEndian.Uint32(d[3:]) offset = binary.BigEndian.Uint32(d[3+4:]) return }
go
func (ix *Index) listAt(off uint32) (trigram, count, offset uint32) { d := ix.slice(ix.postIndex+off, postEntrySize) trigram = uint32(d[0])<<16 | uint32(d[1])<<8 | uint32(d[2]) count = binary.BigEndian.Uint32(d[3:]) offset = binary.BigEndian.Uint32(d[3+4:]) return }
[ "func", "(", "ix", "*", "Index", ")", "listAt", "(", "off", "uint32", ")", "(", "trigram", ",", "count", ",", "offset", "uint32", ")", "{", "d", ":=", "ix", ".", "slice", "(", "ix", ".", "postIndex", "+", "off", ",", "postEntrySize", ")", "\n", "...
// listAt returns the index list entry at the given offset.
[ "listAt", "returns", "the", "index", "list", "entry", "at", "the", "given", "offset", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/read.go#L177-L183
29,352
google/codesearch
index/read.go
mmap
func mmap(file string) mmapData { f, err := os.Open(file) if err != nil { log.Fatal(err) } return mmapFile(f) }
go
func mmap(file string) mmapData { f, err := os.Open(file) if err != nil { log.Fatal(err) } return mmapFile(f) }
[ "func", "mmap", "(", "file", "string", ")", "mmapData", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "file", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatal", "(", "err", ")", "\n", "}", "\n", "return", "mmapFile", "(", "f",...
// mmap maps the given file into memory.
[ "mmap", "maps", "the", "given", "file", "into", "memory", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/read.go#L421-L427
29,353
google/codesearch
index/write.go
Create
func Create(file string) *IndexWriter { return &IndexWriter{ trigram: sparse.NewSet(1 << 24), nameData: bufCreate(""), nameIndex: bufCreate(""), postIndex: bufCreate(""), main: bufCreate(file), post: make([]postEntry, 0, npost), inbuf: make([]byte, 16384), } }
go
func Create(file string) *IndexWriter { return &IndexWriter{ trigram: sparse.NewSet(1 << 24), nameData: bufCreate(""), nameIndex: bufCreate(""), postIndex: bufCreate(""), main: bufCreate(file), post: make([]postEntry, 0, npost), inbuf: make([]byte, 16384), } }
[ "func", "Create", "(", "file", "string", ")", "*", "IndexWriter", "{", "return", "&", "IndexWriter", "{", "trigram", ":", "sparse", ".", "NewSet", "(", "1", "<<", "24", ")", ",", "nameData", ":", "bufCreate", "(", "\"", "\"", ")", ",", "nameIndex", "...
// Create returns a new IndexWriter that will write the index to file.
[ "Create", "returns", "a", "new", "IndexWriter", "that", "will", "write", "the", "index", "to", "file", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/write.go#L61-L71
29,354
google/codesearch
index/write.go
AddPaths
func (ix *IndexWriter) AddPaths(paths []string) { ix.paths = append(ix.paths, paths...) }
go
func (ix *IndexWriter) AddPaths(paths []string) { ix.paths = append(ix.paths, paths...) }
[ "func", "(", "ix", "*", "IndexWriter", ")", "AddPaths", "(", "paths", "[", "]", "string", ")", "{", "ix", ".", "paths", "=", "append", "(", "ix", ".", "paths", ",", "paths", "...", ")", "\n", "}" ]
// AddPaths adds the given paths to the index's list of paths.
[ "AddPaths", "adds", "the", "given", "paths", "to", "the", "index", "s", "list", "of", "paths", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/write.go#L100-L102
29,355
google/codesearch
index/write.go
Add
func (ix *IndexWriter) Add(name string, f io.Reader) { ix.trigram.Reset() var ( c = byte(0) i = 0 buf = ix.inbuf[:0] tv = uint32(0) n = int64(0) linelen = 0 ) for { tv = (tv << 8) & (1<<24 - 1) if i >= len(buf) { n, err := f.Read(buf[:cap(buf)]) if n == 0 { if er...
go
func (ix *IndexWriter) Add(name string, f io.Reader) { ix.trigram.Reset() var ( c = byte(0) i = 0 buf = ix.inbuf[:0] tv = uint32(0) n = int64(0) linelen = 0 ) for { tv = (tv << 8) & (1<<24 - 1) if i >= len(buf) { n, err := f.Read(buf[:cap(buf)]) if n == 0 { if er...
[ "func", "(", "ix", "*", "IndexWriter", ")", "Add", "(", "name", "string", ",", "f", "io", ".", "Reader", ")", "{", "ix", ".", "trigram", ".", "Reset", "(", ")", "\n", "var", "(", "c", "=", "byte", "(", "0", ")", "\n", "i", "=", "0", "\n", "...
// Add adds the file f to the index under the given name. // It logs errors using package log.
[ "Add", "adds", "the", "file", "f", "to", "the", "index", "under", "the", "given", "name", ".", "It", "logs", "errors", "using", "package", "log", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/write.go#L118-L193
29,356
google/codesearch
index/write.go
Flush
func (ix *IndexWriter) Flush() { ix.addName("") var off [5]uint32 ix.main.writeString(magic) off[0] = ix.main.offset() for _, p := range ix.paths { ix.main.writeString(p) ix.main.writeString("\x00") } ix.main.writeString("\x00") off[1] = ix.main.offset() copyFile(ix.main, ix.nameData) off[2] = ix.main.of...
go
func (ix *IndexWriter) Flush() { ix.addName("") var off [5]uint32 ix.main.writeString(magic) off[0] = ix.main.offset() for _, p := range ix.paths { ix.main.writeString(p) ix.main.writeString("\x00") } ix.main.writeString("\x00") off[1] = ix.main.offset() copyFile(ix.main, ix.nameData) off[2] = ix.main.of...
[ "func", "(", "ix", "*", "IndexWriter", ")", "Flush", "(", ")", "{", "ix", ".", "addName", "(", "\"", "\"", ")", "\n\n", "var", "off", "[", "5", "]", "uint32", "\n", "ix", ".", "main", ".", "writeString", "(", "magic", ")", "\n", "off", "[", "0"...
// Flush flushes the index entry to the target file.
[ "Flush", "flushes", "the", "index", "entry", "to", "the", "target", "file", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/write.go#L196-L230
29,357
google/codesearch
index/write.go
addName
func (ix *IndexWriter) addName(name string) uint32 { if strings.Contains(name, "\x00") { log.Fatalf("%q: file has NUL byte in name", name) } ix.nameIndex.writeUint32(ix.nameData.offset()) ix.nameData.writeString(name) ix.nameData.writeByte(0) id := ix.numName ix.numName++ return uint32(id) }
go
func (ix *IndexWriter) addName(name string) uint32 { if strings.Contains(name, "\x00") { log.Fatalf("%q: file has NUL byte in name", name) } ix.nameIndex.writeUint32(ix.nameData.offset()) ix.nameData.writeString(name) ix.nameData.writeByte(0) id := ix.numName ix.numName++ return uint32(id) }
[ "func", "(", "ix", "*", "IndexWriter", ")", "addName", "(", "name", "string", ")", "uint32", "{", "if", "strings", ".", "Contains", "(", "name", ",", "\"", "\\x00", "\"", ")", "{", "log", ".", "Fatalf", "(", "\"", "\"", ",", "name", ")", "\n", "}...
// addName adds the file with the given name to the index. // It returns the assigned file ID number.
[ "addName", "adds", "the", "file", "with", "the", "given", "name", "to", "the", "index", ".", "It", "returns", "the", "assigned", "file", "ID", "number", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/write.go#L242-L253
29,358
google/codesearch
index/write.go
flushPost
func (ix *IndexWriter) flushPost() { w, err := ioutil.TempFile("", "csearch-index") if err != nil { log.Fatal(err) } if ix.Verbose { log.Printf("flush %d entries to %s", len(ix.post), w.Name()) } sortPost(ix.post) // Write the raw ix.post array to disk as is. // This process is the one reading it back in, ...
go
func (ix *IndexWriter) flushPost() { w, err := ioutil.TempFile("", "csearch-index") if err != nil { log.Fatal(err) } if ix.Verbose { log.Printf("flush %d entries to %s", len(ix.post), w.Name()) } sortPost(ix.post) // Write the raw ix.post array to disk as is. // This process is the one reading it back in, ...
[ "func", "(", "ix", "*", "IndexWriter", ")", "flushPost", "(", ")", "{", "w", ",", "err", ":=", "ioutil", ".", "TempFile", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatal", "(", "err", ")", "\n", ...
// flushPost writes ix.post to a new temporary file and // clears the slice.
[ "flushPost", "writes", "ix", ".", "post", "to", "a", "new", "temporary", "file", "and", "clears", "the", "slice", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/write.go#L257-L280
29,359
google/codesearch
index/write.go
mergePost
func (ix *IndexWriter) mergePost(out *bufWriter) { var h postHeap log.Printf("merge %d files + mem", len(ix.postFile)) for _, f := range ix.postFile { h.addFile(f) } sortPost(ix.post) h.addMem(ix.post) npost := 0 e := h.next() offset0 := out.offset() for { npost++ offset := out.offset() - offset0 tr...
go
func (ix *IndexWriter) mergePost(out *bufWriter) { var h postHeap log.Printf("merge %d files + mem", len(ix.postFile)) for _, f := range ix.postFile { h.addFile(f) } sortPost(ix.post) h.addMem(ix.post) npost := 0 e := h.next() offset0 := out.offset() for { npost++ offset := out.offset() - offset0 tr...
[ "func", "(", "ix", "*", "IndexWriter", ")", "mergePost", "(", "out", "*", "bufWriter", ")", "{", "var", "h", "postHeap", "\n\n", "log", ".", "Printf", "(", "\"", "\"", ",", "len", "(", "ix", ".", "postFile", ")", ")", "\n", "for", "_", ",", "f", ...
// mergePost reads the flushed index entries and merges them // into posting lists, writing the resulting lists to out.
[ "mergePost", "reads", "the", "flushed", "index", "entries", "and", "merges", "them", "into", "posting", "lists", "writing", "the", "resulting", "lists", "to", "out", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/write.go#L284-L325
29,360
google/codesearch
index/write.go
step
func (h *postHeap) step(ch *postChunk) bool { old := ch.e m := ch.m if len(m) == 0 { return false } ch.e = postEntry(m[0]) m = m[1:] ch.m = m if old >= ch.e { panic("bad sort") } return true }
go
func (h *postHeap) step(ch *postChunk) bool { old := ch.e m := ch.m if len(m) == 0 { return false } ch.e = postEntry(m[0]) m = m[1:] ch.m = m if old >= ch.e { panic("bad sort") } return true }
[ "func", "(", "h", "*", "postHeap", ")", "step", "(", "ch", "*", "postChunk", ")", "bool", "{", "old", ":=", "ch", ".", "e", "\n", "m", ":=", "ch", ".", "m", "\n", "if", "len", "(", "m", ")", "==", "0", "{", "return", "false", "\n", "}", "\n...
// step reads the next entry from ch and saves it in ch.e. // It returns false if ch is over.
[ "step", "reads", "the", "next", "entry", "from", "ch", "and", "saves", "it", "in", "ch", ".", "e", ".", "It", "returns", "false", "if", "ch", "is", "over", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/write.go#L353-L366
29,361
google/codesearch
index/write.go
add
func (h *postHeap) add(ch *postChunk) { if len(ch.m) > 0 { ch.e = ch.m[0] ch.m = ch.m[1:] h.push(ch) } }
go
func (h *postHeap) add(ch *postChunk) { if len(ch.m) > 0 { ch.e = ch.m[0] ch.m = ch.m[1:] h.push(ch) } }
[ "func", "(", "h", "*", "postHeap", ")", "add", "(", "ch", "*", "postChunk", ")", "{", "if", "len", "(", "ch", ".", "m", ")", ">", "0", "{", "ch", ".", "e", "=", "ch", ".", "m", "[", "0", "]", "\n", "ch", ".", "m", "=", "ch", ".", "m", ...
// add adds the chunk to the postHeap. // All adds must be called before the first call to next.
[ "add", "adds", "the", "chunk", "to", "the", "postHeap", ".", "All", "adds", "must", "be", "called", "before", "the", "first", "call", "to", "next", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/write.go#L370-L376
29,362
google/codesearch
index/write.go
next
func (h *postHeap) next() postEntry { if len(h.ch) == 0 { return makePostEntry(1<<24-1, 0) } ch := h.ch[0] e := ch.e m := ch.m if len(m) == 0 { h.pop() } else { ch.e = m[0] ch.m = m[1:] h.siftDown(0) } return e }
go
func (h *postHeap) next() postEntry { if len(h.ch) == 0 { return makePostEntry(1<<24-1, 0) } ch := h.ch[0] e := ch.e m := ch.m if len(m) == 0 { h.pop() } else { ch.e = m[0] ch.m = m[1:] h.siftDown(0) } return e }
[ "func", "(", "h", "*", "postHeap", ")", "next", "(", ")", "postEntry", "{", "if", "len", "(", "h", ".", "ch", ")", "==", "0", "{", "return", "makePostEntry", "(", "1", "<<", "24", "-", "1", ",", "0", ")", "\n", "}", "\n", "ch", ":=", "h", "...
// next returns the next entry from the postHeap. // It returns a postEntry with trigram == 1<<24 - 1 if h is empty.
[ "next", "returns", "the", "next", "entry", "from", "the", "postHeap", ".", "It", "returns", "a", "postEntry", "with", "trigram", "==", "1<<24", "-", "1", "if", "h", "is", "empty", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/write.go#L385-L400
29,363
google/codesearch
index/write.go
bufCreate
func bufCreate(name string) *bufWriter { var ( f *os.File err error ) if name != "" { f, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) } else { f, err = ioutil.TempFile("", "csearch") } if err != nil { log.Fatal(err) } return &bufWriter{ name: f.Name(), buf: make([]byte, 0, 25...
go
func bufCreate(name string) *bufWriter { var ( f *os.File err error ) if name != "" { f, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) } else { f, err = ioutil.TempFile("", "csearch") } if err != nil { log.Fatal(err) } return &bufWriter{ name: f.Name(), buf: make([]byte, 0, 25...
[ "func", "bufCreate", "(", "name", "string", ")", "*", "bufWriter", "{", "var", "(", "f", "*", "os", ".", "File", "\n", "err", "error", "\n", ")", "\n", "if", "name", "!=", "\"", "\"", "{", "f", ",", "err", "=", "os", ".", "OpenFile", "(", "name...
// bufCreate creates a new file with the given name and returns a // corresponding bufWriter. If name is empty, bufCreate uses a // temporary file.
[ "bufCreate", "creates", "a", "new", "file", "with", "the", "given", "name", "and", "returns", "a", "corresponding", "bufWriter", ".", "If", "name", "is", "empty", "bufCreate", "uses", "a", "temporary", "file", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/write.go#L463-L481
29,364
google/codesearch
index/write.go
offset
func (b *bufWriter) offset() uint32 { off, _ := b.file.Seek(0, 1) off += int64(len(b.buf)) if int64(uint32(off)) != off { log.Fatalf("index is larger than 4GB") } return uint32(off) }
go
func (b *bufWriter) offset() uint32 { off, _ := b.file.Seek(0, 1) off += int64(len(b.buf)) if int64(uint32(off)) != off { log.Fatalf("index is larger than 4GB") } return uint32(off) }
[ "func", "(", "b", "*", "bufWriter", ")", "offset", "(", ")", "uint32", "{", "off", ",", "_", ":=", "b", ".", "file", ".", "Seek", "(", "0", ",", "1", ")", "\n", "off", "+=", "int64", "(", "len", "(", "b", ".", "buf", ")", ")", "\n", "if", ...
// offset returns the current write offset.
[ "offset", "returns", "the", "current", "write", "offset", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/write.go#L519-L526
29,365
google/codesearch
index/write.go
finish
func (b *bufWriter) finish() *os.File { b.flush() f := b.file f.Seek(0, 0) return f }
go
func (b *bufWriter) finish() *os.File { b.flush() f := b.file f.Seek(0, 0) return f }
[ "func", "(", "b", "*", "bufWriter", ")", "finish", "(", ")", "*", "os", ".", "File", "{", "b", ".", "flush", "(", ")", "\n", "f", ":=", "b", ".", "file", "\n", "f", ".", "Seek", "(", "0", ",", "0", ")", "\n", "return", "f", "\n", "}" ]
// finish flushes the file to disk and returns an open file ready for reading.
[ "finish", "flushes", "the", "file", "to", "disk", "and", "returns", "an", "open", "file", "ready", "for", "reading", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/write.go#L540-L545
29,366
google/codesearch
index/write.go
validUTF8
func validUTF8(c1, c2 uint32) bool { switch { case c1 < 0x80: // 1-byte, must be followed by 1-byte or first of multi-byte return c2 < 0x80 || 0xc0 <= c2 && c2 < 0xf8 case c1 < 0xc0: // continuation byte, can be followed by nearly anything return c2 < 0xf8 case c1 < 0xf8: // first of multi-byte, must be f...
go
func validUTF8(c1, c2 uint32) bool { switch { case c1 < 0x80: // 1-byte, must be followed by 1-byte or first of multi-byte return c2 < 0x80 || 0xc0 <= c2 && c2 < 0xf8 case c1 < 0xc0: // continuation byte, can be followed by nearly anything return c2 < 0xf8 case c1 < 0xf8: // first of multi-byte, must be f...
[ "func", "validUTF8", "(", "c1", ",", "c2", "uint32", ")", "bool", "{", "switch", "{", "case", "c1", "<", "0x80", ":", "// 1-byte, must be followed by 1-byte or first of multi-byte", "return", "c2", "<", "0x80", "||", "0xc0", "<=", "c2", "&&", "c2", "<", "0xf...
// validUTF8 reports whether the byte pair can appear in a // valid sequence of UTF-8-encoded code points.
[ "validUTF8", "reports", "whether", "the", "byte", "pair", "can", "appear", "in", "a", "valid", "sequence", "of", "UTF", "-", "8", "-", "encoded", "code", "points", "." ]
4fe90b597ae534f90238f82c7b5b1bb6d6d52dff
https://github.com/google/codesearch/blob/4fe90b597ae534f90238f82c7b5b1bb6d6d52dff/index/write.go#L581-L594
29,367
hyperledger/fabric-sdk-go
pkg/client/common/selection/dynamicselection/ccpolicyprovider.go
newCCPolicyProvider
func newCCPolicyProvider(ctx context.Client, discovery fab.DiscoveryService, channelID string) (CCPolicyProvider, error) { if channelID == "" { return nil, errors.New("Must provide channel ID for cc policy provider") } cpp := ccPolicyProvider{ context: ctx, channelID: channelID, discovery: discovery, cc...
go
func newCCPolicyProvider(ctx context.Client, discovery fab.DiscoveryService, channelID string) (CCPolicyProvider, error) { if channelID == "" { return nil, errors.New("Must provide channel ID for cc policy provider") } cpp := ccPolicyProvider{ context: ctx, channelID: channelID, discovery: discovery, cc...
[ "func", "newCCPolicyProvider", "(", "ctx", "context", ".", "Client", ",", "discovery", "fab", ".", "DiscoveryService", ",", "channelID", "string", ")", "(", "CCPolicyProvider", ",", "error", ")", "{", "if", "channelID", "==", "\"", "\"", "{", "return", "nil"...
// NewCCPolicyProvider creates new chaincode policy data provider
[ "NewCCPolicyProvider", "creates", "new", "chaincode", "policy", "data", "provider" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/client/common/selection/dynamicselection/ccpolicyprovider.go#L43-L56
29,368
hyperledger/fabric-sdk-go
pkg/fab/mocks/mockidentity.go
NewMockIdentity
func NewMockIdentity(err error) (msp.Identity, error) { return &MockIdentity{Err: err}, nil }
go
func NewMockIdentity(err error) (msp.Identity, error) { return &MockIdentity{Err: err}, nil }
[ "func", "NewMockIdentity", "(", "err", "error", ")", "(", "msp", ".", "Identity", ",", "error", ")", "{", "return", "&", "MockIdentity", "{", "Err", ":", "err", "}", ",", "nil", "\n", "}" ]
// NewMockIdentity creates new mock identity
[ "NewMockIdentity", "creates", "new", "mock", "identity" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/mocks/mockidentity.go#L24-L26
29,369
hyperledger/fabric-sdk-go
pkg/fab/mocks/mockidentity.go
Validate
func (id *MockIdentity) Validate() error { if id.Err != nil && id.Err.Error() == "Validate" { return id.Err } return nil }
go
func (id *MockIdentity) Validate() error { if id.Err != nil && id.Err.Error() == "Validate" { return id.Err } return nil }
[ "func", "(", "id", "*", "MockIdentity", ")", "Validate", "(", ")", "error", "{", "if", "id", ".", "Err", "!=", "nil", "&&", "id", ".", "Err", ".", "Error", "(", ")", "==", "\"", "\"", "{", "return", "id", ".", "Err", "\n", "}", "\n", "return", ...
// Validate returns nil if this instance is a valid identity or an error otherwise
[ "Validate", "returns", "nil", "if", "this", "instance", "is", "a", "valid", "identity", "or", "an", "error", "otherwise" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/mocks/mockidentity.go#L49-L54
29,370
hyperledger/fabric-sdk-go
pkg/fab/comm/streamconnection.go
NewStreamConnection
func NewStreamConnection(ctx fabcontext.Client, chConfig fab.ChannelCfg, streamProvider StreamProvider, url string, opts ...options.Opt) (*StreamConnection, error) { conn, err := NewConnection(ctx, url, opts...) if err != nil { return nil, err } stream, err := streamProvider(conn.conn) if err != nil { conn.co...
go
func NewStreamConnection(ctx fabcontext.Client, chConfig fab.ChannelCfg, streamProvider StreamProvider, url string, opts ...options.Opt) (*StreamConnection, error) { conn, err := NewConnection(ctx, url, opts...) if err != nil { return nil, err } stream, err := streamProvider(conn.conn) if err != nil { conn.co...
[ "func", "NewStreamConnection", "(", "ctx", "fabcontext", ".", "Client", ",", "chConfig", "fab", ".", "ChannelCfg", ",", "streamProvider", "StreamProvider", ",", "url", "string", ",", "opts", "...", "options", ".", "Opt", ")", "(", "*", "StreamConnection", ",",...
// NewStreamConnection creates a new connection with stream
[ "NewStreamConnection", "creates", "a", "new", "connection", "with", "stream" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/comm/streamconnection.go#L35-L74
29,371
hyperledger/fabric-sdk-go
pkg/fab/resource/config.go
CreateConfigSignature
func CreateConfigSignature(ctx context.Client, config []byte) (*common.ConfigSignature, error) { cfd, e := GetConfigSignatureData(ctx, config) if e != nil { return nil, e } signingMgr := ctx.SigningManager() signature, err := signingMgr.Sign(cfd.SigningBytes, ctx.PrivateKey()) if err != nil { return nil, err...
go
func CreateConfigSignature(ctx context.Client, config []byte) (*common.ConfigSignature, error) { cfd, e := GetConfigSignatureData(ctx, config) if e != nil { return nil, e } signingMgr := ctx.SigningManager() signature, err := signingMgr.Sign(cfd.SigningBytes, ctx.PrivateKey()) if err != nil { return nil, err...
[ "func", "CreateConfigSignature", "(", "ctx", "context", ".", "Client", ",", "config", "[", "]", "byte", ")", "(", "*", "common", ".", "ConfigSignature", ",", "error", ")", "{", "cfd", ",", "e", ":=", "GetConfigSignatureData", "(", "ctx", ",", "config", "...
// CreateConfigSignature creates a ConfigSignature for the current context
[ "CreateConfigSignature", "creates", "a", "ConfigSignature", "for", "the", "current", "context" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/resource/config.go#L20-L38
29,372
hyperledger/fabric-sdk-go
pkg/fab/resource/config.go
ExtractChannelConfig
func ExtractChannelConfig(configEnvelope []byte) ([]byte, error) { envelope := &common.Envelope{} err := proto.Unmarshal(configEnvelope, envelope) if err != nil { return nil, errors.Wrap(err, "unmarshal config envelope failed") } payload := &common.Payload{} err = proto.Unmarshal(envelope.Payload, payload) i...
go
func ExtractChannelConfig(configEnvelope []byte) ([]byte, error) { envelope := &common.Envelope{} err := proto.Unmarshal(configEnvelope, envelope) if err != nil { return nil, errors.Wrap(err, "unmarshal config envelope failed") } payload := &common.Payload{} err = proto.Unmarshal(envelope.Payload, payload) i...
[ "func", "ExtractChannelConfig", "(", "configEnvelope", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "envelope", ":=", "&", "common", ".", "Envelope", "{", "}", "\n", "err", ":=", "proto", ".", "Unmarshal", "(", "configEnvelope", ...
// ExtractChannelConfig extracts the protobuf 'ConfigUpdate' object out of the 'ConfigEnvelope'.
[ "ExtractChannelConfig", "extracts", "the", "protobuf", "ConfigUpdate", "object", "out", "of", "the", "ConfigEnvelope", "." ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/resource/config.go#L90-L111
29,373
hyperledger/fabric-sdk-go
pkg/fab/resource/config.go
CreateConfigEnvelope
func CreateConfigEnvelope(data []byte) (*common.ConfigEnvelope, error) { envelope := &common.Envelope{} if err := proto.Unmarshal(data, envelope); err != nil { return nil, errors.Wrap(err, "unmarshal envelope from config block failed") } payload := &common.Payload{} if err := proto.Unmarshal(envelope.Payload, p...
go
func CreateConfigEnvelope(data []byte) (*common.ConfigEnvelope, error) { envelope := &common.Envelope{} if err := proto.Unmarshal(data, envelope); err != nil { return nil, errors.Wrap(err, "unmarshal envelope from config block failed") } payload := &common.Payload{} if err := proto.Unmarshal(envelope.Payload, p...
[ "func", "CreateConfigEnvelope", "(", "data", "[", "]", "byte", ")", "(", "*", "common", ".", "ConfigEnvelope", ",", "error", ")", "{", "envelope", ":=", "&", "common", ".", "Envelope", "{", "}", "\n", "if", "err", ":=", "proto", ".", "Unmarshal", "(", ...
// CreateConfigEnvelope creates configuration envelope proto
[ "CreateConfigEnvelope", "creates", "configuration", "envelope", "proto" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/resource/config.go#L114-L137
29,374
hyperledger/fabric-sdk-go
pkg/fab/resource/config.go
GetLastConfigFromBlock
func GetLastConfigFromBlock(block *common.Block) (*common.LastConfig, error) { if block.Metadata == nil { return nil, errors.New("block metadata is nil") } metadata := &common.Metadata{} err := proto.Unmarshal(block.Metadata.Metadata[common.BlockMetadataIndex_LAST_CONFIG], metadata) if err != nil { return nil,...
go
func GetLastConfigFromBlock(block *common.Block) (*common.LastConfig, error) { if block.Metadata == nil { return nil, errors.New("block metadata is nil") } metadata := &common.Metadata{} err := proto.Unmarshal(block.Metadata.Metadata[common.BlockMetadataIndex_LAST_CONFIG], metadata) if err != nil { return nil,...
[ "func", "GetLastConfigFromBlock", "(", "block", "*", "common", ".", "Block", ")", "(", "*", "common", ".", "LastConfig", ",", "error", ")", "{", "if", "block", ".", "Metadata", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", ...
// GetLastConfigFromBlock returns the LastConfig data from the given block
[ "GetLastConfigFromBlock", "returns", "the", "LastConfig", "data", "from", "the", "given", "block" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/resource/config.go#L166-L183
29,375
hyperledger/fabric-sdk-go
pkg/core/cryptosuite/cryptoconfig.go
ConfigFromBackend
func ConfigFromBackend(coreBackend ...core.ConfigBackend) core.CryptoSuiteConfig { return &Config{backend: lookup.New(coreBackend...)} }
go
func ConfigFromBackend(coreBackend ...core.ConfigBackend) core.CryptoSuiteConfig { return &Config{backend: lookup.New(coreBackend...)} }
[ "func", "ConfigFromBackend", "(", "coreBackend", "...", "core", ".", "ConfigBackend", ")", "core", ".", "CryptoSuiteConfig", "{", "return", "&", "Config", "{", "backend", ":", "lookup", ".", "New", "(", "coreBackend", "...", ")", "}", "\n", "}" ]
//ConfigFromBackend returns CryptoSuite config implementation for given backend
[ "ConfigFromBackend", "returns", "CryptoSuite", "config", "implementation", "for", "given", "backend" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/core/cryptosuite/cryptoconfig.go#L29-L31
29,376
hyperledger/fabric-sdk-go
pkg/core/cryptosuite/cryptoconfig.go
IsSecurityEnabled
func (c *Config) IsSecurityEnabled() bool { val, ok := c.backend.Lookup("client.BCCSP.security.enabled") if !ok { return defEnabled } return cast.ToBool(val) }
go
func (c *Config) IsSecurityEnabled() bool { val, ok := c.backend.Lookup("client.BCCSP.security.enabled") if !ok { return defEnabled } return cast.ToBool(val) }
[ "func", "(", "c", "*", "Config", ")", "IsSecurityEnabled", "(", ")", "bool", "{", "val", ",", "ok", ":=", "c", ".", "backend", ".", "Lookup", "(", "\"", "\"", ")", "\n", "if", "!", "ok", "{", "return", "defEnabled", "\n", "}", "\n", "return", "ca...
// IsSecurityEnabled config used enable and disable security in cryptosuite
[ "IsSecurityEnabled", "config", "used", "enable", "and", "disable", "security", "in", "cryptosuite" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/core/cryptosuite/cryptoconfig.go#L39-L45
29,377
hyperledger/fabric-sdk-go
pkg/core/cryptosuite/cryptoconfig.go
SecurityAlgorithm
func (c *Config) SecurityAlgorithm() string { val, ok := c.backend.Lookup("client.BCCSP.security.hashAlgorithm") if !ok { return defHashAlgorithm } return cast.ToString(val) }
go
func (c *Config) SecurityAlgorithm() string { val, ok := c.backend.Lookup("client.BCCSP.security.hashAlgorithm") if !ok { return defHashAlgorithm } return cast.ToString(val) }
[ "func", "(", "c", "*", "Config", ")", "SecurityAlgorithm", "(", ")", "string", "{", "val", ",", "ok", ":=", "c", ".", "backend", ".", "Lookup", "(", "\"", "\"", ")", "\n", "if", "!", "ok", "{", "return", "defHashAlgorithm", "\n", "}", "\n", "return...
// SecurityAlgorithm returns cryptoSuite config hash algorithm
[ "SecurityAlgorithm", "returns", "cryptoSuite", "config", "hash", "algorithm" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/core/cryptosuite/cryptoconfig.go#L48-L54
29,378
hyperledger/fabric-sdk-go
pkg/core/cryptosuite/cryptoconfig.go
SecurityLevel
func (c *Config) SecurityLevel() int { val, ok := c.backend.Lookup("client.BCCSP.security.level") if !ok { return defLevel } return cast.ToInt(val) }
go
func (c *Config) SecurityLevel() int { val, ok := c.backend.Lookup("client.BCCSP.security.level") if !ok { return defLevel } return cast.ToInt(val) }
[ "func", "(", "c", "*", "Config", ")", "SecurityLevel", "(", ")", "int", "{", "val", ",", "ok", ":=", "c", ".", "backend", ".", "Lookup", "(", "\"", "\"", ")", "\n", "if", "!", "ok", "{", "return", "defLevel", "\n", "}", "\n", "return", "cast", ...
// SecurityLevel returns cryptSuite config security level
[ "SecurityLevel", "returns", "cryptSuite", "config", "security", "level" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/core/cryptosuite/cryptoconfig.go#L57-L63
29,379
hyperledger/fabric-sdk-go
pkg/core/cryptosuite/cryptoconfig.go
SecurityProvider
func (c *Config) SecurityProvider() string { val, ok := c.backend.Lookup("client.BCCSP.security.default.provider") if !ok { return strings.ToLower(defProvider) } return strings.ToLower(cast.ToString(val)) }
go
func (c *Config) SecurityProvider() string { val, ok := c.backend.Lookup("client.BCCSP.security.default.provider") if !ok { return strings.ToLower(defProvider) } return strings.ToLower(cast.ToString(val)) }
[ "func", "(", "c", "*", "Config", ")", "SecurityProvider", "(", ")", "string", "{", "val", ",", "ok", ":=", "c", ".", "backend", ".", "Lookup", "(", "\"", "\"", ")", "\n", "if", "!", "ok", "{", "return", "strings", ".", "ToLower", "(", "defProvider"...
//SecurityProvider provider SW or PKCS11
[ "SecurityProvider", "provider", "SW", "or", "PKCS11" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/core/cryptosuite/cryptoconfig.go#L66-L72
29,380
hyperledger/fabric-sdk-go
pkg/core/cryptosuite/cryptoconfig.go
SecurityProviderLibPath
func (c *Config) SecurityProviderLibPath() string { configuredLibs := c.backend.GetString("client.BCCSP.security.library") libPaths := strings.Split(configuredLibs, ",") logger.Debugf("Configured BCCSP Lib Paths %s", libPaths) var lib string for _, path := range libPaths { if _, err := os.Stat(strings.TrimSpace(...
go
func (c *Config) SecurityProviderLibPath() string { configuredLibs := c.backend.GetString("client.BCCSP.security.library") libPaths := strings.Split(configuredLibs, ",") logger.Debugf("Configured BCCSP Lib Paths %s", libPaths) var lib string for _, path := range libPaths { if _, err := os.Stat(strings.TrimSpace(...
[ "func", "(", "c", "*", "Config", ")", "SecurityProviderLibPath", "(", ")", "string", "{", "configuredLibs", ":=", "c", ".", "backend", ".", "GetString", "(", "\"", "\"", ")", "\n", "libPaths", ":=", "strings", ".", "Split", "(", "configuredLibs", ",", "\...
//SecurityProviderLibPath will be set only if provider is PKCS11
[ "SecurityProviderLibPath", "will", "be", "set", "only", "if", "provider", "is", "PKCS11" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/core/cryptosuite/cryptoconfig.go#L84-L101
29,381
hyperledger/fabric-sdk-go
pkg/core/cryptosuite/cryptoconfig.go
KeyStorePath
func (c *Config) KeyStorePath() string { keystorePath := pathvar.Subst(c.backend.GetString("client.credentialStore.cryptoStore.path")) return filepath.Join(keystorePath, "keystore") }
go
func (c *Config) KeyStorePath() string { keystorePath := pathvar.Subst(c.backend.GetString("client.credentialStore.cryptoStore.path")) return filepath.Join(keystorePath, "keystore") }
[ "func", "(", "c", "*", "Config", ")", "KeyStorePath", "(", ")", "string", "{", "keystorePath", ":=", "pathvar", ".", "Subst", "(", "c", ".", "backend", ".", "GetString", "(", "\"", "\"", ")", ")", "\n", "return", "filepath", ".", "Join", "(", "keysto...
// KeyStorePath returns the keystore path used by BCCSP
[ "KeyStorePath", "returns", "the", "keystore", "path", "used", "by", "BCCSP" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/core/cryptosuite/cryptoconfig.go#L114-L117
29,382
hyperledger/fabric-sdk-go
pkg/client/common/discovery/discoveryfilter.go
NewDiscoveryFilterService
func NewDiscoveryFilterService(discoveryService fab.DiscoveryService, targetFilter fab.TargetFilter) fab.DiscoveryService { return &filterService{discoveryService: discoveryService, targetFilter: targetFilter} }
go
func NewDiscoveryFilterService(discoveryService fab.DiscoveryService, targetFilter fab.TargetFilter) fab.DiscoveryService { return &filterService{discoveryService: discoveryService, targetFilter: targetFilter} }
[ "func", "NewDiscoveryFilterService", "(", "discoveryService", "fab", ".", "DiscoveryService", ",", "targetFilter", "fab", ".", "TargetFilter", ")", "fab", ".", "DiscoveryService", "{", "return", "&", "filterService", "{", "discoveryService", ":", "discoveryService", "...
// NewDiscoveryFilterService return discovery service with filter
[ "NewDiscoveryFilterService", "return", "discovery", "service", "with", "filter" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/client/common/discovery/discoveryfilter.go#L20-L22
29,383
hyperledger/fabric-sdk-go
pkg/client/common/discovery/discoveryfilter.go
GetPeers
func (fs *filterService) GetPeers() ([]fab.Peer, error) { peers, err := fs.discoveryService.GetPeers() if err != nil { return nil, err } targets := filterTargets(peers, fs.targetFilter) return targets, nil }
go
func (fs *filterService) GetPeers() ([]fab.Peer, error) { peers, err := fs.discoveryService.GetPeers() if err != nil { return nil, err } targets := filterTargets(peers, fs.targetFilter) return targets, nil }
[ "func", "(", "fs", "*", "filterService", ")", "GetPeers", "(", ")", "(", "[", "]", "fab", ".", "Peer", ",", "error", ")", "{", "peers", ",", "err", ":=", "fs", ".", "discoveryService", ".", "GetPeers", "(", ")", "\n", "if", "err", "!=", "nil", "{...
// GetPeers is used to get peers
[ "GetPeers", "is", "used", "to", "get", "peers" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/client/common/discovery/discoveryfilter.go#L25-L32
29,384
hyperledger/fabric-sdk-go
pkg/client/common/discovery/discoveryfilter.go
filterTargets
func filterTargets(peers []fab.Peer, filter fab.TargetFilter) []fab.Peer { if filter == nil { return peers } filteredPeers := []fab.Peer{} for _, peer := range peers { if filter.Accept(peer) { filteredPeers = append(filteredPeers, peer) } } return filteredPeers }
go
func filterTargets(peers []fab.Peer, filter fab.TargetFilter) []fab.Peer { if filter == nil { return peers } filteredPeers := []fab.Peer{} for _, peer := range peers { if filter.Accept(peer) { filteredPeers = append(filteredPeers, peer) } } return filteredPeers }
[ "func", "filterTargets", "(", "peers", "[", "]", "fab", ".", "Peer", ",", "filter", "fab", ".", "TargetFilter", ")", "[", "]", "fab", ".", "Peer", "{", "if", "filter", "==", "nil", "{", "return", "peers", "\n", "}", "\n\n", "filteredPeers", ":=", "["...
// filterTargets is helper method to filter peers
[ "filterTargets", "is", "helper", "method", "to", "filter", "peers" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/client/common/discovery/discoveryfilter.go#L35-L49
29,385
hyperledger/fabric-sdk-go
pkg/fab/mocks/mockchprovider.go
NewMockChannelProvider
func NewMockChannelProvider(ctx core.Providers) (*MockChannelProvider, error) { // Create a mock client with the mock channel cp := MockChannelProvider{ ctx: ctx, } return &cp, nil }
go
func NewMockChannelProvider(ctx core.Providers) (*MockChannelProvider, error) { // Create a mock client with the mock channel cp := MockChannelProvider{ ctx: ctx, } return &cp, nil }
[ "func", "NewMockChannelProvider", "(", "ctx", "core", ".", "Providers", ")", "(", "*", "MockChannelProvider", ",", "error", ")", "{", "// Create a mock client with the mock channel", "cp", ":=", "MockChannelProvider", "{", "ctx", ":", "ctx", ",", "}", "\n", "retur...
// NewMockChannelProvider returns a mock ChannelProvider
[ "NewMockChannelProvider", "returns", "a", "mock", "ChannelProvider" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/mocks/mockchprovider.go#L35-L41
29,386
hyperledger/fabric-sdk-go
pkg/fab/mocks/mockchprovider.go
ChannelService
func (cp *MockChannelProvider) ChannelService(ctx fab.ClientContext, channelID string) (fab.ChannelService, error) { if cp.customChannelService != nil { return cp.customChannelService, nil } cs := MockChannelService{ provider: cp, channelID: channelID, transactor: &MockTransactor{}, discovery: NewMoc...
go
func (cp *MockChannelProvider) ChannelService(ctx fab.ClientContext, channelID string) (fab.ChannelService, error) { if cp.customChannelService != nil { return cp.customChannelService, nil } cs := MockChannelService{ provider: cp, channelID: channelID, transactor: &MockTransactor{}, discovery: NewMoc...
[ "func", "(", "cp", "*", "MockChannelProvider", ")", "ChannelService", "(", "ctx", "fab", ".", "ClientContext", ",", "channelID", "string", ")", "(", "fab", ".", "ChannelService", ",", "error", ")", "{", "if", "cp", ".", "customChannelService", "!=", "nil", ...
// ChannelService returns a mock ChannelService
[ "ChannelService", "returns", "a", "mock", "ChannelService" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/mocks/mockchprovider.go#L44-L58
29,387
hyperledger/fabric-sdk-go
pkg/fab/mocks/mockchprovider.go
EventService
func (cs *MockChannelService) EventService(opts ...options.Opt) (fab.EventService, error) { return NewMockEventService(), nil }
go
func (cs *MockChannelService) EventService(opts ...options.Opt) (fab.EventService, error) { return NewMockEventService(), nil }
[ "func", "(", "cs", "*", "MockChannelService", ")", "EventService", "(", "opts", "...", "options", ".", "Opt", ")", "(", "fab", ".", "EventService", ",", "error", ")", "{", "return", "NewMockEventService", "(", ")", ",", "nil", "\n", "}" ]
// EventService returns a mock event service
[ "EventService", "returns", "a", "mock", "event", "service" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/mocks/mockchprovider.go#L71-L73
29,388
hyperledger/fabric-sdk-go
pkg/fab/mocks/mockchprovider.go
Transactor
func (cs *MockChannelService) Transactor(reqCtx reqContext.Context) (fab.Transactor, error) { if cs.transactor != nil { return cs.transactor, nil } return &MockTransactor{ChannelID: cs.channelID, Ctx: reqCtx}, nil }
go
func (cs *MockChannelService) Transactor(reqCtx reqContext.Context) (fab.Transactor, error) { if cs.transactor != nil { return cs.transactor, nil } return &MockTransactor{ChannelID: cs.channelID, Ctx: reqCtx}, nil }
[ "func", "(", "cs", "*", "MockChannelService", ")", "Transactor", "(", "reqCtx", "reqContext", ".", "Context", ")", "(", "fab", ".", "Transactor", ",", "error", ")", "{", "if", "cs", ".", "transactor", "!=", "nil", "{", "return", "cs", ".", "transactor", ...
// Transactor returns a mock transactor
[ "Transactor", "returns", "a", "mock", "transactor" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/mocks/mockchprovider.go#L81-L86
29,389
hyperledger/fabric-sdk-go
pkg/fab/mocks/mockchprovider.go
Membership
func (cs *MockChannelService) Membership() (fab.ChannelMembership, error) { if cs.membership != nil { return cs.membership, nil } return NewMockMembership(), nil }
go
func (cs *MockChannelService) Membership() (fab.ChannelMembership, error) { if cs.membership != nil { return cs.membership, nil } return NewMockMembership(), nil }
[ "func", "(", "cs", "*", "MockChannelService", ")", "Membership", "(", ")", "(", "fab", ".", "ChannelMembership", ",", "error", ")", "{", "if", "cs", ".", "membership", "!=", "nil", "{", "return", "cs", ".", "membership", ",", "nil", "\n", "}", "\n", ...
// Membership returns member identification
[ "Membership", "returns", "member", "identification" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/mocks/mockchprovider.go#L94-L99
29,390
hyperledger/fabric-sdk-go
pkg/fab/mocks/mockchprovider.go
ChannelConfig
func (cs *MockChannelService) ChannelConfig() (fab.ChannelCfg, error) { return &MockChannelCfg{MockID: cs.channelID, MockOrderers: cs.mockOrderers}, nil }
go
func (cs *MockChannelService) ChannelConfig() (fab.ChannelCfg, error) { return &MockChannelCfg{MockID: cs.channelID, MockOrderers: cs.mockOrderers}, nil }
[ "func", "(", "cs", "*", "MockChannelService", ")", "ChannelConfig", "(", ")", "(", "fab", ".", "ChannelCfg", ",", "error", ")", "{", "return", "&", "MockChannelCfg", "{", "MockID", ":", "cs", ".", "channelID", ",", "MockOrderers", ":", "cs", ".", "mockOr...
//ChannelConfig returns channel config
[ "ChannelConfig", "returns", "channel", "config" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/mocks/mockchprovider.go#L107-L109
29,391
hyperledger/fabric-sdk-go
pkg/fab/events/client/mocks/mockconnection.go
NewMockConnection
func NewMockConnection(opts ...Opt) *MockConnection { copts := &Opts{} for _, opt := range opts { opt(copts) } operations := copts.Operations if operations == nil { operations = make(map[Operation]ResultDesc) } if copts.Ledger == nil { panic("ledger is nil") } sourceURL := copts.SourceURL if sourceUR...
go
func NewMockConnection(opts ...Opt) *MockConnection { copts := &Opts{} for _, opt := range opts { opt(copts) } operations := copts.Operations if operations == nil { operations = make(map[Operation]ResultDesc) } if copts.Ledger == nil { panic("ledger is nil") } sourceURL := copts.SourceURL if sourceUR...
[ "func", "NewMockConnection", "(", "opts", "...", "Opt", ")", "*", "MockConnection", "{", "copts", ":=", "&", "Opts", "{", "}", "\n", "for", "_", ",", "opt", ":=", "range", "opts", "{", "opt", "(", "copts", ")", "\n", "}", "\n\n", "operations", ":=", ...
// NewMockConnection returns a new MockConnection using the given options
[ "NewMockConnection", "returns", "a", "new", "MockConnection", "using", "the", "given", "options" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/events/client/mocks/mockconnection.go#L108-L138
29,392
hyperledger/fabric-sdk-go
pkg/fab/events/client/mocks/mockconnection.go
Close
func (c *MockConnection) Close() { if !atomic.CompareAndSwapInt32(&c.closed, 0, 1) { // Already closed return } c.producer.Close() close(c.rcvch) }
go
func (c *MockConnection) Close() { if !atomic.CompareAndSwapInt32(&c.closed, 0, 1) { // Already closed return } c.producer.Close() close(c.rcvch) }
[ "func", "(", "c", "*", "MockConnection", ")", "Close", "(", ")", "{", "if", "!", "atomic", ".", "CompareAndSwapInt32", "(", "&", "c", ".", "closed", ",", "0", ",", "1", ")", "{", "// Already closed", "return", "\n", "}", "\n\n", "c", ".", "producer",...
// Close implements the MockConnection interface
[ "Close", "implements", "the", "MockConnection", "interface" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/events/client/mocks/mockconnection.go#L141-L149
29,393
hyperledger/fabric-sdk-go
pkg/fab/events/client/mocks/mockconnection.go
Result
func (c *MockConnection) Result(operation Operation) (ResultDesc, bool) { op, ok := c.operations[operation] return op, ok }
go
func (c *MockConnection) Result(operation Operation) (ResultDesc, bool) { op, ok := c.operations[operation] return op, ok }
[ "func", "(", "c", "*", "MockConnection", ")", "Result", "(", "operation", "Operation", ")", "(", "ResultDesc", ",", "bool", ")", "{", "op", ",", "ok", ":=", "c", ".", "operations", "[", "operation", "]", "\n", "return", "op", ",", "ok", "\n", "}" ]
// Result returns the result for the given operation
[ "Result", "returns", "the", "result", "for", "the", "given", "operation" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/events/client/mocks/mockconnection.go#L182-L185
29,394
hyperledger/fabric-sdk-go
pkg/fab/events/client/mocks/mockconnection.go
Connection
func (cp *ProviderFactory) Connection() Connection { cp.mtx.RLock() defer cp.mtx.RUnlock() return cp.connection }
go
func (cp *ProviderFactory) Connection() Connection { cp.mtx.RLock() defer cp.mtx.RUnlock() return cp.connection }
[ "func", "(", "cp", "*", "ProviderFactory", ")", "Connection", "(", ")", "Connection", "{", "cp", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cp", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "cp", ".", "connection", "\n", "}" ]
// Connection returns the connection
[ "Connection", "returns", "the", "connection" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/events/client/mocks/mockconnection.go#L209-L213
29,395
hyperledger/fabric-sdk-go
pkg/fab/events/client/mocks/mockconnection.go
Provider
func (cp *ProviderFactory) Provider(conn Connection) api.ConnectionProvider { return func(context.Client, fab.ChannelCfg, fab.Peer) (api.Connection, error) { return conn, nil } }
go
func (cp *ProviderFactory) Provider(conn Connection) api.ConnectionProvider { return func(context.Client, fab.ChannelCfg, fab.Peer) (api.Connection, error) { return conn, nil } }
[ "func", "(", "cp", "*", "ProviderFactory", ")", "Provider", "(", "conn", "Connection", ")", "api", ".", "ConnectionProvider", "{", "return", "func", "(", "context", ".", "Client", ",", "fab", ".", "ChannelCfg", ",", "fab", ".", "Peer", ")", "(", "api", ...
// Provider returns a connection provider that always returns the given connection
[ "Provider", "returns", "a", "connection", "provider", "that", "always", "returns", "the", "given", "connection" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/events/client/mocks/mockconnection.go#L216-L220
29,396
hyperledger/fabric-sdk-go
pkg/fab/events/client/mocks/mockconnection.go
FlakeyProvider
func (cp *ProviderFactory) FlakeyProvider(connAttemptResults ConnectAttemptResults, opts ...Opt) api.ConnectionProvider { var connectAttempt Attempt return func(ctx context.Client, cfg fab.ChannelCfg, peer fab.Peer) (api.Connection, error) { connectAttempt++ result, ok := connAttemptResults[connectAttempt] if ...
go
func (cp *ProviderFactory) FlakeyProvider(connAttemptResults ConnectAttemptResults, opts ...Opt) api.ConnectionProvider { var connectAttempt Attempt return func(ctx context.Client, cfg fab.ChannelCfg, peer fab.Peer) (api.Connection, error) { connectAttempt++ result, ok := connAttemptResults[connectAttempt] if ...
[ "func", "(", "cp", "*", "ProviderFactory", ")", "FlakeyProvider", "(", "connAttemptResults", "ConnectAttemptResults", ",", "opts", "...", "Opt", ")", "api", ".", "ConnectionProvider", "{", "var", "connectAttempt", "Attempt", "\n", "return", "func", "(", "ctx", "...
// FlakeyProvider creates a connection provider that returns a connection according to the given // connection attempt results. The results tell the connection provider whether or not to fail, // to return a connection, what authorization to give the connection, etc.
[ "FlakeyProvider", "creates", "a", "connection", "provider", "that", "returns", "a", "connection", "according", "to", "the", "given", "connection", "attempt", "results", ".", "The", "results", "tell", "the", "connection", "provider", "whether", "or", "not", "to", ...
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/events/client/mocks/mockconnection.go#L225-L242
29,397
hyperledger/fabric-sdk-go
pkg/fab/events/client/mocks/mockconnection.go
NewConnectResult
func NewConnectResult(attempt Attempt, connFactory ConnectionFactory) ConnectResult { return ConnectResult{Attempt: attempt, ConnFactory: connFactory} }
go
func NewConnectResult(attempt Attempt, connFactory ConnectionFactory) ConnectResult { return ConnectResult{Attempt: attempt, ConnFactory: connFactory} }
[ "func", "NewConnectResult", "(", "attempt", "Attempt", ",", "connFactory", "ConnectionFactory", ")", "ConnectResult", "{", "return", "ConnectResult", "{", "Attempt", ":", "attempt", ",", "ConnFactory", ":", "connFactory", "}", "\n", "}" ]
// NewConnectResult returns a new ConnectResult
[ "NewConnectResult", "returns", "a", "new", "ConnectResult" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/events/client/mocks/mockconnection.go#L251-L253
29,398
hyperledger/fabric-sdk-go
pkg/fab/events/client/mocks/mockconnection.go
NewConnectResults
func NewConnectResults(results ...ConnectResult) ConnectAttemptResults { mapResults := make(map[Attempt]ConnectResult) for _, r := range results { mapResults[r.Attempt] = r } return mapResults }
go
func NewConnectResults(results ...ConnectResult) ConnectAttemptResults { mapResults := make(map[Attempt]ConnectResult) for _, r := range results { mapResults[r.Attempt] = r } return mapResults }
[ "func", "NewConnectResults", "(", "results", "...", "ConnectResult", ")", "ConnectAttemptResults", "{", "mapResults", ":=", "make", "(", "map", "[", "Attempt", "]", "ConnectResult", ")", "\n", "for", "_", ",", "r", ":=", "range", "results", "{", "mapResults", ...
// NewConnectResults returns a new ConnectAttemptResults
[ "NewConnectResults", "returns", "a", "new", "ConnectAttemptResults" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/events/client/mocks/mockconnection.go#L259-L265
29,399
hyperledger/fabric-sdk-go
pkg/fab/events/client/mocks/mockconnection.go
NewResult
func NewResult(operation Operation, result Result, errMsg ...string) *OperationResult { msg := "" if len(errMsg) > 0 { msg = errMsg[0] } return &OperationResult{ Operation: operation, Result: result, ErrMessage: msg, } }
go
func NewResult(operation Operation, result Result, errMsg ...string) *OperationResult { msg := "" if len(errMsg) > 0 { msg = errMsg[0] } return &OperationResult{ Operation: operation, Result: result, ErrMessage: msg, } }
[ "func", "NewResult", "(", "operation", "Operation", ",", "result", "Result", ",", "errMsg", "...", "string", ")", "*", "OperationResult", "{", "msg", ":=", "\"", "\"", "\n", "if", "len", "(", "errMsg", ")", ">", "0", "{", "msg", "=", "errMsg", "[", "...
// NewResult returns a new OperationResult
[ "NewResult", "returns", "a", "new", "OperationResult" ]
48bb0d199e2cee03ad3af0a413bdfc064fc69bfe
https://github.com/hyperledger/fabric-sdk-go/blob/48bb0d199e2cee03ad3af0a413bdfc064fc69bfe/pkg/fab/events/client/mocks/mockconnection.go#L287-L297