repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
pilosa/pilosa | stats/stats.go | Close | func (a MultiStatsClient) Close() error {
for _, c := range a {
err := c.Close()
if err != nil {
return err
}
}
return nil
} | go | func (a MultiStatsClient) Close() error {
for _, c := range a {
err := c.Close()
if err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"a",
"MultiStatsClient",
")",
"Close",
"(",
")",
"error",
"{",
"for",
"_",
",",
"c",
":=",
"range",
"a",
"{",
"err",
":=",
"c",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"... | // Close shuts down the stats clients. | [
"Close",
"shuts",
"down",
"the",
"stats",
"clients",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/stats/stats.go#L240-L248 | train |
pilosa/pilosa | server/server.go | NewCommand | func NewCommand(stdin io.Reader, stdout, stderr io.Writer, opts ...CommandOption) *Command {
c := &Command{
Config: NewConfig(),
CmdIO: pilosa.NewCmdIO(stdin, stdout, stderr),
Started: make(chan struct{}),
done: make(chan struct{}),
}
for _, opt := range opts {
err := opt(c)
if err != nil {
pani... | go | func NewCommand(stdin io.Reader, stdout, stderr io.Writer, opts ...CommandOption) *Command {
c := &Command{
Config: NewConfig(),
CmdIO: pilosa.NewCmdIO(stdin, stdout, stderr),
Started: make(chan struct{}),
done: make(chan struct{}),
}
for _, opt := range opts {
err := opt(c)
if err != nil {
pani... | [
"func",
"NewCommand",
"(",
"stdin",
"io",
".",
"Reader",
",",
"stdout",
",",
"stderr",
"io",
".",
"Writer",
",",
"opts",
"...",
"CommandOption",
")",
"*",
"Command",
"{",
"c",
":=",
"&",
"Command",
"{",
"Config",
":",
"NewConfig",
"(",
")",
",",
"Cmd... | // NewCommand returns a new instance of Main. | [
"NewCommand",
"returns",
"a",
"new",
"instance",
"of",
"Main",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/server/server.go#L107-L126 | train |
pilosa/pilosa | server/server.go | Start | func (m *Command) Start() (err error) {
defer close(m.Started)
// Seed random number generator
rand.Seed(time.Now().UTC().UnixNano())
// SetupServer
err = m.SetupServer()
if err != nil {
return errors.Wrap(err, "setting up server")
}
// SetupNetworking
err = m.setupNetworking()
if err != nil {
return e... | go | func (m *Command) Start() (err error) {
defer close(m.Started)
// Seed random number generator
rand.Seed(time.Now().UTC().UnixNano())
// SetupServer
err = m.SetupServer()
if err != nil {
return errors.Wrap(err, "setting up server")
}
// SetupNetworking
err = m.setupNetworking()
if err != nil {
return e... | [
"func",
"(",
"m",
"*",
"Command",
")",
"Start",
"(",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"close",
"(",
"m",
".",
"Started",
")",
"\n\n",
"// Seed random number generator",
"rand",
".",
"Seed",
"(",
"time",
".",
"Now",
"(",
")",
".",
"UTC",
... | // Start starts the pilosa server - it returns once the server is running. | [
"Start",
"starts",
"the",
"pilosa",
"server",
"-",
"it",
"returns",
"once",
"the",
"server",
"is",
"running",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/server/server.go#L129-L161 | train |
pilosa/pilosa | server/server.go | Wait | func (m *Command) Wait() error {
// First SIGKILL causes server to shut down gracefully.
c := make(chan os.Signal, 2)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
select {
case sig := <-c:
m.logger.Printf("received signal '%s', gracefully shutting down...\n", sig.String())
// Second signal causes a hard sh... | go | func (m *Command) Wait() error {
// First SIGKILL causes server to shut down gracefully.
c := make(chan os.Signal, 2)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
select {
case sig := <-c:
m.logger.Printf("received signal '%s', gracefully shutting down...\n", sig.String())
// Second signal causes a hard sh... | [
"func",
"(",
"m",
"*",
"Command",
")",
"Wait",
"(",
")",
"error",
"{",
"// First SIGKILL causes server to shut down gracefully.",
"c",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"2",
")",
"\n",
"signal",
".",
"Notify",
"(",
"c",
",",
"os",
".",... | // Wait waits for the server to be closed or interrupted. | [
"Wait",
"waits",
"for",
"the",
"server",
"to",
"be",
"closed",
"or",
"interrupted",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/server/server.go#L164-L179 | train |
pilosa/pilosa | server/server.go | setupNetworking | func (m *Command) setupNetworking() error {
if m.Config.Cluster.Disabled {
return nil
}
gossipPort, err := strconv.Atoi(m.Config.Gossip.Port)
if err != nil {
return errors.Wrap(err, "parsing port")
}
// get the host portion of addr to use for binding
gossipHost := m.listenURI.Host
m.gossipTransport, err =... | go | func (m *Command) setupNetworking() error {
if m.Config.Cluster.Disabled {
return nil
}
gossipPort, err := strconv.Atoi(m.Config.Gossip.Port)
if err != nil {
return errors.Wrap(err, "parsing port")
}
// get the host portion of addr to use for binding
gossipHost := m.listenURI.Host
m.gossipTransport, err =... | [
"func",
"(",
"m",
"*",
"Command",
")",
"setupNetworking",
"(",
")",
"error",
"{",
"if",
"m",
".",
"Config",
".",
"Cluster",
".",
"Disabled",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"gossipPort",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"m",
... | // setupNetworking sets up internode communication based on the configuration. | [
"setupNetworking",
"sets",
"up",
"internode",
"communication",
"based",
"on",
"the",
"configuration",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/server/server.go#L332-L362 | train |
pilosa/pilosa | server/server.go | newStatsClient | func newStatsClient(name string, host string) (stats.StatsClient, error) {
switch name {
case "expvar":
return stats.NewExpvarStatsClient(), nil
case "statsd":
return statsd.NewStatsClient(host)
case "nop", "none":
return stats.NopStatsClient, nil
default:
return nil, errors.Errorf("'%v' not a valid stats ... | go | func newStatsClient(name string, host string) (stats.StatsClient, error) {
switch name {
case "expvar":
return stats.NewExpvarStatsClient(), nil
case "statsd":
return statsd.NewStatsClient(host)
case "nop", "none":
return stats.NopStatsClient, nil
default:
return nil, errors.Errorf("'%v' not a valid stats ... | [
"func",
"newStatsClient",
"(",
"name",
"string",
",",
"host",
"string",
")",
"(",
"stats",
".",
"StatsClient",
",",
"error",
")",
"{",
"switch",
"name",
"{",
"case",
"\"",
"\"",
":",
"return",
"stats",
".",
"NewExpvarStatsClient",
"(",
")",
",",
"nil",
... | // newStatsClient creates a stats client from the config | [
"newStatsClient",
"creates",
"a",
"stats",
"client",
"from",
"the",
"config"
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/server/server.go#L392-L403 | train |
pilosa/pilosa | server/server.go | getListener | func getListener(uri pilosa.URI, tlsconf *tls.Config) (ln net.Listener, err error) {
// If bind URI has the https scheme, enable TLS
if uri.Scheme == "https" && tlsconf != nil {
ln, err = tls.Listen("tcp", uri.HostPort(), tlsconf)
if err != nil {
return nil, errors.Wrap(err, "tls.Listener")
}
} else if uri.... | go | func getListener(uri pilosa.URI, tlsconf *tls.Config) (ln net.Listener, err error) {
// If bind URI has the https scheme, enable TLS
if uri.Scheme == "https" && tlsconf != nil {
ln, err = tls.Listen("tcp", uri.HostPort(), tlsconf)
if err != nil {
return nil, errors.Wrap(err, "tls.Listener")
}
} else if uri.... | [
"func",
"getListener",
"(",
"uri",
"pilosa",
".",
"URI",
",",
"tlsconf",
"*",
"tls",
".",
"Config",
")",
"(",
"ln",
"net",
".",
"Listener",
",",
"err",
"error",
")",
"{",
"// If bind URI has the https scheme, enable TLS",
"if",
"uri",
".",
"Scheme",
"==",
... | // getListener gets a net.Listener based on the config. | [
"getListener",
"gets",
"a",
"net",
".",
"Listener",
"based",
"on",
"the",
"config",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/server/server.go#L406-L424 | train |
pilosa/pilosa | roaring/roaring.go | NewBitmap | func NewBitmap(a ...uint64) *Bitmap {
b := &Bitmap{
Containers: newSliceContainers(),
}
// TODO: We have no way to report this. We aren't in a server context
// so we haven't got a logger, nothing is checking for nil returns
// from this...
_, _ = b.AddN(a...)
return b
} | go | func NewBitmap(a ...uint64) *Bitmap {
b := &Bitmap{
Containers: newSliceContainers(),
}
// TODO: We have no way to report this. We aren't in a server context
// so we haven't got a logger, nothing is checking for nil returns
// from this...
_, _ = b.AddN(a...)
return b
} | [
"func",
"NewBitmap",
"(",
"a",
"...",
"uint64",
")",
"*",
"Bitmap",
"{",
"b",
":=",
"&",
"Bitmap",
"{",
"Containers",
":",
"newSliceContainers",
"(",
")",
",",
"}",
"\n",
"// TODO: We have no way to report this. We aren't in a server context",
"// so we haven't got a ... | // NewBitmap returns a Bitmap with an initial set of values. | [
"NewBitmap",
"returns",
"a",
"Bitmap",
"with",
"an",
"initial",
"set",
"of",
"values",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L136-L145 | train |
pilosa/pilosa | roaring/roaring.go | DirectRemoveN | func (b *Bitmap) DirectRemoveN(a ...uint64) (changed int) {
return b.directOpN((*Container).remove, a...)
} | go | func (b *Bitmap) DirectRemoveN(a ...uint64) (changed int) {
return b.directOpN((*Container).remove, a...)
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"DirectRemoveN",
"(",
"a",
"...",
"uint64",
")",
"(",
"changed",
"int",
")",
"{",
"return",
"b",
".",
"directOpN",
"(",
"(",
"*",
"Container",
")",
".",
"remove",
",",
"a",
"...",
")",
"\n",
"}"
] | // DirectRemoveN behaves analgously to DirectAddN. | [
"DirectRemoveN",
"behaves",
"analgously",
"to",
"DirectAddN",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L224-L226 | train |
pilosa/pilosa | roaring/roaring.go | directOpN | func (b *Bitmap) directOpN(op func(c *Container, v uint16) bool, a ...uint64) (changed int) {
hb := uint64(0xFFFFFFFFFFFFFFFF) // impossible sentinel value
var cont *Container
for _, v := range a {
if newhb := highbits(v); newhb != hb {
hb = newhb
cont = b.Containers.GetOrCreate(hb)
}
if op(cont, lowbits... | go | func (b *Bitmap) directOpN(op func(c *Container, v uint16) bool, a ...uint64) (changed int) {
hb := uint64(0xFFFFFFFFFFFFFFFF) // impossible sentinel value
var cont *Container
for _, v := range a {
if newhb := highbits(v); newhb != hb {
hb = newhb
cont = b.Containers.GetOrCreate(hb)
}
if op(cont, lowbits... | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"directOpN",
"(",
"op",
"func",
"(",
"c",
"*",
"Container",
",",
"v",
"uint16",
")",
"bool",
",",
"a",
"...",
"uint64",
")",
"(",
"changed",
"int",
")",
"{",
"hb",
":=",
"uint64",
"(",
"0xFFFFFFFFFFFFFFFF",
")"... | // directOpN contains the logic for DirectAddN and DirectRemoveN. Theoretically,
// it could be used by anything that wanted to apply a boolean-returning
// container level operation across a list of values and return the number of
// trues while modifying the list of values in place to contain the
// true-returning va... | [
"directOpN",
"contains",
"the",
"logic",
"for",
"DirectAddN",
"and",
"DirectRemoveN",
".",
"Theoretically",
"it",
"could",
"be",
"used",
"by",
"anything",
"that",
"wanted",
"to",
"apply",
"a",
"boolean",
"-",
"returning",
"container",
"level",
"operation",
"acro... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L233-L247 | train |
pilosa/pilosa | roaring/roaring.go | Contains | func (b *Bitmap) Contains(v uint64) bool {
c := b.Containers.Get(highbits(v))
if c == nil {
return false
}
return c.Contains(lowbits(v))
} | go | func (b *Bitmap) Contains(v uint64) bool {
c := b.Containers.Get(highbits(v))
if c == nil {
return false
}
return c.Contains(lowbits(v))
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"Contains",
"(",
"v",
"uint64",
")",
"bool",
"{",
"c",
":=",
"b",
".",
"Containers",
".",
"Get",
"(",
"highbits",
"(",
"v",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
... | // Contains returns true if v is in the bitmap. | [
"Contains",
"returns",
"true",
"if",
"v",
"is",
"in",
"the",
"bitmap",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L257-L263 | train |
pilosa/pilosa | roaring/roaring.go | RemoveN | func (b *Bitmap) RemoveN(a ...uint64) (changed int, err error) {
if len(a) == 0 {
return 0, nil
}
changed = b.DirectRemoveN(a...) // modifies a in-place
if b.OpWriter != nil {
op := &op{
typ: opTypeRemoveBatch,
values: a[:changed],
}
if err := b.writeOp(op); err != nil {
b.DirectAddN(op.values... | go | func (b *Bitmap) RemoveN(a ...uint64) (changed int, err error) {
if len(a) == 0 {
return 0, nil
}
changed = b.DirectRemoveN(a...) // modifies a in-place
if b.OpWriter != nil {
op := &op{
typ: opTypeRemoveBatch,
values: a[:changed],
}
if err := b.writeOp(op); err != nil {
b.DirectAddN(op.values... | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"RemoveN",
"(",
"a",
"...",
"uint64",
")",
"(",
"changed",
"int",
",",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"a",
")",
"==",
"0",
"{",
"return",
"0",
",",
"nil",
"\n",
"}",
"\n\n",
"changed",
"=",
"... | // RemoveN behaves analagously to AddN. | [
"RemoveN",
"behaves",
"analagously",
"to",
"AddN",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L288-L307 | train |
pilosa/pilosa | roaring/roaring.go | Max | func (b *Bitmap) Max() uint64 {
if b.Containers.Size() == 0 {
return 0
}
hb, c := b.Containers.Last()
lb := c.max()
return hb<<16 | uint64(lb)
} | go | func (b *Bitmap) Max() uint64 {
if b.Containers.Size() == 0 {
return 0
}
hb, c := b.Containers.Last()
lb := c.max()
return hb<<16 | uint64(lb)
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"Max",
"(",
")",
"uint64",
"{",
"if",
"b",
".",
"Containers",
".",
"Size",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"hb",
",",
"c",
":=",
"b",
".",
"Containers",
".",
"Last",
"(",
")",
... | // Max returns the highest value in the bitmap.
// Returns zero if the bitmap is empty. | [
"Max",
"returns",
"the",
"highest",
"value",
"in",
"the",
"bitmap",
".",
"Returns",
"zero",
"if",
"the",
"bitmap",
"is",
"empty",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L320-L328 | train |
pilosa/pilosa | roaring/roaring.go | Size | func (b *Bitmap) Size() int {
numbytes := 0
citer, _ := b.Containers.Iterator(0)
for citer.Next() {
_, c := citer.Value()
numbytes += c.size()
}
return numbytes
} | go | func (b *Bitmap) Size() int {
numbytes := 0
citer, _ := b.Containers.Iterator(0)
for citer.Next() {
_, c := citer.Value()
numbytes += c.size()
}
return numbytes
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"Size",
"(",
")",
"int",
"{",
"numbytes",
":=",
"0",
"\n",
"citer",
",",
"_",
":=",
"b",
".",
"Containers",
".",
"Iterator",
"(",
"0",
")",
"\n",
"for",
"citer",
".",
"Next",
"(",
")",
"{",
"_",
",",
"c",... | // Size returns the number of bytes required for the bitmap. | [
"Size",
"returns",
"the",
"number",
"of",
"bytes",
"required",
"for",
"the",
"bitmap",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L351-L360 | train |
pilosa/pilosa | roaring/roaring.go | CountRange | func (b *Bitmap) CountRange(start, end uint64) (n uint64) {
if b.Containers.Size() == 0 {
return
}
skey := highbits(start)
ekey := highbits(end)
citer, found := b.Containers.Iterator(highbits(start))
// If range is entirely in one container then just count that range.
if found && skey == ekey {
citer.Next(... | go | func (b *Bitmap) CountRange(start, end uint64) (n uint64) {
if b.Containers.Size() == 0 {
return
}
skey := highbits(start)
ekey := highbits(end)
citer, found := b.Containers.Iterator(highbits(start))
// If range is entirely in one container then just count that range.
if found && skey == ekey {
citer.Next(... | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"CountRange",
"(",
"start",
",",
"end",
"uint64",
")",
"(",
"n",
"uint64",
")",
"{",
"if",
"b",
".",
"Containers",
".",
"Size",
"(",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"skey",
":=",
"highbits",... | // CountRange returns the number of bits set between [start, end). | [
"CountRange",
"returns",
"the",
"number",
"of",
"bits",
"set",
"between",
"[",
"start",
"end",
")",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L363-L402 | train |
pilosa/pilosa | roaring/roaring.go | Slice | func (b *Bitmap) Slice() []uint64 {
var a []uint64
itr := b.Iterator()
itr.Seek(0)
for v, eof := itr.Next(); !eof; v, eof = itr.Next() {
a = append(a, v)
}
return a
} | go | func (b *Bitmap) Slice() []uint64 {
var a []uint64
itr := b.Iterator()
itr.Seek(0)
for v, eof := itr.Next(); !eof; v, eof = itr.Next() {
a = append(a, v)
}
return a
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"Slice",
"(",
")",
"[",
"]",
"uint64",
"{",
"var",
"a",
"[",
"]",
"uint64",
"\n",
"itr",
":=",
"b",
".",
"Iterator",
"(",
")",
"\n",
"itr",
".",
"Seek",
"(",
"0",
")",
"\n\n",
"for",
"v",
",",
"eof",
":... | // Slice returns a slice of all integers in the bitmap. | [
"Slice",
"returns",
"a",
"slice",
"of",
"all",
"integers",
"in",
"the",
"bitmap",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L405-L414 | train |
pilosa/pilosa | roaring/roaring.go | SliceRange | func (b *Bitmap) SliceRange(start, end uint64) []uint64 {
var a []uint64
itr := b.Iterator()
itr.Seek(start)
for v, eof := itr.Next(); !eof && v < end; v, eof = itr.Next() {
a = append(a, v)
}
return a
} | go | func (b *Bitmap) SliceRange(start, end uint64) []uint64 {
var a []uint64
itr := b.Iterator()
itr.Seek(start)
for v, eof := itr.Next(); !eof && v < end; v, eof = itr.Next() {
a = append(a, v)
}
return a
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"SliceRange",
"(",
"start",
",",
"end",
"uint64",
")",
"[",
"]",
"uint64",
"{",
"var",
"a",
"[",
"]",
"uint64",
"\n",
"itr",
":=",
"b",
".",
"Iterator",
"(",
")",
"\n",
"itr",
".",
"Seek",
"(",
"start",
")"... | // SliceRange returns a slice of integers between [start, end). | [
"SliceRange",
"returns",
"a",
"slice",
"of",
"integers",
"between",
"[",
"start",
"end",
")",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L417-L425 | train |
pilosa/pilosa | roaring/roaring.go | ForEach | func (b *Bitmap) ForEach(fn func(uint64)) {
itr := b.Iterator()
itr.Seek(0)
for v, eof := itr.Next(); !eof; v, eof = itr.Next() {
fn(v)
}
} | go | func (b *Bitmap) ForEach(fn func(uint64)) {
itr := b.Iterator()
itr.Seek(0)
for v, eof := itr.Next(); !eof; v, eof = itr.Next() {
fn(v)
}
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"ForEach",
"(",
"fn",
"func",
"(",
"uint64",
")",
")",
"{",
"itr",
":=",
"b",
".",
"Iterator",
"(",
")",
"\n",
"itr",
".",
"Seek",
"(",
"0",
")",
"\n",
"for",
"v",
",",
"eof",
":=",
"itr",
".",
"Next",
... | // ForEach executes fn for each value in the bitmap. | [
"ForEach",
"executes",
"fn",
"for",
"each",
"value",
"in",
"the",
"bitmap",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L428-L434 | train |
pilosa/pilosa | roaring/roaring.go | ForEachRange | func (b *Bitmap) ForEachRange(start, end uint64, fn func(uint64)) {
itr := b.Iterator()
itr.Seek(start)
for v, eof := itr.Next(); !eof && v < end; v, eof = itr.Next() {
fn(v)
}
} | go | func (b *Bitmap) ForEachRange(start, end uint64, fn func(uint64)) {
itr := b.Iterator()
itr.Seek(start)
for v, eof := itr.Next(); !eof && v < end; v, eof = itr.Next() {
fn(v)
}
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"ForEachRange",
"(",
"start",
",",
"end",
"uint64",
",",
"fn",
"func",
"(",
"uint64",
")",
")",
"{",
"itr",
":=",
"b",
".",
"Iterator",
"(",
")",
"\n",
"itr",
".",
"Seek",
"(",
"start",
")",
"\n",
"for",
"v... | // ForEachRange executes fn for each value in the bitmap between [start, end). | [
"ForEachRange",
"executes",
"fn",
"for",
"each",
"value",
"in",
"the",
"bitmap",
"between",
"[",
"start",
"end",
")",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L437-L443 | train |
pilosa/pilosa | roaring/roaring.go | OffsetRange | func (b *Bitmap) OffsetRange(offset, start, end uint64) *Bitmap {
if lowbits(offset) != 0 {
panic("offset must not contain low bits")
}
if lowbits(start) != 0 {
panic("range start must not contain low bits")
}
if lowbits(end) != 0 {
panic("range end must not contain low bits")
}
off := highbits(offset)
h... | go | func (b *Bitmap) OffsetRange(offset, start, end uint64) *Bitmap {
if lowbits(offset) != 0 {
panic("offset must not contain low bits")
}
if lowbits(start) != 0 {
panic("range start must not contain low bits")
}
if lowbits(end) != 0 {
panic("range end must not contain low bits")
}
off := highbits(offset)
h... | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"OffsetRange",
"(",
"offset",
",",
"start",
",",
"end",
"uint64",
")",
"*",
"Bitmap",
"{",
"if",
"lowbits",
"(",
"offset",
")",
"!=",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"lowbits",... | // OffsetRange returns a new bitmap with a containers offset by start. | [
"OffsetRange",
"returns",
"a",
"new",
"bitmap",
"with",
"a",
"containers",
"offset",
"by",
"start",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L446-L469 | train |
pilosa/pilosa | roaring/roaring.go | container | func (b *Bitmap) container(key uint64) *Container {
return b.Containers.Get(key)
} | go | func (b *Bitmap) container(key uint64) *Container {
return b.Containers.Get(key)
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"container",
"(",
"key",
"uint64",
")",
"*",
"Container",
"{",
"return",
"b",
".",
"Containers",
".",
"Get",
"(",
"key",
")",
"\n",
"}"
] | // container returns the container with the given key. | [
"container",
"returns",
"the",
"container",
"with",
"the",
"given",
"key",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L472-L474 | train |
pilosa/pilosa | roaring/roaring.go | IntersectionCount | func (b *Bitmap) IntersectionCount(other *Bitmap) uint64 {
var n uint64
iiter, _ := b.Containers.Iterator(0)
jiter, _ := other.Containers.Iterator(0)
i, j := iiter.Next(), jiter.Next()
ki, ci := iiter.Value()
kj, cj := jiter.Value()
for i && j {
if ki < kj {
i = iiter.Next()
ki, ci = iiter.Value()
} el... | go | func (b *Bitmap) IntersectionCount(other *Bitmap) uint64 {
var n uint64
iiter, _ := b.Containers.Iterator(0)
jiter, _ := other.Containers.Iterator(0)
i, j := iiter.Next(), jiter.Next()
ki, ci := iiter.Value()
kj, cj := jiter.Value()
for i && j {
if ki < kj {
i = iiter.Next()
ki, ci = iiter.Value()
} el... | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"IntersectionCount",
"(",
"other",
"*",
"Bitmap",
")",
"uint64",
"{",
"var",
"n",
"uint64",
"\n",
"iiter",
",",
"_",
":=",
"b",
".",
"Containers",
".",
"Iterator",
"(",
"0",
")",
"\n",
"jiter",
",",
"_",
":=",
... | // IntersectionCount returns the number of set bits that would result in an
// intersection between b and other. It is more efficient than actually
// intersecting the two and counting the result. | [
"IntersectionCount",
"returns",
"the",
"number",
"of",
"set",
"bits",
"that",
"would",
"result",
"in",
"an",
"intersection",
"between",
"b",
"and",
"other",
".",
"It",
"is",
"more",
"efficient",
"than",
"actually",
"intersecting",
"the",
"two",
"and",
"countin... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L479-L501 | train |
pilosa/pilosa | roaring/roaring.go | Intersect | func (b *Bitmap) Intersect(other *Bitmap) *Bitmap {
output := NewBitmap()
iiter, _ := b.Containers.Iterator(0)
jiter, _ := other.Containers.Iterator(0)
i, j := iiter.Next(), jiter.Next()
ki, ci := iiter.Value()
kj, cj := jiter.Value()
for i && j {
if ki < kj {
i = iiter.Next()
ki, ci = iiter.Value()
} ... | go | func (b *Bitmap) Intersect(other *Bitmap) *Bitmap {
output := NewBitmap()
iiter, _ := b.Containers.Iterator(0)
jiter, _ := other.Containers.Iterator(0)
i, j := iiter.Next(), jiter.Next()
ki, ci := iiter.Value()
kj, cj := jiter.Value()
for i && j {
if ki < kj {
i = iiter.Next()
ki, ci = iiter.Value()
} ... | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"Intersect",
"(",
"other",
"*",
"Bitmap",
")",
"*",
"Bitmap",
"{",
"output",
":=",
"NewBitmap",
"(",
")",
"\n",
"iiter",
",",
"_",
":=",
"b",
".",
"Containers",
".",
"Iterator",
"(",
"0",
")",
"\n",
"jiter",
... | // Intersect returns the intersection of b and other. | [
"Intersect",
"returns",
"the",
"intersection",
"of",
"b",
"and",
"other",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L504-L526 | train |
pilosa/pilosa | roaring/roaring.go | Union | func (b *Bitmap) Union(others ...*Bitmap) *Bitmap {
if len(others) == 1 {
output := NewBitmap()
b.unionIntoTargetSingle(output, others[0])
return output
}
output := b.Clone()
output.UnionInPlace(others...)
return output
} | go | func (b *Bitmap) Union(others ...*Bitmap) *Bitmap {
if len(others) == 1 {
output := NewBitmap()
b.unionIntoTargetSingle(output, others[0])
return output
}
output := b.Clone()
output.UnionInPlace(others...)
return output
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"Union",
"(",
"others",
"...",
"*",
"Bitmap",
")",
"*",
"Bitmap",
"{",
"if",
"len",
"(",
"others",
")",
"==",
"1",
"{",
"output",
":=",
"NewBitmap",
"(",
")",
"\n",
"b",
".",
"unionIntoTargetSingle",
"(",
"outp... | // Union returns the bitwise union of b and others as a new bitmap. | [
"Union",
"returns",
"the",
"bitwise",
"union",
"of",
"b",
"and",
"others",
"as",
"a",
"new",
"bitmap",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L529-L538 | train |
pilosa/pilosa | roaring/roaring.go | Difference | func (b *Bitmap) Difference(other *Bitmap) *Bitmap {
output := NewBitmap()
iiter, _ := b.Containers.Iterator(0)
jiter, _ := other.Containers.Iterator(0)
i, j := iiter.Next(), jiter.Next()
ki, ci := iiter.Value()
kj, cj := jiter.Value()
for i || j {
if i && (!j || ki < kj) {
output.Containers.Put(ki, ci.Clo... | go | func (b *Bitmap) Difference(other *Bitmap) *Bitmap {
output := NewBitmap()
iiter, _ := b.Containers.Iterator(0)
jiter, _ := other.Containers.Iterator(0)
i, j := iiter.Next(), jiter.Next()
ki, ci := iiter.Value()
kj, cj := jiter.Value()
for i || j {
if i && (!j || ki < kj) {
output.Containers.Put(ki, ci.Clo... | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"Difference",
"(",
"other",
"*",
"Bitmap",
")",
"*",
"Bitmap",
"{",
"output",
":=",
"NewBitmap",
"(",
")",
"\n\n",
"iiter",
",",
"_",
":=",
"b",
".",
"Containers",
".",
"Iterator",
"(",
"0",
")",
"\n",
"jiter",... | // Difference returns the difference of b and other. | [
"Difference",
"returns",
"the",
"difference",
"of",
"b",
"and",
"other",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L794-L818 | train |
pilosa/pilosa | roaring/roaring.go | Shift | func (b *Bitmap) Shift(n int) (*Bitmap, error) {
if n != 1 {
return nil, errors.New("cannot shift by a value other than 1")
}
output := NewBitmap()
iiter, _ := b.Containers.Iterator(0)
lastCarry := false
lastKey := uint64(0)
for iiter.Next() {
ki, ci := iiter.Value()
o, carry := shift(ci)
if lastCarry {
... | go | func (b *Bitmap) Shift(n int) (*Bitmap, error) {
if n != 1 {
return nil, errors.New("cannot shift by a value other than 1")
}
output := NewBitmap()
iiter, _ := b.Containers.Iterator(0)
lastCarry := false
lastKey := uint64(0)
for iiter.Next() {
ki, ci := iiter.Value()
o, carry := shift(ci)
if lastCarry {
... | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"Shift",
"(",
"n",
"int",
")",
"(",
"*",
"Bitmap",
",",
"error",
")",
"{",
"if",
"n",
"!=",
"1",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"output",
":=",
"... | // Shift shifts the contents of b by 1. | [
"Shift",
"shifts",
"the",
"contents",
"of",
"b",
"by",
"1",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L849-L877 | train |
pilosa/pilosa | roaring/roaring.go | removeEmptyContainers | func (b *Bitmap) removeEmptyContainers() {
citer, _ := b.Containers.Iterator(0)
for citer.Next() {
k, c := citer.Value()
if c.n == 0 {
b.Containers.Remove(k)
}
}
} | go | func (b *Bitmap) removeEmptyContainers() {
citer, _ := b.Containers.Iterator(0)
for citer.Next() {
k, c := citer.Value()
if c.n == 0 {
b.Containers.Remove(k)
}
}
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"removeEmptyContainers",
"(",
")",
"{",
"citer",
",",
"_",
":=",
"b",
".",
"Containers",
".",
"Iterator",
"(",
"0",
")",
"\n",
"for",
"citer",
".",
"Next",
"(",
")",
"{",
"k",
",",
"c",
":=",
"citer",
".",
... | // removeEmptyContainers deletes all containers that have a count of zero. | [
"removeEmptyContainers",
"deletes",
"all",
"containers",
"that",
"have",
"a",
"count",
"of",
"zero",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L880-L888 | train |
pilosa/pilosa | roaring/roaring.go | Optimize | func (b *Bitmap) Optimize() {
citer, _ := b.Containers.Iterator(0)
for citer.Next() {
_, c := citer.Value()
c.optimize()
}
} | go | func (b *Bitmap) Optimize() {
citer, _ := b.Containers.Iterator(0)
for citer.Next() {
_, c := citer.Value()
c.optimize()
}
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"Optimize",
"(",
")",
"{",
"citer",
",",
"_",
":=",
"b",
".",
"Containers",
".",
"Iterator",
"(",
"0",
")",
"\n",
"for",
"citer",
".",
"Next",
"(",
")",
"{",
"_",
",",
"c",
":=",
"citer",
".",
"Value",
"(... | // Optimize converts array and bitmap containers to run containers as necessary. | [
"Optimize",
"converts",
"array",
"and",
"bitmap",
"containers",
"to",
"run",
"containers",
"as",
"necessary",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L902-L908 | train |
pilosa/pilosa | roaring/roaring.go | WriteTo | func (b *Bitmap) WriteTo(w io.Writer) (n int64, err error) {
b.Optimize()
return b.writeToUnoptimized(w)
} | go | func (b *Bitmap) WriteTo(w io.Writer) (n int64, err error) {
b.Optimize()
return b.writeToUnoptimized(w)
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"WriteTo",
"(",
"w",
"io",
".",
"Writer",
")",
"(",
"n",
"int64",
",",
"err",
"error",
")",
"{",
"b",
".",
"Optimize",
"(",
")",
"\n",
"return",
"b",
".",
"writeToUnoptimized",
"(",
"w",
")",
"\n",
"}"
] | // WriteTo writes b to w. | [
"WriteTo",
"writes",
"b",
"to",
"w",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L946-L949 | train |
pilosa/pilosa | roaring/roaring.go | writeOp | func (b *Bitmap) writeOp(op *op) error {
if b.OpWriter == nil {
return nil
}
if _, err := op.WriteTo(b.OpWriter); err != nil {
return err
}
b.opN += op.count()
return nil
} | go | func (b *Bitmap) writeOp(op *op) error {
if b.OpWriter == nil {
return nil
}
if _, err := op.WriteTo(b.OpWriter); err != nil {
return err
}
b.opN += op.count()
return nil
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"writeOp",
"(",
"op",
"*",
"op",
")",
"error",
"{",
"if",
"b",
".",
"OpWriter",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"_",
",",
"err",
":=",
"op",
".",
"WriteTo",
"(",
"b",
".",
"OpW... | // writeOp writes op to the OpWriter, if available. | [
"writeOp",
"writes",
"op",
"to",
"the",
"OpWriter",
"if",
"available",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1113-L1124 | train |
pilosa/pilosa | roaring/roaring.go | Iterator | func (b *Bitmap) Iterator() *Iterator {
itr := &Iterator{bitmap: b}
itr.Seek(0)
return itr
} | go | func (b *Bitmap) Iterator() *Iterator {
itr := &Iterator{bitmap: b}
itr.Seek(0)
return itr
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"Iterator",
"(",
")",
"*",
"Iterator",
"{",
"itr",
":=",
"&",
"Iterator",
"{",
"bitmap",
":",
"b",
"}",
"\n",
"itr",
".",
"Seek",
"(",
"0",
")",
"\n",
"return",
"itr",
"\n",
"}"
] | // Iterator returns a new iterator for the bitmap. | [
"Iterator",
"returns",
"a",
"new",
"iterator",
"for",
"the",
"bitmap",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1127-L1131 | train |
pilosa/pilosa | roaring/roaring.go | Info | func (b *Bitmap) Info() bitmapInfo {
info := bitmapInfo{
OpN: b.opN,
Containers: make([]containerInfo, 0, b.Containers.Size()),
}
citer, _ := b.Containers.Iterator(0)
for citer.Next() {
k, c := citer.Value()
ci := c.info()
ci.Key = k
info.Containers = append(info.Containers, ci)
}
return info
... | go | func (b *Bitmap) Info() bitmapInfo {
info := bitmapInfo{
OpN: b.opN,
Containers: make([]containerInfo, 0, b.Containers.Size()),
}
citer, _ := b.Containers.Iterator(0)
for citer.Next() {
k, c := citer.Value()
ci := c.info()
ci.Key = k
info.Containers = append(info.Containers, ci)
}
return info
... | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"Info",
"(",
")",
"bitmapInfo",
"{",
"info",
":=",
"bitmapInfo",
"{",
"OpN",
":",
"b",
".",
"opN",
",",
"Containers",
":",
"make",
"(",
"[",
"]",
"containerInfo",
",",
"0",
",",
"b",
".",
"Containers",
".",
"... | // Info returns stats for the bitmap. | [
"Info",
"returns",
"stats",
"for",
"the",
"bitmap",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1134-L1148 | train |
pilosa/pilosa | roaring/roaring.go | Check | func (b *Bitmap) Check() error {
var a ErrorList
// Check each container.
citer, _ := b.Containers.Iterator(0)
for citer.Next() {
k, c := citer.Value()
if err := c.check(); err != nil {
a.AppendWithPrefix(err, fmt.Sprintf("%d/", k))
}
}
if len(a) == 0 {
return nil
}
return a
} | go | func (b *Bitmap) Check() error {
var a ErrorList
// Check each container.
citer, _ := b.Containers.Iterator(0)
for citer.Next() {
k, c := citer.Value()
if err := c.check(); err != nil {
a.AppendWithPrefix(err, fmt.Sprintf("%d/", k))
}
}
if len(a) == 0 {
return nil
}
return a
} | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"Check",
"(",
")",
"error",
"{",
"var",
"a",
"ErrorList",
"\n\n",
"// Check each container.",
"citer",
",",
"_",
":=",
"b",
".",
"Containers",
".",
"Iterator",
"(",
"0",
")",
"\n",
"for",
"citer",
".",
"Next",
"(... | // Check performs a consistency check on the bitmap. Returns nil if consistent. | [
"Check",
"performs",
"a",
"consistency",
"check",
"on",
"the",
"bitmap",
".",
"Returns",
"nil",
"if",
"consistent",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1151-L1167 | train |
pilosa/pilosa | roaring/roaring.go | Seek | func (itr *Iterator) Seek(seek uint64) {
// k should always be -1 unless we're seeking into a run container. Then the
// "if c.isRun" section will take care of it.
itr.k = -1
// Move to the correct container.
itr.citer, _ = itr.bitmap.Containers.Iterator(highbits(seek))
if !itr.citer.Next() {
itr.c = nil
ret... | go | func (itr *Iterator) Seek(seek uint64) {
// k should always be -1 unless we're seeking into a run container. Then the
// "if c.isRun" section will take care of it.
itr.k = -1
// Move to the correct container.
itr.citer, _ = itr.bitmap.Containers.Iterator(highbits(seek))
if !itr.citer.Next() {
itr.c = nil
ret... | [
"func",
"(",
"itr",
"*",
"Iterator",
")",
"Seek",
"(",
"seek",
"uint64",
")",
"{",
"// k should always be -1 unless we're seeking into a run container. Then the",
"// \"if c.isRun\" section will take care of it.",
"itr",
".",
"k",
"=",
"-",
"1",
"\n\n",
"// Move to the corr... | // Seek moves to the first value equal to or greater than `seek`. | [
"Seek",
"moves",
"to",
"the",
"first",
"value",
"equal",
"to",
"or",
"greater",
"than",
"seek",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1213-L1269 | train |
pilosa/pilosa | roaring/roaring.go | peek | func (itr *Iterator) peek() uint64 {
if itr.c == nil {
return 0
}
if itr.c.isArray() {
return itr.key<<16 | uint64(itr.c.array()[itr.j])
}
if itr.c.isRun() {
return itr.key<<16 | uint64(itr.c.runs()[itr.j].start+uint16(itr.k))
}
return itr.key<<16 | uint64(itr.j)
} | go | func (itr *Iterator) peek() uint64 {
if itr.c == nil {
return 0
}
if itr.c.isArray() {
return itr.key<<16 | uint64(itr.c.array()[itr.j])
}
if itr.c.isRun() {
return itr.key<<16 | uint64(itr.c.runs()[itr.j].start+uint16(itr.k))
}
return itr.key<<16 | uint64(itr.j)
} | [
"func",
"(",
"itr",
"*",
"Iterator",
")",
"peek",
"(",
")",
"uint64",
"{",
"if",
"itr",
".",
"c",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"if",
"itr",
".",
"c",
".",
"isArray",
"(",
")",
"{",
"return",
"itr",
".",
"key",
"<<",
"16",... | // peek returns the current value. | [
"peek",
"returns",
"the",
"current",
"value",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1380-L1391 | train |
pilosa/pilosa | roaring/roaring.go | countRange | func (c *Container) countRange(start, end int32) (n int32) {
if c.isArray() {
return c.arrayCountRange(start, end)
} else if c.isRun() {
return c.runCountRange(start, end)
}
return c.bitmapCountRange(start, end)
} | go | func (c *Container) countRange(start, end int32) (n int32) {
if c.isArray() {
return c.arrayCountRange(start, end)
} else if c.isRun() {
return c.runCountRange(start, end)
}
return c.bitmapCountRange(start, end)
} | [
"func",
"(",
"c",
"*",
"Container",
")",
"countRange",
"(",
"start",
",",
"end",
"int32",
")",
"(",
"n",
"int32",
")",
"{",
"if",
"c",
".",
"isArray",
"(",
")",
"{",
"return",
"c",
".",
"arrayCountRange",
"(",
"start",
",",
"end",
")",
"\n",
"}",... | // countRange counts the number of bits set between [start, end). | [
"countRange",
"counts",
"the",
"number",
"of",
"bits",
"set",
"between",
"[",
"start",
"end",
")",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1415-L1422 | train |
pilosa/pilosa | roaring/roaring.go | add | func (c *Container) add(v uint16) (added bool) {
if c.isArray() {
added = c.arrayAdd(v)
} else if c.isRun() {
added = c.runAdd(v)
} else {
added = c.bitmapAdd(v)
}
if added {
c.n++
}
return added
} | go | func (c *Container) add(v uint16) (added bool) {
if c.isArray() {
added = c.arrayAdd(v)
} else if c.isRun() {
added = c.runAdd(v)
} else {
added = c.bitmapAdd(v)
}
if added {
c.n++
}
return added
} | [
"func",
"(",
"c",
"*",
"Container",
")",
"add",
"(",
"v",
"uint16",
")",
"(",
"added",
"bool",
")",
"{",
"if",
"c",
".",
"isArray",
"(",
")",
"{",
"added",
"=",
"c",
".",
"arrayAdd",
"(",
"v",
")",
"\n",
"}",
"else",
"if",
"c",
".",
"isRun",
... | // add adds a value to the container. | [
"add",
"adds",
"a",
"value",
"to",
"the",
"container",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1500-L1513 | train |
pilosa/pilosa | roaring/roaring.go | Contains | func (c *Container) Contains(v uint16) bool {
if c.isArray() {
return c.arrayContains(v)
} else if c.isRun() {
return c.runContains(v)
} else {
return c.bitmapContains(v)
}
} | go | func (c *Container) Contains(v uint16) bool {
if c.isArray() {
return c.arrayContains(v)
} else if c.isRun() {
return c.runContains(v)
} else {
return c.bitmapContains(v)
}
} | [
"func",
"(",
"c",
"*",
"Container",
")",
"Contains",
"(",
"v",
"uint16",
")",
"bool",
"{",
"if",
"c",
".",
"isArray",
"(",
")",
"{",
"return",
"c",
".",
"arrayContains",
"(",
"v",
")",
"\n",
"}",
"else",
"if",
"c",
".",
"isRun",
"(",
")",
"{",
... | // Contains returns true if v is in the container. | [
"Contains",
"returns",
"true",
"if",
"v",
"is",
"in",
"the",
"container",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1612-L1620 | train |
pilosa/pilosa | roaring/roaring.go | optimize | func (c *Container) optimize() {
if c.n == 0 {
statsHit("optimize/empty")
return
}
runs := c.countRuns()
var newType byte
if runs <= runMaxSize && runs <= c.n/2 {
newType = containerRun
} else if c.n < ArrayMaxSize {
newType = containerArray
} else {
newType = containerBitmap
}
// Then convert acco... | go | func (c *Container) optimize() {
if c.n == 0 {
statsHit("optimize/empty")
return
}
runs := c.countRuns()
var newType byte
if runs <= runMaxSize && runs <= c.n/2 {
newType = containerRun
} else if c.n < ArrayMaxSize {
newType = containerArray
} else {
newType = containerBitmap
}
// Then convert acco... | [
"func",
"(",
"c",
"*",
"Container",
")",
"optimize",
"(",
")",
"{",
"if",
"c",
".",
"n",
"==",
"0",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"runs",
":=",
"c",
".",
"countRuns",
"(",
")",
"\n\n",
"var",
"newType",... | // optimize converts the container to the type which will take up the least
// amount of space. | [
"optimize",
"converts",
"the",
"container",
"to",
"the",
"type",
"which",
"will",
"take",
"up",
"the",
"least",
"amount",
"of",
"space",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1666-L1714 | train |
pilosa/pilosa | roaring/roaring.go | binSearchRuns | func binSearchRuns(v uint16, a []interval16) (int32, bool) {
i := int32(sort.Search(len(a),
func(i int) bool { return a[i].last >= v }))
if i < int32(len(a)) {
return i, (v >= a[i].start) && (v <= a[i].last)
}
return i, false
} | go | func binSearchRuns(v uint16, a []interval16) (int32, bool) {
i := int32(sort.Search(len(a),
func(i int) bool { return a[i].last >= v }))
if i < int32(len(a)) {
return i, (v >= a[i].start) && (v <= a[i].last)
}
return i, false
} | [
"func",
"binSearchRuns",
"(",
"v",
"uint16",
",",
"a",
"[",
"]",
"interval16",
")",
"(",
"int32",
",",
"bool",
")",
"{",
"i",
":=",
"int32",
"(",
"sort",
".",
"Search",
"(",
"len",
"(",
"a",
")",
",",
"func",
"(",
"i",
"int",
")",
"bool",
"{",
... | // binSearchRuns returns the index of the run containing v, and true, when v is contained;
// or the index of the next run starting after v, and false, when v is not contained. | [
"binSearchRuns",
"returns",
"the",
"index",
"of",
"the",
"run",
"containing",
"v",
"and",
"true",
"when",
"v",
"is",
"contained",
";",
"or",
"the",
"index",
"of",
"the",
"next",
"run",
"starting",
"after",
"v",
"and",
"false",
"when",
"v",
"is",
"not",
... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1767-L1775 | train |
pilosa/pilosa | roaring/roaring.go | runContains | func (c *Container) runContains(v uint16) bool {
_, found := binSearchRuns(v, c.runs())
return found
} | go | func (c *Container) runContains(v uint16) bool {
_, found := binSearchRuns(v, c.runs())
return found
} | [
"func",
"(",
"c",
"*",
"Container",
")",
"runContains",
"(",
"v",
"uint16",
")",
"bool",
"{",
"_",
",",
"found",
":=",
"binSearchRuns",
"(",
"v",
",",
"c",
".",
"runs",
"(",
")",
")",
"\n",
"return",
"found",
"\n",
"}"
] | // runContains determines if v is in the container assuming c is a run
// container. | [
"runContains",
"determines",
"if",
"v",
"is",
"in",
"the",
"container",
"assuming",
"c",
"is",
"a",
"run",
"container",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1779-L1782 | train |
pilosa/pilosa | roaring/roaring.go | remove | func (c *Container) remove(v uint16) (removed bool) {
if c.isArray() {
removed = c.arrayRemove(v)
} else if c.isRun() {
removed = c.runRemove(v)
} else {
removed = c.bitmapRemove(v)
}
return removed
} | go | func (c *Container) remove(v uint16) (removed bool) {
if c.isArray() {
removed = c.arrayRemove(v)
} else if c.isRun() {
removed = c.runRemove(v)
} else {
removed = c.bitmapRemove(v)
}
return removed
} | [
"func",
"(",
"c",
"*",
"Container",
")",
"remove",
"(",
"v",
"uint16",
")",
"(",
"removed",
"bool",
")",
"{",
"if",
"c",
".",
"isArray",
"(",
")",
"{",
"removed",
"=",
"c",
".",
"arrayRemove",
"(",
"v",
")",
"\n",
"}",
"else",
"if",
"c",
".",
... | // remove removes a value from the container. | [
"remove",
"removes",
"a",
"value",
"from",
"the",
"container",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1785-L1794 | train |
pilosa/pilosa | roaring/roaring.go | runRemove | func (c *Container) runRemove(v uint16) bool {
runs := c.runs()
i, contains := binSearchRuns(v, runs)
if !contains {
return false
}
c.unmapRun()
runs = c.runs()
if v == runs[i].last && v == runs[i].start {
runs = append(runs[:i], runs[i+1:]...)
} else if v == runs[i].last {
runs[i].last--
} else if v == ... | go | func (c *Container) runRemove(v uint16) bool {
runs := c.runs()
i, contains := binSearchRuns(v, runs)
if !contains {
return false
}
c.unmapRun()
runs = c.runs()
if v == runs[i].last && v == runs[i].start {
runs = append(runs[:i], runs[i+1:]...)
} else if v == runs[i].last {
runs[i].last--
} else if v == ... | [
"func",
"(",
"c",
"*",
"Container",
")",
"runRemove",
"(",
"v",
"uint16",
")",
"bool",
"{",
"runs",
":=",
"c",
".",
"runs",
"(",
")",
"\n",
"i",
",",
"contains",
":=",
"binSearchRuns",
"(",
"v",
",",
"runs",
")",
"\n",
"if",
"!",
"contains",
"{",... | // runRemove removes v from a run container, and returns true if v was removed. | [
"runRemove",
"removes",
"v",
"from",
"a",
"run",
"container",
"and",
"returns",
"true",
"if",
"v",
"was",
"removed",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1830-L1855 | train |
pilosa/pilosa | roaring/roaring.go | max | func (c *Container) max() uint16 {
if c.isArray() {
return c.arrayMax()
} else if c.isRun() {
return c.runMax()
} else {
return c.bitmapMax()
}
} | go | func (c *Container) max() uint16 {
if c.isArray() {
return c.arrayMax()
} else if c.isRun() {
return c.runMax()
} else {
return c.bitmapMax()
}
} | [
"func",
"(",
"c",
"*",
"Container",
")",
"max",
"(",
")",
"uint16",
"{",
"if",
"c",
".",
"isArray",
"(",
")",
"{",
"return",
"c",
".",
"arrayMax",
"(",
")",
"\n",
"}",
"else",
"if",
"c",
".",
"isRun",
"(",
")",
"{",
"return",
"c",
".",
"runMa... | // max returns the maximum value in the container. | [
"max",
"returns",
"the",
"maximum",
"value",
"in",
"the",
"container",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1858-L1866 | train |
pilosa/pilosa | roaring/roaring.go | bitmapToArray | func (c *Container) bitmapToArray() {
statsHit("bitmapToArray")
bitmap := c.bitmap()
c.setBitmap(nil)
c.typ = containerArray
c.mapped = false
// return early if empty
if c.n == 0 {
c.setArray(nil)
return
}
n := int32(0)
array := make([]uint16, c.n)
for i, word := range bitmap {
for word != 0 {
t :... | go | func (c *Container) bitmapToArray() {
statsHit("bitmapToArray")
bitmap := c.bitmap()
c.setBitmap(nil)
c.typ = containerArray
c.mapped = false
// return early if empty
if c.n == 0 {
c.setArray(nil)
return
}
n := int32(0)
array := make([]uint16, c.n)
for i, word := range bitmap {
for word != 0 {
t :... | [
"func",
"(",
"c",
"*",
"Container",
")",
"bitmapToArray",
"(",
")",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"bitmap",
":=",
"c",
".",
"bitmap",
"(",
")",
"\n",
"c",
".",
"setBitmap",
"(",
"nil",
")",
"\n",
"c",
".",
"typ",
"=",
"containerArr... | // bitmapToArray converts from bitmap format to array format. | [
"bitmapToArray",
"converts",
"from",
"bitmap",
"format",
"to",
"array",
"format",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1900-L1934 | train |
pilosa/pilosa | roaring/roaring.go | arrayToBitmap | func (c *Container) arrayToBitmap() {
statsHit("arrayToBitmap")
array := c.array()
c.typ = containerBitmap
bitmap := make([]uint64, bitmapN)
c.setBitmap(bitmap)
c.mapped = false
// return early if empty
if c.n == 0 {
return
}
for _, v := range array {
bitmap[int(v)/64] |= (uint64(1) << uint(v%64))
}
} | go | func (c *Container) arrayToBitmap() {
statsHit("arrayToBitmap")
array := c.array()
c.typ = containerBitmap
bitmap := make([]uint64, bitmapN)
c.setBitmap(bitmap)
c.mapped = false
// return early if empty
if c.n == 0 {
return
}
for _, v := range array {
bitmap[int(v)/64] |= (uint64(1) << uint(v%64))
}
} | [
"func",
"(",
"c",
"*",
"Container",
")",
"arrayToBitmap",
"(",
")",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"array",
":=",
"c",
".",
"array",
"(",
")",
"\n",
"c",
".",
"typ",
"=",
"containerBitmap",
"\n",
"bitmap",
":=",
"make",
"(",
"[",
"]... | // arrayToBitmap converts from array format to bitmap format. | [
"arrayToBitmap",
"converts",
"from",
"array",
"format",
"to",
"bitmap",
"format",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1937-L1953 | train |
pilosa/pilosa | roaring/roaring.go | runToBitmap | func (c *Container) runToBitmap() {
statsHit("runToBitmap")
runs := c.runs()
bitmap := make([]uint64, bitmapN)
c.typ = containerBitmap
c.setBitmap(bitmap)
c.mapped = false
// return early if empty
if c.n == 0 {
return
}
for _, r := range runs {
// TODO this can be ~64x faster for long runs by setting m... | go | func (c *Container) runToBitmap() {
statsHit("runToBitmap")
runs := c.runs()
bitmap := make([]uint64, bitmapN)
c.typ = containerBitmap
c.setBitmap(bitmap)
c.mapped = false
// return early if empty
if c.n == 0 {
return
}
for _, r := range runs {
// TODO this can be ~64x faster for long runs by setting m... | [
"func",
"(",
"c",
"*",
"Container",
")",
"runToBitmap",
"(",
")",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"runs",
":=",
"c",
".",
"runs",
"(",
")",
"\n",
"bitmap",
":=",
"make",
"(",
"[",
"]",
"uint64",
",",
"bitmapN",
")",
"\n",
"c",
".",... | // runToBitmap converts from RLE format to bitmap format. | [
"runToBitmap",
"converts",
"from",
"RLE",
"format",
"to",
"bitmap",
"format",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1956-L1977 | train |
pilosa/pilosa | roaring/roaring.go | bitmapToRun | func (c *Container) bitmapToRun(numRuns int32) {
statsHit("bitmapToRun")
bitmap := c.bitmap()
c.mapped = false
c.typ = containerRun
// return early if empty
if c.n == 0 {
c.setRuns(nil)
return
}
if numRuns == 0 {
numRuns = bitmapCountRuns(bitmap)
}
runs := make([]interval16, 0, numRuns)
current := bi... | go | func (c *Container) bitmapToRun(numRuns int32) {
statsHit("bitmapToRun")
bitmap := c.bitmap()
c.mapped = false
c.typ = containerRun
// return early if empty
if c.n == 0 {
c.setRuns(nil)
return
}
if numRuns == 0 {
numRuns = bitmapCountRuns(bitmap)
}
runs := make([]interval16, 0, numRuns)
current := bi... | [
"func",
"(",
"c",
"*",
"Container",
")",
"bitmapToRun",
"(",
"numRuns",
"int32",
")",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"bitmap",
":=",
"c",
".",
"bitmap",
"(",
")",
"\n",
"c",
".",
"mapped",
"=",
"false",
"\n",
"c",
".",
"typ",
"=",
... | // bitmapToRun converts from bitmap format to RLE format. | [
"bitmapToRun",
"converts",
"from",
"bitmap",
"format",
"to",
"RLE",
"format",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L1980-L2034 | train |
pilosa/pilosa | roaring/roaring.go | arrayToRun | func (c *Container) arrayToRun(numRuns int32) {
statsHit("arrayToRun")
array := c.array()
c.typ = containerRun
c.mapped = false
// return early if empty
if c.n == 0 {
c.setRuns(nil)
return
}
if numRuns == 0 {
numRuns = arrayCountRuns(array)
}
runs := make([]interval16, 0, numRuns)
start := array[0]
f... | go | func (c *Container) arrayToRun(numRuns int32) {
statsHit("arrayToRun")
array := c.array()
c.typ = containerRun
c.mapped = false
// return early if empty
if c.n == 0 {
c.setRuns(nil)
return
}
if numRuns == 0 {
numRuns = arrayCountRuns(array)
}
runs := make([]interval16, 0, numRuns)
start := array[0]
f... | [
"func",
"(",
"c",
"*",
"Container",
")",
"arrayToRun",
"(",
"numRuns",
"int32",
")",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"array",
":=",
"c",
".",
"array",
"(",
")",
"\n",
"c",
".",
"typ",
"=",
"containerRun",
"\n",
"c",
".",
"mapped",
"=... | // arrayToRun converts from array format to RLE format. | [
"arrayToRun",
"converts",
"from",
"array",
"format",
"to",
"RLE",
"format",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L2037-L2063 | train |
pilosa/pilosa | roaring/roaring.go | runToArray | func (c *Container) runToArray() {
statsHit("runToArray")
runs := c.runs()
c.typ = containerArray
c.mapped = false
// return early if empty
if c.n == 0 {
c.setArray(nil)
return
}
array := make([]uint16, c.n)
n := int32(0)
for _, r := range runs {
for v := int(r.start); v <= int(r.last); v++ {
array... | go | func (c *Container) runToArray() {
statsHit("runToArray")
runs := c.runs()
c.typ = containerArray
c.mapped = false
// return early if empty
if c.n == 0 {
c.setArray(nil)
return
}
array := make([]uint16, c.n)
n := int32(0)
for _, r := range runs {
for v := int(r.start); v <= int(r.last); v++ {
array... | [
"func",
"(",
"c",
"*",
"Container",
")",
"runToArray",
"(",
")",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"runs",
":=",
"c",
".",
"runs",
"(",
")",
"\n",
"c",
".",
"typ",
"=",
"containerArray",
"\n",
"c",
".",
"mapped",
"=",
"false",
"\n\n",
... | // runToArray converts from RLE format to array format. | [
"runToArray",
"converts",
"from",
"RLE",
"format",
"to",
"array",
"format",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L2066-L2092 | train |
pilosa/pilosa | roaring/roaring.go | WriteTo | func (c *Container) WriteTo(w io.Writer) (n int64, err error) {
if c.isArray() {
return c.arrayWriteTo(w)
} else if c.isRun() {
return c.runWriteTo(w)
} else {
return c.bitmapWriteTo(w)
}
} | go | func (c *Container) WriteTo(w io.Writer) (n int64, err error) {
if c.isArray() {
return c.arrayWriteTo(w)
} else if c.isRun() {
return c.runWriteTo(w)
} else {
return c.bitmapWriteTo(w)
}
} | [
"func",
"(",
"c",
"*",
"Container",
")",
"WriteTo",
"(",
"w",
"io",
".",
"Writer",
")",
"(",
"n",
"int64",
",",
"err",
"error",
")",
"{",
"if",
"c",
".",
"isArray",
"(",
")",
"{",
"return",
"c",
".",
"arrayWriteTo",
"(",
"w",
")",
"\n",
"}",
... | // WriteTo writes c to w. | [
"WriteTo",
"writes",
"c",
"to",
"w",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L2126-L2134 | train |
pilosa/pilosa | roaring/roaring.go | size | func (c *Container) size() int {
if c.isArray() {
return len(c.array()) * 2 // sizeof(uint16)
} else if c.isRun() {
return len(c.runs())*interval16Size + runCountHeaderSize
} else {
return len(c.bitmap()) * 8 // sizeof(uint64)
}
} | go | func (c *Container) size() int {
if c.isArray() {
return len(c.array()) * 2 // sizeof(uint16)
} else if c.isRun() {
return len(c.runs())*interval16Size + runCountHeaderSize
} else {
return len(c.bitmap()) * 8 // sizeof(uint64)
}
} | [
"func",
"(",
"c",
"*",
"Container",
")",
"size",
"(",
")",
"int",
"{",
"if",
"c",
".",
"isArray",
"(",
")",
"{",
"return",
"len",
"(",
"c",
".",
"array",
"(",
")",
")",
"*",
"2",
"// sizeof(uint16)",
"\n",
"}",
"else",
"if",
"c",
".",
"isRun",
... | // size returns the encoded size of the container, in bytes. | [
"size",
"returns",
"the",
"encoded",
"size",
"of",
"the",
"container",
"in",
"bytes",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L2179-L2187 | train |
pilosa/pilosa | roaring/roaring.go | info | func (c *Container) info() containerInfo {
info := containerInfo{N: c.n}
if c.isArray() {
info.Type = "array"
info.Alloc = len(c.array()) * 2 // sizeof(uint16)
} else if c.isRun() {
info.Type = "run"
info.Alloc = len(c.runs())*interval16Size + runCountHeaderSize
} else {
info.Type = "bitmap"
info.Alloc... | go | func (c *Container) info() containerInfo {
info := containerInfo{N: c.n}
if c.isArray() {
info.Type = "array"
info.Alloc = len(c.array()) * 2 // sizeof(uint16)
} else if c.isRun() {
info.Type = "run"
info.Alloc = len(c.runs())*interval16Size + runCountHeaderSize
} else {
info.Type = "bitmap"
info.Alloc... | [
"func",
"(",
"c",
"*",
"Container",
")",
"info",
"(",
")",
"containerInfo",
"{",
"info",
":=",
"containerInfo",
"{",
"N",
":",
"c",
".",
"n",
"}",
"\n\n",
"if",
"c",
".",
"isArray",
"(",
")",
"{",
"info",
".",
"Type",
"=",
"\"",
"\"",
"\n",
"in... | // info returns the current stats about the container. | [
"info",
"returns",
"the",
"current",
"stats",
"about",
"the",
"container",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L2190-L2215 | train |
pilosa/pilosa | roaring/roaring.go | check | func (c *Container) check() error {
var a ErrorList
if c.isArray() {
array := c.array()
if int32(len(array)) != c.n {
a.Append(fmt.Errorf("array count mismatch: count=%d, n=%d", len(array), c.n))
}
} else if c.isRun() {
n := c.runCountRange(0, maxContainerVal+1)
if n != c.n {
a.Append(fmt.Errorf("ru... | go | func (c *Container) check() error {
var a ErrorList
if c.isArray() {
array := c.array()
if int32(len(array)) != c.n {
a.Append(fmt.Errorf("array count mismatch: count=%d, n=%d", len(array), c.n))
}
} else if c.isRun() {
n := c.runCountRange(0, maxContainerVal+1)
if n != c.n {
a.Append(fmt.Errorf("ru... | [
"func",
"(",
"c",
"*",
"Container",
")",
"check",
"(",
")",
"error",
"{",
"var",
"a",
"ErrorList",
"\n\n",
"if",
"c",
".",
"isArray",
"(",
")",
"{",
"array",
":=",
"c",
".",
"array",
"(",
")",
"\n",
"if",
"int32",
"(",
"len",
"(",
"array",
")",... | // check performs a consistency check on the container. | [
"check",
"performs",
"a",
"consistency",
"check",
"on",
"the",
"container",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L2218-L2246 | train |
pilosa/pilosa | roaring/roaring.go | flip | func flip(a *Container) *Container { // nolint: deadcode
if a.isArray() {
return flipArray(a)
} else if a.isRun() {
return flipRun(a)
} else {
return flipBitmap(a)
}
} | go | func flip(a *Container) *Container { // nolint: deadcode
if a.isArray() {
return flipArray(a)
} else if a.isRun() {
return flipRun(a)
} else {
return flipBitmap(a)
}
} | [
"func",
"flip",
"(",
"a",
"*",
"Container",
")",
"*",
"Container",
"{",
"// nolint: deadcode",
"if",
"a",
".",
"isArray",
"(",
")",
"{",
"return",
"flipArray",
"(",
"a",
")",
"\n",
"}",
"else",
"if",
"a",
".",
"isRun",
"(",
")",
"{",
"return",
"fli... | // flip returns a new container containing the inverse of all
// bits in a. | [
"flip",
"returns",
"a",
"new",
"container",
"containing",
"the",
"inverse",
"of",
"all",
"bits",
"in",
"a",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L2282-L2290 | train |
pilosa/pilosa | roaring/roaring.go | intersectRunRun | func intersectRunRun(a, b *Container) *Container {
statsHit("intersect/RunRun")
output := NewContainerRun(nil)
ra, rb := a.runs(), b.runs()
na, nb := len(ra), len(rb)
for i, j := 0, 0; i < na && j < nb; {
va, vb := ra[i], rb[j]
if va.last < vb.start {
// |--va--| |--vb--|
i++
} else if vb.last < va.sta... | go | func intersectRunRun(a, b *Container) *Container {
statsHit("intersect/RunRun")
output := NewContainerRun(nil)
ra, rb := a.runs(), b.runs()
na, nb := len(ra), len(rb)
for i, j := 0, 0; i < na && j < nb; {
va, vb := ra[i], rb[j]
if va.last < vb.start {
// |--va--| |--vb--|
i++
} else if vb.last < va.sta... | [
"func",
"intersectRunRun",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"*",
"Container",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"output",
":=",
"NewContainerRun",
"(",
"nil",
")",
"\n",
"ra",
",",
"rb",
":=",
"a",
".",
"runs",
"(",
")",
",",
... | // intersectRunRun computes the intersect of two run containers. | [
"intersectRunRun",
"computes",
"the",
"intersect",
"of",
"two",
"run",
"containers",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L2524-L2562 | train |
pilosa/pilosa | roaring/roaring.go | intersectBitmapRun | func intersectBitmapRun(a, b *Container) *Container {
statsHit("intersect/BitmapRun")
var output *Container
runs := b.runs()
if b.n <= ArrayMaxSize || a.n <= ArrayMaxSize {
// output is array container
array := make([]uint16, 0, b.n)
for _, iv := range runs {
for i := iv.start; i <= iv.last; i++ {
if a... | go | func intersectBitmapRun(a, b *Container) *Container {
statsHit("intersect/BitmapRun")
var output *Container
runs := b.runs()
if b.n <= ArrayMaxSize || a.n <= ArrayMaxSize {
// output is array container
array := make([]uint16, 0, b.n)
for _, iv := range runs {
for i := iv.start; i <= iv.last; i++ {
if a... | [
"func",
"intersectBitmapRun",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"*",
"Container",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"var",
"output",
"*",
"Container",
"\n",
"runs",
":=",
"b",
".",
"runs",
"(",
")",
"\n",
"if",
"b",
".",
"n",
... | // intersectBitmapRun returns an array container if either container's
// cardinality is <= ArrayMaxSize. Otherwise it returns a bitmap container. | [
"intersectBitmapRun",
"returns",
"an",
"array",
"container",
"if",
"either",
"container",
"s",
"cardinality",
"is",
"<",
"=",
"ArrayMaxSize",
".",
"Otherwise",
"it",
"returns",
"a",
"bitmap",
"container",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L2566-L2626 | train |
pilosa/pilosa | roaring/roaring.go | unionArrayRun | func unionArrayRun(a, b *Container) *Container {
statsHit("union/ArrayRun")
if b.n == maxContainerVal+1 {
return b.Clone()
}
output := NewContainerRun(nil)
aa, rb := a.array(), b.runs()
na, nb := len(aa), len(rb)
var vb interval16
var va uint16
for i, j := 0, 0; i < na || j < nb; {
if i < na {
va = aa[i... | go | func unionArrayRun(a, b *Container) *Container {
statsHit("union/ArrayRun")
if b.n == maxContainerVal+1 {
return b.Clone()
}
output := NewContainerRun(nil)
aa, rb := a.array(), b.runs()
na, nb := len(aa), len(rb)
var vb interval16
var va uint16
for i, j := 0, 0; i < na || j < nb; {
if i < na {
va = aa[i... | [
"func",
"unionArrayRun",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"*",
"Container",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"if",
"b",
".",
"n",
"==",
"maxContainerVal",
"+",
"1",
"{",
"return",
"b",
".",
"Clone",
"(",
")",
"\n",
"}",
"\n"... | // unionArrayRun optimistically assumes that the result will be a run container,
// and converts to a bitmap or array container afterwards if necessary. | [
"unionArrayRun",
"optimistically",
"assumes",
"that",
"the",
"result",
"will",
"be",
"a",
"run",
"container",
"and",
"converts",
"to",
"a",
"bitmap",
"or",
"array",
"container",
"afterwards",
"if",
"necessary",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L2777-L2808 | train |
pilosa/pilosa | roaring/roaring.go | runAppendInterval | func (c *Container) runAppendInterval(v interval16) int32 {
runs := c.runs()
if len(runs) == 0 {
runs = append(runs, v)
c.setRuns(runs)
return int32(v.last-v.start) + 1
}
last := runs[len(runs)-1]
if last.last == maxContainerVal { //protect against overflow
return 0
}
if last.last+1 >= v.start && v.last... | go | func (c *Container) runAppendInterval(v interval16) int32 {
runs := c.runs()
if len(runs) == 0 {
runs = append(runs, v)
c.setRuns(runs)
return int32(v.last-v.start) + 1
}
last := runs[len(runs)-1]
if last.last == maxContainerVal { //protect against overflow
return 0
}
if last.last+1 >= v.start && v.last... | [
"func",
"(",
"c",
"*",
"Container",
")",
"runAppendInterval",
"(",
"v",
"interval16",
")",
"int32",
"{",
"runs",
":=",
"c",
".",
"runs",
"(",
")",
"\n",
"if",
"len",
"(",
"runs",
")",
"==",
"0",
"{",
"runs",
"=",
"append",
"(",
"runs",
",",
"v",
... | // runAppendInterval adds the given interval to the run container. It assumes
// that the interval comes at the end of the list of runs, and does not check
// that this is the case. It will not behave correctly if the start of the given
// interval is earlier than the start of the last interval in the list of runs.
// ... | [
"runAppendInterval",
"adds",
"the",
"given",
"interval",
"to",
"the",
"run",
"container",
".",
"It",
"assumes",
"that",
"the",
"interval",
"comes",
"at",
"the",
"end",
"of",
"the",
"list",
"of",
"runs",
"and",
"does",
"not",
"check",
"that",
"this",
"is",
... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L2816-L2838 | train |
pilosa/pilosa | roaring/roaring.go | unionBitmapRunInPlace | func unionBitmapRunInPlace(a, b *Container) {
a.unmapBitmap()
bitmap := a.bitmap()
statsHit("union/BitmapRun")
for _, run := range b.runs() {
bitmapSetRangeIgnoreN(bitmap, uint64(run.start), uint64(run.last)+1)
}
} | go | func unionBitmapRunInPlace(a, b *Container) {
a.unmapBitmap()
bitmap := a.bitmap()
statsHit("union/BitmapRun")
for _, run := range b.runs() {
bitmapSetRangeIgnoreN(bitmap, uint64(run.start), uint64(run.last)+1)
}
} | [
"func",
"unionBitmapRunInPlace",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"{",
"a",
".",
"unmapBitmap",
"(",
")",
"\n",
"bitmap",
":=",
"a",
".",
"bitmap",
"(",
")",
"\n",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"for",
"_",
",",
"run",
":=",
"r... | // unions the run b into the bitmap a, mutating a in place. The n value of
// a will need to be repaired after the fact. | [
"unions",
"the",
"run",
"b",
"into",
"the",
"bitmap",
"a",
"mutating",
"a",
"in",
"place",
".",
"The",
"n",
"value",
"of",
"a",
"will",
"need",
"to",
"be",
"repaired",
"after",
"the",
"fact",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L2891-L2898 | train |
pilosa/pilosa | roaring/roaring.go | bitmapSetRangeIgnoreN | func bitmapSetRangeIgnoreN(bitmap []uint64, i, j uint64) {
x := i >> 6
y := (j - 1) >> 6
var X uint64 = maxBitmap << (i % 64)
var Y uint64 = maxBitmap >> (63 - ((j - 1) % 64))
if x == y {
bitmap[x] |= (X & Y)
} else {
bitmap[x] |= X
for i := x + 1; i < y; i++ {
bitmap[i] = maxBitmap
}
bitmap[y] |= Y... | go | func bitmapSetRangeIgnoreN(bitmap []uint64, i, j uint64) {
x := i >> 6
y := (j - 1) >> 6
var X uint64 = maxBitmap << (i % 64)
var Y uint64 = maxBitmap >> (63 - ((j - 1) % 64))
if x == y {
bitmap[x] |= (X & Y)
} else {
bitmap[x] |= X
for i := x + 1; i < y; i++ {
bitmap[i] = maxBitmap
}
bitmap[y] |= Y... | [
"func",
"bitmapSetRangeIgnoreN",
"(",
"bitmap",
"[",
"]",
"uint64",
",",
"i",
",",
"j",
"uint64",
")",
"{",
"x",
":=",
"i",
">>",
"6",
"\n",
"y",
":=",
"(",
"j",
"-",
"1",
")",
">>",
"6",
"\n",
"var",
"X",
"uint64",
"=",
"maxBitmap",
"<<",
"(",... | // sets all bits in [i, j) without updating any corresponding n value. | [
"sets",
"all",
"bits",
"in",
"[",
"i",
"j",
")",
"without",
"updating",
"any",
"corresponding",
"n",
"value",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L2927-L2942 | train |
pilosa/pilosa | roaring/roaring.go | unionBitmapArrayInPlace | func unionBitmapArrayInPlace(a, b *Container) {
a.unmapBitmap()
bitmap := a.bitmap()
for _, v := range b.array() {
bitmap[v>>6] |= (uint64(1) << (v % 64))
}
} | go | func unionBitmapArrayInPlace(a, b *Container) {
a.unmapBitmap()
bitmap := a.bitmap()
for _, v := range b.array() {
bitmap[v>>6] |= (uint64(1) << (v % 64))
}
} | [
"func",
"unionBitmapArrayInPlace",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"{",
"a",
".",
"unmapBitmap",
"(",
")",
"\n",
"bitmap",
":=",
"a",
".",
"bitmap",
"(",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"b",
".",
"array",
"(",
")",
"{",... | // unions array b into bitmap a, mutating a in place. The n value
// of a will need to be repaired after the fact. | [
"unions",
"array",
"b",
"into",
"bitmap",
"a",
"mutating",
"a",
"in",
"place",
".",
"The",
"n",
"value",
"of",
"a",
"will",
"need",
"to",
"be",
"repaired",
"after",
"the",
"fact",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3046-L3052 | train |
pilosa/pilosa | roaring/roaring.go | unionBitmapBitmapInPlace | func unionBitmapBitmapInPlace(a, b *Container) {
a.unmapBitmap()
// local variables added to prevent BCE checks in loop
// see https://go101.org/article/bounds-check-elimination.html
var (
ab = a.bitmap()[:bitmapN]
bb = b.bitmap()[:bitmapN]
)
// Manually unroll loop to make it a little faster.
// TODO(rart... | go | func unionBitmapBitmapInPlace(a, b *Container) {
a.unmapBitmap()
// local variables added to prevent BCE checks in loop
// see https://go101.org/article/bounds-check-elimination.html
var (
ab = a.bitmap()[:bitmapN]
bb = b.bitmap()[:bitmapN]
)
// Manually unroll loop to make it a little faster.
// TODO(rart... | [
"func",
"unionBitmapBitmapInPlace",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"{",
"a",
".",
"unmapBitmap",
"(",
")",
"\n\n",
"// local variables added to prevent BCE checks in loop",
"// see https://go101.org/article/bounds-check-elimination.html",
"var",
"(",
"ab",
"=",
... | // unions bitmap b into bitmap a, mutating a in place. The n value of
// a will need to be repaired after the fact. | [
"unions",
"bitmap",
"b",
"into",
"bitmap",
"a",
"mutating",
"a",
"in",
"place",
".",
"The",
"n",
"value",
"of",
"a",
"will",
"need",
"to",
"be",
"repaired",
"after",
"the",
"fact",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3077-L3096 | train |
pilosa/pilosa | roaring/roaring.go | differenceArrayArray | func differenceArrayArray(a, b *Container) *Container {
statsHit("difference/ArrayArray")
output := NewContainerArray(nil)
aa, ab := a.array(), b.array()
na, nb := len(aa), len(ab)
for i, j := 0, 0; i < na; {
va := aa[i]
if j >= nb {
output.add(va)
i++
continue
}
vb := ab[j]
if va < vb {
out... | go | func differenceArrayArray(a, b *Container) *Container {
statsHit("difference/ArrayArray")
output := NewContainerArray(nil)
aa, ab := a.array(), b.array()
na, nb := len(aa), len(ab)
for i, j := 0, 0; i < na; {
va := aa[i]
if j >= nb {
output.add(va)
i++
continue
}
vb := ab[j]
if va < vb {
out... | [
"func",
"differenceArrayArray",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"*",
"Container",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"output",
":=",
"NewContainerArray",
"(",
"nil",
")",
"\n",
"aa",
",",
"ab",
":=",
"a",
".",
"array",
"(",
")",
... | // differenceArrayArray computes the difference bween two arrays. | [
"differenceArrayArray",
"computes",
"the",
"difference",
"bween",
"two",
"arrays",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3127-L3151 | train |
pilosa/pilosa | roaring/roaring.go | differenceArrayRun | func differenceArrayRun(a, b *Container) *Container {
statsHit("difference/ArrayRun")
// func (ac *arrayContainer) iandNotRun16(rc *runContainer16) container {
if a.n == 0 || b.n == 0 {
return a.Clone()
}
output := NewContainerArray(make([]uint16, 0, a.n))
// cardinality upper bound: card(A)
i := 0 // array... | go | func differenceArrayRun(a, b *Container) *Container {
statsHit("difference/ArrayRun")
// func (ac *arrayContainer) iandNotRun16(rc *runContainer16) container {
if a.n == 0 || b.n == 0 {
return a.Clone()
}
output := NewContainerArray(make([]uint16, 0, a.n))
// cardinality upper bound: card(A)
i := 0 // array... | [
"func",
"differenceArrayRun",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"*",
"Container",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"// func (ac *arrayContainer) iandNotRun16(rc *runContainer16) container {",
"if",
"a",
".",
"n",
"==",
"0",
"||",
"b",
".",
... | // differenceArrayRun computes the difference of an array from a run. | [
"differenceArrayRun",
"computes",
"the",
"difference",
"of",
"an",
"array",
"from",
"a",
"run",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3154-L3212 | train |
pilosa/pilosa | roaring/roaring.go | differenceBitmapRun | func differenceBitmapRun(a, b *Container) *Container {
statsHit("difference/BitmapRun")
if a.n == 0 || b.n == 0 {
return a.Clone()
}
output := a.Clone()
for _, run := range b.runs() {
output.bitmapZeroRange(uint64(run.start), uint64(run.last)+1)
}
return output
} | go | func differenceBitmapRun(a, b *Container) *Container {
statsHit("difference/BitmapRun")
if a.n == 0 || b.n == 0 {
return a.Clone()
}
output := a.Clone()
for _, run := range b.runs() {
output.bitmapZeroRange(uint64(run.start), uint64(run.last)+1)
}
return output
} | [
"func",
"differenceBitmapRun",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"*",
"Container",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"if",
"a",
".",
"n",
"==",
"0",
"||",
"b",
".",
"n",
"==",
"0",
"{",
"return",
"a",
".",
"Clone",
"(",
")",... | // differenceBitmapRun computes the difference of an bitmap from a run. | [
"differenceBitmapRun",
"computes",
"the",
"difference",
"of",
"an",
"bitmap",
"from",
"a",
"run",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3215-L3226 | train |
pilosa/pilosa | roaring/roaring.go | differenceRunArray | func differenceRunArray(a, b *Container) *Container {
statsHit("difference/RunArray")
if a.n == 0 || b.n == 0 {
return a.Clone()
}
ra, ab := a.runs(), b.array()
runs := make([]interval16, 0, len(ra))
bidx := 0
vb := ab[bidx]
RUNLOOP:
for _, run := range ra {
start := run.start
for vb < run.start {
bi... | go | func differenceRunArray(a, b *Container) *Container {
statsHit("difference/RunArray")
if a.n == 0 || b.n == 0 {
return a.Clone()
}
ra, ab := a.runs(), b.array()
runs := make([]interval16, 0, len(ra))
bidx := 0
vb := ab[bidx]
RUNLOOP:
for _, run := range ra {
start := run.start
for vb < run.start {
bi... | [
"func",
"differenceRunArray",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"*",
"Container",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"if",
"a",
".",
"n",
"==",
"0",
"||",
"b",
".",
"n",
"==",
"0",
"{",
"return",
"a",
".",
"Clone",
"(",
")",
... | // differenceRunArray subtracts the bits in an array container from a run
// container. | [
"differenceRunArray",
"subtracts",
"the",
"bits",
"in",
"an",
"array",
"container",
"from",
"a",
"run",
"container",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3230-L3283 | train |
pilosa/pilosa | roaring/roaring.go | differenceRunBitmap | func differenceRunBitmap(a, b *Container) *Container {
statsHit("difference/RunBitmap")
ra := a.runs()
// If a is full, difference is the flip of b.
if len(ra) > 0 && ra[0].start == 0 && ra[0].last == 65535 {
return flipBitmap(b)
}
output := NewContainerRun(nil)
runs := output.runs()
if len(ra) == 0 {
retur... | go | func differenceRunBitmap(a, b *Container) *Container {
statsHit("difference/RunBitmap")
ra := a.runs()
// If a is full, difference is the flip of b.
if len(ra) > 0 && ra[0].start == 0 && ra[0].last == 65535 {
return flipBitmap(b)
}
output := NewContainerRun(nil)
runs := output.runs()
if len(ra) == 0 {
retur... | [
"func",
"differenceRunBitmap",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"*",
"Container",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"ra",
":=",
"a",
".",
"runs",
"(",
")",
"\n",
"// If a is full, difference is the flip of b.",
"if",
"len",
"(",
"ra",
... | // differenceRunBitmap computes the difference of an run from a bitmap. | [
"differenceRunBitmap",
"computes",
"the",
"difference",
"of",
"an",
"run",
"from",
"a",
"bitmap",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3286-L3344 | train |
pilosa/pilosa | roaring/roaring.go | differenceRunRun | func differenceRunRun(a, b *Container) *Container {
statsHit("difference/RunRun")
if a.n == 0 || b.n == 0 {
return a.Clone()
}
ra, rb := a.runs(), b.runs()
apos := 0 // current a-run index
bpos := 0 // current b-run index
astart := ra[apos].start
alast := ra[apos].last
bstart := rb[bpos].start
blast := rb[... | go | func differenceRunRun(a, b *Container) *Container {
statsHit("difference/RunRun")
if a.n == 0 || b.n == 0 {
return a.Clone()
}
ra, rb := a.runs(), b.runs()
apos := 0 // current a-run index
bpos := 0 // current b-run index
astart := ra[apos].start
alast := ra[apos].last
bstart := rb[bpos].start
blast := rb[... | [
"func",
"differenceRunRun",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"*",
"Container",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"if",
"a",
".",
"n",
"==",
"0",
"||",
"b",
".",
"n",
"==",
"0",
"{",
"return",
"a",
".",
"Clone",
"(",
")",
... | // differenceRunRun computes the difference of two runs. | [
"differenceRunRun",
"computes",
"the",
"difference",
"of",
"two",
"runs",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3347-L3408 | train |
pilosa/pilosa | roaring/roaring.go | apply | func (op *op) apply(b *Bitmap) (changed bool) {
switch op.typ {
case opTypeAdd:
return b.DirectAdd(op.value)
case opTypeRemove:
return b.remove(op.value)
case opTypeAddBatch:
changed = b.DirectAddN(op.values...) > 0
case opTypeRemoveBatch:
changed = b.DirectRemoveN(op.values...) > 0
default:
panic(fmt.S... | go | func (op *op) apply(b *Bitmap) (changed bool) {
switch op.typ {
case opTypeAdd:
return b.DirectAdd(op.value)
case opTypeRemove:
return b.remove(op.value)
case opTypeAddBatch:
changed = b.DirectAddN(op.values...) > 0
case opTypeRemoveBatch:
changed = b.DirectRemoveN(op.values...) > 0
default:
panic(fmt.S... | [
"func",
"(",
"op",
"*",
"op",
")",
"apply",
"(",
"b",
"*",
"Bitmap",
")",
"(",
"changed",
"bool",
")",
"{",
"switch",
"op",
".",
"typ",
"{",
"case",
"opTypeAdd",
":",
"return",
"b",
".",
"DirectAdd",
"(",
"op",
".",
"value",
")",
"\n",
"case",
... | // apply executes the operation against a bitmap. | [
"apply",
"executes",
"the",
"operation",
"against",
"a",
"bitmap",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3666-L3680 | train |
pilosa/pilosa | roaring/roaring.go | WriteTo | func (op *op) WriteTo(w io.Writer) (n int64, err error) {
buf := make([]byte, op.size())
// Write type and value.
buf[0] = byte(op.typ)
if op.typ <= 1 {
binary.LittleEndian.PutUint64(buf[1:9], op.value)
} else {
binary.LittleEndian.PutUint64(buf[1:9], uint64(len(op.values)))
p := 13 // start of values (skip... | go | func (op *op) WriteTo(w io.Writer) (n int64, err error) {
buf := make([]byte, op.size())
// Write type and value.
buf[0] = byte(op.typ)
if op.typ <= 1 {
binary.LittleEndian.PutUint64(buf[1:9], op.value)
} else {
binary.LittleEndian.PutUint64(buf[1:9], uint64(len(op.values)))
p := 13 // start of values (skip... | [
"func",
"(",
"op",
"*",
"op",
")",
"WriteTo",
"(",
"w",
"io",
".",
"Writer",
")",
"(",
"n",
"int64",
",",
"err",
"error",
")",
"{",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"op",
".",
"size",
"(",
")",
")",
"\n\n",
"// Write type and va... | // WriteTo writes op to the w. | [
"WriteTo",
"writes",
"op",
"to",
"the",
"w",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3683-L3708 | train |
pilosa/pilosa | roaring/roaring.go | UnmarshalBinary | func (op *op) UnmarshalBinary(data []byte) error {
if len(data) < minOpSize {
return fmt.Errorf("op data out of bounds: len=%d", len(data))
}
statsHit("op/UnmarshalBinary")
op.typ = opType(data[0])
// op.value will actually contain the length of values for batch ops
op.value = binary.LittleEndian.Uint64(data[1... | go | func (op *op) UnmarshalBinary(data []byte) error {
if len(data) < minOpSize {
return fmt.Errorf("op data out of bounds: len=%d", len(data))
}
statsHit("op/UnmarshalBinary")
op.typ = opType(data[0])
// op.value will actually contain the length of values for batch ops
op.value = binary.LittleEndian.Uint64(data[1... | [
"func",
"(",
"op",
"*",
"op",
")",
"UnmarshalBinary",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"data",
")",
"<",
"minOpSize",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len",
"(",
"data",
")",
")",
"\... | // UnmarshalBinary decodes data into an op. | [
"UnmarshalBinary",
"decodes",
"data",
"into",
"an",
"op",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3713-L3744 | train |
pilosa/pilosa | roaring/roaring.go | size | func (op *op) size() int {
if op.typ == opTypeAdd || op.typ == opTypeRemove {
return 1 + 8 + 4
}
return 1 + 8 + 4 + len(op.values)*8
} | go | func (op *op) size() int {
if op.typ == opTypeAdd || op.typ == opTypeRemove {
return 1 + 8 + 4
}
return 1 + 8 + 4 + len(op.values)*8
} | [
"func",
"(",
"op",
"*",
"op",
")",
"size",
"(",
")",
"int",
"{",
"if",
"op",
".",
"typ",
"==",
"opTypeAdd",
"||",
"op",
".",
"typ",
"==",
"opTypeRemove",
"{",
"return",
"1",
"+",
"8",
"+",
"4",
"\n",
"}",
"\n",
"return",
"1",
"+",
"8",
"+",
... | // size returns the encoded size of the op, in bytes. | [
"size",
"returns",
"the",
"encoded",
"size",
"of",
"the",
"op",
"in",
"bytes",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3747-L3752 | train |
pilosa/pilosa | roaring/roaring.go | count | func (op *op) count() int {
switch op.typ {
case 0, 1:
return 1
case 2, 3:
return len(op.values)
default:
panic(fmt.Sprintf("unknown operation type: %d", op.typ))
}
} | go | func (op *op) count() int {
switch op.typ {
case 0, 1:
return 1
case 2, 3:
return len(op.values)
default:
panic(fmt.Sprintf("unknown operation type: %d", op.typ))
}
} | [
"func",
"(",
"op",
"*",
"op",
")",
"count",
"(",
")",
"int",
"{",
"switch",
"op",
".",
"typ",
"{",
"case",
"0",
",",
"1",
":",
"return",
"1",
"\n",
"case",
"2",
",",
"3",
":",
"return",
"len",
"(",
"op",
".",
"values",
")",
"\n",
"default",
... | // count returns the number of bits the operation mutates. | [
"count",
"returns",
"the",
"number",
"of",
"bits",
"the",
"operation",
"mutates",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3755-L3764 | train |
pilosa/pilosa | roaring/roaring.go | search32 | func search32(a []uint16, value uint16) int32 {
statsHit("search32")
// Optimize for elements and the last element.
n := int32(len(a))
if n == 0 {
return -1
} else if a[n-1] == value {
return n - 1
}
// Otherwise perform binary search for exact match.
lo, hi := int32(0), n-1
for lo+16 <= hi {
i := int32... | go | func search32(a []uint16, value uint16) int32 {
statsHit("search32")
// Optimize for elements and the last element.
n := int32(len(a))
if n == 0 {
return -1
} else if a[n-1] == value {
return n - 1
}
// Otherwise perform binary search for exact match.
lo, hi := int32(0), n-1
for lo+16 <= hi {
i := int32... | [
"func",
"search32",
"(",
"a",
"[",
"]",
"uint16",
",",
"value",
"uint16",
")",
"int32",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"// Optimize for elements and the last element.",
"n",
":=",
"int32",
"(",
"len",
"(",
"a",
")",
")",
"\n",
"if",
"n",
... | // search32 returns the index of value in a. If value is not found, it works the
// same way as search64. | [
"search32",
"returns",
"the",
"index",
"of",
"value",
"in",
"a",
".",
"If",
"value",
"is",
"not",
"found",
"it",
"works",
"the",
"same",
"way",
"as",
"search64",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3771-L3806 | train |
pilosa/pilosa | roaring/roaring.go | Append | func (a *ErrorList) Append(err error) {
switch err := err.(type) {
case ErrorList:
*a = append(*a, err...)
default:
*a = append(*a, err)
}
} | go | func (a *ErrorList) Append(err error) {
switch err := err.(type) {
case ErrorList:
*a = append(*a, err...)
default:
*a = append(*a, err)
}
} | [
"func",
"(",
"a",
"*",
"ErrorList",
")",
"Append",
"(",
"err",
"error",
")",
"{",
"switch",
"err",
":=",
"err",
".",
"(",
"type",
")",
"{",
"case",
"ErrorList",
":",
"*",
"a",
"=",
"append",
"(",
"*",
"a",
",",
"err",
"...",
")",
"\n",
"default... | // Append appends an error to the list. If err is an ErrorList then all errors are appended. | [
"Append",
"appends",
"an",
"error",
"to",
"the",
"list",
".",
"If",
"err",
"is",
"an",
"ErrorList",
"then",
"all",
"errors",
"are",
"appended",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3872-L3879 | train |
pilosa/pilosa | roaring/roaring.go | AppendWithPrefix | func (a *ErrorList) AppendWithPrefix(err error, prefix string) {
switch err := err.(type) {
case ErrorList:
for i := range err {
*a = append(*a, fmt.Errorf("%s%s", prefix, err[i]))
}
default:
*a = append(*a, fmt.Errorf("%s%s", prefix, err))
}
} | go | func (a *ErrorList) AppendWithPrefix(err error, prefix string) {
switch err := err.(type) {
case ErrorList:
for i := range err {
*a = append(*a, fmt.Errorf("%s%s", prefix, err[i]))
}
default:
*a = append(*a, fmt.Errorf("%s%s", prefix, err))
}
} | [
"func",
"(",
"a",
"*",
"ErrorList",
")",
"AppendWithPrefix",
"(",
"err",
"error",
",",
"prefix",
"string",
")",
"{",
"switch",
"err",
":=",
"err",
".",
"(",
"type",
")",
"{",
"case",
"ErrorList",
":",
"for",
"i",
":=",
"range",
"err",
"{",
"*",
"a"... | // AppendWithPrefix appends an error to the list and includes a prefix. | [
"AppendWithPrefix",
"appends",
"an",
"error",
"to",
"the",
"list",
"and",
"includes",
"a",
"prefix",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3882-L3891 | train |
pilosa/pilosa | roaring/roaring.go | xorArrayRun | func xorArrayRun(a, b *Container) *Container {
statsHit("xor/ArrayRun")
output := NewContainerRun(nil)
aa, rb := a.array(), b.runs()
na, nb := len(aa), len(rb)
var vb interval16
var va uint16
lastI, lastJ := -1, -1
for i, j := 0, 0; i < na || j < nb; {
if i < na && i != lastI {
va = aa[i]
}
if j < nb &... | go | func xorArrayRun(a, b *Container) *Container {
statsHit("xor/ArrayRun")
output := NewContainerRun(nil)
aa, rb := a.array(), b.runs()
na, nb := len(aa), len(rb)
var vb interval16
var va uint16
lastI, lastJ := -1, -1
for i, j := 0, 0; i < na || j < nb; {
if i < na && i != lastI {
va = aa[i]
}
if j < nb &... | [
"func",
"xorArrayRun",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"*",
"Container",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"output",
":=",
"NewContainerRun",
"(",
"nil",
")",
"\n",
"aa",
",",
"rb",
":=",
"a",
".",
"array",
"(",
")",
",",
"b... | // xorArrayRun computes the exclusive or of an array and a run container. | [
"xorArrayRun",
"computes",
"the",
"exclusive",
"or",
"of",
"an",
"array",
"and",
"a",
"run",
"container",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L3894-L3957 | train |
pilosa/pilosa | roaring/roaring.go | xorRunRun | func xorRunRun(a, b *Container) *Container {
statsHit("xor/RunRun")
ra, rb := a.runs(), b.runs()
na, nb := len(ra), len(rb)
if na == 0 {
return b.Clone()
}
if nb == 0 {
return a.Clone()
}
output := NewContainerRun(nil)
lastI, lastJ := -1, -1
state := &xorstm{}
for i, j := 0, 0; i < na || j < nb; {
i... | go | func xorRunRun(a, b *Container) *Container {
statsHit("xor/RunRun")
ra, rb := a.runs(), b.runs()
na, nb := len(ra), len(rb)
if na == 0 {
return b.Clone()
}
if nb == 0 {
return a.Clone()
}
output := NewContainerRun(nil)
lastI, lastJ := -1, -1
state := &xorstm{}
for i, j := 0, 0; i < na || j < nb; {
i... | [
"func",
"xorRunRun",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"*",
"Container",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"ra",
",",
"rb",
":=",
"a",
".",
"runs",
"(",
")",
",",
"b",
".",
"runs",
"(",
")",
"\n",
"na",
",",
"nb",
":=",
... | // xorRunRun computes the exclusive or of two run containers. | [
"xorRunRun",
"computes",
"the",
"exclusive",
"or",
"of",
"two",
"run",
"containers",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L4054-L4102 | train |
pilosa/pilosa | roaring/roaring.go | xorBitmapRun | func xorBitmapRun(a, b *Container) *Container {
statsHit("xor/BitmapRun")
output := a.Clone()
for _, run := range b.runs() {
output.bitmapXorRange(uint64(run.start), uint64(run.last)+1)
}
return output
} | go | func xorBitmapRun(a, b *Container) *Container {
statsHit("xor/BitmapRun")
output := a.Clone()
for _, run := range b.runs() {
output.bitmapXorRange(uint64(run.start), uint64(run.last)+1)
}
return output
} | [
"func",
"xorBitmapRun",
"(",
"a",
",",
"b",
"*",
"Container",
")",
"*",
"Container",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"output",
":=",
"a",
".",
"Clone",
"(",
")",
"\n\n",
"for",
"_",
",",
"run",
":=",
"range",
"b",
".",
"runs",
"(",
... | // xorRunRun computes the exclusive or of a bitmap and a run container. | [
"xorRunRun",
"computes",
"the",
"exclusive",
"or",
"of",
"a",
"bitmap",
"and",
"a",
"run",
"container",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L4105-L4114 | train |
pilosa/pilosa | roaring/roaring.go | UnmarshalBinary | func (b *Bitmap) UnmarshalBinary(data []byte) error {
if data == nil {
// Nothing to unmarshal
return nil
}
statsHit("Bitmap/UnmarshalBinary")
b.opN = 0 // reset opN since we're reading new data.
fileMagic := uint32(binary.LittleEndian.Uint16(data[0:2]))
if fileMagic == MagicNumber { // if pilosa roaring
re... | go | func (b *Bitmap) UnmarshalBinary(data []byte) error {
if data == nil {
// Nothing to unmarshal
return nil
}
statsHit("Bitmap/UnmarshalBinary")
b.opN = 0 // reset opN since we're reading new data.
fileMagic := uint32(binary.LittleEndian.Uint16(data[0:2]))
if fileMagic == MagicNumber { // if pilosa roaring
re... | [
"func",
"(",
"b",
"*",
"Bitmap",
")",
"UnmarshalBinary",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"data",
"==",
"nil",
"{",
"// Nothing to unmarshal",
"return",
"nil",
"\n",
"}",
"\n",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"b",
".",
... | // UnmarshalBinary decodes b from a binary-encoded byte slice. data can be in
// either official roaring format or Pilosa's roaring format. | [
"UnmarshalBinary",
"decodes",
"b",
"from",
"a",
"binary",
"-",
"encoded",
"byte",
"slice",
".",
"data",
"can",
"be",
"in",
"either",
"official",
"roaring",
"format",
"or",
"Pilosa",
"s",
"roaring",
"format",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L4231-L4269 | train |
pilosa/pilosa | roaring/roaring.go | markItersWithKeyAsHandled | func (w handledIters) markItersWithKeyAsHandled(startIdx int, key uint64) {
for i := startIdx; i < len(w); i++ {
wrapped := w[i]
currKey, _ := wrapped.iter.Value()
if currKey == key {
w[i].handled = true
}
}
} | go | func (w handledIters) markItersWithKeyAsHandled(startIdx int, key uint64) {
for i := startIdx; i < len(w); i++ {
wrapped := w[i]
currKey, _ := wrapped.iter.Value()
if currKey == key {
w[i].handled = true
}
}
} | [
"func",
"(",
"w",
"handledIters",
")",
"markItersWithKeyAsHandled",
"(",
"startIdx",
"int",
",",
"key",
"uint64",
")",
"{",
"for",
"i",
":=",
"startIdx",
";",
"i",
"<",
"len",
"(",
"w",
")",
";",
"i",
"++",
"{",
"wrapped",
":=",
"w",
"[",
"i",
"]",... | // Check all the iters from startIdx and up to see whether their next
// key is the given key; if it is, mark them as handled. | [
"Check",
"all",
"the",
"iters",
"from",
"startIdx",
"and",
"up",
"to",
"see",
"whether",
"their",
"next",
"key",
"is",
"the",
"given",
"key",
";",
"if",
"it",
"is",
"mark",
"them",
"as",
"handled",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/roaring.go#L4349-L4357 | train |
pilosa/pilosa | roaring/btree.go | Seek | func (t *tree) Seek(k uint64) (e *enumerator, ok bool) {
q := t.r
if q == nil {
e = btEPool.get(nil, false, 0, k, nil, t, t.ver)
return
}
for {
var i int
if i, ok = t.find(q, k); ok {
switch x := q.(type) {
case *x:
q = x.x[i+1].ch
continue
case *d:
return btEPool.get(nil, ok, i, k, x,... | go | func (t *tree) Seek(k uint64) (e *enumerator, ok bool) {
q := t.r
if q == nil {
e = btEPool.get(nil, false, 0, k, nil, t, t.ver)
return
}
for {
var i int
if i, ok = t.find(q, k); ok {
switch x := q.(type) {
case *x:
q = x.x[i+1].ch
continue
case *d:
return btEPool.get(nil, ok, i, k, x,... | [
"func",
"(",
"t",
"*",
"tree",
")",
"Seek",
"(",
"k",
"uint64",
")",
"(",
"e",
"*",
"enumerator",
",",
"ok",
"bool",
")",
"{",
"q",
":=",
"t",
".",
"r",
"\n",
"if",
"q",
"==",
"nil",
"{",
"e",
"=",
"btEPool",
".",
"get",
"(",
"nil",
",",
... | // Seek returns an Enumerator positioned on an item such that k >= item's key.
// ok reports if k == item.key The Enumerator's position is possibly after the
// last item in the tree. | [
"Seek",
"returns",
"an",
"Enumerator",
"positioned",
"on",
"an",
"item",
"such",
"that",
"k",
">",
"=",
"item",
"s",
"key",
".",
"ok",
"reports",
"if",
"k",
"==",
"item",
".",
"key",
"The",
"Enumerator",
"s",
"position",
"is",
"possibly",
"after",
"the... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/btree.go#L517-L543 | train |
pilosa/pilosa | roaring/btree.go | Prev | func (e *enumerator) Prev() (k uint64, v *Container, err error) {
if err = e.err; err != nil {
return 0, nil, err
}
if e.ver != e.t.ver {
f, _ := e.t.Seek(e.k)
*e = *f
f.Close()
}
if e.q == nil {
e.err, err = io.EOF, io.EOF
return 0, nil, err
}
if !e.hit {
// move to previous because Seek oversho... | go | func (e *enumerator) Prev() (k uint64, v *Container, err error) {
if err = e.err; err != nil {
return 0, nil, err
}
if e.ver != e.t.ver {
f, _ := e.t.Seek(e.k)
*e = *f
f.Close()
}
if e.q == nil {
e.err, err = io.EOF, io.EOF
return 0, nil, err
}
if !e.hit {
// move to previous because Seek oversho... | [
"func",
"(",
"e",
"*",
"enumerator",
")",
"Prev",
"(",
")",
"(",
"k",
"uint64",
",",
"v",
"*",
"Container",
",",
"err",
"error",
")",
"{",
"if",
"err",
"=",
"e",
".",
"err",
";",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"nil",
",",
"err",... | // Prev returns the currently enumerated item, if it exists and moves to the
// previous item in the key collation order. If there is no item to return, err
// == io.EOF is returned. | [
"Prev",
"returns",
"the",
"currently",
"enumerated",
"item",
"if",
"it",
"exists",
"and",
"moves",
"to",
"the",
"previous",
"item",
"in",
"the",
"key",
"collation",
"order",
".",
"If",
"there",
"is",
"no",
"item",
"to",
"return",
"err",
"==",
"io",
".",
... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/btree.go#L899-L934 | train |
pilosa/pilosa | translate.go | OptTranslateFileMapSize | func OptTranslateFileMapSize(mapSize int) TranslateFileOption {
return func(f *TranslateFile) error {
f.mapSize = mapSize
return nil
}
} | go | func OptTranslateFileMapSize(mapSize int) TranslateFileOption {
return func(f *TranslateFile) error {
f.mapSize = mapSize
return nil
}
} | [
"func",
"OptTranslateFileMapSize",
"(",
"mapSize",
"int",
")",
"TranslateFileOption",
"{",
"return",
"func",
"(",
"f",
"*",
"TranslateFile",
")",
"error",
"{",
"f",
".",
"mapSize",
"=",
"mapSize",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // OptTranslateFileMapSize is a functional option on TranslateFile
// used to set the map size. | [
"OptTranslateFileMapSize",
"is",
"a",
"functional",
"option",
"on",
"TranslateFile",
"used",
"to",
"set",
"the",
"map",
"size",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L106-L111 | train |
pilosa/pilosa | translate.go | OptTranslateFileLogger | func OptTranslateFileLogger(l logger.Logger) TranslateFileOption {
return func(s *TranslateFile) error {
s.logger = l
return nil
}
} | go | func OptTranslateFileLogger(l logger.Logger) TranslateFileOption {
return func(s *TranslateFile) error {
s.logger = l
return nil
}
} | [
"func",
"OptTranslateFileLogger",
"(",
"l",
"logger",
".",
"Logger",
")",
"TranslateFileOption",
"{",
"return",
"func",
"(",
"s",
"*",
"TranslateFile",
")",
"error",
"{",
"s",
".",
"logger",
"=",
"l",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // OptTranslateFileLogger is a functional option on TranslateFile
// used to set the file logger. | [
"OptTranslateFileLogger",
"is",
"a",
"functional",
"option",
"on",
"TranslateFile",
"used",
"to",
"set",
"the",
"file",
"logger",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L115-L120 | train |
pilosa/pilosa | translate.go | NewTranslateFile | func NewTranslateFile(opts ...TranslateFileOption) *TranslateFile {
var defaultMapSize64 int64 = 10 * (1 << 30)
var defaultMapSize int
if ^uint(0)>>32 > 0 {
// 10GB default map size
defaultMapSize = int(defaultMapSize64)
} else {
// Use 2GB default map size on 32-bit systems
defaultMapSize = (1 << 31) - 1
... | go | func NewTranslateFile(opts ...TranslateFileOption) *TranslateFile {
var defaultMapSize64 int64 = 10 * (1 << 30)
var defaultMapSize int
if ^uint(0)>>32 > 0 {
// 10GB default map size
defaultMapSize = int(defaultMapSize64)
} else {
// Use 2GB default map size on 32-bit systems
defaultMapSize = (1 << 31) - 1
... | [
"func",
"NewTranslateFile",
"(",
"opts",
"...",
"TranslateFileOption",
")",
"*",
"TranslateFile",
"{",
"var",
"defaultMapSize64",
"int64",
"=",
"10",
"*",
"(",
"1",
"<<",
"30",
")",
"\n",
"var",
"defaultMapSize",
"int",
"\n\n",
"if",
"^",
"uint",
"(",
"0",... | // NewTranslateFile returns a new instance of TranslateFile. | [
"NewTranslateFile",
"returns",
"a",
"new",
"instance",
"of",
"TranslateFile",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L123-L159 | train |
pilosa/pilosa | translate.go | Open | func (s *TranslateFile) Open() (err error) {
// Open writer & buffered writer.
if err := os.MkdirAll(filepath.Dir(s.Path), 0777); err != nil {
return errors.Wrapf(err, "mkdir %s", filepath.Dir(s.Path))
} else if s.file, err = os.OpenFile(s.Path, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666); err != nil {
return error... | go | func (s *TranslateFile) Open() (err error) {
// Open writer & buffered writer.
if err := os.MkdirAll(filepath.Dir(s.Path), 0777); err != nil {
return errors.Wrapf(err, "mkdir %s", filepath.Dir(s.Path))
} else if s.file, err = os.OpenFile(s.Path, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666); err != nil {
return error... | [
"func",
"(",
"s",
"*",
"TranslateFile",
")",
"Open",
"(",
")",
"(",
"err",
"error",
")",
"{",
"// Open writer & buffered writer.",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"filepath",
".",
"Dir",
"(",
"s",
".",
"Path",
")",
",",
"0777",
")",
";... | // Open opens the translate file. | [
"Open",
"opens",
"the",
"translate",
"file",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L162-L186 | train |
pilosa/pilosa | translate.go | handlePrimaryStoreEvent | func (s *TranslateFile) handlePrimaryStoreEvent(ev primaryStoreEvent) error {
s.mu.Lock()
defer s.mu.Unlock()
if ev.id == s.primaryID {
return nil
}
// Stop translate store replication.
close(s.replicationClosing)
s.repWG.Wait()
// Set the primary node for translate store replication.
s.logger.Debugf("set... | go | func (s *TranslateFile) handlePrimaryStoreEvent(ev primaryStoreEvent) error {
s.mu.Lock()
defer s.mu.Unlock()
if ev.id == s.primaryID {
return nil
}
// Stop translate store replication.
close(s.replicationClosing)
s.repWG.Wait()
// Set the primary node for translate store replication.
s.logger.Debugf("set... | [
"func",
"(",
"s",
"*",
"TranslateFile",
")",
"handlePrimaryStoreEvent",
"(",
"ev",
"primaryStoreEvent",
")",
"error",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"ev",
".",
"id",
... | // handlePrimaryStoreEvent changes the PrimaryTranslateStore
// used for replication by TranslateFile. | [
"handlePrimaryStoreEvent",
"changes",
"the",
"PrimaryTranslateStore",
"used",
"for",
"replication",
"by",
"TranslateFile",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L212-L241 | train |
pilosa/pilosa | translate.go | Close | func (s *TranslateFile) Close() (err error) {
s.once.Do(func() {
close(s.closing)
if s.file != nil {
if e := s.file.Close(); e != nil && err == nil {
err = e
}
}
if s.data != nil {
if e := syscall.Munmap(s.data); e != nil && err == nil {
err = e
}
}
})
s.wg.Wait()
return err
} | go | func (s *TranslateFile) Close() (err error) {
s.once.Do(func() {
close(s.closing)
if s.file != nil {
if e := s.file.Close(); e != nil && err == nil {
err = e
}
}
if s.data != nil {
if e := syscall.Munmap(s.data); e != nil && err == nil {
err = e
}
}
})
s.wg.Wait()
return err
} | [
"func",
"(",
"s",
"*",
"TranslateFile",
")",
"Close",
"(",
")",
"(",
"err",
"error",
")",
"{",
"s",
".",
"once",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"close",
"(",
"s",
".",
"closing",
")",
"\n\n",
"if",
"s",
".",
"file",
"!=",
"nil",
"{",
... | // Close closes the translate file. | [
"Close",
"closes",
"the",
"translate",
"file",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L244-L261 | train |
pilosa/pilosa | translate.go | size | func (s *TranslateFile) size() int64 {
s.mu.RLock()
n := s.n
s.mu.RUnlock()
return n
} | go | func (s *TranslateFile) size() int64 {
s.mu.RLock()
n := s.n
s.mu.RUnlock()
return n
} | [
"func",
"(",
"s",
"*",
"TranslateFile",
")",
"size",
"(",
")",
"int64",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"n",
":=",
"s",
".",
"n",
"\n",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"n",
"\n",
"}"
] | // size returns the number of bytes in use in the data file. | [
"size",
"returns",
"the",
"number",
"of",
"bytes",
"in",
"use",
"in",
"the",
"data",
"file",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L269-L274 | train |
pilosa/pilosa | translate.go | WriteNotify | func (s *TranslateFile) WriteNotify() <-chan struct{} {
s.mu.RLock()
ch := s.writeNotify
s.mu.RUnlock()
return ch
} | go | func (s *TranslateFile) WriteNotify() <-chan struct{} {
s.mu.RLock()
ch := s.writeNotify
s.mu.RUnlock()
return ch
} | [
"func",
"(",
"s",
"*",
"TranslateFile",
")",
"WriteNotify",
"(",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"ch",
":=",
"s",
".",
"writeNotify",
"\n",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n"... | // WriteNotify returns a channel that is closed when a new entry is written. | [
"WriteNotify",
"returns",
"a",
"channel",
"that",
"is",
"closed",
"when",
"a",
"new",
"entry",
"is",
"written",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L282-L287 | train |
pilosa/pilosa | translate.go | monitorReplication | func (s *TranslateFile) monitorReplication() {
// Create context that will cancel on close.
ctx, cancel := context.WithCancel(context.Background())
go func() {
select {
case <-s.closing:
case <-s.replicationClosing:
}
cancel()
}()
// Keep attempting to replicate until the store closes.
for {
if err :... | go | func (s *TranslateFile) monitorReplication() {
// Create context that will cancel on close.
ctx, cancel := context.WithCancel(context.Background())
go func() {
select {
case <-s.closing:
case <-s.replicationClosing:
}
cancel()
}()
// Keep attempting to replicate until the store closes.
for {
if err :... | [
"func",
"(",
"s",
"*",
"TranslateFile",
")",
"monitorReplication",
"(",
")",
"{",
"// Create context that will cancel on close.",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"context",
".",
"Background",
"(",
")",
")",
"\n",
"go",
"func",
"(... | // monitorReplication is executed in a separate goroutine and continually streams
// from the primary store until this store is closed. | [
"monitorReplication",
"is",
"executed",
"in",
"a",
"separate",
"goroutine",
"and",
"continually",
"streams",
"from",
"the",
"primary",
"store",
"until",
"this",
"store",
"is",
"closed",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L382-L405 | train |
pilosa/pilosa | translate.go | monitorPrimaryStoreEvents | func (s *TranslateFile) monitorPrimaryStoreEvents() {
// Keep handling events until the store closes.
for {
select {
case <-s.closing:
return
case ev := <-s.primaryStoreEvents:
if err := s.handlePrimaryStoreEvent(ev); err != nil {
s.logger.Printf("handle primary store event")
}
}
}
} | go | func (s *TranslateFile) monitorPrimaryStoreEvents() {
// Keep handling events until the store closes.
for {
select {
case <-s.closing:
return
case ev := <-s.primaryStoreEvents:
if err := s.handlePrimaryStoreEvent(ev); err != nil {
s.logger.Printf("handle primary store event")
}
}
}
} | [
"func",
"(",
"s",
"*",
"TranslateFile",
")",
"monitorPrimaryStoreEvents",
"(",
")",
"{",
"// Keep handling events until the store closes.",
"for",
"{",
"select",
"{",
"case",
"<-",
"s",
".",
"closing",
":",
"return",
"\n",
"case",
"ev",
":=",
"<-",
"s",
".",
... | // monitorPrimaryStoreEvents is executed in a separate goroutine and listens for changes
// to the primary store assignment. | [
"monitorPrimaryStoreEvents",
"is",
"executed",
"in",
"a",
"separate",
"goroutine",
"and",
"listens",
"for",
"changes",
"to",
"the",
"primary",
"store",
"assignment",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L409-L421 | train |
pilosa/pilosa | translate.go | TranslateColumnsToUint64 | func (s *TranslateFile) TranslateColumnsToUint64(index string, values []string) ([]uint64, error) {
ret := make([]uint64, len(values))
// Read value under read lock.
s.mu.RLock()
if idx := s.cols[index]; idx != nil {
var writeRequired bool
for i := range values {
v, ok := idx.idByKey([]byte(values[i]))
i... | go | func (s *TranslateFile) TranslateColumnsToUint64(index string, values []string) ([]uint64, error) {
ret := make([]uint64, len(values))
// Read value under read lock.
s.mu.RLock()
if idx := s.cols[index]; idx != nil {
var writeRequired bool
for i := range values {
v, ok := idx.idByKey([]byte(values[i]))
i... | [
"func",
"(",
"s",
"*",
"TranslateFile",
")",
"TranslateColumnsToUint64",
"(",
"index",
"string",
",",
"values",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"uint64",
",",
"error",
")",
"{",
"ret",
":=",
"make",
"(",
"[",
"]",
"uint64",
",",
"len",
"(",
... | // TranslateColumnsToUint64 converts values to a uint64 id.
// If value does not have an associated id then one is created. | [
"TranslateColumnsToUint64",
"converts",
"values",
"to",
"a",
"uint64",
"id",
".",
"If",
"value",
"does",
"not",
"have",
"an",
"associated",
"id",
"then",
"one",
"is",
"created",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L496-L584 | train |
pilosa/pilosa | translate.go | TranslateRowToString | func (s *TranslateFile) TranslateRowToString(index, field string, id uint64) (string, error) {
s.mu.RLock()
if idx := s.rows[fieldKey{index, field}]; idx != nil {
if ret, ok := idx.keyByID(id); ok {
s.mu.RUnlock()
return string(ret), nil
}
}
s.mu.RUnlock()
return "", nil
} | go | func (s *TranslateFile) TranslateRowToString(index, field string, id uint64) (string, error) {
s.mu.RLock()
if idx := s.rows[fieldKey{index, field}]; idx != nil {
if ret, ok := idx.keyByID(id); ok {
s.mu.RUnlock()
return string(ret), nil
}
}
s.mu.RUnlock()
return "", nil
} | [
"func",
"(",
"s",
"*",
"TranslateFile",
")",
"TranslateRowToString",
"(",
"index",
",",
"field",
"string",
",",
"id",
"uint64",
")",
"(",
"string",
",",
"error",
")",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"if",
"idx",
":=",
"s",
".",
... | // TranslateRowToString translates a row ID to a string key. | [
"TranslateRowToString",
"translates",
"a",
"row",
"ID",
"to",
"a",
"string",
"key",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L693-L703 | train |
pilosa/pilosa | translate.go | Reader | func (s *TranslateFile) Reader(ctx context.Context, offset int64) (io.ReadCloser, error) {
rc := newTranslateFileReader(ctx, s, offset)
if err := rc.Open(); err != nil {
return nil, err
}
return rc, nil
} | go | func (s *TranslateFile) Reader(ctx context.Context, offset int64) (io.ReadCloser, error) {
rc := newTranslateFileReader(ctx, s, offset)
if err := rc.Open(); err != nil {
return nil, err
}
return rc, nil
} | [
"func",
"(",
"s",
"*",
"TranslateFile",
")",
"Reader",
"(",
"ctx",
"context",
".",
"Context",
",",
"offset",
"int64",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"rc",
":=",
"newTranslateFileReader",
"(",
"ctx",
",",
"s",
",",
"offset",
... | // Reader returns a reader that streams the underlying data file. | [
"Reader",
"returns",
"a",
"reader",
"that",
"streams",
"the",
"underlying",
"data",
"file",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L706-L712 | train |
pilosa/pilosa | translate.go | headerSize | func (e *LogEntry) headerSize() int64 {
sz := uVarintSize(e.Length) + // total entry length
1 + // type
uVarintSize(uint64(len(e.Index))) + len(e.Index) + // Index length and data
uVarintSize(uint64(len(e.Field))) + len(e.Field) + // Field length and data
uVarintSize(uint64(len(e.IDs))) // ID/Key pair count
r... | go | func (e *LogEntry) headerSize() int64 {
sz := uVarintSize(e.Length) + // total entry length
1 + // type
uVarintSize(uint64(len(e.Index))) + len(e.Index) + // Index length and data
uVarintSize(uint64(len(e.Field))) + len(e.Field) + // Field length and data
uVarintSize(uint64(len(e.IDs))) // ID/Key pair count
r... | [
"func",
"(",
"e",
"*",
"LogEntry",
")",
"headerSize",
"(",
")",
"int64",
"{",
"sz",
":=",
"uVarintSize",
"(",
"e",
".",
"Length",
")",
"+",
"// total entry length",
"1",
"+",
"// type",
"uVarintSize",
"(",
"uint64",
"(",
"len",
"(",
"e",
".",
"Index",
... | // headerSize returns the number of bytes required for size, type, index, field, & pair count. | [
"headerSize",
"returns",
"the",
"number",
"of",
"bytes",
"required",
"for",
"size",
"type",
"index",
"field",
"&",
"pair",
"count",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L730-L737 | train |
pilosa/pilosa | translate.go | WriteTo | func (e *LogEntry) WriteTo(w io.Writer) (_ int64, err error) {
var buf bytes.Buffer
b := make([]byte, binary.MaxVarintLen64)
// Write the entry type.
if err := binary.Write(&buf, binary.BigEndian, e.Type); err != nil {
return 0, err
}
// Write the index name.
sz := binary.PutUvarint(b, uint64(len(e.Index)))
... | go | func (e *LogEntry) WriteTo(w io.Writer) (_ int64, err error) {
var buf bytes.Buffer
b := make([]byte, binary.MaxVarintLen64)
// Write the entry type.
if err := binary.Write(&buf, binary.BigEndian, e.Type); err != nil {
return 0, err
}
// Write the index name.
sz := binary.PutUvarint(b, uint64(len(e.Index)))
... | [
"func",
"(",
"e",
"*",
"LogEntry",
")",
"WriteTo",
"(",
"w",
"io",
".",
"Writer",
")",
"(",
"_",
"int64",
",",
"err",
"error",
")",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"binary",
".",
... | // WriteTo serializes a LogEntry to w. | [
"WriteTo",
"serializes",
"a",
"LogEntry",
"to",
"w",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L817-L875 | train |
pilosa/pilosa | translate.go | validLogEntriesLen | func validLogEntriesLen(p []byte) (n int) {
r := bytes.NewReader(p)
for {
if sz, err := binary.ReadUvarint(r); err != nil {
return n
} else if off, err := r.Seek(int64(sz), io.SeekCurrent); err != nil {
return n
} else if off > int64(len(p)) {
return n
} else {
n = int(off)
}
}
} | go | func validLogEntriesLen(p []byte) (n int) {
r := bytes.NewReader(p)
for {
if sz, err := binary.ReadUvarint(r); err != nil {
return n
} else if off, err := r.Seek(int64(sz), io.SeekCurrent); err != nil {
return n
} else if off > int64(len(p)) {
return n
} else {
n = int(off)
}
}
} | [
"func",
"validLogEntriesLen",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
")",
"{",
"r",
":=",
"bytes",
".",
"NewReader",
"(",
"p",
")",
"\n",
"for",
"{",
"if",
"sz",
",",
"err",
":=",
"binary",
".",
"ReadUvarint",
"(",
"r",
")",
";",
"er... | // validLogEntriesLen returns the maximum length of p that contains valid entries. | [
"validLogEntriesLen",
"returns",
"the",
"maximum",
"length",
"of",
"p",
"that",
"contains",
"valid",
"entries",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L878-L891 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.