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 | translate.go | keyByID | func (idx *index) keyByID(id uint64) ([]byte, bool) {
offset, ok := idx.offsetsByID[id]
if !ok {
return nil, false
}
return idx.lookupKey(offset), true
} | go | func (idx *index) keyByID(id uint64) ([]byte, bool) {
offset, ok := idx.offsetsByID[id]
if !ok {
return nil, false
}
return idx.lookupKey(offset), true
} | [
"func",
"(",
"idx",
"*",
"index",
")",
"keyByID",
"(",
"id",
"uint64",
")",
"(",
"[",
"]",
"byte",
",",
"bool",
")",
"{",
"offset",
",",
"ok",
":=",
"idx",
".",
"offsetsByID",
"[",
"id",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
... | // keyByID returns the key for a given ID, if it exists. | [
"keyByID",
"returns",
"the",
"key",
"for",
"a",
"given",
"ID",
"if",
"it",
"exists",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L930-L936 | train |
pilosa/pilosa | translate.go | idByKey | func (idx *index) idByKey(key []byte) (uint64, bool) {
hash := hashKey(key)
pos := hash & idx.mask
var dist uint64
for {
if e := &idx.elems[pos]; e.hash == 0 {
return 0, false
} else if dist > idx.dist(e.hash, pos) {
return 0, false
} else if e.hash == hash && bytes.Equal(idx.lookupKey(e.offset), key) ... | go | func (idx *index) idByKey(key []byte) (uint64, bool) {
hash := hashKey(key)
pos := hash & idx.mask
var dist uint64
for {
if e := &idx.elems[pos]; e.hash == 0 {
return 0, false
} else if dist > idx.dist(e.hash, pos) {
return 0, false
} else if e.hash == hash && bytes.Equal(idx.lookupKey(e.offset), key) ... | [
"func",
"(",
"idx",
"*",
"index",
")",
"idByKey",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"uint64",
",",
"bool",
")",
"{",
"hash",
":=",
"hashKey",
"(",
"key",
")",
"\n",
"pos",
":=",
"hash",
"&",
"idx",
".",
"mask",
"\n\n",
"var",
"dist",
"uin... | // idByKey returns the ID for a given key, if it exists. | [
"idByKey",
"returns",
"the",
"ID",
"for",
"a",
"given",
"key",
"if",
"it",
"exists",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L939-L956 | train |
pilosa/pilosa | translate.go | insertIDbyOffset | func (idx *index) insertIDbyOffset(offset int64, id uint64) (overwritten bool) {
key := idx.lookupKey(offset)
hash := hashKey(key)
pos := hash & idx.mask
var dist uint64
for {
e := &idx.elems[pos]
// Exit if a matching or empty slot exists.
if e.hash == 0 {
e.hash, e.offset, e.id = hash, offset, id
r... | go | func (idx *index) insertIDbyOffset(offset int64, id uint64) (overwritten bool) {
key := idx.lookupKey(offset)
hash := hashKey(key)
pos := hash & idx.mask
var dist uint64
for {
e := &idx.elems[pos]
// Exit if a matching or empty slot exists.
if e.hash == 0 {
e.hash, e.offset, e.id = hash, offset, id
r... | [
"func",
"(",
"idx",
"*",
"index",
")",
"insertIDbyOffset",
"(",
"offset",
"int64",
",",
"id",
"uint64",
")",
"(",
"overwritten",
"bool",
")",
"{",
"key",
":=",
"idx",
".",
"lookupKey",
"(",
"offset",
")",
"\n",
"hash",
":=",
"hashKey",
"(",
"key",
")... | // insertIDbyOffset writes to the RHH id-by-offset map. | [
"insertIDbyOffset",
"writes",
"to",
"the",
"RHH",
"id",
"-",
"by",
"-",
"offset",
"map",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L987-L1018 | train |
pilosa/pilosa | translate.go | lookupKey | func (idx *index) lookupKey(offset int64) []byte {
data := idx.data[offset:]
n, sz := binary.Uvarint(data)
if sz == 0 {
return nil
}
return data[sz : sz+int(n)]
} | go | func (idx *index) lookupKey(offset int64) []byte {
data := idx.data[offset:]
n, sz := binary.Uvarint(data)
if sz == 0 {
return nil
}
return data[sz : sz+int(n)]
} | [
"func",
"(",
"idx",
"*",
"index",
")",
"lookupKey",
"(",
"offset",
"int64",
")",
"[",
"]",
"byte",
"{",
"data",
":=",
"idx",
".",
"data",
"[",
"offset",
":",
"]",
"\n",
"n",
",",
"sz",
":=",
"binary",
".",
"Uvarint",
"(",
"data",
")",
"\n",
"if... | // lookupKey returns the key at the given offset in the memory-mapped file. | [
"lookupKey",
"returns",
"the",
"key",
"at",
"the",
"given",
"offset",
"in",
"the",
"memory",
"-",
"mapped",
"file",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L1021-L1028 | train |
pilosa/pilosa | translate.go | newTranslateFileReader | func newTranslateFileReader(ctx context.Context, store *TranslateFile, offset int64) *translateFileReader {
return &translateFileReader{
ctx: ctx,
store: store,
offset: offset,
notify: store.WriteNotify(),
closing: make(chan struct{}),
}
} | go | func newTranslateFileReader(ctx context.Context, store *TranslateFile, offset int64) *translateFileReader {
return &translateFileReader{
ctx: ctx,
store: store,
offset: offset,
notify: store.WriteNotify(),
closing: make(chan struct{}),
}
} | [
"func",
"newTranslateFileReader",
"(",
"ctx",
"context",
".",
"Context",
",",
"store",
"*",
"TranslateFile",
",",
"offset",
"int64",
")",
"*",
"translateFileReader",
"{",
"return",
"&",
"translateFileReader",
"{",
"ctx",
":",
"ctx",
",",
"store",
":",
"store",... | // newTranslateFileReader returns a new instance of translateFileReader. | [
"newTranslateFileReader",
"returns",
"a",
"new",
"instance",
"of",
"translateFileReader",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L1076-L1084 | train |
pilosa/pilosa | translate.go | Open | func (r *translateFileReader) Open() (err error) {
r.file, err = os.Open(r.store.Path)
return err
} | go | func (r *translateFileReader) Open() (err error) {
r.file, err = os.Open(r.store.Path)
return err
} | [
"func",
"(",
"r",
"*",
"translateFileReader",
")",
"Open",
"(",
")",
"(",
"err",
"error",
")",
"{",
"r",
".",
"file",
",",
"err",
"=",
"os",
".",
"Open",
"(",
"r",
".",
"store",
".",
"Path",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Open initializes the reader. | [
"Open",
"initializes",
"the",
"reader",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L1087-L1090 | train |
pilosa/pilosa | translate.go | Close | func (r *translateFileReader) Close() error {
r.once.Do(func() { close(r.closing) })
if r.file != nil {
return r.file.Close()
}
return nil
} | go | func (r *translateFileReader) Close() error {
r.once.Do(func() { close(r.closing) })
if r.file != nil {
return r.file.Close()
}
return nil
} | [
"func",
"(",
"r",
"*",
"translateFileReader",
")",
"Close",
"(",
")",
"error",
"{",
"r",
".",
"once",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"close",
"(",
"r",
".",
"closing",
")",
"}",
")",
"\n\n",
"if",
"r",
".",
"file",
"!=",
"nil",
"{",
"... | // Close closes the underlying file reader. | [
"Close",
"closes",
"the",
"underlying",
"file",
"reader",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L1093-L1100 | train |
pilosa/pilosa | translate.go | Read | func (r *translateFileReader) Read(p []byte) (n int, err error) {
for {
// Obtain notification channel before we check for new data.
notify := r.store.WriteNotify()
// Exit if we can read one or more valid entries or we receive an error.
if n, err = r.read(p); n > 0 || err != nil {
return n, err
}
// ... | go | func (r *translateFileReader) Read(p []byte) (n int, err error) {
for {
// Obtain notification channel before we check for new data.
notify := r.store.WriteNotify()
// Exit if we can read one or more valid entries or we receive an error.
if n, err = r.read(p); n > 0 || err != nil {
return n, err
}
// ... | [
"func",
"(",
"r",
"*",
"translateFileReader",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"for",
"{",
"// Obtain notification channel before we check for new data.",
"notify",
":=",
"r",
".",
"store",
".",
... | // Read reads the next section of the available data to p. This should always
// read from the start of an entry and read n bytes to the end of another entry. | [
"Read",
"reads",
"the",
"next",
"section",
"of",
"the",
"available",
"data",
"to",
"p",
".",
"This",
"should",
"always",
"read",
"from",
"the",
"start",
"of",
"an",
"entry",
"and",
"read",
"n",
"bytes",
"to",
"the",
"end",
"of",
"another",
"entry",
"."... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L1104-L1126 | train |
pilosa/pilosa | translate.go | read | func (r *translateFileReader) read(p []byte) (n int, err error) {
sz := r.store.size()
// Exit if there is no new data.
if sz < r.offset {
return 0, fmt.Errorf("pilosa: translate store reader past file size: sz=%d off=%d", sz, r.offset)
} else if sz == r.offset {
return 0, nil
}
if max := sz - r.offset; max... | go | func (r *translateFileReader) read(p []byte) (n int, err error) {
sz := r.store.size()
// Exit if there is no new data.
if sz < r.offset {
return 0, fmt.Errorf("pilosa: translate store reader past file size: sz=%d off=%d", sz, r.offset)
} else if sz == r.offset {
return 0, nil
}
if max := sz - r.offset; max... | [
"func",
"(",
"r",
"*",
"translateFileReader",
")",
"read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"sz",
":=",
"r",
".",
"store",
".",
"size",
"(",
")",
"\n\n",
"// Exit if there is no new data.",
"if",
"sz",
... | // read writes the bytes for zero or more valid entries to p. | [
"read",
"writes",
"the",
"bytes",
"for",
"zero",
"or",
"more",
"valid",
"entries",
"to",
"p",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L1129-L1155 | train |
pilosa/pilosa | translate.go | TranslateColumnToString | func (s nopTranslateStore) TranslateColumnToString(index string, values uint64) (string, error) {
return "", nil
} | go | func (s nopTranslateStore) TranslateColumnToString(index string, values uint64) (string, error) {
return "", nil
} | [
"func",
"(",
"s",
"nopTranslateStore",
")",
"TranslateColumnToString",
"(",
"index",
"string",
",",
"values",
"uint64",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"\"",
"\"",
",",
"nil",
"\n",
"}"
] | // TranslateColumnToString is a no-op implementation of the TranslateStore TranslateColumnToString method. | [
"TranslateColumnToString",
"is",
"a",
"no",
"-",
"op",
"implementation",
"of",
"the",
"TranslateStore",
"TranslateColumnToString",
"method",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L1182-L1184 | train |
pilosa/pilosa | translate.go | TranslateRowsToUint64 | func (s nopTranslateStore) TranslateRowsToUint64(index, field string, values []string) ([]uint64, error) {
return []uint64{}, nil
} | go | func (s nopTranslateStore) TranslateRowsToUint64(index, field string, values []string) ([]uint64, error) {
return []uint64{}, nil
} | [
"func",
"(",
"s",
"nopTranslateStore",
")",
"TranslateRowsToUint64",
"(",
"index",
",",
"field",
"string",
",",
"values",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"uint64",
",",
"error",
")",
"{",
"return",
"[",
"]",
"uint64",
"{",
"}",
",",
"nil",
"\... | // TranslateRowsToUint64 is a no-op implementation of the TranslateStore TranslateRowsToUint64 method. | [
"TranslateRowsToUint64",
"is",
"a",
"no",
"-",
"op",
"implementation",
"of",
"the",
"TranslateStore",
"TranslateRowsToUint64",
"method",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L1187-L1189 | train |
pilosa/pilosa | translate.go | Reader | func (s nopTranslateStore) Reader(ctx context.Context, off int64) (io.ReadCloser, error) {
return ioutil.NopCloser(bytes.NewReader(nil)), nil
} | go | func (s nopTranslateStore) Reader(ctx context.Context, off int64) (io.ReadCloser, error) {
return ioutil.NopCloser(bytes.NewReader(nil)), nil
} | [
"func",
"(",
"s",
"nopTranslateStore",
")",
"Reader",
"(",
"ctx",
"context",
".",
"Context",
",",
"off",
"int64",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"return",
"ioutil",
".",
"NopCloser",
"(",
"bytes",
".",
"NewReader",
"(",
"nil... | // Reader is a no-op implementation of the TranslateStore Reader method. | [
"Reader",
"is",
"a",
"no",
"-",
"op",
"implementation",
"of",
"the",
"TranslateStore",
"Reader",
"method",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/translate.go#L1197-L1199 | train |
pilosa/pilosa | server/setup_logger.go | setupLogger | func (m *Command) setupLogger() error {
if m.Config.LogPath == "" {
m.logOutput = m.Stderr
} else {
f, err := os.OpenFile(m.Config.LogPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
if err != nil {
return errors.Wrap(err, "opening file")
}
m.logOutput = f
err = syscall.Dup2(int(f.Fd()), int(os.Stderr.Fd... | go | func (m *Command) setupLogger() error {
if m.Config.LogPath == "" {
m.logOutput = m.Stderr
} else {
f, err := os.OpenFile(m.Config.LogPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
if err != nil {
return errors.Wrap(err, "opening file")
}
m.logOutput = f
err = syscall.Dup2(int(f.Fd()), int(os.Stderr.Fd... | [
"func",
"(",
"m",
"*",
"Command",
")",
"setupLogger",
"(",
")",
"error",
"{",
"if",
"m",
".",
"Config",
".",
"LogPath",
"==",
"\"",
"\"",
"{",
"m",
".",
"logOutput",
"=",
"m",
".",
"Stderr",
"\n",
"}",
"else",
"{",
"f",
",",
"err",
":=",
"os",
... | // setupLogger sets up the logger based on the configuration. | [
"setupLogger",
"sets",
"up",
"the",
"logger",
"based",
"on",
"the",
"configuration",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/server/setup_logger.go#L28-L49 | train |
pilosa/pilosa | field.go | OptFieldTypeDefault | func OptFieldTypeDefault() FieldOption {
return func(fo *FieldOptions) error {
if fo.Type != "" {
return errors.Errorf("field type is already set to: %s", fo.Type)
}
fo.Type = FieldTypeSet
fo.CacheType = DefaultCacheType
fo.CacheSize = DefaultCacheSize
return nil
}
} | go | func OptFieldTypeDefault() FieldOption {
return func(fo *FieldOptions) error {
if fo.Type != "" {
return errors.Errorf("field type is already set to: %s", fo.Type)
}
fo.Type = FieldTypeSet
fo.CacheType = DefaultCacheType
fo.CacheSize = DefaultCacheSize
return nil
}
} | [
"func",
"OptFieldTypeDefault",
"(",
")",
"FieldOption",
"{",
"return",
"func",
"(",
"fo",
"*",
"FieldOptions",
")",
"error",
"{",
"if",
"fo",
".",
"Type",
"!=",
"\"",
"\"",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"fo",
".",
"Typ... | // OptFieldTypeDefault is a functional option on FieldOptions
// used to set the field type and cache setting to the default values. | [
"OptFieldTypeDefault",
"is",
"a",
"functional",
"option",
"on",
"FieldOptions",
"used",
"to",
"set",
"the",
"field",
"type",
"and",
"cache",
"setting",
"to",
"the",
"default",
"values",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L103-L113 | train |
pilosa/pilosa | field.go | OptFieldTypeSet | func OptFieldTypeSet(cacheType string, cacheSize uint32) FieldOption {
return func(fo *FieldOptions) error {
if fo.Type != "" {
return errors.Errorf("field type is already set to: %s", fo.Type)
}
fo.Type = FieldTypeSet
fo.CacheType = cacheType
fo.CacheSize = cacheSize
return nil
}
} | go | func OptFieldTypeSet(cacheType string, cacheSize uint32) FieldOption {
return func(fo *FieldOptions) error {
if fo.Type != "" {
return errors.Errorf("field type is already set to: %s", fo.Type)
}
fo.Type = FieldTypeSet
fo.CacheType = cacheType
fo.CacheSize = cacheSize
return nil
}
} | [
"func",
"OptFieldTypeSet",
"(",
"cacheType",
"string",
",",
"cacheSize",
"uint32",
")",
"FieldOption",
"{",
"return",
"func",
"(",
"fo",
"*",
"FieldOptions",
")",
"error",
"{",
"if",
"fo",
".",
"Type",
"!=",
"\"",
"\"",
"{",
"return",
"errors",
".",
"Err... | // OptFieldTypeSet is a functional option on FieldOptions
// used to specify the field as being type `set` and to
// provide any respective configuration values. | [
"OptFieldTypeSet",
"is",
"a",
"functional",
"option",
"on",
"FieldOptions",
"used",
"to",
"specify",
"the",
"field",
"as",
"being",
"type",
"set",
"and",
"to",
"provide",
"any",
"respective",
"configuration",
"values",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L118-L128 | train |
pilosa/pilosa | field.go | OptFieldTypeInt | func OptFieldTypeInt(min, max int64) FieldOption {
return func(fo *FieldOptions) error {
if fo.Type != "" {
return errors.Errorf("field type is already set to: %s", fo.Type)
}
if min > max {
return ErrInvalidBSIGroupRange
}
fo.Type = FieldTypeInt
fo.Min = min
fo.Max = max
return nil
}
} | go | func OptFieldTypeInt(min, max int64) FieldOption {
return func(fo *FieldOptions) error {
if fo.Type != "" {
return errors.Errorf("field type is already set to: %s", fo.Type)
}
if min > max {
return ErrInvalidBSIGroupRange
}
fo.Type = FieldTypeInt
fo.Min = min
fo.Max = max
return nil
}
} | [
"func",
"OptFieldTypeInt",
"(",
"min",
",",
"max",
"int64",
")",
"FieldOption",
"{",
"return",
"func",
"(",
"fo",
"*",
"FieldOptions",
")",
"error",
"{",
"if",
"fo",
".",
"Type",
"!=",
"\"",
"\"",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\... | // OptFieldTypeInt is a functional option on FieldOptions
// used to specify the field as being type `int` and to
// provide any respective configuration values. | [
"OptFieldTypeInt",
"is",
"a",
"functional",
"option",
"on",
"FieldOptions",
"used",
"to",
"specify",
"the",
"field",
"as",
"being",
"type",
"int",
"and",
"to",
"provide",
"any",
"respective",
"configuration",
"values",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L133-L146 | train |
pilosa/pilosa | field.go | OptFieldTypeTime | func OptFieldTypeTime(timeQuantum TimeQuantum, opt ...bool) FieldOption {
return func(fo *FieldOptions) error {
if fo.Type != "" {
return errors.Errorf("field type is already set to: %s", fo.Type)
}
if !timeQuantum.Valid() {
return ErrInvalidTimeQuantum
}
fo.Type = FieldTypeTime
fo.TimeQuantum = time... | go | func OptFieldTypeTime(timeQuantum TimeQuantum, opt ...bool) FieldOption {
return func(fo *FieldOptions) error {
if fo.Type != "" {
return errors.Errorf("field type is already set to: %s", fo.Type)
}
if !timeQuantum.Valid() {
return ErrInvalidTimeQuantum
}
fo.Type = FieldTypeTime
fo.TimeQuantum = time... | [
"func",
"OptFieldTypeTime",
"(",
"timeQuantum",
"TimeQuantum",
",",
"opt",
"...",
"bool",
")",
"FieldOption",
"{",
"return",
"func",
"(",
"fo",
"*",
"FieldOptions",
")",
"error",
"{",
"if",
"fo",
".",
"Type",
"!=",
"\"",
"\"",
"{",
"return",
"errors",
".... | // OptFieldTypeTime is a functional option on FieldOptions
// used to specify the field as being type `time` and to
// provide any respective configuration values.
// Pass true to skip creation of the standard view. | [
"OptFieldTypeTime",
"is",
"a",
"functional",
"option",
"on",
"FieldOptions",
"used",
"to",
"specify",
"the",
"field",
"as",
"being",
"type",
"time",
"and",
"to",
"provide",
"any",
"respective",
"configuration",
"values",
".",
"Pass",
"true",
"to",
"skip",
"cre... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L152-L165 | train |
pilosa/pilosa | field.go | OptFieldTypeMutex | func OptFieldTypeMutex(cacheType string, cacheSize uint32) FieldOption {
return func(fo *FieldOptions) error {
if fo.Type != "" {
return errors.Errorf("field type is already set to: %s", fo.Type)
}
fo.Type = FieldTypeMutex
fo.CacheType = cacheType
fo.CacheSize = cacheSize
return nil
}
} | go | func OptFieldTypeMutex(cacheType string, cacheSize uint32) FieldOption {
return func(fo *FieldOptions) error {
if fo.Type != "" {
return errors.Errorf("field type is already set to: %s", fo.Type)
}
fo.Type = FieldTypeMutex
fo.CacheType = cacheType
fo.CacheSize = cacheSize
return nil
}
} | [
"func",
"OptFieldTypeMutex",
"(",
"cacheType",
"string",
",",
"cacheSize",
"uint32",
")",
"FieldOption",
"{",
"return",
"func",
"(",
"fo",
"*",
"FieldOptions",
")",
"error",
"{",
"if",
"fo",
".",
"Type",
"!=",
"\"",
"\"",
"{",
"return",
"errors",
".",
"E... | // OptFieldTypeMutex is a functional option on FieldOptions
// used to specify the field as being type `mutex` and to
// provide any respective configuration values. | [
"OptFieldTypeMutex",
"is",
"a",
"functional",
"option",
"on",
"FieldOptions",
"used",
"to",
"specify",
"the",
"field",
"as",
"being",
"type",
"mutex",
"and",
"to",
"provide",
"any",
"respective",
"configuration",
"values",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L170-L180 | train |
pilosa/pilosa | field.go | OptFieldTypeBool | func OptFieldTypeBool() FieldOption {
return func(fo *FieldOptions) error {
if fo.Type != "" {
return errors.Errorf("field type is already set to: %s", fo.Type)
}
fo.Type = FieldTypeBool
return nil
}
} | go | func OptFieldTypeBool() FieldOption {
return func(fo *FieldOptions) error {
if fo.Type != "" {
return errors.Errorf("field type is already set to: %s", fo.Type)
}
fo.Type = FieldTypeBool
return nil
}
} | [
"func",
"OptFieldTypeBool",
"(",
")",
"FieldOption",
"{",
"return",
"func",
"(",
"fo",
"*",
"FieldOptions",
")",
"error",
"{",
"if",
"fo",
".",
"Type",
"!=",
"\"",
"\"",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"fo",
".",
"Type",... | // OptFieldTypeBool is a functional option on FieldOptions
// used to specify the field as being type `bool` and to
// provide any respective configuration values. | [
"OptFieldTypeBool",
"is",
"a",
"functional",
"option",
"on",
"FieldOptions",
"used",
"to",
"specify",
"the",
"field",
"as",
"being",
"type",
"bool",
"and",
"to",
"provide",
"any",
"respective",
"configuration",
"values",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L185-L193 | train |
pilosa/pilosa | field.go | NewField | func NewField(path, index, name string, opts FieldOption) (*Field, error) {
err := validateName(name)
if err != nil {
return nil, errors.Wrap(err, "validating name")
}
return newField(path, index, name, opts)
} | go | func NewField(path, index, name string, opts FieldOption) (*Field, error) {
err := validateName(name)
if err != nil {
return nil, errors.Wrap(err, "validating name")
}
return newField(path, index, name, opts)
} | [
"func",
"NewField",
"(",
"path",
",",
"index",
",",
"name",
"string",
",",
"opts",
"FieldOption",
")",
"(",
"*",
"Field",
",",
"error",
")",
"{",
"err",
":=",
"validateName",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"... | // NewField returns a new instance of field. | [
"NewField",
"returns",
"a",
"new",
"instance",
"of",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L196-L203 | train |
pilosa/pilosa | field.go | AvailableShards | func (f *Field) AvailableShards() *roaring.Bitmap {
f.mu.RLock()
defer f.mu.RUnlock()
b := f.remoteAvailableShards.Clone()
for _, view := range f.viewMap {
b = b.Union(view.availableShards())
}
return b
} | go | func (f *Field) AvailableShards() *roaring.Bitmap {
f.mu.RLock()
defer f.mu.RUnlock()
b := f.remoteAvailableShards.Clone()
for _, view := range f.viewMap {
b = b.Union(view.availableShards())
}
return b
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"AvailableShards",
"(",
")",
"*",
"roaring",
".",
"Bitmap",
"{",
"f",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"b",
":=",
"f",
".",
"remoteAvailableSh... | // AvailableShards returns a bitmap of shards that contain data. | [
"AvailableShards",
"returns",
"a",
"bitmap",
"of",
"shards",
"that",
"contain",
"data",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L248-L257 | train |
pilosa/pilosa | field.go | AddRemoteAvailableShards | func (f *Field) AddRemoteAvailableShards(b *roaring.Bitmap) error {
f.mergeRemoteAvailableShards(b)
// Save the updated bitmap to the data store.
return f.saveAvailableShards()
} | go | func (f *Field) AddRemoteAvailableShards(b *roaring.Bitmap) error {
f.mergeRemoteAvailableShards(b)
// Save the updated bitmap to the data store.
return f.saveAvailableShards()
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"AddRemoteAvailableShards",
"(",
"b",
"*",
"roaring",
".",
"Bitmap",
")",
"error",
"{",
"f",
".",
"mergeRemoteAvailableShards",
"(",
"b",
")",
"\n",
"// Save the updated bitmap to the data store.",
"return",
"f",
".",
"saveAv... | // AddRemoteAvailableShards merges the set of available shards into the current known set
// and saves the set to a file. | [
"AddRemoteAvailableShards",
"merges",
"the",
"set",
"of",
"available",
"shards",
"into",
"the",
"current",
"known",
"set",
"and",
"saves",
"the",
"set",
"to",
"a",
"file",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L261-L265 | train |
pilosa/pilosa | field.go | mergeRemoteAvailableShards | func (f *Field) mergeRemoteAvailableShards(b *roaring.Bitmap) {
f.mu.Lock()
defer f.mu.Unlock()
f.remoteAvailableShards = f.remoteAvailableShards.Union(b)
} | go | func (f *Field) mergeRemoteAvailableShards(b *roaring.Bitmap) {
f.mu.Lock()
defer f.mu.Unlock()
f.remoteAvailableShards = f.remoteAvailableShards.Union(b)
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"mergeRemoteAvailableShards",
"(",
"b",
"*",
"roaring",
".",
"Bitmap",
")",
"{",
"f",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"f",
".",
"remoteAvailableSha... | // mergeRemoteAvailableShards merges the set of available shards into the current known set. | [
"mergeRemoteAvailableShards",
"merges",
"the",
"set",
"of",
"available",
"shards",
"into",
"the",
"current",
"known",
"set",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L268-L272 | train |
pilosa/pilosa | field.go | loadAvailableShards | func (f *Field) loadAvailableShards() error {
bm := roaring.NewBitmap()
// Read data from meta file.
path := filepath.Join(f.path, ".available.shards")
buf, err := ioutil.ReadFile(path)
if os.IsNotExist(err) {
return nil
} else if err != nil {
return errors.Wrap(err, "reading available shards")
} else {
if... | go | func (f *Field) loadAvailableShards() error {
bm := roaring.NewBitmap()
// Read data from meta file.
path := filepath.Join(f.path, ".available.shards")
buf, err := ioutil.ReadFile(path)
if os.IsNotExist(err) {
return nil
} else if err != nil {
return errors.Wrap(err, "reading available shards")
} else {
if... | [
"func",
"(",
"f",
"*",
"Field",
")",
"loadAvailableShards",
"(",
")",
"error",
"{",
"bm",
":=",
"roaring",
".",
"NewBitmap",
"(",
")",
"\n",
"// Read data from meta file.",
"path",
":=",
"filepath",
".",
"Join",
"(",
"f",
".",
"path",
",",
"\"",
"\"",
... | // loadAvailableShards reads remoteAvailableShards data for the field, if any. | [
"loadAvailableShards",
"reads",
"remoteAvailableShards",
"data",
"for",
"the",
"field",
"if",
"any",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L275-L293 | train |
pilosa/pilosa | field.go | saveAvailableShards | func (f *Field) saveAvailableShards() error {
f.mu.Lock()
defer f.mu.Unlock()
return f.unprotectedSaveAvailableShards()
} | go | func (f *Field) saveAvailableShards() error {
f.mu.Lock()
defer f.mu.Unlock()
return f.unprotectedSaveAvailableShards()
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"saveAvailableShards",
"(",
")",
"error",
"{",
"f",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"f",
".",
"unprotectedSaveAvailableShards",
"(",
")",
... | // saveAvailableShards writes remoteAvailableShards data for the field. | [
"saveAvailableShards",
"writes",
"remoteAvailableShards",
"data",
"for",
"the",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L296-L300 | train |
pilosa/pilosa | field.go | Type | func (f *Field) Type() string {
f.mu.RLock()
defer f.mu.RUnlock()
return f.options.Type
} | go | func (f *Field) Type() string {
f.mu.RLock()
defer f.mu.RUnlock()
return f.options.Type
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"Type",
"(",
")",
"string",
"{",
"f",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"f",
".",
"options",
".",
"Type",
"\n",
"}"
] | // Type returns the field type. | [
"Type",
"returns",
"the",
"field",
"type",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L339-L343 | train |
pilosa/pilosa | field.go | SetCacheSize | func (f *Field) SetCacheSize(v uint32) error {
f.mu.Lock()
defer f.mu.Unlock()
// Ignore if no change occurred.
if v == 0 || f.options.CacheSize == v {
return nil
}
// Persist meta data to disk on change.
f.options.CacheSize = v
if err := f.saveMeta(); err != nil {
return errors.Wrap(err, "saving")
}
r... | go | func (f *Field) SetCacheSize(v uint32) error {
f.mu.Lock()
defer f.mu.Unlock()
// Ignore if no change occurred.
if v == 0 || f.options.CacheSize == v {
return nil
}
// Persist meta data to disk on change.
f.options.CacheSize = v
if err := f.saveMeta(); err != nil {
return errors.Wrap(err, "saving")
}
r... | [
"func",
"(",
"f",
"*",
"Field",
")",
"SetCacheSize",
"(",
"v",
"uint32",
")",
"error",
"{",
"f",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"// Ignore if no change occurred.",
"if",
"v",
"==",
... | // SetCacheSize sets the cache size for ranked fames. Persists to meta file on update.
// defaults to DefaultCacheSize 50000 | [
"SetCacheSize",
"sets",
"the",
"cache",
"size",
"for",
"ranked",
"fames",
".",
"Persists",
"to",
"meta",
"file",
"on",
"update",
".",
"defaults",
"to",
"DefaultCacheSize",
"50000"
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L347-L363 | train |
pilosa/pilosa | field.go | CacheSize | func (f *Field) CacheSize() uint32 {
f.mu.RLock()
v := f.options.CacheSize
f.mu.RUnlock()
return v
} | go | func (f *Field) CacheSize() uint32 {
f.mu.RLock()
v := f.options.CacheSize
f.mu.RUnlock()
return v
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"CacheSize",
"(",
")",
"uint32",
"{",
"f",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"v",
":=",
"f",
".",
"options",
".",
"CacheSize",
"\n",
"f",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"v",
"\... | // CacheSize returns the ranked field cache size. | [
"CacheSize",
"returns",
"the",
"ranked",
"field",
"cache",
"size",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L366-L371 | train |
pilosa/pilosa | field.go | Options | func (f *Field) Options() FieldOptions {
f.mu.RLock()
defer f.mu.RUnlock()
return f.options
} | go | func (f *Field) Options() FieldOptions {
f.mu.RLock()
defer f.mu.RUnlock()
return f.options
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"Options",
"(",
")",
"FieldOptions",
"{",
"f",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"f",
".",
"options",
"\n",
"}"
] | // Options returns all options for this field. | [
"Options",
"returns",
"all",
"options",
"for",
"this",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L374-L378 | train |
pilosa/pilosa | field.go | Open | func (f *Field) Open() error {
if err := func() error {
// Ensure the field's path exists.
f.logger.Debugf("ensure field path exists: %s", f.path)
if err := os.MkdirAll(f.path, 0777); err != nil {
return errors.Wrap(err, "creating field dir")
}
f.logger.Debugf("load meta file for index/field: %s/%s", f.i... | go | func (f *Field) Open() error {
if err := func() error {
// Ensure the field's path exists.
f.logger.Debugf("ensure field path exists: %s", f.path)
if err := os.MkdirAll(f.path, 0777); err != nil {
return errors.Wrap(err, "creating field dir")
}
f.logger.Debugf("load meta file for index/field: %s/%s", f.i... | [
"func",
"(",
"f",
"*",
"Field",
")",
"Open",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"func",
"(",
")",
"error",
"{",
"// Ensure the field's path exists.",
"f",
".",
"logger",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"f",
".",
"path",
")",
"\n",
"if"... | // Open opens and initializes the field. | [
"Open",
"opens",
"and",
"initializes",
"the",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L381-L423 | train |
pilosa/pilosa | field.go | openViews | func (f *Field) openViews() error {
file, err := os.Open(filepath.Join(f.path, "views"))
if os.IsNotExist(err) {
return nil
} else if err != nil {
return errors.Wrap(err, "opening view directory")
}
defer file.Close()
fis, err := file.Readdir(0)
if err != nil {
return errors.Wrap(err, "reading directory")... | go | func (f *Field) openViews() error {
file, err := os.Open(filepath.Join(f.path, "views"))
if os.IsNotExist(err) {
return nil
} else if err != nil {
return errors.Wrap(err, "opening view directory")
}
defer file.Close()
fis, err := file.Readdir(0)
if err != nil {
return errors.Wrap(err, "reading directory")... | [
"func",
"(",
"f",
"*",
"Field",
")",
"openViews",
"(",
")",
"error",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filepath",
".",
"Join",
"(",
"f",
".",
"path",
",",
"\"",
"\"",
")",
")",
"\n",
"if",
"os",
".",
"IsNotExist",
"(",
"... | // openViews opens and initializes the views inside the field. | [
"openViews",
"opens",
"and",
"initializes",
"the",
"views",
"inside",
"the",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L426-L457 | train |
pilosa/pilosa | field.go | loadMeta | func (f *Field) loadMeta() error {
var pb internal.FieldOptions
// Read data from meta file.
buf, err := ioutil.ReadFile(filepath.Join(f.path, ".meta"))
if os.IsNotExist(err) {
return nil
} else if err != nil {
return errors.Wrap(err, "reading meta")
} else {
if err := proto.Unmarshal(buf, &pb); err != nil... | go | func (f *Field) loadMeta() error {
var pb internal.FieldOptions
// Read data from meta file.
buf, err := ioutil.ReadFile(filepath.Join(f.path, ".meta"))
if os.IsNotExist(err) {
return nil
} else if err != nil {
return errors.Wrap(err, "reading meta")
} else {
if err := proto.Unmarshal(buf, &pb); err != nil... | [
"func",
"(",
"f",
"*",
"Field",
")",
"loadMeta",
"(",
")",
"error",
"{",
"var",
"pb",
"internal",
".",
"FieldOptions",
"\n\n",
"// Read data from meta file.",
"buf",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filepath",
".",
"Join",
"(",
"f",
"."... | // loadMeta reads meta data for the field, if any. | [
"loadMeta",
"reads",
"meta",
"data",
"for",
"the",
"field",
"if",
"any",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L460-L486 | train |
pilosa/pilosa | field.go | saveMeta | func (f *Field) saveMeta() error {
// Marshal metadata.
fo := f.options
buf, err := proto.Marshal(fo.encode())
if err != nil {
return errors.Wrap(err, "marshaling")
}
// Write to meta file.
if err := ioutil.WriteFile(filepath.Join(f.path, ".meta"), buf, 0666); err != nil {
return errors.Wrap(err, "writing m... | go | func (f *Field) saveMeta() error {
// Marshal metadata.
fo := f.options
buf, err := proto.Marshal(fo.encode())
if err != nil {
return errors.Wrap(err, "marshaling")
}
// Write to meta file.
if err := ioutil.WriteFile(filepath.Join(f.path, ".meta"), buf, 0666); err != nil {
return errors.Wrap(err, "writing m... | [
"func",
"(",
"f",
"*",
"Field",
")",
"saveMeta",
"(",
")",
"error",
"{",
"// Marshal metadata.",
"fo",
":=",
"f",
".",
"options",
"\n",
"buf",
",",
"err",
":=",
"proto",
".",
"Marshal",
"(",
"fo",
".",
"encode",
"(",
")",
")",
"\n",
"if",
"err",
... | // saveMeta writes meta data for the field. | [
"saveMeta",
"writes",
"meta",
"data",
"for",
"the",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L489-L503 | train |
pilosa/pilosa | field.go | applyOptions | func (f *Field) applyOptions(opt FieldOptions) error {
switch opt.Type {
case FieldTypeSet, FieldTypeMutex, "":
fldType := opt.Type
if fldType == "" {
fldType = FieldTypeSet
}
f.options.Type = fldType
if opt.CacheType != "" {
f.options.CacheType = opt.CacheType
}
if opt.CacheSize != 0 {
if opt.... | go | func (f *Field) applyOptions(opt FieldOptions) error {
switch opt.Type {
case FieldTypeSet, FieldTypeMutex, "":
fldType := opt.Type
if fldType == "" {
fldType = FieldTypeSet
}
f.options.Type = fldType
if opt.CacheType != "" {
f.options.CacheType = opt.CacheType
}
if opt.CacheSize != 0 {
if opt.... | [
"func",
"(",
"f",
"*",
"Field",
")",
"applyOptions",
"(",
"opt",
"FieldOptions",
")",
"error",
"{",
"switch",
"opt",
".",
"Type",
"{",
"case",
"FieldTypeSet",
",",
"FieldTypeMutex",
",",
"\"",
"\"",
":",
"fldType",
":=",
"opt",
".",
"Type",
"\n",
"if",... | // applyOptions configures the field based on opt. | [
"applyOptions",
"configures",
"the",
"field",
"based",
"on",
"opt",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L506-L577 | train |
pilosa/pilosa | field.go | Close | func (f *Field) Close() error {
f.mu.Lock()
defer f.mu.Unlock()
// Close the attribute store.
if f.rowAttrStore != nil {
_ = f.rowAttrStore.Close()
}
// Close all views.
for _, view := range f.viewMap {
if err := view.close(); err != nil {
return err
}
}
f.viewMap = make(map[string]*view)
return n... | go | func (f *Field) Close() error {
f.mu.Lock()
defer f.mu.Unlock()
// Close the attribute store.
if f.rowAttrStore != nil {
_ = f.rowAttrStore.Close()
}
// Close all views.
for _, view := range f.viewMap {
if err := view.close(); err != nil {
return err
}
}
f.viewMap = make(map[string]*view)
return n... | [
"func",
"(",
"f",
"*",
"Field",
")",
"Close",
"(",
")",
"error",
"{",
"f",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"// Close the attribute store.",
"if",
"f",
".",
"rowAttrStore",
"!=",
"nil... | // Close closes the field and its views. | [
"Close",
"closes",
"the",
"field",
"and",
"its",
"views",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L580-L598 | train |
pilosa/pilosa | field.go | keys | func (f *Field) keys() bool {
f.mu.RLock()
defer f.mu.RUnlock()
return f.options.Keys
} | go | func (f *Field) keys() bool {
f.mu.RLock()
defer f.mu.RUnlock()
return f.options.Keys
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"keys",
"(",
")",
"bool",
"{",
"f",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"f",
".",
"options",
".",
"Keys",
"\n",
"}"
] | // keys returns true if the field uses string keys. | [
"keys",
"returns",
"true",
"if",
"the",
"field",
"uses",
"string",
"keys",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L601-L605 | train |
pilosa/pilosa | field.go | bsiGroup | func (f *Field) bsiGroup(name string) *bsiGroup {
f.mu.RLock()
defer f.mu.RUnlock()
for _, bsig := range f.bsiGroups {
if bsig.Name == name {
return bsig
}
}
return nil
} | go | func (f *Field) bsiGroup(name string) *bsiGroup {
f.mu.RLock()
defer f.mu.RUnlock()
for _, bsig := range f.bsiGroups {
if bsig.Name == name {
return bsig
}
}
return nil
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"bsiGroup",
"(",
"name",
"string",
")",
"*",
"bsiGroup",
"{",
"f",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"for",
"_",
",",
"bsig",
":=",
"range",
... | // bsiGroup returns a bsiGroup by name. | [
"bsiGroup",
"returns",
"a",
"bsiGroup",
"by",
"name",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L608-L617 | train |
pilosa/pilosa | field.go | hasBSIGroup | func (f *Field) hasBSIGroup(name string) bool {
for _, bsig := range f.bsiGroups {
if bsig.Name == name {
return true
}
}
return false
} | go | func (f *Field) hasBSIGroup(name string) bool {
for _, bsig := range f.bsiGroups {
if bsig.Name == name {
return true
}
}
return false
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"hasBSIGroup",
"(",
"name",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"bsig",
":=",
"range",
"f",
".",
"bsiGroups",
"{",
"if",
"bsig",
".",
"Name",
"==",
"name",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",... | // hasBSIGroup returns true if a bsiGroup exists on the field. | [
"hasBSIGroup",
"returns",
"true",
"if",
"a",
"bsiGroup",
"exists",
"on",
"the",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L620-L627 | train |
pilosa/pilosa | field.go | createBSIGroup | func (f *Field) createBSIGroup(bsig *bsiGroup) error {
f.mu.Lock()
defer f.mu.Unlock()
// Append bsiGroup.
if err := f.addBSIGroup(bsig); err != nil {
return err
}
if err := f.saveMeta(); err != nil {
return errors.Wrap(err, "saving")
}
return nil
} | go | func (f *Field) createBSIGroup(bsig *bsiGroup) error {
f.mu.Lock()
defer f.mu.Unlock()
// Append bsiGroup.
if err := f.addBSIGroup(bsig); err != nil {
return err
}
if err := f.saveMeta(); err != nil {
return errors.Wrap(err, "saving")
}
return nil
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"createBSIGroup",
"(",
"bsig",
"*",
"bsiGroup",
")",
"error",
"{",
"f",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"// Append bsiGroup.",
"if",
"err",
":=",... | // createBSIGroup creates a new bsiGroup on the field. | [
"createBSIGroup",
"creates",
"a",
"new",
"bsiGroup",
"on",
"the",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L630-L642 | train |
pilosa/pilosa | field.go | addBSIGroup | func (f *Field) addBSIGroup(bsig *bsiGroup) error {
if err := bsig.validate(); err != nil {
return errors.Wrap(err, "validating bsigroup")
} else if f.hasBSIGroup(bsig.Name) {
return ErrBSIGroupExists
}
// Add bsiGroup to list.
f.bsiGroups = append(f.bsiGroups, bsig)
// Sort bsiGroups by name.
sort.Slice(f... | go | func (f *Field) addBSIGroup(bsig *bsiGroup) error {
if err := bsig.validate(); err != nil {
return errors.Wrap(err, "validating bsigroup")
} else if f.hasBSIGroup(bsig.Name) {
return ErrBSIGroupExists
}
// Add bsiGroup to list.
f.bsiGroups = append(f.bsiGroups, bsig)
// Sort bsiGroups by name.
sort.Slice(f... | [
"func",
"(",
"f",
"*",
"Field",
")",
"addBSIGroup",
"(",
"bsig",
"*",
"bsiGroup",
")",
"error",
"{",
"if",
"err",
":=",
"bsig",
".",
"validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",... | // addBSIGroup adds a single bsiGroup to bsiGroups. | [
"addBSIGroup",
"adds",
"a",
"single",
"bsiGroup",
"to",
"bsiGroups",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L645-L661 | train |
pilosa/pilosa | field.go | TimeQuantum | func (f *Field) TimeQuantum() TimeQuantum {
f.mu.Lock()
defer f.mu.Unlock()
return f.options.TimeQuantum
} | go | func (f *Field) TimeQuantum() TimeQuantum {
f.mu.Lock()
defer f.mu.Unlock()
return f.options.TimeQuantum
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"TimeQuantum",
"(",
")",
"TimeQuantum",
"{",
"f",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"f",
".",
"options",
".",
"TimeQuantum",
"\n",
"}"
] | // TimeQuantum returns the time quantum for the field. | [
"TimeQuantum",
"returns",
"the",
"time",
"quantum",
"for",
"the",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L664-L668 | train |
pilosa/pilosa | field.go | setTimeQuantum | func (f *Field) setTimeQuantum(q TimeQuantum) error {
f.mu.Lock()
defer f.mu.Unlock()
// Validate input.
if !q.Valid() {
return ErrInvalidTimeQuantum
}
// Update value on field.
f.options.TimeQuantum = q
// Persist meta data to disk.
if err := f.saveMeta(); err != nil {
return errors.Wrap(err, "saving m... | go | func (f *Field) setTimeQuantum(q TimeQuantum) error {
f.mu.Lock()
defer f.mu.Unlock()
// Validate input.
if !q.Valid() {
return ErrInvalidTimeQuantum
}
// Update value on field.
f.options.TimeQuantum = q
// Persist meta data to disk.
if err := f.saveMeta(); err != nil {
return errors.Wrap(err, "saving m... | [
"func",
"(",
"f",
"*",
"Field",
")",
"setTimeQuantum",
"(",
"q",
"TimeQuantum",
")",
"error",
"{",
"f",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"// Validate input.",
"if",
"!",
"q",
".",
"... | // setTimeQuantum sets the time quantum for the field. | [
"setTimeQuantum",
"sets",
"the",
"time",
"quantum",
"for",
"the",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L671-L689 | train |
pilosa/pilosa | field.go | RowTime | func (f *Field) RowTime(rowID uint64, time time.Time, quantum string) (*Row, error) {
if !TimeQuantum(quantum).Valid() {
return nil, ErrInvalidTimeQuantum
}
viewname := viewsByTime(viewStandard, time, TimeQuantum(quantum[len(quantum)-1:]))[0]
view := f.view(viewname)
if view == nil {
return nil, errors.Errorf(... | go | func (f *Field) RowTime(rowID uint64, time time.Time, quantum string) (*Row, error) {
if !TimeQuantum(quantum).Valid() {
return nil, ErrInvalidTimeQuantum
}
viewname := viewsByTime(viewStandard, time, TimeQuantum(quantum[len(quantum)-1:]))[0]
view := f.view(viewname)
if view == nil {
return nil, errors.Errorf(... | [
"func",
"(",
"f",
"*",
"Field",
")",
"RowTime",
"(",
"rowID",
"uint64",
",",
"time",
"time",
".",
"Time",
",",
"quantum",
"string",
")",
"(",
"*",
"Row",
",",
"error",
")",
"{",
"if",
"!",
"TimeQuantum",
"(",
"quantum",
")",
".",
"Valid",
"(",
")... | // RowTime gets the row at the particular time with the granularity specified by
// the quantum. | [
"RowTime",
"gets",
"the",
"row",
"at",
"the",
"particular",
"time",
"with",
"the",
"granularity",
"specified",
"by",
"the",
"quantum",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L693-L703 | train |
pilosa/pilosa | field.go | viewPath | func (f *Field) viewPath(name string) string {
return filepath.Join(f.path, "views", name)
} | go | func (f *Field) viewPath(name string) string {
return filepath.Join(f.path, "views", name)
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"viewPath",
"(",
"name",
"string",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"f",
".",
"path",
",",
"\"",
"\"",
",",
"name",
")",
"\n",
"}"
] | // viewPath returns the path to a view in the field. | [
"viewPath",
"returns",
"the",
"path",
"to",
"a",
"view",
"in",
"the",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L706-L708 | train |
pilosa/pilosa | field.go | view | func (f *Field) view(name string) *view {
f.mu.RLock()
defer f.mu.RUnlock()
return f.unprotectedView(name)
} | go | func (f *Field) view(name string) *view {
f.mu.RLock()
defer f.mu.RUnlock()
return f.unprotectedView(name)
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"view",
"(",
"name",
"string",
")",
"*",
"view",
"{",
"f",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"f",
".",
"unprotectedView",
"(",
"name"... | // view returns a view in the field by name. | [
"view",
"returns",
"a",
"view",
"in",
"the",
"field",
"by",
"name",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L711-L715 | train |
pilosa/pilosa | field.go | views | func (f *Field) views() []*view {
f.mu.RLock()
defer f.mu.RUnlock()
other := make([]*view, 0, len(f.viewMap))
for _, view := range f.viewMap {
other = append(other, view)
}
return other
} | go | func (f *Field) views() []*view {
f.mu.RLock()
defer f.mu.RUnlock()
other := make([]*view, 0, len(f.viewMap))
for _, view := range f.viewMap {
other = append(other, view)
}
return other
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"views",
"(",
")",
"[",
"]",
"*",
"view",
"{",
"f",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"other",
":=",
"make",
"(",
"[",
"]",
"*",
"view",
... | // views returns a list of all views in the field. | [
"views",
"returns",
"a",
"list",
"of",
"all",
"views",
"in",
"the",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L720-L729 | train |
pilosa/pilosa | field.go | createViewIfNotExists | func (f *Field) createViewIfNotExists(name string) (*view, error) {
view, created, err := f.createViewIfNotExistsBase(name)
if err != nil {
return nil, err
}
if created {
// Broadcast view creation to the cluster.
err = f.broadcaster.SendSync(
&CreateViewMessage{
Index: f.index,
Field: f.name,
... | go | func (f *Field) createViewIfNotExists(name string) (*view, error) {
view, created, err := f.createViewIfNotExistsBase(name)
if err != nil {
return nil, err
}
if created {
// Broadcast view creation to the cluster.
err = f.broadcaster.SendSync(
&CreateViewMessage{
Index: f.index,
Field: f.name,
... | [
"func",
"(",
"f",
"*",
"Field",
")",
"createViewIfNotExists",
"(",
"name",
"string",
")",
"(",
"*",
"view",
",",
"error",
")",
"{",
"view",
",",
"created",
",",
"err",
":=",
"f",
".",
"createViewIfNotExistsBase",
"(",
"name",
")",
"\n",
"if",
"err",
... | // createViewIfNotExists returns the named view, creating it if necessary.
// Additionally, a CreateViewMessage is sent to the cluster. | [
"createViewIfNotExists",
"returns",
"the",
"named",
"view",
"creating",
"it",
"if",
"necessary",
".",
"Additionally",
"a",
"CreateViewMessage",
"is",
"sent",
"to",
"the",
"cluster",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L740-L760 | train |
pilosa/pilosa | field.go | createViewIfNotExistsBase | func (f *Field) createViewIfNotExistsBase(name string) (*view, bool, error) {
f.mu.Lock()
defer f.mu.Unlock()
if view := f.viewMap[name]; view != nil {
return view, false, nil
}
view := f.newView(f.viewPath(name), name)
if err := view.open(); err != nil {
return nil, false, errors.Wrap(err, "opening view")
... | go | func (f *Field) createViewIfNotExistsBase(name string) (*view, bool, error) {
f.mu.Lock()
defer f.mu.Unlock()
if view := f.viewMap[name]; view != nil {
return view, false, nil
}
view := f.newView(f.viewPath(name), name)
if err := view.open(); err != nil {
return nil, false, errors.Wrap(err, "opening view")
... | [
"func",
"(",
"f",
"*",
"Field",
")",
"createViewIfNotExistsBase",
"(",
"name",
"string",
")",
"(",
"*",
"view",
",",
"bool",
",",
"error",
")",
"{",
"f",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"mu",
".",
"Unlock",
"(",
")",
... | // createViewIfNotExistsBase returns the named view, creating it if necessary.
// The returned bool indicates whether the view was created or not. | [
"createViewIfNotExistsBase",
"returns",
"the",
"named",
"view",
"creating",
"it",
"if",
"necessary",
".",
"The",
"returned",
"bool",
"indicates",
"whether",
"the",
"view",
"was",
"created",
"or",
"not",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L764-L780 | train |
pilosa/pilosa | field.go | deleteView | func (f *Field) deleteView(name string) error {
view := f.viewMap[name]
if view == nil {
return ErrInvalidView
}
// Close data files before deletion.
if err := view.close(); err != nil {
return errors.Wrap(err, "closing view")
}
// Delete view directory.
if err := os.RemoveAll(view.path); err != nil {
r... | go | func (f *Field) deleteView(name string) error {
view := f.viewMap[name]
if view == nil {
return ErrInvalidView
}
// Close data files before deletion.
if err := view.close(); err != nil {
return errors.Wrap(err, "closing view")
}
// Delete view directory.
if err := os.RemoveAll(view.path); err != nil {
r... | [
"func",
"(",
"f",
"*",
"Field",
")",
"deleteView",
"(",
"name",
"string",
")",
"error",
"{",
"view",
":=",
"f",
".",
"viewMap",
"[",
"name",
"]",
"\n",
"if",
"view",
"==",
"nil",
"{",
"return",
"ErrInvalidView",
"\n",
"}",
"\n\n",
"// Close data files ... | // deleteView removes the view from the field. | [
"deleteView",
"removes",
"the",
"view",
"from",
"the",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L792-L811 | train |
pilosa/pilosa | field.go | Row | func (f *Field) Row(rowID uint64) (*Row, error) {
if f.Type() != FieldTypeSet {
return nil, errors.Errorf("row method unsupported for field type: %s", f.Type())
}
view := f.view(viewStandard)
if view == nil {
return nil, ErrInvalidView
}
return view.row(rowID), nil
} | go | func (f *Field) Row(rowID uint64) (*Row, error) {
if f.Type() != FieldTypeSet {
return nil, errors.Errorf("row method unsupported for field type: %s", f.Type())
}
view := f.view(viewStandard)
if view == nil {
return nil, ErrInvalidView
}
return view.row(rowID), nil
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"Row",
"(",
"rowID",
"uint64",
")",
"(",
"*",
"Row",
",",
"error",
")",
"{",
"if",
"f",
".",
"Type",
"(",
")",
"!=",
"FieldTypeSet",
"{",
"return",
"nil",
",",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
... | // Row returns a row of the standard view.
// It seems this method is only being used by the test
// package, and the fact that it's only allowed on
// `set` fields is odd. This may be considered for
// deprecation in a future version. | [
"Row",
"returns",
"a",
"row",
"of",
"the",
"standard",
"view",
".",
"It",
"seems",
"this",
"method",
"is",
"only",
"being",
"used",
"by",
"the",
"test",
"package",
"and",
"the",
"fact",
"that",
"it",
"s",
"only",
"allowed",
"on",
"set",
"fields",
"is",... | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L818-L827 | train |
pilosa/pilosa | field.go | SetBit | func (f *Field) SetBit(rowID, colID uint64, t *time.Time) (changed bool, err error) {
viewName := viewStandard
if !f.options.NoStandardView {
// Retrieve view. Exit if it doesn't exist.
view, err := f.createViewIfNotExists(viewName)
if err != nil {
return changed, errors.Wrap(err, "creating view")
}
// ... | go | func (f *Field) SetBit(rowID, colID uint64, t *time.Time) (changed bool, err error) {
viewName := viewStandard
if !f.options.NoStandardView {
// Retrieve view. Exit if it doesn't exist.
view, err := f.createViewIfNotExists(viewName)
if err != nil {
return changed, errors.Wrap(err, "creating view")
}
// ... | [
"func",
"(",
"f",
"*",
"Field",
")",
"SetBit",
"(",
"rowID",
",",
"colID",
"uint64",
",",
"t",
"*",
"time",
".",
"Time",
")",
"(",
"changed",
"bool",
",",
"err",
"error",
")",
"{",
"viewName",
":=",
"viewStandard",
"\n",
"if",
"!",
"f",
".",
"opt... | // SetBit sets a bit on a view within the field. | [
"SetBit",
"sets",
"a",
"bit",
"on",
"a",
"view",
"within",
"the",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L830-L867 | train |
pilosa/pilosa | field.go | ClearBit | func (f *Field) ClearBit(rowID, colID uint64) (changed bool, err error) {
viewName := viewStandard
// Retrieve view. Exit if it doesn't exist.
view, present := f.viewMap[viewName]
if !present {
return changed, errors.Wrap(err, "clearing missing view")
}
// Clear non-time bit.
if v, err := view.clearBit(rowI... | go | func (f *Field) ClearBit(rowID, colID uint64) (changed bool, err error) {
viewName := viewStandard
// Retrieve view. Exit if it doesn't exist.
view, present := f.viewMap[viewName]
if !present {
return changed, errors.Wrap(err, "clearing missing view")
}
// Clear non-time bit.
if v, err := view.clearBit(rowI... | [
"func",
"(",
"f",
"*",
"Field",
")",
"ClearBit",
"(",
"rowID",
",",
"colID",
"uint64",
")",
"(",
"changed",
"bool",
",",
"err",
"error",
")",
"{",
"viewName",
":=",
"viewStandard",
"\n\n",
"// Retrieve view. Exit if it doesn't exist.",
"view",
",",
"present",
... | // ClearBit clears a bit within the field. | [
"ClearBit",
"clears",
"a",
"bit",
"within",
"the",
"field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L870-L912 | train |
pilosa/pilosa | field.go | Value | func (f *Field) Value(columnID uint64) (value int64, exists bool, err error) {
bsig := f.bsiGroup(f.name)
if bsig == nil {
return 0, false, ErrBSIGroupNotFound
}
// Fetch target view.
view := f.view(viewBSIGroupPrefix + f.name)
if view == nil {
return 0, false, nil
}
v, exists, err := view.value(columnID,... | go | func (f *Field) Value(columnID uint64) (value int64, exists bool, err error) {
bsig := f.bsiGroup(f.name)
if bsig == nil {
return 0, false, ErrBSIGroupNotFound
}
// Fetch target view.
view := f.view(viewBSIGroupPrefix + f.name)
if view == nil {
return 0, false, nil
}
v, exists, err := view.value(columnID,... | [
"func",
"(",
"f",
"*",
"Field",
")",
"Value",
"(",
"columnID",
"uint64",
")",
"(",
"value",
"int64",
",",
"exists",
"bool",
",",
"err",
"error",
")",
"{",
"bsig",
":=",
"f",
".",
"bsiGroup",
"(",
"f",
".",
"name",
")",
"\n",
"if",
"bsig",
"==",
... | // Value reads a field value for a column. | [
"Value",
"reads",
"a",
"field",
"value",
"for",
"a",
"column",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L956-L975 | train |
pilosa/pilosa | field.go | SetValue | func (f *Field) SetValue(columnID uint64, value int64) (changed bool, err error) {
// Fetch bsiGroup and validate value.
bsig := f.bsiGroup(f.name)
if bsig == nil {
return false, ErrBSIGroupNotFound
} else if value < bsig.Min {
return false, ErrBSIGroupValueTooLow
} else if value > bsig.Max {
return false, E... | go | func (f *Field) SetValue(columnID uint64, value int64) (changed bool, err error) {
// Fetch bsiGroup and validate value.
bsig := f.bsiGroup(f.name)
if bsig == nil {
return false, ErrBSIGroupNotFound
} else if value < bsig.Min {
return false, ErrBSIGroupValueTooLow
} else if value > bsig.Max {
return false, E... | [
"func",
"(",
"f",
"*",
"Field",
")",
"SetValue",
"(",
"columnID",
"uint64",
",",
"value",
"int64",
")",
"(",
"changed",
"bool",
",",
"err",
"error",
")",
"{",
"// Fetch bsiGroup and validate value.",
"bsig",
":=",
"f",
".",
"bsiGroup",
"(",
"f",
".",
"na... | // SetValue sets a field value for a column. | [
"SetValue",
"sets",
"a",
"field",
"value",
"for",
"a",
"column",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L978-L999 | train |
pilosa/pilosa | field.go | Sum | func (f *Field) Sum(filter *Row, name string) (sum, count int64, err error) {
bsig := f.bsiGroup(name)
if bsig == nil {
return 0, 0, ErrBSIGroupNotFound
}
view := f.view(viewBSIGroupPrefix + name)
if view == nil {
return 0, 0, nil
}
vsum, vcount, err := view.sum(filter, bsig.BitDepth())
if err != nil {
... | go | func (f *Field) Sum(filter *Row, name string) (sum, count int64, err error) {
bsig := f.bsiGroup(name)
if bsig == nil {
return 0, 0, ErrBSIGroupNotFound
}
view := f.view(viewBSIGroupPrefix + name)
if view == nil {
return 0, 0, nil
}
vsum, vcount, err := view.sum(filter, bsig.BitDepth())
if err != nil {
... | [
"func",
"(",
"f",
"*",
"Field",
")",
"Sum",
"(",
"filter",
"*",
"Row",
",",
"name",
"string",
")",
"(",
"sum",
",",
"count",
"int64",
",",
"err",
"error",
")",
"{",
"bsig",
":=",
"f",
".",
"bsiGroup",
"(",
"name",
")",
"\n",
"if",
"bsig",
"==",... | // Sum returns the sum and count for a field.
// An optional filtering row can be provided. | [
"Sum",
"returns",
"the",
"sum",
"and",
"count",
"for",
"a",
"field",
".",
"An",
"optional",
"filtering",
"row",
"can",
"be",
"provided",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L1003-L1019 | train |
pilosa/pilosa | field.go | Min | func (f *Field) Min(filter *Row, name string) (min, count int64, err error) {
bsig := f.bsiGroup(name)
if bsig == nil {
return 0, 0, ErrBSIGroupNotFound
}
view := f.view(viewBSIGroupPrefix + name)
if view == nil {
return 0, 0, nil
}
vmin, vcount, err := view.min(filter, bsig.BitDepth())
if err != nil {
... | go | func (f *Field) Min(filter *Row, name string) (min, count int64, err error) {
bsig := f.bsiGroup(name)
if bsig == nil {
return 0, 0, ErrBSIGroupNotFound
}
view := f.view(viewBSIGroupPrefix + name)
if view == nil {
return 0, 0, nil
}
vmin, vcount, err := view.min(filter, bsig.BitDepth())
if err != nil {
... | [
"func",
"(",
"f",
"*",
"Field",
")",
"Min",
"(",
"filter",
"*",
"Row",
",",
"name",
"string",
")",
"(",
"min",
",",
"count",
"int64",
",",
"err",
"error",
")",
"{",
"bsig",
":=",
"f",
".",
"bsiGroup",
"(",
"name",
")",
"\n",
"if",
"bsig",
"==",... | // Min returns the min for a field.
// An optional filtering row can be provided. | [
"Min",
"returns",
"the",
"min",
"for",
"a",
"field",
".",
"An",
"optional",
"filtering",
"row",
"can",
"be",
"provided",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L1023-L1039 | train |
pilosa/pilosa | field.go | Max | func (f *Field) Max(filter *Row, name string) (max, count int64, err error) {
bsig := f.bsiGroup(name)
if bsig == nil {
return 0, 0, ErrBSIGroupNotFound
}
view := f.view(viewBSIGroupPrefix + name)
if view == nil {
return 0, 0, nil
}
vmax, vcount, err := view.max(filter, bsig.BitDepth())
if err != nil {
... | go | func (f *Field) Max(filter *Row, name string) (max, count int64, err error) {
bsig := f.bsiGroup(name)
if bsig == nil {
return 0, 0, ErrBSIGroupNotFound
}
view := f.view(viewBSIGroupPrefix + name)
if view == nil {
return 0, 0, nil
}
vmax, vcount, err := view.max(filter, bsig.BitDepth())
if err != nil {
... | [
"func",
"(",
"f",
"*",
"Field",
")",
"Max",
"(",
"filter",
"*",
"Row",
",",
"name",
"string",
")",
"(",
"max",
",",
"count",
"int64",
",",
"err",
"error",
")",
"{",
"bsig",
":=",
"f",
".",
"bsiGroup",
"(",
"name",
")",
"\n",
"if",
"bsig",
"==",... | // Max returns the max for a field.
// An optional filtering row can be provided. | [
"Max",
"returns",
"the",
"max",
"for",
"a",
"field",
".",
"An",
"optional",
"filtering",
"row",
"can",
"be",
"provided",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L1043-L1059 | train |
pilosa/pilosa | field.go | Range | func (f *Field) Range(name string, op pql.Token, predicate int64) (*Row, error) {
// Retrieve and validate bsiGroup.
bsig := f.bsiGroup(name)
if bsig == nil {
return nil, ErrBSIGroupNotFound
} else if predicate < bsig.Min || predicate > bsig.Max {
return nil, nil
}
// Retrieve bsiGroup's view.
view := f.vie... | go | func (f *Field) Range(name string, op pql.Token, predicate int64) (*Row, error) {
// Retrieve and validate bsiGroup.
bsig := f.bsiGroup(name)
if bsig == nil {
return nil, ErrBSIGroupNotFound
} else if predicate < bsig.Min || predicate > bsig.Max {
return nil, nil
}
// Retrieve bsiGroup's view.
view := f.vie... | [
"func",
"(",
"f",
"*",
"Field",
")",
"Range",
"(",
"name",
"string",
",",
"op",
"pql",
".",
"Token",
",",
"predicate",
"int64",
")",
"(",
"*",
"Row",
",",
"error",
")",
"{",
"// Retrieve and validate bsiGroup.",
"bsig",
":=",
"f",
".",
"bsiGroup",
"(",... | // Range performs a conditional operation on Field. | [
"Range",
"performs",
"a",
"conditional",
"operation",
"on",
"Field",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L1062-L1083 | train |
pilosa/pilosa | field.go | Import | func (f *Field) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time, opts ...ImportOption) error {
// Set up import options.
options := &ImportOptions{}
for _, opt := range opts {
err := opt(options)
if err != nil {
return errors.Wrap(err, "applying option")
}
}
// Determine quantum if timestamps... | go | func (f *Field) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time, opts ...ImportOption) error {
// Set up import options.
options := &ImportOptions{}
for _, opt := range opts {
err := opt(options)
if err != nil {
return errors.Wrap(err, "applying option")
}
}
// Determine quantum if timestamps... | [
"func",
"(",
"f",
"*",
"Field",
")",
"Import",
"(",
"rowIDs",
",",
"columnIDs",
"[",
"]",
"uint64",
",",
"timestamps",
"[",
"]",
"*",
"time",
".",
"Time",
",",
"opts",
"...",
"ImportOption",
")",
"error",
"{",
"// Set up import options.",
"options",
":="... | // Import bulk imports data. | [
"Import",
"bulk",
"imports",
"data",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L1086-L1164 | train |
pilosa/pilosa | field.go | importValue | func (f *Field) importValue(columnIDs []uint64, values []int64, options *ImportOptions) error {
viewName := viewBSIGroupPrefix + f.name
// Get the bsiGroup so we know bitDepth.
bsig := f.bsiGroup(f.name)
if bsig == nil {
return errors.Wrap(ErrBSIGroupNotFound, f.name)
}
// Split import data by fragment.
dataB... | go | func (f *Field) importValue(columnIDs []uint64, values []int64, options *ImportOptions) error {
viewName := viewBSIGroupPrefix + f.name
// Get the bsiGroup so we know bitDepth.
bsig := f.bsiGroup(f.name)
if bsig == nil {
return errors.Wrap(ErrBSIGroupNotFound, f.name)
}
// Split import data by fragment.
dataB... | [
"func",
"(",
"f",
"*",
"Field",
")",
"importValue",
"(",
"columnIDs",
"[",
"]",
"uint64",
",",
"values",
"[",
"]",
"int64",
",",
"options",
"*",
"ImportOptions",
")",
"error",
"{",
"viewName",
":=",
"viewBSIGroupPrefix",
"+",
"f",
".",
"name",
"\n",
"/... | // importValue bulk imports range-encoded value data. | [
"importValue",
"bulk",
"imports",
"range",
"-",
"encoded",
"value",
"data",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L1167-L1221 | train |
pilosa/pilosa | field.go | applyDefaultOptions | func applyDefaultOptions(o FieldOptions) FieldOptions {
if o.Type == "" {
return FieldOptions{
Type: DefaultFieldType,
CacheType: DefaultCacheType,
CacheSize: DefaultCacheSize,
}
}
return o
} | go | func applyDefaultOptions(o FieldOptions) FieldOptions {
if o.Type == "" {
return FieldOptions{
Type: DefaultFieldType,
CacheType: DefaultCacheType,
CacheSize: DefaultCacheSize,
}
}
return o
} | [
"func",
"applyDefaultOptions",
"(",
"o",
"FieldOptions",
")",
"FieldOptions",
"{",
"if",
"o",
".",
"Type",
"==",
"\"",
"\"",
"{",
"return",
"FieldOptions",
"{",
"Type",
":",
"DefaultFieldType",
",",
"CacheType",
":",
"DefaultCacheType",
",",
"CacheSize",
":",
... | // applyDefaultOptions returns a new FieldOptions object
// with default values if o does not contain a valid type. | [
"applyDefaultOptions",
"returns",
"a",
"new",
"FieldOptions",
"object",
"with",
"default",
"values",
"if",
"o",
"does",
"not",
"contain",
"a",
"valid",
"type",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L1281-L1290 | train |
pilosa/pilosa | field.go | MarshalJSON | func (o *FieldOptions) MarshalJSON() ([]byte, error) {
switch o.Type {
case FieldTypeSet:
return json.Marshal(struct {
Type string `json:"type"`
CacheType string `json:"cacheType"`
CacheSize uint32 `json:"cacheSize"`
Keys bool `json:"keys"`
}{
o.Type,
o.CacheType,
o.CacheSize,
... | go | func (o *FieldOptions) MarshalJSON() ([]byte, error) {
switch o.Type {
case FieldTypeSet:
return json.Marshal(struct {
Type string `json:"type"`
CacheType string `json:"cacheType"`
CacheSize uint32 `json:"cacheSize"`
Keys bool `json:"keys"`
}{
o.Type,
o.CacheType,
o.CacheSize,
... | [
"func",
"(",
"o",
"*",
"FieldOptions",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"switch",
"o",
".",
"Type",
"{",
"case",
"FieldTypeSet",
":",
"return",
"json",
".",
"Marshal",
"(",
"struct",
"{",
"Type",
"string",
... | // MarshalJSON marshals FieldOptions to JSON such that
// only those attributes associated to the field type
// are included. | [
"MarshalJSON",
"marshals",
"FieldOptions",
"to",
"JSON",
"such",
"that",
"only",
"those",
"attributes",
"associated",
"to",
"the",
"field",
"type",
"are",
"included",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L1316-L1374 | train |
pilosa/pilosa | field.go | BitDepth | func (b *bsiGroup) BitDepth() uint {
for i := uint(0); i < 63; i++ {
if b.Max-b.Min < (1 << i) {
return i
}
}
return 63
} | go | func (b *bsiGroup) BitDepth() uint {
for i := uint(0); i < 63; i++ {
if b.Max-b.Min < (1 << i) {
return i
}
}
return 63
} | [
"func",
"(",
"b",
"*",
"bsiGroup",
")",
"BitDepth",
"(",
")",
"uint",
"{",
"for",
"i",
":=",
"uint",
"(",
"0",
")",
";",
"i",
"<",
"63",
";",
"i",
"++",
"{",
"if",
"b",
".",
"Max",
"-",
"b",
".",
"Min",
"<",
"(",
"1",
"<<",
"i",
")",
"{... | // BitDepth returns the number of bits required to store a value between min & max. | [
"BitDepth",
"returns",
"the",
"number",
"of",
"bits",
"required",
"to",
"store",
"a",
"value",
"between",
"min",
"&",
"max",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L1399-L1406 | train |
pilosa/pilosa | field.go | isValidCacheType | func isValidCacheType(v string) bool {
switch v {
case CacheTypeLRU, CacheTypeRanked, CacheTypeNone:
return true
default:
return false
}
} | go | func isValidCacheType(v string) bool {
switch v {
case CacheTypeLRU, CacheTypeRanked, CacheTypeNone:
return true
default:
return false
}
} | [
"func",
"isValidCacheType",
"(",
"v",
"string",
")",
"bool",
"{",
"switch",
"v",
"{",
"case",
"CacheTypeLRU",
",",
"CacheTypeRanked",
",",
"CacheTypeNone",
":",
"return",
"true",
"\n",
"default",
":",
"return",
"false",
"\n",
"}",
"\n",
"}"
] | // isValidCacheType returns true if v is a valid cache type. | [
"isValidCacheType",
"returns",
"true",
"if",
"v",
"is",
"a",
"valid",
"cache",
"type",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/field.go#L1481-L1488 | train |
pilosa/pilosa | gopsutil/systeminfo.go | Uptime | func (s *systemInfo) Uptime() (uptime uint64, err error) {
hostInfo, err := host.Info()
if err != nil {
return 0, err
}
return hostInfo.Uptime, nil
} | go | func (s *systemInfo) Uptime() (uptime uint64, err error) {
hostInfo, err := host.Info()
if err != nil {
return 0, err
}
return hostInfo.Uptime, nil
} | [
"func",
"(",
"s",
"*",
"systemInfo",
")",
"Uptime",
"(",
")",
"(",
"uptime",
"uint64",
",",
"err",
"error",
")",
"{",
"hostInfo",
",",
"err",
":=",
"host",
".",
"Info",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"... | // Uptime returns the system uptime in seconds. | [
"Uptime",
"returns",
"the",
"system",
"uptime",
"in",
"seconds",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/gopsutil/systeminfo.go#L41-L47 | train |
pilosa/pilosa | gopsutil/systeminfo.go | collectPlatformInfo | func (s *systemInfo) collectPlatformInfo() error {
var err error
if s.platform == "" {
s.platform, s.family, s.osVersion, err = host.PlatformInformation()
if err != nil {
return err
}
}
if s.cpuModel == "" {
infos, err := cpu.Info()
if err != nil || len(infos) == 0 {
s.cpuModel = "unknown"
// if ... | go | func (s *systemInfo) collectPlatformInfo() error {
var err error
if s.platform == "" {
s.platform, s.family, s.osVersion, err = host.PlatformInformation()
if err != nil {
return err
}
}
if s.cpuModel == "" {
infos, err := cpu.Info()
if err != nil || len(infos) == 0 {
s.cpuModel = "unknown"
// if ... | [
"func",
"(",
"s",
"*",
"systemInfo",
")",
"collectPlatformInfo",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"if",
"s",
".",
"platform",
"==",
"\"",
"\"",
"{",
"s",
".",
"platform",
",",
"s",
".",
"family",
",",
"s",
".",
"osVersion",
",",... | // collectPlatformInfo fetches and caches system platform information. | [
"collectPlatformInfo",
"fetches",
"and",
"caches",
"system",
"platform",
"information",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/gopsutil/systeminfo.go#L99-L145 | train |
pilosa/pilosa | gopsutil/systeminfo.go | Platform | func (s *systemInfo) Platform() (string, error) {
err := s.collectPlatformInfo()
if err != nil {
return "", err
}
return s.platform, nil
} | go | func (s *systemInfo) Platform() (string, error) {
err := s.collectPlatformInfo()
if err != nil {
return "", err
}
return s.platform, nil
} | [
"func",
"(",
"s",
"*",
"systemInfo",
")",
"Platform",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"err",
":=",
"s",
".",
"collectPlatformInfo",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",... | // Platform returns the system platform. | [
"Platform",
"returns",
"the",
"system",
"platform",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/gopsutil/systeminfo.go#L148-L154 | train |
pilosa/pilosa | gopsutil/systeminfo.go | Family | func (s *systemInfo) Family() (string, error) {
err := s.collectPlatformInfo()
if err != nil {
return "", err
}
return s.family, err
} | go | func (s *systemInfo) Family() (string, error) {
err := s.collectPlatformInfo()
if err != nil {
return "", err
}
return s.family, err
} | [
"func",
"(",
"s",
"*",
"systemInfo",
")",
"Family",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"err",
":=",
"s",
".",
"collectPlatformInfo",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
... | // Family returns the system family. | [
"Family",
"returns",
"the",
"system",
"family",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/gopsutil/systeminfo.go#L157-L163 | train |
pilosa/pilosa | gopsutil/systeminfo.go | OSVersion | func (s *systemInfo) OSVersion() (string, error) {
err := s.collectPlatformInfo()
if err != nil {
return "", err
}
return s.osVersion, err
} | go | func (s *systemInfo) OSVersion() (string, error) {
err := s.collectPlatformInfo()
if err != nil {
return "", err
}
return s.osVersion, err
} | [
"func",
"(",
"s",
"*",
"systemInfo",
")",
"OSVersion",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"err",
":=",
"s",
".",
"collectPlatformInfo",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n"... | // OSVersion returns the OS Version. | [
"OSVersion",
"returns",
"the",
"OS",
"Version",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/gopsutil/systeminfo.go#L166-L172 | train |
pilosa/pilosa | gopsutil/systeminfo.go | MemFree | func (s *systemInfo) MemFree() (uint64, error) {
memInfo, err := mem.VirtualMemory()
if err != nil {
return 0, err
}
return memInfo.Free, err
} | go | func (s *systemInfo) MemFree() (uint64, error) {
memInfo, err := mem.VirtualMemory()
if err != nil {
return 0, err
}
return memInfo.Free, err
} | [
"func",
"(",
"s",
"*",
"systemInfo",
")",
"MemFree",
"(",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"memInfo",
",",
"err",
":=",
"mem",
".",
"VirtualMemory",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
... | // MemFree returns the amount of free memory in bytes. | [
"MemFree",
"returns",
"the",
"amount",
"of",
"free",
"memory",
"in",
"bytes",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/gopsutil/systeminfo.go#L175-L181 | train |
pilosa/pilosa | gopsutil/systeminfo.go | MemTotal | func (s *systemInfo) MemTotal() (uint64, error) {
memInfo, err := mem.VirtualMemory()
if err != nil {
return 0, err
}
return memInfo.Total, err
} | go | func (s *systemInfo) MemTotal() (uint64, error) {
memInfo, err := mem.VirtualMemory()
if err != nil {
return 0, err
}
return memInfo.Total, err
} | [
"func",
"(",
"s",
"*",
"systemInfo",
")",
"MemTotal",
"(",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"memInfo",
",",
"err",
":=",
"mem",
".",
"VirtualMemory",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
... | // MemTotal returns the amount of total memory in bytes. | [
"MemTotal",
"returns",
"the",
"amount",
"of",
"total",
"memory",
"in",
"bytes",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/gopsutil/systeminfo.go#L184-L190 | train |
pilosa/pilosa | gopsutil/systeminfo.go | MemUsed | func (s *systemInfo) MemUsed() (uint64, error) {
memInfo, err := mem.VirtualMemory()
if err != nil {
return 0, err
}
return memInfo.Used, err
} | go | func (s *systemInfo) MemUsed() (uint64, error) {
memInfo, err := mem.VirtualMemory()
if err != nil {
return 0, err
}
return memInfo.Used, err
} | [
"func",
"(",
"s",
"*",
"systemInfo",
")",
"MemUsed",
"(",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"memInfo",
",",
"err",
":=",
"mem",
".",
"VirtualMemory",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
... | // MemUsed returns the amount of used memory in bytes. | [
"MemUsed",
"returns",
"the",
"amount",
"of",
"used",
"memory",
"in",
"bytes",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/gopsutil/systeminfo.go#L193-L199 | train |
pilosa/pilosa | gopsutil/systeminfo.go | CPUModel | func (s *systemInfo) CPUModel() string {
err := s.collectPlatformInfo()
if err != nil {
return "unknown"
}
return s.cpuModel
} | go | func (s *systemInfo) CPUModel() string {
err := s.collectPlatformInfo()
if err != nil {
return "unknown"
}
return s.cpuModel
} | [
"func",
"(",
"s",
"*",
"systemInfo",
")",
"CPUModel",
"(",
")",
"string",
"{",
"err",
":=",
"s",
".",
"collectPlatformInfo",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"s",
".",
"cpuModel",
"\n",... | // CPUModel returns the CPU model string | [
"CPUModel",
"returns",
"the",
"CPU",
"model",
"string"
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/gopsutil/systeminfo.go#L212-L218 | train |
pilosa/pilosa | gopsutil/systeminfo.go | CPUMHz | func (s *systemInfo) CPUMHz() (int, error) {
err := s.collectPlatformInfo()
if err != nil {
return 0, err
}
return s.cpuMHz, nil
} | go | func (s *systemInfo) CPUMHz() (int, error) {
err := s.collectPlatformInfo()
if err != nil {
return 0, err
}
return s.cpuMHz, nil
} | [
"func",
"(",
"s",
"*",
"systemInfo",
")",
"CPUMHz",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"err",
":=",
"s",
".",
"collectPlatformInfo",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"return",
... | // CPUMhz returns the CPU clock speed | [
"CPUMhz",
"returns",
"the",
"CPU",
"clock",
"speed"
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/gopsutil/systeminfo.go#L221-L227 | train |
pilosa/pilosa | iterator.go | Next | func (itr *bufIterator) Next() (rowID, columnID uint64, eof bool) {
if itr.buf.full {
itr.buf.full = false
return itr.buf.rowID, itr.buf.columnID, itr.buf.eof
}
// Read values onto buffer in case of unread.
itr.buf.rowID, itr.buf.columnID, itr.buf.eof = itr.itr.Next()
return itr.buf.rowID, itr.buf.columnID, ... | go | func (itr *bufIterator) Next() (rowID, columnID uint64, eof bool) {
if itr.buf.full {
itr.buf.full = false
return itr.buf.rowID, itr.buf.columnID, itr.buf.eof
}
// Read values onto buffer in case of unread.
itr.buf.rowID, itr.buf.columnID, itr.buf.eof = itr.itr.Next()
return itr.buf.rowID, itr.buf.columnID, ... | [
"func",
"(",
"itr",
"*",
"bufIterator",
")",
"Next",
"(",
")",
"(",
"rowID",
",",
"columnID",
"uint64",
",",
"eof",
"bool",
")",
"{",
"if",
"itr",
".",
"buf",
".",
"full",
"{",
"itr",
".",
"buf",
".",
"full",
"=",
"false",
"\n",
"return",
"itr",
... | // Next returns the next pair in the row.
// If a value has been buffered then it is returned and the buffer is cleared. | [
"Next",
"returns",
"the",
"next",
"pair",
"in",
"the",
"row",
".",
"If",
"a",
"value",
"has",
"been",
"buffered",
"then",
"it",
"is",
"returned",
"and",
"the",
"buffer",
"is",
"cleared",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/iterator.go#L53-L63 | train |
pilosa/pilosa | iterator.go | Peek | func (itr *bufIterator) Peek() (rowID, columnID uint64, eof bool) {
rowID, columnID, eof = itr.Next()
itr.Unread()
return
} | go | func (itr *bufIterator) Peek() (rowID, columnID uint64, eof bool) {
rowID, columnID, eof = itr.Next()
itr.Unread()
return
} | [
"func",
"(",
"itr",
"*",
"bufIterator",
")",
"Peek",
"(",
")",
"(",
"rowID",
",",
"columnID",
"uint64",
",",
"eof",
"bool",
")",
"{",
"rowID",
",",
"columnID",
",",
"eof",
"=",
"itr",
".",
"Next",
"(",
")",
"\n",
"itr",
".",
"Unread",
"(",
")",
... | // Peek reads the next value but leaves it on the buffer. | [
"Peek",
"reads",
"the",
"next",
"value",
"but",
"leaves",
"it",
"on",
"the",
"buffer",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/iterator.go#L66-L70 | train |
pilosa/pilosa | iterator.go | Unread | func (itr *bufIterator) Unread() {
if itr.buf.full {
panic("pilosa.BufIterator: buffer full")
}
itr.buf.full = true
} | go | func (itr *bufIterator) Unread() {
if itr.buf.full {
panic("pilosa.BufIterator: buffer full")
}
itr.buf.full = true
} | [
"func",
"(",
"itr",
"*",
"bufIterator",
")",
"Unread",
"(",
")",
"{",
"if",
"itr",
".",
"buf",
".",
"full",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"itr",
".",
"buf",
".",
"full",
"=",
"true",
"\n",
"}"
] | // Unread pushes previous pair on to the buffer.
// Panics if the buffer is already full. | [
"Unread",
"pushes",
"previous",
"pair",
"on",
"to",
"the",
"buffer",
".",
"Panics",
"if",
"the",
"buffer",
"is",
"already",
"full",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/iterator.go#L74-L79 | train |
pilosa/pilosa | iterator.go | newLimitIterator | func newLimitIterator(itr iterator, maxRowID, maxColumnID uint64) *limitIterator { // nolint: unparam
return &limitIterator{
itr: itr,
maxRowID: maxRowID,
maxColumnID: maxColumnID,
}
} | go | func newLimitIterator(itr iterator, maxRowID, maxColumnID uint64) *limitIterator { // nolint: unparam
return &limitIterator{
itr: itr,
maxRowID: maxRowID,
maxColumnID: maxColumnID,
}
} | [
"func",
"newLimitIterator",
"(",
"itr",
"iterator",
",",
"maxRowID",
",",
"maxColumnID",
"uint64",
")",
"*",
"limitIterator",
"{",
"// nolint: unparam",
"return",
"&",
"limitIterator",
"{",
"itr",
":",
"itr",
",",
"maxRowID",
":",
"maxRowID",
",",
"maxColumnID",... | // newLimitIterator returns a new LimitIterator. | [
"newLimitIterator",
"returns",
"a",
"new",
"LimitIterator",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/iterator.go#L91-L97 | train |
pilosa/pilosa | iterator.go | Seek | func (itr *sliceIterator) Seek(bseek, pseek uint64) {
for i := 0; i < itr.n; i++ {
rowID := itr.rowIDs[i]
columnID := itr.columnIDs[i]
if (bseek == rowID && pseek <= columnID) || bseek < rowID {
itr.i = i
return
}
}
// Seek to the end of the slice if all values are less than seek pair.
itr.i = itr.n... | go | func (itr *sliceIterator) Seek(bseek, pseek uint64) {
for i := 0; i < itr.n; i++ {
rowID := itr.rowIDs[i]
columnID := itr.columnIDs[i]
if (bseek == rowID && pseek <= columnID) || bseek < rowID {
itr.i = i
return
}
}
// Seek to the end of the slice if all values are less than seek pair.
itr.i = itr.n... | [
"func",
"(",
"itr",
"*",
"sliceIterator",
")",
"Seek",
"(",
"bseek",
",",
"pseek",
"uint64",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"itr",
".",
"n",
";",
"i",
"++",
"{",
"rowID",
":=",
"itr",
".",
"rowIDs",
"[",
"i",
"]",
"\n",
"colu... | // Seek moves the cursor to a given pair.
// If the pair is not found, the iterator seeks to the next pair. | [
"Seek",
"moves",
"the",
"cursor",
"to",
"a",
"given",
"pair",
".",
"If",
"the",
"pair",
"is",
"not",
"found",
"the",
"iterator",
"seeks",
"to",
"the",
"next",
"pair",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/iterator.go#L146-L159 | train |
pilosa/pilosa | encoding/proto/proto.go | Marshal | func (Serializer) Marshal(m pilosa.Message) ([]byte, error) {
pm := encodeToProto(m)
if pm == nil {
return nil, errors.New("passed invalid pilosa.Message")
}
buf, err := proto.Marshal(pm)
return buf, errors.Wrap(err, "marshalling")
} | go | func (Serializer) Marshal(m pilosa.Message) ([]byte, error) {
pm := encodeToProto(m)
if pm == nil {
return nil, errors.New("passed invalid pilosa.Message")
}
buf, err := proto.Marshal(pm)
return buf, errors.Wrap(err, "marshalling")
} | [
"func",
"(",
"Serializer",
")",
"Marshal",
"(",
"m",
"pilosa",
".",
"Message",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"pm",
":=",
"encodeToProto",
"(",
"m",
")",
"\n",
"if",
"pm",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
"."... | // Marshal turns pilosa messages into protobuf serialized bytes. | [
"Marshal",
"turns",
"pilosa",
"messages",
"into",
"protobuf",
"serialized",
"bytes",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/encoding/proto/proto.go#L32-L39 | train |
pilosa/pilosa | encoding/proto/proto.go | encodeNodes | func encodeNodes(a []*pilosa.Node) []*internal.Node {
other := make([]*internal.Node, len(a))
for i := range a {
other[i] = encodeNode(a[i])
}
return other
} | go | func encodeNodes(a []*pilosa.Node) []*internal.Node {
other := make([]*internal.Node, len(a))
for i := range a {
other[i] = encodeNode(a[i])
}
return other
} | [
"func",
"encodeNodes",
"(",
"a",
"[",
"]",
"*",
"pilosa",
".",
"Node",
")",
"[",
"]",
"*",
"internal",
".",
"Node",
"{",
"other",
":=",
"make",
"(",
"[",
"]",
"*",
"internal",
".",
"Node",
",",
"len",
"(",
"a",
")",
")",
"\n",
"for",
"i",
":=... | // encodeNodes converts a slice of Nodes into its internal representation. | [
"encodeNodes",
"converts",
"a",
"slice",
"of",
"Nodes",
"into",
"its",
"internal",
"representation",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/encoding/proto/proto.go#L541-L547 | train |
pilosa/pilosa | encoding/proto/proto.go | encodeNode | func encodeNode(n *pilosa.Node) *internal.Node {
return &internal.Node{
ID: n.ID,
URI: encodeURI(n.URI),
IsCoordinator: n.IsCoordinator,
State: n.State,
}
} | go | func encodeNode(n *pilosa.Node) *internal.Node {
return &internal.Node{
ID: n.ID,
URI: encodeURI(n.URI),
IsCoordinator: n.IsCoordinator,
State: n.State,
}
} | [
"func",
"encodeNode",
"(",
"n",
"*",
"pilosa",
".",
"Node",
")",
"*",
"internal",
".",
"Node",
"{",
"return",
"&",
"internal",
".",
"Node",
"{",
"ID",
":",
"n",
".",
"ID",
",",
"URI",
":",
"encodeURI",
"(",
"n",
".",
"URI",
")",
",",
"IsCoordinat... | // encodeNode converts a Node into its internal representation. | [
"encodeNode",
"converts",
"a",
"Node",
"into",
"its",
"internal",
"representation",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/encoding/proto/proto.go#L550-L557 | train |
pilosa/pilosa | encoding/proto/proto.go | decodeRow | func decodeRow(pr *internal.Row) *pilosa.Row {
if pr == nil {
return nil
}
r := pilosa.NewRow()
r.Attrs = decodeAttrs(pr.Attrs)
r.Keys = pr.Keys
for _, v := range pr.Columns {
r.SetBit(v)
}
return r
} | go | func decodeRow(pr *internal.Row) *pilosa.Row {
if pr == nil {
return nil
}
r := pilosa.NewRow()
r.Attrs = decodeAttrs(pr.Attrs)
r.Keys = pr.Keys
for _, v := range pr.Columns {
r.SetBit(v)
}
return r
} | [
"func",
"decodeRow",
"(",
"pr",
"*",
"internal",
".",
"Row",
")",
"*",
"pilosa",
".",
"Row",
"{",
"if",
"pr",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"r",
":=",
"pilosa",
".",
"NewRow",
"(",
")",
"\n",
"r",
".",
"Attrs",
"=",
"dec... | // DecodeRow converts r from its internal representation. | [
"DecodeRow",
"converts",
"r",
"from",
"its",
"internal",
"representation",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/encoding/proto/proto.go#L1084-L1096 | train |
pilosa/pilosa | row.go | NewRow | func NewRow(columns ...uint64) *Row {
r := &Row{}
for _, i := range columns {
r.SetBit(i)
}
return r
} | go | func NewRow(columns ...uint64) *Row {
r := &Row{}
for _, i := range columns {
r.SetBit(i)
}
return r
} | [
"func",
"NewRow",
"(",
"columns",
"...",
"uint64",
")",
"*",
"Row",
"{",
"r",
":=",
"&",
"Row",
"{",
"}",
"\n",
"for",
"_",
",",
"i",
":=",
"range",
"columns",
"{",
"r",
".",
"SetBit",
"(",
"i",
")",
"\n",
"}",
"\n",
"return",
"r",
"\n",
"}"
... | // NewRow returns a new instance of Row. | [
"NewRow",
"returns",
"a",
"new",
"instance",
"of",
"Row",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L38-L44 | train |
pilosa/pilosa | row.go | IsEmpty | func (r *Row) IsEmpty() bool {
if len(r.segments) == 0 {
return true
}
for i := range r.segments {
if r.segments[i].n > 0 {
return false
}
}
return true
} | go | func (r *Row) IsEmpty() bool {
if len(r.segments) == 0 {
return true
}
for i := range r.segments {
if r.segments[i].n > 0 {
return false
}
}
return true
} | [
"func",
"(",
"r",
"*",
"Row",
")",
"IsEmpty",
"(",
")",
"bool",
"{",
"if",
"len",
"(",
"r",
".",
"segments",
")",
"==",
"0",
"{",
"return",
"true",
"\n",
"}",
"\n",
"for",
"i",
":=",
"range",
"r",
".",
"segments",
"{",
"if",
"r",
".",
"segmen... | // IsEmpty returns true if the row doesn't contain any set bits. | [
"IsEmpty",
"returns",
"true",
"if",
"the",
"row",
"doesn",
"t",
"contain",
"any",
"set",
"bits",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L47-L58 | train |
pilosa/pilosa | row.go | Merge | func (r *Row) Merge(other *Row) {
var segments []rowSegment
itr := newMergeSegmentIterator(r.segments, other.segments)
for s0, s1 := itr.next(); s0 != nil || s1 != nil; s0, s1 = itr.next() {
// Use the other row's data if segment is missing.
if s0 == nil {
segments = append(segments, *s1)
continue
} els... | go | func (r *Row) Merge(other *Row) {
var segments []rowSegment
itr := newMergeSegmentIterator(r.segments, other.segments)
for s0, s1 := itr.next(); s0 != nil || s1 != nil; s0, s1 = itr.next() {
// Use the other row's data if segment is missing.
if s0 == nil {
segments = append(segments, *s1)
continue
} els... | [
"func",
"(",
"r",
"*",
"Row",
")",
"Merge",
"(",
"other",
"*",
"Row",
")",
"{",
"var",
"segments",
"[",
"]",
"rowSegment",
"\n\n",
"itr",
":=",
"newMergeSegmentIterator",
"(",
"r",
".",
"segments",
",",
"other",
".",
"segments",
")",
"\n",
"for",
"s0... | // Merge merges data from other into r. | [
"Merge",
"merges",
"data",
"from",
"other",
"into",
"r",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L61-L82 | train |
pilosa/pilosa | row.go | intersectionCount | func (r *Row) intersectionCount(other *Row) uint64 {
var n uint64
itr := newMergeSegmentIterator(r.segments, other.segments)
for s0, s1 := itr.next(); s0 != nil || s1 != nil; s0, s1 = itr.next() {
// Ignore non-overlapping segments.
if s0 == nil || s1 == nil {
continue
}
n += s0.IntersectionCount(s1)
}... | go | func (r *Row) intersectionCount(other *Row) uint64 {
var n uint64
itr := newMergeSegmentIterator(r.segments, other.segments)
for s0, s1 := itr.next(); s0 != nil || s1 != nil; s0, s1 = itr.next() {
// Ignore non-overlapping segments.
if s0 == nil || s1 == nil {
continue
}
n += s0.IntersectionCount(s1)
}... | [
"func",
"(",
"r",
"*",
"Row",
")",
"intersectionCount",
"(",
"other",
"*",
"Row",
")",
"uint64",
"{",
"var",
"n",
"uint64",
"\n\n",
"itr",
":=",
"newMergeSegmentIterator",
"(",
"r",
".",
"segments",
",",
"other",
".",
"segments",
")",
"\n",
"for",
"s0"... | // intersectionCount returns the number of intersections between r and other. | [
"intersectionCount",
"returns",
"the",
"number",
"of",
"intersections",
"between",
"r",
"and",
"other",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L85-L98 | train |
pilosa/pilosa | row.go | Shift | func (r *Row) Shift(n int64) (*Row, error) {
if n < 0 {
return nil, errors.New("cannot shift by negative values")
} else if n == 0 {
return r, nil
}
work := r
var segments []rowSegment
for i := int64(0); i < n; i++ {
segments = segments[:0]
for _, segment := range work.segments {
shifted, err := segme... | go | func (r *Row) Shift(n int64) (*Row, error) {
if n < 0 {
return nil, errors.New("cannot shift by negative values")
} else if n == 0 {
return r, nil
}
work := r
var segments []rowSegment
for i := int64(0); i < n; i++ {
segments = segments[:0]
for _, segment := range work.segments {
shifted, err := segme... | [
"func",
"(",
"r",
"*",
"Row",
")",
"Shift",
"(",
"n",
"int64",
")",
"(",
"*",
"Row",
",",
"error",
")",
"{",
"if",
"n",
"<",
"0",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"if",
"n",
"==",
"... | // Shift returns the bitwise shift of r by n bits.
// Currently only positive shift values are supported. | [
"Shift",
"returns",
"the",
"bitwise",
"shift",
"of",
"r",
"by",
"n",
"bits",
".",
"Currently",
"only",
"positive",
"shift",
"values",
"are",
"supported",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L174-L196 | train |
pilosa/pilosa | row.go | clearBit | func (r *Row) clearBit(i uint64) (changed bool) { // nolint: unparam
s := r.segment(i / ShardWidth)
if s == nil {
return false
}
return s.ClearBit(i)
} | go | func (r *Row) clearBit(i uint64) (changed bool) { // nolint: unparam
s := r.segment(i / ShardWidth)
if s == nil {
return false
}
return s.ClearBit(i)
} | [
"func",
"(",
"r",
"*",
"Row",
")",
"clearBit",
"(",
"i",
"uint64",
")",
"(",
"changed",
"bool",
")",
"{",
"// nolint: unparam",
"s",
":=",
"r",
".",
"segment",
"(",
"i",
"/",
"ShardWidth",
")",
"\n",
"if",
"s",
"==",
"nil",
"{",
"return",
"false",
... | // clearBit clears the i-th column of the row. | [
"clearBit",
"clears",
"the",
"i",
"-",
"th",
"column",
"of",
"the",
"row",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L204-L210 | train |
pilosa/pilosa | row.go | segment | func (r *Row) segment(shard uint64) *rowSegment {
if i := sort.Search(len(r.segments), func(i int) bool {
return r.segments[i].shard >= shard
}); i < len(r.segments) && r.segments[i].shard == shard {
return &r.segments[i]
}
return nil
} | go | func (r *Row) segment(shard uint64) *rowSegment {
if i := sort.Search(len(r.segments), func(i int) bool {
return r.segments[i].shard >= shard
}); i < len(r.segments) && r.segments[i].shard == shard {
return &r.segments[i]
}
return nil
} | [
"func",
"(",
"r",
"*",
"Row",
")",
"segment",
"(",
"shard",
"uint64",
")",
"*",
"rowSegment",
"{",
"if",
"i",
":=",
"sort",
".",
"Search",
"(",
"len",
"(",
"r",
".",
"segments",
")",
",",
"func",
"(",
"i",
"int",
")",
"bool",
"{",
"return",
"r"... | // segment returns a segment for a given shard.
// Returns nil if segment does not exist. | [
"segment",
"returns",
"a",
"segment",
"for",
"a",
"given",
"shard",
".",
"Returns",
"nil",
"if",
"segment",
"does",
"not",
"exist",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L219-L226 | train |
pilosa/pilosa | row.go | invalidateCount | func (r *Row) invalidateCount() {
for i := range r.segments {
r.segments[i].InvalidateCount()
}
} | go | func (r *Row) invalidateCount() {
for i := range r.segments {
r.segments[i].InvalidateCount()
}
} | [
"func",
"(",
"r",
"*",
"Row",
")",
"invalidateCount",
"(",
")",
"{",
"for",
"i",
":=",
"range",
"r",
".",
"segments",
"{",
"r",
".",
"segments",
"[",
"i",
"]",
".",
"InvalidateCount",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // invalidateCount updates the cached count in the row. | [
"invalidateCount",
"updates",
"the",
"cached",
"count",
"in",
"the",
"row",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L253-L257 | train |
pilosa/pilosa | row.go | Count | func (r *Row) Count() uint64 {
var n uint64
for i := range r.segments {
n += r.segments[i].Count()
}
return n
} | go | func (r *Row) Count() uint64 {
var n uint64
for i := range r.segments {
n += r.segments[i].Count()
}
return n
} | [
"func",
"(",
"r",
"*",
"Row",
")",
"Count",
"(",
")",
"uint64",
"{",
"var",
"n",
"uint64",
"\n",
"for",
"i",
":=",
"range",
"r",
".",
"segments",
"{",
"n",
"+=",
"r",
".",
"segments",
"[",
"i",
"]",
".",
"Count",
"(",
")",
"\n",
"}",
"\n",
... | // Count returns the number of columns in the row. | [
"Count",
"returns",
"the",
"number",
"of",
"columns",
"in",
"the",
"row",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L260-L266 | train |
pilosa/pilosa | row.go | MarshalJSON | func (r *Row) MarshalJSON() ([]byte, error) {
var o struct {
Attrs map[string]interface{} `json:"attrs"`
Columns []uint64 `json:"columns"`
Keys []string `json:"keys,omitempty"`
}
o.Columns = r.Columns()
o.Keys = r.Keys
o.Attrs = r.Attrs
if o.Attrs == nil {
o.Attrs = make(... | go | func (r *Row) MarshalJSON() ([]byte, error) {
var o struct {
Attrs map[string]interface{} `json:"attrs"`
Columns []uint64 `json:"columns"`
Keys []string `json:"keys,omitempty"`
}
o.Columns = r.Columns()
o.Keys = r.Keys
o.Attrs = r.Attrs
if o.Attrs == nil {
o.Attrs = make(... | [
"func",
"(",
"r",
"*",
"Row",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"o",
"struct",
"{",
"Attrs",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"`json:\"attrs\"`",
"\n",
"Columns",
"[",
"]",
"uint64"... | // MarshalJSON returns a JSON-encoded byte slice of r. | [
"MarshalJSON",
"returns",
"a",
"JSON",
"-",
"encoded",
"byte",
"slice",
"of",
"r",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L269-L284 | train |
pilosa/pilosa | row.go | Columns | func (r *Row) Columns() []uint64 {
a := make([]uint64, 0, r.Count())
for i := range r.segments {
a = append(a, r.segments[i].Columns()...)
}
return a
} | go | func (r *Row) Columns() []uint64 {
a := make([]uint64, 0, r.Count())
for i := range r.segments {
a = append(a, r.segments[i].Columns()...)
}
return a
} | [
"func",
"(",
"r",
"*",
"Row",
")",
"Columns",
"(",
")",
"[",
"]",
"uint64",
"{",
"a",
":=",
"make",
"(",
"[",
"]",
"uint64",
",",
"0",
",",
"r",
".",
"Count",
"(",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"r",
".",
"segments",
"{",
"a",
... | // Columns returns the columns in r as a slice of ints. | [
"Columns",
"returns",
"the",
"columns",
"in",
"r",
"as",
"a",
"slice",
"of",
"ints",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L287-L293 | train |
pilosa/pilosa | row.go | Merge | func (s *rowSegment) Merge(other *rowSegment) {
s.ensureWritable()
itr := other.data.Iterator()
for v, eof := itr.Next(); !eof; v, eof = itr.Next() {
s.SetBit(v)
}
} | go | func (s *rowSegment) Merge(other *rowSegment) {
s.ensureWritable()
itr := other.data.Iterator()
for v, eof := itr.Next(); !eof; v, eof = itr.Next() {
s.SetBit(v)
}
} | [
"func",
"(",
"s",
"*",
"rowSegment",
")",
"Merge",
"(",
"other",
"*",
"rowSegment",
")",
"{",
"s",
".",
"ensureWritable",
"(",
")",
"\n\n",
"itr",
":=",
"other",
".",
"data",
".",
"Iterator",
"(",
")",
"\n",
"for",
"v",
",",
"eof",
":=",
"itr",
"... | // Merge adds chunks from other to s.
// Chunks in s are overwritten if they exist in other. | [
"Merge",
"adds",
"chunks",
"from",
"other",
"to",
"s",
".",
"Chunks",
"in",
"s",
"are",
"overwritten",
"if",
"they",
"exist",
"in",
"other",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L314-L321 | train |
pilosa/pilosa | row.go | IntersectionCount | func (s *rowSegment) IntersectionCount(other *rowSegment) uint64 {
return s.data.IntersectionCount(&other.data)
} | go | func (s *rowSegment) IntersectionCount(other *rowSegment) uint64 {
return s.data.IntersectionCount(&other.data)
} | [
"func",
"(",
"s",
"*",
"rowSegment",
")",
"IntersectionCount",
"(",
"other",
"*",
"rowSegment",
")",
"uint64",
"{",
"return",
"s",
".",
"data",
".",
"IntersectionCount",
"(",
"&",
"other",
".",
"data",
")",
"\n",
"}"
] | // IntersectionCount returns the number of intersections between s and other. | [
"IntersectionCount",
"returns",
"the",
"number",
"of",
"intersections",
"between",
"s",
"and",
"other",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L324-L326 | train |
pilosa/pilosa | row.go | Intersect | func (s *rowSegment) Intersect(other *rowSegment) *rowSegment {
data := s.data.Intersect(&other.data)
return &rowSegment{
data: *data,
shard: s.shard,
n: data.Count(),
}
} | go | func (s *rowSegment) Intersect(other *rowSegment) *rowSegment {
data := s.data.Intersect(&other.data)
return &rowSegment{
data: *data,
shard: s.shard,
n: data.Count(),
}
} | [
"func",
"(",
"s",
"*",
"rowSegment",
")",
"Intersect",
"(",
"other",
"*",
"rowSegment",
")",
"*",
"rowSegment",
"{",
"data",
":=",
"s",
".",
"data",
".",
"Intersect",
"(",
"&",
"other",
".",
"data",
")",
"\n\n",
"return",
"&",
"rowSegment",
"{",
"dat... | // Intersect returns the itersection of s and other. | [
"Intersect",
"returns",
"the",
"itersection",
"of",
"s",
"and",
"other",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L329-L337 | train |
pilosa/pilosa | row.go | Union | func (s *rowSegment) Union(other *rowSegment) *rowSegment {
data := s.data.Union(&other.data)
return &rowSegment{
data: *data,
shard: s.shard,
n: data.Count(),
}
} | go | func (s *rowSegment) Union(other *rowSegment) *rowSegment {
data := s.data.Union(&other.data)
return &rowSegment{
data: *data,
shard: s.shard,
n: data.Count(),
}
} | [
"func",
"(",
"s",
"*",
"rowSegment",
")",
"Union",
"(",
"other",
"*",
"rowSegment",
")",
"*",
"rowSegment",
"{",
"data",
":=",
"s",
".",
"data",
".",
"Union",
"(",
"&",
"other",
".",
"data",
")",
"\n\n",
"return",
"&",
"rowSegment",
"{",
"data",
":... | // Union returns the bitwise union of s and other. | [
"Union",
"returns",
"the",
"bitwise",
"union",
"of",
"s",
"and",
"other",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L340-L348 | train |
pilosa/pilosa | row.go | Difference | func (s *rowSegment) Difference(other *rowSegment) *rowSegment {
data := s.data.Difference(&other.data)
return &rowSegment{
data: *data,
shard: s.shard,
n: data.Count(),
}
} | go | func (s *rowSegment) Difference(other *rowSegment) *rowSegment {
data := s.data.Difference(&other.data)
return &rowSegment{
data: *data,
shard: s.shard,
n: data.Count(),
}
} | [
"func",
"(",
"s",
"*",
"rowSegment",
")",
"Difference",
"(",
"other",
"*",
"rowSegment",
")",
"*",
"rowSegment",
"{",
"data",
":=",
"s",
".",
"data",
".",
"Difference",
"(",
"&",
"other",
".",
"data",
")",
"\n\n",
"return",
"&",
"rowSegment",
"{",
"d... | // Difference returns the diff of s and other. | [
"Difference",
"returns",
"the",
"diff",
"of",
"s",
"and",
"other",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L351-L359 | train |
pilosa/pilosa | row.go | Xor | func (s *rowSegment) Xor(other *rowSegment) *rowSegment {
data := s.data.Xor(&other.data)
return &rowSegment{
data: *data,
shard: s.shard,
n: data.Count(),
}
} | go | func (s *rowSegment) Xor(other *rowSegment) *rowSegment {
data := s.data.Xor(&other.data)
return &rowSegment{
data: *data,
shard: s.shard,
n: data.Count(),
}
} | [
"func",
"(",
"s",
"*",
"rowSegment",
")",
"Xor",
"(",
"other",
"*",
"rowSegment",
")",
"*",
"rowSegment",
"{",
"data",
":=",
"s",
".",
"data",
".",
"Xor",
"(",
"&",
"other",
".",
"data",
")",
"\n\n",
"return",
"&",
"rowSegment",
"{",
"data",
":",
... | // Xor returns the xor of s and other. | [
"Xor",
"returns",
"the",
"xor",
"of",
"s",
"and",
"other",
"."
] | 67d53f6b48a43f7fe090f48e35518ca8d024747c | https://github.com/pilosa/pilosa/blob/67d53f6b48a43f7fe090f48e35518ca8d024747c/row.go#L362-L370 | 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.