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 | http/client.go | marshalImportPayload | func (c *InternalClient) marshalImportPayload(index, field string, shard uint64, bits []pilosa.Bit) ([]byte, error) {
// Separate row and column IDs to reduce allocations.
rowIDs := Bits(bits).RowIDs()
rowKeys := Bits(bits).RowKeys()
columnIDs := Bits(bits).ColumnIDs()
columnKeys := Bits(bits).ColumnKeys()
timest... | go | func (c *InternalClient) marshalImportPayload(index, field string, shard uint64, bits []pilosa.Bit) ([]byte, error) {
// Separate row and column IDs to reduce allocations.
rowIDs := Bits(bits).RowIDs()
rowKeys := Bits(bits).RowKeys()
columnIDs := Bits(bits).ColumnIDs()
columnKeys := Bits(bits).ColumnKeys()
timest... | [
"func",
"(",
"c",
"*",
"InternalClient",
")",
"marshalImportPayload",
"(",
"index",
",",
"field",
"string",
",",
"shard",
"uint64",
",",
"bits",
"[",
"]",
"pilosa",
".",
"Bit",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// Separate row and colu... | // marshalImportPayload marshalls the import parameters into a protobuf byte slice. | [
"marshalImportPayload",
"marshalls",
"the",
"import",
"parameters",
"into",
"a",
"protobuf",
"byte",
"slice",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L440-L463 | train |
pilosa/pilosa | http/client.go | importNode | func (c *InternalClient) importNode(ctx context.Context, node *pilosa.Node, index, field string, buf []byte, opts *pilosa.ImportOptions) error {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.importNode")
defer span.Finish()
// Create URL & HTTP request.
path := fmt.Sprintf("/index/%s/field/%s/impo... | go | func (c *InternalClient) importNode(ctx context.Context, node *pilosa.Node, index, field string, buf []byte, opts *pilosa.ImportOptions) error {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.importNode")
defer span.Finish()
// Create URL & HTTP request.
path := fmt.Sprintf("/index/%s/field/%s/impo... | [
"func",
"(",
"c",
"*",
"InternalClient",
")",
"importNode",
"(",
"ctx",
"context",
".",
"Context",
",",
"node",
"*",
"pilosa",
".",
"Node",
",",
"index",
",",
"field",
"string",
",",
"buf",
"[",
"]",
"byte",
",",
"opts",
"*",
"pilosa",
".",
"ImportOp... | // importNode sends a pre-marshaled import request to a node. | [
"importNode",
"sends",
"a",
"pre",
"-",
"marshaled",
"import",
"request",
"to",
"a",
"node",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L466-L513 | train |
pilosa/pilosa | http/client.go | ImportValueK | func (c *InternalClient) ImportValueK(ctx context.Context, index, field string, vals []pilosa.FieldValue, opts ...pilosa.ImportOption) error {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.ImportValueK")
defer span.Finish()
buf, err := c.marshalImportValuePayload(index, field, 0, vals)
if err != n... | go | func (c *InternalClient) ImportValueK(ctx context.Context, index, field string, vals []pilosa.FieldValue, opts ...pilosa.ImportOption) error {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.ImportValueK")
defer span.Finish()
buf, err := c.marshalImportValuePayload(index, field, 0, vals)
if err != n... | [
"func",
"(",
"c",
"*",
"InternalClient",
")",
"ImportValueK",
"(",
"ctx",
"context",
".",
"Context",
",",
"index",
",",
"field",
"string",
",",
"vals",
"[",
"]",
"pilosa",
".",
"FieldValue",
",",
"opts",
"...",
"pilosa",
".",
"ImportOption",
")",
"error"... | // ImportValueK bulk imports keyed field values to a host. | [
"ImportValueK",
"bulk",
"imports",
"keyed",
"field",
"values",
"to",
"a",
"host",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L557-L592 | train |
pilosa/pilosa | http/client.go | marshalImportValuePayload | func (c *InternalClient) marshalImportValuePayload(index, field string, shard uint64, vals []pilosa.FieldValue) ([]byte, error) {
// Separate row and column IDs to reduce allocations.
columnIDs := FieldValues(vals).ColumnIDs()
columnKeys := FieldValues(vals).ColumnKeys()
values := FieldValues(vals).Values()
// Ma... | go | func (c *InternalClient) marshalImportValuePayload(index, field string, shard uint64, vals []pilosa.FieldValue) ([]byte, error) {
// Separate row and column IDs to reduce allocations.
columnIDs := FieldValues(vals).ColumnIDs()
columnKeys := FieldValues(vals).ColumnKeys()
values := FieldValues(vals).Values()
// Ma... | [
"func",
"(",
"c",
"*",
"InternalClient",
")",
"marshalImportValuePayload",
"(",
"index",
",",
"field",
"string",
",",
"shard",
"uint64",
",",
"vals",
"[",
"]",
"pilosa",
".",
"FieldValue",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// Separate ... | // marshalImportValuePayload marshalls the import parameters into a protobuf byte slice. | [
"marshalImportValuePayload",
"marshalls",
"the",
"import",
"parameters",
"into",
"a",
"protobuf",
"byte",
"slice",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L595-L614 | train |
pilosa/pilosa | http/client.go | ExportCSV | func (c *InternalClient) ExportCSV(ctx context.Context, index, field string, shard uint64, w io.Writer) error {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.ExportCSV")
defer span.Finish()
if index == "" {
return pilosa.ErrIndexRequired
} else if field == "" {
return pilosa.ErrFieldRequired
... | go | func (c *InternalClient) ExportCSV(ctx context.Context, index, field string, shard uint64, w io.Writer) error {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.ExportCSV")
defer span.Finish()
if index == "" {
return pilosa.ErrIndexRequired
} else if field == "" {
return pilosa.ErrFieldRequired
... | [
"func",
"(",
"c",
"*",
"InternalClient",
")",
"ExportCSV",
"(",
"ctx",
"context",
".",
"Context",
",",
"index",
",",
"field",
"string",
",",
"shard",
"uint64",
",",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"span",
",",
"ctx",
":=",
"tracing",
"."... | // ExportCSV bulk exports data for a single shard from a host to CSV format. | [
"ExportCSV",
"bulk",
"exports",
"data",
"for",
"a",
"single",
"shard",
"from",
"a",
"host",
"to",
"CSV",
"format",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L671-L701 | train |
pilosa/pilosa | http/client.go | exportNodeCSV | func (c *InternalClient) exportNodeCSV(ctx context.Context, node *pilosa.Node, index, field string, shard uint64, w io.Writer) error {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.exportNodeCSV")
defer span.Finish()
// Create URL.
u := nodePathToURL(node, "/export")
u.RawQuery = url.Values{
"i... | go | func (c *InternalClient) exportNodeCSV(ctx context.Context, node *pilosa.Node, index, field string, shard uint64, w io.Writer) error {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.exportNodeCSV")
defer span.Finish()
// Create URL.
u := nodePathToURL(node, "/export")
u.RawQuery = url.Values{
"i... | [
"func",
"(",
"c",
"*",
"InternalClient",
")",
"exportNodeCSV",
"(",
"ctx",
"context",
".",
"Context",
",",
"node",
"*",
"pilosa",
".",
"Node",
",",
"index",
",",
"field",
"string",
",",
"shard",
"uint64",
",",
"w",
"io",
".",
"Writer",
")",
"error",
... | // exportNode copies a CSV export from a node to w. | [
"exportNode",
"copies",
"a",
"CSV",
"export",
"from",
"a",
"node",
"to",
"w",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L704-L737 | train |
pilosa/pilosa | http/client.go | CreateFieldWithOptions | func (c *InternalClient) CreateFieldWithOptions(ctx context.Context, index, field string, opt pilosa.FieldOptions) error {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.CreateFieldWithOptions")
defer span.Finish()
if index == "" {
return pilosa.ErrIndexRequired
}
// convert pilosa.FieldOptions... | go | func (c *InternalClient) CreateFieldWithOptions(ctx context.Context, index, field string, opt pilosa.FieldOptions) error {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.CreateFieldWithOptions")
defer span.Finish()
if index == "" {
return pilosa.ErrIndexRequired
}
// convert pilosa.FieldOptions... | [
"func",
"(",
"c",
"*",
"InternalClient",
")",
"CreateFieldWithOptions",
"(",
"ctx",
"context",
".",
"Context",
",",
"index",
",",
"field",
"string",
",",
"opt",
"pilosa",
".",
"FieldOptions",
")",
"error",
"{",
"span",
",",
"ctx",
":=",
"tracing",
".",
"... | // CreateField creates a new field on the server. | [
"CreateField",
"creates",
"a",
"new",
"field",
"on",
"the",
"server",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L785-L838 | train |
pilosa/pilosa | http/client.go | FragmentBlocks | func (c *InternalClient) FragmentBlocks(ctx context.Context, uri *pilosa.URI, index, field, view string, shard uint64) ([]pilosa.FragmentBlock, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.FragmentBlocks")
defer span.Finish()
if uri == nil {
uri = c.defaultURI
}
u := uriPathToURL(uri,... | go | func (c *InternalClient) FragmentBlocks(ctx context.Context, uri *pilosa.URI, index, field, view string, shard uint64) ([]pilosa.FragmentBlock, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.FragmentBlocks")
defer span.Finish()
if uri == nil {
uri = c.defaultURI
}
u := uriPathToURL(uri,... | [
"func",
"(",
"c",
"*",
"InternalClient",
")",
"FragmentBlocks",
"(",
"ctx",
"context",
".",
"Context",
",",
"uri",
"*",
"pilosa",
".",
"URI",
",",
"index",
",",
"field",
",",
"view",
"string",
",",
"shard",
"uint64",
")",
"(",
"[",
"]",
"pilosa",
"."... | // FragmentBlocks returns a list of block checksums for a fragment on a host.
// Only returns blocks which contain data. | [
"FragmentBlocks",
"returns",
"a",
"list",
"of",
"block",
"checksums",
"for",
"a",
"fragment",
"on",
"a",
"host",
".",
"Only",
"returns",
"blocks",
"which",
"contain",
"data",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L842-L883 | train |
pilosa/pilosa | http/client.go | RowAttrDiff | func (c *InternalClient) RowAttrDiff(ctx context.Context, uri *pilosa.URI, index, field string, blks []pilosa.AttrBlock) (map[uint64]map[string]interface{}, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.RowAttrDiff")
defer span.Finish()
if uri == nil {
uri = c.defaultURI
}
u := uriPath... | go | func (c *InternalClient) RowAttrDiff(ctx context.Context, uri *pilosa.URI, index, field string, blks []pilosa.AttrBlock) (map[uint64]map[string]interface{}, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.RowAttrDiff")
defer span.Finish()
if uri == nil {
uri = c.defaultURI
}
u := uriPath... | [
"func",
"(",
"c",
"*",
"InternalClient",
")",
"RowAttrDiff",
"(",
"ctx",
"context",
".",
"Context",
",",
"uri",
"*",
"pilosa",
".",
"URI",
",",
"index",
",",
"field",
"string",
",",
"blks",
"[",
"]",
"pilosa",
".",
"AttrBlock",
")",
"(",
"map",
"[",
... | // RowAttrDiff returns data from differing blocks on a remote host. | [
"RowAttrDiff",
"returns",
"data",
"from",
"differing",
"blocks",
"on",
"a",
"remote",
"host",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L974-L1014 | train |
pilosa/pilosa | http/client.go | SendMessage | func (c *InternalClient) SendMessage(ctx context.Context, uri *pilosa.URI, msg []byte) error {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.SendMessage")
defer span.Finish()
u := uriPathToURL(uri, "/internal/cluster/message")
req, err := http.NewRequest("POST", u.String(), bytes.NewReader(msg))
... | go | func (c *InternalClient) SendMessage(ctx context.Context, uri *pilosa.URI, msg []byte) error {
span, ctx := tracing.StartSpanFromContext(ctx, "InternalClient.SendMessage")
defer span.Finish()
u := uriPathToURL(uri, "/internal/cluster/message")
req, err := http.NewRequest("POST", u.String(), bytes.NewReader(msg))
... | [
"func",
"(",
"c",
"*",
"InternalClient",
")",
"SendMessage",
"(",
"ctx",
"context",
".",
"Context",
",",
"uri",
"*",
"pilosa",
".",
"URI",
",",
"msg",
"[",
"]",
"byte",
")",
"error",
"{",
"span",
",",
"ctx",
":=",
"tracing",
".",
"StartSpanFromContext"... | // SendMessage posts a message synchronously. | [
"SendMessage",
"posts",
"a",
"message",
"synchronously",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L1017-L1036 | train |
pilosa/pilosa | http/client.go | executeRequest | func (c *InternalClient) executeRequest(req *http.Request) (*http.Response, error) {
tracing.GlobalTracer.InjectHTTPHeaders(req)
resp, err := c.httpClient.Do(req)
if err != nil {
if resp != nil {
resp.Body.Close()
}
return nil, errors.Wrap(err, "getting response")
}
if resp.StatusCode < 200 || resp.Status... | go | func (c *InternalClient) executeRequest(req *http.Request) (*http.Response, error) {
tracing.GlobalTracer.InjectHTTPHeaders(req)
resp, err := c.httpClient.Do(req)
if err != nil {
if resp != nil {
resp.Body.Close()
}
return nil, errors.Wrap(err, "getting response")
}
if resp.StatusCode < 200 || resp.Status... | [
"func",
"(",
"c",
"*",
"InternalClient",
")",
"executeRequest",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"tracing",
".",
"GlobalTracer",
".",
"InjectHTTPHeaders",
"(",
"req",
")",
"\n",
"r... | // executeRequest executes the given request and checks the Response. For
// responses with non-2XX status, the body is read and closed, and an error is
// returned. If the error is nil, the caller must ensure that the response body
// is closed. | [
"executeRequest",
"executes",
"the",
"given",
"request",
"and",
"checks",
"the",
"Response",
".",
"For",
"responses",
"with",
"non",
"-",
"2XX",
"status",
"the",
"body",
"is",
"read",
"and",
"closed",
"and",
"an",
"error",
"is",
"returned",
".",
"If",
"the... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L1042-L1068 | train |
pilosa/pilosa | http/client.go | HasRowKeys | func (p Bits) HasRowKeys() bool {
for i := range p {
if p[i].RowKey != "" {
return true
}
}
return false
} | go | func (p Bits) HasRowKeys() bool {
for i := range p {
if p[i].RowKey != "" {
return true
}
}
return false
} | [
"func",
"(",
"p",
"Bits",
")",
"HasRowKeys",
"(",
")",
"bool",
"{",
"for",
"i",
":=",
"range",
"p",
"{",
"if",
"p",
"[",
"i",
"]",
".",
"RowKey",
"!=",
"\"",
"\"",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}... | // HasRowKeys returns true if any values use a row key. | [
"HasRowKeys",
"returns",
"true",
"if",
"any",
"values",
"use",
"a",
"row",
"key",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L1087-L1094 | train |
pilosa/pilosa | http/client.go | RowIDs | func (p Bits) RowIDs() []uint64 {
if p.HasRowKeys() {
return nil
}
other := make([]uint64, len(p))
for i := range p {
other[i] = p[i].RowID
}
return other
} | go | func (p Bits) RowIDs() []uint64 {
if p.HasRowKeys() {
return nil
}
other := make([]uint64, len(p))
for i := range p {
other[i] = p[i].RowID
}
return other
} | [
"func",
"(",
"p",
"Bits",
")",
"RowIDs",
"(",
")",
"[",
"]",
"uint64",
"{",
"if",
"p",
".",
"HasRowKeys",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"other",
":=",
"make",
"(",
"[",
"]",
"uint64",
",",
"len",
"(",
"p",
")",
")",
"\n",
... | // RowIDs returns a slice of all the row IDs. | [
"RowIDs",
"returns",
"a",
"slice",
"of",
"all",
"the",
"row",
"IDs",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L1107-L1116 | train |
pilosa/pilosa | http/client.go | ColumnIDs | func (p Bits) ColumnIDs() []uint64 {
if p.HasColumnKeys() {
return nil
}
other := make([]uint64, len(p))
for i := range p {
other[i] = p[i].ColumnID
}
return other
} | go | func (p Bits) ColumnIDs() []uint64 {
if p.HasColumnKeys() {
return nil
}
other := make([]uint64, len(p))
for i := range p {
other[i] = p[i].ColumnID
}
return other
} | [
"func",
"(",
"p",
"Bits",
")",
"ColumnIDs",
"(",
")",
"[",
"]",
"uint64",
"{",
"if",
"p",
".",
"HasColumnKeys",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"other",
":=",
"make",
"(",
"[",
"]",
"uint64",
",",
"len",
"(",
"p",
")",
")",
"... | // ColumnIDs returns a slice of all the column IDs. | [
"ColumnIDs",
"returns",
"a",
"slice",
"of",
"all",
"the",
"column",
"IDs",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L1119-L1128 | train |
pilosa/pilosa | http/client.go | RowKeys | func (p Bits) RowKeys() []string {
if !p.HasRowKeys() {
return nil
}
other := make([]string, len(p))
for i := range p {
other[i] = p[i].RowKey
}
return other
} | go | func (p Bits) RowKeys() []string {
if !p.HasRowKeys() {
return nil
}
other := make([]string, len(p))
for i := range p {
other[i] = p[i].RowKey
}
return other
} | [
"func",
"(",
"p",
"Bits",
")",
"RowKeys",
"(",
")",
"[",
"]",
"string",
"{",
"if",
"!",
"p",
".",
"HasRowKeys",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"other",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"p",
")",
")",
... | // RowKeys returns a slice of all the row keys. | [
"RowKeys",
"returns",
"a",
"slice",
"of",
"all",
"the",
"row",
"keys",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L1131-L1140 | train |
pilosa/pilosa | http/client.go | Timestamps | func (p Bits) Timestamps() []int64 {
other := make([]int64, len(p))
for i := range p {
other[i] = p[i].Timestamp
}
return other
} | go | func (p Bits) Timestamps() []int64 {
other := make([]int64, len(p))
for i := range p {
other[i] = p[i].Timestamp
}
return other
} | [
"func",
"(",
"p",
"Bits",
")",
"Timestamps",
"(",
")",
"[",
"]",
"int64",
"{",
"other",
":=",
"make",
"(",
"[",
"]",
"int64",
",",
"len",
"(",
"p",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"p",
"{",
"other",
"[",
"i",
"]",
"=",
"p",
"[",
... | // Timestamps returns a slice of all the timestamps. | [
"Timestamps",
"returns",
"a",
"slice",
"of",
"all",
"the",
"timestamps",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L1155-L1161 | train |
pilosa/pilosa | http/client.go | GroupByShard | func (p Bits) GroupByShard() map[uint64][]pilosa.Bit {
m := make(map[uint64][]pilosa.Bit)
for _, bit := range p {
shard := bit.ColumnID / pilosa.ShardWidth
m[shard] = append(m[shard], bit)
}
for shard, bits := range m {
sort.Sort(Bits(bits))
m[shard] = bits
}
return m
} | go | func (p Bits) GroupByShard() map[uint64][]pilosa.Bit {
m := make(map[uint64][]pilosa.Bit)
for _, bit := range p {
shard := bit.ColumnID / pilosa.ShardWidth
m[shard] = append(m[shard], bit)
}
for shard, bits := range m {
sort.Sort(Bits(bits))
m[shard] = bits
}
return m
} | [
"func",
"(",
"p",
"Bits",
")",
"GroupByShard",
"(",
")",
"map",
"[",
"uint64",
"]",
"[",
"]",
"pilosa",
".",
"Bit",
"{",
"m",
":=",
"make",
"(",
"map",
"[",
"uint64",
"]",
"[",
"]",
"pilosa",
".",
"Bit",
")",
"\n",
"for",
"_",
",",
"bit",
":=... | // GroupByShard returns a map of bits by shard. | [
"GroupByShard",
"returns",
"a",
"map",
"of",
"bits",
"by",
"shard",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L1164-L1177 | train |
pilosa/pilosa | http/client.go | ColumnKeys | func (p FieldValues) ColumnKeys() []string {
if !p.HasColumnKeys() {
return nil
}
other := make([]string, len(p))
for i := range p {
other[i] = p[i].ColumnKey
}
return other
} | go | func (p FieldValues) ColumnKeys() []string {
if !p.HasColumnKeys() {
return nil
}
other := make([]string, len(p))
for i := range p {
other[i] = p[i].ColumnKey
}
return other
} | [
"func",
"(",
"p",
"FieldValues",
")",
"ColumnKeys",
"(",
")",
"[",
"]",
"string",
"{",
"if",
"!",
"p",
".",
"HasColumnKeys",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"other",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"p",
... | // ColumnKeys returns a slice of all the column keys. | [
"ColumnKeys",
"returns",
"a",
"slice",
"of",
"all",
"the",
"column",
"keys",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L1212-L1221 | train |
pilosa/pilosa | http/client.go | Values | func (p FieldValues) Values() []int64 {
other := make([]int64, len(p))
for i := range p {
other[i] = p[i].Value
}
return other
} | go | func (p FieldValues) Values() []int64 {
other := make([]int64, len(p))
for i := range p {
other[i] = p[i].Value
}
return other
} | [
"func",
"(",
"p",
"FieldValues",
")",
"Values",
"(",
")",
"[",
"]",
"int64",
"{",
"other",
":=",
"make",
"(",
"[",
"]",
"int64",
",",
"len",
"(",
"p",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"p",
"{",
"other",
"[",
"i",
"]",
"=",
"p",
"[... | // Values returns a slice of all the values. | [
"Values",
"returns",
"a",
"slice",
"of",
"all",
"the",
"values",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L1224-L1230 | train |
pilosa/pilosa | http/client.go | GroupByShard | func (p FieldValues) GroupByShard() map[uint64][]pilosa.FieldValue {
m := make(map[uint64][]pilosa.FieldValue)
for _, val := range p {
shard := val.ColumnID / pilosa.ShardWidth
m[shard] = append(m[shard], val)
}
for shard, vals := range m {
sort.Sort(FieldValues(vals))
m[shard] = vals
}
return m
} | go | func (p FieldValues) GroupByShard() map[uint64][]pilosa.FieldValue {
m := make(map[uint64][]pilosa.FieldValue)
for _, val := range p {
shard := val.ColumnID / pilosa.ShardWidth
m[shard] = append(m[shard], val)
}
for shard, vals := range m {
sort.Sort(FieldValues(vals))
m[shard] = vals
}
return m
} | [
"func",
"(",
"p",
"FieldValues",
")",
"GroupByShard",
"(",
")",
"map",
"[",
"uint64",
"]",
"[",
"]",
"pilosa",
".",
"FieldValue",
"{",
"m",
":=",
"make",
"(",
"map",
"[",
"uint64",
"]",
"[",
"]",
"pilosa",
".",
"FieldValue",
")",
"\n",
"for",
"_",
... | // GroupByShard returns a map of field values by shard. | [
"GroupByShard",
"returns",
"a",
"map",
"of",
"field",
"values",
"by",
"shard",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/http/client.go#L1233-L1246 | train |
pilosa/pilosa | syswrap/os.go | OpenFile | func OpenFile(name string, flag int, perm os.FileMode) (file *os.File, mustClose bool, err error) {
file, err = os.OpenFile(name, flag, perm)
fileMu.RLock()
defer fileMu.RUnlock()
if newCount := atomic.AddUint64(&fileCount, 1); newCount > maxFileCount {
mustClose = true
}
return file, mustClose, err
} | go | func OpenFile(name string, flag int, perm os.FileMode) (file *os.File, mustClose bool, err error) {
file, err = os.OpenFile(name, flag, perm)
fileMu.RLock()
defer fileMu.RUnlock()
if newCount := atomic.AddUint64(&fileCount, 1); newCount > maxFileCount {
mustClose = true
}
return file, mustClose, err
} | [
"func",
"OpenFile",
"(",
"name",
"string",
",",
"flag",
"int",
",",
"perm",
"os",
".",
"FileMode",
")",
"(",
"file",
"*",
"os",
".",
"File",
",",
"mustClose",
"bool",
",",
"err",
"error",
")",
"{",
"file",
",",
"err",
"=",
"os",
".",
"OpenFile",
... | // OpenFile passes the arguments along to os.OpenFile while incrementing a
// counter. If the counter is above the maximum, it returns mustClose true to
// signal the calling function that it should not keep the file open
// indefinitely. Files opened with this function should be closed by
// syswrap.CloseFile. | [
"OpenFile",
"passes",
"the",
"arguments",
"along",
"to",
"os",
".",
"OpenFile",
"while",
"incrementing",
"a",
"counter",
".",
"If",
"the",
"counter",
"is",
"above",
"the",
"maximum",
"it",
"returns",
"mustClose",
"true",
"to",
"signal",
"the",
"calling",
"fu... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/syswrap/os.go#L41-L49 | train |
pilosa/pilosa | syswrap/os.go | CloseFile | func CloseFile(f *os.File) error {
atomic.AddUint64(&fileCount, ^uint64(0)) // decrement
return f.Close()
} | go | func CloseFile(f *os.File) error {
atomic.AddUint64(&fileCount, ^uint64(0)) // decrement
return f.Close()
} | [
"func",
"CloseFile",
"(",
"f",
"*",
"os",
".",
"File",
")",
"error",
"{",
"atomic",
".",
"AddUint64",
"(",
"&",
"fileCount",
",",
"^",
"uint64",
"(",
"0",
")",
")",
"// decrement",
"\n",
"return",
"f",
".",
"Close",
"(",
")",
"\n",
"}"
] | // CloseFile decrements the global count of open files and closes the file. | [
"CloseFile",
"decrements",
"the",
"global",
"count",
"of",
"open",
"files",
"and",
"closes",
"the",
"file",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/syswrap/os.go#L52-L55 | train |
pilosa/pilosa | syswrap/mmap.go | Mmap | func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
mu.RLock()
defer mu.RUnlock()
if newCount := atomic.AddUint64(&mapCount, 1); newCount > maxMapCount {
atomic.AddUint64(&mapCount, ^uint64(0)) // decrement
return nil, ErrMaxMapCountReached
}
data, err = syscall.Mmap(fd,... | go | func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
mu.RLock()
defer mu.RUnlock()
if newCount := atomic.AddUint64(&mapCount, 1); newCount > maxMapCount {
atomic.AddUint64(&mapCount, ^uint64(0)) // decrement
return nil, ErrMaxMapCountReached
}
data, err = syscall.Mmap(fd,... | [
"func",
"Mmap",
"(",
"fd",
"int",
",",
"offset",
"int64",
",",
"length",
"int",
",",
"prot",
"int",
",",
"flags",
"int",
")",
"(",
"data",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"mu",
".",
... | // Mmap increments the global map count, and then calls syscall.Mmap. It
// decrements the map count and returns an error if the count was over the
// limit. If syscall.Mmap returns an error it also decrements the count. | [
"Mmap",
"increments",
"the",
"global",
"map",
"count",
"and",
"then",
"calls",
"syscall",
".",
"Mmap",
".",
"It",
"decrements",
"the",
"map",
"count",
"and",
"returns",
"an",
"error",
"if",
"the",
"count",
"was",
"over",
"the",
"limit",
".",
"If",
"sysca... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/syswrap/mmap.go#L46-L58 | train |
pilosa/pilosa | syswrap/mmap.go | Munmap | func Munmap(b []byte) (err error) {
err = syscall.Munmap(b)
if err == nil {
atomic.AddUint64(&mapCount, ^uint64(0)) // decrement
}
return err
} | go | func Munmap(b []byte) (err error) {
err = syscall.Munmap(b)
if err == nil {
atomic.AddUint64(&mapCount, ^uint64(0)) // decrement
}
return err
} | [
"func",
"Munmap",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"syscall",
".",
"Munmap",
"(",
"b",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"atomic",
".",
"AddUint64",
"(",
"&",
"mapCount",
",",
"^",
"uint64",
"(... | // Munmap calls sycall.Munmap, and then decrements the global map count if there
// was no error. | [
"Munmap",
"calls",
"sycall",
".",
"Munmap",
"and",
"then",
"decrements",
"the",
"global",
"map",
"count",
"if",
"there",
"was",
"no",
"error",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/syswrap/mmap.go#L62-L68 | train |
pilosa/pilosa | time.go | Set | func (q *TimeQuantum) Set(value string) error {
*q = TimeQuantum(value)
return nil
} | go | func (q *TimeQuantum) Set(value string) error {
*q = TimeQuantum(value)
return nil
} | [
"func",
"(",
"q",
"*",
"TimeQuantum",
")",
"Set",
"(",
"value",
"string",
")",
"error",
"{",
"*",
"q",
"=",
"TimeQuantum",
"(",
"value",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // The following methods are required to implement pflag Value interface.
// Set sets the time quantum value. | [
"The",
"following",
"methods",
"are",
"required",
"to",
"implement",
"pflag",
"Value",
"interface",
".",
"Set",
"sets",
"the",
"time",
"quantum",
"value",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/time.go#L60-L63 | train |
pilosa/pilosa | time.go | viewByTimeUnit | func viewByTimeUnit(name string, t time.Time, unit rune) string {
switch unit {
case 'Y':
return fmt.Sprintf("%s_%s", name, t.Format("2006"))
case 'M':
return fmt.Sprintf("%s_%s", name, t.Format("200601"))
case 'D':
return fmt.Sprintf("%s_%s", name, t.Format("20060102"))
case 'H':
return fmt.Sprintf("%s_%s... | go | func viewByTimeUnit(name string, t time.Time, unit rune) string {
switch unit {
case 'Y':
return fmt.Sprintf("%s_%s", name, t.Format("2006"))
case 'M':
return fmt.Sprintf("%s_%s", name, t.Format("200601"))
case 'D':
return fmt.Sprintf("%s_%s", name, t.Format("20060102"))
case 'H':
return fmt.Sprintf("%s_%s... | [
"func",
"viewByTimeUnit",
"(",
"name",
"string",
",",
"t",
"time",
".",
"Time",
",",
"unit",
"rune",
")",
"string",
"{",
"switch",
"unit",
"{",
"case",
"'Y'",
":",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"name",
",",
"t",
".",
"Forma... | // viewByTimeUnit returns the view name for time with a given quantum unit. | [
"viewByTimeUnit",
"returns",
"the",
"view",
"name",
"for",
"time",
"with",
"a",
"given",
"quantum",
"unit",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/time.go#L75-L88 | train |
pilosa/pilosa | time.go | viewsByTime | func viewsByTime(name string, t time.Time, q TimeQuantum) []string { // nolint: unparam
a := make([]string, 0, len(q))
for _, unit := range q {
view := viewByTimeUnit(name, t, unit)
if view == "" {
continue
}
a = append(a, view)
}
return a
} | go | func viewsByTime(name string, t time.Time, q TimeQuantum) []string { // nolint: unparam
a := make([]string, 0, len(q))
for _, unit := range q {
view := viewByTimeUnit(name, t, unit)
if view == "" {
continue
}
a = append(a, view)
}
return a
} | [
"func",
"viewsByTime",
"(",
"name",
"string",
",",
"t",
"time",
".",
"Time",
",",
"q",
"TimeQuantum",
")",
"[",
"]",
"string",
"{",
"// nolint: unparam",
"a",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"q",
")",
")",
"\n",
... | // viewsByTime returns a list of views for a given timestamp. | [
"viewsByTime",
"returns",
"a",
"list",
"of",
"views",
"for",
"a",
"given",
"timestamp",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/time.go#L91-L101 | train |
pilosa/pilosa | time.go | viewsByTimeRange | func viewsByTimeRange(name string, start, end time.Time, q TimeQuantum) []string { // nolint: unparam
t := start
// Save flags for performance.
hasYear := q.HasYear()
hasMonth := q.HasMonth()
hasDay := q.HasDay()
hasHour := q.HasHour()
var results []string
// Walk up from smallest units to largest units.
if... | go | func viewsByTimeRange(name string, start, end time.Time, q TimeQuantum) []string { // nolint: unparam
t := start
// Save flags for performance.
hasYear := q.HasYear()
hasMonth := q.HasMonth()
hasDay := q.HasDay()
hasHour := q.HasHour()
var results []string
// Walk up from smallest units to largest units.
if... | [
"func",
"viewsByTimeRange",
"(",
"name",
"string",
",",
"start",
",",
"end",
"time",
".",
"Time",
",",
"q",
"TimeQuantum",
")",
"[",
"]",
"string",
"{",
"// nolint: unparam",
"t",
":=",
"start",
"\n\n",
"// Save flags for performance.",
"hasYear",
":=",
"q",
... | // viewsByTimeRange returns a list of views to traverse to query a time range. | [
"viewsByTimeRange",
"returns",
"a",
"list",
"of",
"views",
"to",
"traverse",
"to",
"query",
"a",
"time",
"range",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/time.go#L104-L176 | train |
pilosa/pilosa | time.go | parseTime | func parseTime(t interface{}) (time.Time, error) {
var err error
var calcTime time.Time
switch v := t.(type) {
case string:
if calcTime, err = time.Parse(TimeFormat, v); err != nil {
return time.Time{}, errors.New("cannot parse string time")
}
case int64:
calcTime = time.Unix(v, 0).UTC()
default:
retur... | go | func parseTime(t interface{}) (time.Time, error) {
var err error
var calcTime time.Time
switch v := t.(type) {
case string:
if calcTime, err = time.Parse(TimeFormat, v); err != nil {
return time.Time{}, errors.New("cannot parse string time")
}
case int64:
calcTime = time.Unix(v, 0).UTC()
default:
retur... | [
"func",
"parseTime",
"(",
"t",
"interface",
"{",
"}",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"calcTime",
"time",
".",
"Time",
"\n",
"switch",
"v",
":=",
"t",
".",
"(",
"type",
")",
"{",
"case",
... | // parseTime parses a string or int64 into a time.Time value. | [
"parseTime",
"parses",
"a",
"string",
"or",
"int64",
"into",
"a",
"time",
".",
"Time",
"value",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/time.go#L220-L234 | train |
pilosa/pilosa | time.go | timeOfView | func timeOfView(v string, adj bool) (time.Time, error) {
if v == "" {
return time.Time{}, nil
}
layout := "2006010203"
timePart := viewTimePart(v)
switch len(timePart) {
case 4: // year
t, err := time.Parse(layout[:4], timePart)
if err != nil {
return time.Time{}, err
}
if adj {
t = t.AddDate(1,... | go | func timeOfView(v string, adj bool) (time.Time, error) {
if v == "" {
return time.Time{}, nil
}
layout := "2006010203"
timePart := viewTimePart(v)
switch len(timePart) {
case 4: // year
t, err := time.Parse(layout[:4], timePart)
if err != nil {
return time.Time{}, err
}
if adj {
t = t.AddDate(1,... | [
"func",
"timeOfView",
"(",
"v",
"string",
",",
"adj",
"bool",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"if",
"v",
"==",
"\"",
"\"",
"{",
"return",
"time",
".",
"Time",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n\n",
"layout",
":=",
"\"",... | // timeOfView returns a valid time.Time based on the view string.
// For upper bound use, the result can be adjusted by one by setting
// the `adj` argument to `true`. | [
"timeOfView",
"returns",
"a",
"valid",
"time",
".",
"Time",
"based",
"on",
"the",
"view",
"string",
".",
"For",
"upper",
"bound",
"use",
"the",
"result",
"can",
"be",
"adjusted",
"by",
"one",
"by",
"setting",
"the",
"adj",
"argument",
"to",
"true",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/time.go#L279-L327 | train |
pilosa/pilosa | cmd.go | NewCmdIO | func NewCmdIO(stdin io.Reader, stdout, stderr io.Writer) *CmdIO {
return &CmdIO{
Stdin: stdin,
Stdout: stdout,
Stderr: stderr,
}
} | go | func NewCmdIO(stdin io.Reader, stdout, stderr io.Writer) *CmdIO {
return &CmdIO{
Stdin: stdin,
Stdout: stdout,
Stderr: stderr,
}
} | [
"func",
"NewCmdIO",
"(",
"stdin",
"io",
".",
"Reader",
",",
"stdout",
",",
"stderr",
"io",
".",
"Writer",
")",
"*",
"CmdIO",
"{",
"return",
"&",
"CmdIO",
"{",
"Stdin",
":",
"stdin",
",",
"Stdout",
":",
"stdout",
",",
"Stderr",
":",
"stderr",
",",
"... | // NewCmdIO returns a new instance of CmdIO with inputs and outputs set to the
// arguments. | [
"NewCmdIO",
"returns",
"a",
"new",
"instance",
"of",
"CmdIO",
"with",
"inputs",
"and",
"outputs",
"set",
"to",
"the",
"arguments",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/cmd.go#L28-L34 | train |
pilosa/pilosa | executor.go | newExecutor | func newExecutor(opts ...executorOption) *executor {
e := &executor{
client: newNopInternalQueryClient(),
}
for _, opt := range opts {
err := opt(e)
if err != nil {
panic(err)
}
}
return e
} | go | func newExecutor(opts ...executorOption) *executor {
e := &executor{
client: newNopInternalQueryClient(),
}
for _, opt := range opts {
err := opt(e)
if err != nil {
panic(err)
}
}
return e
} | [
"func",
"newExecutor",
"(",
"opts",
"...",
"executorOption",
")",
"*",
"executor",
"{",
"e",
":=",
"&",
"executor",
"{",
"client",
":",
"newNopInternalQueryClient",
"(",
")",
",",
"}",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"err",
":... | // newExecutor returns a new instance of Executor. | [
"newExecutor",
"returns",
"a",
"new",
"instance",
"of",
"Executor",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L71-L82 | train |
pilosa/pilosa | executor.go | Execute | func (e *executor) Execute(ctx context.Context, index string, q *pql.Query, shards []uint64, opt *execOptions) (QueryResponse, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.Execute")
defer span.Finish()
resp := QueryResponse{}
// Check for query cancellation.
if err := validateQueryContext(ct... | go | func (e *executor) Execute(ctx context.Context, index string, q *pql.Query, shards []uint64, opt *execOptions) (QueryResponse, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.Execute")
defer span.Finish()
resp := QueryResponse{}
// Check for query cancellation.
if err := validateQueryContext(ct... | [
"func",
"(",
"e",
"*",
"executor",
")",
"Execute",
"(",
"ctx",
"context",
".",
"Context",
",",
"index",
"string",
",",
"q",
"*",
"pql",
".",
"Query",
",",
"shards",
"[",
"]",
"uint64",
",",
"opt",
"*",
"execOptions",
")",
"(",
"QueryResponse",
",",
... | // Execute executes a PQL query. | [
"Execute",
"executes",
"a",
"PQL",
"query",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L85-L178 | train |
pilosa/pilosa | executor.go | readColumnAttrSets | func (e *executor) readColumnAttrSets(index *Index, ids []uint64) ([]*ColumnAttrSet, error) {
if index == nil {
return nil, nil
}
ax := make([]*ColumnAttrSet, 0, len(ids))
for _, id := range ids {
// Read attributes for column. Skip column if empty.
attrs, err := index.ColumnAttrStore().Attrs(id)
if err !=... | go | func (e *executor) readColumnAttrSets(index *Index, ids []uint64) ([]*ColumnAttrSet, error) {
if index == nil {
return nil, nil
}
ax := make([]*ColumnAttrSet, 0, len(ids))
for _, id := range ids {
// Read attributes for column. Skip column if empty.
attrs, err := index.ColumnAttrStore().Attrs(id)
if err !=... | [
"func",
"(",
"e",
"*",
"executor",
")",
"readColumnAttrSets",
"(",
"index",
"*",
"Index",
",",
"ids",
"[",
"]",
"uint64",
")",
"(",
"[",
"]",
"*",
"ColumnAttrSet",
",",
"error",
")",
"{",
"if",
"index",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil"... | // readColumnAttrSets returns a list of column attribute objects by id. | [
"readColumnAttrSets",
"returns",
"a",
"list",
"of",
"column",
"attribute",
"objects",
"by",
"id",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L181-L201 | train |
pilosa/pilosa | executor.go | validateCallArgs | func (e *executor) validateCallArgs(c *pql.Call) error {
if _, ok := c.Args["ids"]; ok {
switch v := c.Args["ids"].(type) {
case []int64, []uint64:
// noop
case []interface{}:
b := make([]int64, len(v))
for i := range v {
b[i] = v[i].(int64)
}
c.Args["ids"] = b
default:
return fmt.Errorf(... | go | func (e *executor) validateCallArgs(c *pql.Call) error {
if _, ok := c.Args["ids"]; ok {
switch v := c.Args["ids"].(type) {
case []int64, []uint64:
// noop
case []interface{}:
b := make([]int64, len(v))
for i := range v {
b[i] = v[i].(int64)
}
c.Args["ids"] = b
default:
return fmt.Errorf(... | [
"func",
"(",
"e",
"*",
"executor",
")",
"validateCallArgs",
"(",
"c",
"*",
"pql",
".",
"Call",
")",
"error",
"{",
"if",
"_",
",",
"ok",
":=",
"c",
".",
"Args",
"[",
"\"",
"\"",
"]",
";",
"ok",
"{",
"switch",
"v",
":=",
"c",
".",
"Args",
"[",
... | // validateCallArgs ensures that the value types in call.Args are expected. | [
"validateCallArgs",
"ensures",
"that",
"the",
"value",
"types",
"in",
"call",
".",
"Args",
"are",
"expected",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L300-L316 | train |
pilosa/pilosa | executor.go | executeBitmapCall | func (e *executor) executeBitmapCall(ctx context.Context, index string, c *pql.Call, shards []uint64, opt *execOptions) (*Row, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeBitmapCall")
defer span.Finish()
// Execute calls in bulk on each remote node and merge.
mapFn := func(shard uint64... | go | func (e *executor) executeBitmapCall(ctx context.Context, index string, c *pql.Call, shards []uint64, opt *execOptions) (*Row, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeBitmapCall")
defer span.Finish()
// Execute calls in bulk on each remote node and merge.
mapFn := func(shard uint64... | [
"func",
"(",
"e",
"*",
"executor",
")",
"executeBitmapCall",
"(",
"ctx",
"context",
".",
"Context",
",",
"index",
"string",
",",
"c",
"*",
"pql",
".",
"Call",
",",
"shards",
"[",
"]",
"uint64",
",",
"opt",
"*",
"execOptions",
")",
"(",
"*",
"Row",
... | // executeBitmapCall executes a call that returns a bitmap. | [
"executeBitmapCall",
"executes",
"a",
"call",
"that",
"returns",
"a",
"bitmap",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L472-L538 | train |
pilosa/pilosa | executor.go | executeBitmapCallShard | func (e *executor) executeBitmapCallShard(ctx context.Context, index string, c *pql.Call, shard uint64) (*Row, error) {
if err := validateQueryContext(ctx); err != nil {
return nil, err
}
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeBitmapCallShard")
defer span.Finish()
switch c.Name {
case... | go | func (e *executor) executeBitmapCallShard(ctx context.Context, index string, c *pql.Call, shard uint64) (*Row, error) {
if err := validateQueryContext(ctx); err != nil {
return nil, err
}
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeBitmapCallShard")
defer span.Finish()
switch c.Name {
case... | [
"func",
"(",
"e",
"*",
"executor",
")",
"executeBitmapCallShard",
"(",
"ctx",
"context",
".",
"Context",
",",
"index",
"string",
",",
"c",
"*",
"pql",
".",
"Call",
",",
"shard",
"uint64",
")",
"(",
"*",
"Row",
",",
"error",
")",
"{",
"if",
"err",
"... | // executeBitmapCallShard executes a bitmap call for a single shard. | [
"executeBitmapCallShard",
"executes",
"a",
"bitmap",
"call",
"for",
"a",
"single",
"shard",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L541-L567 | train |
pilosa/pilosa | executor.go | executeSumCountShard | func (e *executor) executeSumCountShard(ctx context.Context, index string, c *pql.Call, shard uint64) (ValCount, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeSumCountShard")
defer span.Finish()
var filter *Row
if len(c.Children) == 1 {
row, err := e.executeBitmapCallShard(ctx, index, ... | go | func (e *executor) executeSumCountShard(ctx context.Context, index string, c *pql.Call, shard uint64) (ValCount, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeSumCountShard")
defer span.Finish()
var filter *Row
if len(c.Children) == 1 {
row, err := e.executeBitmapCallShard(ctx, index, ... | [
"func",
"(",
"e",
"*",
"executor",
")",
"executeSumCountShard",
"(",
"ctx",
"context",
".",
"Context",
",",
"index",
"string",
",",
"c",
"*",
"pql",
".",
"Call",
",",
"shard",
"uint64",
")",
"(",
"ValCount",
",",
"error",
")",
"{",
"span",
",",
"ctx"... | // executeSumCountShard calculates the sum and count for bsiGroups on a shard. | [
"executeSumCountShard",
"calculates",
"the",
"sum",
"and",
"count",
"for",
"bsiGroups",
"on",
"a",
"shard",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L570-L608 | train |
pilosa/pilosa | executor.go | executeTopNShard | func (e *executor) executeTopNShard(ctx context.Context, index string, c *pql.Call, shard uint64) ([]Pair, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeTopNShard")
defer span.Finish()
field, _ := c.Args["_field"].(string)
n, _, err := c.UintArg("n")
if err != nil {
return nil, fmt.Er... | go | func (e *executor) executeTopNShard(ctx context.Context, index string, c *pql.Call, shard uint64) ([]Pair, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeTopNShard")
defer span.Finish()
field, _ := c.Args["_field"].(string)
n, _, err := c.UintArg("n")
if err != nil {
return nil, fmt.Er... | [
"func",
"(",
"e",
"*",
"executor",
")",
"executeTopNShard",
"(",
"ctx",
"context",
".",
"Context",
",",
"index",
"string",
",",
"c",
"*",
"pql",
".",
"Call",
",",
"shard",
"uint64",
")",
"(",
"[",
"]",
"Pair",
",",
"error",
")",
"{",
"span",
",",
... | // executeTopNShard executes a TopN call for a single shard. | [
"executeTopNShard",
"executes",
"a",
"TopN",
"call",
"for",
"a",
"single",
"shard",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L765-L827 | train |
pilosa/pilosa | executor.go | MarshalJSON | func (fr FieldRow) MarshalJSON() ([]byte, error) {
if fr.RowKey != "" {
return json.Marshal(struct {
Field string `json:"field"`
RowKey string `json:"rowKey"`
}{
Field: fr.Field,
RowKey: fr.RowKey,
})
}
return json.Marshal(struct {
Field string `json:"field"`
RowID uint64 `json:"rowID"`
}{
... | go | func (fr FieldRow) MarshalJSON() ([]byte, error) {
if fr.RowKey != "" {
return json.Marshal(struct {
Field string `json:"field"`
RowKey string `json:"rowKey"`
}{
Field: fr.Field,
RowKey: fr.RowKey,
})
}
return json.Marshal(struct {
Field string `json:"field"`
RowID uint64 `json:"rowID"`
}{
... | [
"func",
"(",
"fr",
"FieldRow",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"fr",
".",
"RowKey",
"!=",
"\"",
"\"",
"{",
"return",
"json",
".",
"Marshal",
"(",
"struct",
"{",
"Field",
"string",
"`json:\"field\"`",... | // MarshalJSON marshals FieldRow to JSON such that
// either a Key or an ID is included. | [
"MarshalJSON",
"marshals",
"FieldRow",
"to",
"JSON",
"such",
"that",
"either",
"a",
"Key",
"or",
"an",
"ID",
"is",
"included",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L992-L1009 | train |
pilosa/pilosa | executor.go | String | func (fr FieldRow) String() string {
return fmt.Sprintf("%s.%d.%s", fr.Field, fr.RowID, fr.RowKey)
} | go | func (fr FieldRow) String() string {
return fmt.Sprintf("%s.%d.%s", fr.Field, fr.RowID, fr.RowKey)
} | [
"func",
"(",
"fr",
"FieldRow",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"fr",
".",
"Field",
",",
"fr",
".",
"RowID",
",",
"fr",
".",
"RowKey",
")",
"\n",
"}"
] | // String is the FieldRow stringer. | [
"String",
"is",
"the",
"FieldRow",
"stringer",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L1012-L1014 | train |
pilosa/pilosa | executor.go | mergeGroupCounts | func mergeGroupCounts(a, b []GroupCount, limit int) []GroupCount {
if limit > len(a)+len(b) {
limit = len(a) + len(b)
}
ret := make([]GroupCount, 0, limit)
i, j := 0, 0
for i < len(a) && j < len(b) && len(ret) < limit {
switch a[i].Compare(b[j]) {
case -1:
ret = append(ret, a[i])
i++
case 0:
a[i].... | go | func mergeGroupCounts(a, b []GroupCount, limit int) []GroupCount {
if limit > len(a)+len(b) {
limit = len(a) + len(b)
}
ret := make([]GroupCount, 0, limit)
i, j := 0, 0
for i < len(a) && j < len(b) && len(ret) < limit {
switch a[i].Compare(b[j]) {
case -1:
ret = append(ret, a[i])
i++
case 0:
a[i].... | [
"func",
"mergeGroupCounts",
"(",
"a",
",",
"b",
"[",
"]",
"GroupCount",
",",
"limit",
"int",
")",
"[",
"]",
"GroupCount",
"{",
"if",
"limit",
">",
"len",
"(",
"a",
")",
"+",
"len",
"(",
"b",
")",
"{",
"limit",
"=",
"len",
"(",
"a",
")",
"+",
... | // mergeGroupCounts merges two slices of GroupCounts throwing away any that go
// beyond the limit. It assume that the two slices are sorted by the row ids in
// the fields of the group counts. It may modify its arguments. | [
"mergeGroupCounts",
"merges",
"two",
"slices",
"of",
"GroupCounts",
"throwing",
"away",
"any",
"that",
"go",
"beyond",
"the",
"limit",
".",
"It",
"assume",
"that",
"the",
"two",
"slices",
"are",
"sorted",
"by",
"the",
"row",
"ids",
"in",
"the",
"fields",
"... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L1025-L1053 | train |
pilosa/pilosa | executor.go | Compare | func (g GroupCount) Compare(o GroupCount) int {
for i := range g.Group {
if g.Group[i].RowID < o.Group[i].RowID {
return -1
}
if g.Group[i].RowID > o.Group[i].RowID {
return 1
}
}
return 0
} | go | func (g GroupCount) Compare(o GroupCount) int {
for i := range g.Group {
if g.Group[i].RowID < o.Group[i].RowID {
return -1
}
if g.Group[i].RowID > o.Group[i].RowID {
return 1
}
}
return 0
} | [
"func",
"(",
"g",
"GroupCount",
")",
"Compare",
"(",
"o",
"GroupCount",
")",
"int",
"{",
"for",
"i",
":=",
"range",
"g",
".",
"Group",
"{",
"if",
"g",
".",
"Group",
"[",
"i",
"]",
".",
"RowID",
"<",
"o",
".",
"Group",
"[",
"i",
"]",
".",
"Row... | // Compare is used in ordering two GroupCount objects. | [
"Compare",
"is",
"used",
"in",
"ordering",
"two",
"GroupCount",
"objects",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L1056-L1066 | train |
pilosa/pilosa | executor.go | remoteExec | func (e *executor) remoteExec(ctx context.Context, node *Node, index string, q *pql.Query, shards []uint64) (results []interface{}, err error) { // nolint: interfacer
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeExec")
defer span.Finish()
// Encode request object.
pbreq := &QueryRequest{
Query... | go | func (e *executor) remoteExec(ctx context.Context, node *Node, index string, q *pql.Query, shards []uint64) (results []interface{}, err error) { // nolint: interfacer
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeExec")
defer span.Finish()
// Encode request object.
pbreq := &QueryRequest{
Query... | [
"func",
"(",
"e",
"*",
"executor",
")",
"remoteExec",
"(",
"ctx",
"context",
".",
"Context",
",",
"node",
"*",
"Node",
",",
"index",
"string",
",",
"q",
"*",
"pql",
".",
"Query",
",",
"shards",
"[",
"]",
"uint64",
")",
"(",
"results",
"[",
"]",
"... | // remoteExec executes a PQL query remotely for a set of shards on a node. | [
"remoteExec",
"executes",
"a",
"PQL",
"query",
"remotely",
"for",
"a",
"set",
"of",
"shards",
"on",
"a",
"node",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L2242-L2259 | train |
pilosa/pilosa | executor.go | shardsByNode | func (e *executor) shardsByNode(nodes []*Node, index string, shards []uint64) (map[*Node][]uint64, error) {
m := make(map[*Node][]uint64)
loop:
for _, shard := range shards {
for _, node := range e.Cluster.ShardNodes(index, shard) {
if Nodes(nodes).Contains(node) {
m[node] = append(m[node], shard)
conti... | go | func (e *executor) shardsByNode(nodes []*Node, index string, shards []uint64) (map[*Node][]uint64, error) {
m := make(map[*Node][]uint64)
loop:
for _, shard := range shards {
for _, node := range e.Cluster.ShardNodes(index, shard) {
if Nodes(nodes).Contains(node) {
m[node] = append(m[node], shard)
conti... | [
"func",
"(",
"e",
"*",
"executor",
")",
"shardsByNode",
"(",
"nodes",
"[",
"]",
"*",
"Node",
",",
"index",
"string",
",",
"shards",
"[",
"]",
"uint64",
")",
"(",
"map",
"[",
"*",
"Node",
"]",
"[",
"]",
"uint64",
",",
"error",
")",
"{",
"m",
":=... | // shardsByNode returns a mapping of nodes to shards.
// Returns errShardUnavailable if a shard cannot be allocated to a node. | [
"shardsByNode",
"returns",
"a",
"mapping",
"of",
"nodes",
"to",
"shards",
".",
"Returns",
"errShardUnavailable",
"if",
"a",
"shard",
"cannot",
"be",
"allocated",
"to",
"a",
"node",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L2263-L2277 | train |
pilosa/pilosa | executor.go | mapReduce | func (e *executor) mapReduce(ctx context.Context, index string, shards []uint64, c *pql.Call, opt *execOptions, mapFn mapFunc, reduceFn reduceFunc) (interface{}, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.mapReduce")
defer span.Finish()
ch := make(chan mapResponse)
// Wrap context with a ca... | go | func (e *executor) mapReduce(ctx context.Context, index string, shards []uint64, c *pql.Call, opt *execOptions, mapFn mapFunc, reduceFn reduceFunc) (interface{}, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.mapReduce")
defer span.Finish()
ch := make(chan mapResponse)
// Wrap context with a ca... | [
"func",
"(",
"e",
"*",
"executor",
")",
"mapReduce",
"(",
"ctx",
"context",
".",
"Context",
",",
"index",
"string",
",",
"shards",
"[",
"]",
"uint64",
",",
"c",
"*",
"pql",
".",
"Call",
",",
"opt",
"*",
"execOptions",
",",
"mapFn",
"mapFunc",
",",
... | // mapReduce maps and reduces data across the cluster.
//
// If a mapping of shards to a node fails then the shards are resplit across
// secondary nodes and retried. This continues to occur until all nodes are exhausted. | [
"mapReduce",
"maps",
"and",
"reduces",
"data",
"across",
"the",
"cluster",
".",
"If",
"a",
"mapping",
"of",
"shards",
"to",
"a",
"node",
"fails",
"then",
"the",
"shards",
"are",
"resplit",
"across",
"secondary",
"nodes",
"and",
"retried",
".",
"This",
"con... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L2283-L2343 | train |
pilosa/pilosa | executor.go | mapperLocal | func (e *executor) mapperLocal(ctx context.Context, shards []uint64, mapFn mapFunc, reduceFn reduceFunc) (interface{}, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.mapperLocal")
defer span.Finish()
ch := make(chan mapResponse, len(shards))
for _, shard := range shards {
go func(shard uint64... | go | func (e *executor) mapperLocal(ctx context.Context, shards []uint64, mapFn mapFunc, reduceFn reduceFunc) (interface{}, error) {
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.mapperLocal")
defer span.Finish()
ch := make(chan mapResponse, len(shards))
for _, shard := range shards {
go func(shard uint64... | [
"func",
"(",
"e",
"*",
"executor",
")",
"mapperLocal",
"(",
"ctx",
"context",
".",
"Context",
",",
"shards",
"[",
"]",
"uint64",
",",
"mapFn",
"mapFunc",
",",
"reduceFn",
"reduceFunc",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"span",
... | // mapperLocal performs map & reduce entirely on the local node. | [
"mapperLocal",
"performs",
"map",
"&",
"reduce",
"entirely",
"on",
"the",
"local",
"node",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L2383-L2421 | train |
pilosa/pilosa | executor.go | validateQueryContext | func validateQueryContext(ctx context.Context) error {
select {
case <-ctx.Done():
switch err := ctx.Err(); err {
case context.Canceled:
return ErrQueryCancelled
case context.DeadlineExceeded:
return ErrQueryTimeout
default:
return err
}
default:
return nil
}
} | go | func validateQueryContext(ctx context.Context) error {
select {
case <-ctx.Done():
switch err := ctx.Err(); err {
case context.Canceled:
return ErrQueryCancelled
case context.DeadlineExceeded:
return ErrQueryTimeout
default:
return err
}
default:
return nil
}
} | [
"func",
"validateQueryContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"switch",
"err",
":=",
"ctx",
".",
"Err",
"(",
")",
";",
"err",
"{",
"case",
"context",
".",
"... | // validateQueryContext returns a query-appropriate error if the context is done. | [
"validateQueryContext",
"returns",
"a",
"query",
"-",
"appropriate",
"error",
"if",
"the",
"context",
"is",
"done",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L2691-L2705 | train |
pilosa/pilosa | executor.go | smaller | func (vc *ValCount) smaller(other ValCount) ValCount {
if vc.Count == 0 || (other.Val < vc.Val && other.Count > 0) {
return other
}
return ValCount{
Val: vc.Val,
Count: vc.Count,
}
} | go | func (vc *ValCount) smaller(other ValCount) ValCount {
if vc.Count == 0 || (other.Val < vc.Val && other.Count > 0) {
return other
}
return ValCount{
Val: vc.Val,
Count: vc.Count,
}
} | [
"func",
"(",
"vc",
"*",
"ValCount",
")",
"smaller",
"(",
"other",
"ValCount",
")",
"ValCount",
"{",
"if",
"vc",
".",
"Count",
"==",
"0",
"||",
"(",
"other",
".",
"Val",
"<",
"vc",
".",
"Val",
"&&",
"other",
".",
"Count",
">",
"0",
")",
"{",
"re... | // smaller returns the smaller of the two ValCounts. | [
"smaller",
"returns",
"the",
"smaller",
"of",
"the",
"two",
"ValCounts",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L2776-L2784 | train |
pilosa/pilosa | executor.go | larger | func (vc *ValCount) larger(other ValCount) ValCount {
if vc.Count == 0 || (other.Val > vc.Val && other.Count > 0) {
return other
}
return ValCount{
Val: vc.Val,
Count: vc.Count,
}
} | go | func (vc *ValCount) larger(other ValCount) ValCount {
if vc.Count == 0 || (other.Val > vc.Val && other.Count > 0) {
return other
}
return ValCount{
Val: vc.Val,
Count: vc.Count,
}
} | [
"func",
"(",
"vc",
"*",
"ValCount",
")",
"larger",
"(",
"other",
"ValCount",
")",
"ValCount",
"{",
"if",
"vc",
".",
"Count",
"==",
"0",
"||",
"(",
"other",
".",
"Val",
">",
"vc",
".",
"Val",
"&&",
"other",
".",
"Count",
">",
"0",
")",
"{",
"ret... | // larger returns the larger of the two ValCounts. | [
"larger",
"returns",
"the",
"larger",
"of",
"the",
"two",
"ValCounts",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L2787-L2795 | train |
pilosa/pilosa | executor.go | nextAtIdx | func (gbi *groupByIterator) nextAtIdx(i int) {
// loop until we find a non-empty row. This is an optimization - the loop and if/break can be removed.
for {
nr, rowID, wrapped := gbi.rowIters[i].Next()
if nr == nil {
gbi.done = true
return
}
if wrapped && i != 0 {
gbi.nextAtIdx(i - 1)
}
if i == 0 ... | go | func (gbi *groupByIterator) nextAtIdx(i int) {
// loop until we find a non-empty row. This is an optimization - the loop and if/break can be removed.
for {
nr, rowID, wrapped := gbi.rowIters[i].Next()
if nr == nil {
gbi.done = true
return
}
if wrapped && i != 0 {
gbi.nextAtIdx(i - 1)
}
if i == 0 ... | [
"func",
"(",
"gbi",
"*",
"groupByIterator",
")",
"nextAtIdx",
"(",
"i",
"int",
")",
"{",
"// loop until we find a non-empty row. This is an optimization - the loop and if/break can be removed.",
"for",
"{",
"nr",
",",
"rowID",
",",
"wrapped",
":=",
"gbi",
".",
"rowIters... | // nextAtIdx is a recursive helper method for getting the next row for the field
// at index i, and then updating the rows in the "higher" fields if it wraps. | [
"nextAtIdx",
"is",
"a",
"recursive",
"helper",
"method",
"for",
"getting",
"the",
"next",
"row",
"for",
"the",
"field",
"at",
"index",
"i",
"and",
"then",
"updating",
"the",
"rows",
"in",
"the",
"higher",
"fields",
"if",
"it",
"wraps",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L2939-L2963 | train |
pilosa/pilosa | executor.go | Next | func (gbi *groupByIterator) Next() (ret GroupCount, done bool) {
// loop until we find a result with count > 0
for {
if gbi.done {
return ret, true
}
if len(gbi.rows) == 1 {
ret.Count = gbi.rows[len(gbi.rows)-1].row.Count()
} else {
ret.Count = gbi.rows[len(gbi.rows)-1].row.intersectionCount(gbi.rows... | go | func (gbi *groupByIterator) Next() (ret GroupCount, done bool) {
// loop until we find a result with count > 0
for {
if gbi.done {
return ret, true
}
if len(gbi.rows) == 1 {
ret.Count = gbi.rows[len(gbi.rows)-1].row.Count()
} else {
ret.Count = gbi.rows[len(gbi.rows)-1].row.intersectionCount(gbi.rows... | [
"func",
"(",
"gbi",
"*",
"groupByIterator",
")",
"Next",
"(",
")",
"(",
"ret",
"GroupCount",
",",
"done",
"bool",
")",
"{",
"// loop until we find a result with count > 0",
"for",
"{",
"if",
"gbi",
".",
"done",
"{",
"return",
"ret",
",",
"true",
"\n",
"}",... | // Next returns a GroupCount representing the next group by record. When there
// are no more records it will return an empty GroupCount and done==true. | [
"Next",
"returns",
"a",
"GroupCount",
"representing",
"the",
"next",
"group",
"by",
"record",
".",
"When",
"there",
"are",
"no",
"more",
"records",
"it",
"will",
"return",
"an",
"empty",
"GroupCount",
"and",
"done",
"==",
"true",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/executor.go#L2967-L2996 | train |
pilosa/pilosa | diagnostics.go | SetVersion | func (d *diagnosticsCollector) SetVersion(v string) {
d.version = v
d.Set("Version", v)
} | go | func (d *diagnosticsCollector) SetVersion(v string) {
d.version = v
d.Set("Version", v)
} | [
"func",
"(",
"d",
"*",
"diagnosticsCollector",
")",
"SetVersion",
"(",
"v",
"string",
")",
"{",
"d",
".",
"version",
"=",
"v",
"\n",
"d",
".",
"Set",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}"
] | // SetVersion of locally running Pilosa Cluster to check against master. | [
"SetVersion",
"of",
"locally",
"running",
"Pilosa",
"Cluster",
"to",
"check",
"against",
"master",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/diagnostics.go#L74-L77 | train |
pilosa/pilosa | diagnostics.go | Flush | func (d *diagnosticsCollector) Flush() error {
d.mu.Lock()
defer d.mu.Unlock()
d.metrics["Uptime"] = (time.Now().Unix() - d.startTime)
buf, err := d.encode()
if err != nil {
return errors.Wrap(err, "encoding")
}
req, err := http.NewRequest("POST", d.host, bytes.NewReader(buf))
if err != nil {
return errors.... | go | func (d *diagnosticsCollector) Flush() error {
d.mu.Lock()
defer d.mu.Unlock()
d.metrics["Uptime"] = (time.Now().Unix() - d.startTime)
buf, err := d.encode()
if err != nil {
return errors.Wrap(err, "encoding")
}
req, err := http.NewRequest("POST", d.host, bytes.NewReader(buf))
if err != nil {
return errors.... | [
"func",
"(",
"d",
"*",
"diagnosticsCollector",
")",
"Flush",
"(",
")",
"error",
"{",
"d",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"d",
".",
"metrics",
"[",
"\"",
"\"",
"]",
"=",
"(",
"ti... | // Flush sends the current metrics. | [
"Flush",
"sends",
"the",
"current",
"metrics",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/diagnostics.go#L80-L100 | train |
pilosa/pilosa | diagnostics.go | CheckVersion | func (d *diagnosticsCollector) CheckVersion() error {
var rsp versionResponse
req, err := http.NewRequest("GET", d.VersionURL, nil)
if err != nil {
return errors.Wrap(err, "making request")
}
resp, err := d.client.Do(req)
if err != nil {
return errors.Wrap(err, "getting version")
}
defer resp.Body.Close()
... | go | func (d *diagnosticsCollector) CheckVersion() error {
var rsp versionResponse
req, err := http.NewRequest("GET", d.VersionURL, nil)
if err != nil {
return errors.Wrap(err, "making request")
}
resp, err := d.client.Do(req)
if err != nil {
return errors.Wrap(err, "getting version")
}
defer resp.Body.Close()
... | [
"func",
"(",
"d",
"*",
"diagnosticsCollector",
")",
"CheckVersion",
"(",
")",
"error",
"{",
"var",
"rsp",
"versionResponse",
"\n",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"d",
".",
"VersionURL",
",",
"nil",
")",
"\n",
... | // CheckVersion of the local build against Pilosa master. | [
"CheckVersion",
"of",
"the",
"local",
"build",
"against",
"Pilosa",
"master",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/diagnostics.go#L103-L132 | train |
pilosa/pilosa | diagnostics.go | compareVersion | func (d *diagnosticsCollector) compareVersion(value string) error {
currentVersion := versionSegments(value)
localVersion := versionSegments(d.version)
if localVersion[0] < currentVersion[0] { //Major
return fmt.Errorf("you are running Pilosa %s, a newer version (%s) is available: https://github.com/pilosa/pilosa... | go | func (d *diagnosticsCollector) compareVersion(value string) error {
currentVersion := versionSegments(value)
localVersion := versionSegments(d.version)
if localVersion[0] < currentVersion[0] { //Major
return fmt.Errorf("you are running Pilosa %s, a newer version (%s) is available: https://github.com/pilosa/pilosa... | [
"func",
"(",
"d",
"*",
"diagnosticsCollector",
")",
"compareVersion",
"(",
"value",
"string",
")",
"error",
"{",
"currentVersion",
":=",
"versionSegments",
"(",
"value",
")",
"\n",
"localVersion",
":=",
"versionSegments",
"(",
"d",
".",
"version",
")",
"\n\n",... | // compareVersion check version strings. | [
"compareVersion",
"check",
"version",
"strings",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/diagnostics.go#L135-L148 | train |
pilosa/pilosa | diagnostics.go | Set | func (d *diagnosticsCollector) Set(name string, value interface{}) {
switch v := value.(type) {
case string:
if v == "" {
// Do not set empty string
return
}
}
d.mu.Lock()
defer d.mu.Unlock()
d.metrics[name] = value
} | go | func (d *diagnosticsCollector) Set(name string, value interface{}) {
switch v := value.(type) {
case string:
if v == "" {
// Do not set empty string
return
}
}
d.mu.Lock()
defer d.mu.Unlock()
d.metrics[name] = value
} | [
"func",
"(",
"d",
"*",
"diagnosticsCollector",
")",
"Set",
"(",
"name",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"switch",
"v",
":=",
"value",
".",
"(",
"type",
")",
"{",
"case",
"string",
":",
"if",
"v",
"==",
"\"",
"\"",
"{",
"/... | // Set adds a key value metric. | [
"Set",
"adds",
"a",
"key",
"value",
"metric",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/diagnostics.go#L156-L167 | train |
pilosa/pilosa | diagnostics.go | logErr | func (d *diagnosticsCollector) logErr(err error) bool {
if err != nil {
d.Logger.Printf("%v", err)
return true
}
return false
} | go | func (d *diagnosticsCollector) logErr(err error) bool {
if err != nil {
d.Logger.Printf("%v", err)
return true
}
return false
} | [
"func",
"(",
"d",
"*",
"diagnosticsCollector",
")",
"logErr",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"!=",
"nil",
"{",
"d",
".",
"Logger",
".",
"Printf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"true",
"\n",
"}",
"\n",
"ret... | // logErr logs the error and returns true if an error exists | [
"logErr",
"logs",
"the",
"error",
"and",
"returns",
"true",
"if",
"an",
"error",
"exists"
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/diagnostics.go#L170-L176 | train |
pilosa/pilosa | diagnostics.go | EnrichWithOSInfo | func (d *diagnosticsCollector) EnrichWithOSInfo() {
uptime, err := d.server.systemInfo.Uptime()
if !d.logErr(err) {
d.Set("HostUptime", uptime)
}
platform, err := d.server.systemInfo.Platform()
if !d.logErr(err) {
d.Set("OSPlatform", platform)
}
family, err := d.server.systemInfo.Family()
if !d.logErr(err) ... | go | func (d *diagnosticsCollector) EnrichWithOSInfo() {
uptime, err := d.server.systemInfo.Uptime()
if !d.logErr(err) {
d.Set("HostUptime", uptime)
}
platform, err := d.server.systemInfo.Platform()
if !d.logErr(err) {
d.Set("OSPlatform", platform)
}
family, err := d.server.systemInfo.Family()
if !d.logErr(err) ... | [
"func",
"(",
"d",
"*",
"diagnosticsCollector",
")",
"EnrichWithOSInfo",
"(",
")",
"{",
"uptime",
",",
"err",
":=",
"d",
".",
"server",
".",
"systemInfo",
".",
"Uptime",
"(",
")",
"\n",
"if",
"!",
"d",
".",
"logErr",
"(",
"err",
")",
"{",
"d",
".",
... | // EnrichWithOSInfo adds OS information to the diagnostics payload. | [
"EnrichWithOSInfo",
"adds",
"OS",
"information",
"to",
"the",
"diagnostics",
"payload",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/diagnostics.go#L184-L205 | train |
pilosa/pilosa | diagnostics.go | EnrichWithMemoryInfo | func (d *diagnosticsCollector) EnrichWithMemoryInfo() {
memFree, err := d.server.systemInfo.MemFree()
if !d.logErr(err) {
d.Set("MemFree", memFree)
}
memTotal, err := d.server.systemInfo.MemTotal()
if !d.logErr(err) {
d.Set("MemTotal", memTotal)
}
memUsed, err := d.server.systemInfo.MemUsed()
if !d.logErr(e... | go | func (d *diagnosticsCollector) EnrichWithMemoryInfo() {
memFree, err := d.server.systemInfo.MemFree()
if !d.logErr(err) {
d.Set("MemFree", memFree)
}
memTotal, err := d.server.systemInfo.MemTotal()
if !d.logErr(err) {
d.Set("MemTotal", memTotal)
}
memUsed, err := d.server.systemInfo.MemUsed()
if !d.logErr(e... | [
"func",
"(",
"d",
"*",
"diagnosticsCollector",
")",
"EnrichWithMemoryInfo",
"(",
")",
"{",
"memFree",
",",
"err",
":=",
"d",
".",
"server",
".",
"systemInfo",
".",
"MemFree",
"(",
")",
"\n",
"if",
"!",
"d",
".",
"logErr",
"(",
"err",
")",
"{",
"d",
... | // EnrichWithMemoryInfo adds memory information to the diagnostics payload. | [
"EnrichWithMemoryInfo",
"adds",
"memory",
"information",
"to",
"the",
"diagnostics",
"payload",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/diagnostics.go#L208-L221 | train |
pilosa/pilosa | diagnostics.go | EnrichWithSchemaProperties | func (d *diagnosticsCollector) EnrichWithSchemaProperties() {
var numShards uint64
numFields := 0
numIndexes := 0
bsiFieldCount := 0
timeQuantumEnabled := false
for _, index := range d.server.holder.Indexes() {
numShards += index.AvailableShards().Count()
numIndexes++
for _, field := range index.Fields() {... | go | func (d *diagnosticsCollector) EnrichWithSchemaProperties() {
var numShards uint64
numFields := 0
numIndexes := 0
bsiFieldCount := 0
timeQuantumEnabled := false
for _, index := range d.server.holder.Indexes() {
numShards += index.AvailableShards().Count()
numIndexes++
for _, field := range index.Fields() {... | [
"func",
"(",
"d",
"*",
"diagnosticsCollector",
")",
"EnrichWithSchemaProperties",
"(",
")",
"{",
"var",
"numShards",
"uint64",
"\n",
"numFields",
":=",
"0",
"\n",
"numIndexes",
":=",
"0",
"\n",
"bsiFieldCount",
":=",
"0",
"\n",
"timeQuantumEnabled",
":=",
"fal... | // EnrichWithSchemaProperties adds schema info to the diagnostics payload. | [
"EnrichWithSchemaProperties",
"adds",
"schema",
"info",
"to",
"the",
"diagnostics",
"payload",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/diagnostics.go#L224-L250 | train |
pilosa/pilosa | diagnostics.go | versionSegments | func versionSegments(segments string) []int {
segments = strings.Trim(segments, "v")
segments = strings.Split(segments, "-")[0]
s := strings.Split(segments, ".")
segmentSlice := make([]int, len(s))
for i, v := range s {
segmentSlice[i], _ = strconv.Atoi(v)
}
return segmentSlice
} | go | func versionSegments(segments string) []int {
segments = strings.Trim(segments, "v")
segments = strings.Split(segments, "-")[0]
s := strings.Split(segments, ".")
segmentSlice := make([]int, len(s))
for i, v := range s {
segmentSlice[i], _ = strconv.Atoi(v)
}
return segmentSlice
} | [
"func",
"versionSegments",
"(",
"segments",
"string",
")",
"[",
"]",
"int",
"{",
"segments",
"=",
"strings",
".",
"Trim",
"(",
"segments",
",",
"\"",
"\"",
")",
"\n",
"segments",
"=",
"strings",
".",
"Split",
"(",
"segments",
",",
"\"",
"\"",
")",
"[... | // versionSegments returns the numeric segments of the version as a slice of ints. | [
"versionSegments",
"returns",
"the",
"numeric",
"segments",
"of",
"the",
"version",
"as",
"a",
"slice",
"of",
"ints",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/diagnostics.go#L253-L262 | train |
pilosa/pilosa | roaring/container_stash.go | NewContainer | func NewContainer() *Container {
statsHit("NewContainer")
c := &Container{typ: containerArray, len: 0, cap: stashedArraySize}
c.pointer = (*uint16)(unsafe.Pointer(&c.data[0]))
return c
} | go | func NewContainer() *Container {
statsHit("NewContainer")
c := &Container{typ: containerArray, len: 0, cap: stashedArraySize}
c.pointer = (*uint16)(unsafe.Pointer(&c.data[0]))
return c
} | [
"func",
"NewContainer",
"(",
")",
"*",
"Container",
"{",
"statsHit",
"(",
"\"",
"\"",
")",
"\n",
"c",
":=",
"&",
"Container",
"{",
"typ",
":",
"containerArray",
",",
"len",
":",
"0",
",",
"cap",
":",
"stashedArraySize",
"}",
"\n",
"c",
".",
"pointer"... | // NewContainer returns a new instance of container. This trivial function
// may later become more interesting. | [
"NewContainer",
"returns",
"a",
"new",
"instance",
"of",
"container",
".",
"This",
"trivial",
"function",
"may",
"later",
"become",
"more",
"interesting",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/container_stash.go#L49-L54 | train |
pilosa/pilosa | roaring/container_stash.go | NewContainerBitmap | func NewContainerBitmap(n int32, bitmap []uint64) *Container {
if bitmap == nil {
bitmap = make([]uint64, bitmapN)
}
// pad to required length
if len(bitmap) < bitmapN {
bm2 := make([]uint64, bitmapN)
copy(bm2, bitmap)
bitmap = bm2
}
c := &Container{typ: containerBitmap, n: n}
c.setBitmap(bitmap)
return... | go | func NewContainerBitmap(n int32, bitmap []uint64) *Container {
if bitmap == nil {
bitmap = make([]uint64, bitmapN)
}
// pad to required length
if len(bitmap) < bitmapN {
bm2 := make([]uint64, bitmapN)
copy(bm2, bitmap)
bitmap = bm2
}
c := &Container{typ: containerBitmap, n: n}
c.setBitmap(bitmap)
return... | [
"func",
"NewContainerBitmap",
"(",
"n",
"int32",
",",
"bitmap",
"[",
"]",
"uint64",
")",
"*",
"Container",
"{",
"if",
"bitmap",
"==",
"nil",
"{",
"bitmap",
"=",
"make",
"(",
"[",
"]",
"uint64",
",",
"bitmapN",
")",
"\n",
"}",
"\n",
"// pad to required ... | // NewContainerBitmap makes a bitmap container using the provided bitmap, or
// an empty one if provided bitmap is nil. If the provided bitmap is too short,
// it will be padded. | [
"NewContainerBitmap",
"makes",
"a",
"bitmap",
"container",
"using",
"the",
"provided",
"bitmap",
"or",
"an",
"empty",
"one",
"if",
"provided",
"bitmap",
"is",
"nil",
".",
"If",
"the",
"provided",
"bitmap",
"is",
"too",
"short",
"it",
"will",
"be",
"padded",
... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/container_stash.go#L59-L72 | train |
pilosa/pilosa | roaring/container_stash.go | NewContainerArray | func NewContainerArray(set []uint16) *Container {
c := &Container{typ: containerArray, n: int32(len(set))}
c.setArray(set)
return c
} | go | func NewContainerArray(set []uint16) *Container {
c := &Container{typ: containerArray, n: int32(len(set))}
c.setArray(set)
return c
} | [
"func",
"NewContainerArray",
"(",
"set",
"[",
"]",
"uint16",
")",
"*",
"Container",
"{",
"c",
":=",
"&",
"Container",
"{",
"typ",
":",
"containerArray",
",",
"n",
":",
"int32",
"(",
"len",
"(",
"set",
")",
")",
"}",
"\n",
"c",
".",
"setArray",
"(",... | // NewContainerArray returns an array using the provided set of values. It's
// okay if the slice is nil; that's a length of zero. | [
"NewContainerArray",
"returns",
"an",
"array",
"using",
"the",
"provided",
"set",
"of",
"values",
".",
"It",
"s",
"okay",
"if",
"the",
"slice",
"is",
"nil",
";",
"that",
"s",
"a",
"length",
"of",
"zero",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/container_stash.go#L76-L80 | train |
pilosa/pilosa | roaring/container_stash.go | array | func (c *Container) array() []uint16 {
if roaringParanoia {
if c.typ != containerArray {
panic("attempt to read non-array's array")
}
}
return *(*[]uint16)(unsafe.Pointer(&reflect.SliceHeader{Data: uintptr(unsafe.Pointer(c.pointer)), Len: int(c.len), Cap: int(c.cap)}))
} | go | func (c *Container) array() []uint16 {
if roaringParanoia {
if c.typ != containerArray {
panic("attempt to read non-array's array")
}
}
return *(*[]uint16)(unsafe.Pointer(&reflect.SliceHeader{Data: uintptr(unsafe.Pointer(c.pointer)), Len: int(c.len), Cap: int(c.cap)}))
} | [
"func",
"(",
"c",
"*",
"Container",
")",
"array",
"(",
")",
"[",
"]",
"uint16",
"{",
"if",
"roaringParanoia",
"{",
"if",
"c",
".",
"typ",
"!=",
"containerArray",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"*",
"(",
... | // array yields the data viewed as a slice of uint16 values. | [
"array",
"yields",
"the",
"data",
"viewed",
"as",
"a",
"slice",
"of",
"uint16",
"values",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/container_stash.go#L106-L113 | train |
pilosa/pilosa | roaring/container_stash.go | setArray | func (c *Container) setArray(array []uint16) {
if roaringParanoia {
if c.typ != containerArray {
panic("attempt to write non-array's array")
}
}
// no array: start with our default 5-value array
if array == nil {
c.pointer, c.len, c.cap = (*uint16)(unsafe.Pointer(&c.data[0])), 0, stashedArraySize
return
... | go | func (c *Container) setArray(array []uint16) {
if roaringParanoia {
if c.typ != containerArray {
panic("attempt to write non-array's array")
}
}
// no array: start with our default 5-value array
if array == nil {
c.pointer, c.len, c.cap = (*uint16)(unsafe.Pointer(&c.data[0])), 0, stashedArraySize
return
... | [
"func",
"(",
"c",
"*",
"Container",
")",
"setArray",
"(",
"array",
"[",
"]",
"uint16",
")",
"{",
"if",
"roaringParanoia",
"{",
"if",
"c",
".",
"typ",
"!=",
"containerArray",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"// no arr... | // setArray stores a set of uint16s as data. | [
"setArray",
"stores",
"a",
"set",
"of",
"uint16s",
"as",
"data",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/container_stash.go#L116-L142 | train |
pilosa/pilosa | roaring/container_stash.go | bitmap | func (c *Container) bitmap() []uint64 {
if roaringParanoia {
if c.typ != containerBitmap {
panic("attempt to read non-bitmap's bitmap")
}
}
return *(*[]uint64)(unsafe.Pointer(&reflect.SliceHeader{Data: uintptr(unsafe.Pointer(c.pointer)), Len: int(c.len), Cap: int(c.cap)}))
} | go | func (c *Container) bitmap() []uint64 {
if roaringParanoia {
if c.typ != containerBitmap {
panic("attempt to read non-bitmap's bitmap")
}
}
return *(*[]uint64)(unsafe.Pointer(&reflect.SliceHeader{Data: uintptr(unsafe.Pointer(c.pointer)), Len: int(c.len), Cap: int(c.cap)}))
} | [
"func",
"(",
"c",
"*",
"Container",
")",
"bitmap",
"(",
")",
"[",
"]",
"uint64",
"{",
"if",
"roaringParanoia",
"{",
"if",
"c",
".",
"typ",
"!=",
"containerBitmap",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"*",
"("... | // bitmap yields the data viewed as a slice of uint64s holding bits. | [
"bitmap",
"yields",
"the",
"data",
"viewed",
"as",
"a",
"slice",
"of",
"uint64s",
"holding",
"bits",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/container_stash.go#L145-L152 | train |
pilosa/pilosa | roaring/container_stash.go | setBitmap | func (c *Container) setBitmap(bitmap []uint64) {
if roaringParanoia {
if c.typ != containerBitmap {
panic("attempt to write non-bitmap's bitmap")
}
}
h := (*reflect.SliceHeader)(unsafe.Pointer(&bitmap))
c.pointer, c.len, c.cap = (*uint16)(unsafe.Pointer(h.Data)), int32(h.Len), int32(h.Cap)
runtime.KeepAlive... | go | func (c *Container) setBitmap(bitmap []uint64) {
if roaringParanoia {
if c.typ != containerBitmap {
panic("attempt to write non-bitmap's bitmap")
}
}
h := (*reflect.SliceHeader)(unsafe.Pointer(&bitmap))
c.pointer, c.len, c.cap = (*uint16)(unsafe.Pointer(h.Data)), int32(h.Len), int32(h.Cap)
runtime.KeepAlive... | [
"func",
"(",
"c",
"*",
"Container",
")",
"setBitmap",
"(",
"bitmap",
"[",
"]",
"uint64",
")",
"{",
"if",
"roaringParanoia",
"{",
"if",
"c",
".",
"typ",
"!=",
"containerBitmap",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"h",
... | // setBitmap stores a set of uint64s as data. | [
"setBitmap",
"stores",
"a",
"set",
"of",
"uint64s",
"as",
"data",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/container_stash.go#L155-L164 | train |
pilosa/pilosa | roaring/container_stash.go | runs | func (c *Container) runs() []interval16 {
if roaringParanoia {
if c.typ != containerRun {
panic("attempt to read non-run's runs")
}
}
return *(*[]interval16)(unsafe.Pointer(&reflect.SliceHeader{Data: uintptr(unsafe.Pointer(c.pointer)), Len: int(c.len), Cap: int(c.cap)}))
} | go | func (c *Container) runs() []interval16 {
if roaringParanoia {
if c.typ != containerRun {
panic("attempt to read non-run's runs")
}
}
return *(*[]interval16)(unsafe.Pointer(&reflect.SliceHeader{Data: uintptr(unsafe.Pointer(c.pointer)), Len: int(c.len), Cap: int(c.cap)}))
} | [
"func",
"(",
"c",
"*",
"Container",
")",
"runs",
"(",
")",
"[",
"]",
"interval16",
"{",
"if",
"roaringParanoia",
"{",
"if",
"c",
".",
"typ",
"!=",
"containerRun",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"*",
"(",... | // runs yields the data viewed as a slice of intervals. | [
"runs",
"yields",
"the",
"data",
"viewed",
"as",
"a",
"slice",
"of",
"intervals",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/container_stash.go#L167-L174 | train |
pilosa/pilosa | roaring/container_stash.go | setRuns | func (c *Container) setRuns(runs []interval16) {
if roaringParanoia {
if c.typ != containerRun {
panic("attempt to write non-run's runs")
}
}
// no array: start with our default 2-value array
if runs == nil {
c.pointer, c.len, c.cap = (*uint16)(unsafe.Pointer(&c.data[0])), 0, stashedRunSize
return
}
h ... | go | func (c *Container) setRuns(runs []interval16) {
if roaringParanoia {
if c.typ != containerRun {
panic("attempt to write non-run's runs")
}
}
// no array: start with our default 2-value array
if runs == nil {
c.pointer, c.len, c.cap = (*uint16)(unsafe.Pointer(&c.data[0])), 0, stashedRunSize
return
}
h ... | [
"func",
"(",
"c",
"*",
"Container",
")",
"setRuns",
"(",
"runs",
"[",
"]",
"interval16",
")",
"{",
"if",
"roaringParanoia",
"{",
"if",
"c",
".",
"typ",
"!=",
"containerRun",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"// no arr... | // setRuns stores a set of intervals as data. | [
"setRuns",
"stores",
"a",
"set",
"of",
"intervals",
"as",
"data",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/container_stash.go#L177-L205 | train |
pilosa/pilosa | roaring/container_stash.go | Update | func (c *Container) Update(typ byte, n int32, mapped bool) {
c.typ = typ
c.n = n
c.mapped = mapped
// we don't know that any existing slice is usable, so let's ditch it
switch c.typ {
case containerArray:
c.pointer, c.len, c.cap = (*uint16)(unsafe.Pointer(&c.data[0])), int32(0), stashedArraySize
case container... | go | func (c *Container) Update(typ byte, n int32, mapped bool) {
c.typ = typ
c.n = n
c.mapped = mapped
// we don't know that any existing slice is usable, so let's ditch it
switch c.typ {
case containerArray:
c.pointer, c.len, c.cap = (*uint16)(unsafe.Pointer(&c.data[0])), int32(0), stashedArraySize
case container... | [
"func",
"(",
"c",
"*",
"Container",
")",
"Update",
"(",
"typ",
"byte",
",",
"n",
"int32",
",",
"mapped",
"bool",
")",
"{",
"c",
".",
"typ",
"=",
"typ",
"\n",
"c",
".",
"n",
"=",
"n",
"\n",
"c",
".",
"mapped",
"=",
"mapped",
"\n",
"// we don't k... | // Update updates the container | [
"Update",
"updates",
"the",
"container"
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/container_stash.go#L208-L221 | train |
pilosa/pilosa | roaring/container_stash.go | unmapArray | func (c *Container) unmapArray() {
if !c.mapped {
return
}
array := c.array()
tmp := make([]uint16, c.len)
copy(tmp, array)
h := (*reflect.SliceHeader)(unsafe.Pointer(&tmp))
c.pointer, c.cap = (*uint16)(unsafe.Pointer(h.Data)), int32(h.Cap)
runtime.KeepAlive(&tmp)
c.mapped = false
} | go | func (c *Container) unmapArray() {
if !c.mapped {
return
}
array := c.array()
tmp := make([]uint16, c.len)
copy(tmp, array)
h := (*reflect.SliceHeader)(unsafe.Pointer(&tmp))
c.pointer, c.cap = (*uint16)(unsafe.Pointer(h.Data)), int32(h.Cap)
runtime.KeepAlive(&tmp)
c.mapped = false
} | [
"func",
"(",
"c",
"*",
"Container",
")",
"unmapArray",
"(",
")",
"{",
"if",
"!",
"c",
".",
"mapped",
"{",
"return",
"\n",
"}",
"\n",
"array",
":=",
"c",
".",
"array",
"(",
")",
"\n",
"tmp",
":=",
"make",
"(",
"[",
"]",
"uint16",
",",
"c",
"."... | // unmapArray ensures that the container is not using mmapped storage. | [
"unmapArray",
"ensures",
"that",
"the",
"container",
"is",
"not",
"using",
"mmapped",
"storage",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/container_stash.go#L239-L250 | train |
pilosa/pilosa | roaring/container_stash.go | unmapRun | func (c *Container) unmapRun() {
if !c.mapped {
return
}
runs := c.runs()
tmp := make([]interval16, c.len)
copy(tmp, runs)
h := (*reflect.SliceHeader)(unsafe.Pointer(&tmp))
c.pointer, c.cap = (*uint16)(unsafe.Pointer(h.Data)), int32(h.Cap)
c.mapped = false
} | go | func (c *Container) unmapRun() {
if !c.mapped {
return
}
runs := c.runs()
tmp := make([]interval16, c.len)
copy(tmp, runs)
h := (*reflect.SliceHeader)(unsafe.Pointer(&tmp))
c.pointer, c.cap = (*uint16)(unsafe.Pointer(h.Data)), int32(h.Cap)
c.mapped = false
} | [
"func",
"(",
"c",
"*",
"Container",
")",
"unmapRun",
"(",
")",
"{",
"if",
"!",
"c",
".",
"mapped",
"{",
"return",
"\n",
"}",
"\n",
"runs",
":=",
"c",
".",
"runs",
"(",
")",
"\n",
"tmp",
":=",
"make",
"(",
"[",
"]",
"interval16",
",",
"c",
"."... | // unmapRun ensures that the container is not using mmapped storage. | [
"unmapRun",
"ensures",
"that",
"the",
"container",
"is",
"not",
"using",
"mmapped",
"storage",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/roaring/container_stash.go#L267-L277 | train |
pilosa/pilosa | server/config.go | NewConfig | func NewConfig() *Config {
c := &Config{
DataDir: "~/.pilosa",
Bind: ":10101",
MaxWritesPerRequest: 5000,
// We default these Max File/Map counts very high. This is basically a
// backwards compatibility thing where we don't want to cause different
// behavior for those who had ... | go | func NewConfig() *Config {
c := &Config{
DataDir: "~/.pilosa",
Bind: ":10101",
MaxWritesPerRequest: 5000,
// We default these Max File/Map counts very high. This is basically a
// backwards compatibility thing where we don't want to cause different
// behavior for those who had ... | [
"func",
"NewConfig",
"(",
")",
"*",
"Config",
"{",
"c",
":=",
"&",
"Config",
"{",
"DataDir",
":",
"\"",
"\"",
",",
"Bind",
":",
"\"",
"\"",
",",
"MaxWritesPerRequest",
":",
"5000",
",",
"// We default these Max File/Map counts very high. This is basically a",
"/... | // NewConfig returns an instance of Config with default options. | [
"NewConfig",
"returns",
"an",
"instance",
"of",
"Config",
"with",
"default",
"options",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/server/config.go#L141-L190 | train |
pilosa/pilosa | server/config.go | validateAddrs | func (cfg *Config) validateAddrs(ctx context.Context) error {
// Validate the advertise address.
advScheme, advHost, advPort, err := validateAdvertiseAddr(ctx, cfg.Advertise, cfg.Bind)
if err != nil {
return errors.Wrapf(err, "validating advertise address")
}
cfg.Advertise = schemeHostPortString(advScheme, advHo... | go | func (cfg *Config) validateAddrs(ctx context.Context) error {
// Validate the advertise address.
advScheme, advHost, advPort, err := validateAdvertiseAddr(ctx, cfg.Advertise, cfg.Bind)
if err != nil {
return errors.Wrapf(err, "validating advertise address")
}
cfg.Advertise = schemeHostPortString(advScheme, advHo... | [
"func",
"(",
"cfg",
"*",
"Config",
")",
"validateAddrs",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"// Validate the advertise address.",
"advScheme",
",",
"advHost",
",",
"advPort",
",",
"err",
":=",
"validateAdvertiseAddr",
"(",
"ctx",
",",
"c... | // validateAddrs controls the address fields in the Config object
// and fills in any blanks.
// The addresses fields must be guaranteed by the caller to either be
// completely empty, or have both a host part and a port part
// separated by a colon. In the latter case either can be empty to
// indicate it's left unspe... | [
"validateAddrs",
"controls",
"the",
"address",
"fields",
"in",
"the",
"Config",
"object",
"and",
"fills",
"in",
"any",
"blanks",
".",
"The",
"addresses",
"fields",
"must",
"be",
"guaranteed",
"by",
"the",
"caller",
"to",
"either",
"be",
"completely",
"empty",
... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/server/config.go#L198-L214 | train |
pilosa/pilosa | server/config.go | validateAdvertiseAddr | func validateAdvertiseAddr(ctx context.Context, advAddr, listenAddr string) (string, string, string, error) {
listenScheme, listenHost, listenPort, err := splitAddr(listenAddr)
if err != nil {
return "", "", "", errors.Wrap(err, "getting listen address")
}
advScheme, advHostPort := splitScheme(advAddr)
advHost,... | go | func validateAdvertiseAddr(ctx context.Context, advAddr, listenAddr string) (string, string, string, error) {
listenScheme, listenHost, listenPort, err := splitAddr(listenAddr)
if err != nil {
return "", "", "", errors.Wrap(err, "getting listen address")
}
advScheme, advHostPort := splitScheme(advAddr)
advHost,... | [
"func",
"validateAdvertiseAddr",
"(",
"ctx",
"context",
".",
"Context",
",",
"advAddr",
",",
"listenAddr",
"string",
")",
"(",
"string",
",",
"string",
",",
"string",
",",
"error",
")",
"{",
"listenScheme",
",",
"listenHost",
",",
"listenPort",
",",
"err",
... | // validateAdvertiseAddr validates and normalizes an address accessible
// Ensures that if the "host" part is empty, it gets filled in with
// the configured listen address if any, otherwise it makes a best
// guess at the outbound IP address.
// Returns scheme, host, port as strings. | [
"validateAdvertiseAddr",
"validates",
"and",
"normalizes",
"an",
"address",
"accessible",
"Ensures",
"that",
"if",
"the",
"host",
"part",
"is",
"empty",
"it",
"gets",
"filled",
"in",
"with",
"the",
"configured",
"listen",
"address",
"if",
"any",
"otherwise",
"it... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/server/config.go#L221-L262 | train |
pilosa/pilosa | server/config.go | outboundIP | func outboundIP() net.IP {
// This is not actually making a connection to 8.8.8.8.
// net.Dial() selects the IP address that would be used
// if an actual connection to 8.8.8.8 were made, so this
// choice of address is just meant to ensure that an
// external address is returned (as opposed to a local
// address... | go | func outboundIP() net.IP {
// This is not actually making a connection to 8.8.8.8.
// net.Dial() selects the IP address that would be used
// if an actual connection to 8.8.8.8 were made, so this
// choice of address is just meant to ensure that an
// external address is returned (as opposed to a local
// address... | [
"func",
"outboundIP",
"(",
")",
"net",
".",
"IP",
"{",
"// This is not actually making a connection to 8.8.8.8.",
"// net.Dial() selects the IP address that would be used",
"// if an actual connection to 8.8.8.8 were made, so this",
"// choice of address is just meant to ensure that an",
"//... | // outboundIP gets the preferred outbound ip of this machine. | [
"outboundIP",
"gets",
"the",
"preferred",
"outbound",
"ip",
"of",
"this",
"machine",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/server/config.go#L265-L281 | train |
pilosa/pilosa | server/config.go | splitAddr | func splitAddr(addr string) (string, string, string, error) {
scheme, hostPort := splitScheme(addr)
host, port := "", ""
if hostPort != "" {
var err error
host, port, err = net.SplitHostPort(hostPort)
if err != nil {
return "", "", "", errors.Wrapf(err, "splitting host port: %s", hostPort)
}
}
// It's n... | go | func splitAddr(addr string) (string, string, string, error) {
scheme, hostPort := splitScheme(addr)
host, port := "", ""
if hostPort != "" {
var err error
host, port, err = net.SplitHostPort(hostPort)
if err != nil {
return "", "", "", errors.Wrapf(err, "splitting host port: %s", hostPort)
}
}
// It's n... | [
"func",
"splitAddr",
"(",
"addr",
"string",
")",
"(",
"string",
",",
"string",
",",
"string",
",",
"error",
")",
"{",
"scheme",
",",
"hostPort",
":=",
"splitScheme",
"(",
"addr",
")",
"\n",
"host",
",",
"port",
":=",
"\"",
"\"",
",",
"\"",
"\"",
"\... | // splitAddr returns scheme, host, port as strings. | [
"splitAddr",
"returns",
"scheme",
"host",
"port",
"as",
"strings",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/server/config.go#L318-L335 | train |
pilosa/pilosa | ctl/generate_config.go | NewGenerateConfigCommand | func NewGenerateConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *GenerateConfigCommand {
return &GenerateConfigCommand{
CmdIO: pilosa.NewCmdIO(stdin, stdout, stderr),
}
} | go | func NewGenerateConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *GenerateConfigCommand {
return &GenerateConfigCommand{
CmdIO: pilosa.NewCmdIO(stdin, stdout, stderr),
}
} | [
"func",
"NewGenerateConfigCommand",
"(",
"stdin",
"io",
".",
"Reader",
",",
"stdout",
",",
"stderr",
"io",
".",
"Writer",
")",
"*",
"GenerateConfigCommand",
"{",
"return",
"&",
"GenerateConfigCommand",
"{",
"CmdIO",
":",
"pilosa",
".",
"NewCmdIO",
"(",
"stdin"... | // NewGenerateConfigCommand returns a new instance of GenerateConfigCommand. | [
"NewGenerateConfigCommand",
"returns",
"a",
"new",
"instance",
"of",
"GenerateConfigCommand",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/ctl/generate_config.go#L34-L38 | train |
pilosa/pilosa | cmd/server.go | newServeCmd | func newServeCmd(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command {
Server = server.NewCommand(stdin, stdout, stderr)
serveCmd := &cobra.Command{
Use: "server",
Short: "Run Pilosa.",
Long: `pilosa server runs Pilosa.
It will load existing data from the configured
directory and start listening for cl... | go | func newServeCmd(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command {
Server = server.NewCommand(stdin, stdout, stderr)
serveCmd := &cobra.Command{
Use: "server",
Short: "Run Pilosa.",
Long: `pilosa server runs Pilosa.
It will load existing data from the configured
directory and start listening for cl... | [
"func",
"newServeCmd",
"(",
"stdin",
"io",
".",
"Reader",
",",
"stdout",
",",
"stderr",
"io",
".",
"Writer",
")",
"*",
"cobra",
".",
"Command",
"{",
"Server",
"=",
"server",
".",
"NewCommand",
"(",
"stdin",
",",
"stdout",
",",
"stderr",
")",
"\n",
"s... | // newServeCmd creates a pilosa server and runs it with command line flags. | [
"newServeCmd",
"creates",
"a",
"pilosa",
"server",
"and",
"runs",
"it",
"with",
"command",
"line",
"flags",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/cmd/server.go#L33-L73 | train |
pilosa/pilosa | boltdb/attrstore.go | Get | func (c *attrCache) Get(id uint64) map[string]interface{} {
c.mu.RLock()
defer c.mu.RUnlock()
attrs := c.attrs[id]
if attrs == nil {
return nil
}
// Make a copy for safety
ret := make(map[string]interface{})
for k, v := range attrs {
ret[k] = v
}
return ret
} | go | func (c *attrCache) Get(id uint64) map[string]interface{} {
c.mu.RLock()
defer c.mu.RUnlock()
attrs := c.attrs[id]
if attrs == nil {
return nil
}
// Make a copy for safety
ret := make(map[string]interface{})
for k, v := range attrs {
ret[k] = v
}
return ret
} | [
"func",
"(",
"c",
"*",
"attrCache",
")",
"Get",
"(",
"id",
"uint64",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"c",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"attrs",
"... | // Get returns the cached attributes for a given id. | [
"Get",
"returns",
"the",
"cached",
"attributes",
"for",
"a",
"given",
"id",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/boltdb/attrstore.go#L43-L57 | train |
pilosa/pilosa | boltdb/attrstore.go | Set | func (c *attrCache) Set(id uint64, attrs map[string]interface{}) {
c.mu.Lock()
defer c.mu.Unlock()
c.attrs[id] = attrs
} | go | func (c *attrCache) Set(id uint64, attrs map[string]interface{}) {
c.mu.Lock()
defer c.mu.Unlock()
c.attrs[id] = attrs
} | [
"func",
"(",
"c",
"*",
"attrCache",
")",
"Set",
"(",
"id",
"uint64",
",",
"attrs",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n"... | // Set updates the cached attributes for a given id. | [
"Set",
"updates",
"the",
"cached",
"attributes",
"for",
"a",
"given",
"id",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/boltdb/attrstore.go#L60-L64 | train |
pilosa/pilosa | boltdb/attrstore.go | NewAttrStore | func NewAttrStore(path string) pilosa.AttrStore {
return &attrStore{
path: path,
attrCache: newAttrCache(),
}
} | go | func NewAttrStore(path string) pilosa.AttrStore {
return &attrStore{
path: path,
attrCache: newAttrCache(),
}
} | [
"func",
"NewAttrStore",
"(",
"path",
"string",
")",
"pilosa",
".",
"AttrStore",
"{",
"return",
"&",
"attrStore",
"{",
"path",
":",
"path",
",",
"attrCache",
":",
"newAttrCache",
"(",
")",
",",
"}",
"\n",
"}"
] | // NewAttrStore returns a new instance of AttrStore. | [
"NewAttrStore",
"returns",
"a",
"new",
"instance",
"of",
"AttrStore",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/boltdb/attrstore.go#L82-L87 | train |
pilosa/pilosa | boltdb/attrstore.go | Open | func (s *attrStore) Open() error {
// Open storage.
db, err := bolt.Open(s.path, 0666, &bolt.Options{Timeout: 1 * time.Second})
if err != nil {
return errors.Wrap(err, "opening storage")
}
s.db = db
// Initialize database.
if err := s.db.Update(func(tx *bolt.Tx) error {
_, err := tx.CreateBucketIfNotExists(... | go | func (s *attrStore) Open() error {
// Open storage.
db, err := bolt.Open(s.path, 0666, &bolt.Options{Timeout: 1 * time.Second})
if err != nil {
return errors.Wrap(err, "opening storage")
}
s.db = db
// Initialize database.
if err := s.db.Update(func(tx *bolt.Tx) error {
_, err := tx.CreateBucketIfNotExists(... | [
"func",
"(",
"s",
"*",
"attrStore",
")",
"Open",
"(",
")",
"error",
"{",
"// Open storage.",
"db",
",",
"err",
":=",
"bolt",
".",
"Open",
"(",
"s",
".",
"path",
",",
"0666",
",",
"&",
"bolt",
".",
"Options",
"{",
"Timeout",
":",
"1",
"*",
"time",... | // Open opens and initializes the store. | [
"Open",
"opens",
"and",
"initializes",
"the",
"store",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/boltdb/attrstore.go#L93-L110 | train |
pilosa/pilosa | boltdb/attrstore.go | Attrs | func (s *attrStore) Attrs(id uint64) (m map[string]interface{}, err error) {
s.mu.RLock()
defer s.mu.RUnlock()
// Check cache for map.
if m = s.attrCache.Get(id); m != nil {
return m, nil
}
// Find attributes from storage.
if err = s.db.View(func(tx *bolt.Tx) error {
m, err = txAttrs(tx, id)
return err
... | go | func (s *attrStore) Attrs(id uint64) (m map[string]interface{}, err error) {
s.mu.RLock()
defer s.mu.RUnlock()
// Check cache for map.
if m = s.attrCache.Get(id); m != nil {
return m, nil
}
// Find attributes from storage.
if err = s.db.View(func(tx *bolt.Tx) error {
m, err = txAttrs(tx, id)
return err
... | [
"func",
"(",
"s",
"*",
"attrStore",
")",
"Attrs",
"(",
"id",
"uint64",
")",
"(",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",... | // Attrs returns a set of attributes by ID. | [
"Attrs",
"returns",
"a",
"set",
"of",
"attributes",
"by",
"ID",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/boltdb/attrstore.go#L121-L142 | train |
pilosa/pilosa | boltdb/attrstore.go | SetAttrs | func (s *attrStore) SetAttrs(id uint64, m map[string]interface{}) error {
// Ignore empty maps.
if len(m) == 0 {
return nil
}
// Check if the attributes already exist under a read-only lock.
if attr, err := s.Attrs(id); err != nil {
return errors.Wrap(err, "checking attrs")
} else if attr != nil && mapContai... | go | func (s *attrStore) SetAttrs(id uint64, m map[string]interface{}) error {
// Ignore empty maps.
if len(m) == 0 {
return nil
}
// Check if the attributes already exist under a read-only lock.
if attr, err := s.Attrs(id); err != nil {
return errors.Wrap(err, "checking attrs")
} else if attr != nil && mapContai... | [
"func",
"(",
"s",
"*",
"attrStore",
")",
"SetAttrs",
"(",
"id",
"uint64",
",",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"// Ignore empty maps.",
"if",
"len",
"(",
"m",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}"... | // SetAttrs sets attribute values for a given ID. | [
"SetAttrs",
"sets",
"attribute",
"values",
"for",
"a",
"given",
"ID",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/boltdb/attrstore.go#L145-L179 | train |
pilosa/pilosa | boltdb/attrstore.go | SetBulkAttrs | func (s *attrStore) SetBulkAttrs(m map[uint64]map[string]interface{}) error {
s.mu.Lock()
defer s.mu.Unlock()
attrs := make(map[uint64]map[string]interface{})
if err := s.db.Update(func(tx *bolt.Tx) error {
// Collect and sort keys.
ids := make([]uint64, 0, len(m))
for id := range m {
ids = append(ids, id... | go | func (s *attrStore) SetBulkAttrs(m map[uint64]map[string]interface{}) error {
s.mu.Lock()
defer s.mu.Unlock()
attrs := make(map[uint64]map[string]interface{})
if err := s.db.Update(func(tx *bolt.Tx) error {
// Collect and sort keys.
ids := make([]uint64, 0, len(m))
for id := range m {
ids = append(ids, id... | [
"func",
"(",
"s",
"*",
"attrStore",
")",
"SetBulkAttrs",
"(",
"m",
"map",
"[",
"uint64",
"]",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unloc... | // SetBulkAttrs sets attribute values for a set of ids. | [
"SetBulkAttrs",
"sets",
"attribute",
"values",
"for",
"a",
"set",
"of",
"ids",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/boltdb/attrstore.go#L182-L215 | train |
pilosa/pilosa | boltdb/attrstore.go | Blocks | func (s *attrStore) Blocks() (blocks []pilosa.AttrBlock, err error) {
err = s.db.View(func(tx *bolt.Tx) error {
// Wrap cursor to segment by block.
cur := newBlockCursor(tx.Bucket([]byte("attrs")).Cursor(), attrBlockSize)
// Iterate over each block.
for cur.nextBlock() {
block := pilosa.AttrBlock{ID: cur.b... | go | func (s *attrStore) Blocks() (blocks []pilosa.AttrBlock, err error) {
err = s.db.View(func(tx *bolt.Tx) error {
// Wrap cursor to segment by block.
cur := newBlockCursor(tx.Bucket([]byte("attrs")).Cursor(), attrBlockSize)
// Iterate over each block.
for cur.nextBlock() {
block := pilosa.AttrBlock{ID: cur.b... | [
"func",
"(",
"s",
"*",
"attrStore",
")",
"Blocks",
"(",
")",
"(",
"blocks",
"[",
"]",
"pilosa",
".",
"AttrBlock",
",",
"err",
"error",
")",
"{",
"err",
"=",
"s",
".",
"db",
".",
"View",
"(",
"func",
"(",
"tx",
"*",
"bolt",
".",
"Tx",
")",
"er... | // Blocks returns a list of all blocks in the store. | [
"Blocks",
"returns",
"a",
"list",
"of",
"all",
"blocks",
"in",
"the",
"store",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/boltdb/attrstore.go#L218-L245 | train |
pilosa/pilosa | boltdb/attrstore.go | BlockData | func (s *attrStore) BlockData(i uint64) (m map[uint64]map[string]interface{}, err error) {
m = make(map[uint64]map[string]interface{})
// Start read-only transaction.
err = s.db.View(func(tx *bolt.Tx) error {
// Move to the start of the block.
min := u64tob(i * attrBlockSize)
max := u64tob((i + 1) * attrBlock... | go | func (s *attrStore) BlockData(i uint64) (m map[uint64]map[string]interface{}, err error) {
m = make(map[uint64]map[string]interface{})
// Start read-only transaction.
err = s.db.View(func(tx *bolt.Tx) error {
// Move to the start of the block.
min := u64tob(i * attrBlockSize)
max := u64tob((i + 1) * attrBlock... | [
"func",
"(",
"s",
"*",
"attrStore",
")",
"BlockData",
"(",
"i",
"uint64",
")",
"(",
"m",
"map",
"[",
"uint64",
"]",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"m",
"=",
"make",
"(",
"map",
"[",
"uint64",
"]... | // BlockData returns all data for a single block. | [
"BlockData",
"returns",
"all",
"data",
"for",
"a",
"single",
"block",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/boltdb/attrstore.go#L248-L277 | train |
pilosa/pilosa | boltdb/attrstore.go | txAttrs | func txAttrs(tx *bolt.Tx, id uint64) (map[string]interface{}, error) {
v := tx.Bucket([]byte("attrs")).Get(u64tob(id))
if v == nil {
return emptyMap, nil
}
return pilosa.DecodeAttrs(v)
} | go | func txAttrs(tx *bolt.Tx, id uint64) (map[string]interface{}, error) {
v := tx.Bucket([]byte("attrs")).Get(u64tob(id))
if v == nil {
return emptyMap, nil
}
return pilosa.DecodeAttrs(v)
} | [
"func",
"txAttrs",
"(",
"tx",
"*",
"bolt",
".",
"Tx",
",",
"id",
"uint64",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"v",
":=",
"tx",
".",
"Bucket",
"(",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
")",
... | // txAttrs returns a map of attributes for an id. | [
"txAttrs",
"returns",
"a",
"map",
"of",
"attributes",
"for",
"an",
"id",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/boltdb/attrstore.go#L280-L286 | train |
pilosa/pilosa | boltdb/attrstore.go | txUpdateAttrs | func txUpdateAttrs(tx *bolt.Tx, id uint64, m map[string]interface{}) (map[string]interface{}, error) {
attr, err := txAttrs(tx, id)
if err != nil {
return nil, err
}
// Create a new map if it is empty so we don't update emptyMap.
if len(attr) == 0 {
attr = make(map[string]interface{}, len(m))
}
// Merge at... | go | func txUpdateAttrs(tx *bolt.Tx, id uint64, m map[string]interface{}) (map[string]interface{}, error) {
attr, err := txAttrs(tx, id)
if err != nil {
return nil, err
}
// Create a new map if it is empty so we don't update emptyMap.
if len(attr) == 0 {
attr = make(map[string]interface{}, len(m))
}
// Merge at... | [
"func",
"txUpdateAttrs",
"(",
"tx",
"*",
"bolt",
".",
"Tx",
",",
"id",
"uint64",
",",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"attr",
",",
"err",
... | // txUpdateAttrs updates the attributes for an id.
// Returns the new combined set of attributes for the id. | [
"txUpdateAttrs",
"updates",
"the",
"attributes",
"for",
"an",
"id",
".",
"Returns",
"the",
"new",
"combined",
"set",
"of",
"attributes",
"for",
"the",
"id",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/boltdb/attrstore.go#L290-L332 | train |
pilosa/pilosa | boltdb/attrstore.go | mapContains | func mapContains(m, subset map[string]interface{}) bool {
for k, v := range subset {
value, ok := m[k]
if !ok || value != v {
return false
}
}
return true
} | go | func mapContains(m, subset map[string]interface{}) bool {
for k, v := range subset {
value, ok := m[k]
if !ok || value != v {
return false
}
}
return true
} | [
"func",
"mapContains",
"(",
"m",
",",
"subset",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"bool",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"subset",
"{",
"value",
",",
"ok",
":=",
"m",
"[",
"k",
"]",
"\n",
"if",
"!",
"ok",
"||",
... | // mapContains returns true if all keys & values of subset are in m. | [
"mapContains",
"returns",
"true",
"if",
"all",
"keys",
"&",
"values",
"of",
"subset",
"are",
"in",
"m",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/boltdb/attrstore.go#L348-L356 | train |
pilosa/pilosa | boltdb/attrstore.go | newBlockCursor | func newBlockCursor(c *bolt.Cursor, n int) blockCursor { // nolint: unparam
cur := blockCursor{
cur: c,
n: uint64(n),
}
cur.buf.key, cur.buf.value = c.First()
cur.buf.filled = true
return cur
} | go | func newBlockCursor(c *bolt.Cursor, n int) blockCursor { // nolint: unparam
cur := blockCursor{
cur: c,
n: uint64(n),
}
cur.buf.key, cur.buf.value = c.First()
cur.buf.filled = true
return cur
} | [
"func",
"newBlockCursor",
"(",
"c",
"*",
"bolt",
".",
"Cursor",
",",
"n",
"int",
")",
"blockCursor",
"{",
"// nolint: unparam",
"cur",
":=",
"blockCursor",
"{",
"cur",
":",
"c",
",",
"n",
":",
"uint64",
"(",
"n",
")",
",",
"}",
"\n",
"cur",
".",
"b... | // newBlockCursor returns a new block cursor that wraps cur using n sized blocks. | [
"newBlockCursor",
"returns",
"a",
"new",
"block",
"cursor",
"that",
"wraps",
"cur",
"using",
"n",
"sized",
"blocks",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/boltdb/attrstore.go#L372-L380 | train |
pilosa/pilosa | boltdb/attrstore.go | nextBlock | func (cur *blockCursor) nextBlock() bool {
if cur.buf.key == nil {
return false
}
cur.base = binary.BigEndian.Uint64(cur.buf.key) / cur.n
return true
} | go | func (cur *blockCursor) nextBlock() bool {
if cur.buf.key == nil {
return false
}
cur.base = binary.BigEndian.Uint64(cur.buf.key) / cur.n
return true
} | [
"func",
"(",
"cur",
"*",
"blockCursor",
")",
"nextBlock",
"(",
")",
"bool",
"{",
"if",
"cur",
".",
"buf",
".",
"key",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"cur",
".",
"base",
"=",
"binary",
".",
"BigEndian",
".",
"Uint64",
"(",
... | // nextBlock moves the cursor to the next block.
// Returns true if another block exists, otherwise returns false. | [
"nextBlock",
"moves",
"the",
"cursor",
"to",
"the",
"next",
"block",
".",
"Returns",
"true",
"if",
"another",
"block",
"exists",
"otherwise",
"returns",
"false",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/boltdb/attrstore.go#L387-L394 | train |
pilosa/pilosa | ctl/import.go | NewImportCommand | func NewImportCommand(stdin io.Reader, stdout, stderr io.Writer) *ImportCommand {
return &ImportCommand{
CmdIO: pilosa.NewCmdIO(stdin, stdout, stderr),
BufferSize: 10000000,
}
} | go | func NewImportCommand(stdin io.Reader, stdout, stderr io.Writer) *ImportCommand {
return &ImportCommand{
CmdIO: pilosa.NewCmdIO(stdin, stdout, stderr),
BufferSize: 10000000,
}
} | [
"func",
"NewImportCommand",
"(",
"stdin",
"io",
".",
"Reader",
",",
"stdout",
",",
"stderr",
"io",
".",
"Writer",
")",
"*",
"ImportCommand",
"{",
"return",
"&",
"ImportCommand",
"{",
"CmdIO",
":",
"pilosa",
".",
"NewCmdIO",
"(",
"stdin",
",",
"stdout",
"... | // NewImportCommand returns a new instance of ImportCommand. | [
"NewImportCommand",
"returns",
"a",
"new",
"instance",
"of",
"ImportCommand",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/ctl/import.go#L74-L79 | train |
pilosa/pilosa | ctl/import.go | Run | func (cmd *ImportCommand) Run(ctx context.Context) error {
logger := log.New(cmd.Stderr, "", log.LstdFlags)
// Validate arguments.
// Index and field are validated early before the files are parsed.
if cmd.Index == "" {
return pilosa.ErrIndexRequired
} else if cmd.Field == "" {
return pilosa.ErrFieldRequired
... | go | func (cmd *ImportCommand) Run(ctx context.Context) error {
logger := log.New(cmd.Stderr, "", log.LstdFlags)
// Validate arguments.
// Index and field are validated early before the files are parsed.
if cmd.Index == "" {
return pilosa.ErrIndexRequired
} else if cmd.Field == "" {
return pilosa.ErrFieldRequired
... | [
"func",
"(",
"cmd",
"*",
"ImportCommand",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"logger",
":=",
"log",
".",
"New",
"(",
"cmd",
".",
"Stderr",
",",
"\"",
"\"",
",",
"log",
".",
"LstdFlags",
")",
"\n\n",
"// Validate arg... | // Run executes the main program execution. | [
"Run",
"executes",
"the",
"main",
"program",
"execution",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/ctl/import.go#L82-L149 | train |
pilosa/pilosa | ctl/import.go | importPath | func (cmd *ImportCommand) importPath(ctx context.Context, fieldType string, useColumnKeys, useRowKeys bool, path string) error {
// If fieldType is `int`, treat the import data as values to be range-encoded.
if fieldType == pilosa.FieldTypeInt {
return cmd.bufferValues(ctx, useColumnKeys, path)
}
return cmd.buffe... | go | func (cmd *ImportCommand) importPath(ctx context.Context, fieldType string, useColumnKeys, useRowKeys bool, path string) error {
// If fieldType is `int`, treat the import data as values to be range-encoded.
if fieldType == pilosa.FieldTypeInt {
return cmd.bufferValues(ctx, useColumnKeys, path)
}
return cmd.buffe... | [
"func",
"(",
"cmd",
"*",
"ImportCommand",
")",
"importPath",
"(",
"ctx",
"context",
".",
"Context",
",",
"fieldType",
"string",
",",
"useColumnKeys",
",",
"useRowKeys",
"bool",
",",
"path",
"string",
")",
"error",
"{",
"// If fieldType is `int`, treat the import d... | // importPath parses a path into bits and imports it to the server. | [
"importPath",
"parses",
"a",
"path",
"into",
"bits",
"and",
"imports",
"it",
"to",
"the",
"server",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/ctl/import.go#L164-L170 | train |
pilosa/pilosa | ctl/import.go | bufferBits | func (cmd *ImportCommand) bufferBits(ctx context.Context, useColumnKeys, useRowKeys bool, path string) error {
a := make([]pilosa.Bit, 0, cmd.BufferSize)
var r *csv.Reader
if path != "-" {
// Open file for reading.
f, err := os.Open(path)
if err != nil {
return errors.Wrap(err, "opening file")
}
defer... | go | func (cmd *ImportCommand) bufferBits(ctx context.Context, useColumnKeys, useRowKeys bool, path string) error {
a := make([]pilosa.Bit, 0, cmd.BufferSize)
var r *csv.Reader
if path != "-" {
// Open file for reading.
f, err := os.Open(path)
if err != nil {
return errors.Wrap(err, "opening file")
}
defer... | [
"func",
"(",
"cmd",
"*",
"ImportCommand",
")",
"bufferBits",
"(",
"ctx",
"context",
".",
"Context",
",",
"useColumnKeys",
",",
"useRowKeys",
"bool",
",",
"path",
"string",
")",
"error",
"{",
"a",
":=",
"make",
"(",
"[",
"]",
"pilosa",
".",
"Bit",
",",
... | // bufferBits buffers slices of bits to be imported as a batch. | [
"bufferBits",
"buffers",
"slices",
"of",
"bits",
"to",
"be",
"imported",
"as",
"a",
"batch",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/ctl/import.go#L173-L254 | train |
pilosa/pilosa | ctl/import.go | importBits | func (cmd *ImportCommand) importBits(ctx context.Context, useColumnKeys, useRowKeys bool, bits []pilosa.Bit) error {
logger := log.New(cmd.Stderr, "", log.LstdFlags)
// If keys are used, all bits are sent to the primary translate store (i.e. coordinator).
if useColumnKeys || useRowKeys {
logger.Printf("importing ... | go | func (cmd *ImportCommand) importBits(ctx context.Context, useColumnKeys, useRowKeys bool, bits []pilosa.Bit) error {
logger := log.New(cmd.Stderr, "", log.LstdFlags)
// If keys are used, all bits are sent to the primary translate store (i.e. coordinator).
if useColumnKeys || useRowKeys {
logger.Printf("importing ... | [
"func",
"(",
"cmd",
"*",
"ImportCommand",
")",
"importBits",
"(",
"ctx",
"context",
".",
"Context",
",",
"useColumnKeys",
",",
"useRowKeys",
"bool",
",",
"bits",
"[",
"]",
"pilosa",
".",
"Bit",
")",
"error",
"{",
"logger",
":=",
"log",
".",
"New",
"(",... | // importBits sends batches of bits to the server. | [
"importBits",
"sends",
"batches",
"of",
"bits",
"to",
"the",
"server",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/ctl/import.go#L257-L286 | 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.