id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
134,900 | influxdata/platform | tsdb/tsm1/engine.go | ShouldCompactCache | func (e *Engine) ShouldCompactCache(t time.Time) bool {
sz := e.Cache.Size()
if sz == 0 {
return false
}
if sz > e.CacheFlushMemorySizeThreshold {
return true
}
return t.Sub(e.Cache.LastWriteTime()) > e.CacheFlushWriteColdDuration
} | go | func (e *Engine) ShouldCompactCache(t time.Time) bool {
sz := e.Cache.Size()
if sz == 0 {
return false
}
if sz > e.CacheFlushMemorySizeThreshold {
return true
}
return t.Sub(e.Cache.LastWriteTime()) > e.CacheFlushWriteColdDuration
} | [
"func",
"(",
"e",
"*",
"Engine",
")",
"ShouldCompactCache",
"(",
"t",
"time",
".",
"Time",
")",
"bool",
"{",
"sz",
":=",
"e",
".",
"Cache",
".",
"Size",
"(",
")",
"\n\n",
"if",
"sz",
"==",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"if",
"... | // ShouldCompactCache returns true if the Cache is over its flush threshold
// or if the passed in lastWriteTime is older than the write cold threshold. | [
"ShouldCompactCache",
"returns",
"true",
"if",
"the",
"Cache",
"is",
"over",
"its",
"flush",
"threshold",
"or",
"if",
"the",
"passed",
"in",
"lastWriteTime",
"is",
"older",
"than",
"the",
"write",
"cold",
"threshold",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/engine.go#L1299-L1311 |
134,901 | influxdata/platform | tsdb/tsm1/engine.go | compactHiPriorityLevel | func (e *Engine) compactHiPriorityLevel(grp CompactionGroup, level compactionLevel, fast bool, wg *sync.WaitGroup) bool {
s := e.levelCompactionStrategy(grp, fast, level)
if s == nil {
return false
}
// Try hi priority limiter, otherwise steal a little from the low priority if we can.
if e.compactionLimiter.Try... | go | func (e *Engine) compactHiPriorityLevel(grp CompactionGroup, level compactionLevel, fast bool, wg *sync.WaitGroup) bool {
s := e.levelCompactionStrategy(grp, fast, level)
if s == nil {
return false
}
// Try hi priority limiter, otherwise steal a little from the low priority if we can.
if e.compactionLimiter.Try... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"compactHiPriorityLevel",
"(",
"grp",
"CompactionGroup",
",",
"level",
"compactionLevel",
",",
"fast",
"bool",
",",
"wg",
"*",
"sync",
".",
"WaitGroup",
")",
"bool",
"{",
"s",
":=",
"e",
".",
"levelCompactionStrategy",
... | // compactHiPriorityLevel kicks off compactions using the high priority policy. It returns
// true if the compaction was started | [
"compactHiPriorityLevel",
"kicks",
"off",
"compactions",
"using",
"the",
"high",
"priority",
"policy",
".",
"It",
"returns",
"true",
"if",
"the",
"compaction",
"was",
"started"
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/engine.go#L1385-L1409 |
134,902 | influxdata/platform | tsdb/tsm1/engine.go | compactFull | func (e *Engine) compactFull(grp CompactionGroup, wg *sync.WaitGroup) bool {
s := e.fullCompactionStrategy(grp, false)
if s == nil {
return false
}
// Try the lo priority limiter, otherwise steal a little from the high priority if we can.
if e.compactionLimiter.TryTake() {
e.compactionTracker.IncFullActive()
... | go | func (e *Engine) compactFull(grp CompactionGroup, wg *sync.WaitGroup) bool {
s := e.fullCompactionStrategy(grp, false)
if s == nil {
return false
}
// Try the lo priority limiter, otherwise steal a little from the high priority if we can.
if e.compactionLimiter.TryTake() {
e.compactionTracker.IncFullActive()
... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"compactFull",
"(",
"grp",
"CompactionGroup",
",",
"wg",
"*",
"sync",
".",
"WaitGroup",
")",
"bool",
"{",
"s",
":=",
"e",
".",
"fullCompactionStrategy",
"(",
"grp",
",",
"false",
")",
"\n",
"if",
"s",
"==",
"nil"... | // compactFull kicks off full and optimize compactions using the lo priority policy. It returns
// the plans that were not able to be started. | [
"compactFull",
"kicks",
"off",
"full",
"and",
"optimize",
"compactions",
"using",
"the",
"lo",
"priority",
"policy",
".",
"It",
"returns",
"the",
"plans",
"that",
"were",
"not",
"able",
"to",
"be",
"started",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/engine.go#L1438-L1459 |
134,903 | influxdata/platform | tsdb/tsm1/engine.go | compactGroup | func (s *compactionStrategy) compactGroup() {
now := time.Now()
group := s.group
log, logEnd := logger.NewOperation(s.logger, "TSM compaction", "tsm1_compact_group")
defer logEnd()
log.Info("Beginning compaction", zap.Int("tsm1_files_n", len(group)))
for i, f := range group {
log.Info("Compacting file", zap.In... | go | func (s *compactionStrategy) compactGroup() {
now := time.Now()
group := s.group
log, logEnd := logger.NewOperation(s.logger, "TSM compaction", "tsm1_compact_group")
defer logEnd()
log.Info("Beginning compaction", zap.Int("tsm1_files_n", len(group)))
for i, f := range group {
log.Info("Compacting file", zap.In... | [
"func",
"(",
"s",
"*",
"compactionStrategy",
")",
"compactGroup",
"(",
")",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"group",
":=",
"s",
".",
"group",
"\n",
"log",
",",
"logEnd",
":=",
"logger",
".",
"NewOperation",
"(",
"s",
".",
"log... | // compactGroup executes the compaction strategy against a single CompactionGroup. | [
"compactGroup",
"executes",
"the",
"compaction",
"strategy",
"against",
"a",
"single",
"CompactionGroup",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/engine.go#L1483-L1534 |
134,904 | influxdata/platform | tsdb/tsm1/engine.go | reloadCache | func (e *Engine) reloadCache() error {
now := time.Now()
files, err := segmentFileNames(e.WAL.Path())
if err != nil {
return err
}
limit := e.Cache.MaxSize()
defer func() {
e.Cache.SetMaxSize(limit)
}()
// Disable the max size during loading
e.Cache.SetMaxSize(0)
loader := NewCacheLoader(files)
loader... | go | func (e *Engine) reloadCache() error {
now := time.Now()
files, err := segmentFileNames(e.WAL.Path())
if err != nil {
return err
}
limit := e.Cache.MaxSize()
defer func() {
e.Cache.SetMaxSize(limit)
}()
// Disable the max size during loading
e.Cache.SetMaxSize(0)
loader := NewCacheLoader(files)
loader... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"reloadCache",
"(",
")",
"error",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"files",
",",
"err",
":=",
"segmentFileNames",
"(",
"e",
".",
"WAL",
".",
"Path",
"(",
")",
")",
"\n",
"if",
"err",
"!... | // reloadCache reads the WAL segment files and loads them into the cache. | [
"reloadCache",
"reads",
"the",
"WAL",
"segment",
"files",
"and",
"loads",
"them",
"into",
"the",
"cache",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/engine.go#L1572-L1595 |
134,905 | influxdata/platform | tsdb/tsm1/engine.go | SeriesAndFieldFromCompositeKey | func SeriesAndFieldFromCompositeKey(key []byte) ([]byte, []byte) {
sep := bytes.Index(key, keyFieldSeparatorBytes)
if sep == -1 {
// No field???
return key, nil
}
return key[:sep], key[sep+len(keyFieldSeparator):]
} | go | func SeriesAndFieldFromCompositeKey(key []byte) ([]byte, []byte) {
sep := bytes.Index(key, keyFieldSeparatorBytes)
if sep == -1 {
// No field???
return key, nil
}
return key[:sep], key[sep+len(keyFieldSeparator):]
} | [
"func",
"SeriesAndFieldFromCompositeKey",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"[",
"]",
"byte",
")",
"{",
"sep",
":=",
"bytes",
".",
"Index",
"(",
"key",
",",
"keyFieldSeparatorBytes",
")",
"\n",
"if",
"sep",
"==",
"-",
"1"... | // SeriesAndFieldFromCompositeKey returns the series key and the field key extracted from the composite key. | [
"SeriesAndFieldFromCompositeKey",
"returns",
"the",
"series",
"key",
"and",
"the",
"field",
"key",
"extracted",
"from",
"the",
"composite",
"key",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/engine.go#L1740-L1747 |
134,906 | influxdata/platform | tsdb/tsi1/index.go | Bytes | func (i *Index) Bytes() int {
var b int
i.mu.RLock()
b += 24 // mu RWMutex is 24 bytes
b += int(unsafe.Sizeof(i.partitions))
for _, p := range i.partitions {
b += int(unsafe.Sizeof(p)) + p.bytes()
}
b += int(unsafe.Sizeof(i.opened))
b += int(unsafe.Sizeof(i.path)) + len(i.path)
b += int(unsafe.Sizeof(i.disab... | go | func (i *Index) Bytes() int {
var b int
i.mu.RLock()
b += 24 // mu RWMutex is 24 bytes
b += int(unsafe.Sizeof(i.partitions))
for _, p := range i.partitions {
b += int(unsafe.Sizeof(p)) + p.bytes()
}
b += int(unsafe.Sizeof(i.opened))
b += int(unsafe.Sizeof(i.path)) + len(i.path)
b += int(unsafe.Sizeof(i.disab... | [
"func",
"(",
"i",
"*",
"Index",
")",
"Bytes",
"(",
")",
"int",
"{",
"var",
"b",
"int",
"\n",
"i",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"b",
"+=",
"24",
"// mu RWMutex is 24 bytes",
"\n",
"b",
"+=",
"int",
"(",
"unsafe",
".",
"Sizeof",
"(",
... | // Bytes estimates the memory footprint of this Index, in bytes. | [
"Bytes",
"estimates",
"the",
"memory",
"footprint",
"of",
"this",
"Index",
"in",
"bytes",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsi1/index.go#L164-L183 |
134,907 | influxdata/platform | tsdb/tsi1/index.go | measurementSeriesByExprIterator | func (i *Index) measurementSeriesByExprIterator(name []byte, expr influxql.Expr) (tsdb.SeriesIDIterator, error) {
// Return all series for the measurement if there are no tag expressions.
release := i.sfile.Retain()
defer release()
if expr == nil {
itr, err := i.measurementSeriesIDIterator(name)
if err != nil... | go | func (i *Index) measurementSeriesByExprIterator(name []byte, expr influxql.Expr) (tsdb.SeriesIDIterator, error) {
// Return all series for the measurement if there are no tag expressions.
release := i.sfile.Retain()
defer release()
if expr == nil {
itr, err := i.measurementSeriesIDIterator(name)
if err != nil... | [
"func",
"(",
"i",
"*",
"Index",
")",
"measurementSeriesByExprIterator",
"(",
"name",
"[",
"]",
"byte",
",",
"expr",
"influxql",
".",
"Expr",
")",
"(",
"tsdb",
".",
"SeriesIDIterator",
",",
"error",
")",
"{",
"// Return all series for the measurement if there are n... | // measurementSeriesByExprIterator returns a series iterator for a measurement
// that is filtered by expr. See MeasurementSeriesByExprIterator for more details.
//
// measurementSeriesByExprIterator guarantees to never take any locks on the
// series file. | [
"measurementSeriesByExprIterator",
"returns",
"a",
"series",
"iterator",
"for",
"a",
"measurement",
"that",
"is",
"filtered",
"by",
"expr",
".",
"See",
"MeasurementSeriesByExprIterator",
"for",
"more",
"details",
".",
"measurementSeriesByExprIterator",
"guarantees",
"to",... | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsi1/index.go#L517-L537 |
134,908 | influxdata/platform | tsdb/tsi1/index.go | MeasurementSeriesIDIterator | func (i *Index) MeasurementSeriesIDIterator(name []byte) (tsdb.SeriesIDIterator, error) {
itr, err := i.measurementSeriesIDIterator(name)
if err != nil {
return nil, err
}
release := i.sfile.Retain()
defer release()
return tsdb.FilterUndeletedSeriesIDIterator(i.sfile, itr), nil
} | go | func (i *Index) MeasurementSeriesIDIterator(name []byte) (tsdb.SeriesIDIterator, error) {
itr, err := i.measurementSeriesIDIterator(name)
if err != nil {
return nil, err
}
release := i.sfile.Retain()
defer release()
return tsdb.FilterUndeletedSeriesIDIterator(i.sfile, itr), nil
} | [
"func",
"(",
"i",
"*",
"Index",
")",
"MeasurementSeriesIDIterator",
"(",
"name",
"[",
"]",
"byte",
")",
"(",
"tsdb",
".",
"SeriesIDIterator",
",",
"error",
")",
"{",
"itr",
",",
"err",
":=",
"i",
".",
"measurementSeriesIDIterator",
"(",
"name",
")",
"\n"... | // MeasurementSeriesIDIterator returns an iterator over all non-tombstoned series
// for the provided measurement. | [
"MeasurementSeriesIDIterator",
"returns",
"an",
"iterator",
"over",
"all",
"non",
"-",
"tombstoned",
"series",
"for",
"the",
"provided",
"measurement",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsi1/index.go#L541-L550 |
134,909 | influxdata/platform | tsdb/tsi1/index.go | tagValueSeriesIDIterator | func (i *Index) tagValueSeriesIDIterator(name, key, value []byte) (tsdb.SeriesIDIterator, error) {
// Check series ID set cache...
if i.config.SeriesIDSetCacheSize > 0 { // Cache enabled.
if ss := i.tagValueCache.Get(name, key, value); ss != nil {
// Return a clone because the set is mutable.
return tsdb.NewS... | go | func (i *Index) tagValueSeriesIDIterator(name, key, value []byte) (tsdb.SeriesIDIterator, error) {
// Check series ID set cache...
if i.config.SeriesIDSetCacheSize > 0 { // Cache enabled.
if ss := i.tagValueCache.Get(name, key, value); ss != nil {
// Return a clone because the set is mutable.
return tsdb.NewS... | [
"func",
"(",
"i",
"*",
"Index",
")",
"tagValueSeriesIDIterator",
"(",
"name",
",",
"key",
",",
"value",
"[",
"]",
"byte",
")",
"(",
"tsdb",
".",
"SeriesIDIterator",
",",
"error",
")",
"{",
"// Check series ID set cache...",
"if",
"i",
".",
"config",
".",
... | // tagValueSeriesIDIterator returns a series iterator for a single tag value. | [
"tagValueSeriesIDIterator",
"returns",
"a",
"series",
"iterator",
"for",
"a",
"single",
"tag",
"value",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsi1/index.go#L924-L955 |
134,910 | influxdata/platform | tsdb/tsi1/index.go | RetainFileSet | func (i *Index) RetainFileSet() (*FileSet, error) {
i.mu.RLock()
defer i.mu.RUnlock()
fs, _ := NewFileSet(nil, i.sfile, nil)
for _, p := range i.partitions {
pfs, err := p.RetainFileSet()
if err != nil {
fs.Close()
return nil, err
}
fs.files = append(fs.files, pfs.files...)
}
return fs, nil
} | go | func (i *Index) RetainFileSet() (*FileSet, error) {
i.mu.RLock()
defer i.mu.RUnlock()
fs, _ := NewFileSet(nil, i.sfile, nil)
for _, p := range i.partitions {
pfs, err := p.RetainFileSet()
if err != nil {
fs.Close()
return nil, err
}
fs.files = append(fs.files, pfs.files...)
}
return fs, nil
} | [
"func",
"(",
"i",
"*",
"Index",
")",
"RetainFileSet",
"(",
")",
"(",
"*",
"FileSet",
",",
"error",
")",
"{",
"i",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"i",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"fs",
",",
"_",
":=",
"NewFi... | // RetainFileSet returns the set of all files across all partitions.
// This is only needed when all files need to be retained for an operation. | [
"RetainFileSet",
"returns",
"the",
"set",
"of",
"all",
"files",
"across",
"all",
"partitions",
".",
"This",
"is",
"only",
"needed",
"when",
"all",
"files",
"need",
"to",
"be",
"retained",
"for",
"an",
"operation",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsi1/index.go#L1134-L1148 |
134,911 | influxdata/platform | tsdb/tsi1/index.go | MatchTagValueSeriesIDIterator | func (i *Index) MatchTagValueSeriesIDIterator(name, key []byte, value *regexp.Regexp, matches bool) (tsdb.SeriesIDIterator, error) {
release := i.sfile.Retain()
defer release()
itr, err := i.matchTagValueSeriesIDIterator(name, key, value, matches)
if err != nil {
return nil, err
}
return tsdb.FilterUndeletedSe... | go | func (i *Index) MatchTagValueSeriesIDIterator(name, key []byte, value *regexp.Regexp, matches bool) (tsdb.SeriesIDIterator, error) {
release := i.sfile.Retain()
defer release()
itr, err := i.matchTagValueSeriesIDIterator(name, key, value, matches)
if err != nil {
return nil, err
}
return tsdb.FilterUndeletedSe... | [
"func",
"(",
"i",
"*",
"Index",
")",
"MatchTagValueSeriesIDIterator",
"(",
"name",
",",
"key",
"[",
"]",
"byte",
",",
"value",
"*",
"regexp",
".",
"Regexp",
",",
"matches",
"bool",
")",
"(",
"tsdb",
".",
"SeriesIDIterator",
",",
"error",
")",
"{",
"rel... | // MatchTagValueSeriesIDIterator returns a series iterator for tags which match value.
// If matches is false, returns iterators which do not match value. | [
"MatchTagValueSeriesIDIterator",
"returns",
"a",
"series",
"iterator",
"for",
"tags",
"which",
"match",
"value",
".",
"If",
"matches",
"is",
"false",
"returns",
"iterators",
"which",
"do",
"not",
"match",
"value",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsi1/index.go#L1378-L1387 |
134,912 | influxdata/platform | gather/storage.go | Process | func (h *StorageHandler) Process(s nats.Subscription, m nats.Message) {
defer m.Ack()
ms := make([]Metrics, 0)
err := json.Unmarshal(m.Data(), &ms)
if err != nil {
h.Logger.Error(fmt.Sprintf("storage handler process err: %v", err))
return
}
err = h.Storage.Record(ms)
if err != nil {
h.Logger.Error(fmt.Spri... | go | func (h *StorageHandler) Process(s nats.Subscription, m nats.Message) {
defer m.Ack()
ms := make([]Metrics, 0)
err := json.Unmarshal(m.Data(), &ms)
if err != nil {
h.Logger.Error(fmt.Sprintf("storage handler process err: %v", err))
return
}
err = h.Storage.Record(ms)
if err != nil {
h.Logger.Error(fmt.Spri... | [
"func",
"(",
"h",
"*",
"StorageHandler",
")",
"Process",
"(",
"s",
"nats",
".",
"Subscription",
",",
"m",
"nats",
".",
"Message",
")",
"{",
"defer",
"m",
".",
"Ack",
"(",
")",
"\n",
"ms",
":=",
"make",
"(",
"[",
"]",
"Metrics",
",",
"0",
")",
"... | // Process consumes job queue, and use storage to record. | [
"Process",
"consumes",
"job",
"queue",
"and",
"use",
"storage",
"to",
"record",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/gather/storage.go#L24-L36 |
134,913 | influxdata/platform | bolt/bucket.go | CreateBucket | func (c *Client) CreateBucket(ctx context.Context, b *platform.Bucket) error {
var err error
op := getOp(platform.OpCreateBucket)
return c.db.Update(func(tx *bolt.Tx) error {
if b.OrganizationID.Valid() {
_, pe := c.findOrganizationByID(ctx, tx, b.OrganizationID)
if pe != nil {
return &platform.Error{
... | go | func (c *Client) CreateBucket(ctx context.Context, b *platform.Bucket) error {
var err error
op := getOp(platform.OpCreateBucket)
return c.db.Update(func(tx *bolt.Tx) error {
if b.OrganizationID.Valid() {
_, pe := c.findOrganizationByID(ctx, tx, b.OrganizationID)
if pe != nil {
return &platform.Error{
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateBucket",
"(",
"ctx",
"context",
".",
"Context",
",",
"b",
"*",
"platform",
".",
"Bucket",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"op",
":=",
"getOp",
"(",
"platform",
".",
"OpCreateBucket",
")",
"... | // CreateBucket creates a platform bucket and sets b.ID. | [
"CreateBucket",
"creates",
"a",
"platform",
"bucket",
"and",
"sets",
"b",
".",
"ID",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/bolt/bucket.go#L305-L359 |
134,914 | influxdata/platform | id.go | UnmarshalJSON | func (i *ID) UnmarshalJSON(b []byte) error {
if b[0] == '"' {
b = b[1:]
}
if b[len(b)-1] == '"' {
b = b[:len(b)-1]
}
return i.Decode(b)
} | go | func (i *ID) UnmarshalJSON(b []byte) error {
if b[0] == '"' {
b = b[1:]
}
if b[len(b)-1] == '"' {
b = b[:len(b)-1]
}
return i.Decode(b)
} | [
"func",
"(",
"i",
"*",
"ID",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"b",
"[",
"0",
"]",
"==",
"'\"'",
"{",
"b",
"=",
"b",
"[",
"1",
":",
"]",
"\n",
"}",
"\n\n",
"if",
"b",
"[",
"len",
"(",
"b",
")",
"... | // UnmarshalJSON implements JSON unmarshaller for IDs. | [
"UnmarshalJSON",
"implements",
"JSON",
"unmarshaller",
"for",
"IDs",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/id.go#L123-L133 |
134,915 | influxdata/platform | id.go | MarshalJSON | func (i ID) MarshalJSON() ([]byte, error) {
enc, err := i.Encode()
if err != nil {
return nil, err
}
return json.Marshal(string(enc))
} | go | func (i ID) MarshalJSON() ([]byte, error) {
enc, err := i.Encode()
if err != nil {
return nil, err
}
return json.Marshal(string(enc))
} | [
"func",
"(",
"i",
"ID",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"enc",
",",
"err",
":=",
"i",
".",
"Encode",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"... | // MarshalJSON implements JSON marshaller for IDs. | [
"MarshalJSON",
"implements",
"JSON",
"marshaller",
"for",
"IDs",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/id.go#L136-L142 |
134,916 | influxdata/platform | tsdb/tsm1/ring.go | getPartition | func (r *ring) getPartition(key []byte) *partition {
return r.partitions[int(xxhash.Sum64(key)%partitions)]
} | go | func (r *ring) getPartition(key []byte) *partition {
return r.partitions[int(xxhash.Sum64(key)%partitions)]
} | [
"func",
"(",
"r",
"*",
"ring",
")",
"getPartition",
"(",
"key",
"[",
"]",
"byte",
")",
"*",
"partition",
"{",
"return",
"r",
".",
"partitions",
"[",
"int",
"(",
"xxhash",
".",
"Sum64",
"(",
"key",
")",
"%",
"partitions",
")",
"]",
"\n",
"}"
] | // getPartition retrieves the hash ring partition associated with the provided
// key. | [
"getPartition",
"retrieves",
"the",
"hash",
"ring",
"partition",
"associated",
"with",
"the",
"provided",
"key",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/ring.go#L86-L88 |
134,917 | influxdata/platform | inmem/organization_service.go | FindOrganization | func (s *Service) FindOrganization(ctx context.Context, filter platform.OrganizationFilter) (*platform.Organization, error) {
op := OpPrefix + platform.OpFindOrganization
if filter.ID == nil && filter.Name == nil {
return nil, &platform.Error{
Code: platform.EInvalid,
Op: op,
Msg: "no filter parameters ... | go | func (s *Service) FindOrganization(ctx context.Context, filter platform.OrganizationFilter) (*platform.Organization, error) {
op := OpPrefix + platform.OpFindOrganization
if filter.ID == nil && filter.Name == nil {
return nil, &platform.Error{
Code: platform.EInvalid,
Op: op,
Msg: "no filter parameters ... | [
"func",
"(",
"s",
"*",
"Service",
")",
"FindOrganization",
"(",
"ctx",
"context",
".",
"Context",
",",
"filter",
"platform",
".",
"OrganizationFilter",
")",
"(",
"*",
"platform",
".",
"Organization",
",",
"error",
")",
"{",
"op",
":=",
"OpPrefix",
"+",
"... | // FindOrganization returns the first organization that matches a filter. | [
"FindOrganization",
"returns",
"the",
"first",
"organization",
"that",
"matches",
"a",
"filter",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/inmem/organization_service.go#L79-L116 |
134,918 | influxdata/platform | inmem/organization_service.go | FindOrganizations | func (s *Service) FindOrganizations(ctx context.Context, filter platform.OrganizationFilter, opt ...platform.FindOptions) ([]*platform.Organization, int, error) {
op := OpPrefix + platform.OpFindOrganizations
if filter.ID != nil {
o, err := s.FindOrganizationByID(ctx, *filter.ID)
if err != nil {
return nil, 0,... | go | func (s *Service) FindOrganizations(ctx context.Context, filter platform.OrganizationFilter, opt ...platform.FindOptions) ([]*platform.Organization, int, error) {
op := OpPrefix + platform.OpFindOrganizations
if filter.ID != nil {
o, err := s.FindOrganizationByID(ctx, *filter.ID)
if err != nil {
return nil, 0,... | [
"func",
"(",
"s",
"*",
"Service",
")",
"FindOrganizations",
"(",
"ctx",
"context",
".",
"Context",
",",
"filter",
"platform",
".",
"OrganizationFilter",
",",
"opt",
"...",
"platform",
".",
"FindOptions",
")",
"(",
"[",
"]",
"*",
"platform",
".",
"Organizat... | // FindOrganizations returns a list of organizations that match filter and the total count of matching organizations. | [
"FindOrganizations",
"returns",
"a",
"list",
"of",
"organizations",
"that",
"match",
"filter",
"and",
"the",
"total",
"count",
"of",
"matching",
"organizations",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/inmem/organization_service.go#L119-L157 |
134,919 | influxdata/platform | zap/auth_service.go | SetAuthorizationStatus | func (s *AuthorizationService) SetAuthorizationStatus(ctx context.Context, id platform.ID, status platform.Status) (err error) {
defer func() {
if err != nil {
s.Logger.Info("error updating authorization", zap.Error(err))
}
}()
return s.AuthorizationService.SetAuthorizationStatus(ctx, id, status)
} | go | func (s *AuthorizationService) SetAuthorizationStatus(ctx context.Context, id platform.ID, status platform.Status) (err error) {
defer func() {
if err != nil {
s.Logger.Info("error updating authorization", zap.Error(err))
}
}()
return s.AuthorizationService.SetAuthorizationStatus(ctx, id, status)
} | [
"func",
"(",
"s",
"*",
"AuthorizationService",
")",
"SetAuthorizationStatus",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"platform",
".",
"ID",
",",
"status",
"platform",
".",
"Status",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")"... | // SetAuthorizationStatus updates an authorization's status and logs any errors. | [
"SetAuthorizationStatus",
"updates",
"an",
"authorization",
"s",
"status",
"and",
"logs",
"any",
"errors",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/zap/auth_service.go#L75-L83 |
134,920 | influxdata/platform | tsdb/tsm1/bool.go | Write | func (e *BooleanEncoder) Write(b bool) {
// If we have filled the current byte, flush it
if e.i >= 8 {
e.flush()
}
// Use 1 bit for each boolean value, shift the current byte
// by 1 and set the least signficant bit acordingly
e.b = e.b << 1
if b {
e.b |= 1
}
// Increment the current boolean count
e.i++... | go | func (e *BooleanEncoder) Write(b bool) {
// If we have filled the current byte, flush it
if e.i >= 8 {
e.flush()
}
// Use 1 bit for each boolean value, shift the current byte
// by 1 and set the least signficant bit acordingly
e.b = e.b << 1
if b {
e.b |= 1
}
// Increment the current boolean count
e.i++... | [
"func",
"(",
"e",
"*",
"BooleanEncoder",
")",
"Write",
"(",
"b",
"bool",
")",
"{",
"// If we have filled the current byte, flush it",
"if",
"e",
".",
"i",
">=",
"8",
"{",
"e",
".",
"flush",
"(",
")",
"\n",
"}",
"\n\n",
"// Use 1 bit for each boolean value, shi... | // Write encodes b to the underlying buffer. | [
"Write",
"encodes",
"b",
"to",
"the",
"underlying",
"buffer",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/bool.go#L48-L65 |
134,921 | influxdata/platform | cmd/influxd/launcher/launcher.go | Shutdown | func (m *Launcher) Shutdown(ctx context.Context) {
m.httpServer.Shutdown(ctx)
m.logger.Info("Stopping", zap.String("service", "task"))
m.scheduler.Stop()
m.logger.Info("Stopping", zap.String("service", "nats"))
m.natsServer.Close()
m.logger.Info("Stopping", zap.String("service", "bolt"))
if err := m.boltClien... | go | func (m *Launcher) Shutdown(ctx context.Context) {
m.httpServer.Shutdown(ctx)
m.logger.Info("Stopping", zap.String("service", "task"))
m.scheduler.Stop()
m.logger.Info("Stopping", zap.String("service", "nats"))
m.natsServer.Close()
m.logger.Info("Stopping", zap.String("service", "bolt"))
if err := m.boltClien... | [
"func",
"(",
"m",
"*",
"Launcher",
")",
"Shutdown",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"m",
".",
"httpServer",
".",
"Shutdown",
"(",
"ctx",
")",
"\n\n",
"m",
".",
"logger",
".",
"Info",
"(",
"\"",
"\"",
",",
"zap",
".",
"String",
"(... | // Shutdown shuts down the HTTP server and waits for all services to clean up. | [
"Shutdown",
"shuts",
"down",
"the",
"HTTP",
"server",
"and",
"waits",
"for",
"all",
"services",
"to",
"clean",
"up",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/cmd/influxd/launcher/launcher.go#L109-L136 |
134,922 | influxdata/platform | query/influxql/service.go | Query | func (s *Service) Query(ctx context.Context, req *query.Request) (flux.ResultIterator, error) {
resp, err := s.query(ctx, req)
if err != nil {
return nil, err
}
// Decode the response into the JSON structure.
var results Response
if err := json.NewDecoder(resp.Body).Decode(&results); err != nil {
return nil,... | go | func (s *Service) Query(ctx context.Context, req *query.Request) (flux.ResultIterator, error) {
resp, err := s.query(ctx, req)
if err != nil {
return nil, err
}
// Decode the response into the JSON structure.
var results Response
if err := json.NewDecoder(resp.Body).Decode(&results); err != nil {
return nil,... | [
"func",
"(",
"s",
"*",
"Service",
")",
"Query",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"query",
".",
"Request",
")",
"(",
"flux",
".",
"ResultIterator",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"s",
".",
"query",
"(",
"c... | // Query will execute a query for the influxql.Compiler type against an influxdb 1.x endpoint,
// and return results using the default decoder. | [
"Query",
"will",
"execute",
"a",
"query",
"for",
"the",
"influxql",
".",
"Compiler",
"type",
"against",
"an",
"influxdb",
"1",
".",
"x",
"endpoint",
"and",
"return",
"results",
"using",
"the",
"default",
"decoder",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/query/influxql/service.go#L31-L45 |
134,923 | influxdata/platform | task/backend/executor/executor.go | NewAsyncQueryServiceExecutor | func NewAsyncQueryServiceExecutor(logger *zap.Logger, svc query.AsyncQueryService, st backend.Store) backend.Executor {
return &asyncQueryServiceExecutor{logger: logger, svc: svc, st: st}
} | go | func NewAsyncQueryServiceExecutor(logger *zap.Logger, svc query.AsyncQueryService, st backend.Store) backend.Executor {
return &asyncQueryServiceExecutor{logger: logger, svc: svc, st: st}
} | [
"func",
"NewAsyncQueryServiceExecutor",
"(",
"logger",
"*",
"zap",
".",
"Logger",
",",
"svc",
"query",
".",
"AsyncQueryService",
",",
"st",
"backend",
".",
"Store",
")",
"backend",
".",
"Executor",
"{",
"return",
"&",
"asyncQueryServiceExecutor",
"{",
"logger",
... | // NewQueryServiceExecutor returns a new executor based on the given AsyncQueryService. | [
"NewQueryServiceExecutor",
"returns",
"a",
"new",
"executor",
"based",
"on",
"the",
"given",
"AsyncQueryService",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/task/backend/executor/executor.go#L189-L191 |
134,924 | influxdata/platform | mock/auth_service.go | NewAuthorizationService | func NewAuthorizationService() *AuthorizationService {
return &AuthorizationService{
FindAuthorizationByIDFn: func(context.Context, platform.ID) (*platform.Authorization, error) { return nil, nil },
FindAuthorizationByTokenFn: func(context.Context, string) (*platform.Authorization, error) { return nil, nil },
... | go | func NewAuthorizationService() *AuthorizationService {
return &AuthorizationService{
FindAuthorizationByIDFn: func(context.Context, platform.ID) (*platform.Authorization, error) { return nil, nil },
FindAuthorizationByTokenFn: func(context.Context, string) (*platform.Authorization, error) { return nil, nil },
... | [
"func",
"NewAuthorizationService",
"(",
")",
"*",
"AuthorizationService",
"{",
"return",
"&",
"AuthorizationService",
"{",
"FindAuthorizationByIDFn",
":",
"func",
"(",
"context",
".",
"Context",
",",
"platform",
".",
"ID",
")",
"(",
"*",
"platform",
".",
"Author... | // NewAuthorizationService returns a mock AuthorizationService where its methods will return
// zero values. | [
"NewAuthorizationService",
"returns",
"a",
"mock",
"AuthorizationService",
"where",
"its",
"methods",
"will",
"return",
"zero",
"values",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/mock/auth_service.go#L29-L40 |
134,925 | influxdata/platform | http/user_service.go | FindMe | func (s *UserService) FindMe(ctx context.Context, id platform.ID) (*platform.User, error) {
url, err := newURL(s.Addr, mePath)
if err != nil {
return nil, err
}
req, err := http.NewRequest("GET", url.String(), nil)
if err != nil {
return nil, err
}
SetToken(s.Token, req)
hc := newClient(url.Scheme, s.Inse... | go | func (s *UserService) FindMe(ctx context.Context, id platform.ID) (*platform.User, error) {
url, err := newURL(s.Addr, mePath)
if err != nil {
return nil, err
}
req, err := http.NewRequest("GET", url.String(), nil)
if err != nil {
return nil, err
}
SetToken(s.Token, req)
hc := newClient(url.Scheme, s.Inse... | [
"func",
"(",
"s",
"*",
"UserService",
")",
"FindMe",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"platform",
".",
"ID",
")",
"(",
"*",
"platform",
".",
"User",
",",
"error",
")",
"{",
"url",
",",
"err",
":=",
"newURL",
"(",
"s",
".",
"Addr"... | // FindMe returns user information about the owner of the token | [
"FindMe",
"returns",
"user",
"information",
"about",
"the",
"owner",
"of",
"the",
"token"
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/http/user_service.go#L421-L450 |
134,926 | influxdata/platform | http/user_service.go | FindUsers | func (s *UserService) FindUsers(ctx context.Context, filter platform.UserFilter, opt ...platform.FindOptions) ([]*platform.User, int, error) {
url, err := newURL(s.Addr, usersPath)
if err != nil {
return nil, 0, err
}
query := url.Query()
req, err := http.NewRequest("GET", url.String(), nil)
if err != nil {
... | go | func (s *UserService) FindUsers(ctx context.Context, filter platform.UserFilter, opt ...platform.FindOptions) ([]*platform.User, int, error) {
url, err := newURL(s.Addr, usersPath)
if err != nil {
return nil, 0, err
}
query := url.Query()
req, err := http.NewRequest("GET", url.String(), nil)
if err != nil {
... | [
"func",
"(",
"s",
"*",
"UserService",
")",
"FindUsers",
"(",
"ctx",
"context",
".",
"Context",
",",
"filter",
"platform",
".",
"UserFilter",
",",
"opt",
"...",
"platform",
".",
"FindOptions",
")",
"(",
"[",
"]",
"*",
"platform",
".",
"User",
",",
"int"... | // FindUsers returns a list of users that match filter and the total count of matching users.
// Additional options provide pagination & sorting. | [
"FindUsers",
"returns",
"a",
"list",
"of",
"users",
"that",
"match",
"filter",
"and",
"the",
"total",
"count",
"of",
"matching",
"users",
".",
"Additional",
"options",
"provide",
"pagination",
"&",
"sorting",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/http/user_service.go#L507-L546 |
134,927 | influxdata/platform | http/user_service.go | CreateUser | func (s *UserService) CreateUser(ctx context.Context, u *platform.User) error {
url, err := newURL(s.Addr, usersPath)
if err != nil {
return err
}
octets, err := json.Marshal(u)
if err != nil {
return err
}
req, err := http.NewRequest("POST", url.String(), bytes.NewReader(octets))
if err != nil {
return... | go | func (s *UserService) CreateUser(ctx context.Context, u *platform.User) error {
url, err := newURL(s.Addr, usersPath)
if err != nil {
return err
}
octets, err := json.Marshal(u)
if err != nil {
return err
}
req, err := http.NewRequest("POST", url.String(), bytes.NewReader(octets))
if err != nil {
return... | [
"func",
"(",
"s",
"*",
"UserService",
")",
"CreateUser",
"(",
"ctx",
"context",
".",
"Context",
",",
"u",
"*",
"platform",
".",
"User",
")",
"error",
"{",
"url",
",",
"err",
":=",
"newURL",
"(",
"s",
".",
"Addr",
",",
"usersPath",
")",
"\n",
"if",
... | // CreateUser creates a new user and sets u.ID with the new identifier. | [
"CreateUser",
"creates",
"a",
"new",
"user",
"and",
"sets",
"u",
".",
"ID",
"with",
"the",
"new",
"identifier",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/http/user_service.go#L549-L585 |
134,928 | influxdata/platform | pkg/deep/equal.go | Equal | func Equal(a1, a2 interface{}) bool {
if a1 == nil || a2 == nil {
return a1 == a2
}
v1 := reflect.ValueOf(a1)
v2 := reflect.ValueOf(a2)
if v1.Type() != v2.Type() {
return false
}
return deepValueEqual(v1, v2, make(map[visit]bool), 0)
} | go | func Equal(a1, a2 interface{}) bool {
if a1 == nil || a2 == nil {
return a1 == a2
}
v1 := reflect.ValueOf(a1)
v2 := reflect.ValueOf(a2)
if v1.Type() != v2.Type() {
return false
}
return deepValueEqual(v1, v2, make(map[visit]bool), 0)
} | [
"func",
"Equal",
"(",
"a1",
",",
"a2",
"interface",
"{",
"}",
")",
"bool",
"{",
"if",
"a1",
"==",
"nil",
"||",
"a2",
"==",
"nil",
"{",
"return",
"a1",
"==",
"a2",
"\n",
"}",
"\n",
"v1",
":=",
"reflect",
".",
"ValueOf",
"(",
"a1",
")",
"\n",
"... | // Equal is a copy of reflect.DeepEqual except that it treats NaN == NaN as true. | [
"Equal",
"is",
"a",
"copy",
"of",
"reflect",
".",
"DeepEqual",
"except",
"that",
"it",
"treats",
"NaN",
"==",
"NaN",
"as",
"true",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/pkg/deep/equal.go#L41-L51 |
134,929 | influxdata/platform | storage/compat/compat.go | NewConfig | func NewConfig() Config {
return Config{
WALFsyncDelay: toml.Duration(tsm1.DefaultWALFsyncDelay),
ValidateKeys: storage.DefaultValidateKeys,
CacheMaxMemorySize: toml.Size(tsm1.DefaultCacheMaxMemorySize),
CacheSnapshotMemorySize: toml.Size(tsm1.DefaultCacheS... | go | func NewConfig() Config {
return Config{
WALFsyncDelay: toml.Duration(tsm1.DefaultWALFsyncDelay),
ValidateKeys: storage.DefaultValidateKeys,
CacheMaxMemorySize: toml.Size(tsm1.DefaultCacheMaxMemorySize),
CacheSnapshotMemorySize: toml.Size(tsm1.DefaultCacheS... | [
"func",
"NewConfig",
"(",
")",
"Config",
"{",
"return",
"Config",
"{",
"WALFsyncDelay",
":",
"toml",
".",
"Duration",
"(",
"tsm1",
".",
"DefaultWALFsyncDelay",
")",
",",
"ValidateKeys",
":",
"storage",
".",
"DefaultValidateKeys",
",",
"CacheMaxMemorySize",
":",
... | // NewConfig constructs an old Config struct with appropriate defaults for a new Config. | [
"NewConfig",
"constructs",
"an",
"old",
"Config",
"struct",
"with",
"appropriate",
"defaults",
"for",
"a",
"new",
"Config",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/storage/compat/compat.go#L35-L49 |
134,930 | influxdata/platform | storage/compat/compat.go | Convert | func Convert(oldConfig Config) (string, storage.Config) {
newConfig := storage.NewConfig()
newConfig.TraceLoggingEnabled = oldConfig.TraceLoggingEnabled
newConfig.ValidateKeys = oldConfig.ValidateKeys
newConfig.Engine.MADVWillNeed = oldConfig.TSMWillNeed
newConfig.Engine.Cache.MaxMemorySize = oldConfig.CacheMaxMem... | go | func Convert(oldConfig Config) (string, storage.Config) {
newConfig := storage.NewConfig()
newConfig.TraceLoggingEnabled = oldConfig.TraceLoggingEnabled
newConfig.ValidateKeys = oldConfig.ValidateKeys
newConfig.Engine.MADVWillNeed = oldConfig.TSMWillNeed
newConfig.Engine.Cache.MaxMemorySize = oldConfig.CacheMaxMem... | [
"func",
"Convert",
"(",
"oldConfig",
"Config",
")",
"(",
"string",
",",
"storage",
".",
"Config",
")",
"{",
"newConfig",
":=",
"storage",
".",
"NewConfig",
"(",
")",
"\n",
"newConfig",
".",
"TraceLoggingEnabled",
"=",
"oldConfig",
".",
"TraceLoggingEnabled",
... | // Convert takes an old Config and converts it into a new Config. It also returns the value
// of the Dir key so that it can be passed through appropriately to the storage engine constructor. | [
"Convert",
"takes",
"an",
"old",
"Config",
"and",
"converts",
"it",
"into",
"a",
"new",
"Config",
".",
"It",
"also",
"returns",
"the",
"value",
"of",
"the",
"Dir",
"key",
"so",
"that",
"it",
"can",
"be",
"passed",
"through",
"appropriately",
"to",
"the",... | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/storage/compat/compat.go#L53-L68 |
134,931 | influxdata/platform | query/control/controller.go | Query | func (c *Controller) Query(ctx context.Context, req *query.Request) (flux.Query, error) {
// Set the request on the context so platform specific Flux operations can retrieve it later.
ctx = query.ContextWithRequest(ctx, req)
// Set the org label value for controller metrics
ctx = context.WithValue(ctx, orgLabel, re... | go | func (c *Controller) Query(ctx context.Context, req *query.Request) (flux.Query, error) {
// Set the request on the context so platform specific Flux operations can retrieve it later.
ctx = query.ContextWithRequest(ctx, req)
// Set the org label value for controller metrics
ctx = context.WithValue(ctx, orgLabel, re... | [
"func",
"(",
"c",
"*",
"Controller",
")",
"Query",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"query",
".",
"Request",
")",
"(",
"flux",
".",
"Query",
",",
"error",
")",
"{",
"// Set the request on the context so platform specific Flux operations ca... | // Query satisfies the AsyncQueryService while ensuring the request is propagated on the context. | [
"Query",
"satisfies",
"the",
"AsyncQueryService",
"while",
"ensuring",
"the",
"request",
"is",
"propagated",
"on",
"the",
"context",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/query/control/controller.go#L30-L46 |
134,932 | influxdata/platform | pkg/rhh/rhh.go | grow | func (m *HashMap) grow() {
// Copy old elements and hashes.
elems, hashes := m.elems, m.hashes
capacity := m.capacity
// Double capacity & reallocate.
m.capacity *= 2
m.alloc()
// Copy old elements to new hash/elem list.
for i := int64(0); i < capacity; i++ {
elem, hash := &elems[i], hashes[i]
if hash == ... | go | func (m *HashMap) grow() {
// Copy old elements and hashes.
elems, hashes := m.elems, m.hashes
capacity := m.capacity
// Double capacity & reallocate.
m.capacity *= 2
m.alloc()
// Copy old elements to new hash/elem list.
for i := int64(0); i < capacity; i++ {
elem, hash := &elems[i], hashes[i]
if hash == ... | [
"func",
"(",
"m",
"*",
"HashMap",
")",
"grow",
"(",
")",
"{",
"// Copy old elements and hashes.",
"elems",
",",
"hashes",
":=",
"m",
".",
"elems",
",",
"m",
".",
"hashes",
"\n",
"capacity",
":=",
"m",
".",
"capacity",
"\n\n",
"// Double capacity & reallocate... | // grow doubles the capacity and reinserts all existing hashes & elements. | [
"grow",
"doubles",
"the",
"capacity",
"and",
"reinserts",
"all",
"existing",
"hashes",
"&",
"elements",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/pkg/rhh/rhh.go#L185-L202 |
134,933 | influxdata/platform | bolt/dashboard.go | CreateDashboard | func (c *Client) CreateDashboard(ctx context.Context, d *platform.Dashboard) error {
err := c.db.Update(func(tx *bolt.Tx) error {
d.ID = c.IDGenerator.ID()
for _, cell := range d.Cells {
cell.ID = c.IDGenerator.ID()
if err := c.createCellView(ctx, tx, d.ID, cell.ID, nil); err != nil {
return err
}
... | go | func (c *Client) CreateDashboard(ctx context.Context, d *platform.Dashboard) error {
err := c.db.Update(func(tx *bolt.Tx) error {
d.ID = c.IDGenerator.ID()
for _, cell := range d.Cells {
cell.ID = c.IDGenerator.ID()
if err := c.createCellView(ctx, tx, d.ID, cell.ID, nil); err != nil {
return err
}
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateDashboard",
"(",
"ctx",
"context",
".",
"Context",
",",
"d",
"*",
"platform",
".",
"Dashboard",
")",
"error",
"{",
"err",
":=",
"c",
".",
"db",
".",
"Update",
"(",
"func",
"(",
"tx",
"*",
"bolt",
".",
... | // CreateDashboard creates a platform dashboard and sets d.ID. | [
"CreateDashboard",
"creates",
"a",
"platform",
"dashboard",
"and",
"sets",
"d",
".",
"ID",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/bolt/dashboard.go#L197-L225 |
134,934 | influxdata/platform | tsdb/tsm1/wal.go | EnableTraceLogging | func (l *WAL) EnableTraceLogging(enabled bool) {
l.traceLogging = enabled
if enabled {
l.traceLogger = l.logger
}
} | go | func (l *WAL) EnableTraceLogging(enabled bool) {
l.traceLogging = enabled
if enabled {
l.traceLogger = l.logger
}
} | [
"func",
"(",
"l",
"*",
"WAL",
")",
"EnableTraceLogging",
"(",
"enabled",
"bool",
")",
"{",
"l",
".",
"traceLogging",
"=",
"enabled",
"\n",
"if",
"enabled",
"{",
"l",
".",
"traceLogger",
"=",
"l",
".",
"logger",
"\n",
"}",
"\n",
"}"
] | // EnableTraceLogging must be called before the WAL is opened. | [
"EnableTraceLogging",
"must",
"be",
"called",
"before",
"the",
"WAL",
"is",
"opened",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/wal.go#L145-L150 |
134,935 | influxdata/platform | tsdb/tsm1/wal.go | WriteMulti | func (l *WAL) WriteMulti(values map[string][]Value) (int, error) {
entry := &WriteWALEntry{
Values: values,
}
id, err := l.writeToLog(entry)
if err != nil {
l.tracker.IncWritesErr()
return -1, err
}
l.tracker.IncWritesOK()
return id, nil
} | go | func (l *WAL) WriteMulti(values map[string][]Value) (int, error) {
entry := &WriteWALEntry{
Values: values,
}
id, err := l.writeToLog(entry)
if err != nil {
l.tracker.IncWritesErr()
return -1, err
}
l.tracker.IncWritesOK()
return id, nil
} | [
"func",
"(",
"l",
"*",
"WAL",
")",
"WriteMulti",
"(",
"values",
"map",
"[",
"string",
"]",
"[",
"]",
"Value",
")",
"(",
"int",
",",
"error",
")",
"{",
"entry",
":=",
"&",
"WriteWALEntry",
"{",
"Values",
":",
"values",
",",
"}",
"\n\n",
"id",
",",... | // WriteMulti writes the given values to the WAL. It returns the WAL segment ID to
// which the points were written. If an error is returned the segment ID should
// be ignored. | [
"WriteMulti",
"writes",
"the",
"given",
"values",
"to",
"the",
"WAL",
".",
"It",
"returns",
"the",
"WAL",
"segment",
"ID",
"to",
"which",
"the",
"points",
"were",
"written",
".",
"If",
"an",
"error",
"is",
"returned",
"the",
"segment",
"ID",
"should",
"b... | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/wal.go#L303-L316 |
134,936 | influxdata/platform | tsdb/tsm1/wal.go | ClosedSegments | func (l *WAL) ClosedSegments() ([]string, error) {
l.mu.RLock()
defer l.mu.RUnlock()
// Not loading files from disk so nothing to do
if l.path == "" {
return nil, nil
}
var currentFile string
if l.currentSegmentWriter != nil {
currentFile = l.currentSegmentWriter.path()
}
files, err := segmentFileNames(l... | go | func (l *WAL) ClosedSegments() ([]string, error) {
l.mu.RLock()
defer l.mu.RUnlock()
// Not loading files from disk so nothing to do
if l.path == "" {
return nil, nil
}
var currentFile string
if l.currentSegmentWriter != nil {
currentFile = l.currentSegmentWriter.path()
}
files, err := segmentFileNames(l... | [
"func",
"(",
"l",
"*",
"WAL",
")",
"ClosedSegments",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"l",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"l",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"// Not loading files from disk s... | // ClosedSegments returns a slice of the names of the closed segment files. | [
"ClosedSegments",
"returns",
"a",
"slice",
"of",
"the",
"names",
"of",
"the",
"closed",
"segment",
"files",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/wal.go#L319-L348 |
134,937 | influxdata/platform | tsdb/tsm1/wal.go | Delete | func (l *WAL) Delete(keys [][]byte) (int, error) {
if len(keys) == 0 {
return 0, nil
}
entry := &DeleteWALEntry{
Keys: keys,
}
id, err := l.writeToLog(entry)
if err != nil {
return -1, err
}
return id, nil
} | go | func (l *WAL) Delete(keys [][]byte) (int, error) {
if len(keys) == 0 {
return 0, nil
}
entry := &DeleteWALEntry{
Keys: keys,
}
id, err := l.writeToLog(entry)
if err != nil {
return -1, err
}
return id, nil
} | [
"func",
"(",
"l",
"*",
"WAL",
")",
"Delete",
"(",
"keys",
"[",
"]",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"len",
"(",
"keys",
")",
"==",
"0",
"{",
"return",
"0",
",",
"nil",
"\n",
"}",
"\n",
"entry",
":=",
"&",
... | // Delete deletes the given keys, returning the segment ID for the operation. | [
"Delete",
"deletes",
"the",
"given",
"keys",
"returning",
"the",
"segment",
"ID",
"for",
"the",
"operation",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/wal.go#L487-L500 |
134,938 | influxdata/platform | tsdb/tsm1/wal.go | DeleteRange | func (l *WAL) DeleteRange(keys [][]byte, min, max int64) (int, error) {
if len(keys) == 0 {
return 0, nil
}
entry := &DeleteRangeWALEntry{
Keys: keys,
Min: min,
Max: max,
}
id, err := l.writeToLog(entry)
if err != nil {
return -1, err
}
return id, nil
} | go | func (l *WAL) DeleteRange(keys [][]byte, min, max int64) (int, error) {
if len(keys) == 0 {
return 0, nil
}
entry := &DeleteRangeWALEntry{
Keys: keys,
Min: min,
Max: max,
}
id, err := l.writeToLog(entry)
if err != nil {
return -1, err
}
return id, nil
} | [
"func",
"(",
"l",
"*",
"WAL",
")",
"DeleteRange",
"(",
"keys",
"[",
"]",
"[",
"]",
"byte",
",",
"min",
",",
"max",
"int64",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"len",
"(",
"keys",
")",
"==",
"0",
"{",
"return",
"0",
",",
"nil",
"... | // DeleteRange deletes the given keys within the given time range,
// returning the segment ID for the operation. | [
"DeleteRange",
"deletes",
"the",
"given",
"keys",
"within",
"the",
"given",
"time",
"range",
"returning",
"the",
"segment",
"ID",
"for",
"the",
"operation",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/wal.go#L504-L519 |
134,939 | influxdata/platform | tsdb/tsm1/wal.go | segmentFileNames | func segmentFileNames(dir string) ([]string, error) {
names, err := filepath.Glob(filepath.Join(dir, fmt.Sprintf("%s*.%s", WALFilePrefix, WALFileExtension)))
if err != nil {
return nil, err
}
sort.Strings(names)
return names, nil
} | go | func segmentFileNames(dir string) ([]string, error) {
names, err := filepath.Glob(filepath.Join(dir, fmt.Sprintf("%s*.%s", WALFilePrefix, WALFileExtension)))
if err != nil {
return nil, err
}
sort.Strings(names)
return names, nil
} | [
"func",
"segmentFileNames",
"(",
"dir",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"names",
",",
"err",
":=",
"filepath",
".",
"Glob",
"(",
"filepath",
".",
"Join",
"(",
"dir",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
... | // segmentFileNames will return all files that are WAL segment files in sorted order by ascending ID. | [
"segmentFileNames",
"will",
"return",
"all",
"files",
"that",
"are",
"WAL",
"segment",
"files",
"in",
"sorted",
"order",
"by",
"ascending",
"ID",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/wal.go#L542-L549 |
134,940 | influxdata/platform | tsdb/tsm1/wal.go | Encode | func (w *DeleteWALEntry) Encode(dst []byte) ([]byte, error) {
sz := w.MarshalSize()
if len(dst) < sz {
dst = make([]byte, sz)
}
var n int
for _, k := range w.Keys {
n += copy(dst[n:], k)
n += copy(dst[n:], "\n")
}
// We return n-1 to strip off the last newline so that unmarshalling the value
// does no... | go | func (w *DeleteWALEntry) Encode(dst []byte) ([]byte, error) {
sz := w.MarshalSize()
if len(dst) < sz {
dst = make([]byte, sz)
}
var n int
for _, k := range w.Keys {
n += copy(dst[n:], k)
n += copy(dst[n:], "\n")
}
// We return n-1 to strip off the last newline so that unmarshalling the value
// does no... | [
"func",
"(",
"w",
"*",
"DeleteWALEntry",
")",
"Encode",
"(",
"dst",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"sz",
":=",
"w",
".",
"MarshalSize",
"(",
")",
"\n\n",
"if",
"len",
"(",
"dst",
")",
"<",
"sz",
"{",
"ds... | // Encode converts the DeleteWALEntry into a byte slice, appending to dst. | [
"Encode",
"converts",
"the",
"DeleteWALEntry",
"into",
"a",
"byte",
"slice",
"appending",
"to",
"dst",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/wal.go#L1005-L1021 |
134,941 | influxdata/platform | tsdb/tsm1/wal.go | Encode | func (w *DeleteRangeWALEntry) Encode(b []byte) ([]byte, error) {
sz := w.MarshalSize()
if len(b) < sz {
b = make([]byte, sz)
}
binary.BigEndian.PutUint64(b[:8], uint64(w.Min))
binary.BigEndian.PutUint64(b[8:16], uint64(w.Max))
i := 16
for _, k := range w.Keys {
binary.BigEndian.PutUint32(b[i:i+4], uint32(... | go | func (w *DeleteRangeWALEntry) Encode(b []byte) ([]byte, error) {
sz := w.MarshalSize()
if len(b) < sz {
b = make([]byte, sz)
}
binary.BigEndian.PutUint64(b[:8], uint64(w.Min))
binary.BigEndian.PutUint64(b[8:16], uint64(w.Max))
i := 16
for _, k := range w.Keys {
binary.BigEndian.PutUint32(b[i:i+4], uint32(... | [
"func",
"(",
"w",
"*",
"DeleteRangeWALEntry",
")",
"Encode",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"sz",
":=",
"w",
".",
"MarshalSize",
"(",
")",
"\n\n",
"if",
"len",
"(",
"b",
")",
"<",
"sz",
"{",
"b... | // Encode converts the DeleteRangeWALEntry into a byte slice, appending to b. | [
"Encode",
"converts",
"the",
"DeleteRangeWALEntry",
"into",
"a",
"byte",
"slice",
"appending",
"to",
"b",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/wal.go#L1087-L1105 |
134,942 | influxdata/platform | tsdb/tsm1/wal.go | Next | func (r *WALSegmentReader) Next() bool {
var nReadOK int
// read the type and the length of the entry
var lv [5]byte
n, err := io.ReadFull(r.r, lv[:])
if err == io.EOF {
return false
}
if err != nil {
r.err = err
// We return true here because we want the client code to call read which
// will return t... | go | func (r *WALSegmentReader) Next() bool {
var nReadOK int
// read the type and the length of the entry
var lv [5]byte
n, err := io.ReadFull(r.r, lv[:])
if err == io.EOF {
return false
}
if err != nil {
r.err = err
// We return true here because we want the client code to call read which
// will return t... | [
"func",
"(",
"r",
"*",
"WALSegmentReader",
")",
"Next",
"(",
")",
"bool",
"{",
"var",
"nReadOK",
"int",
"\n\n",
"// read the type and the length of the entry",
"var",
"lv",
"[",
"5",
"]",
"byte",
"\n",
"n",
",",
"err",
":=",
"io",
".",
"ReadFull",
"(",
"... | // Next indicates if there is a value to read. | [
"Next",
"indicates",
"if",
"there",
"is",
"a",
"value",
"to",
"read",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/wal.go#L1203-L1270 |
134,943 | influxdata/platform | bolt/authorization.go | SetAuthorizationStatus | func (c *Client) SetAuthorizationStatus(ctx context.Context, id platform.ID, status platform.Status) error {
return c.db.Update(func(tx *bolt.Tx) error {
if pe := c.updateAuthorization(ctx, tx, id, status); pe != nil {
return &platform.Error{
Err: pe,
Op: platform.OpSetAuthorizationStatus,
}
}
ret... | go | func (c *Client) SetAuthorizationStatus(ctx context.Context, id platform.ID, status platform.Status) error {
return c.db.Update(func(tx *bolt.Tx) error {
if pe := c.updateAuthorization(ctx, tx, id, status); pe != nil {
return &platform.Error{
Err: pe,
Op: platform.OpSetAuthorizationStatus,
}
}
ret... | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetAuthorizationStatus",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"platform",
".",
"ID",
",",
"status",
"platform",
".",
"Status",
")",
"error",
"{",
"return",
"c",
".",
"db",
".",
"Update",
"(",
"func",
... | // SetAuthorizationStatus updates the status of the authorization. Useful
// for setting an authorization to inactive or active. | [
"SetAuthorizationStatus",
"updates",
"the",
"status",
"of",
"the",
"authorization",
".",
"Useful",
"for",
"setting",
"an",
"authorization",
"to",
"inactive",
"or",
"active",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/bolt/authorization.go#L377-L387 |
134,944 | influxdata/platform | cmd/influx/main.go | Execute | func Execute() {
if err := influxCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
} | go | func Execute() {
if err := influxCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
} | [
"func",
"Execute",
"(",
")",
"{",
"if",
"err",
":=",
"influxCmd",
".",
"Execute",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Println",
"(",
"err",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"}"
] | // Execute executes the influx command | [
"Execute",
"executes",
"the",
"influx",
"command"
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/cmd/influx/main.go#L90-L95 |
134,945 | influxdata/platform | tsdb/tsm1/cache.go | init | func (c *Cache) init() {
if !atomic.CompareAndSwapUint32(&c.initializedCount, 0, 1) {
return
}
c.mu.Lock()
c.store, _ = newring(ringShards)
c.mu.Unlock()
} | go | func (c *Cache) init() {
if !atomic.CompareAndSwapUint32(&c.initializedCount, 0, 1) {
return
}
c.mu.Lock()
c.store, _ = newring(ringShards)
c.mu.Unlock()
} | [
"func",
"(",
"c",
"*",
"Cache",
")",
"init",
"(",
")",
"{",
"if",
"!",
"atomic",
".",
"CompareAndSwapUint32",
"(",
"&",
"c",
".",
"initializedCount",
",",
"0",
",",
"1",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"c",
".",
"mu",
".",
"Lock",
"(",
"... | // init initializes the cache and allocates the underlying store. Once initialized,
// the store re-used until Freed. | [
"init",
"initializes",
"the",
"cache",
"and",
"allocates",
"the",
"underlying",
"store",
".",
"Once",
"initialized",
"the",
"store",
"re",
"-",
"used",
"until",
"Freed",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/cache.go#L199-L207 |
134,946 | influxdata/platform | tsdb/tsm1/cache.go | Free | func (c *Cache) Free() {
if !atomic.CompareAndSwapUint32(&c.initializedCount, 1, 0) {
return
}
c.mu.Lock()
c.store = emptyStore{}
c.mu.Unlock()
} | go | func (c *Cache) Free() {
if !atomic.CompareAndSwapUint32(&c.initializedCount, 1, 0) {
return
}
c.mu.Lock()
c.store = emptyStore{}
c.mu.Unlock()
} | [
"func",
"(",
"c",
"*",
"Cache",
")",
"Free",
"(",
")",
"{",
"if",
"!",
"atomic",
".",
"CompareAndSwapUint32",
"(",
"&",
"c",
".",
"initializedCount",
",",
"1",
",",
"0",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"c",
".",
"mu",
".",
"Lock",
"(",
"... | // Free releases the underlying store and memory held by the Cache. | [
"Free",
"releases",
"the",
"underlying",
"store",
"and",
"memory",
"held",
"by",
"the",
"Cache",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/cache.go#L210-L218 |
134,947 | influxdata/platform | tsdb/tsm1/cache.go | Write | func (c *Cache) Write(key []byte, values []Value) error {
c.init()
addedSize := uint64(Values(values).Size())
// Enough room in the cache?
limit := c.maxSize
n := c.Size() + addedSize
if limit > 0 && n > limit {
c.tracker.IncWritesErr()
c.tracker.AddWrittenBytesDrop(uint64(addedSize))
return ErrCacheMemor... | go | func (c *Cache) Write(key []byte, values []Value) error {
c.init()
addedSize := uint64(Values(values).Size())
// Enough room in the cache?
limit := c.maxSize
n := c.Size() + addedSize
if limit > 0 && n > limit {
c.tracker.IncWritesErr()
c.tracker.AddWrittenBytesDrop(uint64(addedSize))
return ErrCacheMemor... | [
"func",
"(",
"c",
"*",
"Cache",
")",
"Write",
"(",
"key",
"[",
"]",
"byte",
",",
"values",
"[",
"]",
"Value",
")",
"error",
"{",
"c",
".",
"init",
"(",
")",
"\n",
"addedSize",
":=",
"uint64",
"(",
"Values",
"(",
"values",
")",
".",
"Size",
"(",... | // Write writes the set of values for the key to the cache. This function is goroutine-safe.
// It returns an error if the cache will exceed its max size by adding the new values. | [
"Write",
"writes",
"the",
"set",
"of",
"values",
"for",
"the",
"key",
"to",
"the",
"cache",
".",
"This",
"function",
"is",
"goroutine",
"-",
"safe",
".",
"It",
"returns",
"an",
"error",
"if",
"the",
"cache",
"will",
"exceed",
"its",
"max",
"size",
"by"... | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/cache.go#L222-L253 |
134,948 | influxdata/platform | tsdb/tsm1/cache.go | WriteMulti | func (c *Cache) WriteMulti(values map[string][]Value) error {
c.init()
var addedSize uint64
for _, v := range values {
addedSize += uint64(Values(v).Size())
}
// Enough room in the cache?
limit := c.maxSize // maxSize is safe for reading without a lock.
n := c.Size() + addedSize
if limit > 0 && n > limit {
... | go | func (c *Cache) WriteMulti(values map[string][]Value) error {
c.init()
var addedSize uint64
for _, v := range values {
addedSize += uint64(Values(v).Size())
}
// Enough room in the cache?
limit := c.maxSize // maxSize is safe for reading without a lock.
n := c.Size() + addedSize
if limit > 0 && n > limit {
... | [
"func",
"(",
"c",
"*",
"Cache",
")",
"WriteMulti",
"(",
"values",
"map",
"[",
"string",
"]",
"[",
"]",
"Value",
")",
"error",
"{",
"c",
".",
"init",
"(",
")",
"\n",
"var",
"addedSize",
"uint64",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"values"... | // WriteMulti writes the map of keys and associated values to the cache. This
// function is goroutine-safe. It returns an error if the cache will exceeded
// its max size by adding the new values. The write attempts to write as many
// values as possible. If one key fails, the others can still succeed and an
// erro... | [
"WriteMulti",
"writes",
"the",
"map",
"of",
"keys",
"and",
"associated",
"values",
"to",
"the",
"cache",
".",
"This",
"function",
"is",
"goroutine",
"-",
"safe",
".",
"It",
"returns",
"an",
"error",
"if",
"the",
"cache",
"will",
"exceeded",
"its",
"max",
... | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/cache.go#L260-L317 |
134,949 | influxdata/platform | tsdb/tsm1/cache.go | Delete | func (c *Cache) Delete(keys [][]byte) {
c.DeleteRange(keys, math.MinInt64, math.MaxInt64)
} | go | func (c *Cache) Delete(keys [][]byte) {
c.DeleteRange(keys, math.MinInt64, math.MaxInt64)
} | [
"func",
"(",
"c",
"*",
"Cache",
")",
"Delete",
"(",
"keys",
"[",
"]",
"[",
"]",
"byte",
")",
"{",
"c",
".",
"DeleteRange",
"(",
"keys",
",",
"math",
".",
"MinInt64",
",",
"math",
".",
"MaxInt64",
")",
"\n",
"}"
] | // Delete removes all values for the given keys from the cache. | [
"Delete",
"removes",
"all",
"values",
"for",
"the",
"given",
"keys",
"from",
"the",
"cache",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/cache.go#L549-L551 |
134,950 | influxdata/platform | tsdb/tsm1/cache.go | NewCacheLoader | func NewCacheLoader(files []string) *CacheLoader {
return &CacheLoader{
files: files,
Logger: zap.NewNop(),
}
} | go | func NewCacheLoader(files []string) *CacheLoader {
return &CacheLoader{
files: files,
Logger: zap.NewNop(),
}
} | [
"func",
"NewCacheLoader",
"(",
"files",
"[",
"]",
"string",
")",
"*",
"CacheLoader",
"{",
"return",
"&",
"CacheLoader",
"{",
"files",
":",
"files",
",",
"Logger",
":",
"zap",
".",
"NewNop",
"(",
")",
",",
"}",
"\n",
"}"
] | // NewCacheLoader returns a new instance of a CacheLoader. | [
"NewCacheLoader",
"returns",
"a",
"new",
"instance",
"of",
"a",
"CacheLoader",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/cache.go#L636-L641 |
134,951 | influxdata/platform | tsdb/tsm1/cache.go | Load | func (cl *CacheLoader) Load(cache *Cache) error {
var r *WALSegmentReader
for _, fn := range cl.files {
if err := func() error {
f, err := os.OpenFile(fn, os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
return err
}
defer f.Close()
// Log some information about the segments.
stat, err := os.Sta... | go | func (cl *CacheLoader) Load(cache *Cache) error {
var r *WALSegmentReader
for _, fn := range cl.files {
if err := func() error {
f, err := os.OpenFile(fn, os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
return err
}
defer f.Close()
// Log some information about the segments.
stat, err := os.Sta... | [
"func",
"(",
"cl",
"*",
"CacheLoader",
")",
"Load",
"(",
"cache",
"*",
"Cache",
")",
"error",
"{",
"var",
"r",
"*",
"WALSegmentReader",
"\n",
"for",
"_",
",",
"fn",
":=",
"range",
"cl",
".",
"files",
"{",
"if",
"err",
":=",
"func",
"(",
")",
"err... | // Load returns a cache loaded with the data contained within the segment files.
// If, during reading of a segment file, corruption is encountered, that segment
// file is truncated up to and including the last valid byte, and processing
// continues with the next segment file. | [
"Load",
"returns",
"a",
"cache",
"loaded",
"with",
"the",
"data",
"contained",
"within",
"the",
"segment",
"files",
".",
"If",
"during",
"reading",
"of",
"a",
"segment",
"file",
"corruption",
"is",
"encountered",
"that",
"segment",
"file",
"is",
"truncated",
... | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/tsm1/cache.go#L647-L706 |
134,952 | influxdata/platform | view.go | UnmarshalViewPropertiesJSON | func UnmarshalViewPropertiesJSON(b []byte) (ViewProperties, error) {
var v struct {
B json.RawMessage `json:"properties"`
}
if err := json.Unmarshal(b, &v); err != nil {
return nil, err
}
if len(v.B) == 0 {
// Then there wasn't any visualization field, so there's no need unmarshal it
return EmptyViewProp... | go | func UnmarshalViewPropertiesJSON(b []byte) (ViewProperties, error) {
var v struct {
B json.RawMessage `json:"properties"`
}
if err := json.Unmarshal(b, &v); err != nil {
return nil, err
}
if len(v.B) == 0 {
// Then there wasn't any visualization field, so there's no need unmarshal it
return EmptyViewProp... | [
"func",
"UnmarshalViewPropertiesJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"ViewProperties",
",",
"error",
")",
"{",
"var",
"v",
"struct",
"{",
"B",
"json",
".",
"RawMessage",
"`json:\"properties\"`",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"json",
".",
... | // UnmarshalViewPropertiesJSON unmarshals JSON bytes into a ViewProperties. | [
"UnmarshalViewPropertiesJSON",
"unmarshals",
"JSON",
"bytes",
"into",
"a",
"ViewProperties",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/view.go#L117-L198 |
134,953 | influxdata/platform | view.go | MarshalViewPropertiesJSON | func MarshalViewPropertiesJSON(v ViewProperties) ([]byte, error) {
var s interface{}
switch vis := v.(type) {
case SingleStatViewProperties:
s = struct {
Shape string `json:"shape"`
SingleStatViewProperties
}{
Shape: "chronograf-v2",
SingleStatViewProperties: vis,
}
case TableVi... | go | func MarshalViewPropertiesJSON(v ViewProperties) ([]byte, error) {
var s interface{}
switch vis := v.(type) {
case SingleStatViewProperties:
s = struct {
Shape string `json:"shape"`
SingleStatViewProperties
}{
Shape: "chronograf-v2",
SingleStatViewProperties: vis,
}
case TableVi... | [
"func",
"MarshalViewPropertiesJSON",
"(",
"v",
"ViewProperties",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"s",
"interface",
"{",
"}",
"\n",
"switch",
"vis",
":=",
"v",
".",
"(",
"type",
")",
"{",
"case",
"SingleStatViewProperties",
":",... | // MarshalViewPropertiesJSON encodes a view into JSON bytes. | [
"MarshalViewPropertiesJSON",
"encodes",
"a",
"view",
"into",
"JSON",
"bytes",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/view.go#L201-L270 |
134,954 | influxdata/platform | http/proto.go | NewProtoBackend | func NewProtoBackend(b *APIBackend) *ProtoBackend {
return &ProtoBackend{
Logger: b.Logger.With(zap.String("handler", "proto")),
ProtoService: b.ProtoService,
LabelService: b.LabelService,
}
} | go | func NewProtoBackend(b *APIBackend) *ProtoBackend {
return &ProtoBackend{
Logger: b.Logger.With(zap.String("handler", "proto")),
ProtoService: b.ProtoService,
LabelService: b.LabelService,
}
} | [
"func",
"NewProtoBackend",
"(",
"b",
"*",
"APIBackend",
")",
"*",
"ProtoBackend",
"{",
"return",
"&",
"ProtoBackend",
"{",
"Logger",
":",
"b",
".",
"Logger",
".",
"With",
"(",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
")",
",",
"... | // NewProtoBackend creates an instance of the Protobackend from the APIBackend. | [
"NewProtoBackend",
"creates",
"an",
"instance",
"of",
"the",
"Protobackend",
"from",
"the",
"APIBackend",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/http/proto.go#L55-L61 |
134,955 | influxdata/platform | http/proto.go | NewProtoHandler | func NewProtoHandler(b *ProtoBackend) *ProtoHandler {
h := &ProtoHandler{
Router: NewRouter(),
Logger: b.Logger,
ProtoService: b.ProtoService,
LabelService: b.LabelService,
}
h.HandlerFunc("GET", protosPath, h.handleGetProtos)
h.HandlerFunc("POST", protosDashboardsPath, h.handlePostProtosDashbo... | go | func NewProtoHandler(b *ProtoBackend) *ProtoHandler {
h := &ProtoHandler{
Router: NewRouter(),
Logger: b.Logger,
ProtoService: b.ProtoService,
LabelService: b.LabelService,
}
h.HandlerFunc("GET", protosPath, h.handleGetProtos)
h.HandlerFunc("POST", protosDashboardsPath, h.handlePostProtosDashbo... | [
"func",
"NewProtoHandler",
"(",
"b",
"*",
"ProtoBackend",
")",
"*",
"ProtoHandler",
"{",
"h",
":=",
"&",
"ProtoHandler",
"{",
"Router",
":",
"NewRouter",
"(",
")",
",",
"Logger",
":",
"b",
".",
"Logger",
",",
"ProtoService",
":",
"b",
".",
"ProtoService"... | // NewProtoHandler creates an instance of a proto handler. | [
"NewProtoHandler",
"creates",
"an",
"instance",
"of",
"a",
"proto",
"handler",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/http/proto.go#L64-L76 |
134,956 | influxdata/platform | http/proto.go | Decode | func (r *createProtoResourcesRequest) Decode(req *http.Request) error {
ctx := req.Context()
id, err := extractProtoID(ctx)
if err != nil {
return err
}
r.ProtoID = id
if err := json.NewDecoder(req.Body).Decode(r); err != nil {
return err
}
return nil
} | go | func (r *createProtoResourcesRequest) Decode(req *http.Request) error {
ctx := req.Context()
id, err := extractProtoID(ctx)
if err != nil {
return err
}
r.ProtoID = id
if err := json.NewDecoder(req.Body).Decode(r); err != nil {
return err
}
return nil
} | [
"func",
"(",
"r",
"*",
"createProtoResourcesRequest",
")",
"Decode",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"ctx",
":=",
"req",
".",
"Context",
"(",
")",
"\n",
"id",
",",
"err",
":=",
"extractProtoID",
"(",
"ctx",
")",
"\n",
"if"... | // Decode turns an http request into a createProtoResourceRequest. | [
"Decode",
"turns",
"an",
"http",
"request",
"into",
"a",
"createProtoResourceRequest",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/http/proto.go#L128-L142 |
134,957 | influxdata/platform | tsdb/errors.go | NewShardError | func NewShardError(id uint64, err error) error {
if err == nil {
return nil
}
return ShardError{id: id, Err: err}
} | go | func NewShardError(id uint64, err error) error {
if err == nil {
return nil
}
return ShardError{id: id, Err: err}
} | [
"func",
"NewShardError",
"(",
"id",
"uint64",
",",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"ShardError",
"{",
"id",
":",
"id",
",",
"Err",
":",
"err",
"}",
"\n",
"}"
] | // NewShardError returns a new ShardError. | [
"NewShardError",
"returns",
"a",
"new",
"ShardError",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/errors.go#L28-L33 |
134,958 | influxdata/platform | http/org_service.go | UpdateOrganization | func (s *OrganizationService) UpdateOrganization(ctx context.Context, id platform.ID, upd platform.OrganizationUpdate) (*platform.Organization, error) {
u, err := newURL(s.Addr, organizationIDPath(id))
if err != nil {
return nil, err
}
octets, err := json.Marshal(upd)
if err != nil {
return nil, err
}
req,... | go | func (s *OrganizationService) UpdateOrganization(ctx context.Context, id platform.ID, upd platform.OrganizationUpdate) (*platform.Organization, error) {
u, err := newURL(s.Addr, organizationIDPath(id))
if err != nil {
return nil, err
}
octets, err := json.Marshal(upd)
if err != nil {
return nil, err
}
req,... | [
"func",
"(",
"s",
"*",
"OrganizationService",
")",
"UpdateOrganization",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"platform",
".",
"ID",
",",
"upd",
"platform",
".",
"OrganizationUpdate",
")",
"(",
"*",
"platform",
".",
"Organization",
",",
"error",... | // UpdateOrganization updates the organization over HTTP. | [
"UpdateOrganization",
"updates",
"the",
"organization",
"over",
"HTTP",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/http/org_service.go#L632-L669 |
134,959 | influxdata/platform | bolt/macro.go | FindMacroByID | func (c *Client) FindMacroByID(ctx context.Context, id platform.ID) (*platform.Macro, error) {
op := getOp(platform.OpFindMacroByID)
var macro *platform.Macro
err := c.db.View(func(tx *bolt.Tx) error {
m, pe := c.findMacroByID(ctx, tx, id)
if pe != nil {
return &platform.Error{
Op: op,
Err: pe,
}
... | go | func (c *Client) FindMacroByID(ctx context.Context, id platform.ID) (*platform.Macro, error) {
op := getOp(platform.OpFindMacroByID)
var macro *platform.Macro
err := c.db.View(func(tx *bolt.Tx) error {
m, pe := c.findMacroByID(ctx, tx, id)
if pe != nil {
return &platform.Error{
Op: op,
Err: pe,
}
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"FindMacroByID",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"platform",
".",
"ID",
")",
"(",
"*",
"platform",
".",
"Macro",
",",
"error",
")",
"{",
"op",
":=",
"getOp",
"(",
"platform",
".",
"OpFindMacroBy... | // FindMacroByID finds a single macro in the store by its ID | [
"FindMacroByID",
"finds",
"a",
"single",
"macro",
"in",
"the",
"store",
"by",
"its",
"ID"
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/bolt/macro.go#L54-L73 |
134,960 | influxdata/platform | bolt/macro.go | CreateMacro | func (c *Client) CreateMacro(ctx context.Context, macro *platform.Macro) error {
op := getOp(platform.OpCreateMacro)
return c.db.Update(func(tx *bolt.Tx) error {
macro.ID = c.IDGenerator.ID()
if pe := c.putMacro(ctx, tx, macro); pe != nil {
return &platform.Error{
Op: op,
Err: pe,
}
}
return n... | go | func (c *Client) CreateMacro(ctx context.Context, macro *platform.Macro) error {
op := getOp(platform.OpCreateMacro)
return c.db.Update(func(tx *bolt.Tx) error {
macro.ID = c.IDGenerator.ID()
if pe := c.putMacro(ctx, tx, macro); pe != nil {
return &platform.Error{
Op: op,
Err: pe,
}
}
return n... | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateMacro",
"(",
"ctx",
"context",
".",
"Context",
",",
"macro",
"*",
"platform",
".",
"Macro",
")",
"error",
"{",
"op",
":=",
"getOp",
"(",
"platform",
".",
"OpCreateMacro",
")",
"\n",
"return",
"c",
".",
"db... | // CreateMacro creates a new macro and assigns it an ID | [
"CreateMacro",
"creates",
"a",
"new",
"macro",
"and",
"assigns",
"it",
"an",
"ID"
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/bolt/macro.go#L104-L117 |
134,961 | influxdata/platform | bolt/macro.go | ReplaceMacro | func (c *Client) ReplaceMacro(ctx context.Context, macro *platform.Macro) error {
op := getOp(platform.OpReplaceMacro)
return c.db.Update(func(tx *bolt.Tx) error {
if pe := c.putMacro(ctx, tx, macro); pe != nil {
return &platform.Error{
Op: op,
Err: pe,
}
}
return nil
})
} | go | func (c *Client) ReplaceMacro(ctx context.Context, macro *platform.Macro) error {
op := getOp(platform.OpReplaceMacro)
return c.db.Update(func(tx *bolt.Tx) error {
if pe := c.putMacro(ctx, tx, macro); pe != nil {
return &platform.Error{
Op: op,
Err: pe,
}
}
return nil
})
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ReplaceMacro",
"(",
"ctx",
"context",
".",
"Context",
",",
"macro",
"*",
"platform",
".",
"Macro",
")",
"error",
"{",
"op",
":=",
"getOp",
"(",
"platform",
".",
"OpReplaceMacro",
")",
"\n",
"return",
"c",
".",
"... | // ReplaceMacro puts a macro in the store | [
"ReplaceMacro",
"puts",
"a",
"macro",
"in",
"the",
"store"
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/bolt/macro.go#L120-L131 |
134,962 | influxdata/platform | bolt/macro.go | UpdateMacro | func (c *Client) UpdateMacro(ctx context.Context, id platform.ID, update *platform.MacroUpdate) (*platform.Macro, error) {
op := getOp(platform.OpUpdateMacro)
var macro *platform.Macro
err := c.db.Update(func(tx *bolt.Tx) error {
m, pe := c.findMacroByID(ctx, tx, id)
if pe != nil {
return &platform.Error{
... | go | func (c *Client) UpdateMacro(ctx context.Context, id platform.ID, update *platform.MacroUpdate) (*platform.Macro, error) {
op := getOp(platform.OpUpdateMacro)
var macro *platform.Macro
err := c.db.Update(func(tx *bolt.Tx) error {
m, pe := c.findMacroByID(ctx, tx, id)
if pe != nil {
return &platform.Error{
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateMacro",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"platform",
".",
"ID",
",",
"update",
"*",
"platform",
".",
"MacroUpdate",
")",
"(",
"*",
"platform",
".",
"Macro",
",",
"error",
")",
"{",
"op",
... | // UpdateMacro updates a single macro in the store with a changeset | [
"UpdateMacro",
"updates",
"a",
"single",
"macro",
"in",
"the",
"store",
"with",
"a",
"changeset"
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/bolt/macro.go#L159-L189 |
134,963 | influxdata/platform | bolt/macro.go | DeleteMacro | func (c *Client) DeleteMacro(ctx context.Context, id platform.ID) error {
op := getOp(platform.OpDeleteMacro)
return c.db.Update(func(tx *bolt.Tx) error {
b := tx.Bucket(macroBucket)
encID, err := id.Encode()
if err != nil {
return &platform.Error{
Code: platform.EInvalid,
Op: op,
Err: err,
... | go | func (c *Client) DeleteMacro(ctx context.Context, id platform.ID) error {
op := getOp(platform.OpDeleteMacro)
return c.db.Update(func(tx *bolt.Tx) error {
b := tx.Bucket(macroBucket)
encID, err := id.Encode()
if err != nil {
return &platform.Error{
Code: platform.EInvalid,
Op: op,
Err: err,
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteMacro",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"platform",
".",
"ID",
")",
"error",
"{",
"op",
":=",
"getOp",
"(",
"platform",
".",
"OpDeleteMacro",
")",
"\n",
"return",
"c",
".",
"db",
".",
"... | // DeleteMacro removes a single macro from the store by its ID | [
"DeleteMacro",
"removes",
"a",
"single",
"macro",
"from",
"the",
"store",
"by",
"its",
"ID"
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/bolt/macro.go#L192-L224 |
134,964 | influxdata/platform | models/points.go | ParsePoints | func ParsePoints(buf []byte) ([]Point, error) {
return ParsePointsWithPrecision(buf, time.Now().UTC(), "n")
} | go | func ParsePoints(buf []byte) ([]Point, error) {
return ParsePointsWithPrecision(buf, time.Now().UTC(), "n")
} | [
"func",
"ParsePoints",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"Point",
",",
"error",
")",
"{",
"return",
"ParsePointsWithPrecision",
"(",
"buf",
",",
"time",
".",
"Now",
"(",
")",
".",
"UTC",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // ParsePoints returns a slice of Points from a text representation of a point
// with each point separated by newlines. If any points fail to parse, a non-nil error
// will be returned in addition to the points that parsed successfully. | [
"ParsePoints",
"returns",
"a",
"slice",
"of",
"Points",
"from",
"a",
"text",
"representation",
"of",
"a",
"point",
"with",
"each",
"point",
"separated",
"by",
"newlines",
".",
"If",
"any",
"points",
"fail",
"to",
"parse",
"a",
"non",
"-",
"nil",
"error",
... | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/models/points.go#L279-L281 |
134,965 | influxdata/platform | models/points.go | ValidKeyToken | func ValidKeyToken(s string) bool {
if !utf8.ValidString(s) {
return false
}
for _, r := range s {
if !unicode.IsPrint(r) || r == unicode.ReplacementChar {
return false
}
}
return true
} | go | func ValidKeyToken(s string) bool {
if !utf8.ValidString(s) {
return false
}
for _, r := range s {
if !unicode.IsPrint(r) || r == unicode.ReplacementChar {
return false
}
}
return true
} | [
"func",
"ValidKeyToken",
"(",
"s",
"string",
")",
"bool",
"{",
"if",
"!",
"utf8",
".",
"ValidString",
"(",
"s",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"s",
"{",
"if",
"!",
"unicode",
".",
"IsPrint",
"("... | // ValidKeyToken returns true if the token used for measurement, tag key, or tag
// value is a valid unicode string and only contains printable, non-replacement characters. | [
"ValidKeyToken",
"returns",
"true",
"if",
"the",
"token",
"used",
"for",
"measurement",
"tag",
"key",
"or",
"tag",
"value",
"is",
"a",
"valid",
"unicode",
"string",
"and",
"only",
"contains",
"printable",
"non",
"-",
"replacement",
"characters",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/models/points.go#L2458-L2468 |
134,966 | influxdata/platform | models/points.go | ValidKeyTokens | func ValidKeyTokens(name string, tags Tags) bool {
if !ValidKeyToken(name) {
return false
}
for _, tag := range tags {
if !ValidKeyToken(string(tag.Key)) || !ValidKeyToken(string(tag.Value)) {
return false
}
}
return true
} | go | func ValidKeyTokens(name string, tags Tags) bool {
if !ValidKeyToken(name) {
return false
}
for _, tag := range tags {
if !ValidKeyToken(string(tag.Key)) || !ValidKeyToken(string(tag.Value)) {
return false
}
}
return true
} | [
"func",
"ValidKeyTokens",
"(",
"name",
"string",
",",
"tags",
"Tags",
")",
"bool",
"{",
"if",
"!",
"ValidKeyToken",
"(",
"name",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"_",
",",
"tag",
":=",
"range",
"tags",
"{",
"if",
"!",
"ValidKeyTok... | // ValidKeyTokens returns true if the measurement name and all tags are valid. | [
"ValidKeyTokens",
"returns",
"true",
"if",
"the",
"measurement",
"name",
"and",
"all",
"tags",
"are",
"valid",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/models/points.go#L2471-L2481 |
134,967 | influxdata/platform | label.go | Validate | func (l *Label) Validate() error {
if !l.ResourceID.Valid() {
return &Error{
Code: EInvalid,
Msg: "resourceID is required",
}
}
if l.Name == "" {
return &Error{
Code: EInvalid,
Msg: "label name is required",
}
}
return nil
} | go | func (l *Label) Validate() error {
if !l.ResourceID.Valid() {
return &Error{
Code: EInvalid,
Msg: "resourceID is required",
}
}
if l.Name == "" {
return &Error{
Code: EInvalid,
Msg: "label name is required",
}
}
return nil
} | [
"func",
"(",
"l",
"*",
"Label",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"!",
"l",
".",
"ResourceID",
".",
"Valid",
"(",
")",
"{",
"return",
"&",
"Error",
"{",
"Code",
":",
"EInvalid",
",",
"Msg",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"... | // Validate returns an error if the label is invalid. | [
"Validate",
"returns",
"an",
"error",
"if",
"the",
"label",
"is",
"invalid",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/label.go#L38-L54 |
134,968 | influxdata/platform | http/auth_service.go | SetAuthorizationStatus | func (s *AuthorizationService) SetAuthorizationStatus(ctx context.Context, id platform.ID, status platform.Status) error {
u, err := newURL(s.Addr, authorizationIDPath(id))
if err != nil {
return err
}
b, err := json.Marshal(setAuthorizationStatusRequest{
Status: status,
})
if err != nil {
return err
}
... | go | func (s *AuthorizationService) SetAuthorizationStatus(ctx context.Context, id platform.ID, status platform.Status) error {
u, err := newURL(s.Addr, authorizationIDPath(id))
if err != nil {
return err
}
b, err := json.Marshal(setAuthorizationStatusRequest{
Status: status,
})
if err != nil {
return err
}
... | [
"func",
"(",
"s",
"*",
"AuthorizationService",
")",
"SetAuthorizationStatus",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"platform",
".",
"ID",
",",
"status",
"platform",
".",
"Status",
")",
"error",
"{",
"u",
",",
"err",
":=",
"newURL",
"(",
"s",... | // SetAuthorizationStatus updates an authorization's status. | [
"SetAuthorizationStatus",
"updates",
"an",
"authorization",
"s",
"status",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/http/auth_service.go#L695-L728 |
134,969 | influxdata/platform | inmem/macro.go | FindMacroByID | func (s *Service) FindMacroByID(ctx context.Context, id platform.ID) (*platform.Macro, error) {
op := OpPrefix + platform.OpFindMacroByID
i, ok := s.macroKV.Load(id.String())
if !ok {
return nil, &platform.Error{
Op: op,
Code: platform.ENotFound,
Msg: "macro not found",
}
}
macro, ok := i.(*platfo... | go | func (s *Service) FindMacroByID(ctx context.Context, id platform.ID) (*platform.Macro, error) {
op := OpPrefix + platform.OpFindMacroByID
i, ok := s.macroKV.Load(id.String())
if !ok {
return nil, &platform.Error{
Op: op,
Code: platform.ENotFound,
Msg: "macro not found",
}
}
macro, ok := i.(*platfo... | [
"func",
"(",
"s",
"*",
"Service",
")",
"FindMacroByID",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"platform",
".",
"ID",
")",
"(",
"*",
"platform",
".",
"Macro",
",",
"error",
")",
"{",
"op",
":=",
"OpPrefix",
"+",
"platform",
".",
"OpFindMac... | // FindMacroByID implements the platform.MacroService interface | [
"FindMacroByID",
"implements",
"the",
"platform",
".",
"MacroService",
"interface"
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/inmem/macro.go#L11-L31 |
134,970 | influxdata/platform | inmem/macro.go | FindMacros | func (s *Service) FindMacros(ctx context.Context) ([]*platform.Macro, error) {
op := OpPrefix + platform.OpFindMacros
var err error
var macros []*platform.Macro
s.macroKV.Range(func(k, v interface{}) bool {
macro, ok := v.(*platform.Macro)
if !ok {
err = &platform.Error{
Op: op,
Msg: fmt.Sprintf("ty... | go | func (s *Service) FindMacros(ctx context.Context) ([]*platform.Macro, error) {
op := OpPrefix + platform.OpFindMacros
var err error
var macros []*platform.Macro
s.macroKV.Range(func(k, v interface{}) bool {
macro, ok := v.(*platform.Macro)
if !ok {
err = &platform.Error{
Op: op,
Msg: fmt.Sprintf("ty... | [
"func",
"(",
"s",
"*",
"Service",
")",
"FindMacros",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"*",
"platform",
".",
"Macro",
",",
"error",
")",
"{",
"op",
":=",
"OpPrefix",
"+",
"platform",
".",
"OpFindMacros",
"\n",
"var",
"err",
... | // FindMacros implements the platform.MacroService interface | [
"FindMacros",
"implements",
"the",
"platform",
".",
"MacroService",
"interface"
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/inmem/macro.go#L34-L57 |
134,971 | influxdata/platform | inmem/macro.go | CreateMacro | func (s *Service) CreateMacro(ctx context.Context, m *platform.Macro) error {
op := OpPrefix + platform.OpCreateMacro
m.ID = s.IDGenerator.ID()
err := s.ReplaceMacro(ctx, m)
if err != nil {
return &platform.Error{
Op: op,
Err: err,
}
}
return nil
} | go | func (s *Service) CreateMacro(ctx context.Context, m *platform.Macro) error {
op := OpPrefix + platform.OpCreateMacro
m.ID = s.IDGenerator.ID()
err := s.ReplaceMacro(ctx, m)
if err != nil {
return &platform.Error{
Op: op,
Err: err,
}
}
return nil
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"CreateMacro",
"(",
"ctx",
"context",
".",
"Context",
",",
"m",
"*",
"platform",
".",
"Macro",
")",
"error",
"{",
"op",
":=",
"OpPrefix",
"+",
"platform",
".",
"OpCreateMacro",
"\n",
"m",
".",
"ID",
"=",
"s",
... | // CreateMacro implements the platform.MacroService interface | [
"CreateMacro",
"implements",
"the",
"platform",
".",
"MacroService",
"interface"
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/inmem/macro.go#L60-L71 |
134,972 | influxdata/platform | inmem/macro.go | UpdateMacro | func (s *Service) UpdateMacro(ctx context.Context, id platform.ID, update *platform.MacroUpdate) (*platform.Macro, error) {
op := OpPrefix + platform.OpUpdateMacro
macro, err := s.FindMacroByID(ctx, id)
if err != nil {
return nil, &platform.Error{
Op: op,
Code: platform.ENotFound,
Msg: "macro not found... | go | func (s *Service) UpdateMacro(ctx context.Context, id platform.ID, update *platform.MacroUpdate) (*platform.Macro, error) {
op := OpPrefix + platform.OpUpdateMacro
macro, err := s.FindMacroByID(ctx, id)
if err != nil {
return nil, &platform.Error{
Op: op,
Code: platform.ENotFound,
Msg: "macro not found... | [
"func",
"(",
"s",
"*",
"Service",
")",
"UpdateMacro",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"platform",
".",
"ID",
",",
"update",
"*",
"platform",
".",
"MacroUpdate",
")",
"(",
"*",
"platform",
".",
"Macro",
",",
"error",
")",
"{",
"op",
... | // UpdateMacro implements the platform.MacroService interface | [
"UpdateMacro",
"implements",
"the",
"platform",
".",
"MacroService",
"interface"
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/inmem/macro.go#L74-L101 |
134,973 | influxdata/platform | inmem/macro.go | DeleteMacro | func (s *Service) DeleteMacro(ctx context.Context, id platform.ID) error {
op := OpPrefix + platform.OpDeleteMacro
_, err := s.FindMacroByID(ctx, id)
if err != nil {
return &platform.Error{
Op: op,
Code: platform.ENotFound,
Msg: "macro not found",
Err: err,
}
}
s.macroKV.Delete(id.String())
... | go | func (s *Service) DeleteMacro(ctx context.Context, id platform.ID) error {
op := OpPrefix + platform.OpDeleteMacro
_, err := s.FindMacroByID(ctx, id)
if err != nil {
return &platform.Error{
Op: op,
Code: platform.ENotFound,
Msg: "macro not found",
Err: err,
}
}
s.macroKV.Delete(id.String())
... | [
"func",
"(",
"s",
"*",
"Service",
")",
"DeleteMacro",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"platform",
".",
"ID",
")",
"error",
"{",
"op",
":=",
"OpPrefix",
"+",
"platform",
".",
"OpDeleteMacro",
"\n",
"_",
",",
"err",
":=",
"s",
".",
... | // DeleteMacro implements the platform.MacroService interface | [
"DeleteMacro",
"implements",
"the",
"platform",
".",
"MacroService",
"interface"
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/inmem/macro.go#L104-L119 |
134,974 | influxdata/platform | inmem/macro.go | ReplaceMacro | func (s *Service) ReplaceMacro(ctx context.Context, m *platform.Macro) error {
s.macroKV.Store(m.ID.String(), m)
return nil
} | go | func (s *Service) ReplaceMacro(ctx context.Context, m *platform.Macro) error {
s.macroKV.Store(m.ID.String(), m)
return nil
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"ReplaceMacro",
"(",
"ctx",
"context",
".",
"Context",
",",
"m",
"*",
"platform",
".",
"Macro",
")",
"error",
"{",
"s",
".",
"macroKV",
".",
"Store",
"(",
"m",
".",
"ID",
".",
"String",
"(",
")",
",",
"m",
... | // ReplaceMacro stores a Macro in the key value store | [
"ReplaceMacro",
"stores",
"a",
"Macro",
"in",
"the",
"key",
"value",
"store"
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/inmem/macro.go#L122-L125 |
134,975 | influxdata/platform | task/backend/meta.go | NewStoreTaskMeta | func NewStoreTaskMeta(req CreateTaskRequest, o options.Options) StoreTaskMeta {
stm := StoreTaskMeta{
MaxConcurrency: int32(o.Concurrency),
Status: string(req.Status),
LatestCompleted: req.ScheduleAfter,
EffectiveCron: o.EffectiveCronString(),
Offset: int32(o.Offset / time.Second),
}
... | go | func NewStoreTaskMeta(req CreateTaskRequest, o options.Options) StoreTaskMeta {
stm := StoreTaskMeta{
MaxConcurrency: int32(o.Concurrency),
Status: string(req.Status),
LatestCompleted: req.ScheduleAfter,
EffectiveCron: o.EffectiveCronString(),
Offset: int32(o.Offset / time.Second),
}
... | [
"func",
"NewStoreTaskMeta",
"(",
"req",
"CreateTaskRequest",
",",
"o",
"options",
".",
"Options",
")",
"StoreTaskMeta",
"{",
"stm",
":=",
"StoreTaskMeta",
"{",
"MaxConcurrency",
":",
"int32",
"(",
"o",
".",
"Concurrency",
")",
",",
"Status",
":",
"string",
"... | // This file contains helper methods for the StoreTaskMeta type defined in protobuf.
// NewStoreTaskMeta returns a new StoreTaskMeta based on the given request and parsed options. | [
"This",
"file",
"contains",
"helper",
"methods",
"for",
"the",
"StoreTaskMeta",
"type",
"defined",
"in",
"protobuf",
".",
"NewStoreTaskMeta",
"returns",
"a",
"new",
"StoreTaskMeta",
"based",
"on",
"the",
"given",
"request",
"and",
"parsed",
"options",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/task/backend/meta.go#L16-L41 |
134,976 | influxdata/platform | inmem/view.go | FindViews | func (s *Service) FindViews(ctx context.Context, filter platform.ViewFilter) ([]*platform.View, int, error) {
var ds []*platform.View
if filter.ID != nil {
d, err := s.FindViewByID(ctx, *filter.ID)
if err != nil && platform.ErrorCode(err) != platform.ENotFound {
return nil, 0, &platform.Error{
Err: err,
... | go | func (s *Service) FindViews(ctx context.Context, filter platform.ViewFilter) ([]*platform.View, int, error) {
var ds []*platform.View
if filter.ID != nil {
d, err := s.FindViewByID(ctx, *filter.ID)
if err != nil && platform.ErrorCode(err) != platform.ENotFound {
return nil, 0, &platform.Error{
Err: err,
... | [
"func",
"(",
"s",
"*",
"Service",
")",
"FindViews",
"(",
"ctx",
"context",
".",
"Context",
",",
"filter",
"platform",
".",
"ViewFilter",
")",
"(",
"[",
"]",
"*",
"platform",
".",
"View",
",",
"int",
",",
"error",
")",
"{",
"var",
"ds",
"[",
"]",
... | // FindViews implements platform.ViewService interface. | [
"FindViews",
"implements",
"platform",
".",
"ViewService",
"interface",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/inmem/view.go#L52-L83 |
134,977 | influxdata/platform | inmem/view.go | CreateView | func (s *Service) CreateView(ctx context.Context, c *platform.View) error {
c.ID = s.IDGenerator.ID()
if err := s.PutView(ctx, c); err != nil {
return &platform.Error{
Err: err,
Op: OpPrefix + platform.OpCreateView,
}
}
return nil
} | go | func (s *Service) CreateView(ctx context.Context, c *platform.View) error {
c.ID = s.IDGenerator.ID()
if err := s.PutView(ctx, c); err != nil {
return &platform.Error{
Err: err,
Op: OpPrefix + platform.OpCreateView,
}
}
return nil
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"CreateView",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"platform",
".",
"View",
")",
"error",
"{",
"c",
".",
"ID",
"=",
"s",
".",
"IDGenerator",
".",
"ID",
"(",
")",
"\n",
"if",
"err",
":=",
"... | // CreateView implements platform.ViewService interface. | [
"CreateView",
"implements",
"platform",
".",
"ViewService",
"interface",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/inmem/view.go#L86-L95 |
134,978 | influxdata/platform | inmem/view.go | UpdateView | func (s *Service) UpdateView(ctx context.Context, id platform.ID, upd platform.ViewUpdate) (*platform.View, error) {
c, err := s.FindViewByID(ctx, id)
if err != nil {
return nil, &platform.Error{
Err: err,
Op: OpPrefix + platform.OpUpdateView,
}
}
if upd.Name != nil {
c.Name = *upd.Name
}
if upd.Pr... | go | func (s *Service) UpdateView(ctx context.Context, id platform.ID, upd platform.ViewUpdate) (*platform.View, error) {
c, err := s.FindViewByID(ctx, id)
if err != nil {
return nil, &platform.Error{
Err: err,
Op: OpPrefix + platform.OpUpdateView,
}
}
if upd.Name != nil {
c.Name = *upd.Name
}
if upd.Pr... | [
"func",
"(",
"s",
"*",
"Service",
")",
"UpdateView",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"platform",
".",
"ID",
",",
"upd",
"platform",
".",
"ViewUpdate",
")",
"(",
"*",
"platform",
".",
"View",
",",
"error",
")",
"{",
"c",
",",
"err"... | // UpdateView implements platform.ViewService interface. | [
"UpdateView",
"implements",
"platform",
".",
"ViewService",
"interface",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/inmem/view.go#L107-L127 |
134,979 | influxdata/platform | inmem/view.go | DeleteView | func (s *Service) DeleteView(ctx context.Context, id platform.ID) error {
if _, err := s.FindViewByID(ctx, id); err != nil {
return &platform.Error{
Err: err,
Op: OpPrefix + platform.OpDeleteView,
}
}
s.viewKV.Delete(id.String())
return nil
} | go | func (s *Service) DeleteView(ctx context.Context, id platform.ID) error {
if _, err := s.FindViewByID(ctx, id); err != nil {
return &platform.Error{
Err: err,
Op: OpPrefix + platform.OpDeleteView,
}
}
s.viewKV.Delete(id.String())
return nil
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"DeleteView",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"platform",
".",
"ID",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"s",
".",
"FindViewByID",
"(",
"ctx",
",",
"id",
")",
";",
"err",
"!=",
... | // DeleteView implements platform.ViewService interface. | [
"DeleteView",
"implements",
"platform",
".",
"ViewService",
"interface",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/inmem/view.go#L130-L139 |
134,980 | influxdata/platform | bolt/kv.go | Open | func (s *KVStore) Open(ctx context.Context) error {
// Ensure the required directory structure exists.
if err := os.MkdirAll(filepath.Dir(s.path), 0700); err != nil {
return fmt.Errorf("unable to create directory %s: %v", s.path, err)
}
if _, err := os.Stat(s.path); err != nil && !os.IsNotExist(err) {
return e... | go | func (s *KVStore) Open(ctx context.Context) error {
// Ensure the required directory structure exists.
if err := os.MkdirAll(filepath.Dir(s.path), 0700); err != nil {
return fmt.Errorf("unable to create directory %s: %v", s.path, err)
}
if _, err := os.Stat(s.path); err != nil && !os.IsNotExist(err) {
return e... | [
"func",
"(",
"s",
"*",
"KVStore",
")",
"Open",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"// Ensure the required directory structure exists.",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"filepath",
".",
"Dir",
"(",
"s",
".",
"path",
")"... | // Open creates boltDB file it doesn't exists and opens it otherwise. | [
"Open",
"creates",
"boltDB",
"file",
"it",
"doesn",
"t",
"exists",
"and",
"opens",
"it",
"otherwise",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/bolt/kv.go#L32-L51 |
134,981 | influxdata/platform | bolt/kv.go | Seek | func (c *Cursor) Seek(prefix []byte) ([]byte, []byte) {
k, v := c.cursor.Seek(prefix)
if len(v) == 0 {
return nil, nil
}
return k, v
} | go | func (c *Cursor) Seek(prefix []byte) ([]byte, []byte) {
k, v := c.cursor.Seek(prefix)
if len(v) == 0 {
return nil, nil
}
return k, v
} | [
"func",
"(",
"c",
"*",
"Cursor",
")",
"Seek",
"(",
"prefix",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"[",
"]",
"byte",
")",
"{",
"k",
",",
"v",
":=",
"c",
".",
"cursor",
".",
"Seek",
"(",
"prefix",
")",
"\n",
"if",
"len",
"(",
... | // Seek seeks for the first key that matches the prefix provided. | [
"Seek",
"seeks",
"for",
"the",
"first",
"key",
"that",
"matches",
"the",
"prefix",
"provided",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/bolt/kv.go#L177-L183 |
134,982 | influxdata/platform | mock/proxy_query_service.go | NewProxyQueryService | func NewProxyQueryService() *ProxyQueryService {
return &ProxyQueryService{
QueryFn: func(context.Context, io.Writer, *query.ProxyRequest) (int64, error) { return 0, nil },
}
} | go | func NewProxyQueryService() *ProxyQueryService {
return &ProxyQueryService{
QueryFn: func(context.Context, io.Writer, *query.ProxyRequest) (int64, error) { return 0, nil },
}
} | [
"func",
"NewProxyQueryService",
"(",
")",
"*",
"ProxyQueryService",
"{",
"return",
"&",
"ProxyQueryService",
"{",
"QueryFn",
":",
"func",
"(",
"context",
".",
"Context",
",",
"io",
".",
"Writer",
",",
"*",
"query",
".",
"ProxyRequest",
")",
"(",
"int64",
"... | // NewProxyQueryService returns a mock of ProxyQueryService where its methods will return zero values. | [
"NewProxyQueryService",
"returns",
"a",
"mock",
"of",
"ProxyQueryService",
"where",
"its",
"methods",
"will",
"return",
"zero",
"values",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/mock/proxy_query_service.go#L18-L22 |
134,983 | influxdata/platform | mock/proxy_query_service.go | Query | func (s *ProxyQueryService) Query(ctx context.Context, w io.Writer, req *query.ProxyRequest) (int64, error) {
return s.QueryFn(ctx, w, req)
} | go | func (s *ProxyQueryService) Query(ctx context.Context, w io.Writer, req *query.ProxyRequest) (int64, error) {
return s.QueryFn(ctx, w, req)
} | [
"func",
"(",
"s",
"*",
"ProxyQueryService",
")",
"Query",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"io",
".",
"Writer",
",",
"req",
"*",
"query",
".",
"ProxyRequest",
")",
"(",
"int64",
",",
"error",
")",
"{",
"return",
"s",
".",
"QueryFn",
... | // Query performs the requested query and encodes the results into w. | [
"Query",
"performs",
"the",
"requested",
"query",
"and",
"encodes",
"the",
"results",
"into",
"w",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/mock/proxy_query_service.go#L25-L27 |
134,984 | influxdata/platform | tsdb/index.go | NewSeriesIteratorAdapter | func NewSeriesIteratorAdapter(sfile *SeriesFile, itr SeriesIDIterator) SeriesIterator {
return &seriesIteratorAdapter{
sfile: sfile,
itr: itr,
}
} | go | func NewSeriesIteratorAdapter(sfile *SeriesFile, itr SeriesIDIterator) SeriesIterator {
return &seriesIteratorAdapter{
sfile: sfile,
itr: itr,
}
} | [
"func",
"NewSeriesIteratorAdapter",
"(",
"sfile",
"*",
"SeriesFile",
",",
"itr",
"SeriesIDIterator",
")",
"SeriesIterator",
"{",
"return",
"&",
"seriesIteratorAdapter",
"{",
"sfile",
":",
"sfile",
",",
"itr",
":",
"itr",
",",
"}",
"\n",
"}"
] | // NewSeriesIteratorAdapter returns an adapter for converting series ids to series. | [
"NewSeriesIteratorAdapter",
"returns",
"an",
"adapter",
"for",
"converting",
"series",
"ids",
"to",
"series",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/index.go#L30-L35 |
134,985 | influxdata/platform | tsdb/index.go | NewSeriesQueryAdapterIterator | func NewSeriesQueryAdapterIterator(sfile *SeriesFile, itr SeriesIDIterator, opt query.IteratorOptions) query.Iterator {
return &seriesQueryAdapterIterator{
sfile: sfile,
itr: itr,
point: query.FloatPoint{
Aux: make([]interface{}, len(opt.Aux)),
},
opt: opt,
}
} | go | func NewSeriesQueryAdapterIterator(sfile *SeriesFile, itr SeriesIDIterator, opt query.IteratorOptions) query.Iterator {
return &seriesQueryAdapterIterator{
sfile: sfile,
itr: itr,
point: query.FloatPoint{
Aux: make([]interface{}, len(opt.Aux)),
},
opt: opt,
}
} | [
"func",
"NewSeriesQueryAdapterIterator",
"(",
"sfile",
"*",
"SeriesFile",
",",
"itr",
"SeriesIDIterator",
",",
"opt",
"query",
".",
"IteratorOptions",
")",
"query",
".",
"Iterator",
"{",
"return",
"&",
"seriesQueryAdapterIterator",
"{",
"sfile",
":",
"sfile",
",",... | // NewSeriesQueryAdapterIterator returns a new instance of SeriesQueryAdapterIterator. | [
"NewSeriesQueryAdapterIterator",
"returns",
"a",
"new",
"instance",
"of",
"SeriesQueryAdapterIterator",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/tsdb/index.go#L221-L230 |
134,986 | influxdata/platform | task/backend/store.go | CreateArgs | func (StoreValidation) CreateArgs(req CreateTaskRequest) (options.Options, error) {
var missing []string
var o options.Options
if req.Script == "" {
missing = append(missing, "script")
} else {
var err error
o, err = options.FromScript(req.Script)
if err != nil {
return o, err
}
}
if !req.Org.Valid... | go | func (StoreValidation) CreateArgs(req CreateTaskRequest) (options.Options, error) {
var missing []string
var o options.Options
if req.Script == "" {
missing = append(missing, "script")
} else {
var err error
o, err = options.FromScript(req.Script)
if err != nil {
return o, err
}
}
if !req.Org.Valid... | [
"func",
"(",
"StoreValidation",
")",
"CreateArgs",
"(",
"req",
"CreateTaskRequest",
")",
"(",
"options",
".",
"Options",
",",
"error",
")",
"{",
"var",
"missing",
"[",
"]",
"string",
"\n",
"var",
"o",
"options",
".",
"Options",
"\n\n",
"if",
"req",
".",
... | // CreateArgs returns the script's parsed options,
// and an error if any of the provided fields are invalid for creating a task. | [
"CreateArgs",
"returns",
"the",
"script",
"s",
"parsed",
"options",
"and",
"an",
"error",
"if",
"any",
"of",
"the",
"provided",
"fields",
"are",
"invalid",
"for",
"creating",
"a",
"task",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/task/backend/store.go#L352-L382 |
134,987 | influxdata/platform | gather/handler.go | Process | func (h *handler) Process(s nats.Subscription, m nats.Message) {
defer m.Ack()
req := new(platform.ScraperTarget)
err := json.Unmarshal(m.Data(), req)
if err != nil {
h.Logger.Error("unable to unmarshal json", zap.Error(err))
return
}
ms, err := h.Scraper.Gather(context.TODO(), *req)
if err != nil {
h.Lo... | go | func (h *handler) Process(s nats.Subscription, m nats.Message) {
defer m.Ack()
req := new(platform.ScraperTarget)
err := json.Unmarshal(m.Data(), req)
if err != nil {
h.Logger.Error("unable to unmarshal json", zap.Error(err))
return
}
ms, err := h.Scraper.Gather(context.TODO(), *req)
if err != nil {
h.Lo... | [
"func",
"(",
"h",
"*",
"handler",
")",
"Process",
"(",
"s",
"nats",
".",
"Subscription",
",",
"m",
"nats",
".",
"Message",
")",
"{",
"defer",
"m",
".",
"Ack",
"(",
")",
"\n\n",
"req",
":=",
"new",
"(",
"platform",
".",
"ScraperTarget",
")",
"\n",
... | // Process consumes scraper target from scraper target queue,
// call the scraper to gather, and publish to metrics queue. | [
"Process",
"consumes",
"scraper",
"target",
"from",
"scraper",
"target",
"queue",
"call",
"the",
"scraper",
"to",
"gather",
"and",
"publish",
"to",
"metrics",
"queue",
"."
] | d500d3cf55899337bc03259b46c58bae9c06f1eb | https://github.com/influxdata/platform/blob/d500d3cf55899337bc03259b46c58bae9c06f1eb/gather/handler.go#L22-L50 |
134,988 | 0xrawsec/golang-utils | net/sftp/sftp.go | PrivateKeyAuthMethod | func PrivateKeyAuthMethod(privateKeyPath string) ssh.AuthMethod {
sss, err := loadPrivateKey(privateKeyPath)
if err != nil {
panic(err)
}
return ssh.PublicKeys(sss)
} | go | func PrivateKeyAuthMethod(privateKeyPath string) ssh.AuthMethod {
sss, err := loadPrivateKey(privateKeyPath)
if err != nil {
panic(err)
}
return ssh.PublicKeys(sss)
} | [
"func",
"PrivateKeyAuthMethod",
"(",
"privateKeyPath",
"string",
")",
"ssh",
".",
"AuthMethod",
"{",
"sss",
",",
"err",
":=",
"loadPrivateKey",
"(",
"privateKeyPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"r... | // PrivateKeyAuthMethod returns a ssh.AuthMethod initialized with a private key
// @privateKeyPath: path to the private key to use | [
"PrivateKeyAuthMethod",
"returns",
"a",
"ssh",
".",
"AuthMethod",
"initialized",
"with",
"a",
"private",
"key"
] | 817f34752728629396193de0249e187c6ab1c5cb | https://github.com/0xrawsec/golang-utils/blob/817f34752728629396193de0249e187c6ab1c5cb/net/sftp/sftp.go#L45-L52 |
134,989 | 0xrawsec/golang-utils | net/sftp/sftp.go | New | func New(host, port, username string, sams ...ssh.AuthMethod) (*Client, error) {
config := &ssh.ClientConfig{
User: username,
Auth: sams,
}
client, err := ssh.Dial("tcp", BuildSSHURL(host, port), config)
if err != nil {
return nil, err
}
tmpSftpClient, err := sftp.NewClient(client)
if err != nil {
return... | go | func New(host, port, username string, sams ...ssh.AuthMethod) (*Client, error) {
config := &ssh.ClientConfig{
User: username,
Auth: sams,
}
client, err := ssh.Dial("tcp", BuildSSHURL(host, port), config)
if err != nil {
return nil, err
}
tmpSftpClient, err := sftp.NewClient(client)
if err != nil {
return... | [
"func",
"New",
"(",
"host",
",",
"port",
",",
"username",
"string",
",",
"sams",
"...",
"ssh",
".",
"AuthMethod",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"config",
":=",
"&",
"ssh",
".",
"ClientConfig",
"{",
"User",
":",
"username",
",",
"... | // New returns a new SFTP Client
// @host: hostname to connect to
// @port: port on the hostname
// @username: username to login
// @sams: list of ssh.AuthMethod to use | [
"New",
"returns",
"a",
"new",
"SFTP",
"Client"
] | 817f34752728629396193de0249e187c6ab1c5cb | https://github.com/0xrawsec/golang-utils/blob/817f34752728629396193de0249e187c6ab1c5cb/net/sftp/sftp.go#L59-L73 |
134,990 | 0xrawsec/golang-utils | net/sftp/sftp.go | ResolveSymlink | func (sc *Client) ResolveSymlink(path string) string {
pointer, err := sc.ReadLink(path)
if err != nil {
return path
}
return pointer
} | go | func (sc *Client) ResolveSymlink(path string) string {
pointer, err := sc.ReadLink(path)
if err != nil {
return path
}
return pointer
} | [
"func",
"(",
"sc",
"*",
"Client",
")",
"ResolveSymlink",
"(",
"path",
"string",
")",
"string",
"{",
"pointer",
",",
"err",
":=",
"sc",
".",
"ReadLink",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"path",
"\n",
"}",
"\n",
"retur... | // ResolveSymlink resolve a path and returns the path of the file pointed if
// it is a symlink
// @path: path to resolve | [
"ResolveSymlink",
"resolve",
"a",
"path",
"and",
"returns",
"the",
"path",
"of",
"the",
"file",
"pointed",
"if",
"it",
"is",
"a",
"symlink"
] | 817f34752728629396193de0249e187c6ab1c5cb | https://github.com/0xrawsec/golang-utils/blob/817f34752728629396193de0249e187c6ab1c5cb/net/sftp/sftp.go#L78-L84 |
134,991 | 0xrawsec/golang-utils | net/sftp/sftp.go | Walk | func (sc *Client) Walk(root string) <-chan fswalker.WalkItem {
iterChannel := make(chan fswalker.WalkItem)
dirsToProcess := []string{root}
go func() {
for len(dirsToProcess) > 0 {
dirs, files := []os.FileInfo{}, []os.FileInfo{}
dirpath := dirsToProcess[len(dirsToProcess)-1]
dirsToProcess = dirsToProcess[:... | go | func (sc *Client) Walk(root string) <-chan fswalker.WalkItem {
iterChannel := make(chan fswalker.WalkItem)
dirsToProcess := []string{root}
go func() {
for len(dirsToProcess) > 0 {
dirs, files := []os.FileInfo{}, []os.FileInfo{}
dirpath := dirsToProcess[len(dirsToProcess)-1]
dirsToProcess = dirsToProcess[:... | [
"func",
"(",
"sc",
"*",
"Client",
")",
"Walk",
"(",
"root",
"string",
")",
"<-",
"chan",
"fswalker",
".",
"WalkItem",
"{",
"iterChannel",
":=",
"make",
"(",
"chan",
"fswalker",
".",
"WalkItem",
")",
"\n",
"dirsToProcess",
":=",
"[",
"]",
"string",
"{",... | // Walk walks recursively through the SFTP
// @root: root path to start walking through | [
"Walk",
"walks",
"recursively",
"through",
"the",
"SFTP"
] | 817f34752728629396193de0249e187c6ab1c5cb | https://github.com/0xrawsec/golang-utils/blob/817f34752728629396193de0249e187c6ab1c5cb/net/sftp/sftp.go#L88-L132 |
134,992 | 0xrawsec/golang-utils | crypto/data/data.go | Md5 | func Md5(data []byte) string {
md5 := md5.New()
md5.Write(data)
return hex.EncodeToString(md5.Sum(nil))
} | go | func Md5(data []byte) string {
md5 := md5.New()
md5.Write(data)
return hex.EncodeToString(md5.Sum(nil))
} | [
"func",
"Md5",
"(",
"data",
"[",
"]",
"byte",
")",
"string",
"{",
"md5",
":=",
"md5",
".",
"New",
"(",
")",
"\n",
"md5",
".",
"Write",
"(",
"data",
")",
"\n",
"return",
"hex",
".",
"EncodeToString",
"(",
"md5",
".",
"Sum",
"(",
"nil",
")",
")",... | // Md5 returns the md5 sum of data | [
"Md5",
"returns",
"the",
"md5",
"sum",
"of",
"data"
] | 817f34752728629396193de0249e187c6ab1c5cb | https://github.com/0xrawsec/golang-utils/blob/817f34752728629396193de0249e187c6ab1c5cb/crypto/data/data.go#L12-L16 |
134,993 | 0xrawsec/golang-utils | crypto/data/data.go | Sha1 | func Sha1(data []byte) string {
sha1 := sha1.New()
sha1.Write(data)
return hex.EncodeToString(sha1.Sum(nil))
} | go | func Sha1(data []byte) string {
sha1 := sha1.New()
sha1.Write(data)
return hex.EncodeToString(sha1.Sum(nil))
} | [
"func",
"Sha1",
"(",
"data",
"[",
"]",
"byte",
")",
"string",
"{",
"sha1",
":=",
"sha1",
".",
"New",
"(",
")",
"\n",
"sha1",
".",
"Write",
"(",
"data",
")",
"\n",
"return",
"hex",
".",
"EncodeToString",
"(",
"sha1",
".",
"Sum",
"(",
"nil",
")",
... | // Sha1 returns the sha1 sum of data | [
"Sha1",
"returns",
"the",
"sha1",
"sum",
"of",
"data"
] | 817f34752728629396193de0249e187c6ab1c5cb | https://github.com/0xrawsec/golang-utils/blob/817f34752728629396193de0249e187c6ab1c5cb/crypto/data/data.go#L19-L23 |
134,994 | 0xrawsec/golang-utils | crypto/data/data.go | Sha256 | func Sha256(data []byte) string {
sha256 := sha256.New()
sha256.Write(data)
return hex.EncodeToString(sha256.Sum(nil))
} | go | func Sha256(data []byte) string {
sha256 := sha256.New()
sha256.Write(data)
return hex.EncodeToString(sha256.Sum(nil))
} | [
"func",
"Sha256",
"(",
"data",
"[",
"]",
"byte",
")",
"string",
"{",
"sha256",
":=",
"sha256",
".",
"New",
"(",
")",
"\n",
"sha256",
".",
"Write",
"(",
"data",
")",
"\n",
"return",
"hex",
".",
"EncodeToString",
"(",
"sha256",
".",
"Sum",
"(",
"nil"... | // Sha256 returns the sha256 sum of data | [
"Sha256",
"returns",
"the",
"sha256",
"sum",
"of",
"data"
] | 817f34752728629396193de0249e187c6ab1c5cb | https://github.com/0xrawsec/golang-utils/blob/817f34752728629396193de0249e187c6ab1c5cb/crypto/data/data.go#L26-L30 |
134,995 | 0xrawsec/golang-utils | crypto/data/data.go | Sha512 | func Sha512(data []byte) string {
sha512 := sha512.New()
sha512.Write(data)
return hex.EncodeToString(sha512.Sum(nil))
} | go | func Sha512(data []byte) string {
sha512 := sha512.New()
sha512.Write(data)
return hex.EncodeToString(sha512.Sum(nil))
} | [
"func",
"Sha512",
"(",
"data",
"[",
"]",
"byte",
")",
"string",
"{",
"sha512",
":=",
"sha512",
".",
"New",
"(",
")",
"\n",
"sha512",
".",
"Write",
"(",
"data",
")",
"\n",
"return",
"hex",
".",
"EncodeToString",
"(",
"sha512",
".",
"Sum",
"(",
"nil"... | // Sha512 returns the sha512 sum of data | [
"Sha512",
"returns",
"the",
"sha512",
"sum",
"of",
"data"
] | 817f34752728629396193de0249e187c6ab1c5cb | https://github.com/0xrawsec/golang-utils/blob/817f34752728629396193de0249e187c6ab1c5cb/crypto/data/data.go#L33-L37 |
134,996 | 0xrawsec/golang-utils | stats/stats.go | Truncate | func Truncate(f float64, p int) float64 {
return float64(int(f*math.Pow10(p))) / math.Pow10(p)
} | go | func Truncate(f float64, p int) float64 {
return float64(int(f*math.Pow10(p))) / math.Pow10(p)
} | [
"func",
"Truncate",
"(",
"f",
"float64",
",",
"p",
"int",
")",
"float64",
"{",
"return",
"float64",
"(",
"int",
"(",
"f",
"*",
"math",
".",
"Pow10",
"(",
"p",
")",
")",
")",
"/",
"math",
".",
"Pow10",
"(",
"p",
")",
"\n",
"}"
] | // Trucate truncates a float with p figures of precision | [
"Trucate",
"truncates",
"a",
"float",
"with",
"p",
"figures",
"of",
"precision"
] | 817f34752728629396193de0249e187c6ab1c5cb | https://github.com/0xrawsec/golang-utils/blob/817f34752728629396193de0249e187c6ab1c5cb/stats/stats.go#L6-L8 |
134,997 | 0xrawsec/golang-utils | stats/stats.go | Average | func Average(floats []float64) float64 {
var sum float64
var cnt float64
for _, f := range floats {
sum += f
cnt++
}
return sum / cnt
} | go | func Average(floats []float64) float64 {
var sum float64
var cnt float64
for _, f := range floats {
sum += f
cnt++
}
return sum / cnt
} | [
"func",
"Average",
"(",
"floats",
"[",
"]",
"float64",
")",
"float64",
"{",
"var",
"sum",
"float64",
"\n",
"var",
"cnt",
"float64",
"\n",
"for",
"_",
",",
"f",
":=",
"range",
"floats",
"{",
"sum",
"+=",
"f",
"\n",
"cnt",
"++",
"\n",
"}",
"\n",
"r... | // Average computes the average of a table of floats | [
"Average",
"computes",
"the",
"average",
"of",
"a",
"table",
"of",
"floats"
] | 817f34752728629396193de0249e187c6ab1c5cb | https://github.com/0xrawsec/golang-utils/blob/817f34752728629396193de0249e187c6ab1c5cb/stats/stats.go#L11-L19 |
134,998 | 0xrawsec/golang-utils | stats/stats.go | StdDev | func StdDev(floats []float64) float64 {
var sum float64
a := Average(floats)
for _, f := range floats {
sum += math.Pow(f-a, 2)
}
return math.Sqrt(sum / float64(len(floats)))
} | go | func StdDev(floats []float64) float64 {
var sum float64
a := Average(floats)
for _, f := range floats {
sum += math.Pow(f-a, 2)
}
return math.Sqrt(sum / float64(len(floats)))
} | [
"func",
"StdDev",
"(",
"floats",
"[",
"]",
"float64",
")",
"float64",
"{",
"var",
"sum",
"float64",
"\n",
"a",
":=",
"Average",
"(",
"floats",
")",
"\n",
"for",
"_",
",",
"f",
":=",
"range",
"floats",
"{",
"sum",
"+=",
"math",
".",
"Pow",
"(",
"f... | // StdDev returns the standard deviation of a random variable | [
"StdDev",
"returns",
"the",
"standard",
"deviation",
"of",
"a",
"random",
"variable"
] | 817f34752728629396193de0249e187c6ab1c5cb | https://github.com/0xrawsec/golang-utils/blob/817f34752728629396193de0249e187c6ab1c5cb/stats/stats.go#L22-L29 |
134,999 | 0xrawsec/golang-utils | fileutils/hash/hash.go | Update | func (h *Hashes) Update(path string) (err error) {
var buffer [4096]byte
file, err := os.Open(path)
if err != nil {
return err
}
defer file.Close()
md5 := md5.New()
sha1 := sha1.New()
sha256 := sha256.New()
sha512 := sha512.New()
for read, err := file.Read(buffer[:]); err != io.EOF && read != 0; read, err ... | go | func (h *Hashes) Update(path string) (err error) {
var buffer [4096]byte
file, err := os.Open(path)
if err != nil {
return err
}
defer file.Close()
md5 := md5.New()
sha1 := sha1.New()
sha256 := sha256.New()
sha512 := sha512.New()
for read, err := file.Read(buffer[:]); err != io.EOF && read != 0; read, err ... | [
"func",
"(",
"h",
"*",
"Hashes",
")",
"Update",
"(",
"path",
"string",
")",
"(",
"err",
"error",
")",
"{",
"var",
"buffer",
"[",
"4096",
"]",
"byte",
"\n",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
... | // Update the current Hashes structure | [
"Update",
"the",
"current",
"Hashes",
"structure"
] | 817f34752728629396193de0249e187c6ab1c5cb | https://github.com/0xrawsec/golang-utils/blob/817f34752728629396193de0249e187c6ab1c5cb/fileutils/hash/hash.go#L43-L71 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.