id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
22,600
RoaringBitmap/roaring
runcontainer.go
newRunContainer16FromVals
func newRunContainer16FromVals(alreadySorted bool, vals ...uint16) *runContainer16 { // keep this in sync with newRunContainer16FromArray below rc := &runContainer16{} ah := addHelper16{rc: rc} if !alreadySorted { sort.Sort(uint16Slice(vals)) } n := len(vals) var cur, prev uint16 switch { case n == 0: //...
go
func newRunContainer16FromVals(alreadySorted bool, vals ...uint16) *runContainer16 { // keep this in sync with newRunContainer16FromArray below rc := &runContainer16{} ah := addHelper16{rc: rc} if !alreadySorted { sort.Sort(uint16Slice(vals)) } n := len(vals) var cur, prev uint16 switch { case n == 0: //...
[ "func", "newRunContainer16FromVals", "(", "alreadySorted", "bool", ",", "vals", "...", "uint16", ")", "*", "runContainer16", "{", "// keep this in sync with newRunContainer16FromArray below", "rc", ":=", "&", "runContainer16", "{", "}", "\n", "ah", ":=", "addHelper16", ...
// newRunContainer16FromVals makes a new container from vals. // // For efficiency, vals should be sorted in ascending order. // Ideally vals should not contain duplicates, but we detect and // ignore them. If vals is already sorted in ascending order, then // pass alreadySorted = true. Otherwise, for !alreadySorted, /...
[ "newRunContainer16FromVals", "makes", "a", "new", "container", "from", "vals", ".", "For", "efficiency", "vals", "should", "be", "sorted", "in", "ascending", "order", ".", "Ideally", "vals", "should", "not", "contain", "duplicates", "but", "we", "detect", "and",...
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L176-L206
22,601
RoaringBitmap/roaring
runcontainer.go
newRunContainer16FromArray
func newRunContainer16FromArray(arr *arrayContainer) *runContainer16 { // keep this in sync with newRunContainer16FromVals above rc := &runContainer16{} ah := addHelper16{rc: rc} n := arr.getCardinality() var cur, prev uint16 switch { case n == 0: // nothing more case n == 1: ah.m = append(ah.m, newInterv...
go
func newRunContainer16FromArray(arr *arrayContainer) *runContainer16 { // keep this in sync with newRunContainer16FromVals above rc := &runContainer16{} ah := addHelper16{rc: rc} n := arr.getCardinality() var cur, prev uint16 switch { case n == 0: // nothing more case n == 1: ah.m = append(ah.m, newInterv...
[ "func", "newRunContainer16FromArray", "(", "arr", "*", "arrayContainer", ")", "*", "runContainer16", "{", "// keep this in sync with newRunContainer16FromVals above", "rc", ":=", "&", "runContainer16", "{", "}", "\n", "ah", ":=", "addHelper16", "{", "rc", ":", "rc", ...
// // newRunContainer16FromArray populates a new // runContainer16 from the contents of arr. //
[ "newRunContainer16FromArray", "populates", "a", "new", "runContainer16", "from", "the", "contents", "of", "arr", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L269-L296
22,602
RoaringBitmap/roaring
runcontainer.go
canMerge16
func canMerge16(a, b interval16) bool { if int64(a.last())+1 < int64(b.start) { return false } return int64(b.last())+1 >= int64(a.start) }
go
func canMerge16(a, b interval16) bool { if int64(a.last())+1 < int64(b.start) { return false } return int64(b.last())+1 >= int64(a.start) }
[ "func", "canMerge16", "(", "a", ",", "b", "interval16", ")", "bool", "{", "if", "int64", "(", "a", ".", "last", "(", ")", ")", "+", "1", "<", "int64", "(", "b", ".", "start", ")", "{", "return", "false", "\n", "}", "\n", "return", "int64", "(",...
// canMerge returns true iff the intervals // a and b either overlap or they are // contiguous and so can be merged into // a single interval.
[ "canMerge", "returns", "true", "iff", "the", "intervals", "a", "and", "b", "either", "overlap", "or", "they", "are", "contiguous", "and", "so", "can", "be", "merged", "into", "a", "single", "interval", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L318-L323
22,603
RoaringBitmap/roaring
runcontainer.go
mergeInterval16s
func mergeInterval16s(a, b interval16) (res interval16) { if !canMerge16(a, b) { panic(fmt.Sprintf("cannot merge %#v and %#v", a, b)) } if b.start < a.start { res.start = b.start } else { res.start = a.start } if b.last() > a.last() { res.length = b.last() - res.start } else { res.length = a.last() -...
go
func mergeInterval16s(a, b interval16) (res interval16) { if !canMerge16(a, b) { panic(fmt.Sprintf("cannot merge %#v and %#v", a, b)) } if b.start < a.start { res.start = b.start } else { res.start = a.start } if b.last() > a.last() { res.length = b.last() - res.start } else { res.length = a.last() -...
[ "func", "mergeInterval16s", "(", "a", ",", "b", "interval16", ")", "(", "res", "interval16", ")", "{", "if", "!", "canMerge16", "(", "a", ",", "b", ")", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "a", ",", "b", ")", ")", "\...
// mergeInterval16s joins a and b into a // new interval, and panics if it cannot.
[ "mergeInterval16s", "joins", "a", "and", "b", "into", "a", "new", "interval", "and", "panics", "if", "it", "cannot", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L339-L357
22,604
RoaringBitmap/roaring
runcontainer.go
intersectInterval16s
func intersectInterval16s(a, b interval16) (res interval16, isEmpty bool) { if !haveOverlap16(a, b) { isEmpty = true return } if b.start > a.start { res.start = b.start } else { res.start = a.start } bEnd := b.last() aEnd := a.last() var resEnd uint16 if bEnd < aEnd { resEnd = bEnd } else { resE...
go
func intersectInterval16s(a, b interval16) (res interval16, isEmpty bool) { if !haveOverlap16(a, b) { isEmpty = true return } if b.start > a.start { res.start = b.start } else { res.start = a.start } bEnd := b.last() aEnd := a.last() var resEnd uint16 if bEnd < aEnd { resEnd = bEnd } else { resE...
[ "func", "intersectInterval16s", "(", "a", ",", "b", "interval16", ")", "(", "res", "interval16", ",", "isEmpty", "bool", ")", "{", "if", "!", "haveOverlap16", "(", "a", ",", "b", ")", "{", "isEmpty", "=", "true", "\n", "return", "\n", "}", "\n", "if"...
// intersectInterval16s returns the intersection // of a and b. The isEmpty flag will be true if // a and b were disjoint.
[ "intersectInterval16s", "returns", "the", "intersection", "of", "a", "and", "b", ".", "The", "isEmpty", "flag", "will", "be", "true", "if", "a", "and", "b", "were", "disjoint", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L362-L384
22,605
RoaringBitmap/roaring
runcontainer.go
indexOfIntervalAtOrAfter
func (rc *runContainer16) indexOfIntervalAtOrAfter(key int64, startIndex int64) int64 { rc.myOpts.startIndex = startIndex rc.myOpts.endxIndex = 0 w, already, _ := rc.search(key, &rc.myOpts) if already { return w } return w + 1 }
go
func (rc *runContainer16) indexOfIntervalAtOrAfter(key int64, startIndex int64) int64 { rc.myOpts.startIndex = startIndex rc.myOpts.endxIndex = 0 w, already, _ := rc.search(key, &rc.myOpts) if already { return w } return w + 1 }
[ "func", "(", "rc", "*", "runContainer16", ")", "indexOfIntervalAtOrAfter", "(", "key", "int64", ",", "startIndex", "int64", ")", "int64", "{", "rc", ".", "myOpts", ".", "startIndex", "=", "startIndex", "\n", "rc", ".", "myOpts", ".", "endxIndex", "=", "0",...
// indexOfIntervalAtOrAfter is a helper for union.
[ "indexOfIntervalAtOrAfter", "is", "a", "helper", "for", "union", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L619-L628
22,606
RoaringBitmap/roaring
runcontainer.go
contains
func (rc *runContainer16) contains(key uint16) bool { _, in, _ := rc.search(int64(key), nil) return in }
go
func (rc *runContainer16) contains(key uint16) bool { _, in, _ := rc.search(int64(key), nil) return in }
[ "func", "(", "rc", "*", "runContainer16", ")", "contains", "(", "key", "uint16", ")", "bool", "{", "_", ",", "in", ",", "_", ":=", "rc", ".", "search", "(", "int64", "(", "key", ")", ",", "nil", ")", "\n", "return", "in", "\n", "}" ]
// get returns true iff key is in the container.
[ "get", "returns", "true", "iff", "key", "is", "in", "the", "container", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L846-L849
22,607
RoaringBitmap/roaring
runcontainer.go
cardinality
func (rc *runContainer16) cardinality() int64 { if len(rc.iv) == 0 { rc.card = 0 return 0 } if rc.card > 0 { return rc.card // already cached } // have to compute it var n int64 for _, p := range rc.iv { n += p.runlen() } rc.card = n // cache it return n }
go
func (rc *runContainer16) cardinality() int64 { if len(rc.iv) == 0 { rc.card = 0 return 0 } if rc.card > 0 { return rc.card // already cached } // have to compute it var n int64 for _, p := range rc.iv { n += p.runlen() } rc.card = n // cache it return n }
[ "func", "(", "rc", "*", "runContainer16", ")", "cardinality", "(", ")", "int64", "{", "if", "len", "(", "rc", ".", "iv", ")", "==", "0", "{", "rc", ".", "card", "=", "0", "\n", "return", "0", "\n", "}", "\n", "if", "rc", ".", "card", ">", "0"...
// cardinality returns the count of the integers stored in the // runContainer16.
[ "cardinality", "returns", "the", "count", "of", "the", "integers", "stored", "in", "the", "runContainer16", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L984-L999
22,608
RoaringBitmap/roaring
runcontainer.go
newRunContainer16CopyIv
func newRunContainer16CopyIv(iv []interval16) *runContainer16 { rc := &runContainer16{ iv: make([]interval16, len(iv)), } copy(rc.iv, iv) return rc }
go
func newRunContainer16CopyIv(iv []interval16) *runContainer16 { rc := &runContainer16{ iv: make([]interval16, len(iv)), } copy(rc.iv, iv) return rc }
[ "func", "newRunContainer16CopyIv", "(", "iv", "[", "]", "interval16", ")", "*", "runContainer16", "{", "rc", ":=", "&", "runContainer16", "{", "iv", ":", "make", "(", "[", "]", "interval16", ",", "len", "(", "iv", ")", ")", ",", "}", "\n", "copy", "(...
// newRunContainer16CopyIv creates a run container, initializing // with a copy of the supplied iv slice. //
[ "newRunContainer16CopyIv", "creates", "a", "run", "container", "initializing", "with", "a", "copy", "of", "the", "supplied", "iv", "slice", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L1022-L1028
22,609
RoaringBitmap/roaring
runcontainer.go
Add
func (rc *runContainer16) Add(k uint16) (wasNew bool) { // TODO comment from runContainer16.java: // it might be better and simpler to do return // toBitmapOrArrayContainer(getCardinality()).add(k) // but note that some unit tests use this method to build up test // runcontainers without calling runOptimize k64 ...
go
func (rc *runContainer16) Add(k uint16) (wasNew bool) { // TODO comment from runContainer16.java: // it might be better and simpler to do return // toBitmapOrArrayContainer(getCardinality()).add(k) // but note that some unit tests use this method to build up test // runcontainers without calling runOptimize k64 ...
[ "func", "(", "rc", "*", "runContainer16", ")", "Add", "(", "k", "uint16", ")", "(", "wasNew", "bool", ")", "{", "// TODO comment from runContainer16.java:", "// it might be better and simpler to do return", "// toBitmapOrArrayContainer(getCardinality()).add(k)", "// but note th...
// Add adds a single value k to the set.
[ "Add", "adds", "a", "single", "value", "k", "to", "the", "set", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L1066-L1148
22,610
RoaringBitmap/roaring
runcontainer.go
hasNext
func (ri *runIterator16) hasNext() bool { if len(ri.rc.iv) == 0 { return false } if ri.curIndex == -1 { return true } return ri.curSeq+1 < ri.rc.cardinality() }
go
func (ri *runIterator16) hasNext() bool { if len(ri.rc.iv) == 0 { return false } if ri.curIndex == -1 { return true } return ri.curSeq+1 < ri.rc.cardinality() }
[ "func", "(", "ri", "*", "runIterator16", ")", "hasNext", "(", ")", "bool", "{", "if", "len", "(", "ri", ".", "rc", ".", "iv", ")", "==", "0", "{", "return", "false", "\n", "}", "\n", "if", "ri", ".", "curIndex", "==", "-", "1", "{", "return", ...
// HasNext returns false if calling Next will panic. It // returns true when there is at least one more value // available in the iteration sequence.
[ "HasNext", "returns", "false", "if", "calling", "Next", "will", "panic", ".", "It", "returns", "true", "when", "there", "is", "at", "least", "one", "more", "value", "available", "in", "the", "iteration", "sequence", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L1170-L1178
22,611
RoaringBitmap/roaring
runcontainer.go
next
func (ri *runIterator16) next() uint16 { if !ri.hasNext() { panic("no Next available") } if ri.curIndex >= int64(len(ri.rc.iv)) { panic("runIterator.Next() going beyond what is available") } if ri.curIndex == -1 { // first time is special ri.curIndex = 0 } else { ri.curPosInIndex++ if int64(ri.rc.iv[r...
go
func (ri *runIterator16) next() uint16 { if !ri.hasNext() { panic("no Next available") } if ri.curIndex >= int64(len(ri.rc.iv)) { panic("runIterator.Next() going beyond what is available") } if ri.curIndex == -1 { // first time is special ri.curIndex = 0 } else { ri.curPosInIndex++ if int64(ri.rc.iv[r...
[ "func", "(", "ri", "*", "runIterator16", ")", "next", "(", ")", "uint16", "{", "if", "!", "ri", ".", "hasNext", "(", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "ri", ".", "curIndex", ">=", "int64", "(", "len", "(", "ri", ...
// Next returns the next value in the iteration sequence.
[ "Next", "returns", "the", "next", "value", "in", "the", "iteration", "sequence", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L1186-L1205
22,612
RoaringBitmap/roaring
runcontainer.go
cur
func (ri *runReverseIterator16) cur() uint16 { return ri.rc.iv[ri.curIndex].start + ri.curPosInIndex }
go
func (ri *runReverseIterator16) cur() uint16 { return ri.rc.iv[ri.curIndex].start + ri.curPosInIndex }
[ "func", "(", "ri", "*", "runReverseIterator16", ")", "cur", "(", ")", "uint16", "{", "return", "ri", ".", "rc", ".", "iv", "[", "ri", ".", "curIndex", "]", ".", "start", "+", "ri", ".", "curPosInIndex", "\n", "}" ]
// cur returns the current value pointed to by the iterator.
[ "cur", "returns", "the", "current", "value", "pointed", "to", "by", "the", "iterator", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L1251-L1253
22,613
RoaringBitmap/roaring
runcontainer.go
next
func (ri *runReverseIterator16) next() uint16 { if !ri.hasNext() { panic("no next available") } if ri.curIndex == -1 { panic("runReverseIterator.next() going beyond what is available") } if ri.curIndex == -2 { // first time is special ri.curIndex = int64(len(ri.rc.iv)) - 1 ri.curPosInIndex = ri.rc.iv[ri....
go
func (ri *runReverseIterator16) next() uint16 { if !ri.hasNext() { panic("no next available") } if ri.curIndex == -1 { panic("runReverseIterator.next() going beyond what is available") } if ri.curIndex == -2 { // first time is special ri.curIndex = int64(len(ri.rc.iv)) - 1 ri.curPosInIndex = ri.rc.iv[ri....
[ "func", "(", "ri", "*", "runReverseIterator16", ")", "next", "(", ")", "uint16", "{", "if", "!", "ri", ".", "hasNext", "(", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "ri", ".", "curIndex", "==", "-", "1", "{", "panic", "("...
// next returns the next value in the iteration sequence.
[ "next", "returns", "the", "next", "value", "in", "the", "iteration", "sequence", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L1256-L1277
22,614
RoaringBitmap/roaring
runcontainer.go
remove
func (ri *runReverseIterator16) remove() uint16 { n := ri.rc.cardinality() if n == 0 { panic("runReverseIterator.Remove called on empty runContainer16") } cur := ri.cur() ri.rc.deleteAt(&ri.curIndex, &ri.curPosInIndex, &ri.curSeq) return cur }
go
func (ri *runReverseIterator16) remove() uint16 { n := ri.rc.cardinality() if n == 0 { panic("runReverseIterator.Remove called on empty runContainer16") } cur := ri.cur() ri.rc.deleteAt(&ri.curIndex, &ri.curPosInIndex, &ri.curSeq) return cur }
[ "func", "(", "ri", "*", "runReverseIterator16", ")", "remove", "(", ")", "uint16", "{", "n", ":=", "ri", ".", "rc", ".", "cardinality", "(", ")", "\n", "if", "n", "==", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "cur", ":=", "ri"...
// remove removes the element that the iterator // is on from the run container. You can use // cur if you want to double check what is about // to be deleted.
[ "remove", "removes", "the", "element", "that", "the", "iterator", "is", "on", "from", "the", "run", "container", ".", "You", "can", "use", "cur", "if", "you", "want", "to", "double", "check", "what", "is", "about", "to", "be", "deleted", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L1283-L1292
22,615
RoaringBitmap/roaring
runcontainer.go
nextMany
func (ri *manyRunIterator16) nextMany(hs uint32, buf []uint32) int { n := 0 if !ri.hasNext() { return n } // start and end are inclusive for n < len(buf) { if ri.curIndex == -1 || int(ri.rc.iv[ri.curIndex].length-ri.curPosInIndex) <= 0 { ri.curPosInIndex = 0 ri.curIndex++ if ri.curIndex == int64(len(r...
go
func (ri *manyRunIterator16) nextMany(hs uint32, buf []uint32) int { n := 0 if !ri.hasNext() { return n } // start and end are inclusive for n < len(buf) { if ri.curIndex == -1 || int(ri.rc.iv[ri.curIndex].length-ri.curPosInIndex) <= 0 { ri.curPosInIndex = 0 ri.curIndex++ if ri.curIndex == int64(len(r...
[ "func", "(", "ri", "*", "manyRunIterator16", ")", "nextMany", "(", "hs", "uint32", ",", "buf", "[", "]", "uint32", ")", "int", "{", "n", ":=", "0", "\n", "if", "!", "ri", ".", "hasNext", "(", ")", "{", "return", "n", "\n", "}", "\n", "// start an...
// hs are the high bits to include to avoid needing to reiterate over the buffer in NextMany
[ "hs", "are", "the", "high", "bits", "to", "include", "to", "avoid", "needing", "to", "reiterate", "over", "the", "buffer", "in", "NextMany" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L1316-L1354
22,616
RoaringBitmap/roaring
runcontainer.go
removeKey
func (rc *runContainer16) removeKey(key uint16) (wasPresent bool) { var index int64 var curSeq int64 index, wasPresent, _ = rc.search(int64(key), nil) if !wasPresent { return // already removed, nothing to do. } pos := key - rc.iv[index].start rc.deleteAt(&index, &pos, &curSeq) return }
go
func (rc *runContainer16) removeKey(key uint16) (wasPresent bool) { var index int64 var curSeq int64 index, wasPresent, _ = rc.search(int64(key), nil) if !wasPresent { return // already removed, nothing to do. } pos := key - rc.iv[index].start rc.deleteAt(&index, &pos, &curSeq) return }
[ "func", "(", "rc", "*", "runContainer16", ")", "removeKey", "(", "key", "uint16", ")", "(", "wasPresent", "bool", ")", "{", "var", "index", "int64", "\n", "var", "curSeq", "int64", "\n", "index", ",", "wasPresent", ",", "_", "=", "rc", ".", "search", ...
// remove removes key from the container.
[ "remove", "removes", "key", "from", "the", "container", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L1357-L1368
22,617
RoaringBitmap/roaring
runcontainer.go
selectInt16
func (rc *runContainer16) selectInt16(j uint16) int { n := rc.cardinality() if int64(j) > n { panic(fmt.Sprintf("Cannot select %v since Cardinality is %v", j, n)) } var offset int64 for k := range rc.iv { nextOffset := offset + rc.iv[k].runlen() + 1 if nextOffset > int64(j) { return int(int64(rc.iv[k].st...
go
func (rc *runContainer16) selectInt16(j uint16) int { n := rc.cardinality() if int64(j) > n { panic(fmt.Sprintf("Cannot select %v since Cardinality is %v", j, n)) } var offset int64 for k := range rc.iv { nextOffset := offset + rc.iv[k].runlen() + 1 if nextOffset > int64(j) { return int(int64(rc.iv[k].st...
[ "func", "(", "rc", "*", "runContainer16", ")", "selectInt16", "(", "j", "uint16", ")", "int", "{", "n", ":=", "rc", ".", "cardinality", "(", ")", "\n", "if", "int64", "(", "j", ")", ">", "n", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", ...
// selectInt16 returns the j-th value in the container. // We panic of j is out of bounds.
[ "selectInt16", "returns", "the", "j", "-", "th", "value", "in", "the", "container", ".", "We", "panic", "of", "j", "is", "out", "of", "bounds", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L1483-L1498
22,618
RoaringBitmap/roaring
runcontainer.go
invertlastInterval
func (rc *runContainer16) invertlastInterval(origin uint16, lastIdx int) []interval16 { cur := rc.iv[lastIdx] if cur.last() == MaxUint16 { if cur.start == origin { return nil // empty container } return []interval16{newInterval16Range(origin, cur.start-1)} } if cur.start == origin { return []interval16{n...
go
func (rc *runContainer16) invertlastInterval(origin uint16, lastIdx int) []interval16 { cur := rc.iv[lastIdx] if cur.last() == MaxUint16 { if cur.start == origin { return nil // empty container } return []interval16{newInterval16Range(origin, cur.start-1)} } if cur.start == origin { return []interval16{n...
[ "func", "(", "rc", "*", "runContainer16", ")", "invertlastInterval", "(", "origin", "uint16", ",", "lastIdx", "int", ")", "[", "]", "interval16", "{", "cur", ":=", "rc", ".", "iv", "[", "lastIdx", "]", "\n", "if", "cur", ".", "last", "(", ")", "==", ...
// helper for invert
[ "helper", "for", "invert" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L1501-L1517
22,619
RoaringBitmap/roaring
runcontainer.go
andBitmapContainer
func (rc *runContainer16) andBitmapContainer(bc *bitmapContainer) container { bc2 := newBitmapContainerFromRun(rc) return bc2.andBitmap(bc) }
go
func (rc *runContainer16) andBitmapContainer(bc *bitmapContainer) container { bc2 := newBitmapContainerFromRun(rc) return bc2.andBitmap(bc) }
[ "func", "(", "rc", "*", "runContainer16", ")", "andBitmapContainer", "(", "bc", "*", "bitmapContainer", ")", "container", "{", "bc2", ":=", "newBitmapContainerFromRun", "(", "rc", ")", "\n", "return", "bc2", ".", "andBitmap", "(", "bc", ")", "\n", "}" ]
// andBitmapContainer finds the intersection of rc and b.
[ "andBitmapContainer", "finds", "the", "intersection", "of", "rc", "and", "b", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L1878-L1881
22,620
RoaringBitmap/roaring
runcontainer.go
iaddRange
func (rc *runContainer16) iaddRange(firstOfRange, endx int) container { if firstOfRange >= endx { panic(fmt.Sprintf("invalid %v = endx >= firstOfRange", endx)) } addme := newRunContainer16TakeOwnership([]interval16{ { start: uint16(firstOfRange), length: uint16(endx - 1 - firstOfRange), }, }) *rc = *...
go
func (rc *runContainer16) iaddRange(firstOfRange, endx int) container { if firstOfRange >= endx { panic(fmt.Sprintf("invalid %v = endx >= firstOfRange", endx)) } addme := newRunContainer16TakeOwnership([]interval16{ { start: uint16(firstOfRange), length: uint16(endx - 1 - firstOfRange), }, }) *rc = *...
[ "func", "(", "rc", "*", "runContainer16", ")", "iaddRange", "(", "firstOfRange", ",", "endx", "int", ")", "container", "{", "if", "firstOfRange", ">=", "endx", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "endx", ")", ")", "\n", "}...
// add the values in the range [firstOfRange, endx). endx // is still abe to express 2^16 because it is an int not an uint16.
[ "add", "the", "values", "in", "the", "range", "[", "firstOfRange", "endx", ")", ".", "endx", "is", "still", "abe", "to", "express", "2^16", "because", "it", "is", "an", "int", "not", "an", "uint16", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L2010-L2023
22,621
RoaringBitmap/roaring
runcontainer.go
equals
func (rc *runContainer16) equals(o container) bool { srb, ok := o.(*runContainer16) if !ok { // maybe value instead of pointer val, valok := o.(*runContainer16) if valok { srb = val ok = true } } if ok { // Check if the containers are the same object. if rc == srb { return true } if len(s...
go
func (rc *runContainer16) equals(o container) bool { srb, ok := o.(*runContainer16) if !ok { // maybe value instead of pointer val, valok := o.(*runContainer16) if valok { srb = val ok = true } } if ok { // Check if the containers are the same object. if rc == srb { return true } if len(s...
[ "func", "(", "rc", "*", "runContainer16", ")", "equals", "(", "o", "container", ")", "bool", "{", "srb", ",", "ok", ":=", "o", ".", "(", "*", "runContainer16", ")", "\n\n", "if", "!", "ok", "{", "// maybe value instead of pointer", "val", ",", "valok", ...
// equals is now logical equals; it does not require the // same underlying container type.
[ "equals", "is", "now", "logical", "equals", ";", "it", "does", "not", "require", "the", "same", "underlying", "container", "type", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L2087-L2131
22,622
RoaringBitmap/roaring
runcontainer.go
orBitmapContainer
func (rc *runContainer16) orBitmapContainer(bc *bitmapContainer) container { bc2 := newBitmapContainerFromRun(rc) return bc2.iorBitmap(bc) }
go
func (rc *runContainer16) orBitmapContainer(bc *bitmapContainer) container { bc2 := newBitmapContainerFromRun(rc) return bc2.iorBitmap(bc) }
[ "func", "(", "rc", "*", "runContainer16", ")", "orBitmapContainer", "(", "bc", "*", "bitmapContainer", ")", "container", "{", "bc2", ":=", "newBitmapContainerFromRun", "(", "rc", ")", "\n", "return", "bc2", ".", "iorBitmap", "(", "bc", ")", "\n", "}" ]
// orBitmapContainer finds the union of rc and bc.
[ "orBitmapContainer", "finds", "the", "union", "of", "rc", "and", "bc", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L2179-L2182
22,623
RoaringBitmap/roaring
runcontainer.go
And
func (rc *runContainer16) And(b *Bitmap) *Bitmap { out := NewBitmap() for _, p := range rc.iv { plast := p.last() for i := p.start; i <= plast; i++ { if b.Contains(uint32(i)) { out.Add(uint32(i)) } } } return out }
go
func (rc *runContainer16) And(b *Bitmap) *Bitmap { out := NewBitmap() for _, p := range rc.iv { plast := p.last() for i := p.start; i <= plast; i++ { if b.Contains(uint32(i)) { out.Add(uint32(i)) } } } return out }
[ "func", "(", "rc", "*", "runContainer16", ")", "And", "(", "b", "*", "Bitmap", ")", "*", "Bitmap", "{", "out", ":=", "NewBitmap", "(", ")", "\n", "for", "_", ",", "p", ":=", "range", "rc", ".", "iv", "{", "plast", ":=", "p", ".", "last", "(", ...
// And finds the intersection of rc and b.
[ "And", "finds", "the", "intersection", "of", "rc", "and", "b", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L2490-L2501
22,624
RoaringBitmap/roaring
runcontainer.go
Xor
func (rc *runContainer16) Xor(b *Bitmap) *Bitmap { out := b.Clone() for _, p := range rc.iv { plast := p.last() for v := p.start; v <= plast; v++ { w := uint32(v) if out.Contains(w) { out.RemoveRange(uint64(w), uint64(w+1)) } else { out.Add(w) } } } return out }
go
func (rc *runContainer16) Xor(b *Bitmap) *Bitmap { out := b.Clone() for _, p := range rc.iv { plast := p.last() for v := p.start; v <= plast; v++ { w := uint32(v) if out.Contains(w) { out.RemoveRange(uint64(w), uint64(w+1)) } else { out.Add(w) } } } return out }
[ "func", "(", "rc", "*", "runContainer16", ")", "Xor", "(", "b", "*", "Bitmap", ")", "*", "Bitmap", "{", "out", ":=", "b", ".", "Clone", "(", ")", "\n", "for", "_", ",", "p", ":=", "range", "rc", ".", "iv", "{", "plast", ":=", "p", ".", "last"...
// Xor returns the exclusive-or of rc and b.
[ "Xor", "returns", "the", "exclusive", "-", "or", "of", "rc", "and", "b", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L2504-L2518
22,625
RoaringBitmap/roaring
runcontainer.go
Or
func (rc *runContainer16) Or(b *Bitmap) *Bitmap { out := b.Clone() for _, p := range rc.iv { plast := p.last() for v := p.start; v <= plast; v++ { out.Add(uint32(v)) } } return out }
go
func (rc *runContainer16) Or(b *Bitmap) *Bitmap { out := b.Clone() for _, p := range rc.iv { plast := p.last() for v := p.start; v <= plast; v++ { out.Add(uint32(v)) } } return out }
[ "func", "(", "rc", "*", "runContainer16", ")", "Or", "(", "b", "*", "Bitmap", ")", "*", "Bitmap", "{", "out", ":=", "b", ".", "Clone", "(", ")", "\n", "for", "_", ",", "p", ":=", "range", "rc", ".", "iv", "{", "plast", ":=", "p", ".", "last",...
// Or returns the union of rc and b.
[ "Or", "returns", "the", "union", "of", "rc", "and", "b", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/runcontainer.go#L2521-L2530
22,626
RoaringBitmap/roaring
serialization_littleendian.go
byteSliceAsUint16Slice
func byteSliceAsUint16Slice(slice []byte) []uint16 { if len(slice)%2 != 0 { panic("Slice size should be divisible by 2") } // make a new slice header header := *(*reflect.SliceHeader)(unsafe.Pointer(&slice)) // update its capacity and length header.Len /= 2 header.Cap /= 2 // return it return *(*[]uint16)...
go
func byteSliceAsUint16Slice(slice []byte) []uint16 { if len(slice)%2 != 0 { panic("Slice size should be divisible by 2") } // make a new slice header header := *(*reflect.SliceHeader)(unsafe.Pointer(&slice)) // update its capacity and length header.Len /= 2 header.Cap /= 2 // return it return *(*[]uint16)...
[ "func", "byteSliceAsUint16Slice", "(", "slice", "[", "]", "byte", ")", "[", "]", "uint16", "{", "if", "len", "(", "slice", ")", "%", "2", "!=", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// make a new slice header", "header", ":=", ...
// Deserialization code follows
[ "Deserialization", "code", "follows" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/serialization_littleendian.go#L71-L85
22,627
RoaringBitmap/roaring
ctz_compat.go
countTrailingZeros
func countTrailingZeros(x uint64) int { // x & -x leaves only the right-most bit set in the word. Let k be the // index of that bit. Since only a single bit is set, the value is two // to the power of k. Multiplying by a power of two is equivalent to // left shifting, in this case by k bits. The de Bruijn constant ...
go
func countTrailingZeros(x uint64) int { // x & -x leaves only the right-most bit set in the word. Let k be the // index of that bit. Since only a single bit is set, the value is two // to the power of k. Multiplying by a power of two is equivalent to // left shifting, in this case by k bits. The de Bruijn constant ...
[ "func", "countTrailingZeros", "(", "x", "uint64", ")", "int", "{", "// x & -x leaves only the right-most bit set in the word. Let k be the", "// index of that bit. Since only a single bit is set, the value is two", "// to the power of k. Multiplying by a power of two is equivalent to", "// lef...
// trailingZeroBits returns the number of consecutive least significant zero // bits of x.
[ "trailingZeroBits", "returns", "the", "number", "of", "consecutive", "least", "significant", "zero", "bits", "of", "x", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/ctz_compat.go#L55-L71
22,628
RoaringBitmap/roaring
fastaggregation.go
lazyOR
func lazyOR(x1, x2 *Bitmap) *Bitmap { answer := NewBitmap() pos1 := 0 pos2 := 0 length1 := x1.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for (pos1 < length1) && (pos2 < length2) { s1 := x1.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for { i...
go
func lazyOR(x1, x2 *Bitmap) *Bitmap { answer := NewBitmap() pos1 := 0 pos2 := 0 length1 := x1.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for (pos1 < length1) && (pos2 < length2) { s1 := x1.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for { i...
[ "func", "lazyOR", "(", "x1", ",", "x2", "*", "Bitmap", ")", "*", "Bitmap", "{", "answer", ":=", "NewBitmap", "(", ")", "\n", "pos1", ":=", "0", "\n", "pos2", ":=", "0", "\n", "length1", ":=", "x1", ".", "highlowcontainer", ".", "size", "(", ")", ...
// Or function that requires repairAfterLazy
[ "Or", "function", "that", "requires", "repairAfterLazy" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/fastaggregation.go#L8-L62
22,629
RoaringBitmap/roaring
fastaggregation.go
lazyOR
func (x1 *Bitmap) lazyOR(x2 *Bitmap) *Bitmap { pos1 := 0 pos2 := 0 length1 := x1.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for (pos1 < length1) && (pos2 < length2) { s1 := x1.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for { if s1 < s2 { ...
go
func (x1 *Bitmap) lazyOR(x2 *Bitmap) *Bitmap { pos1 := 0 pos2 := 0 length1 := x1.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for (pos1 < length1) && (pos2 < length2) { s1 := x1.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for { if s1 < s2 { ...
[ "func", "(", "x1", "*", "Bitmap", ")", "lazyOR", "(", "x2", "*", "Bitmap", ")", "*", "Bitmap", "{", "pos1", ":=", "0", "\n", "pos2", ":=", "0", "\n", "length1", ":=", "x1", ".", "highlowcontainer", ".", "size", "(", ")", "\n", "length2", ":=", "x...
// In-place Or function that requires repairAfterLazy
[ "In", "-", "place", "Or", "function", "that", "requires", "repairAfterLazy" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/fastaggregation.go#L65-L120
22,630
RoaringBitmap/roaring
fastaggregation.go
repairAfterLazy
func (x1 *Bitmap) repairAfterLazy() { for pos := 0; pos < x1.highlowcontainer.size(); pos++ { c := x1.highlowcontainer.getContainerAtIndex(pos) switch c.(type) { case *bitmapContainer: if c.(*bitmapContainer).cardinality == invalidCardinality { c = x1.highlowcontainer.getWritableContainerAtIndex(pos) ...
go
func (x1 *Bitmap) repairAfterLazy() { for pos := 0; pos < x1.highlowcontainer.size(); pos++ { c := x1.highlowcontainer.getContainerAtIndex(pos) switch c.(type) { case *bitmapContainer: if c.(*bitmapContainer).cardinality == invalidCardinality { c = x1.highlowcontainer.getWritableContainerAtIndex(pos) ...
[ "func", "(", "x1", "*", "Bitmap", ")", "repairAfterLazy", "(", ")", "{", "for", "pos", ":=", "0", ";", "pos", "<", "x1", ".", "highlowcontainer", ".", "size", "(", ")", ";", "pos", "++", "{", "c", ":=", "x1", ".", "highlowcontainer", ".", "getConta...
// to be called after lazy aggregates
[ "to", "be", "called", "after", "lazy", "aggregates" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/fastaggregation.go#L123-L139
22,631
RoaringBitmap/roaring
fastaggregation.go
FastAnd
func FastAnd(bitmaps ...*Bitmap) *Bitmap { if len(bitmaps) == 0 { return NewBitmap() } else if len(bitmaps) == 1 { return bitmaps[0].Clone() } answer := And(bitmaps[0], bitmaps[1]) for _, bm := range bitmaps[2:] { answer.And(bm) } return answer }
go
func FastAnd(bitmaps ...*Bitmap) *Bitmap { if len(bitmaps) == 0 { return NewBitmap() } else if len(bitmaps) == 1 { return bitmaps[0].Clone() } answer := And(bitmaps[0], bitmaps[1]) for _, bm := range bitmaps[2:] { answer.And(bm) } return answer }
[ "func", "FastAnd", "(", "bitmaps", "...", "*", "Bitmap", ")", "*", "Bitmap", "{", "if", "len", "(", "bitmaps", ")", "==", "0", "{", "return", "NewBitmap", "(", ")", "\n", "}", "else", "if", "len", "(", "bitmaps", ")", "==", "1", "{", "return", "b...
// FastAnd computes the intersection between many bitmaps quickly // Compared to the And function, it can take many bitmaps as input, thus saving the trouble // of manually calling "And" many times.
[ "FastAnd", "computes", "the", "intersection", "between", "many", "bitmaps", "quickly", "Compared", "to", "the", "And", "function", "it", "can", "take", "many", "bitmaps", "as", "input", "thus", "saving", "the", "trouble", "of", "manually", "calling", "And", "m...
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/fastaggregation.go#L144-L155
22,632
RoaringBitmap/roaring
fastaggregation.go
FastOr
func FastOr(bitmaps ...*Bitmap) *Bitmap { if len(bitmaps) == 0 { return NewBitmap() } else if len(bitmaps) == 1 { return bitmaps[0].Clone() } answer := lazyOR(bitmaps[0], bitmaps[1]) for _, bm := range bitmaps[2:] { answer = answer.lazyOR(bm) } // here is where repairAfterLazy is called. answer.repairAfte...
go
func FastOr(bitmaps ...*Bitmap) *Bitmap { if len(bitmaps) == 0 { return NewBitmap() } else if len(bitmaps) == 1 { return bitmaps[0].Clone() } answer := lazyOR(bitmaps[0], bitmaps[1]) for _, bm := range bitmaps[2:] { answer = answer.lazyOR(bm) } // here is where repairAfterLazy is called. answer.repairAfte...
[ "func", "FastOr", "(", "bitmaps", "...", "*", "Bitmap", ")", "*", "Bitmap", "{", "if", "len", "(", "bitmaps", ")", "==", "0", "{", "return", "NewBitmap", "(", ")", "\n", "}", "else", "if", "len", "(", "bitmaps", ")", "==", "1", "{", "return", "bi...
// FastOr computes the union between many bitmaps quickly, as opposed to having to call Or repeatedly. // It might also be faster than calling Or repeatedly.
[ "FastOr", "computes", "the", "union", "between", "many", "bitmaps", "quickly", "as", "opposed", "to", "having", "to", "call", "Or", "repeatedly", ".", "It", "might", "also", "be", "faster", "than", "calling", "Or", "repeatedly", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/fastaggregation.go#L159-L172
22,633
RoaringBitmap/roaring
fastaggregation.go
HeapOr
func HeapOr(bitmaps ...*Bitmap) *Bitmap { if len(bitmaps) == 0 { return NewBitmap() } // TODO: for better speed, we could do the operation lazily, see Java implementation pq := make(priorityQueue, len(bitmaps)) for i, bm := range bitmaps { pq[i] = &item{bm, i} } heap.Init(&pq) for pq.Len() > 1 { x1 := h...
go
func HeapOr(bitmaps ...*Bitmap) *Bitmap { if len(bitmaps) == 0 { return NewBitmap() } // TODO: for better speed, we could do the operation lazily, see Java implementation pq := make(priorityQueue, len(bitmaps)) for i, bm := range bitmaps { pq[i] = &item{bm, i} } heap.Init(&pq) for pq.Len() > 1 { x1 := h...
[ "func", "HeapOr", "(", "bitmaps", "...", "*", "Bitmap", ")", "*", "Bitmap", "{", "if", "len", "(", "bitmaps", ")", "==", "0", "{", "return", "NewBitmap", "(", ")", "\n", "}", "\n", "// TODO: for better speed, we could do the operation lazily, see Java implementat...
// HeapOr computes the union between many bitmaps quickly using a heap. // It might be faster than calling Or repeatedly.
[ "HeapOr", "computes", "the", "union", "between", "many", "bitmaps", "quickly", "using", "a", "heap", ".", "It", "might", "be", "faster", "than", "calling", "Or", "repeatedly", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/fastaggregation.go#L176-L193
22,634
RoaringBitmap/roaring
roaring.go
ToBase64
func (rb *Bitmap) ToBase64() (string, error) { buf := new(bytes.Buffer) _, err := rb.WriteTo(buf) return base64.StdEncoding.EncodeToString(buf.Bytes()), err }
go
func (rb *Bitmap) ToBase64() (string, error) { buf := new(bytes.Buffer) _, err := rb.WriteTo(buf) return base64.StdEncoding.EncodeToString(buf.Bytes()), err }
[ "func", "(", "rb", "*", "Bitmap", ")", "ToBase64", "(", ")", "(", "string", ",", "error", ")", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n", "_", ",", "err", ":=", "rb", ".", "WriteTo", "(", "buf", ")", "\n", "return", "base6...
// ToBase64 serializes a bitmap as Base64
[ "ToBase64", "serializes", "a", "bitmap", "as", "Base64" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L23-L28
22,635
RoaringBitmap/roaring
roaring.go
FromBase64
func (rb *Bitmap) FromBase64(str string) (int64, error) { data, err := base64.StdEncoding.DecodeString(str) if err != nil { return 0, err } buf := bytes.NewBuffer(data) return rb.ReadFrom(buf) }
go
func (rb *Bitmap) FromBase64(str string) (int64, error) { data, err := base64.StdEncoding.DecodeString(str) if err != nil { return 0, err } buf := bytes.NewBuffer(data) return rb.ReadFrom(buf) }
[ "func", "(", "rb", "*", "Bitmap", ")", "FromBase64", "(", "str", "string", ")", "(", "int64", ",", "error", ")", "{", "data", ",", "err", ":=", "base64", ".", "StdEncoding", ".", "DecodeString", "(", "str", ")", "\n", "if", "err", "!=", "nil", "{",...
// FromBase64 deserializes a bitmap from Base64
[ "FromBase64", "deserializes", "a", "bitmap", "from", "Base64" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L31-L39
22,636
RoaringBitmap/roaring
roaring.go
MarshalBinary
func (rb *Bitmap) MarshalBinary() ([]byte, error) { var buf bytes.Buffer writer := bufio.NewWriter(&buf) _, err := rb.WriteTo(writer) if err != nil { return nil, err } err = writer.Flush() if err != nil { return nil, err } return buf.Bytes(), nil }
go
func (rb *Bitmap) MarshalBinary() ([]byte, error) { var buf bytes.Buffer writer := bufio.NewWriter(&buf) _, err := rb.WriteTo(writer) if err != nil { return nil, err } err = writer.Flush() if err != nil { return nil, err } return buf.Bytes(), nil }
[ "func", "(", "rb", "*", "Bitmap", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "writer", ":=", "bufio", ".", "NewWriter", "(", "&", "buf", ")", "\n", "_", ",", "err", ...
// MarshalBinary implements the encoding.BinaryMarshaler interface for the bitmap
[ "MarshalBinary", "implements", "the", "encoding", ".", "BinaryMarshaler", "interface", "for", "the", "bitmap" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L113-L125
22,637
RoaringBitmap/roaring
roaring.go
UnmarshalBinary
func (rb *Bitmap) UnmarshalBinary(data []byte) error { var buf bytes.Buffer _, err := buf.Write(data) if err != nil { return err } reader := bufio.NewReader(&buf) _, err = rb.ReadFrom(reader) return err }
go
func (rb *Bitmap) UnmarshalBinary(data []byte) error { var buf bytes.Buffer _, err := buf.Write(data) if err != nil { return err } reader := bufio.NewReader(&buf) _, err = rb.ReadFrom(reader) return err }
[ "func", "(", "rb", "*", "Bitmap", ")", "UnmarshalBinary", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "_", ",", "err", ":=", "buf", ".", "Write", "(", "data", ")", "\n", "if", "err", "!=", "nil", ...
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface for the bitmap
[ "UnmarshalBinary", "implements", "the", "encoding", ".", "BinaryUnmarshaler", "interface", "for", "the", "bitmap" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L128-L137
22,638
RoaringBitmap/roaring
roaring.go
ToArray
func (rb *Bitmap) ToArray() []uint32 { array := make([]uint32, rb.GetCardinality()) pos := 0 pos2 := 0 for pos < rb.highlowcontainer.size() { hs := uint32(rb.highlowcontainer.getKeyAtIndex(pos)) << 16 c := rb.highlowcontainer.getContainerAtIndex(pos) pos++ c.fillLeastSignificant16bits(array, pos2, hs) po...
go
func (rb *Bitmap) ToArray() []uint32 { array := make([]uint32, rb.GetCardinality()) pos := 0 pos2 := 0 for pos < rb.highlowcontainer.size() { hs := uint32(rb.highlowcontainer.getKeyAtIndex(pos)) << 16 c := rb.highlowcontainer.getContainerAtIndex(pos) pos++ c.fillLeastSignificant16bits(array, pos2, hs) po...
[ "func", "(", "rb", "*", "Bitmap", ")", "ToArray", "(", ")", "[", "]", "uint32", "{", "array", ":=", "make", "(", "[", "]", "uint32", ",", "rb", ".", "GetCardinality", "(", ")", ")", "\n", "pos", ":=", "0", "\n", "pos2", ":=", "0", "\n\n", "for"...
// ToArray creates a new slice containing all of the integers stored in the Bitmap in sorted order
[ "ToArray", "creates", "a", "new", "slice", "containing", "all", "of", "the", "integers", "stored", "in", "the", "Bitmap", "in", "sorted", "order" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L156-L169
22,639
RoaringBitmap/roaring
roaring.go
GetSizeInBytes
func (rb *Bitmap) GetSizeInBytes() uint64 { size := uint64(8) for _, c := range rb.highlowcontainer.containers { size += uint64(2) + uint64(c.getSizeInBytes()) } return size }
go
func (rb *Bitmap) GetSizeInBytes() uint64 { size := uint64(8) for _, c := range rb.highlowcontainer.containers { size += uint64(2) + uint64(c.getSizeInBytes()) } return size }
[ "func", "(", "rb", "*", "Bitmap", ")", "GetSizeInBytes", "(", ")", "uint64", "{", "size", ":=", "uint64", "(", "8", ")", "\n", "for", "_", ",", "c", ":=", "range", "rb", ".", "highlowcontainer", ".", "containers", "{", "size", "+=", "uint64", "(", ...
// GetSizeInBytes estimates the memory usage of the Bitmap. Note that this // might differ slightly from the amount of bytes required for persistent storage
[ "GetSizeInBytes", "estimates", "the", "memory", "usage", "of", "the", "Bitmap", ".", "Note", "that", "this", "might", "differ", "slightly", "from", "the", "amount", "of", "bytes", "required", "for", "persistent", "storage" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L173-L179
22,640
RoaringBitmap/roaring
roaring.go
BoundSerializedSizeInBytes
func BoundSerializedSizeInBytes(cardinality uint64, universeSize uint64) uint64 { contnbr := (universeSize + uint64(65535)) / uint64(65536) if contnbr > cardinality { contnbr = cardinality // we can't have more containers than we have values } headermax := 8*contnbr + 4 if 4 > (contnbr+7)/8 { headermax += 4 ...
go
func BoundSerializedSizeInBytes(cardinality uint64, universeSize uint64) uint64 { contnbr := (universeSize + uint64(65535)) / uint64(65536) if contnbr > cardinality { contnbr = cardinality // we can't have more containers than we have values } headermax := 8*contnbr + 4 if 4 > (contnbr+7)/8 { headermax += 4 ...
[ "func", "BoundSerializedSizeInBytes", "(", "cardinality", "uint64", ",", "universeSize", "uint64", ")", "uint64", "{", "contnbr", ":=", "(", "universeSize", "+", "uint64", "(", "65535", ")", ")", "/", "uint64", "(", "65536", ")", "\n", "if", "contnbr", ">", ...
// BoundSerializedSizeInBytes returns an upper bound on the serialized size in bytes // assuming that one wants to store "cardinality" integers in [0, universe_size)
[ "BoundSerializedSizeInBytes", "returns", "an", "upper", "bound", "on", "the", "serialized", "size", "in", "bytes", "assuming", "that", "one", "wants", "to", "store", "cardinality", "integers", "in", "[", "0", "universe_size", ")" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L191-L210
22,641
RoaringBitmap/roaring
roaring.go
Next
func (ii *intIterator) Next() uint32 { x := uint32(ii.iter.next()) | ii.hs if !ii.iter.hasNext() { ii.pos = ii.pos + 1 ii.init() } return x }
go
func (ii *intIterator) Next() uint32 { x := uint32(ii.iter.next()) | ii.hs if !ii.iter.hasNext() { ii.pos = ii.pos + 1 ii.init() } return x }
[ "func", "(", "ii", "*", "intIterator", ")", "Next", "(", ")", "uint32", "{", "x", ":=", "uint32", "(", "ii", ".", "iter", ".", "next", "(", ")", ")", "|", "ii", ".", "hs", "\n", "if", "!", "ii", ".", "iter", ".", "hasNext", "(", ")", "{", "...
// Next returns the next integer
[ "Next", "returns", "the", "next", "integer" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L238-L245
22,642
RoaringBitmap/roaring
roaring.go
Clone
func (rb *Bitmap) Clone() *Bitmap { ptr := new(Bitmap) ptr.highlowcontainer = *rb.highlowcontainer.clone() return ptr }
go
func (rb *Bitmap) Clone() *Bitmap { ptr := new(Bitmap) ptr.highlowcontainer = *rb.highlowcontainer.clone() return ptr }
[ "func", "(", "rb", "*", "Bitmap", ")", "Clone", "(", ")", "*", "Bitmap", "{", "ptr", ":=", "new", "(", "Bitmap", ")", "\n", "ptr", ".", "highlowcontainer", "=", "*", "rb", ".", "highlowcontainer", ".", "clone", "(", ")", "\n", "return", "ptr", "\n"...
// Clone creates a copy of the Bitmap
[ "Clone", "creates", "a", "copy", "of", "the", "Bitmap" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L386-L390
22,643
RoaringBitmap/roaring
roaring.go
Minimum
func (rb *Bitmap) Minimum() uint32 { return uint32(rb.highlowcontainer.containers[0].minimum()) | (uint32(rb.highlowcontainer.keys[0]) << 16) }
go
func (rb *Bitmap) Minimum() uint32 { return uint32(rb.highlowcontainer.containers[0].minimum()) | (uint32(rb.highlowcontainer.keys[0]) << 16) }
[ "func", "(", "rb", "*", "Bitmap", ")", "Minimum", "(", ")", "uint32", "{", "return", "uint32", "(", "rb", ".", "highlowcontainer", ".", "containers", "[", "0", "]", ".", "minimum", "(", ")", ")", "|", "(", "uint32", "(", "rb", ".", "highlowcontainer"...
// Minimum get the smallest value stored in this roaring bitmap, assumes that it is not empty
[ "Minimum", "get", "the", "smallest", "value", "stored", "in", "this", "roaring", "bitmap", "assumes", "that", "it", "is", "not", "empty" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L393-L395
22,644
RoaringBitmap/roaring
roaring.go
Maximum
func (rb *Bitmap) Maximum() uint32 { lastindex := len(rb.highlowcontainer.containers) - 1 return uint32(rb.highlowcontainer.containers[lastindex].maximum()) | (uint32(rb.highlowcontainer.keys[lastindex]) << 16) }
go
func (rb *Bitmap) Maximum() uint32 { lastindex := len(rb.highlowcontainer.containers) - 1 return uint32(rb.highlowcontainer.containers[lastindex].maximum()) | (uint32(rb.highlowcontainer.keys[lastindex]) << 16) }
[ "func", "(", "rb", "*", "Bitmap", ")", "Maximum", "(", ")", "uint32", "{", "lastindex", ":=", "len", "(", "rb", ".", "highlowcontainer", ".", "containers", ")", "-", "1", "\n", "return", "uint32", "(", "rb", ".", "highlowcontainer", ".", "containers", ...
// Maximum get the largest value stored in this roaring bitmap, assumes that it is not empty
[ "Maximum", "get", "the", "largest", "value", "stored", "in", "this", "roaring", "bitmap", "assumes", "that", "it", "is", "not", "empty" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L398-L401
22,645
RoaringBitmap/roaring
roaring.go
Contains
func (rb *Bitmap) Contains(x uint32) bool { hb := highbits(x) c := rb.highlowcontainer.getContainer(hb) return c != nil && c.contains(lowbits(x)) }
go
func (rb *Bitmap) Contains(x uint32) bool { hb := highbits(x) c := rb.highlowcontainer.getContainer(hb) return c != nil && c.contains(lowbits(x)) }
[ "func", "(", "rb", "*", "Bitmap", ")", "Contains", "(", "x", "uint32", ")", "bool", "{", "hb", ":=", "highbits", "(", "x", ")", "\n", "c", ":=", "rb", ".", "highlowcontainer", ".", "getContainer", "(", "hb", ")", "\n", "return", "c", "!=", "nil", ...
// Contains returns true if the integer is contained in the bitmap
[ "Contains", "returns", "true", "if", "the", "integer", "is", "contained", "in", "the", "bitmap" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L404-L408
22,646
RoaringBitmap/roaring
roaring.go
Equals
func (rb *Bitmap) Equals(o interface{}) bool { srb, ok := o.(*Bitmap) if ok { return srb.highlowcontainer.equals(rb.highlowcontainer) } return false }
go
func (rb *Bitmap) Equals(o interface{}) bool { srb, ok := o.(*Bitmap) if ok { return srb.highlowcontainer.equals(rb.highlowcontainer) } return false }
[ "func", "(", "rb", "*", "Bitmap", ")", "Equals", "(", "o", "interface", "{", "}", ")", "bool", "{", "srb", ",", "ok", ":=", "o", ".", "(", "*", "Bitmap", ")", "\n", "if", "ok", "{", "return", "srb", ".", "highlowcontainer", ".", "equals", "(", ...
// Equals returns true if the two bitmaps contain the same integers
[ "Equals", "returns", "true", "if", "the", "two", "bitmaps", "contain", "the", "same", "integers" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L416-L422
22,647
RoaringBitmap/roaring
roaring.go
AddOffset
func AddOffset(x *Bitmap, offset uint32) (answer *Bitmap) { containerOffset := highbits(offset) inOffset := lowbits(offset) if inOffset == 0 { answer = x.Clone() for pos := 0; pos < answer.highlowcontainer.size(); pos++ { key := answer.highlowcontainer.getKeyAtIndex(pos) key += containerOffset answer.hi...
go
func AddOffset(x *Bitmap, offset uint32) (answer *Bitmap) { containerOffset := highbits(offset) inOffset := lowbits(offset) if inOffset == 0 { answer = x.Clone() for pos := 0; pos < answer.highlowcontainer.size(); pos++ { key := answer.highlowcontainer.getKeyAtIndex(pos) key += containerOffset answer.hi...
[ "func", "AddOffset", "(", "x", "*", "Bitmap", ",", "offset", "uint32", ")", "(", "answer", "*", "Bitmap", ")", "{", "containerOffset", ":=", "highbits", "(", "offset", ")", "\n", "inOffset", ":=", "lowbits", "(", "offset", ")", "\n", "if", "inOffset", ...
// AddOffset adds the value 'offset' to each and every value in a bitmap, generating a new bitmap in the process
[ "AddOffset", "adds", "the", "value", "offset", "to", "each", "and", "every", "value", "in", "a", "bitmap", "generating", "a", "new", "bitmap", "in", "the", "process" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L425-L462
22,648
RoaringBitmap/roaring
roaring.go
Add
func (rb *Bitmap) Add(x uint32) { hb := highbits(x) ra := &rb.highlowcontainer i := ra.getIndex(hb) if i >= 0 { var c container c = ra.getWritableContainerAtIndex(i).iaddReturnMinimized(lowbits(x)) rb.highlowcontainer.setContainerAtIndex(i, c) } else { newac := newArrayContainer() rb.highlowcontainer.ins...
go
func (rb *Bitmap) Add(x uint32) { hb := highbits(x) ra := &rb.highlowcontainer i := ra.getIndex(hb) if i >= 0 { var c container c = ra.getWritableContainerAtIndex(i).iaddReturnMinimized(lowbits(x)) rb.highlowcontainer.setContainerAtIndex(i, c) } else { newac := newArrayContainer() rb.highlowcontainer.ins...
[ "func", "(", "rb", "*", "Bitmap", ")", "Add", "(", "x", "uint32", ")", "{", "hb", ":=", "highbits", "(", "x", ")", "\n", "ra", ":=", "&", "rb", ".", "highlowcontainer", "\n", "i", ":=", "ra", ".", "getIndex", "(", "hb", ")", "\n", "if", "i", ...
// Add the integer x to the bitmap
[ "Add", "the", "integer", "x", "to", "the", "bitmap" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L465-L477
22,649
RoaringBitmap/roaring
roaring.go
Remove
func (rb *Bitmap) Remove(x uint32) { hb := highbits(x) i := rb.highlowcontainer.getIndex(hb) if i >= 0 { c := rb.highlowcontainer.getWritableContainerAtIndex(i).iremoveReturnMinimized(lowbits(x)) rb.highlowcontainer.setContainerAtIndex(i, c) if rb.highlowcontainer.getContainerAtIndex(i).getCardinality() == 0 {...
go
func (rb *Bitmap) Remove(x uint32) { hb := highbits(x) i := rb.highlowcontainer.getIndex(hb) if i >= 0 { c := rb.highlowcontainer.getWritableContainerAtIndex(i).iremoveReturnMinimized(lowbits(x)) rb.highlowcontainer.setContainerAtIndex(i, c) if rb.highlowcontainer.getContainerAtIndex(i).getCardinality() == 0 {...
[ "func", "(", "rb", "*", "Bitmap", ")", "Remove", "(", "x", "uint32", ")", "{", "hb", ":=", "highbits", "(", "x", ")", "\n", "i", ":=", "rb", ".", "highlowcontainer", ".", "getIndex", "(", "hb", ")", "\n", "if", "i", ">=", "0", "{", "c", ":=", ...
// Remove the integer x from the bitmap
[ "Remove", "the", "integer", "x", "from", "the", "bitmap" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L520-L530
22,650
RoaringBitmap/roaring
roaring.go
GetCardinality
func (rb *Bitmap) GetCardinality() uint64 { size := uint64(0) for _, c := range rb.highlowcontainer.containers { size += uint64(c.getCardinality()) } return size }
go
func (rb *Bitmap) GetCardinality() uint64 { size := uint64(0) for _, c := range rb.highlowcontainer.containers { size += uint64(c.getCardinality()) } return size }
[ "func", "(", "rb", "*", "Bitmap", ")", "GetCardinality", "(", ")", "uint64", "{", "size", ":=", "uint64", "(", "0", ")", "\n", "for", "_", ",", "c", ":=", "range", "rb", ".", "highlowcontainer", ".", "containers", "{", "size", "+=", "uint64", "(", ...
// GetCardinality returns the number of integers contained in the bitmap
[ "GetCardinality", "returns", "the", "number", "of", "integers", "contained", "in", "the", "bitmap" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L558-L564
22,651
RoaringBitmap/roaring
roaring.go
Select
func (rb *Bitmap) Select(x uint32) (uint32, error) { if rb.GetCardinality() <= uint64(x) { return 0, fmt.Errorf("can't find %dth integer in a bitmap with only %d items", x, rb.GetCardinality()) } remaining := x for i := 0; i < rb.highlowcontainer.size(); i++ { c := rb.highlowcontainer.getContainerAtIndex(i) ...
go
func (rb *Bitmap) Select(x uint32) (uint32, error) { if rb.GetCardinality() <= uint64(x) { return 0, fmt.Errorf("can't find %dth integer in a bitmap with only %d items", x, rb.GetCardinality()) } remaining := x for i := 0; i < rb.highlowcontainer.size(); i++ { c := rb.highlowcontainer.getContainerAtIndex(i) ...
[ "func", "(", "rb", "*", "Bitmap", ")", "Select", "(", "x", "uint32", ")", "(", "uint32", ",", "error", ")", "{", "if", "rb", ".", "GetCardinality", "(", ")", "<=", "uint64", "(", "x", ")", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"...
// Select returns the xth integer in the bitmap
[ "Select", "returns", "the", "xth", "integer", "in", "the", "bitmap" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L584-L600
22,652
RoaringBitmap/roaring
roaring.go
And
func (rb *Bitmap) And(x2 *Bitmap) { pos1 := 0 pos2 := 0 intersectionsize := 0 length1 := rb.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for { if pos1 < length1 && pos2 < length2 { s1 := rb.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for { ...
go
func (rb *Bitmap) And(x2 *Bitmap) { pos1 := 0 pos2 := 0 intersectionsize := 0 length1 := rb.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for { if pos1 < length1 && pos2 < length2 { s1 := rb.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for { ...
[ "func", "(", "rb", "*", "Bitmap", ")", "And", "(", "x2", "*", "Bitmap", ")", "{", "pos1", ":=", "0", "\n", "pos2", ":=", "0", "\n", "intersectionsize", ":=", "0", "\n", "length1", ":=", "rb", ".", "highlowcontainer", ".", "size", "(", ")", "\n", ...
// And computes the intersection between two bitmaps and stores the result in the current bitmap
[ "And", "computes", "the", "intersection", "between", "two", "bitmaps", "and", "stores", "the", "result", "in", "the", "current", "bitmap" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L603-L650
22,653
RoaringBitmap/roaring
roaring.go
OrCardinality
func (rb *Bitmap) OrCardinality(x2 *Bitmap) uint64 { pos1 := 0 pos2 := 0 length1 := rb.highlowcontainer.size() length2 := x2.highlowcontainer.size() answer := uint64(0) main: for { if (pos1 < length1) && (pos2 < length2) { s1 := rb.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtInd...
go
func (rb *Bitmap) OrCardinality(x2 *Bitmap) uint64 { pos1 := 0 pos2 := 0 length1 := rb.highlowcontainer.size() length2 := x2.highlowcontainer.size() answer := uint64(0) main: for { if (pos1 < length1) && (pos2 < length2) { s1 := rb.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtInd...
[ "func", "(", "rb", "*", "Bitmap", ")", "OrCardinality", "(", "x2", "*", "Bitmap", ")", "uint64", "{", "pos1", ":=", "0", "\n", "pos2", ":=", "0", "\n", "length1", ":=", "rb", ".", "highlowcontainer", ".", "size", "(", ")", "\n", "length2", ":=", "x...
// OrCardinality returns the cardinality of the union between two bitmaps, bitmaps are not modified
[ "OrCardinality", "returns", "the", "cardinality", "of", "the", "union", "between", "two", "bitmaps", "bitmaps", "are", "not", "modified" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L653-L703
22,654
RoaringBitmap/roaring
roaring.go
AndCardinality
func (rb *Bitmap) AndCardinality(x2 *Bitmap) uint64 { pos1 := 0 pos2 := 0 answer := uint64(0) length1 := rb.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for { if pos1 < length1 && pos2 < length2 { s1 := rb.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex...
go
func (rb *Bitmap) AndCardinality(x2 *Bitmap) uint64 { pos1 := 0 pos2 := 0 answer := uint64(0) length1 := rb.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for { if pos1 < length1 && pos2 < length2 { s1 := rb.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex...
[ "func", "(", "rb", "*", "Bitmap", ")", "AndCardinality", "(", "x2", "*", "Bitmap", ")", "uint64", "{", "pos1", ":=", "0", "\n", "pos2", ":=", "0", "\n", "answer", ":=", "uint64", "(", "0", ")", "\n", "length1", ":=", "rb", ".", "highlowcontainer", ...
// AndCardinality returns the cardinality of the intersection between two bitmaps, bitmaps are not modified
[ "AndCardinality", "returns", "the", "cardinality", "of", "the", "intersection", "between", "two", "bitmaps", "bitmaps", "are", "not", "modified" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L706-L749
22,655
RoaringBitmap/roaring
roaring.go
Intersects
func (rb *Bitmap) Intersects(x2 *Bitmap) bool { pos1 := 0 pos2 := 0 length1 := rb.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for { if pos1 < length1 && pos2 < length2 { s1 := rb.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for { if s1 =...
go
func (rb *Bitmap) Intersects(x2 *Bitmap) bool { pos1 := 0 pos2 := 0 length1 := rb.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for { if pos1 < length1 && pos2 < length2 { s1 := rb.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for { if s1 =...
[ "func", "(", "rb", "*", "Bitmap", ")", "Intersects", "(", "x2", "*", "Bitmap", ")", "bool", "{", "pos1", ":=", "0", "\n", "pos2", ":=", "0", "\n", "length1", ":=", "rb", ".", "highlowcontainer", ".", "size", "(", ")", "\n", "length2", ":=", "x2", ...
// Intersects checks whether two bitmap intersects, bitmaps are not modified
[ "Intersects", "checks", "whether", "two", "bitmap", "intersects", "bitmaps", "are", "not", "modified" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L752-L796
22,656
RoaringBitmap/roaring
roaring.go
Xor
func (rb *Bitmap) Xor(x2 *Bitmap) { pos1 := 0 pos2 := 0 length1 := rb.highlowcontainer.size() length2 := x2.highlowcontainer.size() for { if (pos1 < length1) && (pos2 < length2) { s1 := rb.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) if s1 < s2 { pos1 = rb.highl...
go
func (rb *Bitmap) Xor(x2 *Bitmap) { pos1 := 0 pos2 := 0 length1 := rb.highlowcontainer.size() length2 := x2.highlowcontainer.size() for { if (pos1 < length1) && (pos2 < length2) { s1 := rb.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) if s1 < s2 { pos1 = rb.highl...
[ "func", "(", "rb", "*", "Bitmap", ")", "Xor", "(", "x2", "*", "Bitmap", ")", "{", "pos1", ":=", "0", "\n", "pos2", ":=", "0", "\n", "length1", ":=", "rb", ".", "highlowcontainer", ".", "size", "(", ")", "\n", "length2", ":=", "x2", ".", "highlowc...
// Xor computes the symmetric difference between two bitmaps and stores the result in the current bitmap
[ "Xor", "computes", "the", "symmetric", "difference", "between", "two", "bitmaps", "and", "stores", "the", "result", "in", "the", "current", "bitmap" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L799-L838
22,657
RoaringBitmap/roaring
roaring.go
Or
func (rb *Bitmap) Or(x2 *Bitmap) { pos1 := 0 pos2 := 0 length1 := rb.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for (pos1 < length1) && (pos2 < length2) { s1 := rb.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for { if s1 < s2 { pos1++ ...
go
func (rb *Bitmap) Or(x2 *Bitmap) { pos1 := 0 pos2 := 0 length1 := rb.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for (pos1 < length1) && (pos2 < length2) { s1 := rb.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for { if s1 < s2 { pos1++ ...
[ "func", "(", "rb", "*", "Bitmap", ")", "Or", "(", "x2", "*", "Bitmap", ")", "{", "pos1", ":=", "0", "\n", "pos2", ":=", "0", "\n", "length1", ":=", "rb", ".", "highlowcontainer", ".", "size", "(", ")", "\n", "length2", ":=", "x2", ".", "highlowco...
// Or computes the union between two bitmaps and stores the result in the current bitmap
[ "Or", "computes", "the", "union", "between", "two", "bitmaps", "and", "stores", "the", "result", "in", "the", "current", "bitmap" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L841-L882
22,658
RoaringBitmap/roaring
roaring.go
AndNot
func (rb *Bitmap) AndNot(x2 *Bitmap) { pos1 := 0 pos2 := 0 intersectionsize := 0 length1 := rb.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for { if pos1 < length1 && pos2 < length2 { s1 := rb.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for...
go
func (rb *Bitmap) AndNot(x2 *Bitmap) { pos1 := 0 pos2 := 0 intersectionsize := 0 length1 := rb.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for { if pos1 < length1 && pos2 < length2 { s1 := rb.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for...
[ "func", "(", "rb", "*", "Bitmap", ")", "AndNot", "(", "x2", "*", "Bitmap", ")", "{", "pos1", ":=", "0", "\n", "pos2", ":=", "0", "\n", "intersectionsize", ":=", "0", "\n", "length1", ":=", "rb", ".", "highlowcontainer", ".", "size", "(", ")", "\n",...
// AndNot computes the difference between two bitmaps and stores the result in the current bitmap
[ "AndNot", "computes", "the", "difference", "between", "two", "bitmaps", "and", "stores", "the", "result", "in", "the", "current", "bitmap" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L885-L945
22,659
RoaringBitmap/roaring
roaring.go
Or
func Or(x1, x2 *Bitmap) *Bitmap { answer := NewBitmap() pos1 := 0 pos2 := 0 length1 := x1.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for (pos1 < length1) && (pos2 < length2) { s1 := x1.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for { if s1...
go
func Or(x1, x2 *Bitmap) *Bitmap { answer := NewBitmap() pos1 := 0 pos2 := 0 length1 := x1.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for (pos1 < length1) && (pos2 < length2) { s1 := x1.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for { if s1...
[ "func", "Or", "(", "x1", ",", "x2", "*", "Bitmap", ")", "*", "Bitmap", "{", "answer", ":=", "NewBitmap", "(", ")", "\n", "pos1", ":=", "0", "\n", "pos2", ":=", "0", "\n", "length1", ":=", "x1", ".", "highlowcontainer", ".", "size", "(", ")", "\n"...
// Or computes the union between two bitmaps and returns the result
[ "Or", "computes", "the", "union", "between", "two", "bitmaps", "and", "returns", "the", "result" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L948-L993
22,660
RoaringBitmap/roaring
roaring.go
And
func And(x1, x2 *Bitmap) *Bitmap { answer := NewBitmap() pos1 := 0 pos2 := 0 length1 := x1.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for pos1 < length1 && pos2 < length2 { s1 := x1.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for { if s1 == ...
go
func And(x1, x2 *Bitmap) *Bitmap { answer := NewBitmap() pos1 := 0 pos2 := 0 length1 := x1.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for pos1 < length1 && pos2 < length2 { s1 := x1.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for { if s1 == ...
[ "func", "And", "(", "x1", ",", "x2", "*", "Bitmap", ")", "*", "Bitmap", "{", "answer", ":=", "NewBitmap", "(", ")", "\n", "pos1", ":=", "0", "\n", "pos2", ":=", "0", "\n", "length1", ":=", "x1", ".", "highlowcontainer", ".", "size", "(", ")", "\n...
// And computes the intersection between two bitmaps and returns the result
[ "And", "computes", "the", "intersection", "between", "two", "bitmaps", "and", "returns", "the", "result" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L996-L1037
22,661
RoaringBitmap/roaring
roaring.go
Xor
func Xor(x1, x2 *Bitmap) *Bitmap { answer := NewBitmap() pos1 := 0 pos2 := 0 length1 := x1.highlowcontainer.size() length2 := x2.highlowcontainer.size() for { if (pos1 < length1) && (pos2 < length2) { s1 := x1.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) if s1 < s2...
go
func Xor(x1, x2 *Bitmap) *Bitmap { answer := NewBitmap() pos1 := 0 pos2 := 0 length1 := x1.highlowcontainer.size() length2 := x2.highlowcontainer.size() for { if (pos1 < length1) && (pos2 < length2) { s1 := x1.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) if s1 < s2...
[ "func", "Xor", "(", "x1", ",", "x2", "*", "Bitmap", ")", "*", "Bitmap", "{", "answer", ":=", "NewBitmap", "(", ")", "\n", "pos1", ":=", "0", "\n", "pos2", ":=", "0", "\n", "length1", ":=", "x1", ".", "highlowcontainer", ".", "size", "(", ")", "\n...
// Xor computes the symmetric difference between two bitmaps and returns the result
[ "Xor", "computes", "the", "symmetric", "difference", "between", "two", "bitmaps", "and", "returns", "the", "result" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L1040-L1074
22,662
RoaringBitmap/roaring
roaring.go
AndNot
func AndNot(x1, x2 *Bitmap) *Bitmap { answer := NewBitmap() pos1 := 0 pos2 := 0 length1 := x1.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for { if pos1 < length1 && pos2 < length2 { s1 := x1.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for ...
go
func AndNot(x1, x2 *Bitmap) *Bitmap { answer := NewBitmap() pos1 := 0 pos2 := 0 length1 := x1.highlowcontainer.size() length2 := x2.highlowcontainer.size() main: for { if pos1 < length1 && pos2 < length2 { s1 := x1.highlowcontainer.getKeyAtIndex(pos1) s2 := x2.highlowcontainer.getKeyAtIndex(pos2) for ...
[ "func", "AndNot", "(", "x1", ",", "x2", "*", "Bitmap", ")", "*", "Bitmap", "{", "answer", ":=", "NewBitmap", "(", ")", "\n", "pos1", ":=", "0", "\n", "pos2", ":=", "0", "\n", "length1", ":=", "x1", ".", "highlowcontainer", ".", "size", "(", ")", ...
// AndNot computes the difference between two bitmaps and returns the result
[ "AndNot", "computes", "the", "difference", "between", "two", "bitmaps", "and", "returns", "the", "result" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L1077-L1127
22,663
RoaringBitmap/roaring
roaring.go
AddMany
func (rb *Bitmap) AddMany(dat []uint32) { if len(dat) == 0 { return } prev := dat[0] idx, c := rb.addwithptr(prev) for _, i := range dat[1:] { if highbits(prev) == highbits(i) { c = c.iaddReturnMinimized(lowbits(i)) rb.highlowcontainer.setContainerAtIndex(idx, c) } else { idx, c = rb.addwithptr(i) ...
go
func (rb *Bitmap) AddMany(dat []uint32) { if len(dat) == 0 { return } prev := dat[0] idx, c := rb.addwithptr(prev) for _, i := range dat[1:] { if highbits(prev) == highbits(i) { c = c.iaddReturnMinimized(lowbits(i)) rb.highlowcontainer.setContainerAtIndex(idx, c) } else { idx, c = rb.addwithptr(i) ...
[ "func", "(", "rb", "*", "Bitmap", ")", "AddMany", "(", "dat", "[", "]", "uint32", ")", "{", "if", "len", "(", "dat", ")", "==", "0", "{", "return", "\n", "}", "\n", "prev", ":=", "dat", "[", "0", "]", "\n", "idx", ",", "c", ":=", "rb", ".",...
// AddMany add all of the values in dat
[ "AddMany", "add", "all", "of", "the", "values", "in", "dat" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L1130-L1145
22,664
RoaringBitmap/roaring
roaring.go
BitmapOf
func BitmapOf(dat ...uint32) *Bitmap { ans := NewBitmap() ans.AddMany(dat) return ans }
go
func BitmapOf(dat ...uint32) *Bitmap { ans := NewBitmap() ans.AddMany(dat) return ans }
[ "func", "BitmapOf", "(", "dat", "...", "uint32", ")", "*", "Bitmap", "{", "ans", ":=", "NewBitmap", "(", ")", "\n", "ans", ".", "AddMany", "(", "dat", ")", "\n", "return", "ans", "\n", "}" ]
// BitmapOf generates a new bitmap filled with the specified integers
[ "BitmapOf", "generates", "a", "new", "bitmap", "filled", "with", "the", "specified", "integers" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L1148-L1152
22,665
RoaringBitmap/roaring
roaring.go
Stats
func (rb *Bitmap) Stats() Statistics { stats := Statistics{} stats.Containers = uint64(len(rb.highlowcontainer.containers)) for _, c := range rb.highlowcontainer.containers { stats.Cardinality += uint64(c.getCardinality()) switch c.(type) { case *arrayContainer: stats.ArrayContainers++ stats.ArrayContai...
go
func (rb *Bitmap) Stats() Statistics { stats := Statistics{} stats.Containers = uint64(len(rb.highlowcontainer.containers)) for _, c := range rb.highlowcontainer.containers { stats.Cardinality += uint64(c.getCardinality()) switch c.(type) { case *arrayContainer: stats.ArrayContainers++ stats.ArrayContai...
[ "func", "(", "rb", "*", "Bitmap", ")", "Stats", "(", ")", "Statistics", "{", "stats", ":=", "Statistics", "{", "}", "\n", "stats", ".", "Containers", "=", "uint64", "(", "len", "(", "rb", ".", "highlowcontainer", ".", "containers", ")", ")", "\n", "f...
// Stats returns details on container type usage in a Statistics struct.
[ "Stats", "returns", "details", "on", "container", "type", "usage", "in", "a", "Statistics", "struct", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaring.go#L1405-L1427
22,666
RoaringBitmap/roaring
arraycontainer.go
iaddRange
func (ac *arrayContainer) iaddRange(firstOfRange, endx int) container { if firstOfRange >= endx { return ac } indexstart := binarySearch(ac.content, uint16(firstOfRange)) if indexstart < 0 { indexstart = -indexstart - 1 } indexend := binarySearch(ac.content, uint16(endx-1)) if indexend < 0 { indexend = -in...
go
func (ac *arrayContainer) iaddRange(firstOfRange, endx int) container { if firstOfRange >= endx { return ac } indexstart := binarySearch(ac.content, uint16(firstOfRange)) if indexstart < 0 { indexstart = -indexstart - 1 } indexend := binarySearch(ac.content, uint16(endx-1)) if indexend < 0 { indexend = -in...
[ "func", "(", "ac", "*", "arrayContainer", ")", "iaddRange", "(", "firstOfRange", ",", "endx", "int", ")", "container", "{", "if", "firstOfRange", ">=", "endx", "{", "return", "ac", "\n", "}", "\n", "indexstart", ":=", "binarySearch", "(", "ac", ".", "con...
// add the values in the range [firstOfRange,endx)
[ "add", "the", "values", "in", "the", "range", "[", "firstOfRange", "endx", ")" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/arraycontainer.go#L60-L95
22,667
RoaringBitmap/roaring
arraycontainer.go
iremoveReturnMinimized
func (ac *arrayContainer) iremoveReturnMinimized(x uint16) container { ac.iremove(x) return ac }
go
func (ac *arrayContainer) iremoveReturnMinimized(x uint16) container { ac.iremove(x) return ac }
[ "func", "(", "ac", "*", "arrayContainer", ")", "iremoveReturnMinimized", "(", "x", "uint16", ")", "container", "{", "ac", ".", "iremove", "(", "x", ")", "\n", "return", "ac", "\n", "}" ]
// iremoveReturnMinimized is allowed to change the return type to minimize storage.
[ "iremoveReturnMinimized", "is", "allowed", "to", "change", "the", "return", "type", "to", "minimize", "storage", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/arraycontainer.go#L273-L276
22,668
RoaringBitmap/roaring
serialization_generic.go
byteSliceAsInterval16Slice
func byteSliceAsInterval16Slice(byteSlice []byte) []interval16 { if len(byteSlice)%4 != 0 { panic("Slice size should be divisible by 4") } intervalSlice := make([]interval16, len(byteSlice)/4) for i := range intervalSlice { intervalSlice[i] = interval16{ start: binary.LittleEndian.Uint16(byteSlice[i*4:]),...
go
func byteSliceAsInterval16Slice(byteSlice []byte) []interval16 { if len(byteSlice)%4 != 0 { panic("Slice size should be divisible by 4") } intervalSlice := make([]interval16, len(byteSlice)/4) for i := range intervalSlice { intervalSlice[i] = interval16{ start: binary.LittleEndian.Uint16(byteSlice[i*4:]),...
[ "func", "byteSliceAsInterval16Slice", "(", "byteSlice", "[", "]", "byte", ")", "[", "]", "interval16", "{", "if", "len", "(", "byteSlice", ")", "%", "4", "!=", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "intervalSlice", ":=", "make", ...
// Converts a byte slice to a interval16 slice. // The function assumes that the slice byte buffer is run container data // encoded according to Roaring Format Spec
[ "Converts", "a", "byte", "slice", "to", "a", "interval16", "slice", ".", "The", "function", "assumes", "that", "the", "slice", "byte", "buffer", "is", "run", "container", "data", "encoded", "according", "to", "Roaring", "Format", "Spec" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/serialization_generic.go#L108-L123
22,669
RoaringBitmap/roaring
clz_compat.go
countLeadingZeros
func countLeadingZeros(i uint64) int { if i == 0 { return 64 } n := 1 x := uint32(i >> 32) if x == 0 { n += 32 x = uint32(i) } if (x >> 16) == 0 { n += 16 x <<= 16 } if (x >> 24) == 0 { n += 8 x <<= 8 } if x>>28 == 0 { n += 4 x <<= 4 } if x>>30 == 0 { n += 2 x <<= 2 } n -= int(x >>...
go
func countLeadingZeros(i uint64) int { if i == 0 { return 64 } n := 1 x := uint32(i >> 32) if x == 0 { n += 32 x = uint32(i) } if (x >> 16) == 0 { n += 16 x <<= 16 } if (x >> 24) == 0 { n += 8 x <<= 8 } if x>>28 == 0 { n += 4 x <<= 4 } if x>>30 == 0 { n += 2 x <<= 2 } n -= int(x >>...
[ "func", "countLeadingZeros", "(", "i", "uint64", ")", "int", "{", "if", "i", "==", "0", "{", "return", "64", "\n", "}", "\n", "n", ":=", "1", "\n", "x", ":=", "uint32", "(", "i", ">>", "32", ")", "\n", "if", "x", "==", "0", "{", "n", "+=", ...
// LeadingZeroBits returns the number of consecutive most significant zero // bits of x.
[ "LeadingZeroBits", "returns", "the", "number", "of", "consecutive", "most", "significant", "zero", "bits", "of", "x", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/clz_compat.go#L7-L36
22,670
RoaringBitmap/roaring
roaringarray.go
serializedSizeInBytes
func (ra *roaringArray) serializedSizeInBytes() uint64 { answer := ra.headerSize() for _, c := range ra.containers { answer += uint64(c.serializedSizeInBytes()) } return answer }
go
func (ra *roaringArray) serializedSizeInBytes() uint64 { answer := ra.headerSize() for _, c := range ra.containers { answer += uint64(c.serializedSizeInBytes()) } return answer }
[ "func", "(", "ra", "*", "roaringArray", ")", "serializedSizeInBytes", "(", ")", "uint64", "{", "answer", ":=", "ra", ".", "headerSize", "(", ")", "\n", "for", "_", ",", "c", ":=", "range", "ra", ".", "containers", "{", "answer", "+=", "uint64", "(", ...
// should be dirt cheap
[ "should", "be", "dirt", "cheap" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/roaringarray.go#L451-L457
22,671
RoaringBitmap/roaring
smat.go
smatWrap
func smatWrap(cb func(c *smatContext)) func(smat.Context) (next smat.State, err error) { return func(ctx smat.Context) (next smat.State, err error) { c := ctx.(*smatContext) cb(c) return smatRunning, nil } }
go
func smatWrap(cb func(c *smatContext)) func(smat.Context) (next smat.State, err error) { return func(ctx smat.Context) (next smat.State, err error) { c := ctx.(*smatContext) cb(c) return smatRunning, nil } }
[ "func", "smatWrap", "(", "cb", "func", "(", "c", "*", "smatContext", ")", ")", "func", "(", "smat", ".", "Context", ")", "(", "next", "smat", ".", "State", ",", "err", "error", ")", "{", "return", "func", "(", "ctx", "smat", ".", "Context", ")", ...
// Creates an smat action func based on a simple callback.
[ "Creates", "an", "smat", "action", "func", "based", "on", "a", "simple", "callback", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/smat.go#L173-L179
22,672
mesosphere/mesos-dns
records/state/client/cli.go
NewStateLoader
func NewStateLoader(doer httpcli.Doer, initialEndpoint urls.Builder, unmarshal Unmarshaler) StateLoader { return func(masters []string) (state.State, error) { return LoadMasterStateTryAll(masters, func(ip, port string) (state.State, error) { return LoadMasterStateFailover(ip, func(tryIP string) (state.State, erro...
go
func NewStateLoader(doer httpcli.Doer, initialEndpoint urls.Builder, unmarshal Unmarshaler) StateLoader { return func(masters []string) (state.State, error) { return LoadMasterStateTryAll(masters, func(ip, port string) (state.State, error) { return LoadMasterStateFailover(ip, func(tryIP string) (state.State, erro...
[ "func", "NewStateLoader", "(", "doer", "httpcli", ".", "Doer", ",", "initialEndpoint", "urls", ".", "Builder", ",", "unmarshal", "Unmarshaler", ")", "StateLoader", "{", "return", "func", "(", "masters", "[", "]", "string", ")", "(", "state", ".", "State", ...
// NewStateLoader generates a new Mesos master state loader using the given http client and initial endpoint.
[ "NewStateLoader", "generates", "a", "new", "Mesos", "master", "state", "loader", "using", "the", "given", "http", "client", "and", "initial", "endpoint", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/state/client/cli.go#L27-L36
22,673
mesosphere/mesos-dns
records/state/client/cli.go
LoadMasterStateTryAll
func LoadMasterStateTryAll(masters []string, stateLoader func(ip, port string) (state.State, error)) (state.State, error) { var sj state.State var leader string if len(masters) > 0 { leader, masters = masters[0], masters[1:] } else { return sj, errors.New("no masters given to fetch state.json") } // Check i...
go
func LoadMasterStateTryAll(masters []string, stateLoader func(ip, port string) (state.State, error)) (state.State, error) { var sj state.State var leader string if len(masters) > 0 { leader, masters = masters[0], masters[1:] } else { return sj, errors.New("no masters given to fetch state.json") } // Check i...
[ "func", "LoadMasterStateTryAll", "(", "masters", "[", "]", "string", ",", "stateLoader", "func", "(", "ip", ",", "port", "string", ")", "(", "state", ".", "State", ",", "error", ")", ")", "(", "state", ".", "State", ",", "error", ")", "{", "var", "sj...
// LoadMasterStateTryAll tries each master and looks for the leader; if no leader responds it errors. // The first master in the list is assumed to be the leading mesos master.
[ "LoadMasterStateTryAll", "tries", "each", "master", "and", "looks", "for", "the", "leader", ";", "if", "no", "leader", "responds", "it", "errors", ".", "The", "first", "master", "in", "the", "list", "is", "assumed", "to", "be", "the", "leading", "mesos", "...
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/state/client/cli.go#L40-L90
22,674
mesosphere/mesos-dns
records/state/client/cli.go
LoadMasterStateFailover
func LoadMasterStateFailover(initialMasterIP string, stateLoader func(ip string) (state.State, error)) (state.State, error) { var err error var sj state.State logging.VeryVerbose.Println("reloading from master " + initialMasterIP) sj, err = stateLoader(initialMasterIP) if err != nil { return state.State{}, err ...
go
func LoadMasterStateFailover(initialMasterIP string, stateLoader func(ip string) (state.State, error)) (state.State, error) { var err error var sj state.State logging.VeryVerbose.Println("reloading from master " + initialMasterIP) sj, err = stateLoader(initialMasterIP) if err != nil { return state.State{}, err ...
[ "func", "LoadMasterStateFailover", "(", "initialMasterIP", "string", ",", "stateLoader", "func", "(", "ip", "string", ")", "(", "state", ".", "State", ",", "error", ")", ")", "(", "state", ".", "State", ",", "error", ")", "{", "var", "err", "error", "\n"...
// LoadMasterStateFailover catches an attempt to load state from a mesos master. // Attempts can fail from due to a down server or if contacting a mesos master secondary. // It reloads from a different master if the contacted master is a secondary.
[ "LoadMasterStateFailover", "catches", "an", "attempt", "to", "load", "state", "from", "a", "mesos", "master", ".", "Attempts", "can", "fail", "from", "due", "to", "a", "down", "server", "or", "if", "contacting", "a", "mesos", "master", "secondary", ".", "It"...
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/state/client/cli.go#L95-L119
22,675
mesosphere/mesos-dns
records/state/client/cli.go
LoadMasterState
func LoadMasterState(client httpcli.Doer, stateEndpoint urls.Builder, ip, port string, unmarshal Unmarshaler) (sj state.State, _ error) { // REFACTOR: state security u := url.URL(stateEndpoint.With(urls.Host(net.JoinHostPort(ip, port)))) req, err := http.NewRequest("GET", u.String(), nil) if err != nil { loggin...
go
func LoadMasterState(client httpcli.Doer, stateEndpoint urls.Builder, ip, port string, unmarshal Unmarshaler) (sj state.State, _ error) { // REFACTOR: state security u := url.URL(stateEndpoint.With(urls.Host(net.JoinHostPort(ip, port)))) req, err := http.NewRequest("GET", u.String(), nil) if err != nil { loggin...
[ "func", "LoadMasterState", "(", "client", "httpcli", ".", "Doer", ",", "stateEndpoint", "urls", ".", "Builder", ",", "ip", ",", "port", "string", ",", "unmarshal", "Unmarshaler", ")", "(", "sj", "state", ".", "State", ",", "_", "error", ")", "{", "// REF...
// LoadMasterState loads state from mesos master
[ "LoadMasterState", "loads", "state", "from", "mesos", "master" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/state/client/cli.go#L122-L156
22,676
mesosphere/mesos-dns
records/state/client/cli.go
leaderIP
func leaderIP(leader string) (string, error) { // TODO(jdef) it's unclear why we drop the port here nameAddressPair := strings.Split(leader, "@") if len(nameAddressPair) != 2 { return "", errors.New("Invalid leader address: " + leader) } hostPort := nameAddressPair[1] host, _, err := net.SplitHostPort(hostPort)...
go
func leaderIP(leader string) (string, error) { // TODO(jdef) it's unclear why we drop the port here nameAddressPair := strings.Split(leader, "@") if len(nameAddressPair) != 2 { return "", errors.New("Invalid leader address: " + leader) } hostPort := nameAddressPair[1] host, _, err := net.SplitHostPort(hostPort)...
[ "func", "leaderIP", "(", "leader", "string", ")", "(", "string", ",", "error", ")", "{", "// TODO(jdef) it's unclear why we drop the port here", "nameAddressPair", ":=", "strings", ".", "Split", "(", "leader", ",", "\"", "\"", ")", "\n", "if", "len", "(", "nam...
// leaderIP returns the ip for the mesos master // input format master@ip:port
[ "leaderIP", "returns", "the", "ip", "for", "the", "mesos", "master", "input", "format", "master" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/state/client/cli.go#L160-L172
22,677
mesosphere/mesos-dns
records/validation.go
validateUniqueStrings
func validateUniqueStrings(strings []string, normalize func(string) (string, error)) error { valid := make(map[string]struct{}, len(strings)) for _, str := range strings { normalized, err := normalize(str) if err != nil { return err } if _, found := valid[normalized]; found { return fmt.Errorf("duplicat...
go
func validateUniqueStrings(strings []string, normalize func(string) (string, error)) error { valid := make(map[string]struct{}, len(strings)) for _, str := range strings { normalized, err := normalize(str) if err != nil { return err } if _, found := valid[normalized]; found { return fmt.Errorf("duplicat...
[ "func", "validateUniqueStrings", "(", "strings", "[", "]", "string", ",", "normalize", "func", "(", "string", ")", "(", "string", ",", "error", ")", ")", "error", "{", "valid", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ",", "l...
// validateUniqueStrings runs a normalize function on each string in a list and // retuns an error if any duplicates are found.
[ "validateUniqueStrings", "runs", "a", "normalize", "function", "on", "each", "string", "in", "a", "list", "and", "retuns", "an", "error", "if", "any", "duplicates", "are", "found", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/validation.go#L122-L135
22,678
mesosphere/mesos-dns
records/validation.go
validateIPSources
func validateIPSources(srcs []string) error { if len(srcs) == 0 { return fmt.Errorf("empty ip sources") } if len(srcs) != len(unique(srcs)) { return fmt.Errorf("duplicate ip source specified") } for _, src := range srcs { switch src { case "host", "docker", "mesos", "netinfo": default: return fmt.Erro...
go
func validateIPSources(srcs []string) error { if len(srcs) == 0 { return fmt.Errorf("empty ip sources") } if len(srcs) != len(unique(srcs)) { return fmt.Errorf("duplicate ip source specified") } for _, src := range srcs { switch src { case "host", "docker", "mesos", "netinfo": default: return fmt.Erro...
[ "func", "validateIPSources", "(", "srcs", "[", "]", "string", ")", "error", "{", "if", "len", "(", "srcs", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "srcs", ")", "!=", "len", "...
// validateIPSources checks validity of ip sources
[ "validateIPSources", "checks", "validity", "of", "ip", "sources" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/validation.go#L138-L154
22,679
mesosphere/mesos-dns
records/validation.go
validPortString
func validPortString(portString string) bool { port, err := strconv.Atoi(portString) return err == nil && port > 0 && port <= 65535 }
go
func validPortString(portString string) bool { port, err := strconv.Atoi(portString) return err == nil && port > 0 && port <= 65535 }
[ "func", "validPortString", "(", "portString", "string", ")", "bool", "{", "port", ",", "err", ":=", "strconv", ".", "Atoi", "(", "portString", ")", "\n", "return", "err", "==", "nil", "&&", "port", ">", "0", "&&", "port", "<=", "65535", "\n", "}" ]
// validPortString retuns true if the given port string is // an integer between 1 and 65535, false otherwise.
[ "validPortString", "retuns", "true", "if", "the", "given", "port", "string", "is", "an", "integer", "between", "1", "and", "65535", "false", "otherwise", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/validation.go#L158-L161
22,680
mesosphere/mesos-dns
records/generator.go
ToAXFRResourceRecordSet
func (r rrs) ToAXFRResourceRecordSet() models.AXFRResourceRecordSet { ret := make(models.AXFRResourceRecordSet, len(r)) for host, values := range r { ret[host] = make([]string, 0, len(values)) for record := range values { ret[host] = append(ret[host], record) } } return ret }
go
func (r rrs) ToAXFRResourceRecordSet() models.AXFRResourceRecordSet { ret := make(models.AXFRResourceRecordSet, len(r)) for host, values := range r { ret[host] = make([]string, 0, len(values)) for record := range values { ret[host] = append(ret[host], record) } } return ret }
[ "func", "(", "r", "rrs", ")", "ToAXFRResourceRecordSet", "(", ")", "models", ".", "AXFRResourceRecordSet", "{", "ret", ":=", "make", "(", "models", ".", "AXFRResourceRecordSet", ",", "len", "(", "r", ")", ")", "\n", "for", "host", ",", "values", ":=", "r...
// Transform the record set into something exportable via the REST API
[ "Transform", "the", "record", "set", "into", "something", "exportable", "via", "the", "REST", "API" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/generator.go#L59-L68
22,681
mesosphere/mesos-dns
records/generator.go
NewRecordGenerator
func NewRecordGenerator(options ...Option) *RecordGenerator { rg := &RecordGenerator{} rg.stateLoader = func(_ []string) (s state.State, err error) { return } for i := range options { if options[i] != nil { options[i](rg) } } return rg }
go
func NewRecordGenerator(options ...Option) *RecordGenerator { rg := &RecordGenerator{} rg.stateLoader = func(_ []string) (s state.State, err error) { return } for i := range options { if options[i] != nil { options[i](rg) } } return rg }
[ "func", "NewRecordGenerator", "(", "options", "...", "Option", ")", "*", "RecordGenerator", "{", "rg", ":=", "&", "RecordGenerator", "{", "}", "\n", "rg", ".", "stateLoader", "=", "func", "(", "_", "[", "]", "string", ")", "(", "s", "state", ".", "Stat...
// NewRecordGenerator returns a RecordGenerator that's been configured with a timeout.
[ "NewRecordGenerator", "returns", "a", "RecordGenerator", "that", "s", "been", "configured", "with", "a", "timeout", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/generator.go#L160-L169
22,682
mesosphere/mesos-dns
records/generator.go
InsertState
func (rg *RecordGenerator) InsertState(sj state.State, domain, ns, listener string, masters, ipSources []string, spec labels.Func) error { rg.SlaveIPs = map[string][]string{} rg.SRVs = rrs{} rg.As = rrs{} rg.AAAAs = rrs{} rg.frameworkRecords(sj, domain, spec) rg.slaveRecords(sj, domain, spec) rg.listenerRecord(l...
go
func (rg *RecordGenerator) InsertState(sj state.State, domain, ns, listener string, masters, ipSources []string, spec labels.Func) error { rg.SlaveIPs = map[string][]string{} rg.SRVs = rrs{} rg.As = rrs{} rg.AAAAs = rrs{} rg.frameworkRecords(sj, domain, spec) rg.slaveRecords(sj, domain, spec) rg.listenerRecord(l...
[ "func", "(", "rg", "*", "RecordGenerator", ")", "InsertState", "(", "sj", "state", ".", "State", ",", "domain", ",", "ns", ",", "listener", "string", ",", "masters", ",", "ipSources", "[", "]", "string", ",", "spec", "labels", ".", "Func", ")", "error"...
// InsertState transforms a StateJSON into RecordGenerator RRs
[ "InsertState", "transforms", "a", "StateJSON", "into", "RecordGenerator", "RRs" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/generator.go#L205-L217
22,683
mesosphere/mesos-dns
records/generator.go
setFromLocal
func (rg *RecordGenerator) setFromLocal(host string, ns string) { ifaces, err := net.Interfaces() if err != nil { logging.Error.Println(err) } // handle err for _, i := range ifaces { addrs, err := i.Addrs() if err != nil { logging.Error.Println(err) } for _, addr := range addrs { var ip net.IP...
go
func (rg *RecordGenerator) setFromLocal(host string, ns string) { ifaces, err := net.Interfaces() if err != nil { logging.Error.Println(err) } // handle err for _, i := range ifaces { addrs, err := i.Addrs() if err != nil { logging.Error.Println(err) } for _, addr := range addrs { var ip net.IP...
[ "func", "(", "rg", "*", "RecordGenerator", ")", "setFromLocal", "(", "host", "string", ",", "ns", "string", ")", "{", "ifaces", ",", "err", ":=", "net", ".", "Interfaces", "(", ")", "\n", "if", "err", "!=", "nil", "{", "logging", ".", "Error", ".", ...
// A and AAAA records for each local interface // If this causes problems you should explicitly set the // listener address in config.json
[ "A", "and", "AAAA", "records", "for", "each", "local", "interface", "If", "this", "causes", "problems", "you", "should", "explicitly", "set", "the", "listener", "address", "in", "config", ".", "json" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/generator.go#L500-L531
22,684
mesosphere/mesos-dns
records/generator.go
ipsTo4And6
func ipsTo4And6(allIPs []net.IP) (ips []net.IP) { var ipv4, ipv6 net.IP for _, ip := range allIPs { if ipv4 != nil && ipv6 != nil { break } else if t4 := ip.To4(); t4 != nil { if ipv4 == nil { ipv4 = t4 } } else if t6 := ip.To16(); t6 != nil { if ipv6 == nil { ipv6 = t6 } } } ips = []...
go
func ipsTo4And6(allIPs []net.IP) (ips []net.IP) { var ipv4, ipv6 net.IP for _, ip := range allIPs { if ipv4 != nil && ipv6 != nil { break } else if t4 := ip.To4(); t4 != nil { if ipv4 == nil { ipv4 = t4 } } else if t6 := ip.To16(); t6 != nil { if ipv6 == nil { ipv6 = t6 } } } ips = []...
[ "func", "ipsTo4And6", "(", "allIPs", "[", "]", "net", ".", "IP", ")", "(", "ips", "[", "]", "net", ".", "IP", ")", "{", "var", "ipv4", ",", "ipv6", "net", ".", "IP", "\n", "for", "_", ",", "ip", ":=", "range", "allIPs", "{", "if", "ipv4", "!=...
// ipsTo4And6 returns a list with at most 1 ipv4 and 1 ipv6 // from a list of IPs
[ "ipsTo4And6", "returns", "a", "list", "with", "at", "most", "1", "ipv4", "and", "1", "ipv6", "from", "a", "list", "of", "IPs" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/generator.go#L572-L595
22,685
mesosphere/mesos-dns
records/generator.go
hostToIPs
func hostToIPs(hostname string) (ips []net.IP) { if ip := net.ParseIP(hostname); ip != nil { ips = []net.IP{ip} } else if allIPs, err := net.LookupIP(hostname); err == nil { ips = ipsTo4And6(allIPs) } if len(ips) == 0 { logging.VeryVerbose.Printf("cannot translate hostname %q into an ipv4 or ipv6 address", ho...
go
func hostToIPs(hostname string) (ips []net.IP) { if ip := net.ParseIP(hostname); ip != nil { ips = []net.IP{ip} } else if allIPs, err := net.LookupIP(hostname); err == nil { ips = ipsTo4And6(allIPs) } if len(ips) == 0 { logging.VeryVerbose.Printf("cannot translate hostname %q into an ipv4 or ipv6 address", ho...
[ "func", "hostToIPs", "(", "hostname", "string", ")", "(", "ips", "[", "]", "net", ".", "IP", ")", "{", "if", "ip", ":=", "net", ".", "ParseIP", "(", "hostname", ")", ";", "ip", "!=", "nil", "{", "ips", "=", "[", "]", "net", ".", "IP", "{", "i...
// hostToIPs attempts to parse a hostname into an ip. // If that doesn't work it will perform a lookup and try to // find one ipv4 and one ipv6 in the results.
[ "hostToIPs", "attempts", "to", "parse", "a", "hostname", "into", "an", "ip", ".", "If", "that", "doesn", "t", "work", "it", "will", "perform", "a", "lookup", "and", "try", "to", "find", "one", "ipv4", "and", "one", "ipv6", "in", "the", "results", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/generator.go#L600-L610
22,686
mesosphere/mesos-dns
records/generator.go
slaveIDTail
func slaveIDTail(slaveID string) string { fields := strings.Split(slaveID, "-") return strings.ToLower(fields[len(fields)-1]) }
go
func slaveIDTail(slaveID string) string { fields := strings.Split(slaveID, "-") return strings.ToLower(fields[len(fields)-1]) }
[ "func", "slaveIDTail", "(", "slaveID", "string", ")", "string", "{", "fields", ":=", "strings", ".", "Split", "(", "slaveID", ",", "\"", "\"", ")", "\n", "return", "strings", ".", "ToLower", "(", "fields", "[", "len", "(", "fields", ")", "-", "1", "]...
// return the slave number from a Mesos slave id
[ "return", "the", "slave", "number", "from", "a", "Mesos", "slave", "id" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/records/generator.go#L613-L616
22,687
mesosphere/mesos-dns
exchanger/exchanger.go
Decorate
func Decorate(ex Exchanger, ds ...Decorator) Exchanger { decorated := ex for _, decorate := range ds { decorated = decorate(decorated) } return decorated }
go
func Decorate(ex Exchanger, ds ...Decorator) Exchanger { decorated := ex for _, decorate := range ds { decorated = decorate(decorated) } return decorated }
[ "func", "Decorate", "(", "ex", "Exchanger", ",", "ds", "...", "Decorator", ")", "Exchanger", "{", "decorated", ":=", "ex", "\n", "for", "_", ",", "decorate", ":=", "range", "ds", "{", "decorated", "=", "decorate", "(", "decorated", ")", "\n", "}", "\n"...
// Decorate decorates an Exchanger with the given Decorators.
[ "Decorate", "decorates", "an", "Exchanger", "with", "the", "given", "Decorators", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/exchanger/exchanger.go#L42-L48
22,688
mesosphere/mesos-dns
exchanger/exchanger.go
ErrorLogging
func ErrorLogging(l *log.Logger) Decorator { return func(ex Exchanger) Exchanger { return Func(func(m *dns.Msg, a string) (r *dns.Msg, rtt time.Duration, err error) { defer func() { if err != nil { l.Printf("%v: exchanging %#v with %q", err, m, a) } }() return ex.Exchange(m, a) }) } }
go
func ErrorLogging(l *log.Logger) Decorator { return func(ex Exchanger) Exchanger { return Func(func(m *dns.Msg, a string) (r *dns.Msg, rtt time.Duration, err error) { defer func() { if err != nil { l.Printf("%v: exchanging %#v with %q", err, m, a) } }() return ex.Exchange(m, a) }) } }
[ "func", "ErrorLogging", "(", "l", "*", "log", ".", "Logger", ")", "Decorator", "{", "return", "func", "(", "ex", "Exchanger", ")", "Exchanger", "{", "return", "Func", "(", "func", "(", "m", "*", "dns", ".", "Msg", ",", "a", "string", ")", "(", "r",...
// ErrorLogging returns a Decorator which logs an Exchanger's errors to the given // logger.
[ "ErrorLogging", "returns", "a", "Decorator", "which", "logs", "an", "Exchanger", "s", "errors", "to", "the", "given", "logger", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/exchanger/exchanger.go#L52-L63
22,689
mesosphere/mesos-dns
exchanger/exchanger.go
Instrumentation
func Instrumentation(total, success, failure logging.Counter) Decorator { return func(ex Exchanger) Exchanger { return Func(func(m *dns.Msg, a string) (r *dns.Msg, rtt time.Duration, err error) { defer func() { if total.Inc(); err != nil { failure.Inc() } else { success.Inc() } }() ret...
go
func Instrumentation(total, success, failure logging.Counter) Decorator { return func(ex Exchanger) Exchanger { return Func(func(m *dns.Msg, a string) (r *dns.Msg, rtt time.Duration, err error) { defer func() { if total.Inc(); err != nil { failure.Inc() } else { success.Inc() } }() ret...
[ "func", "Instrumentation", "(", "total", ",", "success", ",", "failure", "logging", ".", "Counter", ")", "Decorator", "{", "return", "func", "(", "ex", "Exchanger", ")", "Exchanger", "{", "return", "Func", "(", "func", "(", "m", "*", "dns", ".", "Msg", ...
// Instrumentation returns a Decorator which instruments an Exchanger with the given // counters.
[ "Instrumentation", "returns", "a", "Decorator", "which", "instruments", "an", "Exchanger", "with", "the", "given", "counters", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/exchanger/exchanger.go#L67-L80
22,690
mesosphere/mesos-dns
httpcli/doer.go
New
func New(am AuthMechanism, cm ConfigMap, options ...Option) Doer { defaultClient := &http.Client{} for i := range options { if options[i] != nil { options[i](defaultClient) } } df, ok := factoryFor(am) if !ok { panic(fmt.Sprintf("unregistered auth mechanism %q", am)) } return df(cm, defaultClient) }
go
func New(am AuthMechanism, cm ConfigMap, options ...Option) Doer { defaultClient := &http.Client{} for i := range options { if options[i] != nil { options[i](defaultClient) } } df, ok := factoryFor(am) if !ok { panic(fmt.Sprintf("unregistered auth mechanism %q", am)) } return df(cm, defaultClient) }
[ "func", "New", "(", "am", "AuthMechanism", ",", "cm", "ConfigMap", ",", "options", "...", "Option", ")", "Doer", "{", "defaultClient", ":=", "&", "http", ".", "Client", "{", "}", "\n", "for", "i", ":=", "range", "options", "{", "if", "options", "[", ...
// New generates and returns an HTTP transactor given an optional IAM configuration and some set of // functional options.
[ "New", "generates", "and", "returns", "an", "HTTP", "transactor", "given", "an", "optional", "IAM", "configuration", "and", "some", "set", "of", "functional", "options", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/httpcli/doer.go#L38-L51
22,691
mesosphere/mesos-dns
httpcli/doer.go
Timeout
func Timeout(timeout time.Duration) Option { return func(client *http.Client) { client.Timeout = timeout } }
go
func Timeout(timeout time.Duration) Option { return func(client *http.Client) { client.Timeout = timeout } }
[ "func", "Timeout", "(", "timeout", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "client", "*", "http", ".", "Client", ")", "{", "client", ".", "Timeout", "=", "timeout", "\n", "}", "\n", "}" ]
// Timeout returns an Option that configures client timeout
[ "Timeout", "returns", "an", "Option", "that", "configures", "client", "timeout" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/httpcli/doer.go#L54-L58
22,692
mesosphere/mesos-dns
httpcli/doer.go
Transport
func Transport(tr http.RoundTripper) Option { return func(client *http.Client) { client.Transport = tr } }
go
func Transport(tr http.RoundTripper) Option { return func(client *http.Client) { client.Transport = tr } }
[ "func", "Transport", "(", "tr", "http", ".", "RoundTripper", ")", "Option", "{", "return", "func", "(", "client", "*", "http", ".", "Client", ")", "{", "client", ".", "Transport", "=", "tr", "\n", "}", "\n", "}" ]
// Transport returns an Option that configures client transport
[ "Transport", "returns", "an", "Option", "that", "configures", "client", "transport" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/httpcli/doer.go#L61-L65
22,693
mesosphere/mesos-dns
httpcli/doer.go
TLSConfig
func TLSConfig(enabled bool, caPool *x509.CertPool, cert tls.Certificate) (opt urls.Option, config *tls.Config) { opt = urls.Scheme("http") if enabled { opt = urls.Scheme("https") config = &tls.Config{ Certificates: []tls.Certificate{cert}, RootCAs: caPool, InsecureSkipVerify: caPool == nil,...
go
func TLSConfig(enabled bool, caPool *x509.CertPool, cert tls.Certificate) (opt urls.Option, config *tls.Config) { opt = urls.Scheme("http") if enabled { opt = urls.Scheme("https") config = &tls.Config{ Certificates: []tls.Certificate{cert}, RootCAs: caPool, InsecureSkipVerify: caPool == nil,...
[ "func", "TLSConfig", "(", "enabled", "bool", ",", "caPool", "*", "x509", ".", "CertPool", ",", "cert", "tls", ".", "Certificate", ")", "(", "opt", "urls", ".", "Option", ",", "config", "*", "tls", ".", "Config", ")", "{", "opt", "=", "urls", ".", "...
// TLSConfig generates and returns a recommended URL generation option and TLS configuration.
[ "TLSConfig", "generates", "and", "returns", "a", "recommended", "URL", "generation", "option", "and", "TLS", "configuration", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/httpcli/doer.go#L68-L79
22,694
mesosphere/mesos-dns
resolver/resolver.go
New
func New(version string, config records.Config) *Resolver { generatorOptions := []records.Option{ records.WithConfig(config), } recordGenerator := records.NewRecordGenerator(generatorOptions...) r := &Resolver{ version: version, config: config, ready: make(chan struct{}), rs: recordGenerator, //...
go
func New(version string, config records.Config) *Resolver { generatorOptions := []records.Option{ records.WithConfig(config), } recordGenerator := records.NewRecordGenerator(generatorOptions...) r := &Resolver{ version: version, config: config, ready: make(chan struct{}), rs: recordGenerator, //...
[ "func", "New", "(", "version", "string", ",", "config", "records", ".", "Config", ")", "*", "Resolver", "{", "generatorOptions", ":=", "[", "]", "records", ".", "Option", "{", "records", ".", "WithConfig", "(", "config", ")", ",", "}", "\n", "recordGener...
// New returns a Resolver with the given version and configuration.
[ "New", "returns", "a", "Resolver", "with", "the", "given", "version", "and", "configuration", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L42-L77
22,695
mesosphere/mesos-dns
resolver/resolver.go
Reload
func (res *Resolver) Reload() { t := records.NewRecordGenerator(res.generatorOptions...) err := t.ParseState(res.config, res.masters...) if err == nil { timestamp := uint32(time.Now().Unix()) // may need to refactor for fairness res.rsLock.Lock() defer res.rsLock.Unlock() atomic.StoreUint32(&res.config.SO...
go
func (res *Resolver) Reload() { t := records.NewRecordGenerator(res.generatorOptions...) err := t.ParseState(res.config, res.masters...) if err == nil { timestamp := uint32(time.Now().Unix()) // may need to refactor for fairness res.rsLock.Lock() defer res.rsLock.Unlock() atomic.StoreUint32(&res.config.SO...
[ "func", "(", "res", "*", "Resolver", ")", "Reload", "(", ")", "{", "t", ":=", "records", ".", "NewRecordGenerator", "(", "res", ".", "generatorOptions", "...", ")", "\n", "err", ":=", "t", ".", "ParseState", "(", "res", ".", "config", ",", "res", "."...
// Reload triggers a new state load from the configured mesos masters. // This method is not goroutine-safe.
[ "Reload", "triggers", "a", "new", "state", "load", "from", "the", "configured", "mesos", "masters", ".", "This", "method", "is", "not", "goroutine", "-", "safe", "." ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L173-L195
22,696
mesosphere/mesos-dns
resolver/resolver.go
formatSRV
func (res *Resolver) formatSRV(name string, target string) (*dns.SRV, error) { ttl := uint32(res.config.TTL) h, port, err := net.SplitHostPort(target) if err != nil { return nil, errors.New("invalid target") } p, err := strconv.Atoi(port) if err != nil { return nil, errors.New("invalid target port") } ret...
go
func (res *Resolver) formatSRV(name string, target string) (*dns.SRV, error) { ttl := uint32(res.config.TTL) h, port, err := net.SplitHostPort(target) if err != nil { return nil, errors.New("invalid target") } p, err := strconv.Atoi(port) if err != nil { return nil, errors.New("invalid target port") } ret...
[ "func", "(", "res", "*", "Resolver", ")", "formatSRV", "(", "name", "string", ",", "target", "string", ")", "(", "*", "dns", ".", "SRV", ",", "error", ")", "{", "ttl", ":=", "uint32", "(", "res", ".", "config", ".", "TTL", ")", "\n\n", "h", ",", ...
// formatSRV returns the SRV resource record for target
[ "formatSRV", "returns", "the", "SRV", "resource", "record", "for", "target" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L198-L222
22,697
mesosphere/mesos-dns
resolver/resolver.go
formatA
func (res *Resolver) formatA(dom string, target string) (*dns.A, error) { ttl := uint32(res.config.TTL) a := net.ParseIP(target) if a == nil { return nil, errors.New("invalid target") } return &dns.A{ Hdr: dns.RR_Header{ Name: dom, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: ttl}, A: a....
go
func (res *Resolver) formatA(dom string, target string) (*dns.A, error) { ttl := uint32(res.config.TTL) a := net.ParseIP(target) if a == nil { return nil, errors.New("invalid target") } return &dns.A{ Hdr: dns.RR_Header{ Name: dom, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: ttl}, A: a....
[ "func", "(", "res", "*", "Resolver", ")", "formatA", "(", "dom", "string", ",", "target", "string", ")", "(", "*", "dns", ".", "A", ",", "error", ")", "{", "ttl", ":=", "uint32", "(", "res", ".", "config", ".", "TTL", ")", "\n\n", "a", ":=", "n...
// returns the A resource record for target // assumes target is a well formed IPv4 address
[ "returns", "the", "A", "resource", "record", "for", "target", "assumes", "target", "is", "a", "well", "formed", "IPv4", "address" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L226-L242
22,698
mesosphere/mesos-dns
resolver/resolver.go
formatAAAA
func (res *Resolver) formatAAAA(dom string, target string) (*dns.AAAA, error) { ttl := uint32(res.config.TTL) aaaa := net.ParseIP(target) if aaaa == nil { return nil, errors.New("invalid target") } return &dns.AAAA{ Hdr: dns.RR_Header{ Name: dom, Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl...
go
func (res *Resolver) formatAAAA(dom string, target string) (*dns.AAAA, error) { ttl := uint32(res.config.TTL) aaaa := net.ParseIP(target) if aaaa == nil { return nil, errors.New("invalid target") } return &dns.AAAA{ Hdr: dns.RR_Header{ Name: dom, Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl...
[ "func", "(", "res", "*", "Resolver", ")", "formatAAAA", "(", "dom", "string", ",", "target", "string", ")", "(", "*", "dns", ".", "AAAA", ",", "error", ")", "{", "ttl", ":=", "uint32", "(", "res", ".", "config", ".", "TTL", ")", "\n\n", "aaaa", "...
// returns the AAAA resource record for target // assumes target is a well formed IPv6 address
[ "returns", "the", "AAAA", "resource", "record", "for", "target", "assumes", "target", "is", "a", "well", "formed", "IPv6", "address" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L246-L262
22,699
mesosphere/mesos-dns
resolver/resolver.go
formatSOA
func (res *Resolver) formatSOA(dom string) *dns.SOA { ttl := uint32(res.config.TTL) return &dns.SOA{ Hdr: dns.RR_Header{ Name: dom, Rrtype: dns.TypeSOA, Class: dns.ClassINET, Ttl: ttl, }, Ns: res.config.SOAMname, Mbox: res.config.SOARname, Serial: atomic.LoadUint32(&res.config.SO...
go
func (res *Resolver) formatSOA(dom string) *dns.SOA { ttl := uint32(res.config.TTL) return &dns.SOA{ Hdr: dns.RR_Header{ Name: dom, Rrtype: dns.TypeSOA, Class: dns.ClassINET, Ttl: ttl, }, Ns: res.config.SOAMname, Mbox: res.config.SOARname, Serial: atomic.LoadUint32(&res.config.SO...
[ "func", "(", "res", "*", "Resolver", ")", "formatSOA", "(", "dom", "string", ")", "*", "dns", ".", "SOA", "{", "ttl", ":=", "uint32", "(", "res", ".", "config", ".", "TTL", ")", "\n\n", "return", "&", "dns", ".", "SOA", "{", "Hdr", ":", "dns", ...
// formatSOA returns the SOA resource record for the mesos domain
[ "formatSOA", "returns", "the", "SOA", "resource", "record", "for", "the", "mesos", "domain" ]
65cb06fff5493c3caa8fc00d26e89fbedab9d95e
https://github.com/mesosphere/mesos-dns/blob/65cb06fff5493c3caa8fc00d26e89fbedab9d95e/resolver/resolver.go#L265-L283