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
140,800
h2non/bimg
vips.go
Shutdown
func Shutdown() { m.Lock() defer m.Unlock() if initialized { C.vips_shutdown() initialized = false } }
go
func Shutdown() { m.Lock() defer m.Unlock() if initialized { C.vips_shutdown() initialized = false } }
[ "func", "Shutdown", "(", ")", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "if", "initialized", "{", "C", ".", "vips_shutdown", "(", ")", "\n", "initialized", "=", "false", "\n", "}", "\n", "}" ]
// Shutdown is used to shutdown libvips in a thread-safe way. // You can call this to drop caches as well. // If libvips was already initialized, the function is no-op
[ "Shutdown", "is", "used", "to", "shutdown", "libvips", "in", "a", "thread", "-", "safe", "way", ".", "You", "can", "call", "this", "to", "drop", "caches", "as", "well", ".", "If", "libvips", "was", "already", "initialized", "the", "function", "is", "no",...
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/vips.go#L121-L129
140,801
h2non/bimg
vips.go
VipsIsTypeSupported
func VipsIsTypeSupported(t ImageType) bool { if t == JPEG { return int(C.vips_type_find_bridge(C.JPEG)) != 0 } if t == WEBP { return int(C.vips_type_find_bridge(C.WEBP)) != 0 } if t == PNG { return int(C.vips_type_find_bridge(C.PNG)) != 0 } if t == GIF { return int(C.vips_type_find_bridge(C.GIF)) != 0 }...
go
func VipsIsTypeSupported(t ImageType) bool { if t == JPEG { return int(C.vips_type_find_bridge(C.JPEG)) != 0 } if t == WEBP { return int(C.vips_type_find_bridge(C.WEBP)) != 0 } if t == PNG { return int(C.vips_type_find_bridge(C.PNG)) != 0 } if t == GIF { return int(C.vips_type_find_bridge(C.GIF)) != 0 }...
[ "func", "VipsIsTypeSupported", "(", "t", "ImageType", ")", "bool", "{", "if", "t", "==", "JPEG", "{", "return", "int", "(", "C", ".", "vips_type_find_bridge", "(", "C", ".", "JPEG", ")", ")", "!=", "0", "\n", "}", "\n", "if", "t", "==", "WEBP", "{"...
// VipsIsTypeSupported returns true if the given image type // is supported by the current libvips compilation.
[ "VipsIsTypeSupported", "returns", "true", "if", "the", "given", "image", "type", "is", "supported", "by", "the", "current", "libvips", "compilation", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/vips.go#L163-L189
140,802
h2non/bimg
vips.go
VipsIsTypeSupportedSave
func VipsIsTypeSupportedSave(t ImageType) bool { if t == JPEG { return int(C.vips_type_find_save_bridge(C.JPEG)) != 0 } if t == WEBP { return int(C.vips_type_find_save_bridge(C.WEBP)) != 0 } if t == PNG { return int(C.vips_type_find_save_bridge(C.PNG)) != 0 } if t == TIFF { return int(C.vips_type_find_sa...
go
func VipsIsTypeSupportedSave(t ImageType) bool { if t == JPEG { return int(C.vips_type_find_save_bridge(C.JPEG)) != 0 } if t == WEBP { return int(C.vips_type_find_save_bridge(C.WEBP)) != 0 } if t == PNG { return int(C.vips_type_find_save_bridge(C.PNG)) != 0 } if t == TIFF { return int(C.vips_type_find_sa...
[ "func", "VipsIsTypeSupportedSave", "(", "t", "ImageType", ")", "bool", "{", "if", "t", "==", "JPEG", "{", "return", "int", "(", "C", ".", "vips_type_find_save_bridge", "(", "C", ".", "JPEG", ")", ")", "!=", "0", "\n", "}", "\n", "if", "t", "==", "WEB...
// VipsIsTypeSupportedSave returns true if the given image type // is supported by the current libvips compilation for the // save operation.
[ "VipsIsTypeSupportedSave", "returns", "true", "if", "the", "given", "image", "type", "is", "supported", "by", "the", "current", "libvips", "compilation", "for", "the", "save", "operation", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/vips.go#L194-L208
140,803
tylertreat/BoomFilters
inverse.go
NewInverseBloomFilter
func NewInverseBloomFilter(capacity uint) *InverseBloomFilter { return &InverseBloomFilter{ array: make([]*[]byte, capacity), hashPool: &sync.Pool{New: func() interface{} { return fnv.New32() }}, capacity: capacity, } }
go
func NewInverseBloomFilter(capacity uint) *InverseBloomFilter { return &InverseBloomFilter{ array: make([]*[]byte, capacity), hashPool: &sync.Pool{New: func() interface{} { return fnv.New32() }}, capacity: capacity, } }
[ "func", "NewInverseBloomFilter", "(", "capacity", "uint", ")", "*", "InverseBloomFilter", "{", "return", "&", "InverseBloomFilter", "{", "array", ":", "make", "(", "[", "]", "*", "[", "]", "byte", ",", "capacity", ")", ",", "hashPool", ":", "&", "sync", ...
// NewInverseBloomFilter creates and returns a new InverseBloomFilter with the // specified capacity.
[ "NewInverseBloomFilter", "creates", "and", "returns", "a", "new", "InverseBloomFilter", "with", "the", "specified", "capacity", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/inverse.go#L68-L74
140,804
tylertreat/BoomFilters
inverse.go
Add
func (i *InverseBloomFilter) Add(data []byte) Filter { index := i.index(data) i.getAndSet(index, data) return i }
go
func (i *InverseBloomFilter) Add(data []byte) Filter { index := i.index(data) i.getAndSet(index, data) return i }
[ "func", "(", "i", "*", "InverseBloomFilter", ")", "Add", "(", "data", "[", "]", "byte", ")", "Filter", "{", "index", ":=", "i", ".", "index", "(", "data", ")", "\n", "i", ".", "getAndSet", "(", "index", ",", "data", ")", "\n", "return", "i", "\n"...
// Add will add the data to the filter. It returns the filter to allow for // chaining.
[ "Add", "will", "add", "the", "data", "to", "the", "filter", ".", "It", "returns", "the", "filter", "to", "allow", "for", "chaining", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/inverse.go#L93-L97
140,805
tylertreat/BoomFilters
inverse.go
getAndSet
func (i *InverseBloomFilter) getAndSet(index uint32, data []byte) []byte { indexPtr := (*unsafe.Pointer)(unsafe.Pointer(&i.array[index])) keyUnsafe := unsafe.Pointer(&data) var oldKey []byte for { oldKeyUnsafe := atomic.LoadPointer(indexPtr) if atomic.CompareAndSwapPointer(indexPtr, oldKeyUnsafe, keyUnsafe) { ...
go
func (i *InverseBloomFilter) getAndSet(index uint32, data []byte) []byte { indexPtr := (*unsafe.Pointer)(unsafe.Pointer(&i.array[index])) keyUnsafe := unsafe.Pointer(&data) var oldKey []byte for { oldKeyUnsafe := atomic.LoadPointer(indexPtr) if atomic.CompareAndSwapPointer(indexPtr, oldKeyUnsafe, keyUnsafe) { ...
[ "func", "(", "i", "*", "InverseBloomFilter", ")", "getAndSet", "(", "index", "uint32", ",", "data", "[", "]", "byte", ")", "[", "]", "byte", "{", "indexPtr", ":=", "(", "*", "unsafe", ".", "Pointer", ")", "(", "unsafe", ".", "Pointer", "(", "&", "i...
// getAndSet returns the data that was in the slice at the given index after // putting the new data in the slice at that index, atomically.
[ "getAndSet", "returns", "the", "data", "that", "was", "in", "the", "slice", "at", "the", "given", "index", "after", "putting", "the", "new", "data", "in", "the", "slice", "at", "that", "index", "atomically", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/inverse.go#L113-L128
140,806
tylertreat/BoomFilters
inverse.go
index
func (i *InverseBloomFilter) index(data []byte) uint32 { hash := i.hashPool.Get().(hash.Hash32) hash.Write(data) index := hash.Sum32() % uint32(i.capacity) hash.Reset() i.hashPool.Put(hash) return index }
go
func (i *InverseBloomFilter) index(data []byte) uint32 { hash := i.hashPool.Get().(hash.Hash32) hash.Write(data) index := hash.Sum32() % uint32(i.capacity) hash.Reset() i.hashPool.Put(hash) return index }
[ "func", "(", "i", "*", "InverseBloomFilter", ")", "index", "(", "data", "[", "]", "byte", ")", "uint32", "{", "hash", ":=", "i", ".", "hashPool", ".", "Get", "(", ")", ".", "(", "hash", ".", "Hash32", ")", "\n", "hash", ".", "Write", "(", "data",...
// index returns the array index for the given data.
[ "index", "returns", "the", "array", "index", "for", "the", "given", "data", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/inverse.go#L131-L138
140,807
tylertreat/BoomFilters
inverse.go
SetHashFactory
func (i *InverseBloomFilter) SetHashFactory(h func() hash.Hash32) { i.hashPool = &sync.Pool{New: func() interface{} { return h() }} }
go
func (i *InverseBloomFilter) SetHashFactory(h func() hash.Hash32) { i.hashPool = &sync.Pool{New: func() interface{} { return h() }} }
[ "func", "(", "i", "*", "InverseBloomFilter", ")", "SetHashFactory", "(", "h", "func", "(", ")", "hash", ".", "Hash32", ")", "{", "i", ".", "hashPool", "=", "&", "sync", ".", "Pool", "{", "New", ":", "func", "(", ")", "interface", "{", "}", "{", "...
// SetHashFactory sets the hashing function factory used in the filter.
[ "SetHashFactory", "sets", "the", "hashing", "function", "factory", "used", "in", "the", "filter", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/inverse.go#L141-L143
140,808
tylertreat/BoomFilters
deletable.go
NewDeletableBloomFilter
func NewDeletableBloomFilter(n, r uint, fpRate float64) *DeletableBloomFilter { var ( m = OptimalM(n, fpRate) k = OptimalK(fpRate) ) return &DeletableBloomFilter{ buckets: NewBuckets(m-r, 1), collisions: NewBuckets(r+1, 1), hash: fnv.New64(), m: m - r, regionSize: (m - r) / r, ...
go
func NewDeletableBloomFilter(n, r uint, fpRate float64) *DeletableBloomFilter { var ( m = OptimalM(n, fpRate) k = OptimalK(fpRate) ) return &DeletableBloomFilter{ buckets: NewBuckets(m-r, 1), collisions: NewBuckets(r+1, 1), hash: fnv.New64(), m: m - r, regionSize: (m - r) / r, ...
[ "func", "NewDeletableBloomFilter", "(", "n", ",", "r", "uint", ",", "fpRate", "float64", ")", "*", "DeletableBloomFilter", "{", "var", "(", "m", "=", "OptimalM", "(", "n", ",", "fpRate", ")", "\n", "k", "=", "OptimalK", "(", "fpRate", ")", "\n", ")", ...
// NewDeletableBloomFilter creates a new DeletableBloomFilter optimized to // store n items with a specified target false-positive rate. The r value // determines the number of bits to use to store collision information. This // controls the deletability of an element. Refer to the paper for selecting an // optimal val...
[ "NewDeletableBloomFilter", "creates", "a", "new", "DeletableBloomFilter", "optimized", "to", "store", "n", "items", "with", "a", "specified", "target", "false", "-", "positive", "rate", ".", "The", "r", "value", "determines", "the", "number", "of", "bits", "to",...
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/deletable.go#L38-L52
140,809
tylertreat/BoomFilters
counting.go
NewCountingBloomFilter
func NewCountingBloomFilter(n uint, b uint8, fpRate float64) *CountingBloomFilter { var ( m = OptimalM(n, fpRate) k = OptimalK(fpRate) ) return &CountingBloomFilter{ buckets: NewBuckets(m, b), hash: fnv.New64(), m: m, k: k, indexBuffer: make([]uint, k), } }
go
func NewCountingBloomFilter(n uint, b uint8, fpRate float64) *CountingBloomFilter { var ( m = OptimalM(n, fpRate) k = OptimalK(fpRate) ) return &CountingBloomFilter{ buckets: NewBuckets(m, b), hash: fnv.New64(), m: m, k: k, indexBuffer: make([]uint, k), } }
[ "func", "NewCountingBloomFilter", "(", "n", "uint", ",", "b", "uint8", ",", "fpRate", "float64", ")", "*", "CountingBloomFilter", "{", "var", "(", "m", "=", "OptimalM", "(", "n", ",", "fpRate", ")", "\n", "k", "=", "OptimalK", "(", "fpRate", ")", "\n",...
// NewCountingBloomFilter creates a new Counting Bloom Filter optimized to // store n items with a specified target false-positive rate and bucket size. // If you don't know how many bits to use for buckets, use // NewDefaultCountingBloomFilter for a sensible default.
[ "NewCountingBloomFilter", "creates", "a", "new", "Counting", "Bloom", "Filter", "optimized", "to", "store", "n", "items", "with", "a", "specified", "target", "false", "-", "positive", "rate", "and", "bucket", "size", ".", "If", "you", "don", "t", "know", "ho...
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/counting.go#L37-L49
140,810
tylertreat/BoomFilters
countmin.go
NewCountMinSketch
func NewCountMinSketch(epsilon, delta float64) *CountMinSketch { var ( width = uint(math.Ceil(math.E / epsilon)) depth = uint(math.Ceil(math.Log(1 / delta))) matrix = make([][]uint64, depth) ) for i := uint(0); i < depth; i++ { matrix[i] = make([]uint64, width) } return &CountMinSketch{ matrix: matr...
go
func NewCountMinSketch(epsilon, delta float64) *CountMinSketch { var ( width = uint(math.Ceil(math.E / epsilon)) depth = uint(math.Ceil(math.Log(1 / delta))) matrix = make([][]uint64, depth) ) for i := uint(0); i < depth; i++ { matrix[i] = make([]uint64, width) } return &CountMinSketch{ matrix: matr...
[ "func", "NewCountMinSketch", "(", "epsilon", ",", "delta", "float64", ")", "*", "CountMinSketch", "{", "var", "(", "width", "=", "uint", "(", "math", ".", "Ceil", "(", "math", ".", "E", "/", "epsilon", ")", ")", "\n", "depth", "=", "uint", "(", "math...
// NewCountMinSketch creates a new Count-Min Sketch whose relative accuracy is // within a factor of epsilon with probability delta. Both of these parameters // affect the space and time complexity.
[ "NewCountMinSketch", "creates", "a", "new", "Count", "-", "Min", "Sketch", "whose", "relative", "accuracy", "is", "within", "a", "factor", "of", "epsilon", "with", "probability", "delta", ".", "Both", "of", "these", "parameters", "affect", "the", "space", "and...
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/countmin.go#L46-L65
140,811
tylertreat/BoomFilters
countmin.go
Add
func (c *CountMinSketch) Add(data []byte) *CountMinSketch { lower, upper := hashKernel(data, c.hash) // Increment count in each row. for i := uint(0); i < c.depth; i++ { c.matrix[i][(uint(lower)+uint(upper)*i)%c.width]++ } c.count++ return c }
go
func (c *CountMinSketch) Add(data []byte) *CountMinSketch { lower, upper := hashKernel(data, c.hash) // Increment count in each row. for i := uint(0); i < c.depth; i++ { c.matrix[i][(uint(lower)+uint(upper)*i)%c.width]++ } c.count++ return c }
[ "func", "(", "c", "*", "CountMinSketch", ")", "Add", "(", "data", "[", "]", "byte", ")", "*", "CountMinSketch", "{", "lower", ",", "upper", ":=", "hashKernel", "(", "data", ",", "c", ".", "hash", ")", "\n\n", "// Increment count in each row.", "for", "i"...
// Add will add the data to the set. Returns the CountMinSketch to allow for // chaining.
[ "Add", "will", "add", "the", "data", "to", "the", "set", ".", "Returns", "the", "CountMinSketch", "to", "allow", "for", "chaining", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/countmin.go#L84-L94
140,812
tylertreat/BoomFilters
countmin.go
Merge
func (c *CountMinSketch) Merge(other *CountMinSketch) error { if c.depth != other.depth { return errors.New("matrix depth must match") } if c.width != other.width { return errors.New("matrix width must match") } for i := uint(0); i < c.depth; i++ { for j := uint(0); j < c.width; j++ { c.matrix[i][j] += ...
go
func (c *CountMinSketch) Merge(other *CountMinSketch) error { if c.depth != other.depth { return errors.New("matrix depth must match") } if c.width != other.width { return errors.New("matrix width must match") } for i := uint(0); i < c.depth; i++ { for j := uint(0); j < c.width; j++ { c.matrix[i][j] += ...
[ "func", "(", "c", "*", "CountMinSketch", ")", "Merge", "(", "other", "*", "CountMinSketch", ")", "error", "{", "if", "c", ".", "depth", "!=", "other", ".", "depth", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if",...
// Merge combines this CountMinSketch with another. Returns an error if the // matrix width and depth are not equal.
[ "Merge", "combines", "this", "CountMinSketch", "with", "another", ".", "Returns", "an", "error", "if", "the", "matrix", "width", "and", "depth", "are", "not", "equal", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/countmin.go#L114-L131
140,813
tylertreat/BoomFilters
countmin.go
Reset
func (c *CountMinSketch) Reset() *CountMinSketch { matrix := make([][]uint64, c.depth) for i := uint(0); i < c.depth; i++ { matrix[i] = make([]uint64, c.width) } c.matrix = matrix c.count = 0 return c }
go
func (c *CountMinSketch) Reset() *CountMinSketch { matrix := make([][]uint64, c.depth) for i := uint(0); i < c.depth; i++ { matrix[i] = make([]uint64, c.width) } c.matrix = matrix c.count = 0 return c }
[ "func", "(", "c", "*", "CountMinSketch", ")", "Reset", "(", ")", "*", "CountMinSketch", "{", "matrix", ":=", "make", "(", "[", "]", "[", "]", "uint64", ",", "c", ".", "depth", ")", "\n", "for", "i", ":=", "uint", "(", "0", ")", ";", "i", "<", ...
// Reset restores the CountMinSketch to its original state. It returns itself // to allow for chaining.
[ "Reset", "restores", "the", "CountMinSketch", "to", "its", "original", "state", ".", "It", "returns", "itself", "to", "allow", "for", "chaining", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/countmin.go#L135-L144
140,814
tylertreat/BoomFilters
countmin.go
WriteDataTo
func (c *CountMinSketch) WriteDataTo(stream io.Writer) (int, error) { buf := new(bytes.Buffer) // serialize epsilon and delta as cms configuration check err := binary.Write(buf, binary.LittleEndian, c.epsilon) if err != nil { return 0, err } err = binary.Write(buf, binary.LittleEndian, c.delta) if err != nil {...
go
func (c *CountMinSketch) WriteDataTo(stream io.Writer) (int, error) { buf := new(bytes.Buffer) // serialize epsilon and delta as cms configuration check err := binary.Write(buf, binary.LittleEndian, c.epsilon) if err != nil { return 0, err } err = binary.Write(buf, binary.LittleEndian, c.delta) if err != nil {...
[ "func", "(", "c", "*", "CountMinSketch", ")", "WriteDataTo", "(", "stream", "io", ".", "Writer", ")", "(", "int", ",", "error", ")", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n", "// serialize epsilon and delta as cms configuration check", ...
// WriteDataTo writes a binary representation of the CMS data to // an io stream. It returns the number of bytes written and error
[ "WriteDataTo", "writes", "a", "binary", "representation", "of", "the", "CMS", "data", "to", "an", "io", "stream", ".", "It", "returns", "the", "number", "of", "bytes", "written", "and", "error" ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/countmin.go#L153-L177
140,815
tylertreat/BoomFilters
cuckoo.go
indexOf
func (b bucket) indexOf(f []byte) int { for i, fingerprint := range b { if bytes.Equal(f, fingerprint) { return i } } return -1 }
go
func (b bucket) indexOf(f []byte) int { for i, fingerprint := range b { if bytes.Equal(f, fingerprint) { return i } } return -1 }
[ "func", "(", "b", "bucket", ")", "indexOf", "(", "f", "[", "]", "byte", ")", "int", "{", "for", "i", ",", "fingerprint", ":=", "range", "b", "{", "if", "bytes", ".", "Equal", "(", "f", ",", "fingerprint", ")", "{", "return", "i", "\n", "}", "\n...
// indexOf returns the entry index of the given fingerprint or -1 if it's not // in the bucket.
[ "indexOf", "returns", "the", "entry", "index", "of", "the", "given", "fingerprint", "or", "-", "1", "if", "it", "s", "not", "in", "the", "bucket", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/cuckoo.go#L28-L35
140,816
tylertreat/BoomFilters
cuckoo.go
getEmptyEntry
func (b bucket) getEmptyEntry() (int, error) { for i, fingerprint := range b { if fingerprint == nil { return i, nil } } return -1, errors.New("full") }
go
func (b bucket) getEmptyEntry() (int, error) { for i, fingerprint := range b { if fingerprint == nil { return i, nil } } return -1, errors.New("full") }
[ "func", "(", "b", "bucket", ")", "getEmptyEntry", "(", ")", "(", "int", ",", "error", ")", "{", "for", "i", ",", "fingerprint", ":=", "range", "b", "{", "if", "fingerprint", "==", "nil", "{", "return", "i", ",", "nil", "\n", "}", "\n", "}", "\n",...
// getEmptyEntry returns the index of the next available entry in the bucket or // an error if it's full.
[ "getEmptyEntry", "returns", "the", "index", "of", "the", "next", "available", "entry", "in", "the", "bucket", "or", "an", "error", "if", "it", "s", "full", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/cuckoo.go#L39-L46
140,817
tylertreat/BoomFilters
cuckoo.go
NewCuckooFilter
func NewCuckooFilter(n uint, fpRate float64) *CuckooFilter { var ( b = uint(4) f = calculateF(b, fpRate) m = power2(n / f * 8) buckets = make([]bucket, m) ) for i := uint(0); i < m; i++ { buckets[i] = make(bucket, b) } return &CuckooFilter{ buckets: buckets, hash: fnv.New32(), ...
go
func NewCuckooFilter(n uint, fpRate float64) *CuckooFilter { var ( b = uint(4) f = calculateF(b, fpRate) m = power2(n / f * 8) buckets = make([]bucket, m) ) for i := uint(0); i < m; i++ { buckets[i] = make(bucket, b) } return &CuckooFilter{ buckets: buckets, hash: fnv.New32(), ...
[ "func", "NewCuckooFilter", "(", "n", "uint", ",", "fpRate", "float64", ")", "*", "CuckooFilter", "{", "var", "(", "b", "=", "uint", "(", "4", ")", "\n", "f", "=", "calculateF", "(", "b", ",", "fpRate", ")", "\n", "m", "=", "power2", "(", "n", "/"...
// NewCuckooFilter creates a new Cuckoo Bloom filter optimized to store n items // with a specified target false-positive rate.
[ "NewCuckooFilter", "creates", "a", "new", "Cuckoo", "Bloom", "filter", "optimized", "to", "store", "n", "items", "with", "a", "specified", "target", "false", "-", "positive", "rate", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/cuckoo.go#L75-L95
140,818
tylertreat/BoomFilters
cuckoo.go
Add
func (c *CuckooFilter) Add(data []byte) error { return c.add(c.components(data)) }
go
func (c *CuckooFilter) Add(data []byte) error { return c.add(c.components(data)) }
[ "func", "(", "c", "*", "CuckooFilter", ")", "Add", "(", "data", "[", "]", "byte", ")", "error", "{", "return", "c", ".", "add", "(", "c", ".", "components", "(", "data", ")", ")", "\n", "}" ]
// Add will add the data to the Cuckoo Filter. It returns an error if the // filter is full. If the filter is full, an item is removed to make room for // the new item. This introduces a possibility for false negatives. To avoid // this, use Count and Capacity to check if the filter is full before adding an // item.
[ "Add", "will", "add", "the", "data", "to", "the", "Cuckoo", "Filter", ".", "It", "returns", "an", "error", "if", "the", "filter", "is", "full", ".", "If", "the", "filter", "is", "full", "an", "item", "is", "removed", "to", "make", "room", "for", "the...
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/cuckoo.go#L127-L129
140,819
tylertreat/BoomFilters
cuckoo.go
add
func (c *CuckooFilter) add(i1, i2 uint, f []byte) error { // Try to insert into bucket[i1]. b1 := c.buckets[i1%c.m] if idx, err := b1.getEmptyEntry(); err == nil { b1[idx] = f c.count++ return nil } // Try to insert into bucket[i2]. b2 := c.buckets[i2%c.m] if idx, err := b2.getEmptyEntry(); err == nil { ...
go
func (c *CuckooFilter) add(i1, i2 uint, f []byte) error { // Try to insert into bucket[i1]. b1 := c.buckets[i1%c.m] if idx, err := b1.getEmptyEntry(); err == nil { b1[idx] = f c.count++ return nil } // Try to insert into bucket[i2]. b2 := c.buckets[i2%c.m] if idx, err := b2.getEmptyEntry(); err == nil { ...
[ "func", "(", "c", "*", "CuckooFilter", ")", "add", "(", "i1", ",", "i2", "uint", ",", "f", "[", "]", "byte", ")", "error", "{", "// Try to insert into bucket[i1].", "b1", ":=", "c", ".", "buckets", "[", "i1", "%", "c", ".", "m", "]", "\n", "if", ...
// add will insert the fingerprint into the filter returning an error if the // filter is full.
[ "add", "will", "insert", "the", "fingerprint", "into", "the", "filter", "returning", "an", "error", "if", "the", "filter", "is", "full", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/cuckoo.go#L185-L218
140,820
tylertreat/BoomFilters
cuckoo.go
components
func (c *CuckooFilter) components(data []byte) (uint, uint, []byte) { var ( hash = c.computeHash(data) f = hash[0:c.f] i1 = uint(binary.BigEndian.Uint32(hash)) i2 = i1 ^ uint(binary.BigEndian.Uint32(c.computeHash(f))) ) return i1, i2, f }
go
func (c *CuckooFilter) components(data []byte) (uint, uint, []byte) { var ( hash = c.computeHash(data) f = hash[0:c.f] i1 = uint(binary.BigEndian.Uint32(hash)) i2 = i1 ^ uint(binary.BigEndian.Uint32(c.computeHash(f))) ) return i1, i2, f }
[ "func", "(", "c", "*", "CuckooFilter", ")", "components", "(", "data", "[", "]", "byte", ")", "(", "uint", ",", "uint", ",", "[", "]", "byte", ")", "{", "var", "(", "hash", "=", "c", ".", "computeHash", "(", "data", ")", "\n", "f", "=", "hash",...
// components returns the two hash values used to index into the buckets and // the fingerprint for the given element.
[ "components", "returns", "the", "two", "hash", "values", "used", "to", "index", "into", "the", "buckets", "and", "the", "fingerprint", "for", "the", "given", "element", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/cuckoo.go#L222-L231
140,821
tylertreat/BoomFilters
cuckoo.go
computeHash
func (c *CuckooFilter) computeHash(data []byte) []byte { c.hash.Write(data) hash := c.hash.Sum(nil) c.hash.Reset() return hash }
go
func (c *CuckooFilter) computeHash(data []byte) []byte { c.hash.Write(data) hash := c.hash.Sum(nil) c.hash.Reset() return hash }
[ "func", "(", "c", "*", "CuckooFilter", ")", "computeHash", "(", "data", "[", "]", "byte", ")", "[", "]", "byte", "{", "c", ".", "hash", ".", "Write", "(", "data", ")", "\n", "hash", ":=", "c", ".", "hash", ".", "Sum", "(", "nil", ")", "\n", "...
// computeHash returns a 32-bit hash value for the given data.
[ "computeHash", "returns", "a", "32", "-", "bit", "hash", "value", "for", "the", "given", "data", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/cuckoo.go#L234-L239
140,822
tylertreat/BoomFilters
cuckoo.go
calculateF
func calculateF(b uint, epsilon float64) uint { f := uint(math.Ceil(math.Log(2 * float64(b) / epsilon))) f = f / 8 if f <= 0 { f = 1 } return f }
go
func calculateF(b uint, epsilon float64) uint { f := uint(math.Ceil(math.Log(2 * float64(b) / epsilon))) f = f / 8 if f <= 0 { f = 1 } return f }
[ "func", "calculateF", "(", "b", "uint", ",", "epsilon", "float64", ")", "uint", "{", "f", ":=", "uint", "(", "math", ".", "Ceil", "(", "math", ".", "Log", "(", "2", "*", "float64", "(", "b", ")", "/", "epsilon", ")", ")", ")", "\n", "f", "=", ...
// calculateF returns the optimal fingerprint length in bytes for the given // bucket size and false-positive rate epsilon.
[ "calculateF", "returns", "the", "optimal", "fingerprint", "length", "in", "bytes", "for", "the", "given", "bucket", "size", "and", "false", "-", "positive", "rate", "epsilon", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/cuckoo.go#L249-L256
140,823
tylertreat/BoomFilters
cuckoo.go
power2
func power2(x uint) uint { x-- x |= x >> 1 x |= x >> 2 x |= x >> 4 x |= x >> 8 x |= x >> 16 x |= x >> 32 x++ return x }
go
func power2(x uint) uint { x-- x |= x >> 1 x |= x >> 2 x |= x >> 4 x |= x >> 8 x |= x >> 16 x |= x >> 32 x++ return x }
[ "func", "power2", "(", "x", "uint", ")", "uint", "{", "x", "--", "\n", "x", "|=", "x", ">>", "1", "\n", "x", "|=", "x", ">>", "2", "\n", "x", "|=", "x", ">>", "4", "\n", "x", "|=", "x", ">>", "8", "\n", "x", "|=", "x", ">>", "16", "\n",...
// power2 calculates the next power of two for the given value.
[ "power2", "calculates", "the", "next", "power", "of", "two", "for", "the", "given", "value", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/cuckoo.go#L259-L269
140,824
tylertreat/BoomFilters
topk.go
NewTopK
func NewTopK(epsilon, delta float64, k uint) *TopK { elements := make(elementHeap, 0, k) heap.Init(&elements) return &TopK{ cms: NewCountMinSketch(epsilon, delta), k: k, elements: &elements, } }
go
func NewTopK(epsilon, delta float64, k uint) *TopK { elements := make(elementHeap, 0, k) heap.Init(&elements) return &TopK{ cms: NewCountMinSketch(epsilon, delta), k: k, elements: &elements, } }
[ "func", "NewTopK", "(", "epsilon", ",", "delta", "float64", ",", "k", "uint", ")", "*", "TopK", "{", "elements", ":=", "make", "(", "elementHeap", ",", "0", ",", "k", ")", "\n", "heap", ".", "Init", "(", "&", "elements", ")", "\n", "return", "&", ...
// NewTopK creates a new TopK backed by a Count-Min sketch whose relative // accuracy is within a factor of epsilon with probability delta. It tracks the // k-most frequent elements.
[ "NewTopK", "creates", "a", "new", "TopK", "backed", "by", "a", "Count", "-", "Min", "sketch", "whose", "relative", "accuracy", "is", "within", "a", "factor", "of", "epsilon", "with", "probability", "delta", ".", "It", "tracks", "the", "k", "-", "most", "...
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/topk.go#L45-L53
140,825
tylertreat/BoomFilters
topk.go
Add
func (t *TopK) Add(data []byte) *TopK { t.cms.Add(data) t.n++ freq := t.cms.Count(data) if t.isTop(freq) { t.insert(data, freq) } return t }
go
func (t *TopK) Add(data []byte) *TopK { t.cms.Add(data) t.n++ freq := t.cms.Count(data) if t.isTop(freq) { t.insert(data, freq) } return t }
[ "func", "(", "t", "*", "TopK", ")", "Add", "(", "data", "[", "]", "byte", ")", "*", "TopK", "{", "t", ".", "cms", ".", "Add", "(", "data", ")", "\n", "t", ".", "n", "++", "\n\n", "freq", ":=", "t", ".", "cms", ".", "Count", "(", "data", "...
// Add will add the data to the Count-Min Sketch and update the top-k heap if // applicable. Returns the TopK to allow for chaining.
[ "Add", "will", "add", "the", "data", "to", "the", "Count", "-", "Min", "Sketch", "and", "update", "the", "top", "-", "k", "heap", "if", "applicable", ".", "Returns", "the", "TopK", "to", "allow", "for", "chaining", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/topk.go#L57-L67
140,826
tylertreat/BoomFilters
topk.go
Elements
func (t *TopK) Elements() []*Element { if t.elements.Len() == 0 { return make([]*Element, 0) } elements := make(elementHeap, t.elements.Len()) copy(elements, *t.elements) heap.Init(&elements) topK := make([]*Element, 0, t.k) for elements.Len() > 0 { topK = append(topK, heap.Pop(&elements).(*Element)) } ...
go
func (t *TopK) Elements() []*Element { if t.elements.Len() == 0 { return make([]*Element, 0) } elements := make(elementHeap, t.elements.Len()) copy(elements, *t.elements) heap.Init(&elements) topK := make([]*Element, 0, t.k) for elements.Len() > 0 { topK = append(topK, heap.Pop(&elements).(*Element)) } ...
[ "func", "(", "t", "*", "TopK", ")", "Elements", "(", ")", "[", "]", "*", "Element", "{", "if", "t", ".", "elements", ".", "Len", "(", ")", "==", "0", "{", "return", "make", "(", "[", "]", "*", "Element", ",", "0", ")", "\n", "}", "\n\n", "e...
// Elements returns the top-k elements from lowest to highest frequency.
[ "Elements", "returns", "the", "top", "-", "k", "elements", "from", "lowest", "to", "highest", "frequency", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/topk.go#L70-L85
140,827
tylertreat/BoomFilters
topk.go
Reset
func (t *TopK) Reset() *TopK { t.cms.Reset() elements := make(elementHeap, 0, t.k) heap.Init(&elements) t.elements = &elements t.n = 0 return t }
go
func (t *TopK) Reset() *TopK { t.cms.Reset() elements := make(elementHeap, 0, t.k) heap.Init(&elements) t.elements = &elements t.n = 0 return t }
[ "func", "(", "t", "*", "TopK", ")", "Reset", "(", ")", "*", "TopK", "{", "t", ".", "cms", ".", "Reset", "(", ")", "\n", "elements", ":=", "make", "(", "elementHeap", ",", "0", ",", "t", ".", "k", ")", "\n", "heap", ".", "Init", "(", "&", "e...
// Reset restores the TopK to its original state. It returns itself to allow // for chaining.
[ "Reset", "restores", "the", "TopK", "to", "its", "original", "state", ".", "It", "returns", "itself", "to", "allow", "for", "chaining", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/topk.go#L89-L96
140,828
tylertreat/BoomFilters
topk.go
isTop
func (t *TopK) isTop(freq uint64) bool { if t.elements.Len() < int(t.k) { return true } return freq >= (*t.elements)[0].Freq }
go
func (t *TopK) isTop(freq uint64) bool { if t.elements.Len() < int(t.k) { return true } return freq >= (*t.elements)[0].Freq }
[ "func", "(", "t", "*", "TopK", ")", "isTop", "(", "freq", "uint64", ")", "bool", "{", "if", "t", ".", "elements", ".", "Len", "(", ")", "<", "int", "(", "t", ".", "k", ")", "{", "return", "true", "\n", "}", "\n\n", "return", "freq", ">=", "("...
// isTop indicates if the given frequency falls within the top-k heap.
[ "isTop", "indicates", "if", "the", "given", "frequency", "falls", "within", "the", "top", "-", "k", "heap", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/topk.go#L99-L105
140,829
tylertreat/BoomFilters
topk.go
insert
func (t *TopK) insert(data []byte, freq uint64) { for i, element := range *t.elements { if bytes.Equal(data, element.Data) { // Element already in top-k, replace it with new frequency. heap.Remove(t.elements, i) element.Freq = freq heap.Push(t.elements, element) return } } if t.elements.Len() == ...
go
func (t *TopK) insert(data []byte, freq uint64) { for i, element := range *t.elements { if bytes.Equal(data, element.Data) { // Element already in top-k, replace it with new frequency. heap.Remove(t.elements, i) element.Freq = freq heap.Push(t.elements, element) return } } if t.elements.Len() == ...
[ "func", "(", "t", "*", "TopK", ")", "insert", "(", "data", "[", "]", "byte", ",", "freq", "uint64", ")", "{", "for", "i", ",", "element", ":=", "range", "*", "t", ".", "elements", "{", "if", "bytes", ".", "Equal", "(", "data", ",", "element", "...
// insert adds the data to the top-k heap. If the data is already an element, // the frequency is updated. If the heap already has k elements, the element // with the minimum frequency is removed.
[ "insert", "adds", "the", "data", "to", "the", "top", "-", "k", "heap", ".", "If", "the", "data", "is", "already", "an", "element", "the", "frequency", "is", "updated", ".", "If", "the", "heap", "already", "has", "k", "elements", "the", "element", "with...
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/topk.go#L110-L128
140,830
tylertreat/BoomFilters
buckets.go
NewBuckets
func NewBuckets(count uint, bucketSize uint8) *Buckets { return &Buckets{ count: count, data: make([]byte, (count*uint(bucketSize)+7)/8), bucketSize: bucketSize, max: (1 << bucketSize) - 1, } }
go
func NewBuckets(count uint, bucketSize uint8) *Buckets { return &Buckets{ count: count, data: make([]byte, (count*uint(bucketSize)+7)/8), bucketSize: bucketSize, max: (1 << bucketSize) - 1, } }
[ "func", "NewBuckets", "(", "count", "uint", ",", "bucketSize", "uint8", ")", "*", "Buckets", "{", "return", "&", "Buckets", "{", "count", ":", "count", ",", "data", ":", "make", "(", "[", "]", "byte", ",", "(", "count", "*", "uint", "(", "bucketSize"...
// NewBuckets creates a new Buckets with the provided number of buckets where // each bucket is the specified number of bits.
[ "NewBuckets", "creates", "a", "new", "Buckets", "with", "the", "provided", "number", "of", "buckets", "where", "each", "bucket", "is", "the", "specified", "number", "of", "bits", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/buckets.go#L20-L27
140,831
tylertreat/BoomFilters
buckets.go
Increment
func (b *Buckets) Increment(bucket uint, delta int32) *Buckets { val := int32(b.getBits(bucket*uint(b.bucketSize), uint(b.bucketSize))) + delta if val > int32(b.max) { val = int32(b.max) } else if val < 0 { val = 0 } b.setBits(uint32(bucket)*uint32(b.bucketSize), uint32(b.bucketSize), uint32(val)) return b }
go
func (b *Buckets) Increment(bucket uint, delta int32) *Buckets { val := int32(b.getBits(bucket*uint(b.bucketSize), uint(b.bucketSize))) + delta if val > int32(b.max) { val = int32(b.max) } else if val < 0 { val = 0 } b.setBits(uint32(bucket)*uint32(b.bucketSize), uint32(b.bucketSize), uint32(val)) return b }
[ "func", "(", "b", "*", "Buckets", ")", "Increment", "(", "bucket", "uint", ",", "delta", "int32", ")", "*", "Buckets", "{", "val", ":=", "int32", "(", "b", ".", "getBits", "(", "bucket", "*", "uint", "(", "b", ".", "bucketSize", ")", ",", "uint", ...
// Increment will increment the value in the specified bucket by the provided // delta. A bucket can be decremented by providing a negative delta. The value // is clamped to zero and the maximum bucket value. Returns itself to allow for // chaining.
[ "Increment", "will", "increment", "the", "value", "in", "the", "specified", "bucket", "by", "the", "provided", "delta", ".", "A", "bucket", "can", "be", "decremented", "by", "providing", "a", "negative", "delta", ".", "The", "value", "is", "clamped", "to", ...
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/buckets.go#L43-L53
140,832
tylertreat/BoomFilters
buckets.go
Set
func (b *Buckets) Set(bucket uint, value uint8) *Buckets { if value > b.max { value = b.max } b.setBits(uint32(bucket)*uint32(b.bucketSize), uint32(b.bucketSize), uint32(value)) return b }
go
func (b *Buckets) Set(bucket uint, value uint8) *Buckets { if value > b.max { value = b.max } b.setBits(uint32(bucket)*uint32(b.bucketSize), uint32(b.bucketSize), uint32(value)) return b }
[ "func", "(", "b", "*", "Buckets", ")", "Set", "(", "bucket", "uint", ",", "value", "uint8", ")", "*", "Buckets", "{", "if", "value", ">", "b", ".", "max", "{", "value", "=", "b", ".", "max", "\n", "}", "\n\n", "b", ".", "setBits", "(", "uint32"...
// Set will set the bucket value. The value is clamped to zero and the maximum // bucket value. Returns itself to allow for chaining.
[ "Set", "will", "set", "the", "bucket", "value", ".", "The", "value", "is", "clamped", "to", "zero", "and", "the", "maximum", "bucket", "value", ".", "Returns", "itself", "to", "allow", "for", "chaining", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/buckets.go#L57-L64
140,833
tylertreat/BoomFilters
buckets.go
Get
func (b *Buckets) Get(bucket uint) uint32 { return b.getBits(bucket*uint(b.bucketSize), uint(b.bucketSize)) }
go
func (b *Buckets) Get(bucket uint) uint32 { return b.getBits(bucket*uint(b.bucketSize), uint(b.bucketSize)) }
[ "func", "(", "b", "*", "Buckets", ")", "Get", "(", "bucket", "uint", ")", "uint32", "{", "return", "b", ".", "getBits", "(", "bucket", "*", "uint", "(", "b", ".", "bucketSize", ")", ",", "uint", "(", "b", ".", "bucketSize", ")", ")", "\n", "}" ]
// Get returns the value in the specified bucket.
[ "Get", "returns", "the", "value", "in", "the", "specified", "bucket", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/buckets.go#L67-L69
140,834
tylertreat/BoomFilters
buckets.go
Reset
func (b *Buckets) Reset() *Buckets { b.data = make([]byte, (b.count*uint(b.bucketSize)+7)/8) return b }
go
func (b *Buckets) Reset() *Buckets { b.data = make([]byte, (b.count*uint(b.bucketSize)+7)/8) return b }
[ "func", "(", "b", "*", "Buckets", ")", "Reset", "(", ")", "*", "Buckets", "{", "b", ".", "data", "=", "make", "(", "[", "]", "byte", ",", "(", "b", ".", "count", "*", "uint", "(", "b", ".", "bucketSize", ")", "+", "7", ")", "/", "8", ")", ...
// Reset restores the Buckets to the original state. Returns itself to allow // for chaining.
[ "Reset", "restores", "the", "Buckets", "to", "the", "original", "state", ".", "Returns", "itself", "to", "allow", "for", "chaining", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/buckets.go#L73-L76
140,835
tylertreat/BoomFilters
buckets.go
getBits
func (b *Buckets) getBits(offset, length uint) uint32 { byteIndex := offset / 8 byteOffset := offset % 8 if byteOffset+length > 8 { rem := 8 - byteOffset return b.getBits(offset, rem) | (b.getBits(offset+rem, length-rem) << rem) } bitMask := uint32((1 << length) - 1) return (uint32(b.data[byteIndex]) & (bitMa...
go
func (b *Buckets) getBits(offset, length uint) uint32 { byteIndex := offset / 8 byteOffset := offset % 8 if byteOffset+length > 8 { rem := 8 - byteOffset return b.getBits(offset, rem) | (b.getBits(offset+rem, length-rem) << rem) } bitMask := uint32((1 << length) - 1) return (uint32(b.data[byteIndex]) & (bitMa...
[ "func", "(", "b", "*", "Buckets", ")", "getBits", "(", "offset", ",", "length", "uint", ")", "uint32", "{", "byteIndex", ":=", "offset", "/", "8", "\n", "byteOffset", ":=", "offset", "%", "8", "\n", "if", "byteOffset", "+", "length", ">", "8", "{", ...
// getBits returns the bits at the specified offset and length.
[ "getBits", "returns", "the", "bits", "at", "the", "specified", "offset", "and", "length", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/buckets.go#L79-L88
140,836
tylertreat/BoomFilters
buckets.go
setBits
func (b *Buckets) setBits(offset, length, bits uint32) { byteIndex := offset / 8 byteOffset := offset % 8 if byteOffset+length > 8 { rem := 8 - byteOffset b.setBits(offset, rem, bits) b.setBits(offset+rem, length-rem, bits>>rem) return } bitMask := uint32((1 << length) - 1) b.data[byteIndex] = byte(uint32...
go
func (b *Buckets) setBits(offset, length, bits uint32) { byteIndex := offset / 8 byteOffset := offset % 8 if byteOffset+length > 8 { rem := 8 - byteOffset b.setBits(offset, rem, bits) b.setBits(offset+rem, length-rem, bits>>rem) return } bitMask := uint32((1 << length) - 1) b.data[byteIndex] = byte(uint32...
[ "func", "(", "b", "*", "Buckets", ")", "setBits", "(", "offset", ",", "length", ",", "bits", "uint32", ")", "{", "byteIndex", ":=", "offset", "/", "8", "\n", "byteOffset", ":=", "offset", "%", "8", "\n", "if", "byteOffset", "+", "length", ">", "8", ...
// setBits sets bits at the specified offset and length.
[ "setBits", "sets", "bits", "at", "the", "specified", "offset", "and", "length", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/buckets.go#L91-L103
140,837
tylertreat/BoomFilters
stable.go
NewStableBloomFilter
func NewStableBloomFilter(m uint, d uint8, fpRate float64) *StableBloomFilter { k := OptimalK(fpRate) / 2 if k > m { k = m } else if k <= 0 { k = 1 } cells := NewBuckets(m, d) return &StableBloomFilter{ hash: fnv.New64(), m: m, k: k, p: optimalStableP(m, k, d, fp...
go
func NewStableBloomFilter(m uint, d uint8, fpRate float64) *StableBloomFilter { k := OptimalK(fpRate) / 2 if k > m { k = m } else if k <= 0 { k = 1 } cells := NewBuckets(m, d) return &StableBloomFilter{ hash: fnv.New64(), m: m, k: k, p: optimalStableP(m, k, d, fp...
[ "func", "NewStableBloomFilter", "(", "m", "uint", ",", "d", "uint8", ",", "fpRate", "float64", ")", "*", "StableBloomFilter", "{", "k", ":=", "OptimalK", "(", "fpRate", ")", "/", "2", "\n", "if", "k", ">", "m", "{", "k", "=", "m", "\n", "}", "else"...
// NewStableBloomFilter creates a new Stable Bloom Filter with m cells and d // bits allocated per cell optimized for the target false-positive rate. Use // NewDefaultStableFilter if you don't want to calculate d.
[ "NewStableBloomFilter", "creates", "a", "new", "Stable", "Bloom", "Filter", "with", "m", "cells", "and", "d", "bits", "allocated", "per", "cell", "optimized", "for", "the", "target", "false", "-", "positive", "rate", ".", "Use", "NewDefaultStableFilter", "if", ...
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/stable.go#L49-L68
140,838
tylertreat/BoomFilters
stable.go
NewUnstableBloomFilter
func NewUnstableBloomFilter(m uint, fpRate float64) *StableBloomFilter { var ( cells = NewBuckets(m, 1) k = OptimalK(fpRate) ) return &StableBloomFilter{ hash: fnv.New64(), m: m, k: k, p: 0, max: cells.MaxBucketValue(), cells: cells, indexBuff...
go
func NewUnstableBloomFilter(m uint, fpRate float64) *StableBloomFilter { var ( cells = NewBuckets(m, 1) k = OptimalK(fpRate) ) return &StableBloomFilter{ hash: fnv.New64(), m: m, k: k, p: 0, max: cells.MaxBucketValue(), cells: cells, indexBuff...
[ "func", "NewUnstableBloomFilter", "(", "m", "uint", ",", "fpRate", "float64", ")", "*", "StableBloomFilter", "{", "var", "(", "cells", "=", "NewBuckets", "(", "m", ",", "1", ")", "\n", "k", "=", "OptimalK", "(", "fpRate", ")", "\n", ")", "\n\n", "retur...
// NewUnstableBloomFilter creates a new special case of Stable Bloom Filter // which is a traditional Bloom filter with m bits and an optimal number of // hash functions for the target false-positive rate. Unlike the stable // variant, data is not evicted and a cell contains a maximum of 1 hash value.
[ "NewUnstableBloomFilter", "creates", "a", "new", "special", "case", "of", "Stable", "Bloom", "Filter", "which", "is", "a", "traditional", "Bloom", "filter", "with", "m", "bits", "and", "an", "optimal", "number", "of", "hash", "functions", "for", "the", "target...
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/stable.go#L82-L97
140,839
tylertreat/BoomFilters
stable.go
StablePoint
func (s *StableBloomFilter) StablePoint() float64 { var ( subDenom = float64(s.p) * (1/float64(s.k) - 1/float64(s.m)) denom = 1 + 1/subDenom base = 1 / denom ) return math.Pow(base, float64(s.max)) }
go
func (s *StableBloomFilter) StablePoint() float64 { var ( subDenom = float64(s.p) * (1/float64(s.k) - 1/float64(s.m)) denom = 1 + 1/subDenom base = 1 / denom ) return math.Pow(base, float64(s.max)) }
[ "func", "(", "s", "*", "StableBloomFilter", ")", "StablePoint", "(", ")", "float64", "{", "var", "(", "subDenom", "=", "float64", "(", "s", ".", "p", ")", "*", "(", "1", "/", "float64", "(", "s", ".", "k", ")", "-", "1", "/", "float64", "(", "s...
// StablePoint returns the limit of the expected fraction of zeros in the // Stable Bloom Filter when the number of iterations goes to infinity. When // this limit is reached, the Stable Bloom Filter is considered stable.
[ "StablePoint", "returns", "the", "limit", "of", "the", "expected", "fraction", "of", "zeros", "in", "the", "Stable", "Bloom", "Filter", "when", "the", "number", "of", "iterations", "goes", "to", "infinity", ".", "When", "this", "limit", "is", "reached", "the...
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/stable.go#L117-L125
140,840
tylertreat/BoomFilters
stable.go
FalsePositiveRate
func (s *StableBloomFilter) FalsePositiveRate() float64 { return math.Pow(1-s.StablePoint(), float64(s.k)) }
go
func (s *StableBloomFilter) FalsePositiveRate() float64 { return math.Pow(1-s.StablePoint(), float64(s.k)) }
[ "func", "(", "s", "*", "StableBloomFilter", ")", "FalsePositiveRate", "(", ")", "float64", "{", "return", "math", ".", "Pow", "(", "1", "-", "s", ".", "StablePoint", "(", ")", ",", "float64", "(", "s", ".", "k", ")", ")", "\n", "}" ]
// FalsePositiveRate returns the upper bound on false positives when the filter // has become stable.
[ "FalsePositiveRate", "returns", "the", "upper", "bound", "on", "false", "positives", "when", "the", "filter", "has", "become", "stable", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/stable.go#L129-L131
140,841
tylertreat/BoomFilters
stable.go
Add
func (s *StableBloomFilter) Add(data []byte) Filter { // Randomly decrement p cells to make room for new elements. s.decrement() lower, upper := hashKernel(data, s.hash) // Set the K cells to max. for i := uint(0); i < s.k; i++ { s.cells.Set((uint(lower)+uint(upper)*i)%s.m, s.max) } return s }
go
func (s *StableBloomFilter) Add(data []byte) Filter { // Randomly decrement p cells to make room for new elements. s.decrement() lower, upper := hashKernel(data, s.hash) // Set the K cells to max. for i := uint(0); i < s.k; i++ { s.cells.Set((uint(lower)+uint(upper)*i)%s.m, s.max) } return s }
[ "func", "(", "s", "*", "StableBloomFilter", ")", "Add", "(", "data", "[", "]", "byte", ")", "Filter", "{", "// Randomly decrement p cells to make room for new elements.", "s", ".", "decrement", "(", ")", "\n\n", "lower", ",", "upper", ":=", "hashKernel", "(", ...
// Add will add the data to the Stable Bloom Filter. It returns the filter to // allow for chaining.
[ "Add", "will", "add", "the", "data", "to", "the", "Stable", "Bloom", "Filter", ".", "It", "returns", "the", "filter", "to", "allow", "for", "chaining", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/stable.go#L151-L163
140,842
tylertreat/BoomFilters
stable.go
optimalStableP
func optimalStableP(m, k uint, d uint8, fpRate float64) uint { var ( max = math.Pow(2, float64(d)) - 1 subDenom = math.Pow(1-math.Pow(fpRate, 1/float64(k)), 1/max) denom = (1/subDenom - 1) * (1/float64(k) - 1/float64(m)) ) p := uint(1 / denom) if p <= 0 { p = 1 } return p }
go
func optimalStableP(m, k uint, d uint8, fpRate float64) uint { var ( max = math.Pow(2, float64(d)) - 1 subDenom = math.Pow(1-math.Pow(fpRate, 1/float64(k)), 1/max) denom = (1/subDenom - 1) * (1/float64(k) - 1/float64(m)) ) p := uint(1 / denom) if p <= 0 { p = 1 } return p }
[ "func", "optimalStableP", "(", "m", ",", "k", "uint", ",", "d", "uint8", ",", "fpRate", "float64", ")", "uint", "{", "var", "(", "max", "=", "math", ".", "Pow", "(", "2", ",", "float64", "(", "d", ")", ")", "-", "1", "\n", "subDenom", "=", "mat...
// optimalStableP returns the optimal number of cells to decrement, p, per // iteration for the provided parameters of an SBF.
[ "optimalStableP", "returns", "the", "optimal", "number", "of", "cells", "to", "decrement", "p", "per", "iteration", "for", "the", "provided", "parameters", "of", "an", "SBF", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/stable.go#L320-L333
140,843
tylertreat/BoomFilters
scalable.go
NewScalableBloomFilter
func NewScalableBloomFilter(hint uint, fpRate, r float64) *ScalableBloomFilter { s := &ScalableBloomFilter{ filters: make([]*PartitionedBloomFilter, 0, 1), r: r, fp: fpRate, p: fillRatio, hint: hint, } s.addFilter() return s }
go
func NewScalableBloomFilter(hint uint, fpRate, r float64) *ScalableBloomFilter { s := &ScalableBloomFilter{ filters: make([]*PartitionedBloomFilter, 0, 1), r: r, fp: fpRate, p: fillRatio, hint: hint, } s.addFilter() return s }
[ "func", "NewScalableBloomFilter", "(", "hint", "uint", ",", "fpRate", ",", "r", "float64", ")", "*", "ScalableBloomFilter", "{", "s", ":=", "&", "ScalableBloomFilter", "{", "filters", ":", "make", "(", "[", "]", "*", "PartitionedBloomFilter", ",", "0", ",", ...
// NewScalableBloomFilter creates a new Scalable Bloom Filter with the // specified target false-positive rate and tightening ratio. Use // NewDefaultScalableBloomFilter if you don't want to calculate these // parameters.
[ "NewScalableBloomFilter", "creates", "a", "new", "Scalable", "Bloom", "Filter", "with", "the", "specified", "target", "false", "-", "positive", "rate", "and", "tightening", "ratio", ".", "Use", "NewDefaultScalableBloomFilter", "if", "you", "don", "t", "want", "to"...
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/scalable.go#L54-L65
140,844
tylertreat/BoomFilters
scalable.go
Capacity
func (s *ScalableBloomFilter) Capacity() uint { capacity := uint(0) for _, bf := range s.filters { capacity += bf.Capacity() } return capacity }
go
func (s *ScalableBloomFilter) Capacity() uint { capacity := uint(0) for _, bf := range s.filters { capacity += bf.Capacity() } return capacity }
[ "func", "(", "s", "*", "ScalableBloomFilter", ")", "Capacity", "(", ")", "uint", "{", "capacity", ":=", "uint", "(", "0", ")", "\n", "for", "_", ",", "bf", ":=", "range", "s", ".", "filters", "{", "capacity", "+=", "bf", ".", "Capacity", "(", ")", ...
// Capacity returns the current Scalable Bloom Filter capacity, which is the // sum of the capacities for the contained series of Bloom filters.
[ "Capacity", "returns", "the", "current", "Scalable", "Bloom", "Filter", "capacity", "which", "is", "the", "sum", "of", "the", "capacities", "for", "the", "contained", "series", "of", "Bloom", "filters", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/scalable.go#L75-L81
140,845
tylertreat/BoomFilters
scalable.go
FillRatio
func (s *ScalableBloomFilter) FillRatio() float64 { sum := 0.0 for _, filter := range s.filters { sum += filter.FillRatio() } return sum / float64(len(s.filters)) }
go
func (s *ScalableBloomFilter) FillRatio() float64 { sum := 0.0 for _, filter := range s.filters { sum += filter.FillRatio() } return sum / float64(len(s.filters)) }
[ "func", "(", "s", "*", "ScalableBloomFilter", ")", "FillRatio", "(", ")", "float64", "{", "sum", ":=", "0.0", "\n", "for", "_", ",", "filter", ":=", "range", "s", ".", "filters", "{", "sum", "+=", "filter", ".", "FillRatio", "(", ")", "\n", "}", "\...
// FillRatio returns the average ratio of set bits across every filter.
[ "FillRatio", "returns", "the", "average", "ratio", "of", "set", "bits", "across", "every", "filter", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/scalable.go#L90-L96
140,846
tylertreat/BoomFilters
scalable.go
addFilter
func (s *ScalableBloomFilter) addFilter() { fpRate := s.fp * math.Pow(s.r, float64(len(s.filters))) p := NewPartitionedBloomFilter(s.hint, fpRate) if len(s.filters) > 0 { p.SetHash(s.filters[0].hash) } s.filters = append(s.filters, p) }
go
func (s *ScalableBloomFilter) addFilter() { fpRate := s.fp * math.Pow(s.r, float64(len(s.filters))) p := NewPartitionedBloomFilter(s.hint, fpRate) if len(s.filters) > 0 { p.SetHash(s.filters[0].hash) } s.filters = append(s.filters, p) }
[ "func", "(", "s", "*", "ScalableBloomFilter", ")", "addFilter", "(", ")", "{", "fpRate", ":=", "s", ".", "fp", "*", "math", ".", "Pow", "(", "s", ".", "r", ",", "float64", "(", "len", "(", "s", ".", "filters", ")", ")", ")", "\n", "p", ":=", ...
// addFilter adds a new Bloom filter with a restricted false-positive rate to // the Scalable Bloom Filter
[ "addFilter", "adds", "a", "new", "Bloom", "filter", "with", "a", "restricted", "false", "-", "positive", "rate", "to", "the", "Scalable", "Bloom", "Filter" ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/scalable.go#L146-L153
140,847
tylertreat/BoomFilters
hyperloglog.go
NewHyperLogLog
func NewHyperLogLog(m uint) (*HyperLogLog, error) { if (m & (m - 1)) != 0 { return nil, errors.New("m must be a power of two") } return &HyperLogLog{ registers: make([]uint8, m), m: m, b: uint32(math.Ceil(math.Log2(float64(m)))), alpha: calculateAlpha(m), hash: fnv.New32(), }, ...
go
func NewHyperLogLog(m uint) (*HyperLogLog, error) { if (m & (m - 1)) != 0 { return nil, errors.New("m must be a power of two") } return &HyperLogLog{ registers: make([]uint8, m), m: m, b: uint32(math.Ceil(math.Log2(float64(m)))), alpha: calculateAlpha(m), hash: fnv.New32(), }, ...
[ "func", "NewHyperLogLog", "(", "m", "uint", ")", "(", "*", "HyperLogLog", ",", "error", ")", "{", "if", "(", "m", "&", "(", "m", "-", "1", ")", ")", "!=", "0", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", ...
// NewHyperLogLog creates a new HyperLogLog with m registers. Returns an error // if m isn't a power of two.
[ "NewHyperLogLog", "creates", "a", "new", "HyperLogLog", "with", "m", "registers", ".", "Returns", "an", "error", "if", "m", "isn", "t", "a", "power", "of", "two", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/hyperloglog.go#L61-L73
140,848
tylertreat/BoomFilters
hyperloglog.go
NewDefaultHyperLogLog
func NewDefaultHyperLogLog(e float64) (*HyperLogLog, error) { m := math.Pow(1.04/e, 2) return NewHyperLogLog(uint(math.Pow(2, math.Ceil(math.Log2(m))))) }
go
func NewDefaultHyperLogLog(e float64) (*HyperLogLog, error) { m := math.Pow(1.04/e, 2) return NewHyperLogLog(uint(math.Pow(2, math.Ceil(math.Log2(m))))) }
[ "func", "NewDefaultHyperLogLog", "(", "e", "float64", ")", "(", "*", "HyperLogLog", ",", "error", ")", "{", "m", ":=", "math", ".", "Pow", "(", "1.04", "/", "e", ",", "2", ")", "\n", "return", "NewHyperLogLog", "(", "uint", "(", "math", ".", "Pow", ...
// NewDefaultHyperLogLog creates a new HyperLogLog optimized for the specified // standard error. Returns an error if the number of registers can't be // calculated for the provided accuracy.
[ "NewDefaultHyperLogLog", "creates", "a", "new", "HyperLogLog", "optimized", "for", "the", "specified", "standard", "error", ".", "Returns", "an", "error", "if", "the", "number", "of", "registers", "can", "t", "be", "calculated", "for", "the", "provided", "accura...
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/hyperloglog.go#L78-L81
140,849
tylertreat/BoomFilters
hyperloglog.go
Add
func (h *HyperLogLog) Add(data []byte) *HyperLogLog { var ( hash = h.calculateHash(data) k = 32 - h.b r = calculateRho(hash<<h.b, k) j = hash >> uint(k) ) if r > h.registers[j] { h.registers[j] = r } return h }
go
func (h *HyperLogLog) Add(data []byte) *HyperLogLog { var ( hash = h.calculateHash(data) k = 32 - h.b r = calculateRho(hash<<h.b, k) j = hash >> uint(k) ) if r > h.registers[j] { h.registers[j] = r } return h }
[ "func", "(", "h", "*", "HyperLogLog", ")", "Add", "(", "data", "[", "]", "byte", ")", "*", "HyperLogLog", "{", "var", "(", "hash", "=", "h", ".", "calculateHash", "(", "data", ")", "\n", "k", "=", "32", "-", "h", ".", "b", "\n", "r", "=", "ca...
// Add will add the data to the set. Returns the HyperLogLog to allow for // chaining.
[ "Add", "will", "add", "the", "data", "to", "the", "set", ".", "Returns", "the", "HyperLogLog", "to", "allow", "for", "chaining", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/hyperloglog.go#L85-L98
140,850
tylertreat/BoomFilters
hyperloglog.go
Count
func (h *HyperLogLog) Count() uint64 { sum := 0.0 m := float64(h.m) for _, val := range h.registers { sum += 1.0 / math.Pow(2.0, float64(val)) } estimate := h.alpha * m * m / sum if estimate <= 5.0/2.0*m { // Small range correction v := 0 for _, r := range h.registers { if r == 0 { v++ } } i...
go
func (h *HyperLogLog) Count() uint64 { sum := 0.0 m := float64(h.m) for _, val := range h.registers { sum += 1.0 / math.Pow(2.0, float64(val)) } estimate := h.alpha * m * m / sum if estimate <= 5.0/2.0*m { // Small range correction v := 0 for _, r := range h.registers { if r == 0 { v++ } } i...
[ "func", "(", "h", "*", "HyperLogLog", ")", "Count", "(", ")", "uint64", "{", "sum", ":=", "0.0", "\n", "m", ":=", "float64", "(", "h", ".", "m", ")", "\n", "for", "_", ",", "val", ":=", "range", "h", ".", "registers", "{", "sum", "+=", "1.0", ...
// Count returns the approximated cardinality of the set.
[ "Count", "returns", "the", "approximated", "cardinality", "of", "the", "set", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/hyperloglog.go#L101-L124
140,851
tylertreat/BoomFilters
hyperloglog.go
Merge
func (h *HyperLogLog) Merge(other *HyperLogLog) error { if h.m != other.m { return errors.New("number of registers must match") } for j, r := range other.registers { if r > h.registers[j] { h.registers[j] = r } } return nil }
go
func (h *HyperLogLog) Merge(other *HyperLogLog) error { if h.m != other.m { return errors.New("number of registers must match") } for j, r := range other.registers { if r > h.registers[j] { h.registers[j] = r } } return nil }
[ "func", "(", "h", "*", "HyperLogLog", ")", "Merge", "(", "other", "*", "HyperLogLog", ")", "error", "{", "if", "h", ".", "m", "!=", "other", ".", "m", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "for", "j", ","...
// Merge combines this HyperLogLog with another. Returns an error if the number // of registers in the two HyperLogLogs are not equal.
[ "Merge", "combines", "this", "HyperLogLog", "with", "another", ".", "Returns", "an", "error", "if", "the", "number", "of", "registers", "in", "the", "two", "HyperLogLogs", "are", "not", "equal", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/hyperloglog.go#L128-L140
140,852
tylertreat/BoomFilters
hyperloglog.go
Reset
func (h *HyperLogLog) Reset() *HyperLogLog { h.registers = make([]uint8, h.m) return h }
go
func (h *HyperLogLog) Reset() *HyperLogLog { h.registers = make([]uint8, h.m) return h }
[ "func", "(", "h", "*", "HyperLogLog", ")", "Reset", "(", ")", "*", "HyperLogLog", "{", "h", ".", "registers", "=", "make", "(", "[", "]", "uint8", ",", "h", ".", "m", ")", "\n", "return", "h", "\n", "}" ]
// Reset restores the HyperLogLog to its original state. It returns itself to // allow for chaining.
[ "Reset", "restores", "the", "HyperLogLog", "to", "its", "original", "state", ".", "It", "returns", "itself", "to", "allow", "for", "chaining", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/hyperloglog.go#L144-L147
140,853
tylertreat/BoomFilters
hyperloglog.go
calculateHash
func (h *HyperLogLog) calculateHash(data []byte) uint32 { h.hash.Write(data) sum := h.hash.Sum32() h.hash.Reset() return sum }
go
func (h *HyperLogLog) calculateHash(data []byte) uint32 { h.hash.Write(data) sum := h.hash.Sum32() h.hash.Reset() return sum }
[ "func", "(", "h", "*", "HyperLogLog", ")", "calculateHash", "(", "data", "[", "]", "byte", ")", "uint32", "{", "h", ".", "hash", ".", "Write", "(", "data", ")", "\n", "sum", ":=", "h", ".", "hash", ".", "Sum32", "(", ")", "\n", "h", ".", "hash"...
// calculateHash calculates the 32-bit hash value for the provided data.
[ "calculateHash", "calculates", "the", "32", "-", "bit", "hash", "value", "for", "the", "provided", "data", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/hyperloglog.go#L150-L155
140,854
tylertreat/BoomFilters
hyperloglog.go
calculateAlpha
func calculateAlpha(m uint) (result float64) { switch m { case 16: result = 0.673 case 32: result = 0.697 case 64: result = 0.709 default: result = 0.7213 / (1.0 + 1.079/float64(m)) } return result }
go
func calculateAlpha(m uint) (result float64) { switch m { case 16: result = 0.673 case 32: result = 0.697 case 64: result = 0.709 default: result = 0.7213 / (1.0 + 1.079/float64(m)) } return result }
[ "func", "calculateAlpha", "(", "m", "uint", ")", "(", "result", "float64", ")", "{", "switch", "m", "{", "case", "16", ":", "result", "=", "0.673", "\n", "case", "32", ":", "result", "=", "0.697", "\n", "case", "64", ":", "result", "=", "0.709", "\...
// calculateAlpha calculates the bias-correction constant alpha based on the // number of registers, m.
[ "calculateAlpha", "calculates", "the", "bias", "-", "correction", "constant", "alpha", "based", "on", "the", "number", "of", "registers", "m", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/hyperloglog.go#L164-L176
140,855
tylertreat/BoomFilters
hyperloglog.go
calculateRho
func calculateRho(val, max uint32) uint8 { r := uint32(1) for val&0x80000000 == 0 && r <= max { r++ val <<= 1 } return uint8(r) }
go
func calculateRho(val, max uint32) uint8 { r := uint32(1) for val&0x80000000 == 0 && r <= max { r++ val <<= 1 } return uint8(r) }
[ "func", "calculateRho", "(", "val", ",", "max", "uint32", ")", "uint8", "{", "r", ":=", "uint32", "(", "1", ")", "\n", "for", "val", "&", "0x80000000", "==", "0", "&&", "r", "<=", "max", "{", "r", "++", "\n", "val", "<<=", "1", "\n", "}", "\n",...
// calculateRho calculates the position of the leftmost 1-bit.
[ "calculateRho", "calculates", "the", "position", "of", "the", "leftmost", "1", "-", "bit", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/hyperloglog.go#L179-L186
140,856
tylertreat/BoomFilters
hyperloglog.go
WriteDataTo
func (h *HyperLogLog) WriteDataTo(stream io.Writer) (n int, err error) { buf := new(bytes.Buffer) // write register number first err = binary.Write(buf, binary.LittleEndian, uint64(h.m)) if err != nil { return } err = binary.Write(buf, binary.LittleEndian, h.b) if err != nil { return } err = binary.Write...
go
func (h *HyperLogLog) WriteDataTo(stream io.Writer) (n int, err error) { buf := new(bytes.Buffer) // write register number first err = binary.Write(buf, binary.LittleEndian, uint64(h.m)) if err != nil { return } err = binary.Write(buf, binary.LittleEndian, h.b) if err != nil { return } err = binary.Write...
[ "func", "(", "h", "*", "HyperLogLog", ")", "WriteDataTo", "(", "stream", "io", ".", "Writer", ")", "(", "n", "int", ",", "err", "error", ")", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n", "// write register number first", "err", "=",...
// WriteDataTo writes a binary representation of the Hll data to // an io stream. It returns the number of bytes written and error
[ "WriteDataTo", "writes", "a", "binary", "representation", "of", "the", "Hll", "data", "to", "an", "io", "stream", ".", "It", "returns", "the", "number", "of", "bytes", "written", "and", "error" ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/hyperloglog.go#L190-L215
140,857
tylertreat/BoomFilters
boom.go
OptimalM
func OptimalM(n uint, fpRate float64) uint { return uint(math.Ceil(float64(n) / ((math.Log(fillRatio) * math.Log(1-fillRatio)) / math.Abs(math.Log(fpRate))))) }
go
func OptimalM(n uint, fpRate float64) uint { return uint(math.Ceil(float64(n) / ((math.Log(fillRatio) * math.Log(1-fillRatio)) / math.Abs(math.Log(fpRate))))) }
[ "func", "OptimalM", "(", "n", "uint", ",", "fpRate", "float64", ")", "uint", "{", "return", "uint", "(", "math", ".", "Ceil", "(", "float64", "(", "n", ")", "/", "(", "(", "math", ".", "Log", "(", "fillRatio", ")", "*", "math", ".", "Log", "(", ...
// OptimalM calculates the optimal Bloom filter size, m, based on the number of // items and the desired rate of false positives.
[ "OptimalM", "calculates", "the", "optimal", "Bloom", "filter", "size", "m", "based", "on", "the", "number", "of", "items", "and", "the", "desired", "rate", "of", "false", "positives", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/boom.go#L65-L68
140,858
tylertreat/BoomFilters
boom.go
OptimalK
func OptimalK(fpRate float64) uint { return uint(math.Ceil(math.Log2(1 / fpRate))) }
go
func OptimalK(fpRate float64) uint { return uint(math.Ceil(math.Log2(1 / fpRate))) }
[ "func", "OptimalK", "(", "fpRate", "float64", ")", "uint", "{", "return", "uint", "(", "math", ".", "Ceil", "(", "math", ".", "Log2", "(", "1", "/", "fpRate", ")", ")", ")", "\n", "}" ]
// OptimalK calculates the optimal number of hash functions to use for a Bloom // filter based on the desired rate of false positives.
[ "OptimalK", "calculates", "the", "optimal", "number", "of", "hash", "functions", "to", "use", "for", "a", "Bloom", "filter", "based", "on", "the", "desired", "rate", "of", "false", "positives", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/boom.go#L72-L74
140,859
tylertreat/BoomFilters
boom.go
hashKernel
func hashKernel(data []byte, hash hash.Hash64) (uint32, uint32) { hash.Write(data) sum := hash.Sum(nil) hash.Reset() return binary.BigEndian.Uint32(sum[4:8]), binary.BigEndian.Uint32(sum[0:4]) }
go
func hashKernel(data []byte, hash hash.Hash64) (uint32, uint32) { hash.Write(data) sum := hash.Sum(nil) hash.Reset() return binary.BigEndian.Uint32(sum[4:8]), binary.BigEndian.Uint32(sum[0:4]) }
[ "func", "hashKernel", "(", "data", "[", "]", "byte", ",", "hash", "hash", ".", "Hash64", ")", "(", "uint32", ",", "uint32", ")", "{", "hash", ".", "Write", "(", "data", ")", "\n", "sum", ":=", "hash", ".", "Sum", "(", "nil", ")", "\n", "hash", ...
// hashKernel returns the upper and lower base hash values from which the k // hashes are derived.
[ "hashKernel", "returns", "the", "upper", "and", "lower", "base", "hash", "values", "from", "which", "the", "k", "hashes", "are", "derived", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/boom.go#L78-L83
140,860
tylertreat/BoomFilters
partitioned.go
NewPartitionedBloomFilter
func NewPartitionedBloomFilter(n uint, fpRate float64) *PartitionedBloomFilter { var ( m = OptimalM(n, fpRate) k = OptimalK(fpRate) partitions = make([]*Buckets, k) s = uint(math.Ceil(float64(m) / float64(k))) ) for i := uint(0); i < k; i++ { partitions[i] = NewBuckets(s, 1) } ...
go
func NewPartitionedBloomFilter(n uint, fpRate float64) *PartitionedBloomFilter { var ( m = OptimalM(n, fpRate) k = OptimalK(fpRate) partitions = make([]*Buckets, k) s = uint(math.Ceil(float64(m) / float64(k))) ) for i := uint(0); i < k; i++ { partitions[i] = NewBuckets(s, 1) } ...
[ "func", "NewPartitionedBloomFilter", "(", "n", "uint", ",", "fpRate", "float64", ")", "*", "PartitionedBloomFilter", "{", "var", "(", "m", "=", "OptimalM", "(", "n", ",", "fpRate", ")", "\n", "k", "=", "OptimalK", "(", "fpRate", ")", "\n", "partitions", ...
// NewPartitionedBloomFilter creates a new partitioned Bloom filter optimized // to store n items with a specified target false-positive rate.
[ "NewPartitionedBloomFilter", "creates", "a", "new", "partitioned", "Bloom", "filter", "optimized", "to", "store", "n", "items", "with", "a", "specified", "target", "false", "-", "positive", "rate", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/partitioned.go#L48-L67
140,861
tylertreat/BoomFilters
partitioned.go
FillRatio
func (p *PartitionedBloomFilter) FillRatio() float64 { t := float64(0) for i := uint(0); i < p.k; i++ { sum := uint32(0) for j := uint(0); j < p.partitions[i].Count(); j++ { sum += p.partitions[i].Get(j) } t += (float64(sum) / float64(p.s)) } return t / float64(p.k) }
go
func (p *PartitionedBloomFilter) FillRatio() float64 { t := float64(0) for i := uint(0); i < p.k; i++ { sum := uint32(0) for j := uint(0); j < p.partitions[i].Count(); j++ { sum += p.partitions[i].Get(j) } t += (float64(sum) / float64(p.s)) } return t / float64(p.k) }
[ "func", "(", "p", "*", "PartitionedBloomFilter", ")", "FillRatio", "(", ")", "float64", "{", "t", ":=", "float64", "(", "0", ")", "\n", "for", "i", ":=", "uint", "(", "0", ")", ";", "i", "<", "p", ".", "k", ";", "i", "++", "{", "sum", ":=", "...
// FillRatio returns the average ratio of set bits across all partitions.
[ "FillRatio", "returns", "the", "average", "ratio", "of", "set", "bits", "across", "all", "partitions", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/partitioned.go#L90-L100
140,862
tylertreat/BoomFilters
classic.go
NewBloomFilter
func NewBloomFilter(n uint, fpRate float64) *BloomFilter { m := OptimalM(n, fpRate) return &BloomFilter{ buckets: NewBuckets(m, 1), hash: fnv.New64(), m: m, k: OptimalK(fpRate), } }
go
func NewBloomFilter(n uint, fpRate float64) *BloomFilter { m := OptimalM(n, fpRate) return &BloomFilter{ buckets: NewBuckets(m, 1), hash: fnv.New64(), m: m, k: OptimalK(fpRate), } }
[ "func", "NewBloomFilter", "(", "n", "uint", ",", "fpRate", "float64", ")", "*", "BloomFilter", "{", "m", ":=", "OptimalM", "(", "n", ",", "fpRate", ")", "\n", "return", "&", "BloomFilter", "{", "buckets", ":", "NewBuckets", "(", "m", ",", "1", ")", "...
// NewBloomFilter creates a new Bloom filter optimized to store n items with a // specified target false-positive rate.
[ "NewBloomFilter", "creates", "a", "new", "Bloom", "filter", "optimized", "to", "store", "n", "items", "with", "a", "specified", "target", "false", "-", "positive", "rate", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/classic.go#L24-L32
140,863
tylertreat/BoomFilters
classic.go
FillRatio
func (b *BloomFilter) FillRatio() float64 { sum := uint32(0) for i := uint(0); i < b.buckets.Count(); i++ { sum += b.buckets.Get(i) } return float64(sum) / float64(b.m) }
go
func (b *BloomFilter) FillRatio() float64 { sum := uint32(0) for i := uint(0); i < b.buckets.Count(); i++ { sum += b.buckets.Get(i) } return float64(sum) / float64(b.m) }
[ "func", "(", "b", "*", "BloomFilter", ")", "FillRatio", "(", ")", "float64", "{", "sum", ":=", "uint32", "(", "0", ")", "\n", "for", "i", ":=", "uint", "(", "0", ")", ";", "i", "<", "b", ".", "buckets", ".", "Count", "(", ")", ";", "i", "++",...
// FillRatio returns the ratio of set bits.
[ "FillRatio", "returns", "the", "ratio", "of", "set", "bits", "." ]
611b3dbe80e85df3a0a10a43997d4d5784e86245
https://github.com/tylertreat/BoomFilters/blob/611b3dbe80e85df3a0a10a43997d4d5784e86245/classic.go#L55-L61
140,864
howeyc/fsnotify
fsnotify_windows.go
NewWatcher
func NewWatcher() (*Watcher, error) { port, e := syscall.CreateIoCompletionPort(syscall.InvalidHandle, 0, 0, 0) if e != nil { return nil, os.NewSyscallError("CreateIoCompletionPort", e) } w := &Watcher{ port: port, watches: make(watchMap), fsnFlags: make(map[string]uint32), input: ...
go
func NewWatcher() (*Watcher, error) { port, e := syscall.CreateIoCompletionPort(syscall.InvalidHandle, 0, 0, 0) if e != nil { return nil, os.NewSyscallError("CreateIoCompletionPort", e) } w := &Watcher{ port: port, watches: make(watchMap), fsnFlags: make(map[string]uint32), input: ...
[ "func", "NewWatcher", "(", ")", "(", "*", "Watcher", ",", "error", ")", "{", "port", ",", "e", ":=", "syscall", ".", "CreateIoCompletionPort", "(", "syscall", ".", "InvalidHandle", ",", "0", ",", "0", ",", "0", ")", "\n", "if", "e", "!=", "nil", "{...
// NewWatcher creates and returns a Watcher.
[ "NewWatcher", "creates", "and", "returns", "a", "Watcher", "." ]
f0c08ee9c60704c1879025f2ae0ff3e000082c13
https://github.com/howeyc/fsnotify/blob/f0c08ee9c60704c1879025f2ae0ff3e000082c13/fsnotify_windows.go#L133-L151
140,865
howeyc/fsnotify
fsnotify.go
purgeEvents
func (w *Watcher) purgeEvents() { for ev := range w.internalEvent { sendEvent := false w.fsnmut.Lock() fsnFlags := w.fsnFlags[ev.Name] w.fsnmut.Unlock() if (fsnFlags&FSN_CREATE == FSN_CREATE) && ev.IsCreate() { sendEvent = true } if (fsnFlags&FSN_MODIFY == FSN_MODIFY) && ev.IsModify() { sendEvent...
go
func (w *Watcher) purgeEvents() { for ev := range w.internalEvent { sendEvent := false w.fsnmut.Lock() fsnFlags := w.fsnFlags[ev.Name] w.fsnmut.Unlock() if (fsnFlags&FSN_CREATE == FSN_CREATE) && ev.IsCreate() { sendEvent = true } if (fsnFlags&FSN_MODIFY == FSN_MODIFY) && ev.IsModify() { sendEvent...
[ "func", "(", "w", "*", "Watcher", ")", "purgeEvents", "(", ")", "{", "for", "ev", ":=", "range", "w", ".", "internalEvent", "{", "sendEvent", ":=", "false", "\n", "w", ".", "fsnmut", ".", "Lock", "(", ")", "\n", "fsnFlags", ":=", "w", ".", "fsnFlag...
// Purge events from interal chan to external chan if passes filter
[ "Purge", "events", "from", "interal", "chan", "to", "external", "chan", "if", "passes", "filter" ]
f0c08ee9c60704c1879025f2ae0ff3e000082c13
https://github.com/howeyc/fsnotify/blob/f0c08ee9c60704c1879025f2ae0ff3e000082c13/fsnotify.go#L20-L58
140,866
howeyc/fsnotify
fsnotify.go
Watch
func (w *Watcher) Watch(path string) error { return w.WatchFlags(path, FSN_ALL) }
go
func (w *Watcher) Watch(path string) error { return w.WatchFlags(path, FSN_ALL) }
[ "func", "(", "w", "*", "Watcher", ")", "Watch", "(", "path", "string", ")", "error", "{", "return", "w", ".", "WatchFlags", "(", "path", ",", "FSN_ALL", ")", "\n", "}" ]
// Watch a given file path
[ "Watch", "a", "given", "file", "path" ]
f0c08ee9c60704c1879025f2ae0ff3e000082c13
https://github.com/howeyc/fsnotify/blob/f0c08ee9c60704c1879025f2ae0ff3e000082c13/fsnotify.go#L61-L63
140,867
howeyc/fsnotify
fsnotify.go
RemoveWatch
func (w *Watcher) RemoveWatch(path string) error { w.fsnmut.Lock() delete(w.fsnFlags, path) w.fsnmut.Unlock() return w.removeWatch(path) }
go
func (w *Watcher) RemoveWatch(path string) error { w.fsnmut.Lock() delete(w.fsnFlags, path) w.fsnmut.Unlock() return w.removeWatch(path) }
[ "func", "(", "w", "*", "Watcher", ")", "RemoveWatch", "(", "path", "string", ")", "error", "{", "w", ".", "fsnmut", ".", "Lock", "(", ")", "\n", "delete", "(", "w", ".", "fsnFlags", ",", "path", ")", "\n", "w", ".", "fsnmut", ".", "Unlock", "(", ...
// Remove a watch on a file
[ "Remove", "a", "watch", "on", "a", "file" ]
f0c08ee9c60704c1879025f2ae0ff3e000082c13
https://github.com/howeyc/fsnotify/blob/f0c08ee9c60704c1879025f2ae0ff3e000082c13/fsnotify.go#L74-L79
140,868
howeyc/fsnotify
fsnotify_linux.go
IsCreate
func (e *FileEvent) IsCreate() bool { return (e.mask&sys_IN_CREATE) == sys_IN_CREATE || (e.mask&sys_IN_MOVED_TO) == sys_IN_MOVED_TO }
go
func (e *FileEvent) IsCreate() bool { return (e.mask&sys_IN_CREATE) == sys_IN_CREATE || (e.mask&sys_IN_MOVED_TO) == sys_IN_MOVED_TO }
[ "func", "(", "e", "*", "FileEvent", ")", "IsCreate", "(", ")", "bool", "{", "return", "(", "e", ".", "mask", "&", "sys_IN_CREATE", ")", "==", "sys_IN_CREATE", "||", "(", "e", ".", "mask", "&", "sys_IN_MOVED_TO", ")", "==", "sys_IN_MOVED_TO", "\n", "}" ...
// IsCreate reports whether the FileEvent was triggered by a creation
[ "IsCreate", "reports", "whether", "the", "FileEvent", "was", "triggered", "by", "a", "creation" ]
f0c08ee9c60704c1879025f2ae0ff3e000082c13
https://github.com/howeyc/fsnotify/blob/f0c08ee9c60704c1879025f2ae0ff3e000082c13/fsnotify_linux.go#L66-L68
140,869
howeyc/fsnotify
fsnotify_linux.go
Close
func (w *Watcher) Close() error { if w.isClosed { return nil } w.isClosed = true // Remove all watches for path := range w.watches { w.RemoveWatch(path) } // Send "quit" message to the reader goroutine w.done <- true return nil }
go
func (w *Watcher) Close() error { if w.isClosed { return nil } w.isClosed = true // Remove all watches for path := range w.watches { w.RemoveWatch(path) } // Send "quit" message to the reader goroutine w.done <- true return nil }
[ "func", "(", "w", "*", "Watcher", ")", "Close", "(", ")", "error", "{", "if", "w", ".", "isClosed", "{", "return", "nil", "\n", "}", "\n", "w", ".", "isClosed", "=", "true", "\n\n", "// Remove all watches", "for", "path", ":=", "range", "w", ".", "...
// Close closes an inotify watcher instance // It sends a message to the reader goroutine to quit and removes all watches // associated with the inotify instance
[ "Close", "closes", "an", "inotify", "watcher", "instance", "It", "sends", "a", "message", "to", "the", "reader", "goroutine", "to", "quit", "and", "removes", "all", "watches", "associated", "with", "the", "inotify", "instance" ]
f0c08ee9c60704c1879025f2ae0ff3e000082c13
https://github.com/howeyc/fsnotify/blob/f0c08ee9c60704c1879025f2ae0ff3e000082c13/fsnotify_linux.go#L134-L149
140,870
howeyc/fsnotify
fsnotify_linux.go
readEvents
func (w *Watcher) readEvents() { var ( buf [syscall.SizeofInotifyEvent * 4096]byte // Buffer for a maximum of 4096 raw events n int // Number of bytes read with read() errno error // Syscall errno ) for { // See if there is a messag...
go
func (w *Watcher) readEvents() { var ( buf [syscall.SizeofInotifyEvent * 4096]byte // Buffer for a maximum of 4096 raw events n int // Number of bytes read with read() errno error // Syscall errno ) for { // See if there is a messag...
[ "func", "(", "w", "*", "Watcher", ")", "readEvents", "(", ")", "{", "var", "(", "buf", "[", "syscall", ".", "SizeofInotifyEvent", "*", "4096", "]", "byte", "// Buffer for a maximum of 4096 raw events", "\n", "n", "int", "// Number of bytes read with read()", "\n",...
// readEvents reads from the inotify file descriptor, converts the // received events into Event objects and sends them via the Event channel
[ "readEvents", "reads", "from", "the", "inotify", "file", "descriptor", "converts", "the", "received", "events", "into", "Event", "objects", "and", "sends", "them", "via", "the", "Event", "channel" ]
f0c08ee9c60704c1879025f2ae0ff3e000082c13
https://github.com/howeyc/fsnotify/blob/f0c08ee9c60704c1879025f2ae0ff3e000082c13/fsnotify_linux.go#L201-L283
140,871
howeyc/fsnotify
fsnotify_linux.go
ignoreLinux
func (e *FileEvent) ignoreLinux() bool { // Ignore anything the inotify API says to ignore if e.mask&sys_IN_IGNORED == sys_IN_IGNORED { return true } // If the event is not a DELETE or RENAME, the file must exist. // Otherwise the event is ignored. // *Note*: this was put in place because it was seen that a MO...
go
func (e *FileEvent) ignoreLinux() bool { // Ignore anything the inotify API says to ignore if e.mask&sys_IN_IGNORED == sys_IN_IGNORED { return true } // If the event is not a DELETE or RENAME, the file must exist. // Otherwise the event is ignored. // *Note*: this was put in place because it was seen that a MO...
[ "func", "(", "e", "*", "FileEvent", ")", "ignoreLinux", "(", ")", "bool", "{", "// Ignore anything the inotify API says to ignore", "if", "e", ".", "mask", "&", "sys_IN_IGNORED", "==", "sys_IN_IGNORED", "{", "return", "true", "\n", "}", "\n\n", "// If the event is...
// Certain types of events can be "ignored" and not sent over the Event // channel. Such as events marked ignore by the kernel, or MODIFY events // against files that do not exist.
[ "Certain", "types", "of", "events", "can", "be", "ignored", "and", "not", "sent", "over", "the", "Event", "channel", ".", "Such", "as", "events", "marked", "ignore", "by", "the", "kernel", "or", "MODIFY", "events", "against", "files", "that", "do", "not", ...
f0c08ee9c60704c1879025f2ae0ff3e000082c13
https://github.com/howeyc/fsnotify/blob/f0c08ee9c60704c1879025f2ae0ff3e000082c13/fsnotify_linux.go#L288-L304
140,872
howeyc/fsnotify
fsnotify_bsd.go
IsModify
func (e *FileEvent) IsModify() bool { return ((e.mask&sys_NOTE_WRITE) == sys_NOTE_WRITE || (e.mask&sys_NOTE_ATTRIB) == sys_NOTE_ATTRIB) }
go
func (e *FileEvent) IsModify() bool { return ((e.mask&sys_NOTE_WRITE) == sys_NOTE_WRITE || (e.mask&sys_NOTE_ATTRIB) == sys_NOTE_ATTRIB) }
[ "func", "(", "e", "*", "FileEvent", ")", "IsModify", "(", ")", "bool", "{", "return", "(", "(", "e", ".", "mask", "&", "sys_NOTE_WRITE", ")", "==", "sys_NOTE_WRITE", "||", "(", "e", ".", "mask", "&", "sys_NOTE_ATTRIB", ")", "==", "sys_NOTE_ATTRIB", ")"...
// IsModify reports whether the FileEvent was triggered by a file modification
[ "IsModify", "reports", "whether", "the", "FileEvent", "was", "triggered", "by", "a", "file", "modification" ]
f0c08ee9c60704c1879025f2ae0ff3e000082c13
https://github.com/howeyc/fsnotify/blob/f0c08ee9c60704c1879025f2ae0ff3e000082c13/fsnotify_bsd.go#L49-L51
140,873
howeyc/fsnotify
fsnotify_bsd.go
Close
func (w *Watcher) Close() error { w.mu.Lock() if w.isClosed { w.mu.Unlock() return nil } w.isClosed = true w.mu.Unlock() // Send "quit" message to the reader goroutine w.done <- true w.wmut.Lock() ws := w.watches w.wmut.Unlock() for path := range ws { w.removeWatch(path) } return nil }
go
func (w *Watcher) Close() error { w.mu.Lock() if w.isClosed { w.mu.Unlock() return nil } w.isClosed = true w.mu.Unlock() // Send "quit" message to the reader goroutine w.done <- true w.wmut.Lock() ws := w.watches w.wmut.Unlock() for path := range ws { w.removeWatch(path) } return nil }
[ "func", "(", "w", "*", "Watcher", ")", "Close", "(", ")", "error", "{", "w", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "w", ".", "isClosed", "{", "w", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "w", ".",...
// Close closes a kevent watcher instance // It sends a message to the reader goroutine to quit and removes all watches // associated with the kevent instance
[ "Close", "closes", "a", "kevent", "watcher", "instance", "It", "sends", "a", "message", "to", "the", "reader", "goroutine", "to", "quit", "and", "removes", "all", "watches", "associated", "with", "the", "kevent", "instance" ]
f0c08ee9c60704c1879025f2ae0ff3e000082c13
https://github.com/howeyc/fsnotify/blob/f0c08ee9c60704c1879025f2ae0ff3e000082c13/fsnotify_bsd.go#L113-L132
140,874
howeyc/fsnotify
fsnotify_bsd.go
sendDirectoryChangeEvents
func (w *Watcher) sendDirectoryChangeEvents(dirPath string) { // Get all files files, err := ioutil.ReadDir(dirPath) if err != nil { w.Error <- err } // Search for new files for _, fileInfo := range files { filePath := filepath.Join(dirPath, fileInfo.Name()) w.femut.Lock() _, doesExist := w.fileExists[fi...
go
func (w *Watcher) sendDirectoryChangeEvents(dirPath string) { // Get all files files, err := ioutil.ReadDir(dirPath) if err != nil { w.Error <- err } // Search for new files for _, fileInfo := range files { filePath := filepath.Join(dirPath, fileInfo.Name()) w.femut.Lock() _, doesExist := w.fileExists[fi...
[ "func", "(", "w", "*", "Watcher", ")", "sendDirectoryChangeEvents", "(", "dirPath", "string", ")", "{", "// Get all files", "files", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "dirPath", ")", "\n", "if", "err", "!=", "nil", "{", "w", ".", "Error", ...
// sendDirectoryEvents searches the directory for newly created files // and sends them over the event channel. This functionality is to have // the BSD version of fsnotify match linux fsnotify which provides a // create event for files created in a watched directory.
[ "sendDirectoryEvents", "searches", "the", "directory", "for", "newly", "created", "files", "and", "sends", "them", "over", "the", "event", "channel", ".", "This", "functionality", "is", "to", "have", "the", "BSD", "version", "of", "fsnotify", "match", "linux", ...
f0c08ee9c60704c1879025f2ae0ff3e000082c13
https://github.com/howeyc/fsnotify/blob/f0c08ee9c60704c1879025f2ae0ff3e000082c13/fsnotify_bsd.go#L462-L496
140,875
coreos/go-oidc
jwks.go
NewRemoteKeySet
func NewRemoteKeySet(ctx context.Context, jwksURL string) KeySet { return newRemoteKeySet(ctx, jwksURL, time.Now) }
go
func NewRemoteKeySet(ctx context.Context, jwksURL string) KeySet { return newRemoteKeySet(ctx, jwksURL, time.Now) }
[ "func", "NewRemoteKeySet", "(", "ctx", "context", ".", "Context", ",", "jwksURL", "string", ")", "KeySet", "{", "return", "newRemoteKeySet", "(", "ctx", ",", "jwksURL", ",", "time", ".", "Now", ")", "\n", "}" ]
// NewRemoteKeySet returns a KeySet that can validate JSON web tokens by using HTTP // GETs to fetch JSON web token sets hosted at a remote URL. This is automatically // used by NewProvider using the URLs returned by OpenID Connect discovery, but is // exposed for providers that don't support discovery or to prevent ro...
[ "NewRemoteKeySet", "returns", "a", "KeySet", "that", "can", "validate", "JSON", "web", "tokens", "by", "using", "HTTP", "GETs", "to", "fetch", "JSON", "web", "token", "sets", "hosted", "at", "a", "remote", "URL", ".", "This", "is", "automatically", "used", ...
66476e0267012774b2f9767d2d37a317d1f1aac3
https://github.com/coreos/go-oidc/blob/66476e0267012774b2f9767d2d37a317d1f1aac3/jwks.go#L36-L38
140,876
coreos/go-oidc
jwks.go
done
func (i *inflight) done(keys []jose.JSONWebKey, err error) { i.keys = keys i.err = err close(i.doneCh) }
go
func (i *inflight) done(keys []jose.JSONWebKey, err error) { i.keys = keys i.err = err close(i.doneCh) }
[ "func", "(", "i", "*", "inflight", ")", "done", "(", "keys", "[", "]", "jose", ".", "JSONWebKey", ",", "err", "error", ")", "{", "i", ".", "keys", "=", "keys", "\n", "i", ".", "err", "=", "err", "\n", "close", "(", "i", ".", "doneCh", ")", "\...
// done can only be called by a single goroutine. It records the result of the // inflight request and signals other goroutines that the result is safe to // inspect.
[ "done", "can", "only", "be", "called", "by", "a", "single", "goroutine", ".", "It", "records", "the", "result", "of", "the", "inflight", "request", "and", "signals", "other", "goroutines", "that", "the", "result", "is", "safe", "to", "inspect", "." ]
66476e0267012774b2f9767d2d37a317d1f1aac3
https://github.com/coreos/go-oidc/blob/66476e0267012774b2f9767d2d37a317d1f1aac3/jwks.go#L85-L89
140,877
coreos/go-oidc
jwks.go
keysFromRemote
func (r *remoteKeySet) keysFromRemote(ctx context.Context) ([]jose.JSONWebKey, error) { // Need to lock to inspect the inflight request field. r.mu.Lock() // If there's not a current inflight request, create one. if r.inflight == nil { r.inflight = newInflight() // This goroutine has exclusive ownership over t...
go
func (r *remoteKeySet) keysFromRemote(ctx context.Context) ([]jose.JSONWebKey, error) { // Need to lock to inspect the inflight request field. r.mu.Lock() // If there's not a current inflight request, create one. if r.inflight == nil { r.inflight = newInflight() // This goroutine has exclusive ownership over t...
[ "func", "(", "r", "*", "remoteKeySet", ")", "keysFromRemote", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "jose", ".", "JSONWebKey", ",", "error", ")", "{", "// Need to lock to inspect the inflight request field.", "r", ".", "mu", ".", "Lock", ...
// keysFromRemote syncs the key set from the remote set, records the values in the // cache, and returns the key set.
[ "keysFromRemote", "syncs", "the", "key", "set", "from", "the", "remote", "set", "records", "the", "values", "in", "the", "cache", "and", "returns", "the", "key", "set", "." ]
66476e0267012774b2f9767d2d37a317d1f1aac3
https://github.com/coreos/go-oidc/blob/66476e0267012774b2f9767d2d37a317d1f1aac3/jwks.go#L151-L190
140,878
coreos/go-oidc
verify.go
Verifier
func (p *Provider) Verifier(config *Config) *IDTokenVerifier { return NewVerifier(p.issuer, p.remoteKeySet, config) }
go
func (p *Provider) Verifier(config *Config) *IDTokenVerifier { return NewVerifier(p.issuer, p.remoteKeySet, config) }
[ "func", "(", "p", "*", "Provider", ")", "Verifier", "(", "config", "*", "Config", ")", "*", "IDTokenVerifier", "{", "return", "NewVerifier", "(", "p", ".", "issuer", ",", "p", ".", "remoteKeySet", ",", "config", ")", "\n", "}" ]
// Verifier returns an IDTokenVerifier that uses the provider's key set to verify JWTs. // // The returned IDTokenVerifier is tied to the Provider's context and its behavior is // undefined once the Provider's context is canceled.
[ "Verifier", "returns", "an", "IDTokenVerifier", "that", "uses", "the", "provider", "s", "key", "set", "to", "verify", "JWTs", ".", "The", "returned", "IDTokenVerifier", "is", "tied", "to", "the", "Provider", "s", "context", "and", "its", "behavior", "is", "u...
66476e0267012774b2f9767d2d37a317d1f1aac3
https://github.com/coreos/go-oidc/blob/66476e0267012774b2f9767d2d37a317d1f1aac3/verify.go#L98-L100
140,879
coreos/go-oidc
verify.go
resolveDistributedClaim
func resolveDistributedClaim(ctx context.Context, verifier *IDTokenVerifier, src claimSource) ([]byte, error) { req, err := http.NewRequest("GET", src.Endpoint, nil) if err != nil { return nil, fmt.Errorf("malformed request: %v", err) } if src.AccessToken != "" { req.Header.Set("Authorization", "Bearer "+src.Ac...
go
func resolveDistributedClaim(ctx context.Context, verifier *IDTokenVerifier, src claimSource) ([]byte, error) { req, err := http.NewRequest("GET", src.Endpoint, nil) if err != nil { return nil, fmt.Errorf("malformed request: %v", err) } if src.AccessToken != "" { req.Header.Set("Authorization", "Bearer "+src.Ac...
[ "func", "resolveDistributedClaim", "(", "ctx", "context", ".", "Context", ",", "verifier", "*", "IDTokenVerifier", ",", "src", "claimSource", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"...
// Returns the Claims from the distributed JWT token
[ "Returns", "the", "Claims", "from", "the", "distributed", "JWT", "token" ]
66476e0267012774b2f9767d2d37a317d1f1aac3
https://github.com/coreos/go-oidc/blob/66476e0267012774b2f9767d2d37a317d1f1aac3/verify.go#L124-L154
140,880
coreos/go-oidc
oidc.go
Claims
func (u *UserInfo) Claims(v interface{}) error { if u.claims == nil { return errors.New("oidc: claims not set") } return json.Unmarshal(u.claims, v) }
go
func (u *UserInfo) Claims(v interface{}) error { if u.claims == nil { return errors.New("oidc: claims not set") } return json.Unmarshal(u.claims, v) }
[ "func", "(", "u", "*", "UserInfo", ")", "Claims", "(", "v", "interface", "{", "}", ")", "error", "{", "if", "u", ".", "claims", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "json", ".", "Unm...
// Claims unmarshals the raw JSON object claims into the provided object.
[ "Claims", "unmarshals", "the", "raw", "JSON", "object", "claims", "into", "the", "provided", "object", "." ]
66476e0267012774b2f9767d2d37a317d1f1aac3
https://github.com/coreos/go-oidc/blob/66476e0267012774b2f9767d2d37a317d1f1aac3/oidc.go#L172-L177
140,881
scylladb/gocqlx
qb/utils.go
placeholders
func placeholders(cql *bytes.Buffer, count int) { if count < 1 { return } for i := 0; i < count-1; i++ { cql.WriteByte('?') cql.WriteByte(',') } cql.WriteByte('?') }
go
func placeholders(cql *bytes.Buffer, count int) { if count < 1 { return } for i := 0; i < count-1; i++ { cql.WriteByte('?') cql.WriteByte(',') } cql.WriteByte('?') }
[ "func", "placeholders", "(", "cql", "*", "bytes", ".", "Buffer", ",", "count", "int", ")", "{", "if", "count", "<", "1", "{", "return", "\n", "}", "\n\n", "for", "i", ":=", "0", ";", "i", "<", "count", "-", "1", ";", "i", "++", "{", "cql", "....
// placeholders returns a string with count ? placeholders joined with commas.
[ "placeholders", "returns", "a", "string", "with", "count", "?", "placeholders", "joined", "with", "commas", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/utils.go#L12-L22
140,882
scylladb/gocqlx
qb/update.go
Table
func (b *UpdateBuilder) Table(table string) *UpdateBuilder { b.table = table return b }
go
func (b *UpdateBuilder) Table(table string) *UpdateBuilder { b.table = table return b }
[ "func", "(", "b", "*", "UpdateBuilder", ")", "Table", "(", "table", "string", ")", "*", "UpdateBuilder", "{", "b", ".", "table", "=", "table", "\n", "return", "b", "\n", "}" ]
// Table sets the table to be updated.
[ "Table", "sets", "the", "table", "to", "be", "updated", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/update.go#L77-L80
140,883
scylladb/gocqlx
qb/update.go
Set
func (b *UpdateBuilder) Set(columns ...string) *UpdateBuilder { for _, c := range columns { b.assignments = append(b.assignments, assignment{ column: c, value: param(c), }) } return b }
go
func (b *UpdateBuilder) Set(columns ...string) *UpdateBuilder { for _, c := range columns { b.assignments = append(b.assignments, assignment{ column: c, value: param(c), }) } return b }
[ "func", "(", "b", "*", "UpdateBuilder", ")", "Set", "(", "columns", "...", "string", ")", "*", "UpdateBuilder", "{", "for", "_", ",", "c", ":=", "range", "columns", "{", "b", ".", "assignments", "=", "append", "(", "b", ".", "assignments", ",", "assi...
// Set adds SET clauses to the query.
[ "Set", "adds", "SET", "clauses", "to", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/update.go#L108-L117
140,884
scylladb/gocqlx
qb/update.go
SetNamed
func (b *UpdateBuilder) SetNamed(column, name string) *UpdateBuilder { b.assignments = append( b.assignments, assignment{column: column, value: param(name)}) return b }
go
func (b *UpdateBuilder) SetNamed(column, name string) *UpdateBuilder { b.assignments = append( b.assignments, assignment{column: column, value: param(name)}) return b }
[ "func", "(", "b", "*", "UpdateBuilder", ")", "SetNamed", "(", "column", ",", "name", "string", ")", "*", "UpdateBuilder", "{", "b", ".", "assignments", "=", "append", "(", "b", ".", "assignments", ",", "assignment", "{", "column", ":", "column", ",", "...
// SetNamed adds SET column=? clause to the query with a custom parameter name.
[ "SetNamed", "adds", "SET", "column", "=", "?", "clause", "to", "the", "query", "with", "a", "custom", "parameter", "name", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/update.go#L120-L124
140,885
scylladb/gocqlx
qb/update.go
SetLit
func (b *UpdateBuilder) SetLit(column, literal string) *UpdateBuilder { b.assignments = append( b.assignments, assignment{column: column, value: lit(literal)}) return b }
go
func (b *UpdateBuilder) SetLit(column, literal string) *UpdateBuilder { b.assignments = append( b.assignments, assignment{column: column, value: lit(literal)}) return b }
[ "func", "(", "b", "*", "UpdateBuilder", ")", "SetLit", "(", "column", ",", "literal", "string", ")", "*", "UpdateBuilder", "{", "b", ".", "assignments", "=", "append", "(", "b", ".", "assignments", ",", "assignment", "{", "column", ":", "column", ",", ...
// SetLit adds SET column=literal clause to the query.
[ "SetLit", "adds", "SET", "column", "=", "literal", "clause", "to", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/update.go#L127-L131
140,886
scylladb/gocqlx
qb/update.go
Add
func (b *UpdateBuilder) Add(column string) *UpdateBuilder { return b.addValue(column, param(column)) }
go
func (b *UpdateBuilder) Add(column string) *UpdateBuilder { return b.addValue(column, param(column)) }
[ "func", "(", "b", "*", "UpdateBuilder", ")", "Add", "(", "column", "string", ")", "*", "UpdateBuilder", "{", "return", "b", ".", "addValue", "(", "column", ",", "param", "(", "column", ")", ")", "\n", "}" ]
// Add adds SET column=column+? clauses to the query.
[ "Add", "adds", "SET", "column", "=", "column", "+", "?", "clauses", "to", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/update.go#L140-L142
140,887
scylladb/gocqlx
qb/update.go
AddNamed
func (b *UpdateBuilder) AddNamed(column, name string) *UpdateBuilder { return b.addValue(column, param(name)) }
go
func (b *UpdateBuilder) AddNamed(column, name string) *UpdateBuilder { return b.addValue(column, param(name)) }
[ "func", "(", "b", "*", "UpdateBuilder", ")", "AddNamed", "(", "column", ",", "name", "string", ")", "*", "UpdateBuilder", "{", "return", "b", ".", "addValue", "(", "column", ",", "param", "(", "name", ")", ")", "\n", "}" ]
// AddNamed adds SET column=column+? clauses to the query with a custom // parameter name.
[ "AddNamed", "adds", "SET", "column", "=", "column", "+", "?", "clauses", "to", "the", "query", "with", "a", "custom", "parameter", "name", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/update.go#L146-L148
140,888
scylladb/gocqlx
qb/update.go
AddLit
func (b *UpdateBuilder) AddLit(column, literal string) *UpdateBuilder { return b.addValue(column, lit(literal)) }
go
func (b *UpdateBuilder) AddLit(column, literal string) *UpdateBuilder { return b.addValue(column, lit(literal)) }
[ "func", "(", "b", "*", "UpdateBuilder", ")", "AddLit", "(", "column", ",", "literal", "string", ")", "*", "UpdateBuilder", "{", "return", "b", ".", "addValue", "(", "column", ",", "lit", "(", "literal", ")", ")", "\n", "}" ]
// AddLit adds SET column=column+literal clauses to the query.
[ "AddLit", "adds", "SET", "column", "=", "column", "+", "literal", "clauses", "to", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/update.go#L151-L153
140,889
scylladb/gocqlx
qb/update.go
Remove
func (b *UpdateBuilder) Remove(column string) *UpdateBuilder { return b.removeValue(column, param(column)) }
go
func (b *UpdateBuilder) Remove(column string) *UpdateBuilder { return b.removeValue(column, param(column)) }
[ "func", "(", "b", "*", "UpdateBuilder", ")", "Remove", "(", "column", "string", ")", "*", "UpdateBuilder", "{", "return", "b", ".", "removeValue", "(", "column", ",", "param", "(", "column", ")", ")", "\n", "}" ]
// Remove adds SET column=column-? clauses to the query.
[ "Remove", "adds", "SET", "column", "=", "column", "-", "?", "clauses", "to", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/update.go#L170-L172
140,890
scylladb/gocqlx
qb/update.go
RemoveNamed
func (b *UpdateBuilder) RemoveNamed(column, name string) *UpdateBuilder { return b.removeValue(column, param(name)) }
go
func (b *UpdateBuilder) RemoveNamed(column, name string) *UpdateBuilder { return b.removeValue(column, param(name)) }
[ "func", "(", "b", "*", "UpdateBuilder", ")", "RemoveNamed", "(", "column", ",", "name", "string", ")", "*", "UpdateBuilder", "{", "return", "b", ".", "removeValue", "(", "column", ",", "param", "(", "name", ")", ")", "\n", "}" ]
// RemoveNamed adds SET column=column-? clauses to the query with a custom // parameter name.
[ "RemoveNamed", "adds", "SET", "column", "=", "column", "-", "?", "clauses", "to", "the", "query", "with", "a", "custom", "parameter", "name", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/update.go#L176-L178
140,891
scylladb/gocqlx
qb/update.go
RemoveLit
func (b *UpdateBuilder) RemoveLit(column, literal string) *UpdateBuilder { return b.removeValue(column, lit(literal)) }
go
func (b *UpdateBuilder) RemoveLit(column, literal string) *UpdateBuilder { return b.removeValue(column, lit(literal)) }
[ "func", "(", "b", "*", "UpdateBuilder", ")", "RemoveLit", "(", "column", ",", "literal", "string", ")", "*", "UpdateBuilder", "{", "return", "b", ".", "removeValue", "(", "column", ",", "lit", "(", "literal", ")", ")", "\n", "}" ]
// RemoveLit adds SET column=column-literal clauses to the query.
[ "RemoveLit", "adds", "SET", "column", "=", "column", "-", "literal", "clauses", "to", "the", "query", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/qb/update.go#L181-L183
140,892
scylladb/gocqlx
queryx.go
Query
func Query(q *gocql.Query, names []string) *Queryx { return &Queryx{ Query: q, Names: names, Mapper: DefaultMapper, } }
go
func Query(q *gocql.Query, names []string) *Queryx { return &Queryx{ Query: q, Names: names, Mapper: DefaultMapper, } }
[ "func", "Query", "(", "q", "*", "gocql", ".", "Query", ",", "names", "[", "]", "string", ")", "*", "Queryx", "{", "return", "&", "Queryx", "{", "Query", ":", "q", ",", "Names", ":", "names", ",", "Mapper", ":", "DefaultMapper", ",", "}", "\n", "}...
// Query creates a new Queryx from gocql.Query using a default mapper.
[ "Query", "creates", "a", "new", "Queryx", "from", "gocql", ".", "Query", "using", "a", "default", "mapper", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/queryx.go#L92-L98
140,893
scylladb/gocqlx
queryx.go
BindStruct
func (q *Queryx) BindStruct(arg interface{}) *Queryx { arglist, err := bindStructArgs(q.Names, arg, nil, q.Mapper) if err != nil { q.err = fmt.Errorf("bind error: %s", err) } else { q.err = nil q.Bind(arglist...) } return q }
go
func (q *Queryx) BindStruct(arg interface{}) *Queryx { arglist, err := bindStructArgs(q.Names, arg, nil, q.Mapper) if err != nil { q.err = fmt.Errorf("bind error: %s", err) } else { q.err = nil q.Bind(arglist...) } return q }
[ "func", "(", "q", "*", "Queryx", ")", "BindStruct", "(", "arg", "interface", "{", "}", ")", "*", "Queryx", "{", "arglist", ",", "err", ":=", "bindStructArgs", "(", "q", ".", "Names", ",", "arg", ",", "nil", ",", "q", ".", "Mapper", ")", "\n", "if...
// BindStruct binds query named parameters to values from arg using mapper. If // value cannot be found error is reported.
[ "BindStruct", "binds", "query", "named", "parameters", "to", "values", "from", "arg", "using", "mapper", ".", "If", "value", "cannot", "be", "found", "error", "is", "reported", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/queryx.go#L102-L112
140,894
scylladb/gocqlx
queryx.go
BindStructMap
func (q *Queryx) BindStructMap(arg0 interface{}, arg1 map[string]interface{}) *Queryx { arglist, err := bindStructArgs(q.Names, arg0, arg1, q.Mapper) if err != nil { q.err = fmt.Errorf("bind error: %s", err) } else { q.err = nil q.Bind(arglist...) } return q }
go
func (q *Queryx) BindStructMap(arg0 interface{}, arg1 map[string]interface{}) *Queryx { arglist, err := bindStructArgs(q.Names, arg0, arg1, q.Mapper) if err != nil { q.err = fmt.Errorf("bind error: %s", err) } else { q.err = nil q.Bind(arglist...) } return q }
[ "func", "(", "q", "*", "Queryx", ")", "BindStructMap", "(", "arg0", "interface", "{", "}", ",", "arg1", "map", "[", "string", "]", "interface", "{", "}", ")", "*", "Queryx", "{", "arglist", ",", "err", ":=", "bindStructArgs", "(", "q", ".", "Names", ...
// BindStructMap binds query named parameters to values from arg0 and arg1 // using a mapper. If value cannot be found in arg0 it's looked up in arg1 // before reporting an error.
[ "BindStructMap", "binds", "query", "named", "parameters", "to", "values", "from", "arg0", "and", "arg1", "using", "a", "mapper", ".", "If", "value", "cannot", "be", "found", "in", "arg0", "it", "s", "looked", "up", "in", "arg1", "before", "reporting", "an"...
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/queryx.go#L117-L127
140,895
scylladb/gocqlx
queryx.go
BindMap
func (q *Queryx) BindMap(arg map[string]interface{}) *Queryx { arglist, err := bindMapArgs(q.Names, arg) if err != nil { q.err = fmt.Errorf("bind error: %s", err) } else { q.err = nil q.Bind(arglist...) } return q }
go
func (q *Queryx) BindMap(arg map[string]interface{}) *Queryx { arglist, err := bindMapArgs(q.Names, arg) if err != nil { q.err = fmt.Errorf("bind error: %s", err) } else { q.err = nil q.Bind(arglist...) } return q }
[ "func", "(", "q", "*", "Queryx", ")", "BindMap", "(", "arg", "map", "[", "string", "]", "interface", "{", "}", ")", "*", "Queryx", "{", "arglist", ",", "err", ":=", "bindMapArgs", "(", "q", ".", "Names", ",", "arg", ")", "\n", "if", "err", "!=", ...
// BindMap binds query named parameters using map.
[ "BindMap", "binds", "query", "named", "parameters", "using", "map", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/queryx.go#L157-L167
140,896
scylladb/gocqlx
queryx.go
Exec
func (q *Queryx) Exec() error { if q.err != nil { return q.err } return q.Query.Exec() }
go
func (q *Queryx) Exec() error { if q.err != nil { return q.err } return q.Query.Exec() }
[ "func", "(", "q", "*", "Queryx", ")", "Exec", "(", ")", "error", "{", "if", "q", ".", "err", "!=", "nil", "{", "return", "q", ".", "err", "\n", "}", "\n", "return", "q", ".", "Query", ".", "Exec", "(", ")", "\n", "}" ]
// Exec executes the query without returning any rows.
[ "Exec", "executes", "the", "query", "without", "returning", "any", "rows", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/queryx.go#L188-L193
140,897
scylladb/gocqlx
queryx.go
Get
func (q *Queryx) Get(dest interface{}) error { if q.err != nil { return q.err } return Iter(q.Query).Get(dest) }
go
func (q *Queryx) Get(dest interface{}) error { if q.err != nil { return q.err } return Iter(q.Query).Get(dest) }
[ "func", "(", "q", "*", "Queryx", ")", "Get", "(", "dest", "interface", "{", "}", ")", "error", "{", "if", "q", ".", "err", "!=", "nil", "{", "return", "q", ".", "err", "\n", "}", "\n", "return", "Iter", "(", "q", ".", "Query", ")", ".", "Get"...
// Get scans first row into a destination. If the destination type is a struct // pointer, then Iter.StructScan will be used. If the destination is some // other type, then the row must only have one column which can scan into that // type. // // If no rows were selected, ErrNotFound is returned.
[ "Get", "scans", "first", "row", "into", "a", "destination", ".", "If", "the", "destination", "type", "is", "a", "struct", "pointer", "then", "Iter", ".", "StructScan", "will", "be", "used", ".", "If", "the", "destination", "is", "some", "other", "type", ...
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/queryx.go#L208-L213
140,898
scylladb/gocqlx
queryx.go
GetRelease
func (q *Queryx) GetRelease(dest interface{}) error { defer q.Release() return q.Get(dest) }
go
func (q *Queryx) GetRelease(dest interface{}) error { defer q.Release() return q.Get(dest) }
[ "func", "(", "q", "*", "Queryx", ")", "GetRelease", "(", "dest", "interface", "{", "}", ")", "error", "{", "defer", "q", ".", "Release", "(", ")", "\n", "return", "q", ".", "Get", "(", "dest", ")", "\n", "}" ]
// GetRelease calls Get and releases the query, a released query cannot be // reused.
[ "GetRelease", "calls", "Get", "and", "releases", "the", "query", "a", "released", "query", "cannot", "be", "reused", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/queryx.go#L217-L220
140,899
scylladb/gocqlx
queryx.go
SelectRelease
func (q *Queryx) SelectRelease(dest interface{}) error { defer q.Release() return q.Select(dest) }
go
func (q *Queryx) SelectRelease(dest interface{}) error { defer q.Release() return q.Select(dest) }
[ "func", "(", "q", "*", "Queryx", ")", "SelectRelease", "(", "dest", "interface", "{", "}", ")", "error", "{", "defer", "q", ".", "Release", "(", ")", "\n", "return", "q", ".", "Select", "(", "dest", ")", "\n", "}" ]
// SelectRelease calls Select and releases the query, a released query cannot be // reused.
[ "SelectRelease", "calls", "Select", "and", "releases", "the", "query", "a", "released", "query", "cannot", "be", "reused", "." ]
3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5
https://github.com/scylladb/gocqlx/blob/3a6a3da0c7b34883b12cb1730c936b2ebd3d04a5/queryx.go#L237-L240