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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28,600 | chrislusf/gleam | sql/util/types/field_type.go | Init | func (ft *FieldType) Init(tp byte) {
ft.Tp = tp
ft.Flen = UnspecifiedLength
ft.Decimal = UnspecifiedLength
} | go | func (ft *FieldType) Init(tp byte) {
ft.Tp = tp
ft.Flen = UnspecifiedLength
ft.Decimal = UnspecifiedLength
} | [
"func",
"(",
"ft",
"*",
"FieldType",
")",
"Init",
"(",
"tp",
"byte",
")",
"{",
"ft",
".",
"Tp",
"=",
"tp",
"\n",
"ft",
".",
"Flen",
"=",
"UnspecifiedLength",
"\n",
"ft",
".",
"Decimal",
"=",
"UnspecifiedLength",
"\n",
"}"
] | // Init initializes the FieldType data. | [
"Init",
"initializes",
"the",
"FieldType",
"data",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/field_type.go#L52-L56 |
28,601 | chrislusf/gleam | sql/util/types/field_type.go | String | func (ft *FieldType) String() string {
strs := []string{ft.CompactStr()}
if mysql.HasUnsignedFlag(ft.Flag) {
strs = append(strs, "UNSIGNED")
}
if mysql.HasZerofillFlag(ft.Flag) {
strs = append(strs, "ZEROFILL")
}
if mysql.HasBinaryFlag(ft.Flag) {
strs = append(strs, "BINARY")
}
if IsTypeChar(ft.Tp) || Is... | go | func (ft *FieldType) String() string {
strs := []string{ft.CompactStr()}
if mysql.HasUnsignedFlag(ft.Flag) {
strs = append(strs, "UNSIGNED")
}
if mysql.HasZerofillFlag(ft.Flag) {
strs = append(strs, "ZEROFILL")
}
if mysql.HasBinaryFlag(ft.Flag) {
strs = append(strs, "BINARY")
}
if IsTypeChar(ft.Tp) || Is... | [
"func",
"(",
"ft",
"*",
"FieldType",
")",
"String",
"(",
")",
"string",
"{",
"strs",
":=",
"[",
"]",
"string",
"{",
"ft",
".",
"CompactStr",
"(",
")",
"}",
"\n",
"if",
"mysql",
".",
"HasUnsignedFlag",
"(",
"ft",
".",
"Flag",
")",
"{",
"strs",
"="... | // String joins the information of FieldType and
// returns a string. | [
"String",
"joins",
"the",
"information",
"of",
"FieldType",
"and",
"returns",
"a",
"string",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/field_type.go#L94-L116 |
28,602 | chrislusf/gleam | sql/util/auth.go | Sha1Hash | func Sha1Hash(bs []byte) []byte {
crypt := sha1.New()
crypt.Write(bs)
return crypt.Sum(nil)
} | go | func Sha1Hash(bs []byte) []byte {
crypt := sha1.New()
crypt.Write(bs)
return crypt.Sum(nil)
} | [
"func",
"Sha1Hash",
"(",
"bs",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"crypt",
":=",
"sha1",
".",
"New",
"(",
")",
"\n",
"crypt",
".",
"Write",
"(",
"bs",
")",
"\n",
"return",
"crypt",
".",
"Sum",
"(",
"nil",
")",
"\n",
"}"
] | // Sha1Hash is an util function to calculate sha1 hash. | [
"Sha1Hash",
"is",
"an",
"util",
"function",
"to",
"calculate",
"sha1",
"hash",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/auth.go#L46-L50 |
28,603 | chrislusf/gleam | sql/util/auth.go | EncodePassword | func EncodePassword(pwd string) string {
if len(pwd) == 0 {
return ""
}
hash := Sha1Hash([]byte(pwd))
return hex.EncodeToString(hash)
} | go | func EncodePassword(pwd string) string {
if len(pwd) == 0 {
return ""
}
hash := Sha1Hash([]byte(pwd))
return hex.EncodeToString(hash)
} | [
"func",
"EncodePassword",
"(",
"pwd",
"string",
")",
"string",
"{",
"if",
"len",
"(",
"pwd",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"hash",
":=",
"Sha1Hash",
"(",
"[",
"]",
"byte",
"(",
"pwd",
")",
")",
"\n",
"return",
"hex",... | // EncodePassword converts plaintext password to hashed hex string. | [
"EncodePassword",
"converts",
"plaintext",
"password",
"to",
"hashed",
"hex",
"string",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/auth.go#L53-L59 |
28,604 | chrislusf/gleam | sql/util/auth.go | DecodePassword | func DecodePassword(pwd string) ([]byte, error) {
x, err := hex.DecodeString(pwd)
if err != nil {
return nil, errors.Trace(err)
}
return x, nil
} | go | func DecodePassword(pwd string) ([]byte, error) {
x, err := hex.DecodeString(pwd)
if err != nil {
return nil, errors.Trace(err)
}
return x, nil
} | [
"func",
"DecodePassword",
"(",
"pwd",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"x",
",",
"err",
":=",
"hex",
".",
"DecodeString",
"(",
"pwd",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Tra... | // DecodePassword converts hex string password to byte array. | [
"DecodePassword",
"converts",
"hex",
"string",
"password",
"to",
"byte",
"array",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/auth.go#L62-L68 |
28,605 | chrislusf/gleam | flow/dataset_join.go | Join | func (d *Dataset) Join(name string, other *Dataset, sortOption *SortOption) *Dataset {
return d.DoJoin(name, other, false, false, sortOption)
} | go | func (d *Dataset) Join(name string, other *Dataset, sortOption *SortOption) *Dataset {
return d.DoJoin(name, other, false, false, sortOption)
} | [
"func",
"(",
"d",
"*",
"Dataset",
")",
"Join",
"(",
"name",
"string",
",",
"other",
"*",
"Dataset",
",",
"sortOption",
"*",
"SortOption",
")",
"*",
"Dataset",
"{",
"return",
"d",
".",
"DoJoin",
"(",
"name",
",",
"other",
",",
"false",
",",
"false",
... | // Join joins two datasets by the key. | [
"Join",
"joins",
"two",
"datasets",
"by",
"the",
"key",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_join.go#L8-L10 |
28,606 | chrislusf/gleam | flow/dataset_join.go | JoinPartitionedSorted | func (this *Dataset) JoinPartitionedSorted(name string, that *Dataset, sortOption *SortOption,
isLeftOuterJoin, isRightOuterJoin bool) *Dataset {
ret := this.Flow.NewNextDataset(len(this.Shards))
ret.IsPartitionedBy = that.IsPartitionedBy
ret.IsLocalSorted = that.IsLocalSorted
inputs := []*Dataset{this, that}
st... | go | func (this *Dataset) JoinPartitionedSorted(name string, that *Dataset, sortOption *SortOption,
isLeftOuterJoin, isRightOuterJoin bool) *Dataset {
ret := this.Flow.NewNextDataset(len(this.Shards))
ret.IsPartitionedBy = that.IsPartitionedBy
ret.IsLocalSorted = that.IsLocalSorted
inputs := []*Dataset{this, that}
st... | [
"func",
"(",
"this",
"*",
"Dataset",
")",
"JoinPartitionedSorted",
"(",
"name",
"string",
",",
"that",
"*",
"Dataset",
",",
"sortOption",
"*",
"SortOption",
",",
"isLeftOuterJoin",
",",
"isRightOuterJoin",
"bool",
")",
"*",
"Dataset",
"{",
"ret",
":=",
"this... | // JoinPartitionedSorted Join multiple datasets that are sharded by the same key, and locally sorted within the shard | [
"JoinPartitionedSorted",
"Join",
"multiple",
"datasets",
"that",
"are",
"sharded",
"by",
"the",
"same",
"key",
"and",
"locally",
"sorted",
"within",
"the",
"shard"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_join.go#L46-L56 |
28,607 | chrislusf/gleam | sql/expression/expression.go | EvalBool | func EvalBool(expr Expression, row []types.Datum, ctx context.Context) (bool, error) {
data, err := expr.Eval(row, ctx)
if err != nil {
return false, errors.Trace(err)
}
if data.IsNull() {
return false, nil
}
i, err := data.ToBool(ctx.GetSessionVars().StmtCtx)
if err != nil {
return false, errors.Trace(er... | go | func EvalBool(expr Expression, row []types.Datum, ctx context.Context) (bool, error) {
data, err := expr.Eval(row, ctx)
if err != nil {
return false, errors.Trace(err)
}
if data.IsNull() {
return false, nil
}
i, err := data.ToBool(ctx.GetSessionVars().StmtCtx)
if err != nil {
return false, errors.Trace(er... | [
"func",
"EvalBool",
"(",
"expr",
"Expression",
",",
"row",
"[",
"]",
"types",
".",
"Datum",
",",
"ctx",
"context",
".",
"Context",
")",
"(",
"bool",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"expr",
".",
"Eval",
"(",
"row",
",",
"ctx",
")... | // EvalBool evaluates expression to a boolean value. | [
"EvalBool",
"evaluates",
"expression",
"to",
"a",
"boolean",
"value",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/expression.go#L78-L92 |
28,608 | chrislusf/gleam | sql/expression/expression.go | TableInfo2Schema | func TableInfo2Schema(tbl *model.TableInfo) Schema {
schema := NewSchema(make([]*Column, 0, len(tbl.Columns)))
keys := make([]KeyInfo, 0, len(tbl.Indices)+1)
for i, col := range tbl.Columns {
newCol := &Column{
ColName: col.Name,
TblName: tbl.Name,
RetType: &col.FieldType,
Position: i,
}
schema.... | go | func TableInfo2Schema(tbl *model.TableInfo) Schema {
schema := NewSchema(make([]*Column, 0, len(tbl.Columns)))
keys := make([]KeyInfo, 0, len(tbl.Indices)+1)
for i, col := range tbl.Columns {
newCol := &Column{
ColName: col.Name,
TblName: tbl.Name,
RetType: &col.FieldType,
Position: i,
}
schema.... | [
"func",
"TableInfo2Schema",
"(",
"tbl",
"*",
"model",
".",
"TableInfo",
")",
"Schema",
"{",
"schema",
":=",
"NewSchema",
"(",
"make",
"(",
"[",
"]",
"*",
"Column",
",",
"0",
",",
"len",
"(",
"tbl",
".",
"Columns",
")",
")",
")",
"\n",
"keys",
":=",... | // TableInfo2Schema converts table info to schema. | [
"TableInfo2Schema",
"converts",
"table",
"info",
"to",
"schema",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/expression.go#L279-L320 |
28,609 | chrislusf/gleam | sql/expression/expression.go | NewCastFunc | func NewCastFunc(tp *types.FieldType, arg Expression, ctx context.Context) *ScalarFunction {
bt := &builtinCastSig{newBaseBuiltinFunc([]Expression{arg}, ctx), tp}
return &ScalarFunction{
FuncName: model.NewCIStr(ast.Cast),
RetType: tp,
Function: bt,
}
} | go | func NewCastFunc(tp *types.FieldType, arg Expression, ctx context.Context) *ScalarFunction {
bt := &builtinCastSig{newBaseBuiltinFunc([]Expression{arg}, ctx), tp}
return &ScalarFunction{
FuncName: model.NewCIStr(ast.Cast),
RetType: tp,
Function: bt,
}
} | [
"func",
"NewCastFunc",
"(",
"tp",
"*",
"types",
".",
"FieldType",
",",
"arg",
"Expression",
",",
"ctx",
"context",
".",
"Context",
")",
"*",
"ScalarFunction",
"{",
"bt",
":=",
"&",
"builtinCastSig",
"{",
"newBaseBuiltinFunc",
"(",
"[",
"]",
"Expression",
"... | // NewCastFunc creates a new cast function. | [
"NewCastFunc",
"creates",
"a",
"new",
"cast",
"function",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/expression.go#L323-L330 |
28,610 | chrislusf/gleam | sql/expression/constant_fold.go | FoldConstant | func FoldConstant(ctx context.Context, expr Expression) Expression {
scalarFunc, ok := expr.(*ScalarFunction)
if !ok {
return expr
}
if _, isDynamic := DynamicFuncs[scalarFunc.FuncName.L]; isDynamic {
return expr
}
args := scalarFunc.GetArgs()
canFold := true
for i := 0; i < len(args); i++ {
foldedArg := ... | go | func FoldConstant(ctx context.Context, expr Expression) Expression {
scalarFunc, ok := expr.(*ScalarFunction)
if !ok {
return expr
}
if _, isDynamic := DynamicFuncs[scalarFunc.FuncName.L]; isDynamic {
return expr
}
args := scalarFunc.GetArgs()
canFold := true
for i := 0; i < len(args); i++ {
foldedArg := ... | [
"func",
"FoldConstant",
"(",
"ctx",
"context",
".",
"Context",
",",
"expr",
"Expression",
")",
"Expression",
"{",
"scalarFunc",
",",
"ok",
":=",
"expr",
".",
"(",
"*",
"ScalarFunction",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"expr",
"\n",
"}",
"\n"... | // FoldConstant does constant folding optimization on an expression. | [
"FoldConstant",
"does",
"constant",
"folding",
"optimization",
"on",
"an",
"expression",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/constant_fold.go#L22-L51 |
28,611 | chrislusf/gleam | util/message_read.go | TakeMessage | func TakeMessage(reader io.Reader, count int, f func([]byte) error) (err error) {
if _, isBufioReader := reader.(*bufio.Reader); !isBufioReader {
reader = bufio.NewReader(reader)
}
for err == nil {
if count == 0 {
io.Copy(ioutil.Discard, reader)
return nil
}
message, readError := ReadMessage(reader)
... | go | func TakeMessage(reader io.Reader, count int, f func([]byte) error) (err error) {
if _, isBufioReader := reader.(*bufio.Reader); !isBufioReader {
reader = bufio.NewReader(reader)
}
for err == nil {
if count == 0 {
io.Copy(ioutil.Discard, reader)
return nil
}
message, readError := ReadMessage(reader)
... | [
"func",
"TakeMessage",
"(",
"reader",
"io",
".",
"Reader",
",",
"count",
"int",
",",
"f",
"func",
"(",
"[",
"]",
"byte",
")",
"error",
")",
"(",
"err",
"error",
")",
"{",
"if",
"_",
",",
"isBufioReader",
":=",
"reader",
".",
"(",
"*",
"bufio",
".... | // TakeMessage Reads and processes MessagePack encoded messages.
// If count is less than 0, all lines are processed. | [
"TakeMessage",
"Reads",
"and",
"processes",
"MessagePack",
"encoded",
"messages",
".",
"If",
"count",
"is",
"less",
"than",
"0",
"all",
"lines",
"are",
"processed",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/util/message_read.go#L58-L80 |
28,612 | chrislusf/gleam | util/message_read.go | ProcessMessage | func ProcessMessage(reader io.Reader, f func([]byte) error) (err error) {
return TakeMessage(reader, -1, f)
} | go | func ProcessMessage(reader io.Reader, f func([]byte) error) (err error) {
return TakeMessage(reader, -1, f)
} | [
"func",
"ProcessMessage",
"(",
"reader",
"io",
".",
"Reader",
",",
"f",
"func",
"(",
"[",
"]",
"byte",
")",
"error",
")",
"(",
"err",
"error",
")",
"{",
"return",
"TakeMessage",
"(",
"reader",
",",
"-",
"1",
",",
"f",
")",
"\n",
"}"
] | // ProcessMessage Reads and processes MessagePack encoded messages until EOF | [
"ProcessMessage",
"Reads",
"and",
"processes",
"MessagePack",
"encoded",
"messages",
"until",
"EOF"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/util/message_read.go#L83-L85 |
28,613 | chrislusf/gleam | distributed/store/single_file_store.go | Write | func (l *SingleFileStore) Write(p []byte) (n int, err error) {
l.mu.Lock()
defer l.mu.Unlock()
if l.file == nil {
if err = l.openNew(); err != nil {
return 0, err
}
}
l.file.Seek(0, 2)
n, err = l.file.Write(p)
l.size += int64(n)
l.Position += int64(n)
l.waitForReading.Broadcast()
return n, err
} | go | func (l *SingleFileStore) Write(p []byte) (n int, err error) {
l.mu.Lock()
defer l.mu.Unlock()
if l.file == nil {
if err = l.openNew(); err != nil {
return 0, err
}
}
l.file.Seek(0, 2)
n, err = l.file.Write(p)
l.size += int64(n)
l.Position += int64(n)
l.waitForReading.Broadcast()
return n, err
} | [
"func",
"(",
"l",
"*",
"SingleFileStore",
")",
"Write",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"l",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
... | // Write implements io.Writer. If a write would cause the log file to be larger
// than MaxMegaByte, the file is closed, renamed to include a timestamp of the
// current time, and a new log file is created using the original log file name.
// If the length of the write is greater than MaxMegaByte, an error is returned... | [
"Write",
"implements",
"io",
".",
"Writer",
".",
"If",
"a",
"write",
"would",
"cause",
"the",
"log",
"file",
"to",
"be",
"larger",
"than",
"MaxMegaByte",
"the",
"file",
"is",
"closed",
"renamed",
"to",
"include",
"a",
"timestamp",
"of",
"the",
"current",
... | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/store/single_file_store.go#L62-L79 |
28,614 | chrislusf/gleam | distributed/driver/scheduler/grpc_client_to_agent.go | mergeStats | func mergeStats(a, b []*pb.InstructionStat) (ret []*pb.InstructionStat) {
var nonOverlapping []*pb.InstructionStat
for _, ai := range a {
var found bool
for _, bi := range b {
if ai.StepId == bi.StepId {
found = true
if ai.InputCounter > bi.InputCounter {
ret = append(ret, ai)
} else {
re... | go | func mergeStats(a, b []*pb.InstructionStat) (ret []*pb.InstructionStat) {
var nonOverlapping []*pb.InstructionStat
for _, ai := range a {
var found bool
for _, bi := range b {
if ai.StepId == bi.StepId {
found = true
if ai.InputCounter > bi.InputCounter {
ret = append(ret, ai)
} else {
re... | [
"func",
"mergeStats",
"(",
"a",
",",
"b",
"[",
"]",
"*",
"pb",
".",
"InstructionStat",
")",
"(",
"ret",
"[",
"]",
"*",
"pb",
".",
"InstructionStat",
")",
"{",
"var",
"nonOverlapping",
"[",
"]",
"*",
"pb",
".",
"InstructionStat",
"\n",
"for",
"_",
"... | // merge existing stats with incoming stats | [
"merge",
"existing",
"stats",
"with",
"incoming",
"stats"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/driver/scheduler/grpc_client_to_agent.go#L148-L179 |
28,615 | chrislusf/gleam | sql/plan/physical_plan_builder.go | tryToConvert2DummyScan | func (p *DataSource) tryToConvert2DummyScan(prop *requiredProperty) (*physicalPlanInfo, error) {
sel, isSel := p.GetParentByIndex(0).(*Selection)
if !isSel {
return nil, nil
}
for _, cond := range sel.Conditions {
if con, ok := cond.(*expression.Constant); ok {
result, err := expression.EvalBool(con, nil, p... | go | func (p *DataSource) tryToConvert2DummyScan(prop *requiredProperty) (*physicalPlanInfo, error) {
sel, isSel := p.GetParentByIndex(0).(*Selection)
if !isSel {
return nil, nil
}
for _, cond := range sel.Conditions {
if con, ok := cond.(*expression.Constant); ok {
result, err := expression.EvalBool(con, nil, p... | [
"func",
"(",
"p",
"*",
"DataSource",
")",
"tryToConvert2DummyScan",
"(",
"prop",
"*",
"requiredProperty",
")",
"(",
"*",
"physicalPlanInfo",
",",
"error",
")",
"{",
"sel",
",",
"isSel",
":=",
"p",
".",
"GetParentByIndex",
"(",
"0",
")",
".",
"(",
"*",
... | // tryToConvert2DummyScan is an optimization which checks if its parent is a selection with a constant condition
// that evaluates to false. If it is, there is no need for a real physical scan, a dummy scan will do. | [
"tryToConvert2DummyScan",
"is",
"an",
"optimization",
"which",
"checks",
"if",
"its",
"parent",
"is",
"a",
"selection",
"with",
"a",
"constant",
"condition",
"that",
"evaluates",
"to",
"false",
".",
"If",
"it",
"is",
"there",
"is",
"no",
"need",
"for",
"a",
... | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/physical_plan_builder.go#L146-L171 |
28,616 | chrislusf/gleam | sql/plan/physical_plan_builder.go | removeLimit | func removeLimit(prop *requiredProperty) *requiredProperty {
ret := &requiredProperty{
props: prop.props,
sortKeyLen: prop.sortKeyLen,
}
return ret
} | go | func removeLimit(prop *requiredProperty) *requiredProperty {
ret := &requiredProperty{
props: prop.props,
sortKeyLen: prop.sortKeyLen,
}
return ret
} | [
"func",
"removeLimit",
"(",
"prop",
"*",
"requiredProperty",
")",
"*",
"requiredProperty",
"{",
"ret",
":=",
"&",
"requiredProperty",
"{",
"props",
":",
"prop",
".",
"props",
",",
"sortKeyLen",
":",
"prop",
".",
"sortKeyLen",
",",
"}",
"\n",
"return",
"ret... | // removeLimit removes the limit from prop. | [
"removeLimit",
"removes",
"the",
"limit",
"from",
"prop",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/physical_plan_builder.go#L222-L228 |
28,617 | chrislusf/gleam | sql/plan/physical_plan_builder.go | replaceColsInPropBySchema | func replaceColsInPropBySchema(prop *requiredProperty, schema expression.Schema) *requiredProperty {
newProps := make([]*columnProp, 0, len(prop.props))
for _, p := range prop.props {
idx := schema.GetColumnIndex(p.col)
if idx == -1 {
log.Printf("Can't find column %s in schema", p.col)
}
newProps = append(... | go | func replaceColsInPropBySchema(prop *requiredProperty, schema expression.Schema) *requiredProperty {
newProps := make([]*columnProp, 0, len(prop.props))
for _, p := range prop.props {
idx := schema.GetColumnIndex(p.col)
if idx == -1 {
log.Printf("Can't find column %s in schema", p.col)
}
newProps = append(... | [
"func",
"replaceColsInPropBySchema",
"(",
"prop",
"*",
"requiredProperty",
",",
"schema",
"expression",
".",
"Schema",
")",
"*",
"requiredProperty",
"{",
"newProps",
":=",
"make",
"(",
"[",
"]",
"*",
"columnProp",
",",
"0",
",",
"len",
"(",
"prop",
".",
"p... | // replaceColsInPropBySchema replaces the columns in original prop with the columns in schema. | [
"replaceColsInPropBySchema",
"replaces",
"the",
"columns",
"in",
"original",
"prop",
"with",
"the",
"columns",
"in",
"schema",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/physical_plan_builder.go#L375-L389 |
28,618 | chrislusf/gleam | sql/plan/physical_plan_builder.go | convert2PhysicalPlanHash | func (p *Aggregation) convert2PhysicalPlanHash() (*physicalPlanInfo, error) {
childInfo, err := p.children[0].(LogicalPlan).convert2PhysicalPlan(&requiredProperty{})
if err != nil {
return nil, errors.Trace(err)
}
distinct := false
for _, fun := range p.AggFuncs {
if fun.IsDistinct() {
distinct = true
br... | go | func (p *Aggregation) convert2PhysicalPlanHash() (*physicalPlanInfo, error) {
childInfo, err := p.children[0].(LogicalPlan).convert2PhysicalPlan(&requiredProperty{})
if err != nil {
return nil, errors.Trace(err)
}
distinct := false
for _, fun := range p.AggFuncs {
if fun.IsDistinct() {
distinct = true
br... | [
"func",
"(",
"p",
"*",
"Aggregation",
")",
"convert2PhysicalPlanHash",
"(",
")",
"(",
"*",
"physicalPlanInfo",
",",
"error",
")",
"{",
"childInfo",
",",
"err",
":=",
"p",
".",
"children",
"[",
"0",
"]",
".",
"(",
"LogicalPlan",
")",
".",
"convert2Physica... | // convert2PhysicalPlanHash converts the logical aggregation to the physical hash aggregation. | [
"convert2PhysicalPlanHash",
"converts",
"the",
"logical",
"aggregation",
"to",
"the",
"physical",
"hash",
"aggregation",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/physical_plan_builder.go#L587-L608 |
28,619 | chrislusf/gleam | sql/plan/physical_plan_builder.go | physicalInitialize | func physicalInitialize(p PhysicalPlan) {
for _, child := range p.GetChildren() {
physicalInitialize(child.(PhysicalPlan))
}
// initialize attributes
p.SetCorrelated()
} | go | func physicalInitialize(p PhysicalPlan) {
for _, child := range p.GetChildren() {
physicalInitialize(child.(PhysicalPlan))
}
// initialize attributes
p.SetCorrelated()
} | [
"func",
"physicalInitialize",
"(",
"p",
"PhysicalPlan",
")",
"{",
"for",
"_",
",",
"child",
":=",
"range",
"p",
".",
"GetChildren",
"(",
")",
"{",
"physicalInitialize",
"(",
"child",
".",
"(",
"PhysicalPlan",
")",
")",
"\n",
"}",
"\n",
"// initialize attri... | // physicalInitialize will set value of some attributes after convert2PhysicalPlan process.
// Currently, only attribute "correlated" is considered. | [
"physicalInitialize",
"will",
"set",
"value",
"of",
"some",
"attributes",
"after",
"convert2PhysicalPlan",
"process",
".",
"Currently",
"only",
"attribute",
"correlated",
"is",
"considered",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/physical_plan_builder.go#L900-L906 |
28,620 | chrislusf/gleam | sql/util/codec/number.go | EncodeInt | func EncodeInt(b []byte, v int64) []byte {
var data [8]byte
u := encodeIntToCmpUint(v)
binary.BigEndian.PutUint64(data[:], u)
return append(b, data[:]...)
} | go | func EncodeInt(b []byte, v int64) []byte {
var data [8]byte
u := encodeIntToCmpUint(v)
binary.BigEndian.PutUint64(data[:], u)
return append(b, data[:]...)
} | [
"func",
"EncodeInt",
"(",
"b",
"[",
"]",
"byte",
",",
"v",
"int64",
")",
"[",
"]",
"byte",
"{",
"var",
"data",
"[",
"8",
"]",
"byte",
"\n",
"u",
":=",
"encodeIntToCmpUint",
"(",
"v",
")",
"\n",
"binary",
".",
"BigEndian",
".",
"PutUint64",
"(",
"... | // EncodeInt appends the encoded value to slice b and returns the appended slice.
// EncodeInt guarantees that the encoded value is in ascending order for comparison. | [
"EncodeInt",
"appends",
"the",
"encoded",
"value",
"to",
"slice",
"b",
"and",
"returns",
"the",
"appended",
"slice",
".",
"EncodeInt",
"guarantees",
"that",
"the",
"encoded",
"value",
"is",
"in",
"ascending",
"order",
"for",
"comparison",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/codec/number.go#L35-L40 |
28,621 | chrislusf/gleam | sql/util/codec/number.go | DecodeIntDesc | func DecodeIntDesc(b []byte) ([]byte, int64, error) {
if len(b) < 8 {
return nil, 0, errors.New("insufficient bytes to decode value")
}
u := binary.BigEndian.Uint64(b[:8])
v := decodeCmpUintToInt(^u)
b = b[8:]
return b, v, nil
} | go | func DecodeIntDesc(b []byte) ([]byte, int64, error) {
if len(b) < 8 {
return nil, 0, errors.New("insufficient bytes to decode value")
}
u := binary.BigEndian.Uint64(b[:8])
v := decodeCmpUintToInt(^u)
b = b[8:]
return b, v, nil
} | [
"func",
"DecodeIntDesc",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"int64",
",",
"error",
")",
"{",
"if",
"len",
"(",
"b",
")",
"<",
"8",
"{",
"return",
"nil",
",",
"0",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\... | // DecodeIntDesc decodes value encoded by EncodeInt before.
// It returns the leftover un-decoded slice, decoded value if no error. | [
"DecodeIntDesc",
"decodes",
"value",
"encoded",
"by",
"EncodeInt",
"before",
".",
"It",
"returns",
"the",
"leftover",
"un",
"-",
"decoded",
"slice",
"decoded",
"value",
"if",
"no",
"error",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/codec/number.go#L66-L75 |
28,622 | chrislusf/gleam | sql/util/types/convert.go | StrToInt | func StrToInt(sc *variable.StatementContext, str string) (int64, error) {
str = strings.TrimSpace(str)
validPrefix, err := getValidIntPrefix(sc, str)
iVal, err1 := strconv.ParseInt(validPrefix, 10, 64)
if err1 != nil {
return iVal, errors.Trace(ErrOverflow)
}
return iVal, errors.Trace(err)
} | go | func StrToInt(sc *variable.StatementContext, str string) (int64, error) {
str = strings.TrimSpace(str)
validPrefix, err := getValidIntPrefix(sc, str)
iVal, err1 := strconv.ParseInt(validPrefix, 10, 64)
if err1 != nil {
return iVal, errors.Trace(ErrOverflow)
}
return iVal, errors.Trace(err)
} | [
"func",
"StrToInt",
"(",
"sc",
"*",
"variable",
".",
"StatementContext",
",",
"str",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"str",
"=",
"strings",
".",
"TrimSpace",
"(",
"str",
")",
"\n",
"validPrefix",
",",
"err",
":=",
"getValidIntPrefix"... | // StrToInt converts a string to an integer at the best-effort. | [
"StrToInt",
"converts",
"a",
"string",
"to",
"an",
"integer",
"at",
"the",
"best",
"-",
"effort",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/convert.go#L138-L146 |
28,623 | chrislusf/gleam | sql/util/types/convert.go | floatStrToIntStr | func floatStrToIntStr(validFloat string) (string, error) {
var dotIdx = -1
var eIdx = -1
for i := 0; i < len(validFloat); i++ {
switch validFloat[i] {
case '.':
dotIdx = i
case 'e', 'E':
eIdx = i
}
}
if eIdx == -1 {
if dotIdx == -1 {
return validFloat, nil
}
return validFloat[:dotIdx], nil
... | go | func floatStrToIntStr(validFloat string) (string, error) {
var dotIdx = -1
var eIdx = -1
for i := 0; i < len(validFloat); i++ {
switch validFloat[i] {
case '.':
dotIdx = i
case 'e', 'E':
eIdx = i
}
}
if eIdx == -1 {
if dotIdx == -1 {
return validFloat, nil
}
return validFloat[:dotIdx], nil
... | [
"func",
"floatStrToIntStr",
"(",
"validFloat",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"dotIdx",
"=",
"-",
"1",
"\n",
"var",
"eIdx",
"=",
"-",
"1",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"validFloat",
")",
";... | // floatStrToIntStr converts a valid float string into valid integer string which can be parsed by
// strconv.ParseInt, we can't parse float first then convert it to string because precision will
// be lost. | [
"floatStrToIntStr",
"converts",
"a",
"valid",
"float",
"string",
"into",
"valid",
"integer",
"string",
"which",
"can",
"be",
"parsed",
"by",
"strconv",
".",
"ParseInt",
"we",
"can",
"t",
"parse",
"float",
"first",
"then",
"convert",
"it",
"to",
"string",
"be... | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/convert.go#L174-L228 |
28,624 | chrislusf/gleam | sql/util/types/convert.go | getValidFloatPrefix | func getValidFloatPrefix(sc *variable.StatementContext, s string) (valid string, err error) {
var (
sawDot bool
sawDigit bool
validLen int
eIdx int
)
for i := 0; i < len(s); i++ {
c := s[i]
if c == '+' || c == '-' {
if i != 0 && i != eIdx+1 { // "1e+1" is valid.
break
}
} else if c == '... | go | func getValidFloatPrefix(sc *variable.StatementContext, s string) (valid string, err error) {
var (
sawDot bool
sawDigit bool
validLen int
eIdx int
)
for i := 0; i < len(s); i++ {
c := s[i]
if c == '+' || c == '-' {
if i != 0 && i != eIdx+1 { // "1e+1" is valid.
break
}
} else if c == '... | [
"func",
"getValidFloatPrefix",
"(",
"sc",
"*",
"variable",
".",
"StatementContext",
",",
"s",
"string",
")",
"(",
"valid",
"string",
",",
"err",
"error",
")",
"{",
"var",
"(",
"sawDot",
"bool",
"\n",
"sawDigit",
"bool",
"\n",
"validLen",
"int",
"\n",
"eI... | // getValidFloatPrefix gets prefix of string which can be successfully parsed as float. | [
"getValidFloatPrefix",
"gets",
"prefix",
"of",
"string",
"which",
"can",
"be",
"successfully",
"parsed",
"as",
"float",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/convert.go#L242-L286 |
28,625 | chrislusf/gleam | sql/util/types/convert.go | ToString | func ToString(value interface{}) (string, error) {
switch v := value.(type) {
case bool:
if v {
return "1", nil
}
return "0", nil
case int:
return strconv.FormatInt(int64(v), 10), nil
case int64:
return strconv.FormatInt(int64(v), 10), nil
case uint64:
return strconv.FormatUint(uint64(v), 10), nil
... | go | func ToString(value interface{}) (string, error) {
switch v := value.(type) {
case bool:
if v {
return "1", nil
}
return "0", nil
case int:
return strconv.FormatInt(int64(v), 10), nil
case int64:
return strconv.FormatInt(int64(v), 10), nil
case uint64:
return strconv.FormatUint(uint64(v), 10), nil
... | [
"func",
"ToString",
"(",
"value",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"switch",
"v",
":=",
"value",
".",
"(",
"type",
")",
"{",
"case",
"bool",
":",
"if",
"v",
"{",
"return",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n... | // ToString converts an interface to a string. | [
"ToString",
"converts",
"an",
"interface",
"to",
"a",
"string",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/convert.go#L289-L327 |
28,626 | chrislusf/gleam | sql/plan/validator.go | Validate | func Validate(node ast.Node, inPrepare bool) error {
v := validator{inPrepare: inPrepare}
node.Accept(&v)
return v.err
} | go | func Validate(node ast.Node, inPrepare bool) error {
v := validator{inPrepare: inPrepare}
node.Accept(&v)
return v.err
} | [
"func",
"Validate",
"(",
"node",
"ast",
".",
"Node",
",",
"inPrepare",
"bool",
")",
"error",
"{",
"v",
":=",
"validator",
"{",
"inPrepare",
":",
"inPrepare",
"}",
"\n",
"node",
".",
"Accept",
"(",
"&",
"v",
")",
"\n",
"return",
"v",
".",
"err",
"\n... | // Validate checkes whether the node is valid. | [
"Validate",
"checkes",
"whether",
"the",
"node",
"is",
"valid",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/validator.go#L29-L33 |
28,627 | chrislusf/gleam | sql/plan/predicate_push_down.go | outerJoinSimplify | func outerJoinSimplify(p *Join, predicates []expression.Expression) error {
var innerTable, outerTable LogicalPlan
child1 := p.GetChildByIndex(0).(LogicalPlan)
child2 := p.GetChildByIndex(1).(LogicalPlan)
var fullConditions []expression.Expression
if p.JoinType == LeftOuterJoin {
innerTable = child2
outerTable... | go | func outerJoinSimplify(p *Join, predicates []expression.Expression) error {
var innerTable, outerTable LogicalPlan
child1 := p.GetChildByIndex(0).(LogicalPlan)
child2 := p.GetChildByIndex(1).(LogicalPlan)
var fullConditions []expression.Expression
if p.JoinType == LeftOuterJoin {
innerTable = child2
outerTable... | [
"func",
"outerJoinSimplify",
"(",
"p",
"*",
"Join",
",",
"predicates",
"[",
"]",
"expression",
".",
"Expression",
")",
"error",
"{",
"var",
"innerTable",
",",
"outerTable",
"LogicalPlan",
"\n",
"child1",
":=",
"p",
".",
"GetChildByIndex",
"(",
"0",
")",
".... | // outerJoinSimplify simplifies outer join. | [
"outerJoinSimplify",
"simplifies",
"outer",
"join",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/predicate_push_down.go#L145-L197 |
28,628 | chrislusf/gleam | sql/plan/predicate_push_down.go | concatOnAndWhereConds | func concatOnAndWhereConds(join *Join, predicates []expression.Expression) []expression.Expression {
equalConds, leftConds, rightConds, otherConds := join.EqualConditions, join.LeftConditions, join.RightConditions, join.OtherConditions
ans := make([]expression.Expression, 0, len(equalConds)+len(leftConds)+len(rightCo... | go | func concatOnAndWhereConds(join *Join, predicates []expression.Expression) []expression.Expression {
equalConds, leftConds, rightConds, otherConds := join.EqualConditions, join.LeftConditions, join.RightConditions, join.OtherConditions
ans := make([]expression.Expression, 0, len(equalConds)+len(leftConds)+len(rightCo... | [
"func",
"concatOnAndWhereConds",
"(",
"join",
"*",
"Join",
",",
"predicates",
"[",
"]",
"expression",
".",
"Expression",
")",
"[",
"]",
"expression",
".",
"Expression",
"{",
"equalConds",
",",
"leftConds",
",",
"rightConds",
",",
"otherConds",
":=",
"join",
... | // concatOnAndWhereConds concatenate ON conditions with WHERE conditions. | [
"concatOnAndWhereConds",
"concatenate",
"ON",
"conditions",
"with",
"WHERE",
"conditions",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/predicate_push_down.go#L223-L234 |
28,629 | chrislusf/gleam | util/row_codec.go | fieldsNotEmpty | func (z *Row) fieldsNotEmpty(isempty []bool) uint32 {
if len(isempty) == 0 {
return 3
}
var fieldsInUse uint32 = 3
isempty[0] = (len(z.K) == 0) // string, omitempty
if isempty[0] {
fieldsInUse--
}
isempty[1] = (len(z.V) == 0) // string, omitempty
if isempty[1] {
fieldsInUse--
}
isempty[2] = (z.T == 0) /... | go | func (z *Row) fieldsNotEmpty(isempty []bool) uint32 {
if len(isempty) == 0 {
return 3
}
var fieldsInUse uint32 = 3
isempty[0] = (len(z.K) == 0) // string, omitempty
if isempty[0] {
fieldsInUse--
}
isempty[1] = (len(z.V) == 0) // string, omitempty
if isempty[1] {
fieldsInUse--
}
isempty[2] = (z.T == 0) /... | [
"func",
"(",
"z",
"*",
"Row",
")",
"fieldsNotEmpty",
"(",
"isempty",
"[",
"]",
"bool",
")",
"uint32",
"{",
"if",
"len",
"(",
"isempty",
")",
"==",
"0",
"{",
"return",
"3",
"\n",
"}",
"\n",
"var",
"fieldsInUse",
"uint32",
"=",
"3",
"\n",
"isempty",
... | // fieldsNotEmpty supports omitempty tags | [
"fieldsNotEmpty",
"supports",
"omitempty",
"tags"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/util/row_codec.go#L145-L164 |
28,630 | chrislusf/gleam | sql/expression/constant_propagation.go | PropagateConstant | func PropagateConstant(ctx context.Context, conditions []Expression) []Expression {
solver := &propagateConstantSolver{
colMapper: make(map[string]int),
ctx: ctx,
}
return solver.solve(conditions)
} | go | func PropagateConstant(ctx context.Context, conditions []Expression) []Expression {
solver := &propagateConstantSolver{
colMapper: make(map[string]int),
ctx: ctx,
}
return solver.solve(conditions)
} | [
"func",
"PropagateConstant",
"(",
"ctx",
"context",
".",
"Context",
",",
"conditions",
"[",
"]",
"Expression",
")",
"[",
"]",
"Expression",
"{",
"solver",
":=",
"&",
"propagateConstantSolver",
"{",
"colMapper",
":",
"make",
"(",
"map",
"[",
"string",
"]",
... | // PropagateConstant propagate constant values of equality predicates and inequality predicates in a condition. | [
"PropagateConstant",
"propagate",
"constant",
"values",
"of",
"equality",
"predicates",
"and",
"inequality",
"predicates",
"in",
"a",
"condition",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/constant_propagation.go#L255-L261 |
28,631 | chrislusf/gleam | flow/dataset_sort_option.go | By | func (o *SortOption) By(index int, ascending bool) *SortOption {
order := instruction.Descending
if ascending {
order = instruction.Ascending
}
o.orderByList = append(o.orderByList, instruction.OrderBy{
Index: index,
Order: order,
})
return o
} | go | func (o *SortOption) By(index int, ascending bool) *SortOption {
order := instruction.Descending
if ascending {
order = instruction.Ascending
}
o.orderByList = append(o.orderByList, instruction.OrderBy{
Index: index,
Order: order,
})
return o
} | [
"func",
"(",
"o",
"*",
"SortOption",
")",
"By",
"(",
"index",
"int",
",",
"ascending",
"bool",
")",
"*",
"SortOption",
"{",
"order",
":=",
"instruction",
".",
"Descending",
"\n",
"if",
"ascending",
"{",
"order",
"=",
"instruction",
".",
"Ascending",
"\n"... | // OrderBy chains a list of sorting order by | [
"OrderBy",
"chains",
"a",
"list",
"of",
"sorting",
"order",
"by"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_sort_option.go#L41-L51 |
28,632 | chrislusf/gleam | flow/dataset_sort_option.go | Indexes | func (o *SortOption) Indexes() []int {
var ret []int
for _, x := range o.orderByList {
ret = append(ret, x.Index)
}
return ret
} | go | func (o *SortOption) Indexes() []int {
var ret []int
for _, x := range o.orderByList {
ret = append(ret, x.Index)
}
return ret
} | [
"func",
"(",
"o",
"*",
"SortOption",
")",
"Indexes",
"(",
")",
"[",
"]",
"int",
"{",
"var",
"ret",
"[",
"]",
"int",
"\n",
"for",
"_",
",",
"x",
":=",
"range",
"o",
".",
"orderByList",
"{",
"ret",
"=",
"append",
"(",
"ret",
",",
"x",
".",
"Ind... | // return a list of indexes | [
"return",
"a",
"list",
"of",
"indexes"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_sort_option.go#L54-L60 |
28,633 | chrislusf/gleam | sql/expression/schema.go | RetrieveColumn | func (s Schema) RetrieveColumn(col *Column) *Column {
index := s.GetColumnIndex(col)
if index != -1 {
return s.Columns[index]
}
return nil
} | go | func (s Schema) RetrieveColumn(col *Column) *Column {
index := s.GetColumnIndex(col)
if index != -1 {
return s.Columns[index]
}
return nil
} | [
"func",
"(",
"s",
"Schema",
")",
"RetrieveColumn",
"(",
"col",
"*",
"Column",
")",
"*",
"Column",
"{",
"index",
":=",
"s",
".",
"GetColumnIndex",
"(",
"col",
")",
"\n",
"if",
"index",
"!=",
"-",
"1",
"{",
"return",
"s",
".",
"Columns",
"[",
"index"... | // RetrieveColumn retrieves column in expression from the columns in schema. | [
"RetrieveColumn",
"retrieves",
"column",
"in",
"expression",
"from",
"the",
"columns",
"in",
"schema",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/schema.go#L97-L103 |
28,634 | chrislusf/gleam | sql/expression/schema.go | GetColumnIndex | func (s Schema) GetColumnIndex(col *Column) int {
for i, c := range s.Columns {
if c.FromID == col.FromID && c.Position == col.Position {
return i
}
}
return -1
} | go | func (s Schema) GetColumnIndex(col *Column) int {
for i, c := range s.Columns {
if c.FromID == col.FromID && c.Position == col.Position {
return i
}
}
return -1
} | [
"func",
"(",
"s",
"Schema",
")",
"GetColumnIndex",
"(",
"col",
"*",
"Column",
")",
"int",
"{",
"for",
"i",
",",
"c",
":=",
"range",
"s",
".",
"Columns",
"{",
"if",
"c",
".",
"FromID",
"==",
"col",
".",
"FromID",
"&&",
"c",
".",
"Position",
"==",
... | // GetColumnIndex finds the index for a column. | [
"GetColumnIndex",
"finds",
"the",
"index",
"for",
"a",
"column",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/schema.go#L106-L113 |
28,635 | chrislusf/gleam | sql/expression/schema.go | Append | func (s *Schema) Append(col *Column) {
s.Columns = append(s.Columns, col)
} | go | func (s *Schema) Append(col *Column) {
s.Columns = append(s.Columns, col)
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"Append",
"(",
"col",
"*",
"Column",
")",
"{",
"s",
".",
"Columns",
"=",
"append",
"(",
"s",
".",
"Columns",
",",
"col",
")",
"\n",
"}"
] | // Append append new column to the columns stored in schema. | [
"Append",
"append",
"new",
"column",
"to",
"the",
"columns",
"stored",
"in",
"schema",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/schema.go#L121-L123 |
28,636 | chrislusf/gleam | sql/expression/schema.go | GetColumnsIndices | func (s Schema) GetColumnsIndices(cols []*Column) (ret []int) {
ret = make([]int, 0, len(cols))
for _, col := range cols {
pos := s.GetColumnIndex(col)
if pos != -1 {
ret = append(ret, pos)
} else {
return nil
}
}
return
} | go | func (s Schema) GetColumnsIndices(cols []*Column) (ret []int) {
ret = make([]int, 0, len(cols))
for _, col := range cols {
pos := s.GetColumnIndex(col)
if pos != -1 {
ret = append(ret, pos)
} else {
return nil
}
}
return
} | [
"func",
"(",
"s",
"Schema",
")",
"GetColumnsIndices",
"(",
"cols",
"[",
"]",
"*",
"Column",
")",
"(",
"ret",
"[",
"]",
"int",
")",
"{",
"ret",
"=",
"make",
"(",
"[",
"]",
"int",
",",
"0",
",",
"len",
"(",
"cols",
")",
")",
"\n",
"for",
"_",
... | // GetColumnsIndices will return a slice which contains the position of each column in schema.
// If there is one column that doesn't match, nil will be returned. | [
"GetColumnsIndices",
"will",
"return",
"a",
"slice",
"which",
"contains",
"the",
"position",
"of",
"each",
"column",
"in",
"schema",
".",
"If",
"there",
"is",
"one",
"column",
"that",
"doesn",
"t",
"match",
"nil",
"will",
"be",
"returned",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/schema.go#L132-L143 |
28,637 | chrislusf/gleam | sql/expression/schema.go | MergeSchema | func MergeSchema(lSchema, rSchema Schema) Schema {
tmpL := lSchema.Clone()
tmpR := rSchema.Clone()
ret := NewSchema(append(tmpL.Columns, tmpR.Columns...))
ret.SetUniqueKeys(append(tmpL.Keys, tmpR.Keys...))
return ret
} | go | func MergeSchema(lSchema, rSchema Schema) Schema {
tmpL := lSchema.Clone()
tmpR := rSchema.Clone()
ret := NewSchema(append(tmpL.Columns, tmpR.Columns...))
ret.SetUniqueKeys(append(tmpL.Keys, tmpR.Keys...))
return ret
} | [
"func",
"MergeSchema",
"(",
"lSchema",
",",
"rSchema",
"Schema",
")",
"Schema",
"{",
"tmpL",
":=",
"lSchema",
".",
"Clone",
"(",
")",
"\n",
"tmpR",
":=",
"rSchema",
".",
"Clone",
"(",
")",
"\n",
"ret",
":=",
"NewSchema",
"(",
"append",
"(",
"tmpL",
"... | // MergeSchema will merge two schema into one schema. | [
"MergeSchema",
"will",
"merge",
"two",
"schema",
"into",
"one",
"schema",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/expression/schema.go#L146-L152 |
28,638 | chrislusf/gleam | flow/dataset_join_hash.go | HashJoin | func (bigger *Dataset) HashJoin(name string, smaller *Dataset, sortOption *SortOption) *Dataset {
return smaller.Broadcast(name, len(bigger.Shards)).LocalHashAndJoinWith(name, bigger, sortOption)
} | go | func (bigger *Dataset) HashJoin(name string, smaller *Dataset, sortOption *SortOption) *Dataset {
return smaller.Broadcast(name, len(bigger.Shards)).LocalHashAndJoinWith(name, bigger, sortOption)
} | [
"func",
"(",
"bigger",
"*",
"Dataset",
")",
"HashJoin",
"(",
"name",
"string",
",",
"smaller",
"*",
"Dataset",
",",
"sortOption",
"*",
"SortOption",
")",
"*",
"Dataset",
"{",
"return",
"smaller",
".",
"Broadcast",
"(",
"name",
",",
"len",
"(",
"bigger",
... | // HashJoin joins two datasets by putting the smaller dataset in memory on all
// executors and streams through the bigger dataset. | [
"HashJoin",
"joins",
"two",
"datasets",
"by",
"putting",
"the",
"smaller",
"dataset",
"in",
"memory",
"on",
"all",
"executors",
"and",
"streams",
"through",
"the",
"bigger",
"dataset",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_join_hash.go#L9-L11 |
28,639 | chrislusf/gleam | flow/dataset_join_hash.go | Broadcast | func (d *Dataset) Broadcast(name string, shardCount int) *Dataset {
if shardCount == 1 && len(d.Shards) == shardCount {
return d
}
ret := d.Flow.NewNextDataset(shardCount)
step := d.Flow.AddOneToAllStep(d, ret)
step.SetInstruction(name, instruction.NewBroadcast())
return ret
} | go | func (d *Dataset) Broadcast(name string, shardCount int) *Dataset {
if shardCount == 1 && len(d.Shards) == shardCount {
return d
}
ret := d.Flow.NewNextDataset(shardCount)
step := d.Flow.AddOneToAllStep(d, ret)
step.SetInstruction(name, instruction.NewBroadcast())
return ret
} | [
"func",
"(",
"d",
"*",
"Dataset",
")",
"Broadcast",
"(",
"name",
"string",
",",
"shardCount",
"int",
")",
"*",
"Dataset",
"{",
"if",
"shardCount",
"==",
"1",
"&&",
"len",
"(",
"d",
".",
"Shards",
")",
"==",
"shardCount",
"{",
"return",
"d",
"\n",
"... | // Broadcast replicates itself to all shards. | [
"Broadcast",
"replicates",
"itself",
"to",
"all",
"shards",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/flow/dataset_join_hash.go#L24-L32 |
28,640 | chrislusf/gleam | distributed/master/ui/svg_writer_helper.go | linelabel | func linelabel(canvas *svg.SVG, x1, y1, x2, y2 int, label string, mark string, d1 string, d2 string, dir string, color string) {
aw := linesize * 4
ah := linesize * 3
if len(color) == 0 {
color = lcolor
}
switch mark {
case "b":
lx1, ly1 := arrow(canvas, x1, y1, aw, ah, d1, color)
lx2, ly2 := arrow(canvas,... | go | func linelabel(canvas *svg.SVG, x1, y1, x2, y2 int, label string, mark string, d1 string, d2 string, dir string, color string) {
aw := linesize * 4
ah := linesize * 3
if len(color) == 0 {
color = lcolor
}
switch mark {
case "b":
lx1, ly1 := arrow(canvas, x1, y1, aw, ah, d1, color)
lx2, ly2 := arrow(canvas,... | [
"func",
"linelabel",
"(",
"canvas",
"*",
"svg",
".",
"SVG",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
"int",
",",
"label",
"string",
",",
"mark",
"string",
",",
"d1",
"string",
",",
"d2",
"string",
",",
"dir",
"string",
",",
"color",
"string",
... | // linelabel determines the connection and arrow geometry | [
"linelabel",
"determines",
"the",
"connection",
"and",
"arrow",
"geometry"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/master/ui/svg_writer_helper.go#L65-L89 |
28,641 | chrislusf/gleam | distributed/master/ui/svg_writer_helper.go | arrow | func arrow(canvas *svg.SVG, x, y, w, h int, dir string, color string) (xl, yl int) {
var xp = []int{x, x, x, x}
var yp = []int{y, y, y, y}
n := notchsize
switch dir {
case "r":
xp[1] = x - w
yp[1] = y - h/2
xp[2] = (x - w) + n
yp[2] = y
xp[3] = x - w
yp[3] = y + h/2
xl, yl = xp[2], y
case "l":
xp... | go | func arrow(canvas *svg.SVG, x, y, w, h int, dir string, color string) (xl, yl int) {
var xp = []int{x, x, x, x}
var yp = []int{y, y, y, y}
n := notchsize
switch dir {
case "r":
xp[1] = x - w
yp[1] = y - h/2
xp[2] = (x - w) + n
yp[2] = y
xp[3] = x - w
yp[3] = y + h/2
xl, yl = xp[2], y
case "l":
xp... | [
"func",
"arrow",
"(",
"canvas",
"*",
"svg",
".",
"SVG",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
"int",
",",
"dir",
"string",
",",
"color",
"string",
")",
"(",
"xl",
",",
"yl",
"int",
")",
"{",
"var",
"xp",
"=",
"[",
"]",
"int",
"{",
"x",
... | // arrow constructs line-ending arrows according to connecting points | [
"arrow",
"constructs",
"line",
"-",
"ending",
"arrows",
"according",
"to",
"connecting",
"points"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/master/ui/svg_writer_helper.go#L97-L138 |
28,642 | chrislusf/gleam | distributed/master/ui/svg_writer_helper.go | doline | func doline(canvas *svg.SVG, x1, y1, x2, y2 int, style, direction, label string) {
var labelstyle string
var upflag bool
tadjust := 6
mx := (x2 - x1) / 2
my := (y2 - y1) / 2
lx := x1 + mx
ly := y1 + my
m, _ := sloper(x1, y1, x2, y2)
hline := m == 0
vline := m == math.Inf(-1) || m == math.Inf(1)
straight := ... | go | func doline(canvas *svg.SVG, x1, y1, x2, y2 int, style, direction, label string) {
var labelstyle string
var upflag bool
tadjust := 6
mx := (x2 - x1) / 2
my := (y2 - y1) / 2
lx := x1 + mx
ly := y1 + my
m, _ := sloper(x1, y1, x2, y2)
hline := m == 0
vline := m == math.Inf(-1) || m == math.Inf(1)
straight := ... | [
"func",
"doline",
"(",
"canvas",
"*",
"svg",
".",
"SVG",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
"int",
",",
"style",
",",
"direction",
",",
"label",
"string",
")",
"{",
"var",
"labelstyle",
"string",
"\n",
"var",
"upflag",
"bool",
"\n\n",
"tad... | // doline draws a line between to coordinates | [
"doline",
"draws",
"a",
"line",
"between",
"to",
"coordinates"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/master/ui/svg_writer_helper.go#L141-L191 |
28,643 | chrislusf/gleam | distributed/master/ui/svg_writer_helper.go | sloper | func sloper(x1, y1, x2, y2 int) (m, r float64) {
dy := float64(y1 - y2)
dx := float64(x1 - x2)
m = dy / dx
r = math.Atan2(dy, dx) * (180 / math.Pi)
return m, r
} | go | func sloper(x1, y1, x2, y2 int) (m, r float64) {
dy := float64(y1 - y2)
dx := float64(x1 - x2)
m = dy / dx
r = math.Atan2(dy, dx) * (180 / math.Pi)
return m, r
} | [
"func",
"sloper",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
"int",
")",
"(",
"m",
",",
"r",
"float64",
")",
"{",
"dy",
":=",
"float64",
"(",
"y1",
"-",
"y2",
")",
"\n",
"dx",
":=",
"float64",
"(",
"x1",
"-",
"x2",
")",
"\n",
"m",
"=",
"... | // sloper computes the slope and r of a line | [
"sloper",
"computes",
"the",
"slope",
"and",
"r",
"of",
"a",
"line"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/master/ui/svg_writer_helper.go#L194-L200 |
28,644 | chrislusf/gleam | gio/map_reduce.go | RegisterMapper | func RegisterMapper(fn Mapper) MapperId {
mappersLock.Lock()
defer mappersLock.Unlock()
mapperId := MapperId(fmt.Sprintf("m%d", len(mappers)+1))
mappers[mapperId] = MapperObject{fn, runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name()}
return mapperId
} | go | func RegisterMapper(fn Mapper) MapperId {
mappersLock.Lock()
defer mappersLock.Unlock()
mapperId := MapperId(fmt.Sprintf("m%d", len(mappers)+1))
mappers[mapperId] = MapperObject{fn, runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name()}
return mapperId
} | [
"func",
"RegisterMapper",
"(",
"fn",
"Mapper",
")",
"MapperId",
"{",
"mappersLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mappersLock",
".",
"Unlock",
"(",
")",
"\n\n",
"mapperId",
":=",
"MapperId",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l... | // RegisterMapper register a mapper function to process a command | [
"RegisterMapper",
"register",
"a",
"mapper",
"function",
"to",
"process",
"a",
"command"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/gio/map_reduce.go#L75-L83 |
28,645 | chrislusf/gleam | gio/map_reduce.go | ListRegisteredFunctions | func ListRegisteredFunctions() {
for k, fn := range mappers {
println(k, "=>", fn.Name)
}
for k, fn := range reducers {
println(k, "=>", fn.Name)
}
} | go | func ListRegisteredFunctions() {
for k, fn := range mappers {
println(k, "=>", fn.Name)
}
for k, fn := range reducers {
println(k, "=>", fn.Name)
}
} | [
"func",
"ListRegisteredFunctions",
"(",
")",
"{",
"for",
"k",
",",
"fn",
":=",
"range",
"mappers",
"{",
"println",
"(",
"k",
",",
"\"",
"\"",
",",
"fn",
".",
"Name",
")",
"\n",
"}",
"\n",
"for",
"k",
",",
"fn",
":=",
"range",
"reducers",
"{",
"pr... | // ListRegisteredFunctions lists out all registered mappers and reducers | [
"ListRegisteredFunctions",
"lists",
"out",
"all",
"registered",
"mappers",
"and",
"reducers"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/gio/map_reduce.go#L129-L136 |
28,646 | chrislusf/gleam | sql/plan/plan.go | getHashKey | func (p *requiredProperty) getHashKey() ([]byte, error) {
datums := make([]types.Datum, 0, len(p.props)*3+1)
datums = append(datums, types.NewDatum(p.sortKeyLen))
for _, c := range p.props {
datums = append(datums, types.NewDatum(c.desc), types.NewDatum(c.col.FromID), types.NewDatum(c.col.Index))
}
bytes, err :=... | go | func (p *requiredProperty) getHashKey() ([]byte, error) {
datums := make([]types.Datum, 0, len(p.props)*3+1)
datums = append(datums, types.NewDatum(p.sortKeyLen))
for _, c := range p.props {
datums = append(datums, types.NewDatum(c.desc), types.NewDatum(c.col.FromID), types.NewDatum(c.col.Index))
}
bytes, err :=... | [
"func",
"(",
"p",
"*",
"requiredProperty",
")",
"getHashKey",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"datums",
":=",
"make",
"(",
"[",
"]",
"types",
".",
"Datum",
",",
"0",
",",
"len",
"(",
"p",
".",
"props",
")",
"*",
"3",
... | // getHashKey encodes a requiredProperty to a unique hash code. | [
"getHashKey",
"encodes",
"a",
"requiredProperty",
"to",
"a",
"unique",
"hash",
"code",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/plan.go#L132-L140 |
28,647 | chrislusf/gleam | sql/plan/plan.go | ResolveIndicesAndCorCols | func (p *baseLogicalPlan) ResolveIndicesAndCorCols() {
for _, child := range p.children {
child.(LogicalPlan).ResolveIndicesAndCorCols()
}
} | go | func (p *baseLogicalPlan) ResolveIndicesAndCorCols() {
for _, child := range p.children {
child.(LogicalPlan).ResolveIndicesAndCorCols()
}
} | [
"func",
"(",
"p",
"*",
"baseLogicalPlan",
")",
"ResolveIndicesAndCorCols",
"(",
")",
"{",
"for",
"_",
",",
"child",
":=",
"range",
"p",
".",
"children",
"{",
"child",
".",
"(",
"LogicalPlan",
")",
".",
"ResolveIndicesAndCorCols",
"(",
")",
"\n",
"}",
"\n... | // ResolveIndicesAndCorCols implements LogicalPlan interface. | [
"ResolveIndicesAndCorCols",
"implements",
"LogicalPlan",
"interface",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/plan.go#L293-L297 |
28,648 | chrislusf/gleam | sql/plan/plan.go | AddParent | func (p *basePlan) AddParent(parent Plan) {
p.parents = append(p.parents, parent)
} | go | func (p *basePlan) AddParent(parent Plan) {
p.parents = append(p.parents, parent)
} | [
"func",
"(",
"p",
"*",
"basePlan",
")",
"AddParent",
"(",
"parent",
"Plan",
")",
"{",
"p",
".",
"parents",
"=",
"append",
"(",
"p",
".",
"parents",
",",
"parent",
")",
"\n",
"}"
] | // AddParent implements Plan AddParent interface. | [
"AddParent",
"implements",
"Plan",
"AddParent",
"interface",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/plan.go#L372-L374 |
28,649 | chrislusf/gleam | sql/plan/plan.go | AddChild | func (p *basePlan) AddChild(child Plan) {
p.children = append(p.children, child)
} | go | func (p *basePlan) AddChild(child Plan) {
p.children = append(p.children, child)
} | [
"func",
"(",
"p",
"*",
"basePlan",
")",
"AddChild",
"(",
"child",
"Plan",
")",
"{",
"p",
".",
"children",
"=",
"append",
"(",
"p",
".",
"children",
",",
"child",
")",
"\n",
"}"
] | // AddChild implements Plan AddChild interface. | [
"AddChild",
"implements",
"Plan",
"AddChild",
"interface",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/plan.go#L377-L379 |
28,650 | chrislusf/gleam | sql/plan/plan.go | ReplaceParent | func (p *basePlan) ReplaceParent(parent, newPar Plan) error {
for i, par := range p.parents {
if par.GetID() == parent.GetID() {
p.parents[i] = newPar
return nil
}
}
return SystemInternalErrorType.Gen("ReplaceParent Failed!")
} | go | func (p *basePlan) ReplaceParent(parent, newPar Plan) error {
for i, par := range p.parents {
if par.GetID() == parent.GetID() {
p.parents[i] = newPar
return nil
}
}
return SystemInternalErrorType.Gen("ReplaceParent Failed!")
} | [
"func",
"(",
"p",
"*",
"basePlan",
")",
"ReplaceParent",
"(",
"parent",
",",
"newPar",
"Plan",
")",
"error",
"{",
"for",
"i",
",",
"par",
":=",
"range",
"p",
".",
"parents",
"{",
"if",
"par",
".",
"GetID",
"(",
")",
"==",
"parent",
".",
"GetID",
... | // ReplaceParent means replace a parent for another one. | [
"ReplaceParent",
"means",
"replace",
"a",
"parent",
"for",
"another",
"one",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/plan.go#L382-L390 |
28,651 | chrislusf/gleam | sql/plan/plan.go | ReplaceChild | func (p *basePlan) ReplaceChild(child, newChild Plan) error {
for i, ch := range p.children {
if ch.GetID() == child.GetID() {
p.children[i] = newChild
return nil
}
}
return SystemInternalErrorType.Gen("ReplaceChildren Failed!")
} | go | func (p *basePlan) ReplaceChild(child, newChild Plan) error {
for i, ch := range p.children {
if ch.GetID() == child.GetID() {
p.children[i] = newChild
return nil
}
}
return SystemInternalErrorType.Gen("ReplaceChildren Failed!")
} | [
"func",
"(",
"p",
"*",
"basePlan",
")",
"ReplaceChild",
"(",
"child",
",",
"newChild",
"Plan",
")",
"error",
"{",
"for",
"i",
",",
"ch",
":=",
"range",
"p",
".",
"children",
"{",
"if",
"ch",
".",
"GetID",
"(",
")",
"==",
"child",
".",
"GetID",
"(... | // ReplaceChild means replace a child with another one. | [
"ReplaceChild",
"means",
"replace",
"a",
"child",
"with",
"another",
"one",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/plan.go#L393-L401 |
28,652 | chrislusf/gleam | sql/plan/plan.go | GetParentByIndex | func (p *basePlan) GetParentByIndex(index int) (parent Plan) {
if index < len(p.parents) && index >= 0 {
return p.parents[index]
}
return nil
} | go | func (p *basePlan) GetParentByIndex(index int) (parent Plan) {
if index < len(p.parents) && index >= 0 {
return p.parents[index]
}
return nil
} | [
"func",
"(",
"p",
"*",
"basePlan",
")",
"GetParentByIndex",
"(",
"index",
"int",
")",
"(",
"parent",
"Plan",
")",
"{",
"if",
"index",
"<",
"len",
"(",
"p",
".",
"parents",
")",
"&&",
"index",
">=",
"0",
"{",
"return",
"p",
".",
"parents",
"[",
"i... | // GetParentByIndex implements Plan GetParentByIndex interface. | [
"GetParentByIndex",
"implements",
"Plan",
"GetParentByIndex",
"interface",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/plan.go#L404-L409 |
28,653 | chrislusf/gleam | sql/plan/plan.go | GetChildByIndex | func (p *basePlan) GetChildByIndex(index int) (parent Plan) {
if index < len(p.children) && index >= 0 {
return p.children[index]
}
return nil
} | go | func (p *basePlan) GetChildByIndex(index int) (parent Plan) {
if index < len(p.children) && index >= 0 {
return p.children[index]
}
return nil
} | [
"func",
"(",
"p",
"*",
"basePlan",
")",
"GetChildByIndex",
"(",
"index",
"int",
")",
"(",
"parent",
"Plan",
")",
"{",
"if",
"index",
"<",
"len",
"(",
"p",
".",
"children",
")",
"&&",
"index",
">=",
"0",
"{",
"return",
"p",
".",
"children",
"[",
"... | // GetChildByIndex implements Plan GetChildByIndex interface. | [
"GetChildByIndex",
"implements",
"Plan",
"GetChildByIndex",
"interface",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/plan/plan.go#L412-L417 |
28,654 | chrislusf/gleam | distributed/agent/agent_server.go | serveTcp | func (as *AgentServer) serveTcp(listener net.Listener) {
for {
// Listen for an incoming connection.
conn, err := listener.Accept()
if err != nil {
fmt.Println("Error accepting: ", err.Error())
continue
}
// Handle connections in a new goroutine.
go func() {
defer conn.Close()
if err = conn.Se... | go | func (as *AgentServer) serveTcp(listener net.Listener) {
for {
// Listen for an incoming connection.
conn, err := listener.Accept()
if err != nil {
fmt.Println("Error accepting: ", err.Error())
continue
}
// Handle connections in a new goroutine.
go func() {
defer conn.Close()
if err = conn.Se... | [
"func",
"(",
"as",
"*",
"AgentServer",
")",
"serveTcp",
"(",
"listener",
"net",
".",
"Listener",
")",
"{",
"for",
"{",
"// Listen for an incoming connection.",
"conn",
",",
"err",
":=",
"listener",
".",
"Accept",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // Run starts the heartbeating to master and starts accepting requests. | [
"Run",
"starts",
"the",
"heartbeating",
"to",
"master",
"and",
"starts",
"accepting",
"requests",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/distributed/agent/agent_server.go#L104-L125 |
28,655 | chrislusf/gleam | sql/util/types/etc.go | IsTypeBlob | func IsTypeBlob(tp byte) bool {
switch tp {
case mysql.TypeTinyBlob, mysql.TypeMediumBlob, mysql.TypeBlob, mysql.TypeLongBlob:
return true
default:
return false
}
} | go | func IsTypeBlob(tp byte) bool {
switch tp {
case mysql.TypeTinyBlob, mysql.TypeMediumBlob, mysql.TypeBlob, mysql.TypeLongBlob:
return true
default:
return false
}
} | [
"func",
"IsTypeBlob",
"(",
"tp",
"byte",
")",
"bool",
"{",
"switch",
"tp",
"{",
"case",
"mysql",
".",
"TypeTinyBlob",
",",
"mysql",
".",
"TypeMediumBlob",
",",
"mysql",
".",
"TypeBlob",
",",
"mysql",
".",
"TypeLongBlob",
":",
"return",
"true",
"\n",
"def... | // IsTypeBlob returns a boolean indicating whether the tp is a blob type. | [
"IsTypeBlob",
"returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"tp",
"is",
"a",
"blob",
"type",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/etc.go#L32-L39 |
28,656 | chrislusf/gleam | sql/util/types/etc.go | IsTypeChar | func IsTypeChar(tp byte) bool {
switch tp {
case mysql.TypeString, mysql.TypeVarchar:
return true
default:
return false
}
} | go | func IsTypeChar(tp byte) bool {
switch tp {
case mysql.TypeString, mysql.TypeVarchar:
return true
default:
return false
}
} | [
"func",
"IsTypeChar",
"(",
"tp",
"byte",
")",
"bool",
"{",
"switch",
"tp",
"{",
"case",
"mysql",
".",
"TypeString",
",",
"mysql",
".",
"TypeVarchar",
":",
"return",
"true",
"\n",
"default",
":",
"return",
"false",
"\n",
"}",
"\n",
"}"
] | // IsTypeChar returns a boolean indicating
// whether the tp is the char type like a string type or a varchar type. | [
"IsTypeChar",
"returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"tp",
"is",
"the",
"char",
"type",
"like",
"a",
"string",
"type",
"or",
"a",
"varchar",
"type",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/etc.go#L43-L50 |
28,657 | chrislusf/gleam | sql/util/types/etc.go | overflow | func overflow(v interface{}, tp byte) error {
return errors.Errorf("constant %v overflows %s", v, TypeStr(tp))
} | go | func overflow(v interface{}, tp byte) error {
return errors.Errorf("constant %v overflows %s", v, TypeStr(tp))
} | [
"func",
"overflow",
"(",
"v",
"interface",
"{",
"}",
",",
"tp",
"byte",
")",
"error",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"v",
",",
"TypeStr",
"(",
"tp",
")",
")",
"\n",
"}"
] | // Overflow returns an overflowed error. | [
"Overflow",
"returns",
"an",
"overflowed",
"error",
"."
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/sql/util/types/etc.go#L132-L134 |
28,658 | chrislusf/gleam | instruction/select.go | DoSelect | func DoSelect(reader io.Reader, writer io.Writer, keyIndexes, valueIndexes []int, stats *pb.InstructionStat) error {
return util.ProcessRow(reader, nil, func(row *util.Row) error {
stats.InputCounter++
var keys, values []interface{}
kLen := len(row.K)
for _, x := range keyIndexes {
if x <= kLen {
keys... | go | func DoSelect(reader io.Reader, writer io.Writer, keyIndexes, valueIndexes []int, stats *pb.InstructionStat) error {
return util.ProcessRow(reader, nil, func(row *util.Row) error {
stats.InputCounter++
var keys, values []interface{}
kLen := len(row.K)
for _, x := range keyIndexes {
if x <= kLen {
keys... | [
"func",
"DoSelect",
"(",
"reader",
"io",
".",
"Reader",
",",
"writer",
"io",
".",
"Writer",
",",
"keyIndexes",
",",
"valueIndexes",
"[",
"]",
"int",
",",
"stats",
"*",
"pb",
".",
"InstructionStat",
")",
"error",
"{",
"return",
"util",
".",
"ProcessRow",
... | // DoSelect projects the fields | [
"DoSelect",
"projects",
"the",
"fields"
] | a7aa467b545f5e5e452aaf818299a5f6e6b23760 | https://github.com/chrislusf/gleam/blob/a7aa467b545f5e5e452aaf818299a5f6e6b23760/instruction/select.go#L57-L86 |
28,659 | gojektech/heimdall | retry.go | NextInterval | func (r *retrier) NextInterval(retry int) time.Duration {
return r.backoff.Next(retry)
} | go | func (r *retrier) NextInterval(retry int) time.Duration {
return r.backoff.Next(retry)
} | [
"func",
"(",
"r",
"*",
"retrier",
")",
"NextInterval",
"(",
"retry",
"int",
")",
"time",
".",
"Duration",
"{",
"return",
"r",
".",
"backoff",
".",
"Next",
"(",
"retry",
")",
"\n",
"}"
] | // NextInterval returns next retriable time | [
"NextInterval",
"returns",
"next",
"retriable",
"time"
] | ef69e0bb0cbf72e832303efe6362855811e8cc89 | https://github.com/gojektech/heimdall/blob/ef69e0bb0cbf72e832303efe6362855811e8cc89/retry.go#L36-L38 |
28,660 | gojektech/heimdall | hystrix/options.go | WithHTTPTimeout | func WithHTTPTimeout(timeout time.Duration) Option {
return func(c *Client) {
c.timeout = timeout
}
} | go | func WithHTTPTimeout(timeout time.Duration) Option {
return func(c *Client) {
c.timeout = timeout
}
} | [
"func",
"WithHTTPTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"func",
"(",
"c",
"*",
"Client",
")",
"{",
"c",
".",
"timeout",
"=",
"timeout",
"\n",
"}",
"\n",
"}"
] | // WithHTTPTimeout sets hystrix timeout | [
"WithHTTPTimeout",
"sets",
"hystrix",
"timeout"
] | ef69e0bb0cbf72e832303efe6362855811e8cc89 | https://github.com/gojektech/heimdall/blob/ef69e0bb0cbf72e832303efe6362855811e8cc89/hystrix/options.go#L20-L24 |
28,661 | gojektech/heimdall | hystrix/options.go | WithHystrixTimeout | func WithHystrixTimeout(timeout time.Duration) Option {
return func(c *Client) {
c.hystrixTimeout = timeout
}
} | go | func WithHystrixTimeout(timeout time.Duration) Option {
return func(c *Client) {
c.hystrixTimeout = timeout
}
} | [
"func",
"WithHystrixTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"func",
"(",
"c",
"*",
"Client",
")",
"{",
"c",
".",
"hystrixTimeout",
"=",
"timeout",
"\n",
"}",
"\n",
"}"
] | // WithHystrixTimeout sets hystrix timeout | [
"WithHystrixTimeout",
"sets",
"hystrix",
"timeout"
] | ef69e0bb0cbf72e832303efe6362855811e8cc89 | https://github.com/gojektech/heimdall/blob/ef69e0bb0cbf72e832303efe6362855811e8cc89/hystrix/options.go#L27-L31 |
28,662 | gojektech/heimdall | hystrix/options.go | WithRetrier | func WithRetrier(retrier heimdall.Retriable) Option {
return func(c *Client) {
c.retrier = retrier
}
} | go | func WithRetrier(retrier heimdall.Retriable) Option {
return func(c *Client) {
c.retrier = retrier
}
} | [
"func",
"WithRetrier",
"(",
"retrier",
"heimdall",
".",
"Retriable",
")",
"Option",
"{",
"return",
"func",
"(",
"c",
"*",
"Client",
")",
"{",
"c",
".",
"retrier",
"=",
"retrier",
"\n",
"}",
"\n",
"}"
] | // WithRetrier sets the strategy for retrying | [
"WithRetrier",
"sets",
"the",
"strategy",
"for",
"retrying"
] | ef69e0bb0cbf72e832303efe6362855811e8cc89 | https://github.com/gojektech/heimdall/blob/ef69e0bb0cbf72e832303efe6362855811e8cc89/hystrix/options.go#L76-L80 |
28,663 | gojektech/heimdall | hystrix/options.go | WithHTTPClient | func WithHTTPClient(client heimdall.Doer) Option {
return func(c *Client) {
c.client = client
}
} | go | func WithHTTPClient(client heimdall.Doer) Option {
return func(c *Client) {
c.client = client
}
} | [
"func",
"WithHTTPClient",
"(",
"client",
"heimdall",
".",
"Doer",
")",
"Option",
"{",
"return",
"func",
"(",
"c",
"*",
"Client",
")",
"{",
"c",
".",
"client",
"=",
"client",
"\n",
"}",
"\n",
"}"
] | // WithHTTPClient sets a custom http client for hystrix client | [
"WithHTTPClient",
"sets",
"a",
"custom",
"http",
"client",
"for",
"hystrix",
"client"
] | ef69e0bb0cbf72e832303efe6362855811e8cc89 | https://github.com/gojektech/heimdall/blob/ef69e0bb0cbf72e832303efe6362855811e8cc89/hystrix/options.go#L83-L87 |
28,664 | gojektech/heimdall | httpclient/client.go | NewClient | func NewClient(opts ...Option) *Client {
client := Client{
timeout: defaultHTTPTimeout,
retryCount: defaultRetryCount,
retrier: heimdall.NewNoRetrier(),
}
for _, opt := range opts {
opt(&client)
}
if client.client == nil {
client.client = &http.Client{
Timeout: client.timeout,
}
}
return ... | go | func NewClient(opts ...Option) *Client {
client := Client{
timeout: defaultHTTPTimeout,
retryCount: defaultRetryCount,
retrier: heimdall.NewNoRetrier(),
}
for _, opt := range opts {
opt(&client)
}
if client.client == nil {
client.client = &http.Client{
Timeout: client.timeout,
}
}
return ... | [
"func",
"NewClient",
"(",
"opts",
"...",
"Option",
")",
"*",
"Client",
"{",
"client",
":=",
"Client",
"{",
"timeout",
":",
"defaultHTTPTimeout",
",",
"retryCount",
":",
"defaultRetryCount",
",",
"retrier",
":",
"heimdall",
".",
"NewNoRetrier",
"(",
")",
",",... | // NewClient returns a new instance of http Client | [
"NewClient",
"returns",
"a",
"new",
"instance",
"of",
"http",
"Client"
] | ef69e0bb0cbf72e832303efe6362855811e8cc89 | https://github.com/gojektech/heimdall/blob/ef69e0bb0cbf72e832303efe6362855811e8cc89/httpclient/client.go#L32-L50 |
28,665 | gojektech/heimdall | backoff.go | Next | func (cb *constantBackoff) Next(retry int) time.Duration {
if retry <= 0 {
return 0 * time.Millisecond
}
return (time.Duration(cb.backoffInterval) * time.Millisecond) + (time.Duration(rand.Int63n(cb.maximumJitterInterval)) * time.Millisecond)
} | go | func (cb *constantBackoff) Next(retry int) time.Duration {
if retry <= 0 {
return 0 * time.Millisecond
}
return (time.Duration(cb.backoffInterval) * time.Millisecond) + (time.Duration(rand.Int63n(cb.maximumJitterInterval)) * time.Millisecond)
} | [
"func",
"(",
"cb",
"*",
"constantBackoff",
")",
"Next",
"(",
"retry",
"int",
")",
"time",
".",
"Duration",
"{",
"if",
"retry",
"<=",
"0",
"{",
"return",
"0",
"*",
"time",
".",
"Millisecond",
"\n",
"}",
"\n",
"return",
"(",
"time",
".",
"Duration",
... | // Next returns next time for retrying operation with constant strategy | [
"Next",
"returns",
"next",
"time",
"for",
"retrying",
"operation",
"with",
"constant",
"strategy"
] | ef69e0bb0cbf72e832303efe6362855811e8cc89 | https://github.com/gojektech/heimdall/blob/ef69e0bb0cbf72e832303efe6362855811e8cc89/backoff.go#L33-L38 |
28,666 | gojektech/heimdall | backoff.go | Next | func (eb *exponentialBackoff) Next(retry int) time.Duration {
if retry <= 0 {
return 0 * time.Millisecond
}
return time.Duration(math.Min(eb.initialTimeout+math.Pow(eb.exponentFactor, float64(retry)), eb.maxTimeout)+float64(rand.Int63n(eb.maximumJitterInterval))) * time.Millisecond
} | go | func (eb *exponentialBackoff) Next(retry int) time.Duration {
if retry <= 0 {
return 0 * time.Millisecond
}
return time.Duration(math.Min(eb.initialTimeout+math.Pow(eb.exponentFactor, float64(retry)), eb.maxTimeout)+float64(rand.Int63n(eb.maximumJitterInterval))) * time.Millisecond
} | [
"func",
"(",
"eb",
"*",
"exponentialBackoff",
")",
"Next",
"(",
"retry",
"int",
")",
"time",
".",
"Duration",
"{",
"if",
"retry",
"<=",
"0",
"{",
"return",
"0",
"*",
"time",
".",
"Millisecond",
"\n",
"}",
"\n",
"return",
"time",
".",
"Duration",
"(",... | // Next returns next time for retrying operation with exponential strategy | [
"Next",
"returns",
"next",
"time",
"for",
"retrying",
"operation",
"with",
"exponential",
"strategy"
] | ef69e0bb0cbf72e832303efe6362855811e8cc89 | https://github.com/gojektech/heimdall/blob/ef69e0bb0cbf72e832303efe6362855811e8cc89/backoff.go#L59-L64 |
28,667 | gojektech/heimdall | hystrix/hystrix_client.go | NewClient | func NewClient(opts ...Option) *Client {
client := Client{
timeout: defaultHTTPTimeout,
hystrixTimeout: defaultHystrixTimeout,
maxConcurrentRequests: defaultMaxConcurrentRequests,
errorPercentThreshold: defaultErrorPercentThreshold,
sleepWindow: defaultSleepWindow,
reque... | go | func NewClient(opts ...Option) *Client {
client := Client{
timeout: defaultHTTPTimeout,
hystrixTimeout: defaultHystrixTimeout,
maxConcurrentRequests: defaultMaxConcurrentRequests,
errorPercentThreshold: defaultErrorPercentThreshold,
sleepWindow: defaultSleepWindow,
reque... | [
"func",
"NewClient",
"(",
"opts",
"...",
"Option",
")",
"*",
"Client",
"{",
"client",
":=",
"Client",
"{",
"timeout",
":",
"defaultHTTPTimeout",
",",
"hystrixTimeout",
":",
"defaultHystrixTimeout",
",",
"maxConcurrentRequests",
":",
"defaultMaxConcurrentRequests",
"... | // NewClient returns a new instance of hystrix Client | [
"NewClient",
"returns",
"a",
"new",
"instance",
"of",
"hystrix",
"Client"
] | ef69e0bb0cbf72e832303efe6362855811e8cc89 | https://github.com/gojektech/heimdall/blob/ef69e0bb0cbf72e832303efe6362855811e8cc89/hystrix/hystrix_client.go#L50-L81 |
28,668 | gojektech/heimdall | hystrix/hystrix_client.go | Patch | func (hhc *Client) Patch(url string, body io.Reader, headers http.Header) (*http.Response, error) {
var response *http.Response
request, err := http.NewRequest(http.MethodPatch, url, body)
if err != nil {
return response, errors.Wrap(err, "PATCH - request creation failed")
}
request.Header = headers
return hh... | go | func (hhc *Client) Patch(url string, body io.Reader, headers http.Header) (*http.Response, error) {
var response *http.Response
request, err := http.NewRequest(http.MethodPatch, url, body)
if err != nil {
return response, errors.Wrap(err, "PATCH - request creation failed")
}
request.Header = headers
return hh... | [
"func",
"(",
"hhc",
"*",
"Client",
")",
"Patch",
"(",
"url",
"string",
",",
"body",
"io",
".",
"Reader",
",",
"headers",
"http",
".",
"Header",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"var",
"response",
"*",
"http",
".",
"... | // Patch makes a HTTP PATCH request to provided URL and requestBody | [
"Patch",
"makes",
"a",
"HTTP",
"PATCH",
"request",
"to",
"provided",
"URL",
"and",
"requestBody"
] | ef69e0bb0cbf72e832303efe6362855811e8cc89 | https://github.com/gojektech/heimdall/blob/ef69e0bb0cbf72e832303efe6362855811e8cc89/hystrix/hystrix_client.go#L135-L145 |
28,669 | gojektech/heimdall | hystrix/hystrix_client.go | Delete | func (hhc *Client) Delete(url string, headers http.Header) (*http.Response, error) {
var response *http.Response
request, err := http.NewRequest(http.MethodDelete, url, nil)
if err != nil {
return response, errors.Wrap(err, "DELETE - request creation failed")
}
request.Header = headers
return hhc.Do(request)
... | go | func (hhc *Client) Delete(url string, headers http.Header) (*http.Response, error) {
var response *http.Response
request, err := http.NewRequest(http.MethodDelete, url, nil)
if err != nil {
return response, errors.Wrap(err, "DELETE - request creation failed")
}
request.Header = headers
return hhc.Do(request)
... | [
"func",
"(",
"hhc",
"*",
"Client",
")",
"Delete",
"(",
"url",
"string",
",",
"headers",
"http",
".",
"Header",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"var",
"response",
"*",
"http",
".",
"Response",
"\n",
"request",
",",
"e... | // Delete makes a HTTP DELETE request with provided URL | [
"Delete",
"makes",
"a",
"HTTP",
"DELETE",
"request",
"with",
"provided",
"URL"
] | ef69e0bb0cbf72e832303efe6362855811e8cc89 | https://github.com/gojektech/heimdall/blob/ef69e0bb0cbf72e832303efe6362855811e8cc89/hystrix/hystrix_client.go#L148-L158 |
28,670 | gopasspw/gopass | pkg/clipboard/clipboard.go | CopyTo | func CopyTo(ctx context.Context, name string, content []byte) error {
if clipboard.Unsupported {
out.Yellow(ctx, "%s", ErrNotSupported)
return nil
}
if err := clipboard.WriteAll(string(content)); err != nil {
return errors.Wrapf(err, "failed to write to clipboard")
}
if err := clear(ctx, content, ctxutil.G... | go | func CopyTo(ctx context.Context, name string, content []byte) error {
if clipboard.Unsupported {
out.Yellow(ctx, "%s", ErrNotSupported)
return nil
}
if err := clipboard.WriteAll(string(content)); err != nil {
return errors.Wrapf(err, "failed to write to clipboard")
}
if err := clear(ctx, content, ctxutil.G... | [
"func",
"CopyTo",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"content",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"clipboard",
".",
"Unsupported",
"{",
"out",
".",
"Yellow",
"(",
"ctx",
",",
"\"",
"\"",
",",
"ErrNotSupported",
... | // CopyTo copies the given data to the clipboard and enqueues automatic
// clearing of the clipboard | [
"CopyTo",
"copies",
"the",
"given",
"data",
"to",
"the",
"clipboard",
"and",
"enqueues",
"automatic",
"clearing",
"of",
"the",
"clipboard"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/clipboard/clipboard.go#L23-L39 |
28,671 | gopasspw/gopass | pkg/store/sub/crypto.go | GetCryptoBackend | func GetCryptoBackend(ctx context.Context, cb backend.CryptoBackend, cfgdir string, agent *client.Client) (backend.Crypto, error) {
ctx = client.WithClient(ctx, agent)
ctx = ctxutil.WithConfigDir(ctx, cfgdir)
crypto, err := backend.NewCrypto(ctx, cb)
if err != nil {
return nil, errors.Wrapf(err, "unknown crypto b... | go | func GetCryptoBackend(ctx context.Context, cb backend.CryptoBackend, cfgdir string, agent *client.Client) (backend.Crypto, error) {
ctx = client.WithClient(ctx, agent)
ctx = ctxutil.WithConfigDir(ctx, cfgdir)
crypto, err := backend.NewCrypto(ctx, cb)
if err != nil {
return nil, errors.Wrapf(err, "unknown crypto b... | [
"func",
"GetCryptoBackend",
"(",
"ctx",
"context",
".",
"Context",
",",
"cb",
"backend",
".",
"CryptoBackend",
",",
"cfgdir",
"string",
",",
"agent",
"*",
"client",
".",
"Client",
")",
"(",
"backend",
".",
"Crypto",
",",
"error",
")",
"{",
"ctx",
"=",
... | // GetCryptoBackend initialized the correct crypto backend | [
"GetCryptoBackend",
"initialized",
"the",
"correct",
"crypto",
"backend"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/crypto.go#L22-L30 |
28,672 | gopasspw/gopass | pkg/action/generate.go | Generate | func (s *Action) Generate(ctx context.Context, c *cli.Context) error {
force := c.Bool("force")
edit := c.Bool("edit")
args, kvps := parseArgs(c)
name := args.Get(0)
key, length := keyAndLength(args)
// ask for name of the secret if it wasn't provided already
if name == "" {
var err error
name, err = termi... | go | func (s *Action) Generate(ctx context.Context, c *cli.Context) error {
force := c.Bool("force")
edit := c.Bool("edit")
args, kvps := parseArgs(c)
name := args.Get(0)
key, length := keyAndLength(args)
// ask for name of the secret if it wasn't provided already
if name == "" {
var err error
name, err = termi... | [
"func",
"(",
"s",
"*",
"Action",
")",
"Generate",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"force",
":=",
"c",
".",
"Bool",
"(",
"\"",
"\"",
")",
"\n",
"edit",
":=",
"c",
".",
"Bool",
"(",
... | // Generate and save a password | [
"Generate",
"and",
"save",
"a",
"password"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/generate.go#L36-L83 |
28,673 | gopasspw/gopass | pkg/action/generate.go | generateCopyOrPrint | func (s *Action) generateCopyOrPrint(ctx context.Context, c *cli.Context, name, key, password string) error {
if ctxutil.IsAutoPrint(ctx) || c.Bool("print") {
if key != "" {
key = " " + key
}
out.Print(
ctx,
"The generated password for %s%s is:\n%s", name, key,
color.YellowString(password),
)
}
... | go | func (s *Action) generateCopyOrPrint(ctx context.Context, c *cli.Context, name, key, password string) error {
if ctxutil.IsAutoPrint(ctx) || c.Bool("print") {
if key != "" {
key = " " + key
}
out.Print(
ctx,
"The generated password for %s%s is:\n%s", name, key,
color.YellowString(password),
)
}
... | [
"func",
"(",
"s",
"*",
"Action",
")",
"generateCopyOrPrint",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
",",
"name",
",",
"key",
",",
"password",
"string",
")",
"error",
"{",
"if",
"ctxutil",
".",
"IsAutoPrint",
"(",
... | // generateCopyOrPrint will print the password to the screen or copy to the
// clipboard | [
"generateCopyOrPrint",
"will",
"print",
"the",
"password",
"to",
"the",
"screen",
"or",
"copy",
"to",
"the",
"clipboard"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/generate.go#L103-L131 |
28,674 | gopasspw/gopass | pkg/action/generate.go | generatePassword | func (s *Action) generatePassword(ctx context.Context, c *cli.Context, length string) (string, error) {
if c.Bool("xkcd") || c.IsSet("xkcdsep") {
return s.generatePasswordXKCD(ctx, c, length)
}
symbols := ctxutil.IsUseSymbols(ctx)
if c.IsSet("symbols") {
symbols = c.Bool("symbols")
}
var pwlen int
if lengt... | go | func (s *Action) generatePassword(ctx context.Context, c *cli.Context, length string) (string, error) {
if c.Bool("xkcd") || c.IsSet("xkcdsep") {
return s.generatePasswordXKCD(ctx, c, length)
}
symbols := ctxutil.IsUseSymbols(ctx)
if c.IsSet("symbols") {
symbols = c.Bool("symbols")
}
var pwlen int
if lengt... | [
"func",
"(",
"s",
"*",
"Action",
")",
"generatePassword",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
",",
"length",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"c",
".",
"Bool",
"(",
"\"",
"\"",
"... | // generatePassword will run through the password generation steps | [
"generatePassword",
"will",
"run",
"through",
"the",
"password",
"generation",
"steps"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/generate.go#L134-L174 |
28,675 | gopasspw/gopass | pkg/action/generate.go | generatePasswordXKCD | func (s *Action) generatePasswordXKCD(ctx context.Context, c *cli.Context, length string) (string, error) {
xkcdSeparator := " "
if c.IsSet("xkcdsep") {
xkcdSeparator = c.String("xkcdsep")
}
var pwlen int
if length == "" {
candidateLength := defaultXKCDLength
question := "How many words should be combined t... | go | func (s *Action) generatePasswordXKCD(ctx context.Context, c *cli.Context, length string) (string, error) {
xkcdSeparator := " "
if c.IsSet("xkcdsep") {
xkcdSeparator = c.String("xkcdsep")
}
var pwlen int
if length == "" {
candidateLength := defaultXKCDLength
question := "How many words should be combined t... | [
"func",
"(",
"s",
"*",
"Action",
")",
"generatePasswordXKCD",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
",",
"length",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"xkcdSeparator",
":=",
"\"",
"\"",
"\n",
"... | // generatePasswordXKCD walks through the steps necessary to create an XKCD-style
// password | [
"generatePasswordXKCD",
"walks",
"through",
"the",
"steps",
"necessary",
"to",
"create",
"an",
"XKCD",
"-",
"style",
"password"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/generate.go#L178-L206 |
28,676 | gopasspw/gopass | pkg/action/generate.go | generateSetPassword | func (s *Action) generateSetPassword(ctx context.Context, name, key, password string, kvps map[string]string) (context.Context, error) {
// set a single key in a yaml doc
if key != "" {
sec, ctx, err := s.Store.GetContext(ctx, name)
if err != nil {
return ctx, ExitError(ctx, ExitEncrypt, err, "failed to set ke... | go | func (s *Action) generateSetPassword(ctx context.Context, name, key, password string, kvps map[string]string) (context.Context, error) {
// set a single key in a yaml doc
if key != "" {
sec, ctx, err := s.Store.GetContext(ctx, name)
if err != nil {
return ctx, ExitError(ctx, ExitEncrypt, err, "failed to set ke... | [
"func",
"(",
"s",
"*",
"Action",
")",
"generateSetPassword",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
",",
"key",
",",
"password",
"string",
",",
"kvps",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"context",
".",
"Context",
",",
"error",... | // generateSetPassword will update or create a secret | [
"generateSetPassword",
"will",
"update",
"or",
"create",
"a",
"secret"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/generate.go#L209-L256 |
28,677 | gopasspw/gopass | pkg/action/generate.go | CompleteGenerate | func (s *Action) CompleteGenerate(ctx context.Context, c *cli.Context) {
args := c.Args()
if len(args) < 1 {
return
}
needle := args[0]
_, err := s.Store.Initialized(ctx) // important to make sure the structs are not nil
if err != nil {
out.Error(ctx, "Store not initialized: %s", err)
return
}
list, err ... | go | func (s *Action) CompleteGenerate(ctx context.Context, c *cli.Context) {
args := c.Args()
if len(args) < 1 {
return
}
needle := args[0]
_, err := s.Store.Initialized(ctx) // important to make sure the structs are not nil
if err != nil {
out.Error(ctx, "Store not initialized: %s", err)
return
}
list, err ... | [
"func",
"(",
"s",
"*",
"Action",
")",
"CompleteGenerate",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"args",
":=",
"c",
".",
"Args",
"(",
")",
"\n",
"if",
"len",
"(",
"args",
")",
"<",
"1",
"{",
"retu... | // CompleteGenerate implements the completion heuristic for the generate command | [
"CompleteGenerate",
"implements",
"the",
"completion",
"heuristic",
"for",
"the",
"generate",
"command"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/generate.go#L265-L291 |
28,678 | gopasspw/gopass | pkg/editor/editor.go | Invoke | func Invoke(ctx context.Context, editor string, content []byte) ([]byte, error) {
if !ctxutil.IsTerminal(ctx) {
return nil, errors.New("need terminal")
}
tmpfile, err := tempfile.New(ctx, "gopass-edit")
if err != nil {
return []byte{}, errors.Errorf("failed to create tmpfile %s: %s", editor, err)
}
defer fun... | go | func Invoke(ctx context.Context, editor string, content []byte) ([]byte, error) {
if !ctxutil.IsTerminal(ctx) {
return nil, errors.New("need terminal")
}
tmpfile, err := tempfile.New(ctx, "gopass-edit")
if err != nil {
return []byte{}, errors.Errorf("failed to create tmpfile %s: %s", editor, err)
}
defer fun... | [
"func",
"Invoke",
"(",
"ctx",
"context",
".",
"Context",
",",
"editor",
"string",
",",
"content",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"!",
"ctxutil",
".",
"IsTerminal",
"(",
"ctx",
")",
"{",
"return",
"nil",
... | // Invoke will start the given editor and return the content | [
"Invoke",
"will",
"start",
"the",
"given",
"editor",
"and",
"return",
"the",
"content"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/editor/editor.go#L30-L80 |
28,679 | gopasspw/gopass | pkg/audit/audit.go | Batch | func Batch(ctx context.Context, secrets []string, secStore secretGetter) error {
out.Print(ctx, "Checking %d secrets. This may take some time ...\n", len(secrets))
// Secrets that still need auditing.
pending := make(chan string, 100)
// Secrets that have been audited.
checked := make(chan auditedSecret, 100)
... | go | func Batch(ctx context.Context, secrets []string, secStore secretGetter) error {
out.Print(ctx, "Checking %d secrets. This may take some time ...\n", len(secrets))
// Secrets that still need auditing.
pending := make(chan string, 100)
// Secrets that have been audited.
checked := make(chan auditedSecret, 100)
... | [
"func",
"Batch",
"(",
"ctx",
"context",
".",
"Context",
",",
"secrets",
"[",
"]",
"string",
",",
"secStore",
"secretGetter",
")",
"error",
"{",
"out",
".",
"Print",
"(",
"ctx",
",",
"\"",
"\\n",
"\"",
",",
"len",
"(",
"secrets",
")",
")",
"\n\n",
"... | // Batch runs a password strength audit on multiple secrets | [
"Batch",
"runs",
"a",
"password",
"strength",
"audit",
"on",
"multiple",
"secrets"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/audit/audit.go#L39-L108 |
28,680 | gopasspw/gopass | pkg/audit/audit.go | Single | func Single(ctx context.Context, password string) {
validator := crunchy.NewValidator()
if err := validator.Check(password); err != nil {
out.Cyan(ctx, fmt.Sprintf("Warning: %s", err))
}
} | go | func Single(ctx context.Context, password string) {
validator := crunchy.NewValidator()
if err := validator.Check(password); err != nil {
out.Cyan(ctx, fmt.Sprintf("Warning: %s", err))
}
} | [
"func",
"Single",
"(",
"ctx",
"context",
".",
"Context",
",",
"password",
"string",
")",
"{",
"validator",
":=",
"crunchy",
".",
"NewValidator",
"(",
")",
"\n",
"if",
"err",
":=",
"validator",
".",
"Check",
"(",
"password",
")",
";",
"err",
"!=",
"nil"... | // Single runs a password strength audit on a single password | [
"Single",
"runs",
"a",
"password",
"strength",
"audit",
"on",
"a",
"single",
"password"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/audit/audit.go#L155-L160 |
28,681 | gopasspw/gopass | pkg/store/vault/secret.go | Bytes | func (s *Secret) Bytes() ([]byte, error) {
if s.d == nil {
return []byte{}, nil
}
buf := &bytes.Buffer{}
if pw, found := s.d[passwordKey]; found {
if sv, ok := pw.(string); ok {
_, _ = buf.WriteString(sv)
}
}
_, _ = buf.WriteString("\n")
keys := make([]string, 0, len(s.d))
for k := range s.d {
keys ... | go | func (s *Secret) Bytes() ([]byte, error) {
if s.d == nil {
return []byte{}, nil
}
buf := &bytes.Buffer{}
if pw, found := s.d[passwordKey]; found {
if sv, ok := pw.(string); ok {
_, _ = buf.WriteString(sv)
}
}
_, _ = buf.WriteString("\n")
keys := make([]string, 0, len(s.d))
for k := range s.d {
keys ... | [
"func",
"(",
"s",
"*",
"Secret",
")",
"Bytes",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"s",
".",
"d",
"==",
"nil",
"{",
"return",
"[",
"]",
"byte",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n\n",
"buf",
":=",
"&",
"bytes",
... | // Bytes returns a list serialized copy of this secret | [
"Bytes",
"returns",
"a",
"list",
"serialized",
"copy",
"of",
"this",
"secret"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/secret.go#L23-L53 |
28,682 | gopasspw/gopass | pkg/store/vault/secret.go | Data | func (s *Secret) Data() map[string]interface{} {
if s.d == nil {
s.d = make(map[string]interface{})
}
return s.d
} | go | func (s *Secret) Data() map[string]interface{} {
if s.d == nil {
s.d = make(map[string]interface{})
}
return s.d
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"Data",
"(",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"if",
"s",
".",
"d",
"==",
"nil",
"{",
"s",
".",
"d",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\... | // Data returns the data map. Will never be nil | [
"Data",
"returns",
"the",
"data",
"map",
".",
"Will",
"never",
"be",
"nil"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/secret.go#L56-L61 |
28,683 | gopasspw/gopass | pkg/store/vault/secret.go | DeleteKey | func (s *Secret) DeleteKey(key string) error {
if s.d == nil {
return nil
}
delete(s.d, key)
return nil
} | go | func (s *Secret) DeleteKey(key string) error {
if s.d == nil {
return nil
}
delete(s.d, key)
return nil
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"DeleteKey",
"(",
"key",
"string",
")",
"error",
"{",
"if",
"s",
".",
"d",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"delete",
"(",
"s",
".",
"d",
",",
"key",
")",
"\n",
"return",
"nil",
"\n",
"... | // DeleteKey removes a single key | [
"DeleteKey",
"removes",
"a",
"single",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/secret.go#L64-L70 |
28,684 | gopasspw/gopass | pkg/store/vault/secret.go | Equal | func (s *Secret) Equal(other store.Secret) bool {
b1, err := s.Bytes()
if err != nil {
return false
}
b2, err := other.Bytes()
if err != nil {
return false
}
return string(b1) == string(b2)
} | go | func (s *Secret) Equal(other store.Secret) bool {
b1, err := s.Bytes()
if err != nil {
return false
}
b2, err := other.Bytes()
if err != nil {
return false
}
return string(b1) == string(b2)
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"Equal",
"(",
"other",
"store",
".",
"Secret",
")",
"bool",
"{",
"b1",
",",
"err",
":=",
"s",
".",
"Bytes",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"b2",
",",
"e... | // Equal returns true if two secrets match | [
"Equal",
"returns",
"true",
"if",
"two",
"secrets",
"match"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/secret.go#L73-L83 |
28,685 | gopasspw/gopass | pkg/store/vault/secret.go | Password | func (s *Secret) Password() string {
v := s.d[passwordKey]
if sv, ok := v.(string); ok {
return sv
}
return ""
} | go | func (s *Secret) Password() string {
v := s.d[passwordKey]
if sv, ok := v.(string); ok {
return sv
}
return ""
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"Password",
"(",
")",
"string",
"{",
"v",
":=",
"s",
".",
"d",
"[",
"passwordKey",
"]",
"\n",
"if",
"sv",
",",
"ok",
":=",
"v",
".",
"(",
"string",
")",
";",
"ok",
"{",
"return",
"sv",
"\n",
"}",
"\n",
... | // Password returns the password | [
"Password",
"returns",
"the",
"password"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/secret.go#L86-L92 |
28,686 | gopasspw/gopass | pkg/store/vault/secret.go | SetValue | func (s *Secret) SetValue(key string, value string) error {
s.d[key] = value
return nil
} | go | func (s *Secret) SetValue(key string, value string) error {
s.d[key] = value
return nil
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"SetValue",
"(",
"key",
"string",
",",
"value",
"string",
")",
"error",
"{",
"s",
".",
"d",
"[",
"key",
"]",
"=",
"value",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetValue sets a single key | [
"SetValue",
"sets",
"a",
"single",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/secret.go#L105-L108 |
28,687 | gopasspw/gopass | pkg/store/vault/secret.go | Value | func (s *Secret) Value(key string) (string, error) {
v := s.d[key]
if sv, ok := v.(string); ok {
return sv, nil
}
return "", nil
} | go | func (s *Secret) Value(key string) (string, error) {
v := s.d[key]
if sv, ok := v.(string); ok {
return sv, nil
}
return "", nil
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"Value",
"(",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"v",
":=",
"s",
".",
"d",
"[",
"key",
"]",
"\n",
"if",
"sv",
",",
"ok",
":=",
"v",
".",
"(",
"string",
")",
";",
"ok",
"{",
"... | // Value returns a single value | [
"Value",
"returns",
"a",
"single",
"value"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/secret.go#L137-L143 |
28,688 | gopasspw/gopass | pkg/store/sub/init.go | Initialized | func (s *Store) Initialized(ctx context.Context) bool {
if s == nil || s.storage == nil {
return false
}
return s.storage.Exists(ctx, s.idFile(ctx, ""))
} | go | func (s *Store) Initialized(ctx context.Context) bool {
if s == nil || s.storage == nil {
return false
}
return s.storage.Exists(ctx, s.idFile(ctx, ""))
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Initialized",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"if",
"s",
"==",
"nil",
"||",
"s",
".",
"storage",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"s",
".",
"storage",
"... | // Initialized returns true if the store is properly initialized | [
"Initialized",
"returns",
"true",
"if",
"the",
"store",
"is",
"properly",
"initialized"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/init.go#L13-L18 |
28,689 | gopasspw/gopass | pkg/store/root/list.go | List | func (r *Store) List(ctx context.Context, maxDepth int) ([]string, error) {
t, err := r.Tree(ctx)
if err != nil {
return []string{}, err
}
return t.List(maxDepth), nil
} | go | func (r *Store) List(ctx context.Context, maxDepth int) ([]string, error) {
t, err := r.Tree(ctx)
if err != nil {
return []string{}, err
}
return t.List(maxDepth), nil
} | [
"func",
"(",
"r",
"*",
"Store",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"maxDepth",
"int",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"t",
",",
"err",
":=",
"r",
".",
"Tree",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=... | // List will return a flattened list of all tree entries | [
"List",
"will",
"return",
"a",
"flattened",
"list",
"of",
"all",
"tree",
"entries"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/list.go#L17-L23 |
28,690 | gopasspw/gopass | pkg/store/root/list.go | Tree | func (r *Store) Tree(ctx context.Context) (tree.Tree, error) {
root := simple.New("gopass")
addFileFunc := func(in ...string) {
for _, f := range in {
var ct string
switch {
case strings.HasSuffix(f, ".b64"):
ct = "application/octet-stream"
case strings.HasSuffix(f, ".yml"):
ct = "text/yaml"
... | go | func (r *Store) Tree(ctx context.Context) (tree.Tree, error) {
root := simple.New("gopass")
addFileFunc := func(in ...string) {
for _, f := range in {
var ct string
switch {
case strings.HasSuffix(f, ".b64"):
ct = "application/octet-stream"
case strings.HasSuffix(f, ".yml"):
ct = "text/yaml"
... | [
"func",
"(",
"r",
"*",
"Store",
")",
"Tree",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"tree",
".",
"Tree",
",",
"error",
")",
"{",
"root",
":=",
"simple",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"addFileFunc",
":=",
"func",
"(",
"in",
"... | // Tree returns the tree representation of the entries | [
"Tree",
"returns",
"the",
"tree",
"representation",
"of",
"the",
"entries"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/list.go#L26-L82 |
28,691 | gopasspw/gopass | pkg/action/hibp.go | HIBP | func (s *Action) HIBP(ctx context.Context, c *cli.Context) error {
force := c.Bool("force")
api := c.Bool("api")
if api {
return s.hibpAPI(ctx, force)
}
out.Yellow(ctx, "WARNING: Using the HIBPv2 dumps is very expensive. If you can condone leaking a few bits of entropy per secret you should probably use the '-... | go | func (s *Action) HIBP(ctx context.Context, c *cli.Context) error {
force := c.Bool("force")
api := c.Bool("api")
if api {
return s.hibpAPI(ctx, force)
}
out.Yellow(ctx, "WARNING: Using the HIBPv2 dumps is very expensive. If you can condone leaking a few bits of entropy per secret you should probably use the '-... | [
"func",
"(",
"s",
"*",
"Action",
")",
"HIBP",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"force",
":=",
"c",
".",
"Bool",
"(",
"\"",
"\"",
")",
"\n",
"api",
":=",
"c",
".",
"Bool",
"(",
"\"... | // HIBP compares all entries from the store against the provided SHA1 sum dumps | [
"HIBP",
"compares",
"all",
"entries",
"from",
"the",
"store",
"against",
"the",
"provided",
"SHA1",
"sum",
"dumps"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/hibp.go#L22-L34 |
28,692 | gopasspw/gopass | pkg/backend/crypto/xc/utils.go | RecipientIDs | func (x *XC) RecipientIDs(ctx context.Context, ciphertext []byte) ([]string, error) {
msg := &xcpb.Message{}
if err := proto.Unmarshal(ciphertext, msg); err != nil {
return nil, err
}
ids := make([]string, 0, len(msg.Header.Recipients))
for k := range msg.Header.Recipients {
ids = append(ids, k)
}
sort.Stri... | go | func (x *XC) RecipientIDs(ctx context.Context, ciphertext []byte) ([]string, error) {
msg := &xcpb.Message{}
if err := proto.Unmarshal(ciphertext, msg); err != nil {
return nil, err
}
ids := make([]string, 0, len(msg.Header.Recipients))
for k := range msg.Header.Recipients {
ids = append(ids, k)
}
sort.Stri... | [
"func",
"(",
"x",
"*",
"XC",
")",
"RecipientIDs",
"(",
"ctx",
"context",
".",
"Context",
",",
"ciphertext",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"msg",
":=",
"&",
"xcpb",
".",
"Message",
"{",
"}",
"\n",
"if",
... | // RecipientIDs reads the header of the given file and extracts the
// recipients IDs | [
"RecipientIDs",
"reads",
"the",
"header",
"of",
"the",
"given",
"file",
"and",
"extracts",
"the",
"recipients",
"IDs"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L18-L30 |
28,693 | gopasspw/gopass | pkg/backend/crypto/xc/utils.go | ReadNamesFromKey | func (x *XC) ReadNamesFromKey(ctx context.Context, buf []byte) ([]string, error) {
pk := &xcpb.PublicKey{}
if err := proto.Unmarshal(buf, pk); err != nil {
return nil, errors.Wrapf(err, "failed to unmarshal public key: %s", err)
}
return []string{pk.Identity.Name}, nil
} | go | func (x *XC) ReadNamesFromKey(ctx context.Context, buf []byte) ([]string, error) {
pk := &xcpb.PublicKey{}
if err := proto.Unmarshal(buf, pk); err != nil {
return nil, errors.Wrapf(err, "failed to unmarshal public key: %s", err)
}
return []string{pk.Identity.Name}, nil
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"ReadNamesFromKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"buf",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"pk",
":=",
"&",
"xcpb",
".",
"PublicKey",
"{",
"}",
"\n",
"if",
"e... | // ReadNamesFromKey unmarshals the given public key and returns the identities name | [
"ReadNamesFromKey",
"unmarshals",
"the",
"given",
"public",
"key",
"and",
"returns",
"the",
"identities",
"name"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L33-L40 |
28,694 | gopasspw/gopass | pkg/backend/crypto/xc/utils.go | ListPublicKeyIDs | func (x *XC) ListPublicKeyIDs(ctx context.Context) ([]string, error) {
return x.pubring.KeyIDs(), nil
} | go | func (x *XC) ListPublicKeyIDs(ctx context.Context) ([]string, error) {
return x.pubring.KeyIDs(), nil
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"ListPublicKeyIDs",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"return",
"x",
".",
"pubring",
".",
"KeyIDs",
"(",
")",
",",
"nil",
"\n",
"}"
] | // ListPublicKeyIDs lists all public key IDs | [
"ListPublicKeyIDs",
"lists",
"all",
"public",
"key",
"IDs"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L43-L45 |
28,695 | gopasspw/gopass | pkg/backend/crypto/xc/utils.go | ListPrivateKeyIDs | func (x *XC) ListPrivateKeyIDs(ctx context.Context) ([]string, error) {
return x.secring.KeyIDs(), nil
} | go | func (x *XC) ListPrivateKeyIDs(ctx context.Context) ([]string, error) {
return x.secring.KeyIDs(), nil
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"ListPrivateKeyIDs",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"return",
"x",
".",
"secring",
".",
"KeyIDs",
"(",
")",
",",
"nil",
"\n",
"}"
] | // ListPrivateKeyIDs lists all private key IDs | [
"ListPrivateKeyIDs",
"lists",
"all",
"private",
"key",
"IDs"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L48-L50 |
28,696 | gopasspw/gopass | pkg/backend/crypto/xc/utils.go | FindPublicKeys | func (x *XC) FindPublicKeys(ctx context.Context, search ...string) ([]string, error) {
ids := make([]string, 0, 1)
candidates, _ := x.ListPublicKeyIDs(ctx)
for _, needle := range search {
for _, fp := range candidates {
if strings.HasSuffix(fp, needle) {
ids = append(ids, fp)
}
}
}
sort.Strings(ids)
... | go | func (x *XC) FindPublicKeys(ctx context.Context, search ...string) ([]string, error) {
ids := make([]string, 0, 1)
candidates, _ := x.ListPublicKeyIDs(ctx)
for _, needle := range search {
for _, fp := range candidates {
if strings.HasSuffix(fp, needle) {
ids = append(ids, fp)
}
}
}
sort.Strings(ids)
... | [
"func",
"(",
"x",
"*",
"XC",
")",
"FindPublicKeys",
"(",
"ctx",
"context",
".",
"Context",
",",
"search",
"...",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"ids",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"1",
"... | // FindPublicKeys finds all matching public keys | [
"FindPublicKeys",
"finds",
"all",
"matching",
"public",
"keys"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L53-L65 |
28,697 | gopasspw/gopass | pkg/backend/crypto/xc/utils.go | FormatKey | func (x *XC) FormatKey(ctx context.Context, id string) string {
if key := x.pubring.Get(id); key != nil {
return id + " - " + key.Identity.ID()
}
if key := x.secring.Get(id); key != nil {
return id + " - " + key.PublicKey.Identity.ID()
}
return id
} | go | func (x *XC) FormatKey(ctx context.Context, id string) string {
if key := x.pubring.Get(id); key != nil {
return id + " - " + key.Identity.ID()
}
if key := x.secring.Get(id); key != nil {
return id + " - " + key.PublicKey.Identity.ID()
}
return id
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"FormatKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"string",
"{",
"if",
"key",
":=",
"x",
".",
"pubring",
".",
"Get",
"(",
"id",
")",
";",
"key",
"!=",
"nil",
"{",
"return",
"id",
"+"... | // FormatKey formats a key | [
"FormatKey",
"formats",
"a",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L83-L91 |
28,698 | gopasspw/gopass | pkg/backend/crypto/xc/utils.go | NameFromKey | func (x *XC) NameFromKey(ctx context.Context, id string) string {
if key := x.pubring.Get(id); key != nil {
return key.Identity.Name
}
if key := x.secring.Get(id); key != nil {
return key.PublicKey.Identity.Name
}
return id
} | go | func (x *XC) NameFromKey(ctx context.Context, id string) string {
if key := x.pubring.Get(id); key != nil {
return key.Identity.Name
}
if key := x.secring.Get(id); key != nil {
return key.PublicKey.Identity.Name
}
return id
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"NameFromKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"string",
"{",
"if",
"key",
":=",
"x",
".",
"pubring",
".",
"Get",
"(",
"id",
")",
";",
"key",
"!=",
"nil",
"{",
"return",
"key",
... | // NameFromKey extracts the name from a key | [
"NameFromKey",
"extracts",
"the",
"name",
"from",
"a",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L94-L102 |
28,699 | gopasspw/gopass | pkg/backend/crypto/xc/utils.go | EmailFromKey | func (x *XC) EmailFromKey(ctx context.Context, id string) string {
if key := x.pubring.Get(id); key != nil {
return key.Identity.Email
}
if key := x.secring.Get(id); key != nil {
return key.PublicKey.Identity.Email
}
return id
} | go | func (x *XC) EmailFromKey(ctx context.Context, id string) string {
if key := x.pubring.Get(id); key != nil {
return key.Identity.Email
}
if key := x.secring.Get(id); key != nil {
return key.PublicKey.Identity.Email
}
return id
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"EmailFromKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"string",
"{",
"if",
"key",
":=",
"x",
".",
"pubring",
".",
"Get",
"(",
"id",
")",
";",
"key",
"!=",
"nil",
"{",
"return",
"key",
... | // EmailFromKey extracts the email from a key | [
"EmailFromKey",
"extracts",
"the",
"email",
"from",
"a",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L105-L113 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.