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
|
---|---|---|---|---|---|---|---|---|---|---|---|
9,900 | aerospike/aerospike-client-go | key.go | SetValue | func (ky *Key) SetValue(val Value) error {
ky.userKey = val
return ky.computeDigest()
} | go | func (ky *Key) SetValue(val Value) error {
ky.userKey = val
return ky.computeDigest()
} | [
"func",
"(",
"ky",
"*",
"Key",
")",
"SetValue",
"(",
"val",
"Value",
")",
"error",
"{",
"ky",
".",
"userKey",
"=",
"val",
"\n",
"return",
"ky",
".",
"computeDigest",
"(",
")",
"\n",
"}"
]
| // SetValue sets the Key's value and recompute's its digest without allocating new memory.
// This allows the keys to be reusable. | [
"SetValue",
"sets",
"the",
"Key",
"s",
"value",
"and",
"recompute",
"s",
"its",
"digest",
"without",
"allocating",
"new",
"memory",
".",
"This",
"allows",
"the",
"keys",
"to",
"be",
"reusable",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/key.go#L68-L71 |
9,901 | aerospike/aerospike-client-go | key.go | Equals | func (ky *Key) Equals(other *Key) bool {
return bytes.Equal(ky.digest[:], other.digest[:])
} | go | func (ky *Key) Equals(other *Key) bool {
return bytes.Equal(ky.digest[:], other.digest[:])
} | [
"func",
"(",
"ky",
"*",
"Key",
")",
"Equals",
"(",
"other",
"*",
"Key",
")",
"bool",
"{",
"return",
"bytes",
".",
"Equal",
"(",
"ky",
".",
"digest",
"[",
":",
"]",
",",
"other",
".",
"digest",
"[",
":",
"]",
")",
"\n",
"}"
]
| // Equals uses key digests to compare key equality. | [
"Equals",
"uses",
"key",
"digests",
"to",
"compare",
"key",
"equality",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/key.go#L79-L81 |
9,902 | aerospike/aerospike-client-go | key.go | String | func (ky *Key) String() string {
if ky == nil {
return ""
}
if ky.userKey != nil {
return fmt.Sprintf("%s:%s:%s:%v", ky.namespace, ky.setName, ky.userKey.String(), Buffer.BytesToHexString(ky.digest[:]))
}
return fmt.Sprintf("%s:%s::%v", ky.namespace, ky.setName, Buffer.BytesToHexString(ky.digest[:]))
} | go | func (ky *Key) String() string {
if ky == nil {
return ""
}
if ky.userKey != nil {
return fmt.Sprintf("%s:%s:%s:%v", ky.namespace, ky.setName, ky.userKey.String(), Buffer.BytesToHexString(ky.digest[:]))
}
return fmt.Sprintf("%s:%s::%v", ky.namespace, ky.setName, Buffer.BytesToHexString(ky.digest[:]))
} | [
"func",
"(",
"ky",
"*",
"Key",
")",
"String",
"(",
")",
"string",
"{",
"if",
"ky",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"if",
"ky",
".",
"userKey",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ky",
".",
"namespace",
",",
"ky",
".",
"setName",
",",
"ky",
".",
"userKey",
".",
"String",
"(",
")",
",",
"Buffer",
".",
"BytesToHexString",
"(",
"ky",
".",
"digest",
"[",
":",
"]",
")",
")",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ky",
".",
"namespace",
",",
"ky",
".",
"setName",
",",
"Buffer",
".",
"BytesToHexString",
"(",
"ky",
".",
"digest",
"[",
":",
"]",
")",
")",
"\n",
"}"
]
| // String implements Stringer interface and returns string representation of key. | [
"String",
"implements",
"Stringer",
"interface",
"and",
"returns",
"string",
"representation",
"of",
"key",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/key.go#L84-L93 |
9,903 | aerospike/aerospike-client-go | key.go | NewKey | func NewKey(namespace string, setName string, key interface{}) (*Key, error) {
newKey := &Key{
namespace: namespace,
setName: setName,
userKey: NewValue(key),
}
if err := newKey.computeDigest(); err != nil {
return nil, err
}
return newKey, nil
} | go | func NewKey(namespace string, setName string, key interface{}) (*Key, error) {
newKey := &Key{
namespace: namespace,
setName: setName,
userKey: NewValue(key),
}
if err := newKey.computeDigest(); err != nil {
return nil, err
}
return newKey, nil
} | [
"func",
"NewKey",
"(",
"namespace",
"string",
",",
"setName",
"string",
",",
"key",
"interface",
"{",
"}",
")",
"(",
"*",
"Key",
",",
"error",
")",
"{",
"newKey",
":=",
"&",
"Key",
"{",
"namespace",
":",
"namespace",
",",
"setName",
":",
"setName",
",",
"userKey",
":",
"NewValue",
"(",
"key",
")",
",",
"}",
"\n\n",
"if",
"err",
":=",
"newKey",
".",
"computeDigest",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"newKey",
",",
"nil",
"\n",
"}"
]
| // NewKey initializes a key from namespace, optional set name and user key.
// The set name and user defined key are converted to a digest before sending to the server.
// The server handles record identifiers by digest only. | [
"NewKey",
"initializes",
"a",
"key",
"from",
"namespace",
"optional",
"set",
"name",
"and",
"user",
"key",
".",
"The",
"set",
"name",
"and",
"user",
"defined",
"key",
"are",
"converted",
"to",
"a",
"digest",
"before",
"sending",
"to",
"the",
"server",
".",
"The",
"server",
"handles",
"record",
"identifiers",
"by",
"digest",
"only",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/key.go#L98-L110 |
9,904 | aerospike/aerospike-client-go | key.go | NewKeyWithDigest | func NewKeyWithDigest(namespace string, setName string, key interface{}, digest []byte) (*Key, error) {
newKey := &Key{
namespace: namespace,
setName: setName,
userKey: NewValue(key),
}
if err := newKey.SetDigest(digest); err != nil {
return nil, err
}
return newKey, nil
} | go | func NewKeyWithDigest(namespace string, setName string, key interface{}, digest []byte) (*Key, error) {
newKey := &Key{
namespace: namespace,
setName: setName,
userKey: NewValue(key),
}
if err := newKey.SetDigest(digest); err != nil {
return nil, err
}
return newKey, nil
} | [
"func",
"NewKeyWithDigest",
"(",
"namespace",
"string",
",",
"setName",
"string",
",",
"key",
"interface",
"{",
"}",
",",
"digest",
"[",
"]",
"byte",
")",
"(",
"*",
"Key",
",",
"error",
")",
"{",
"newKey",
":=",
"&",
"Key",
"{",
"namespace",
":",
"namespace",
",",
"setName",
":",
"setName",
",",
"userKey",
":",
"NewValue",
"(",
"key",
")",
",",
"}",
"\n\n",
"if",
"err",
":=",
"newKey",
".",
"SetDigest",
"(",
"digest",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"newKey",
",",
"nil",
"\n",
"}"
]
| // NewKeyWithDigest initializes a key from namespace, optional set name and user key.
// The server handles record identifiers by digest only. | [
"NewKeyWithDigest",
"initializes",
"a",
"key",
"from",
"namespace",
"optional",
"set",
"name",
"and",
"user",
"key",
".",
"The",
"server",
"handles",
"record",
"identifiers",
"by",
"digest",
"only",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/key.go#L114-L125 |
9,905 | aerospike/aerospike-client-go | key.go | SetDigest | func (ky *Key) SetDigest(digest []byte) error {
if len(digest) != 20 {
return NewAerospikeError(PARAMETER_ERROR, "Invalid digest: Digest is required to be exactly 20 bytes.")
}
copy(ky.digest[:], digest)
return nil
} | go | func (ky *Key) SetDigest(digest []byte) error {
if len(digest) != 20 {
return NewAerospikeError(PARAMETER_ERROR, "Invalid digest: Digest is required to be exactly 20 bytes.")
}
copy(ky.digest[:], digest)
return nil
} | [
"func",
"(",
"ky",
"*",
"Key",
")",
"SetDigest",
"(",
"digest",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"digest",
")",
"!=",
"20",
"{",
"return",
"NewAerospikeError",
"(",
"PARAMETER_ERROR",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"copy",
"(",
"ky",
".",
"digest",
"[",
":",
"]",
",",
"digest",
")",
"\n",
"return",
"nil",
"\n",
"}"
]
| // SetDigest sets a custom hash | [
"SetDigest",
"sets",
"a",
"custom",
"hash"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/key.go#L128-L134 |
9,906 | aerospike/aerospike-client-go | batch_read.go | NewBatchRead | func NewBatchRead(key *Key, binNames []string) *BatchRead {
res := &BatchRead{
Key: key,
BinNames: binNames,
}
if len(binNames) == 0 {
res.ReadAllBins = true
}
return res
} | go | func NewBatchRead(key *Key, binNames []string) *BatchRead {
res := &BatchRead{
Key: key,
BinNames: binNames,
}
if len(binNames) == 0 {
res.ReadAllBins = true
}
return res
} | [
"func",
"NewBatchRead",
"(",
"key",
"*",
"Key",
",",
"binNames",
"[",
"]",
"string",
")",
"*",
"BatchRead",
"{",
"res",
":=",
"&",
"BatchRead",
"{",
"Key",
":",
"key",
",",
"BinNames",
":",
"binNames",
",",
"}",
"\n\n",
"if",
"len",
"(",
"binNames",
")",
"==",
"0",
"{",
"res",
".",
"ReadAllBins",
"=",
"true",
"\n",
"}",
"\n\n",
"return",
"res",
"\n",
"}"
]
| // NewBatchRead defines a key and bins to retrieve in a batch operation. | [
"NewBatchRead",
"defines",
"a",
"key",
"and",
"bins",
"to",
"retrieve",
"in",
"a",
"batch",
"operation",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/batch_read.go#L41-L52 |
9,907 | aerospike/aerospike-client-go | internal/lua/lua.go | LValueToInterface | func LValueToInterface(val lua.LValue) interface{} {
switch val.Type() {
case lua.LTNil:
return nil
case lua.LTBool:
return lua.LVAsBool(val)
case lua.LTNumber:
return float64(lua.LVAsNumber(val))
case lua.LTString:
return lua.LVAsString(val)
case lua.LTUserData:
ud := val.(*lua.LUserData).Value
switch v := ud.(type) {
case *LuaMap:
return v.m
case *LuaList:
return v.l
default:
return v
}
case lua.LTTable:
t := val.(*lua.LTable)
m := make(map[interface{}]interface{}, t.Len())
t.ForEach(func(k, v lua.LValue) { m[k] = v })
return m
default:
panic(fmt.Sprintf("unrecognized data type %#v", val))
}
} | go | func LValueToInterface(val lua.LValue) interface{} {
switch val.Type() {
case lua.LTNil:
return nil
case lua.LTBool:
return lua.LVAsBool(val)
case lua.LTNumber:
return float64(lua.LVAsNumber(val))
case lua.LTString:
return lua.LVAsString(val)
case lua.LTUserData:
ud := val.(*lua.LUserData).Value
switch v := ud.(type) {
case *LuaMap:
return v.m
case *LuaList:
return v.l
default:
return v
}
case lua.LTTable:
t := val.(*lua.LTable)
m := make(map[interface{}]interface{}, t.Len())
t.ForEach(func(k, v lua.LValue) { m[k] = v })
return m
default:
panic(fmt.Sprintf("unrecognized data type %#v", val))
}
} | [
"func",
"LValueToInterface",
"(",
"val",
"lua",
".",
"LValue",
")",
"interface",
"{",
"}",
"{",
"switch",
"val",
".",
"Type",
"(",
")",
"{",
"case",
"lua",
".",
"LTNil",
":",
"return",
"nil",
"\n",
"case",
"lua",
".",
"LTBool",
":",
"return",
"lua",
".",
"LVAsBool",
"(",
"val",
")",
"\n",
"case",
"lua",
".",
"LTNumber",
":",
"return",
"float64",
"(",
"lua",
".",
"LVAsNumber",
"(",
"val",
")",
")",
"\n",
"case",
"lua",
".",
"LTString",
":",
"return",
"lua",
".",
"LVAsString",
"(",
"val",
")",
"\n",
"case",
"lua",
".",
"LTUserData",
":",
"ud",
":=",
"val",
".",
"(",
"*",
"lua",
".",
"LUserData",
")",
".",
"Value",
"\n",
"switch",
"v",
":=",
"ud",
".",
"(",
"type",
")",
"{",
"case",
"*",
"LuaMap",
":",
"return",
"v",
".",
"m",
"\n",
"case",
"*",
"LuaList",
":",
"return",
"v",
".",
"l",
"\n",
"default",
":",
"return",
"v",
"\n",
"}",
"\n\n",
"case",
"lua",
".",
"LTTable",
":",
"t",
":=",
"val",
".",
"(",
"*",
"lua",
".",
"LTable",
")",
"\n",
"m",
":=",
"make",
"(",
"map",
"[",
"interface",
"{",
"}",
"]",
"interface",
"{",
"}",
",",
"t",
".",
"Len",
"(",
")",
")",
"\n",
"t",
".",
"ForEach",
"(",
"func",
"(",
"k",
",",
"v",
"lua",
".",
"LValue",
")",
"{",
"m",
"[",
"k",
"]",
"=",
"v",
"}",
")",
"\n",
"return",
"m",
"\n",
"default",
":",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"val",
")",
")",
"\n",
"}",
"\n",
"}"
]
| // LValueToInterface converts a generic LValue to a native type | [
"LValueToInterface",
"converts",
"a",
"generic",
"LValue",
"to",
"a",
"native",
"type"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/internal/lua/lua.go#L117-L146 |
9,908 | aerospike/aerospike-client-go | index_collection_type.go | ictToString | func ictToString(ict IndexCollectionType) string {
switch ict {
case ICT_LIST:
return "LIST"
case ICT_MAPKEYS:
return "MAPKEYS"
case ICT_MAPVALUES:
return "MAPVALUES"
default:
panic(fmt.Sprintf("Unknown IndexCollectionType value %v", ict))
}
} | go | func ictToString(ict IndexCollectionType) string {
switch ict {
case ICT_LIST:
return "LIST"
case ICT_MAPKEYS:
return "MAPKEYS"
case ICT_MAPVALUES:
return "MAPVALUES"
default:
panic(fmt.Sprintf("Unknown IndexCollectionType value %v", ict))
}
} | [
"func",
"ictToString",
"(",
"ict",
"IndexCollectionType",
")",
"string",
"{",
"switch",
"ict",
"{",
"case",
"ICT_LIST",
":",
"return",
"\"",
"\"",
"\n\n",
"case",
"ICT_MAPKEYS",
":",
"return",
"\"",
"\"",
"\n\n",
"case",
"ICT_MAPVALUES",
":",
"return",
"\"",
"\"",
"\n\n",
"default",
":",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ict",
")",
")",
"\n",
"}",
"\n",
"}"
]
| // ictToString converts IndexCollectionType to string representations | [
"ictToString",
"converts",
"IndexCollectionType",
"to",
"string",
"representations"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/index_collection_type.go#L38-L53 |
9,909 | aerospike/aerospike-client-go | write_policy.go | NewWritePolicy | func NewWritePolicy(generation, expiration uint32) *WritePolicy {
res := &WritePolicy{
BasePolicy: *NewPolicy(),
RecordExistsAction: UPDATE,
GenerationPolicy: NONE,
CommitLevel: COMMIT_ALL,
Generation: generation,
Expiration: expiration,
}
// Writes may not be idempotent.
// do not allow retries on writes by default.
res.MaxRetries = 0
return res
} | go | func NewWritePolicy(generation, expiration uint32) *WritePolicy {
res := &WritePolicy{
BasePolicy: *NewPolicy(),
RecordExistsAction: UPDATE,
GenerationPolicy: NONE,
CommitLevel: COMMIT_ALL,
Generation: generation,
Expiration: expiration,
}
// Writes may not be idempotent.
// do not allow retries on writes by default.
res.MaxRetries = 0
return res
} | [
"func",
"NewWritePolicy",
"(",
"generation",
",",
"expiration",
"uint32",
")",
"*",
"WritePolicy",
"{",
"res",
":=",
"&",
"WritePolicy",
"{",
"BasePolicy",
":",
"*",
"NewPolicy",
"(",
")",
",",
"RecordExistsAction",
":",
"UPDATE",
",",
"GenerationPolicy",
":",
"NONE",
",",
"CommitLevel",
":",
"COMMIT_ALL",
",",
"Generation",
":",
"generation",
",",
"Expiration",
":",
"expiration",
",",
"}",
"\n\n",
"// Writes may not be idempotent.",
"// do not allow retries on writes by default.",
"res",
".",
"MaxRetries",
"=",
"0",
"\n\n",
"return",
"res",
"\n",
"}"
]
| // NewWritePolicy initializes a new WritePolicy instance with default parameters. | [
"NewWritePolicy",
"initializes",
"a",
"new",
"WritePolicy",
"instance",
"with",
"default",
"parameters",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/write_policy.go#L78-L93 |
9,910 | aerospike/aerospike-client-go | policy.go | NewPolicy | func NewPolicy() *BasePolicy {
return &BasePolicy{
Priority: DEFAULT,
ConsistencyLevel: CONSISTENCY_ONE,
TotalTimeout: 0 * time.Millisecond,
SocketTimeout: 30 * time.Second,
MaxRetries: 2,
SleepBetweenRetries: 1 * time.Millisecond,
SleepMultiplier: 1.0,
ReplicaPolicy: SEQUENCE,
SendKey: false,
LinearizeRead: false,
}
} | go | func NewPolicy() *BasePolicy {
return &BasePolicy{
Priority: DEFAULT,
ConsistencyLevel: CONSISTENCY_ONE,
TotalTimeout: 0 * time.Millisecond,
SocketTimeout: 30 * time.Second,
MaxRetries: 2,
SleepBetweenRetries: 1 * time.Millisecond,
SleepMultiplier: 1.0,
ReplicaPolicy: SEQUENCE,
SendKey: false,
LinearizeRead: false,
}
} | [
"func",
"NewPolicy",
"(",
")",
"*",
"BasePolicy",
"{",
"return",
"&",
"BasePolicy",
"{",
"Priority",
":",
"DEFAULT",
",",
"ConsistencyLevel",
":",
"CONSISTENCY_ONE",
",",
"TotalTimeout",
":",
"0",
"*",
"time",
".",
"Millisecond",
",",
"SocketTimeout",
":",
"30",
"*",
"time",
".",
"Second",
",",
"MaxRetries",
":",
"2",
",",
"SleepBetweenRetries",
":",
"1",
"*",
"time",
".",
"Millisecond",
",",
"SleepMultiplier",
":",
"1.0",
",",
"ReplicaPolicy",
":",
"SEQUENCE",
",",
"SendKey",
":",
"false",
",",
"LinearizeRead",
":",
"false",
",",
"}",
"\n",
"}"
]
| // NewPolicy generates a new BasePolicy instance with default values. | [
"NewPolicy",
"generates",
"a",
"new",
"BasePolicy",
"instance",
"with",
"default",
"values",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/policy.go#L126-L139 |
9,911 | aerospike/aerospike-client-go | policy.go | socketTimeout | func (p *BasePolicy) socketTimeout() time.Duration {
if p.TotalTimeout == 0 && p.SocketTimeout == 0 {
return 0
} else if p.TotalTimeout > 0 && p.SocketTimeout == 0 {
return p.TotalTimeout
} else if p.TotalTimeout == 0 && p.SocketTimeout > 0 {
return p.SocketTimeout
} else if p.TotalTimeout > 0 && p.SocketTimeout > 0 {
if p.SocketTimeout < p.TotalTimeout {
return p.SocketTimeout
}
}
return p.TotalTimeout
} | go | func (p *BasePolicy) socketTimeout() time.Duration {
if p.TotalTimeout == 0 && p.SocketTimeout == 0 {
return 0
} else if p.TotalTimeout > 0 && p.SocketTimeout == 0 {
return p.TotalTimeout
} else if p.TotalTimeout == 0 && p.SocketTimeout > 0 {
return p.SocketTimeout
} else if p.TotalTimeout > 0 && p.SocketTimeout > 0 {
if p.SocketTimeout < p.TotalTimeout {
return p.SocketTimeout
}
}
return p.TotalTimeout
} | [
"func",
"(",
"p",
"*",
"BasePolicy",
")",
"socketTimeout",
"(",
")",
"time",
".",
"Duration",
"{",
"if",
"p",
".",
"TotalTimeout",
"==",
"0",
"&&",
"p",
".",
"SocketTimeout",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"else",
"if",
"p",
".",
"TotalTimeout",
">",
"0",
"&&",
"p",
".",
"SocketTimeout",
"==",
"0",
"{",
"return",
"p",
".",
"TotalTimeout",
"\n",
"}",
"else",
"if",
"p",
".",
"TotalTimeout",
"==",
"0",
"&&",
"p",
".",
"SocketTimeout",
">",
"0",
"{",
"return",
"p",
".",
"SocketTimeout",
"\n",
"}",
"else",
"if",
"p",
".",
"TotalTimeout",
">",
"0",
"&&",
"p",
".",
"SocketTimeout",
">",
"0",
"{",
"if",
"p",
".",
"SocketTimeout",
"<",
"p",
".",
"TotalTimeout",
"{",
"return",
"p",
".",
"SocketTimeout",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"p",
".",
"TotalTimeout",
"\n",
"}"
]
| // socketTimeout validates and then calculates the timeout to be used for the socket
// based on Timeout and SocketTimeout values. | [
"socketTimeout",
"validates",
"and",
"then",
"calculates",
"the",
"timeout",
"to",
"be",
"used",
"for",
"the",
"socket",
"based",
"on",
"Timeout",
"and",
"SocketTimeout",
"values",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/policy.go#L148-L161 |
9,912 | aerospike/aerospike-client-go | examples/blob.go | EncodeBlob | func (p Person) EncodeBlob() ([]byte, error) {
return append([]byte(p.name)), nil
} | go | func (p Person) EncodeBlob() ([]byte, error) {
return append([]byte(p.name)), nil
} | [
"func",
"(",
"p",
"Person",
")",
"EncodeBlob",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"append",
"(",
"[",
"]",
"byte",
"(",
"p",
".",
"name",
")",
")",
",",
"nil",
"\n",
"}"
]
| // Define The AerospikeBlob interface | [
"Define",
"The",
"AerospikeBlob",
"interface"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/examples/blob.go#L28-L30 |
9,913 | aerospike/aerospike-client-go | examples/blob.go | DecodeBlob | func (p *Person) DecodeBlob(buf []byte) error {
p.name = string(buf)
return nil
} | go | func (p *Person) DecodeBlob(buf []byte) error {
p.name = string(buf)
return nil
} | [
"func",
"(",
"p",
"*",
"Person",
")",
"DecodeBlob",
"(",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"p",
".",
"name",
"=",
"string",
"(",
"buf",
")",
"\n",
"return",
"nil",
"\n",
"}"
]
| // Decoder is optional, and should be used manually | [
"Decoder",
"is",
"optional",
"and",
"should",
"be",
"used",
"manually"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/examples/blob.go#L33-L36 |
9,914 | aerospike/aerospike-client-go | statement.go | NewStatement | func NewStatement(ns string, set string, binNames ...string) *Statement {
return &Statement{
Namespace: ns,
SetName: set,
BinNames: binNames,
returnData: true,
TaskId: uint64(xornd.Int64()),
}
} | go | func NewStatement(ns string, set string, binNames ...string) *Statement {
return &Statement{
Namespace: ns,
SetName: set,
BinNames: binNames,
returnData: true,
TaskId: uint64(xornd.Int64()),
}
} | [
"func",
"NewStatement",
"(",
"ns",
"string",
",",
"set",
"string",
",",
"binNames",
"...",
"string",
")",
"*",
"Statement",
"{",
"return",
"&",
"Statement",
"{",
"Namespace",
":",
"ns",
",",
"SetName",
":",
"set",
",",
"BinNames",
":",
"binNames",
",",
"returnData",
":",
"true",
",",
"TaskId",
":",
"uint64",
"(",
"xornd",
".",
"Int64",
"(",
")",
")",
",",
"}",
"\n",
"}"
]
| // NewStatement initializes a new Statement instance. | [
"NewStatement",
"initializes",
"a",
"new",
"Statement",
"instance",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/statement.go#L54-L62 |
9,915 | aerospike/aerospike-client-go | statement.go | SetAggregateFunction | func (stmt *Statement) SetAggregateFunction(packageName string, functionName string, functionArgs []Value, returnData bool) {
stmt.packageName = packageName
stmt.functionName = functionName
stmt.functionArgs = functionArgs
stmt.returnData = returnData
} | go | func (stmt *Statement) SetAggregateFunction(packageName string, functionName string, functionArgs []Value, returnData bool) {
stmt.packageName = packageName
stmt.functionName = functionName
stmt.functionArgs = functionArgs
stmt.returnData = returnData
} | [
"func",
"(",
"stmt",
"*",
"Statement",
")",
"SetAggregateFunction",
"(",
"packageName",
"string",
",",
"functionName",
"string",
",",
"functionArgs",
"[",
"]",
"Value",
",",
"returnData",
"bool",
")",
"{",
"stmt",
".",
"packageName",
"=",
"packageName",
"\n",
"stmt",
".",
"functionName",
"=",
"functionName",
"\n",
"stmt",
".",
"functionArgs",
"=",
"functionArgs",
"\n",
"stmt",
".",
"returnData",
"=",
"returnData",
"\n",
"}"
]
| // SetAggregateFunction sets aggregation function parameters.
// This function will be called on both the server
// and client for each selected item. | [
"SetAggregateFunction",
"sets",
"aggregation",
"function",
"parameters",
".",
"This",
"function",
"will",
"be",
"called",
"on",
"both",
"the",
"server",
"and",
"client",
"for",
"each",
"selected",
"item",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/statement.go#L114-L119 |
9,916 | aerospike/aerospike-client-go | statement.go | setTaskID | func (stmt *Statement) setTaskID() {
for stmt.TaskId == 0 {
stmt.TaskId = uint64(xornd.Int64())
}
} | go | func (stmt *Statement) setTaskID() {
for stmt.TaskId == 0 {
stmt.TaskId = uint64(xornd.Int64())
}
} | [
"func",
"(",
"stmt",
"*",
"Statement",
")",
"setTaskID",
"(",
")",
"{",
"for",
"stmt",
".",
"TaskId",
"==",
"0",
"{",
"stmt",
".",
"TaskId",
"=",
"uint64",
"(",
"xornd",
".",
"Int64",
"(",
")",
")",
"\n",
"}",
"\n",
"}"
]
| // Always set the taskID client-side to a non-zero random value | [
"Always",
"set",
"the",
"taskID",
"client",
"-",
"side",
"to",
"a",
"non",
"-",
"zero",
"random",
"value"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/statement.go#L127-L131 |
9,917 | aerospike/aerospike-client-go | logger/logger.go | SetLevel | func (lgr *logger) SetLevel(level LogPriority) {
lgr.mutex.Lock()
defer lgr.mutex.Unlock()
lgr.level = level
} | go | func (lgr *logger) SetLevel(level LogPriority) {
lgr.mutex.Lock()
defer lgr.mutex.Unlock()
lgr.level = level
} | [
"func",
"(",
"lgr",
"*",
"logger",
")",
"SetLevel",
"(",
"level",
"LogPriority",
")",
"{",
"lgr",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"lgr",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"lgr",
".",
"level",
"=",
"level",
"\n",
"}"
]
| // SetLevel sets logging level. Default is ERR. | [
"SetLevel",
"sets",
"logging",
"level",
".",
"Default",
"is",
"ERR",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/logger/logger.go#L65-L70 |
9,918 | aerospike/aerospike-client-go | logger/logger.go | LogAtLevel | func (lgr *logger) LogAtLevel(level LogPriority, format string, v ...interface{}) {
switch level {
case DEBUG:
lgr.Debug(format, v...)
case INFO:
lgr.Info(format, v...)
case WARNING:
lgr.Warn(format, v...)
case ERR:
lgr.Error(format, v...)
}
} | go | func (lgr *logger) LogAtLevel(level LogPriority, format string, v ...interface{}) {
switch level {
case DEBUG:
lgr.Debug(format, v...)
case INFO:
lgr.Info(format, v...)
case WARNING:
lgr.Warn(format, v...)
case ERR:
lgr.Error(format, v...)
}
} | [
"func",
"(",
"lgr",
"*",
"logger",
")",
"LogAtLevel",
"(",
"level",
"LogPriority",
",",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"switch",
"level",
"{",
"case",
"DEBUG",
":",
"lgr",
".",
"Debug",
"(",
"format",
",",
"v",
"...",
")",
"\n",
"case",
"INFO",
":",
"lgr",
".",
"Info",
"(",
"format",
",",
"v",
"...",
")",
"\n",
"case",
"WARNING",
":",
"lgr",
".",
"Warn",
"(",
"format",
",",
"v",
"...",
")",
"\n",
"case",
"ERR",
":",
"lgr",
".",
"Error",
"(",
"format",
",",
"v",
"...",
")",
"\n",
"}",
"\n",
"}"
]
| // Error logs a message if log level allows to do so. | [
"Error",
"logs",
"a",
"message",
"if",
"log",
"level",
"allows",
"to",
"do",
"so",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/logger/logger.go#L73-L84 |
9,919 | aerospike/aerospike-client-go | logger/logger.go | Debug | func (lgr *logger) Debug(format string, v ...interface{}) {
lgr.mutex.RLock()
defer lgr.mutex.RUnlock()
if lgr.level <= DEBUG {
if l, ok := lgr.Logger.(*log.Logger); ok {
l.Output(2, fmt.Sprintf(format, v...))
} else {
lgr.Logger.Printf(format, v...)
}
}
} | go | func (lgr *logger) Debug(format string, v ...interface{}) {
lgr.mutex.RLock()
defer lgr.mutex.RUnlock()
if lgr.level <= DEBUG {
if l, ok := lgr.Logger.(*log.Logger); ok {
l.Output(2, fmt.Sprintf(format, v...))
} else {
lgr.Logger.Printf(format, v...)
}
}
} | [
"func",
"(",
"lgr",
"*",
"logger",
")",
"Debug",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"lgr",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"lgr",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"lgr",
".",
"level",
"<=",
"DEBUG",
"{",
"if",
"l",
",",
"ok",
":=",
"lgr",
".",
"Logger",
".",
"(",
"*",
"log",
".",
"Logger",
")",
";",
"ok",
"{",
"l",
".",
"Output",
"(",
"2",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"v",
"...",
")",
")",
"\n",
"}",
"else",
"{",
"lgr",
".",
"Logger",
".",
"Printf",
"(",
"format",
",",
"v",
"...",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
]
| // Debug logs a message if log level allows to do so. | [
"Debug",
"logs",
"a",
"message",
"if",
"log",
"level",
"allows",
"to",
"do",
"so",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/logger/logger.go#L87-L98 |
9,920 | aerospike/aerospike-client-go | types/result_code.go | KeepConnection | func KeepConnection(err error) bool {
// if error is not an AerospikeError, Throw the connection away conservatively
ae, ok := err.(AerospikeError)
if !ok {
return false
}
switch ae.resultCode {
case 0, // Zero Value
QUERY_TERMINATED,
SCAN_TERMINATED,
PARSE_ERROR,
SERIALIZE_ERROR,
SERVER_NOT_AVAILABLE,
SCAN_ABORT,
QUERY_ABORTED,
INVALID_NODE_ERROR,
SERVER_MEM_ERROR,
TIMEOUT,
INDEX_OOM,
QUERY_TIMEOUT:
return false
default:
return true
}
} | go | func KeepConnection(err error) bool {
// if error is not an AerospikeError, Throw the connection away conservatively
ae, ok := err.(AerospikeError)
if !ok {
return false
}
switch ae.resultCode {
case 0, // Zero Value
QUERY_TERMINATED,
SCAN_TERMINATED,
PARSE_ERROR,
SERIALIZE_ERROR,
SERVER_NOT_AVAILABLE,
SCAN_ABORT,
QUERY_ABORTED,
INVALID_NODE_ERROR,
SERVER_MEM_ERROR,
TIMEOUT,
INDEX_OOM,
QUERY_TIMEOUT:
return false
default:
return true
}
} | [
"func",
"KeepConnection",
"(",
"err",
"error",
")",
"bool",
"{",
"// if error is not an AerospikeError, Throw the connection away conservatively",
"ae",
",",
"ok",
":=",
"err",
".",
"(",
"AerospikeError",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"switch",
"ae",
".",
"resultCode",
"{",
"case",
"0",
",",
"// Zero Value",
"QUERY_TERMINATED",
",",
"SCAN_TERMINATED",
",",
"PARSE_ERROR",
",",
"SERIALIZE_ERROR",
",",
"SERVER_NOT_AVAILABLE",
",",
"SCAN_ABORT",
",",
"QUERY_ABORTED",
",",
"INVALID_NODE_ERROR",
",",
"SERVER_MEM_ERROR",
",",
"TIMEOUT",
",",
"INDEX_OOM",
",",
"QUERY_TIMEOUT",
":",
"return",
"false",
"\n",
"default",
":",
"return",
"true",
"\n",
"}",
"\n",
"}"
]
| // Should connection be put back into pool. | [
"Should",
"connection",
"be",
"put",
"back",
"into",
"pool",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/types/result_code.go#L254-L280 |
9,921 | aerospike/aerospike-client-go | batch_policy.go | NewBatchPolicy | func NewBatchPolicy() *BatchPolicy {
return &BatchPolicy{
BasePolicy: *NewPolicy(),
ConcurrentNodes: 1,
AllowInline: true,
AllowPartialResults: false,
SendSetName: false,
}
} | go | func NewBatchPolicy() *BatchPolicy {
return &BatchPolicy{
BasePolicy: *NewPolicy(),
ConcurrentNodes: 1,
AllowInline: true,
AllowPartialResults: false,
SendSetName: false,
}
} | [
"func",
"NewBatchPolicy",
"(",
")",
"*",
"BatchPolicy",
"{",
"return",
"&",
"BatchPolicy",
"{",
"BasePolicy",
":",
"*",
"NewPolicy",
"(",
")",
",",
"ConcurrentNodes",
":",
"1",
",",
"AllowInline",
":",
"true",
",",
"AllowPartialResults",
":",
"false",
",",
"SendSetName",
":",
"false",
",",
"}",
"\n",
"}"
]
| // NewBatchPolicy initializes a new BatchPolicy instance with default parameters. | [
"NewBatchPolicy",
"initializes",
"a",
"new",
"BatchPolicy",
"instance",
"with",
"default",
"parameters",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/batch_policy.go#L69-L77 |
9,922 | aerospike/aerospike-client-go | connection_heap.go | newSingleConnectionHeap | func newSingleConnectionHeap(size int) *singleConnectionHeap {
if size <= 0 {
panic("Heap size cannot be less than 1")
}
return &singleConnectionHeap{
full: false,
data: make([]*Connection, uint32(size)),
size: uint32(size),
}
} | go | func newSingleConnectionHeap(size int) *singleConnectionHeap {
if size <= 0 {
panic("Heap size cannot be less than 1")
}
return &singleConnectionHeap{
full: false,
data: make([]*Connection, uint32(size)),
size: uint32(size),
}
} | [
"func",
"newSingleConnectionHeap",
"(",
"size",
"int",
")",
"*",
"singleConnectionHeap",
"{",
"if",
"size",
"<=",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"singleConnectionHeap",
"{",
"full",
":",
"false",
",",
"data",
":",
"make",
"(",
"[",
"]",
"*",
"Connection",
",",
"uint32",
"(",
"size",
")",
")",
",",
"size",
":",
"uint32",
"(",
"size",
")",
",",
"}",
"\n",
"}"
]
| // newSingleConnectionHeap creates a new heap with initial size. | [
"newSingleConnectionHeap",
"creates",
"a",
"new",
"heap",
"with",
"initial",
"size",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/connection_heap.go#L34-L44 |
9,923 | aerospike/aerospike-client-go | connection_heap.go | DropIdleTail | func (h *singleConnectionHeap) DropIdleTail() bool {
h.mutex.Lock()
defer h.mutex.Unlock()
// if heap is not empty
if h.full || (h.tail != h.head) {
conn := h.data[(h.tail+1)%h.size]
if conn.IsConnected() && !conn.isIdle() {
return false
}
h.tail = (h.tail + 1) % h.size
h.data[h.tail] = nil
h.full = false
conn.Close()
return true
}
return false
} | go | func (h *singleConnectionHeap) DropIdleTail() bool {
h.mutex.Lock()
defer h.mutex.Unlock()
// if heap is not empty
if h.full || (h.tail != h.head) {
conn := h.data[(h.tail+1)%h.size]
if conn.IsConnected() && !conn.isIdle() {
return false
}
h.tail = (h.tail + 1) % h.size
h.data[h.tail] = nil
h.full = false
conn.Close()
return true
}
return false
} | [
"func",
"(",
"h",
"*",
"singleConnectionHeap",
")",
"DropIdleTail",
"(",
")",
"bool",
"{",
"h",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"// if heap is not empty",
"if",
"h",
".",
"full",
"||",
"(",
"h",
".",
"tail",
"!=",
"h",
".",
"head",
")",
"{",
"conn",
":=",
"h",
".",
"data",
"[",
"(",
"h",
".",
"tail",
"+",
"1",
")",
"%",
"h",
".",
"size",
"]",
"\n\n",
"if",
"conn",
".",
"IsConnected",
"(",
")",
"&&",
"!",
"conn",
".",
"isIdle",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"h",
".",
"tail",
"=",
"(",
"h",
".",
"tail",
"+",
"1",
")",
"%",
"h",
".",
"size",
"\n",
"h",
".",
"data",
"[",
"h",
".",
"tail",
"]",
"=",
"nil",
"\n",
"h",
".",
"full",
"=",
"false",
"\n",
"conn",
".",
"Close",
"(",
")",
"\n\n",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
]
| // DropIdleTail closes idle connection in tail.
// It will return true if tail connection was idle and dropped | [
"DropIdleTail",
"closes",
"idle",
"connection",
"in",
"tail",
".",
"It",
"will",
"return",
"true",
"if",
"tail",
"connection",
"was",
"idle",
"and",
"dropped"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/connection_heap.go#L87-L108 |
9,924 | aerospike/aerospike-client-go | connection_heap.go | Len | func (h *singleConnectionHeap) Len() int {
cnt := 0
h.mutex.Lock()
if !h.full {
if h.head >= h.tail {
cnt = int(h.head) - int(h.tail)
} else {
cnt = int(h.size) - (int(h.tail) - int(h.head))
}
} else {
cnt = int(h.size)
}
h.mutex.Unlock()
return cnt
} | go | func (h *singleConnectionHeap) Len() int {
cnt := 0
h.mutex.Lock()
if !h.full {
if h.head >= h.tail {
cnt = int(h.head) - int(h.tail)
} else {
cnt = int(h.size) - (int(h.tail) - int(h.head))
}
} else {
cnt = int(h.size)
}
h.mutex.Unlock()
return cnt
} | [
"func",
"(",
"h",
"*",
"singleConnectionHeap",
")",
"Len",
"(",
")",
"int",
"{",
"cnt",
":=",
"0",
"\n",
"h",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n\n",
"if",
"!",
"h",
".",
"full",
"{",
"if",
"h",
".",
"head",
">=",
"h",
".",
"tail",
"{",
"cnt",
"=",
"int",
"(",
"h",
".",
"head",
")",
"-",
"int",
"(",
"h",
".",
"tail",
")",
"\n",
"}",
"else",
"{",
"cnt",
"=",
"int",
"(",
"h",
".",
"size",
")",
"-",
"(",
"int",
"(",
"h",
".",
"tail",
")",
"-",
"int",
"(",
"h",
".",
"head",
")",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"cnt",
"=",
"int",
"(",
"h",
".",
"size",
")",
"\n",
"}",
"\n",
"h",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"return",
"cnt",
"\n",
"}"
]
| // Len returns the number of connections in the heap | [
"Len",
"returns",
"the",
"number",
"of",
"connections",
"in",
"the",
"heap"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/connection_heap.go#L111-L126 |
9,925 | aerospike/aerospike-client-go | connection_heap.go | DropIdle | func (h *connectionHeap) DropIdle() {
for i := 0; i < len(h.heaps); i++ {
for h.heaps[i].DropIdleTail() {
}
}
} | go | func (h *connectionHeap) DropIdle() {
for i := 0; i < len(h.heaps); i++ {
for h.heaps[i].DropIdleTail() {
}
}
} | [
"func",
"(",
"h",
"*",
"connectionHeap",
")",
"DropIdle",
"(",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"h",
".",
"heaps",
")",
";",
"i",
"++",
"{",
"for",
"h",
".",
"heaps",
"[",
"i",
"]",
".",
"DropIdleTail",
"(",
")",
"{",
"}",
"\n",
"}",
"\n",
"}"
]
| // DropIdle closes all idle connections. | [
"DropIdle",
"closes",
"all",
"idle",
"connections",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/connection_heap.go#L191-L196 |
9,926 | aerospike/aerospike-client-go | connection_heap.go | Len | func (h *connectionHeap) Len(hint byte) (cnt int) {
if int(hint) < len(h.heaps) {
cnt = h.heaps[hint].Len()
} else {
for i := range h.heaps {
cnt += h.heaps[i].Len()
}
}
return cnt
} | go | func (h *connectionHeap) Len(hint byte) (cnt int) {
if int(hint) < len(h.heaps) {
cnt = h.heaps[hint].Len()
} else {
for i := range h.heaps {
cnt += h.heaps[i].Len()
}
}
return cnt
} | [
"func",
"(",
"h",
"*",
"connectionHeap",
")",
"Len",
"(",
"hint",
"byte",
")",
"(",
"cnt",
"int",
")",
"{",
"if",
"int",
"(",
"hint",
")",
"<",
"len",
"(",
"h",
".",
"heaps",
")",
"{",
"cnt",
"=",
"h",
".",
"heaps",
"[",
"hint",
"]",
".",
"Len",
"(",
")",
"\n",
"}",
"else",
"{",
"for",
"i",
":=",
"range",
"h",
".",
"heaps",
"{",
"cnt",
"+=",
"h",
".",
"heaps",
"[",
"i",
"]",
".",
"Len",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"cnt",
"\n",
"}"
]
| // Len returns the number of connections in all or a specific sub-heap.
// If hint is < 0 or invalid, then the total number of connections will be returned. | [
"Len",
"returns",
"the",
"number",
"of",
"connections",
"in",
"all",
"or",
"a",
"specific",
"sub",
"-",
"heap",
".",
"If",
"hint",
"is",
"<",
"0",
"or",
"invalid",
"then",
"the",
"total",
"number",
"of",
"connections",
"will",
"be",
"returned",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/connection_heap.go#L205-L215 |
9,927 | aerospike/aerospike-client-go | partitions.go | clone | func (p *Partitions) clone() *Partitions {
replicas := make([][]*Node, len(p.Replicas))
for i := range p.Replicas {
r := make([]*Node, len(p.Replicas[i]))
copy(r, p.Replicas[i])
replicas[i] = r
}
regimes := make([]int, len(p.regimes))
copy(regimes, p.regimes)
return &Partitions{
Replicas: replicas,
CPMode: p.CPMode,
regimes: regimes,
}
} | go | func (p *Partitions) clone() *Partitions {
replicas := make([][]*Node, len(p.Replicas))
for i := range p.Replicas {
r := make([]*Node, len(p.Replicas[i]))
copy(r, p.Replicas[i])
replicas[i] = r
}
regimes := make([]int, len(p.regimes))
copy(regimes, p.regimes)
return &Partitions{
Replicas: replicas,
CPMode: p.CPMode,
regimes: regimes,
}
} | [
"func",
"(",
"p",
"*",
"Partitions",
")",
"clone",
"(",
")",
"*",
"Partitions",
"{",
"replicas",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"*",
"Node",
",",
"len",
"(",
"p",
".",
"Replicas",
")",
")",
"\n\n",
"for",
"i",
":=",
"range",
"p",
".",
"Replicas",
"{",
"r",
":=",
"make",
"(",
"[",
"]",
"*",
"Node",
",",
"len",
"(",
"p",
".",
"Replicas",
"[",
"i",
"]",
")",
")",
"\n",
"copy",
"(",
"r",
",",
"p",
".",
"Replicas",
"[",
"i",
"]",
")",
"\n",
"replicas",
"[",
"i",
"]",
"=",
"r",
"\n",
"}",
"\n\n",
"regimes",
":=",
"make",
"(",
"[",
"]",
"int",
",",
"len",
"(",
"p",
".",
"regimes",
")",
")",
"\n",
"copy",
"(",
"regimes",
",",
"p",
".",
"regimes",
")",
"\n\n",
"return",
"&",
"Partitions",
"{",
"Replicas",
":",
"replicas",
",",
"CPMode",
":",
"p",
".",
"CPMode",
",",
"regimes",
":",
"regimes",
",",
"}",
"\n",
"}"
]
| // Copy partition map while reserving space for a new replica count. | [
"Copy",
"partition",
"map",
"while",
"reserving",
"space",
"for",
"a",
"new",
"replica",
"count",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/partitions.go#L60-L77 |
9,928 | aerospike/aerospike-client-go | partitions.go | validate | func (pm partitionMap) validate() error {
masterNodePartitionNotDefined := map[string][]int{}
replicaNodePartitionNotDefined := map[string][]int{}
var errList []error
for nsName, partition := range pm {
if len(partition.regimes) != _PARTITIONS {
errList = append(errList, fmt.Errorf("Wrong number of regimes for namespace `%s`. Must be %d, but found %d..", nsName, _PARTITIONS, len(partition.regimes)))
}
for replica, partitionNodes := range partition.Replicas {
if len(partitionNodes) != _PARTITIONS {
errList = append(errList, fmt.Errorf("Wrong number of partitions for namespace `%s`, replica `%d`. Must be %d, but found %d.", nsName, replica, _PARTITIONS, len(partitionNodes)))
}
for pIndex, node := range partitionNodes {
if node == nil {
if replica == 0 {
masterNodePartitionNotDefined[nsName] = append(masterNodePartitionNotDefined[nsName], pIndex)
} else {
replicaNodePartitionNotDefined[nsName] = append(replicaNodePartitionNotDefined[nsName], pIndex)
}
}
}
}
}
if len(errList) > 0 || len(masterNodePartitionNotDefined) > 0 || len(replicaNodePartitionNotDefined) > 0 {
for nsName, partitionList := range masterNodePartitionNotDefined {
errList = append(errList, fmt.Errorf("Master partition nodes not defined for namespace `%s`: %d out of %d", nsName, len(partitionList), _PARTITIONS))
}
for nsName, partitionList := range replicaNodePartitionNotDefined {
errList = append(errList, fmt.Errorf("Replica partition nodes not defined for namespace `%s`: %d out of %d", nsName, len(partitionList), _PARTITIONS))
}
errList = append(errList, errors.New("Partition map errors normally occur when the cluster has partitioned due to network anomaly or node crash, or is not configured properly. Refer to https://www.aerospike.com/docs/operations/configure for more information."))
return NewAerospikeError(INVALID_CLUSTER_PARTITION_MAP, mergeErrors(errList).Error())
}
return nil
} | go | func (pm partitionMap) validate() error {
masterNodePartitionNotDefined := map[string][]int{}
replicaNodePartitionNotDefined := map[string][]int{}
var errList []error
for nsName, partition := range pm {
if len(partition.regimes) != _PARTITIONS {
errList = append(errList, fmt.Errorf("Wrong number of regimes for namespace `%s`. Must be %d, but found %d..", nsName, _PARTITIONS, len(partition.regimes)))
}
for replica, partitionNodes := range partition.Replicas {
if len(partitionNodes) != _PARTITIONS {
errList = append(errList, fmt.Errorf("Wrong number of partitions for namespace `%s`, replica `%d`. Must be %d, but found %d.", nsName, replica, _PARTITIONS, len(partitionNodes)))
}
for pIndex, node := range partitionNodes {
if node == nil {
if replica == 0 {
masterNodePartitionNotDefined[nsName] = append(masterNodePartitionNotDefined[nsName], pIndex)
} else {
replicaNodePartitionNotDefined[nsName] = append(replicaNodePartitionNotDefined[nsName], pIndex)
}
}
}
}
}
if len(errList) > 0 || len(masterNodePartitionNotDefined) > 0 || len(replicaNodePartitionNotDefined) > 0 {
for nsName, partitionList := range masterNodePartitionNotDefined {
errList = append(errList, fmt.Errorf("Master partition nodes not defined for namespace `%s`: %d out of %d", nsName, len(partitionList), _PARTITIONS))
}
for nsName, partitionList := range replicaNodePartitionNotDefined {
errList = append(errList, fmt.Errorf("Replica partition nodes not defined for namespace `%s`: %d out of %d", nsName, len(partitionList), _PARTITIONS))
}
errList = append(errList, errors.New("Partition map errors normally occur when the cluster has partitioned due to network anomaly or node crash, or is not configured properly. Refer to https://www.aerospike.com/docs/operations/configure for more information."))
return NewAerospikeError(INVALID_CLUSTER_PARTITION_MAP, mergeErrors(errList).Error())
}
return nil
} | [
"func",
"(",
"pm",
"partitionMap",
")",
"validate",
"(",
")",
"error",
"{",
"masterNodePartitionNotDefined",
":=",
"map",
"[",
"string",
"]",
"[",
"]",
"int",
"{",
"}",
"\n",
"replicaNodePartitionNotDefined",
":=",
"map",
"[",
"string",
"]",
"[",
"]",
"int",
"{",
"}",
"\n",
"var",
"errList",
"[",
"]",
"error",
"\n\n",
"for",
"nsName",
",",
"partition",
":=",
"range",
"pm",
"{",
"if",
"len",
"(",
"partition",
".",
"regimes",
")",
"!=",
"_PARTITIONS",
"{",
"errList",
"=",
"append",
"(",
"errList",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"nsName",
",",
"_PARTITIONS",
",",
"len",
"(",
"partition",
".",
"regimes",
")",
")",
")",
"\n",
"}",
"\n\n",
"for",
"replica",
",",
"partitionNodes",
":=",
"range",
"partition",
".",
"Replicas",
"{",
"if",
"len",
"(",
"partitionNodes",
")",
"!=",
"_PARTITIONS",
"{",
"errList",
"=",
"append",
"(",
"errList",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"nsName",
",",
"replica",
",",
"_PARTITIONS",
",",
"len",
"(",
"partitionNodes",
")",
")",
")",
"\n",
"}",
"\n\n",
"for",
"pIndex",
",",
"node",
":=",
"range",
"partitionNodes",
"{",
"if",
"node",
"==",
"nil",
"{",
"if",
"replica",
"==",
"0",
"{",
"masterNodePartitionNotDefined",
"[",
"nsName",
"]",
"=",
"append",
"(",
"masterNodePartitionNotDefined",
"[",
"nsName",
"]",
",",
"pIndex",
")",
"\n",
"}",
"else",
"{",
"replicaNodePartitionNotDefined",
"[",
"nsName",
"]",
"=",
"append",
"(",
"replicaNodePartitionNotDefined",
"[",
"nsName",
"]",
",",
"pIndex",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"errList",
")",
">",
"0",
"||",
"len",
"(",
"masterNodePartitionNotDefined",
")",
">",
"0",
"||",
"len",
"(",
"replicaNodePartitionNotDefined",
")",
">",
"0",
"{",
"for",
"nsName",
",",
"partitionList",
":=",
"range",
"masterNodePartitionNotDefined",
"{",
"errList",
"=",
"append",
"(",
"errList",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"nsName",
",",
"len",
"(",
"partitionList",
")",
",",
"_PARTITIONS",
")",
")",
"\n",
"}",
"\n\n",
"for",
"nsName",
",",
"partitionList",
":=",
"range",
"replicaNodePartitionNotDefined",
"{",
"errList",
"=",
"append",
"(",
"errList",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"nsName",
",",
"len",
"(",
"partitionList",
")",
",",
"_PARTITIONS",
")",
")",
"\n",
"}",
"\n\n",
"errList",
"=",
"append",
"(",
"errList",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
")",
"\n",
"return",
"NewAerospikeError",
"(",
"INVALID_CLUSTER_PARTITION_MAP",
",",
"mergeErrors",
"(",
"errList",
")",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // naively validates the partition map | [
"naively",
"validates",
"the",
"partition",
"map"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/partitions.go#L129-L170 |
9,929 | aerospike/aerospike-client-go | examples/batch.go | writeRecords | func writeRecords(
client *as.Client,
keyPrefix string,
binName string,
valuePrefix string,
size int,
) {
for i := 1; i <= size; i++ {
key, _ := as.NewKey(*shared.Namespace, *shared.Set, keyPrefix+strconv.Itoa(i))
bin := as.NewBin(binName, valuePrefix+strconv.Itoa(i))
log.Printf("Put: ns=%s set=%s key=%s bin=%s value=%s",
key.Namespace(), key.SetName(), key.Value(), bin.Name, bin.Value)
client.PutBins(shared.WritePolicy, key, bin)
}
} | go | func writeRecords(
client *as.Client,
keyPrefix string,
binName string,
valuePrefix string,
size int,
) {
for i := 1; i <= size; i++ {
key, _ := as.NewKey(*shared.Namespace, *shared.Set, keyPrefix+strconv.Itoa(i))
bin := as.NewBin(binName, valuePrefix+strconv.Itoa(i))
log.Printf("Put: ns=%s set=%s key=%s bin=%s value=%s",
key.Namespace(), key.SetName(), key.Value(), bin.Name, bin.Value)
client.PutBins(shared.WritePolicy, key, bin)
}
} | [
"func",
"writeRecords",
"(",
"client",
"*",
"as",
".",
"Client",
",",
"keyPrefix",
"string",
",",
"binName",
"string",
",",
"valuePrefix",
"string",
",",
"size",
"int",
",",
")",
"{",
"for",
"i",
":=",
"1",
";",
"i",
"<=",
"size",
";",
"i",
"++",
"{",
"key",
",",
"_",
":=",
"as",
".",
"NewKey",
"(",
"*",
"shared",
".",
"Namespace",
",",
"*",
"shared",
".",
"Set",
",",
"keyPrefix",
"+",
"strconv",
".",
"Itoa",
"(",
"i",
")",
")",
"\n",
"bin",
":=",
"as",
".",
"NewBin",
"(",
"binName",
",",
"valuePrefix",
"+",
"strconv",
".",
"Itoa",
"(",
"i",
")",
")",
"\n\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"key",
".",
"Namespace",
"(",
")",
",",
"key",
".",
"SetName",
"(",
")",
",",
"key",
".",
"Value",
"(",
")",
",",
"bin",
".",
"Name",
",",
"bin",
".",
"Value",
")",
"\n\n",
"client",
".",
"PutBins",
"(",
"shared",
".",
"WritePolicy",
",",
"key",
",",
"bin",
")",
"\n",
"}",
"\n",
"}"
]
| /**
* Write records individually.
*/ | [
"Write",
"records",
"individually",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/examples/batch.go#L45-L61 |
9,930 | aerospike/aerospike-client-go | examples/batch.go | batchExists | func batchExists(
client *as.Client,
keyPrefix string,
size int,
) {
// Batch into one call.
keys := make([]*as.Key, size)
for i := 0; i < size; i++ {
keys[i], _ = as.NewKey(*shared.Namespace, *shared.Set, keyPrefix+strconv.Itoa(i+1))
}
existsArray, err := client.BatchExists(nil, keys)
shared.PanicOnError(err)
for i := 0; i < len(existsArray); i++ {
key := keys[i]
exists := existsArray[i]
log.Printf("Record: ns=%s set=%s key=%s exists=%t",
key.Namespace(), key.SetName(), key.Value(), exists)
}
} | go | func batchExists(
client *as.Client,
keyPrefix string,
size int,
) {
// Batch into one call.
keys := make([]*as.Key, size)
for i := 0; i < size; i++ {
keys[i], _ = as.NewKey(*shared.Namespace, *shared.Set, keyPrefix+strconv.Itoa(i+1))
}
existsArray, err := client.BatchExists(nil, keys)
shared.PanicOnError(err)
for i := 0; i < len(existsArray); i++ {
key := keys[i]
exists := existsArray[i]
log.Printf("Record: ns=%s set=%s key=%s exists=%t",
key.Namespace(), key.SetName(), key.Value(), exists)
}
} | [
"func",
"batchExists",
"(",
"client",
"*",
"as",
".",
"Client",
",",
"keyPrefix",
"string",
",",
"size",
"int",
",",
")",
"{",
"// Batch into one call.",
"keys",
":=",
"make",
"(",
"[",
"]",
"*",
"as",
".",
"Key",
",",
"size",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
"{",
"keys",
"[",
"i",
"]",
",",
"_",
"=",
"as",
".",
"NewKey",
"(",
"*",
"shared",
".",
"Namespace",
",",
"*",
"shared",
".",
"Set",
",",
"keyPrefix",
"+",
"strconv",
".",
"Itoa",
"(",
"i",
"+",
"1",
")",
")",
"\n",
"}",
"\n\n",
"existsArray",
",",
"err",
":=",
"client",
".",
"BatchExists",
"(",
"nil",
",",
"keys",
")",
"\n",
"shared",
".",
"PanicOnError",
"(",
"err",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"existsArray",
")",
";",
"i",
"++",
"{",
"key",
":=",
"keys",
"[",
"i",
"]",
"\n",
"exists",
":=",
"existsArray",
"[",
"i",
"]",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"key",
".",
"Namespace",
"(",
")",
",",
"key",
".",
"SetName",
"(",
")",
",",
"key",
".",
"Value",
"(",
")",
",",
"exists",
")",
"\n",
"}",
"\n",
"}"
]
| /**
* Check existence of records in one batch.
*/ | [
"Check",
"existence",
"of",
"records",
"in",
"one",
"batch",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/examples/batch.go#L66-L87 |
9,931 | aerospike/aerospike-client-go | examples/batch.go | batchReads | func batchReads(
client *as.Client,
keyPrefix string,
binName string,
size int,
) {
// Batch gets into one call.
keys := make([]*as.Key, size)
for i := 0; i < size; i++ {
keys[i], _ = as.NewKey(*shared.Namespace, *shared.Set, keyPrefix+strconv.Itoa(i+1))
}
records, err := client.BatchGet(nil, keys, binName)
shared.PanicOnError(err)
for i := 0; i < len(records); i++ {
key := keys[i]
record := records[i]
level := asl.ERR
var value interface{}
if record != nil {
level = asl.INFO
value = record.Bins[binName]
}
asl.Logger.LogAtLevel(level, "Record: ns=%s set=%s key=%s bin=%s value=%s",
key.Namespace(), key.SetName(), key.Value(), binName, value)
}
if len(records) != size {
log.Fatalf("Record size mismatch. Expected %d. Received %d.", size, len(records))
}
} | go | func batchReads(
client *as.Client,
keyPrefix string,
binName string,
size int,
) {
// Batch gets into one call.
keys := make([]*as.Key, size)
for i := 0; i < size; i++ {
keys[i], _ = as.NewKey(*shared.Namespace, *shared.Set, keyPrefix+strconv.Itoa(i+1))
}
records, err := client.BatchGet(nil, keys, binName)
shared.PanicOnError(err)
for i := 0; i < len(records); i++ {
key := keys[i]
record := records[i]
level := asl.ERR
var value interface{}
if record != nil {
level = asl.INFO
value = record.Bins[binName]
}
asl.Logger.LogAtLevel(level, "Record: ns=%s set=%s key=%s bin=%s value=%s",
key.Namespace(), key.SetName(), key.Value(), binName, value)
}
if len(records) != size {
log.Fatalf("Record size mismatch. Expected %d. Received %d.", size, len(records))
}
} | [
"func",
"batchReads",
"(",
"client",
"*",
"as",
".",
"Client",
",",
"keyPrefix",
"string",
",",
"binName",
"string",
",",
"size",
"int",
",",
")",
"{",
"// Batch gets into one call.",
"keys",
":=",
"make",
"(",
"[",
"]",
"*",
"as",
".",
"Key",
",",
"size",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
"{",
"keys",
"[",
"i",
"]",
",",
"_",
"=",
"as",
".",
"NewKey",
"(",
"*",
"shared",
".",
"Namespace",
",",
"*",
"shared",
".",
"Set",
",",
"keyPrefix",
"+",
"strconv",
".",
"Itoa",
"(",
"i",
"+",
"1",
")",
")",
"\n",
"}",
"\n\n",
"records",
",",
"err",
":=",
"client",
".",
"BatchGet",
"(",
"nil",
",",
"keys",
",",
"binName",
")",
"\n",
"shared",
".",
"PanicOnError",
"(",
"err",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"records",
")",
";",
"i",
"++",
"{",
"key",
":=",
"keys",
"[",
"i",
"]",
"\n",
"record",
":=",
"records",
"[",
"i",
"]",
"\n",
"level",
":=",
"asl",
".",
"ERR",
"\n",
"var",
"value",
"interface",
"{",
"}",
"\n\n",
"if",
"record",
"!=",
"nil",
"{",
"level",
"=",
"asl",
".",
"INFO",
"\n",
"value",
"=",
"record",
".",
"Bins",
"[",
"binName",
"]",
"\n",
"}",
"\n",
"asl",
".",
"Logger",
".",
"LogAtLevel",
"(",
"level",
",",
"\"",
"\"",
",",
"key",
".",
"Namespace",
"(",
")",
",",
"key",
".",
"SetName",
"(",
")",
",",
"key",
".",
"Value",
"(",
")",
",",
"binName",
",",
"value",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"records",
")",
"!=",
"size",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"size",
",",
"len",
"(",
"records",
")",
")",
"\n",
"}",
"\n",
"}"
]
| /**
* Read records in one batch.
*/ | [
"Read",
"records",
"in",
"one",
"batch",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/examples/batch.go#L92-L124 |
9,932 | aerospike/aerospike-client-go | examples/batch.go | batchReadHeaders | func batchReadHeaders(
client *as.Client,
keyPrefix string,
size int,
) {
// Batch gets into one call.
keys := make([]*as.Key, size)
for i := 0; i < size; i++ {
keys[i], _ = as.NewKey(*shared.Namespace, *shared.Set, keyPrefix+strconv.Itoa(i+1))
}
records, err := client.BatchGetHeader(nil, keys)
shared.PanicOnError(err)
for i := 0; i < len(records); i++ {
key := keys[i]
record := records[i]
level := asl.ERR
generation := uint32(0)
expiration := uint32(0)
if record != nil && (record.Generation > 0 || record.Expiration > 0) {
level = asl.INFO
generation = record.Generation
expiration = record.Expiration
}
asl.Logger.LogAtLevel(level, "Record: ns=%s set=%s key=%s generation=%d expiration=%d",
key.Namespace(), key.SetName(), key.Value(), generation, expiration)
}
if len(records) != size {
log.Fatalf("Record size mismatch. Expected %d. Received %d.", size, len(records))
}
} | go | func batchReadHeaders(
client *as.Client,
keyPrefix string,
size int,
) {
// Batch gets into one call.
keys := make([]*as.Key, size)
for i := 0; i < size; i++ {
keys[i], _ = as.NewKey(*shared.Namespace, *shared.Set, keyPrefix+strconv.Itoa(i+1))
}
records, err := client.BatchGetHeader(nil, keys)
shared.PanicOnError(err)
for i := 0; i < len(records); i++ {
key := keys[i]
record := records[i]
level := asl.ERR
generation := uint32(0)
expiration := uint32(0)
if record != nil && (record.Generation > 0 || record.Expiration > 0) {
level = asl.INFO
generation = record.Generation
expiration = record.Expiration
}
asl.Logger.LogAtLevel(level, "Record: ns=%s set=%s key=%s generation=%d expiration=%d",
key.Namespace(), key.SetName(), key.Value(), generation, expiration)
}
if len(records) != size {
log.Fatalf("Record size mismatch. Expected %d. Received %d.", size, len(records))
}
} | [
"func",
"batchReadHeaders",
"(",
"client",
"*",
"as",
".",
"Client",
",",
"keyPrefix",
"string",
",",
"size",
"int",
",",
")",
"{",
"// Batch gets into one call.",
"keys",
":=",
"make",
"(",
"[",
"]",
"*",
"as",
".",
"Key",
",",
"size",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
"{",
"keys",
"[",
"i",
"]",
",",
"_",
"=",
"as",
".",
"NewKey",
"(",
"*",
"shared",
".",
"Namespace",
",",
"*",
"shared",
".",
"Set",
",",
"keyPrefix",
"+",
"strconv",
".",
"Itoa",
"(",
"i",
"+",
"1",
")",
")",
"\n",
"}",
"\n\n",
"records",
",",
"err",
":=",
"client",
".",
"BatchGetHeader",
"(",
"nil",
",",
"keys",
")",
"\n",
"shared",
".",
"PanicOnError",
"(",
"err",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"records",
")",
";",
"i",
"++",
"{",
"key",
":=",
"keys",
"[",
"i",
"]",
"\n",
"record",
":=",
"records",
"[",
"i",
"]",
"\n",
"level",
":=",
"asl",
".",
"ERR",
"\n",
"generation",
":=",
"uint32",
"(",
"0",
")",
"\n",
"expiration",
":=",
"uint32",
"(",
"0",
")",
"\n\n",
"if",
"record",
"!=",
"nil",
"&&",
"(",
"record",
".",
"Generation",
">",
"0",
"||",
"record",
".",
"Expiration",
">",
"0",
")",
"{",
"level",
"=",
"asl",
".",
"INFO",
"\n",
"generation",
"=",
"record",
".",
"Generation",
"\n",
"expiration",
"=",
"record",
".",
"Expiration",
"\n",
"}",
"\n",
"asl",
".",
"Logger",
".",
"LogAtLevel",
"(",
"level",
",",
"\"",
"\"",
",",
"key",
".",
"Namespace",
"(",
")",
",",
"key",
".",
"SetName",
"(",
")",
",",
"key",
".",
"Value",
"(",
")",
",",
"generation",
",",
"expiration",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"records",
")",
"!=",
"size",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"size",
",",
"len",
"(",
"records",
")",
")",
"\n",
"}",
"\n",
"}"
]
| /**
* Read record header data in one batch.
*/ | [
"Read",
"record",
"header",
"data",
"in",
"one",
"batch",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/examples/batch.go#L129-L162 |
9,933 | aerospike/aerospike-client-go | task_register.go | NewRegisterTask | func NewRegisterTask(cluster *Cluster, packageName string) *RegisterTask {
return &RegisterTask{
baseTask: newTask(cluster),
packageName: packageName,
}
} | go | func NewRegisterTask(cluster *Cluster, packageName string) *RegisterTask {
return &RegisterTask{
baseTask: newTask(cluster),
packageName: packageName,
}
} | [
"func",
"NewRegisterTask",
"(",
"cluster",
"*",
"Cluster",
",",
"packageName",
"string",
")",
"*",
"RegisterTask",
"{",
"return",
"&",
"RegisterTask",
"{",
"baseTask",
":",
"newTask",
"(",
"cluster",
")",
",",
"packageName",
":",
"packageName",
",",
"}",
"\n",
"}"
]
| // NewRegisterTask initializes a RegisterTask with fields needed to query server nodes. | [
"NewRegisterTask",
"initializes",
"a",
"RegisterTask",
"with",
"fields",
"needed",
"to",
"query",
"server",
"nodes",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/task_register.go#L29-L34 |
9,934 | aerospike/aerospike-client-go | task_register.go | IsDone | func (tskr *RegisterTask) IsDone() (bool, error) {
command := "udf-list"
nodes := tskr.cluster.GetNodes()
done := false
for _, node := range nodes {
responseMap, err := node.requestInfoWithRetry(&tskr.cluster.infoPolicy, 5, command)
if err != nil {
return false, err
}
for _, response := range responseMap {
find := "filename=" + tskr.packageName
index := strings.Index(response, find)
if index < 0 {
return false, nil
}
done = true
}
}
return done, nil
} | go | func (tskr *RegisterTask) IsDone() (bool, error) {
command := "udf-list"
nodes := tskr.cluster.GetNodes()
done := false
for _, node := range nodes {
responseMap, err := node.requestInfoWithRetry(&tskr.cluster.infoPolicy, 5, command)
if err != nil {
return false, err
}
for _, response := range responseMap {
find := "filename=" + tskr.packageName
index := strings.Index(response, find)
if index < 0 {
return false, nil
}
done = true
}
}
return done, nil
} | [
"func",
"(",
"tskr",
"*",
"RegisterTask",
")",
"IsDone",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"command",
":=",
"\"",
"\"",
"\n",
"nodes",
":=",
"tskr",
".",
"cluster",
".",
"GetNodes",
"(",
")",
"\n",
"done",
":=",
"false",
"\n\n",
"for",
"_",
",",
"node",
":=",
"range",
"nodes",
"{",
"responseMap",
",",
"err",
":=",
"node",
".",
"requestInfoWithRetry",
"(",
"&",
"tskr",
".",
"cluster",
".",
"infoPolicy",
",",
"5",
",",
"command",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"response",
":=",
"range",
"responseMap",
"{",
"find",
":=",
"\"",
"\"",
"+",
"tskr",
".",
"packageName",
"\n",
"index",
":=",
"strings",
".",
"Index",
"(",
"response",
",",
"find",
")",
"\n\n",
"if",
"index",
"<",
"0",
"{",
"return",
"false",
",",
"nil",
"\n",
"}",
"\n",
"done",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"done",
",",
"nil",
"\n",
"}"
]
| // IsDone will query all nodes for task completion status. | [
"IsDone",
"will",
"query",
"all",
"nodes",
"for",
"task",
"completion",
"status",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/task_register.go#L37-L59 |
9,935 | aerospike/aerospike-client-go | internal/lua/lua_list.go | registerLuaListType | func registerLuaListType(L *lua.LState) {
mt := L.NewTypeMetatable(luaLuaListTypeName)
// List package
L.SetGlobal("List", mt)
// static attributes
L.SetMetatable(mt, mt)
// list package
mt = L.NewTypeMetatable(luaLuaListTypeName)
L.SetGlobal("list", mt)
// static attributes
L.SetField(mt, "__call", L.NewFunction(newLuaList))
L.SetField(mt, "create", L.NewFunction(createLuaList))
L.SetField(mt, "size", L.NewFunction(luaListSize))
L.SetField(mt, "insert", L.NewFunction(luaListInsert))
L.SetField(mt, "append", L.NewFunction(luaListAppend))
L.SetField(mt, "prepend", L.NewFunction(luaListPrepend))
L.SetField(mt, "take", L.NewFunction(luaListTake))
L.SetField(mt, "remove", L.NewFunction(luaListRemove))
L.SetField(mt, "drop", L.NewFunction(luaListDrop))
L.SetField(mt, "trim", L.NewFunction(luaListTrim))
L.SetField(mt, "clone", L.NewFunction(luaListClone))
L.SetField(mt, "concat", L.NewFunction(luaListConcat))
L.SetField(mt, "merge", L.NewFunction(luaListMerge))
L.SetField(mt, "iterator", L.NewFunction(luaListIterator))
// methods
L.SetFuncs(mt, map[string]lua.LGFunction{
"__index": luaListIndex,
"__newindex": luaListNewIndex,
"__len": luaListLen,
"__tostring": luaListToString,
})
L.SetMetatable(mt, mt)
} | go | func registerLuaListType(L *lua.LState) {
mt := L.NewTypeMetatable(luaLuaListTypeName)
// List package
L.SetGlobal("List", mt)
// static attributes
L.SetMetatable(mt, mt)
// list package
mt = L.NewTypeMetatable(luaLuaListTypeName)
L.SetGlobal("list", mt)
// static attributes
L.SetField(mt, "__call", L.NewFunction(newLuaList))
L.SetField(mt, "create", L.NewFunction(createLuaList))
L.SetField(mt, "size", L.NewFunction(luaListSize))
L.SetField(mt, "insert", L.NewFunction(luaListInsert))
L.SetField(mt, "append", L.NewFunction(luaListAppend))
L.SetField(mt, "prepend", L.NewFunction(luaListPrepend))
L.SetField(mt, "take", L.NewFunction(luaListTake))
L.SetField(mt, "remove", L.NewFunction(luaListRemove))
L.SetField(mt, "drop", L.NewFunction(luaListDrop))
L.SetField(mt, "trim", L.NewFunction(luaListTrim))
L.SetField(mt, "clone", L.NewFunction(luaListClone))
L.SetField(mt, "concat", L.NewFunction(luaListConcat))
L.SetField(mt, "merge", L.NewFunction(luaListMerge))
L.SetField(mt, "iterator", L.NewFunction(luaListIterator))
// methods
L.SetFuncs(mt, map[string]lua.LGFunction{
"__index": luaListIndex,
"__newindex": luaListNewIndex,
"__len": luaListLen,
"__tostring": luaListToString,
})
L.SetMetatable(mt, mt)
} | [
"func",
"registerLuaListType",
"(",
"L",
"*",
"lua",
".",
"LState",
")",
"{",
"mt",
":=",
"L",
".",
"NewTypeMetatable",
"(",
"luaLuaListTypeName",
")",
"\n\n",
"// List package",
"L",
".",
"SetGlobal",
"(",
"\"",
"\"",
",",
"mt",
")",
"\n\n",
"// static attributes",
"L",
".",
"SetMetatable",
"(",
"mt",
",",
"mt",
")",
"\n\n",
"// list package",
"mt",
"=",
"L",
".",
"NewTypeMetatable",
"(",
"luaLuaListTypeName",
")",
"\n",
"L",
".",
"SetGlobal",
"(",
"\"",
"\"",
",",
"mt",
")",
"\n\n",
"// static attributes",
"L",
".",
"SetField",
"(",
"mt",
",",
"\"",
"\"",
",",
"L",
".",
"NewFunction",
"(",
"newLuaList",
")",
")",
"\n",
"L",
".",
"SetField",
"(",
"mt",
",",
"\"",
"\"",
",",
"L",
".",
"NewFunction",
"(",
"createLuaList",
")",
")",
"\n\n",
"L",
".",
"SetField",
"(",
"mt",
",",
"\"",
"\"",
",",
"L",
".",
"NewFunction",
"(",
"luaListSize",
")",
")",
"\n",
"L",
".",
"SetField",
"(",
"mt",
",",
"\"",
"\"",
",",
"L",
".",
"NewFunction",
"(",
"luaListInsert",
")",
")",
"\n",
"L",
".",
"SetField",
"(",
"mt",
",",
"\"",
"\"",
",",
"L",
".",
"NewFunction",
"(",
"luaListAppend",
")",
")",
"\n",
"L",
".",
"SetField",
"(",
"mt",
",",
"\"",
"\"",
",",
"L",
".",
"NewFunction",
"(",
"luaListPrepend",
")",
")",
"\n",
"L",
".",
"SetField",
"(",
"mt",
",",
"\"",
"\"",
",",
"L",
".",
"NewFunction",
"(",
"luaListTake",
")",
")",
"\n",
"L",
".",
"SetField",
"(",
"mt",
",",
"\"",
"\"",
",",
"L",
".",
"NewFunction",
"(",
"luaListRemove",
")",
")",
"\n",
"L",
".",
"SetField",
"(",
"mt",
",",
"\"",
"\"",
",",
"L",
".",
"NewFunction",
"(",
"luaListDrop",
")",
")",
"\n",
"L",
".",
"SetField",
"(",
"mt",
",",
"\"",
"\"",
",",
"L",
".",
"NewFunction",
"(",
"luaListTrim",
")",
")",
"\n",
"L",
".",
"SetField",
"(",
"mt",
",",
"\"",
"\"",
",",
"L",
".",
"NewFunction",
"(",
"luaListClone",
")",
")",
"\n",
"L",
".",
"SetField",
"(",
"mt",
",",
"\"",
"\"",
",",
"L",
".",
"NewFunction",
"(",
"luaListConcat",
")",
")",
"\n",
"L",
".",
"SetField",
"(",
"mt",
",",
"\"",
"\"",
",",
"L",
".",
"NewFunction",
"(",
"luaListMerge",
")",
")",
"\n",
"L",
".",
"SetField",
"(",
"mt",
",",
"\"",
"\"",
",",
"L",
".",
"NewFunction",
"(",
"luaListIterator",
")",
")",
"\n\n",
"// methods",
"L",
".",
"SetFuncs",
"(",
"mt",
",",
"map",
"[",
"string",
"]",
"lua",
".",
"LGFunction",
"{",
"\"",
"\"",
":",
"luaListIndex",
",",
"\"",
"\"",
":",
"luaListNewIndex",
",",
"\"",
"\"",
":",
"luaListLen",
",",
"\"",
"\"",
":",
"luaListToString",
",",
"}",
")",
"\n\n",
"L",
".",
"SetMetatable",
"(",
"mt",
",",
"mt",
")",
"\n",
"}"
]
| // Registers my luaList type to given L. | [
"Registers",
"my",
"luaList",
"type",
"to",
"given",
"L",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/internal/lua/lua_list.go#L32-L72 |
9,936 | aerospike/aerospike-client-go | internal/atomic/array.go | NewAtomicArray | func NewAtomicArray(length int) *AtomicArray {
return &AtomicArray{
length: length,
items: make([]interface{}, length),
}
} | go | func NewAtomicArray(length int) *AtomicArray {
return &AtomicArray{
length: length,
items: make([]interface{}, length),
}
} | [
"func",
"NewAtomicArray",
"(",
"length",
"int",
")",
"*",
"AtomicArray",
"{",
"return",
"&",
"AtomicArray",
"{",
"length",
":",
"length",
",",
"items",
":",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"length",
")",
",",
"}",
"\n",
"}"
]
| // NewAtomicArray generates a new AtomicArray instance. | [
"NewAtomicArray",
"generates",
"a",
"new",
"AtomicArray",
"instance",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/internal/atomic/array.go#L30-L35 |
9,937 | aerospike/aerospike-client-go | internal/atomic/array.go | Get | func (aa *AtomicArray) Get(idx int) interface{} {
// do not lock if not needed
if idx < 0 || idx >= aa.length {
return nil
}
aa.mutex.RLock()
res := aa.items[idx]
aa.mutex.RUnlock()
return res
} | go | func (aa *AtomicArray) Get(idx int) interface{} {
// do not lock if not needed
if idx < 0 || idx >= aa.length {
return nil
}
aa.mutex.RLock()
res := aa.items[idx]
aa.mutex.RUnlock()
return res
} | [
"func",
"(",
"aa",
"*",
"AtomicArray",
")",
"Get",
"(",
"idx",
"int",
")",
"interface",
"{",
"}",
"{",
"// do not lock if not needed",
"if",
"idx",
"<",
"0",
"||",
"idx",
">=",
"aa",
".",
"length",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"aa",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"res",
":=",
"aa",
".",
"items",
"[",
"idx",
"]",
"\n",
"aa",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"res",
"\n",
"}"
]
| // Get atomically retrieves an element from the Array.
// If idx is out of range, it will return nil | [
"Get",
"atomically",
"retrieves",
"an",
"element",
"from",
"the",
"Array",
".",
"If",
"idx",
"is",
"out",
"of",
"range",
"it",
"will",
"return",
"nil"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/internal/atomic/array.go#L39-L49 |
9,938 | aerospike/aerospike-client-go | internal/atomic/array.go | Set | func (aa *AtomicArray) Set(idx int, node interface{}) error {
// do not lock if not needed
if idx < 0 || idx >= aa.length {
return fmt.Errorf("index %d is larger than array size (%d)", idx, aa.length)
}
aa.mutex.Lock()
aa.items[idx] = node
aa.mutex.Unlock()
return nil
} | go | func (aa *AtomicArray) Set(idx int, node interface{}) error {
// do not lock if not needed
if idx < 0 || idx >= aa.length {
return fmt.Errorf("index %d is larger than array size (%d)", idx, aa.length)
}
aa.mutex.Lock()
aa.items[idx] = node
aa.mutex.Unlock()
return nil
} | [
"func",
"(",
"aa",
"*",
"AtomicArray",
")",
"Set",
"(",
"idx",
"int",
",",
"node",
"interface",
"{",
"}",
")",
"error",
"{",
"// do not lock if not needed",
"if",
"idx",
"<",
"0",
"||",
"idx",
">=",
"aa",
".",
"length",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"idx",
",",
"aa",
".",
"length",
")",
"\n",
"}",
"\n\n",
"aa",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"aa",
".",
"items",
"[",
"idx",
"]",
"=",
"node",
"\n",
"aa",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
]
| // Set atomically sets an element in the Array.
// If idx is out of range, it will return an error | [
"Set",
"atomically",
"sets",
"an",
"element",
"in",
"the",
"Array",
".",
"If",
"idx",
"is",
"out",
"of",
"range",
"it",
"will",
"return",
"an",
"error"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/internal/atomic/array.go#L53-L63 |
9,939 | aerospike/aerospike-client-go | internal/atomic/array.go | Length | func (aa *AtomicArray) Length() int {
aa.mutex.RLock()
res := aa.length
aa.mutex.RUnlock()
return res
} | go | func (aa *AtomicArray) Length() int {
aa.mutex.RLock()
res := aa.length
aa.mutex.RUnlock()
return res
} | [
"func",
"(",
"aa",
"*",
"AtomicArray",
")",
"Length",
"(",
")",
"int",
"{",
"aa",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"res",
":=",
"aa",
".",
"length",
"\n",
"aa",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"res",
"\n",
"}"
]
| // Length returns the array size. | [
"Length",
"returns",
"the",
"array",
"size",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/internal/atomic/array.go#L66-L72 |
9,940 | aerospike/aerospike-client-go | generics.go | PackList | func (ts stringSlice) PackList(buf BufferEx) (int, error) {
size := 0
for _, elem := range ts {
n, err := PackString(buf, elem)
size += n
if err != nil {
return size, err
}
}
return size, nil
} | go | func (ts stringSlice) PackList(buf BufferEx) (int, error) {
size := 0
for _, elem := range ts {
n, err := PackString(buf, elem)
size += n
if err != nil {
return size, err
}
}
return size, nil
} | [
"func",
"(",
"ts",
"stringSlice",
")",
"PackList",
"(",
"buf",
"BufferEx",
")",
"(",
"int",
",",
"error",
")",
"{",
"size",
":=",
"0",
"\n",
"for",
"_",
",",
"elem",
":=",
"range",
"ts",
"{",
"n",
",",
"err",
":=",
"PackString",
"(",
"buf",
",",
"elem",
")",
"\n",
"size",
"+=",
"n",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"size",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"size",
",",
"nil",
"\n",
"}"
]
| // PackList packs StringSlice as msgpack. | [
"PackList",
"packs",
"StringSlice",
"as",
"msgpack",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/generics.go#L20-L30 |
9,941 | aerospike/aerospike-client-go | generics.go | PackList | func (ts intSlice) PackList(buf BufferEx) (int, error) {
size := 0
for _, elem := range ts {
n, err := PackInt64(buf, int64(elem))
size += n
if err != nil {
return size, err
}
}
return size, nil
} | go | func (ts intSlice) PackList(buf BufferEx) (int, error) {
size := 0
for _, elem := range ts {
n, err := PackInt64(buf, int64(elem))
size += n
if err != nil {
return size, err
}
}
return size, nil
} | [
"func",
"(",
"ts",
"intSlice",
")",
"PackList",
"(",
"buf",
"BufferEx",
")",
"(",
"int",
",",
"error",
")",
"{",
"size",
":=",
"0",
"\n",
"for",
"_",
",",
"elem",
":=",
"range",
"ts",
"{",
"n",
",",
"err",
":=",
"PackInt64",
"(",
"buf",
",",
"int64",
"(",
"elem",
")",
")",
"\n",
"size",
"+=",
"n",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"size",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"size",
",",
"nil",
"\n",
"}"
]
| // PackList packs IntSlice as msgpack. | [
"PackList",
"packs",
"IntSlice",
"as",
"msgpack",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/generics.go#L40-L50 |
9,942 | aerospike/aerospike-client-go | generics.go | PackList | func (ts uint64Slice) PackList(buf BufferEx) (int, error) {
size := 0
for _, elem := range ts {
n, err := PackUInt64(buf, elem)
size += n
if err != nil {
return size, err
}
}
return size, nil
} | go | func (ts uint64Slice) PackList(buf BufferEx) (int, error) {
size := 0
for _, elem := range ts {
n, err := PackUInt64(buf, elem)
size += n
if err != nil {
return size, err
}
}
return size, nil
} | [
"func",
"(",
"ts",
"uint64Slice",
")",
"PackList",
"(",
"buf",
"BufferEx",
")",
"(",
"int",
",",
"error",
")",
"{",
"size",
":=",
"0",
"\n",
"for",
"_",
",",
"elem",
":=",
"range",
"ts",
"{",
"n",
",",
"err",
":=",
"PackUInt64",
"(",
"buf",
",",
"elem",
")",
"\n",
"size",
"+=",
"n",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"size",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"size",
",",
"nil",
"\n",
"}"
]
| // PackList packs Uint64Slice as msgpack. | [
"PackList",
"packs",
"Uint64Slice",
"as",
"msgpack",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/generics.go#L180-L190 |
9,943 | aerospike/aerospike-client-go | generics.go | PackList | func (ts float32Slice) PackList(buf BufferEx) (int, error) {
size := 0
for _, elem := range ts {
n, err := PackFloat32(buf, elem)
size += n
if err != nil {
return size, err
}
}
return size, nil
} | go | func (ts float32Slice) PackList(buf BufferEx) (int, error) {
size := 0
for _, elem := range ts {
n, err := PackFloat32(buf, elem)
size += n
if err != nil {
return size, err
}
}
return size, nil
} | [
"func",
"(",
"ts",
"float32Slice",
")",
"PackList",
"(",
"buf",
"BufferEx",
")",
"(",
"int",
",",
"error",
")",
"{",
"size",
":=",
"0",
"\n",
"for",
"_",
",",
"elem",
":=",
"range",
"ts",
"{",
"n",
",",
"err",
":=",
"PackFloat32",
"(",
"buf",
",",
"elem",
")",
"\n",
"size",
"+=",
"n",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"size",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"size",
",",
"nil",
"\n",
"}"
]
| // PackList packs Float32Slice as msgpack. | [
"PackList",
"packs",
"Float32Slice",
"as",
"msgpack",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/generics.go#L200-L210 |
9,944 | aerospike/aerospike-client-go | generics.go | PackList | func (ts float64Slice) PackList(buf BufferEx) (int, error) {
size := 0
for _, elem := range ts {
n, err := PackFloat64(buf, elem)
size += n
if err != nil {
return size, err
}
}
return size, nil
} | go | func (ts float64Slice) PackList(buf BufferEx) (int, error) {
size := 0
for _, elem := range ts {
n, err := PackFloat64(buf, elem)
size += n
if err != nil {
return size, err
}
}
return size, nil
} | [
"func",
"(",
"ts",
"float64Slice",
")",
"PackList",
"(",
"buf",
"BufferEx",
")",
"(",
"int",
",",
"error",
")",
"{",
"size",
":=",
"0",
"\n",
"for",
"_",
",",
"elem",
":=",
"range",
"ts",
"{",
"n",
",",
"err",
":=",
"PackFloat64",
"(",
"buf",
",",
"elem",
")",
"\n",
"size",
"+=",
"n",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"size",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"size",
",",
"nil",
"\n",
"}"
]
| // PackList packs Float64Slice as msgpack. | [
"PackList",
"packs",
"Float64Slice",
"as",
"msgpack",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/generics.go#L220-L230 |
9,945 | aerospike/aerospike-client-go | packer.go | PackList | func PackList(cmd BufferEx, list ListIter) (int, error) {
return packList(cmd, list)
} | go | func PackList(cmd BufferEx, list ListIter) (int, error) {
return packList(cmd, list)
} | [
"func",
"PackList",
"(",
"cmd",
"BufferEx",
",",
"list",
"ListIter",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"packList",
"(",
"cmd",
",",
"list",
")",
"\n",
"}"
]
| // PackList packs any slice that implement the ListIter interface | [
"PackList",
"packs",
"any",
"slice",
"that",
"implement",
"the",
"ListIter",
"interface"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/packer.go#L51-L53 |
9,946 | aerospike/aerospike-client-go | packer.go | PackJson | func PackJson(cmd BufferEx, theMap map[string]interface{}) (int, error) {
return packJsonMap(cmd, theMap)
} | go | func PackJson(cmd BufferEx, theMap map[string]interface{}) (int, error) {
return packJsonMap(cmd, theMap)
} | [
"func",
"PackJson",
"(",
"cmd",
"BufferEx",
",",
"theMap",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"packJsonMap",
"(",
"cmd",
",",
"theMap",
")",
"\n",
"}"
]
| // PackJson packs json data | [
"PackJson",
"packs",
"json",
"data"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/packer.go#L121-L123 |
9,947 | aerospike/aerospike-client-go | packer.go | PackMap | func PackMap(cmd BufferEx, theMap MapIter) (int, error) {
return packMap(cmd, theMap)
} | go | func PackMap(cmd BufferEx, theMap MapIter) (int, error) {
return packMap(cmd, theMap)
} | [
"func",
"PackMap",
"(",
"cmd",
"BufferEx",
",",
"theMap",
"MapIter",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"packMap",
"(",
"cmd",
",",
"theMap",
")",
"\n",
"}"
]
| // PackMap packs any map that implements the MapIter interface | [
"PackMap",
"packs",
"any",
"map",
"that",
"implements",
"the",
"MapIter",
"interface"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/packer.go#L150-L152 |
9,948 | aerospike/aerospike-client-go | packer.go | PackBytes | func PackBytes(cmd BufferEx, b []byte) (int, error) {
return packBytes(cmd, b)
} | go | func PackBytes(cmd BufferEx, b []byte) (int, error) {
return packBytes(cmd, b)
} | [
"func",
"PackBytes",
"(",
"cmd",
"BufferEx",
",",
"b",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"packBytes",
"(",
"cmd",
",",
"b",
")",
"\n",
"}"
]
| // PackBytes backs a byte array | [
"PackBytes",
"backs",
"a",
"byte",
"array"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/packer.go#L177-L179 |
9,949 | aerospike/aerospike-client-go | packer.go | PackInt64 | func PackInt64(cmd BufferEx, val int64) (int, error) {
return packAInt64(cmd, val)
} | go | func PackInt64(cmd BufferEx, val int64) (int, error) {
return packAInt64(cmd, val)
} | [
"func",
"PackInt64",
"(",
"cmd",
"BufferEx",
",",
"val",
"int64",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"packAInt64",
"(",
"cmd",
",",
"val",
")",
"\n",
"}"
]
| // PackInt64 packs an int64 | [
"PackInt64",
"packs",
"an",
"int64"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/packer.go#L343-L345 |
9,950 | aerospike/aerospike-client-go | packer.go | PackString | func PackString(cmd BufferEx, val string) (int, error) {
return packString(cmd, val)
} | go | func PackString(cmd BufferEx, val string) (int, error) {
return packString(cmd, val)
} | [
"func",
"PackString",
"(",
"cmd",
"BufferEx",
",",
"val",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"packString",
"(",
"cmd",
",",
"val",
")",
"\n",
"}"
]
| // PackString packs a string | [
"PackString",
"packs",
"a",
"string"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/packer.go#L352-L354 |
9,951 | aerospike/aerospike-client-go | packer.go | PackUInt64 | func PackUInt64(cmd BufferEx, val uint64) (int, error) {
return packUInt64(cmd, val)
} | go | func PackUInt64(cmd BufferEx, val uint64) (int, error) {
return packUInt64(cmd, val)
} | [
"func",
"PackUInt64",
"(",
"cmd",
"BufferEx",
",",
"val",
"uint64",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"packUInt64",
"(",
"cmd",
",",
"val",
")",
"\n",
"}"
]
| // PackUInt64 packs a uint64 | [
"PackUInt64",
"packs",
"a",
"uint64"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/packer.go#L433-L435 |
9,952 | aerospike/aerospike-client-go | packer.go | PackBool | func PackBool(cmd BufferEx, val bool) (int, error) {
return packBool(cmd, val)
} | go | func PackBool(cmd BufferEx, val bool) (int, error) {
return packBool(cmd, val)
} | [
"func",
"PackBool",
"(",
"cmd",
"BufferEx",
",",
"val",
"bool",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"packBool",
"(",
"cmd",
",",
"val",
")",
"\n",
"}"
]
| // Pack bool packs a bool value | [
"Pack",
"bool",
"packs",
"a",
"bool",
"value"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/packer.go#L569-L571 |
9,953 | aerospike/aerospike-client-go | packer.go | PackFloat32 | func PackFloat32(cmd BufferEx, val float32) (int, error) {
return packFloat32(cmd, val)
} | go | func PackFloat32(cmd BufferEx, val float32) (int, error) {
return packFloat32(cmd, val)
} | [
"func",
"PackFloat32",
"(",
"cmd",
"BufferEx",
",",
"val",
"float32",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"packFloat32",
"(",
"cmd",
",",
"val",
")",
"\n",
"}"
]
| // PackFloat32 packs float32 value | [
"PackFloat32",
"packs",
"float32",
"value"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/packer.go#L584-L586 |
9,954 | aerospike/aerospike-client-go | packer.go | PackFloat64 | func PackFloat64(cmd BufferEx, val float64) (int, error) {
return packFloat64(cmd, val)
} | go | func PackFloat64(cmd BufferEx, val float64) (int, error) {
return packFloat64(cmd, val)
} | [
"func",
"PackFloat64",
"(",
"cmd",
"BufferEx",
",",
"val",
"float64",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"packFloat64",
"(",
"cmd",
",",
"val",
")",
"\n",
"}"
]
| // PackFloat64 packs float64 value | [
"PackFloat64",
"packs",
"float64",
"value"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/packer.go#L603-L605 |
9,955 | aerospike/aerospike-client-go | operation.go | cache | func (op *Operation) cache() error {
packer := newPacker()
if _, err := op.encoder(op, packer); err != nil {
return err
}
op.binValue = BytesValue(packer.Bytes())
op.encoder = nil // do not encode anymore; just use the cache
op.used = false // do not encode anymore; just use the cache
return nil
} | go | func (op *Operation) cache() error {
packer := newPacker()
if _, err := op.encoder(op, packer); err != nil {
return err
}
op.binValue = BytesValue(packer.Bytes())
op.encoder = nil // do not encode anymore; just use the cache
op.used = false // do not encode anymore; just use the cache
return nil
} | [
"func",
"(",
"op",
"*",
"Operation",
")",
"cache",
"(",
")",
"error",
"{",
"packer",
":=",
"newPacker",
"(",
")",
"\n\n",
"if",
"_",
",",
"err",
":=",
"op",
".",
"encoder",
"(",
"op",
",",
"packer",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"op",
".",
"binValue",
"=",
"BytesValue",
"(",
"packer",
".",
"Bytes",
"(",
")",
")",
"\n",
"op",
".",
"encoder",
"=",
"nil",
"// do not encode anymore; just use the cache",
"\n",
"op",
".",
"used",
"=",
"false",
"// do not encode anymore; just use the cache",
"\n",
"return",
"nil",
"\n",
"}"
]
| // cache uses the encoder and caches the packed operation for further use. | [
"cache",
"uses",
"the",
"encoder",
"and",
"caches",
"the",
"packed",
"operation",
"for",
"further",
"use",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/operation.go#L68-L79 |
9,956 | aerospike/aerospike-client-go | operation.go | GetOpForBin | func GetOpForBin(binName string) *Operation {
return &Operation{opType: _READ, binName: binName, binValue: NewNullValue()}
} | go | func GetOpForBin(binName string) *Operation {
return &Operation{opType: _READ, binName: binName, binValue: NewNullValue()}
} | [
"func",
"GetOpForBin",
"(",
"binName",
"string",
")",
"*",
"Operation",
"{",
"return",
"&",
"Operation",
"{",
"opType",
":",
"_READ",
",",
"binName",
":",
"binName",
",",
"binValue",
":",
"NewNullValue",
"(",
")",
"}",
"\n",
"}"
]
| // GetOpForBin creates read bin database operation. | [
"GetOpForBin",
"creates",
"read",
"bin",
"database",
"operation",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/operation.go#L82-L84 |
9,957 | aerospike/aerospike-client-go | operation.go | PutOp | func PutOp(bin *Bin) *Operation {
return &Operation{opType: _WRITE, binName: bin.Name, binValue: bin.Value}
} | go | func PutOp(bin *Bin) *Operation {
return &Operation{opType: _WRITE, binName: bin.Name, binValue: bin.Value}
} | [
"func",
"PutOp",
"(",
"bin",
"*",
"Bin",
")",
"*",
"Operation",
"{",
"return",
"&",
"Operation",
"{",
"opType",
":",
"_WRITE",
",",
"binName",
":",
"bin",
".",
"Name",
",",
"binValue",
":",
"bin",
".",
"Value",
"}",
"\n",
"}"
]
| // PutOp creates set database operation. | [
"PutOp",
"creates",
"set",
"database",
"operation",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/operation.go#L97-L99 |
9,958 | aerospike/aerospike-client-go | operation.go | AppendOp | func AppendOp(bin *Bin) *Operation {
return &Operation{opType: _APPEND, binName: bin.Name, binValue: bin.Value}
} | go | func AppendOp(bin *Bin) *Operation {
return &Operation{opType: _APPEND, binName: bin.Name, binValue: bin.Value}
} | [
"func",
"AppendOp",
"(",
"bin",
"*",
"Bin",
")",
"*",
"Operation",
"{",
"return",
"&",
"Operation",
"{",
"opType",
":",
"_APPEND",
",",
"binName",
":",
"bin",
".",
"Name",
",",
"binValue",
":",
"bin",
".",
"Value",
"}",
"\n",
"}"
]
| // AppendOp creates string append database operation. | [
"AppendOp",
"creates",
"string",
"append",
"database",
"operation",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/operation.go#L102-L104 |
9,959 | aerospike/aerospike-client-go | operation.go | PrependOp | func PrependOp(bin *Bin) *Operation {
return &Operation{opType: _PREPEND, binName: bin.Name, binValue: bin.Value}
} | go | func PrependOp(bin *Bin) *Operation {
return &Operation{opType: _PREPEND, binName: bin.Name, binValue: bin.Value}
} | [
"func",
"PrependOp",
"(",
"bin",
"*",
"Bin",
")",
"*",
"Operation",
"{",
"return",
"&",
"Operation",
"{",
"opType",
":",
"_PREPEND",
",",
"binName",
":",
"bin",
".",
"Name",
",",
"binValue",
":",
"bin",
".",
"Value",
"}",
"\n",
"}"
]
| // PrependOp creates string prepend database operation. | [
"PrependOp",
"creates",
"string",
"prepend",
"database",
"operation",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/operation.go#L107-L109 |
9,960 | aerospike/aerospike-client-go | operation.go | AddOp | func AddOp(bin *Bin) *Operation {
return &Operation{opType: _ADD, binName: bin.Name, binValue: bin.Value}
} | go | func AddOp(bin *Bin) *Operation {
return &Operation{opType: _ADD, binName: bin.Name, binValue: bin.Value}
} | [
"func",
"AddOp",
"(",
"bin",
"*",
"Bin",
")",
"*",
"Operation",
"{",
"return",
"&",
"Operation",
"{",
"opType",
":",
"_ADD",
",",
"binName",
":",
"bin",
".",
"Name",
",",
"binValue",
":",
"bin",
".",
"Value",
"}",
"\n",
"}"
]
| // AddOp creates integer add database operation. | [
"AddOp",
"creates",
"integer",
"add",
"database",
"operation",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/operation.go#L112-L114 |
9,961 | aerospike/aerospike-client-go | multi_policy.go | NewMultiPolicy | func NewMultiPolicy() *MultiPolicy {
bp := *NewPolicy()
bp.SocketTimeout = 30 * time.Second
return &MultiPolicy{
BasePolicy: bp,
MaxConcurrentNodes: 0,
RecordQueueSize: 50,
IncludeBinData: true,
FailOnClusterChange: true,
}
} | go | func NewMultiPolicy() *MultiPolicy {
bp := *NewPolicy()
bp.SocketTimeout = 30 * time.Second
return &MultiPolicy{
BasePolicy: bp,
MaxConcurrentNodes: 0,
RecordQueueSize: 50,
IncludeBinData: true,
FailOnClusterChange: true,
}
} | [
"func",
"NewMultiPolicy",
"(",
")",
"*",
"MultiPolicy",
"{",
"bp",
":=",
"*",
"NewPolicy",
"(",
")",
"\n",
"bp",
".",
"SocketTimeout",
"=",
"30",
"*",
"time",
".",
"Second",
"\n\n",
"return",
"&",
"MultiPolicy",
"{",
"BasePolicy",
":",
"bp",
",",
"MaxConcurrentNodes",
":",
"0",
",",
"RecordQueueSize",
":",
"50",
",",
"IncludeBinData",
":",
"true",
",",
"FailOnClusterChange",
":",
"true",
",",
"}",
"\n",
"}"
]
| // NewMultiPolicy initializes a MultiPolicy instance with default values. | [
"NewMultiPolicy",
"initializes",
"a",
"MultiPolicy",
"instance",
"with",
"default",
"values",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/multi_policy.go#L45-L56 |
9,962 | aerospike/aerospike-client-go | types/buffer_pool.go | Get | func (bp *BufferPool) Get() (res []byte) {
bp.mutex.Lock()
if bp.pos >= 0 {
res = bp.pool[bp.pos]
bp.pos--
} else {
res = make([]byte, bp.initBufSize, bp.initBufSize)
}
bp.mutex.Unlock()
return res
} | go | func (bp *BufferPool) Get() (res []byte) {
bp.mutex.Lock()
if bp.pos >= 0 {
res = bp.pool[bp.pos]
bp.pos--
} else {
res = make([]byte, bp.initBufSize, bp.initBufSize)
}
bp.mutex.Unlock()
return res
} | [
"func",
"(",
"bp",
"*",
"BufferPool",
")",
"Get",
"(",
")",
"(",
"res",
"[",
"]",
"byte",
")",
"{",
"bp",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"if",
"bp",
".",
"pos",
">=",
"0",
"{",
"res",
"=",
"bp",
".",
"pool",
"[",
"bp",
".",
"pos",
"]",
"\n",
"bp",
".",
"pos",
"--",
"\n",
"}",
"else",
"{",
"res",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"bp",
".",
"initBufSize",
",",
"bp",
".",
"initBufSize",
")",
"\n",
"}",
"\n\n",
"bp",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"return",
"res",
"\n",
"}"
]
| // Get returns a buffer from the pool. If pool is empty, a new buffer of
// size initBufSize will be created and returned. | [
"Get",
"returns",
"a",
"buffer",
"from",
"the",
"pool",
".",
"If",
"pool",
"is",
"empty",
"a",
"new",
"buffer",
"of",
"size",
"initBufSize",
"will",
"be",
"created",
"and",
"returned",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/types/buffer_pool.go#L51-L62 |
9,963 | aerospike/aerospike-client-go | node.go | newNode | func newNode(cluster *Cluster, nv *nodeValidator) *Node {
newNode := &Node{
cluster: cluster,
name: nv.name,
// address: nv.primaryAddress,
host: nv.primaryHost,
// Assign host to first IP alias because the server identifies nodes
// by IP address (not hostname).
connections: *newConnectionHeap(cluster.clientPolicy.ConnectionQueueSize),
connectionCount: *NewAtomicInt(0),
peersGeneration: *NewAtomicInt(-1),
partitionGeneration: *NewAtomicInt(-2),
referenceCount: *NewAtomicInt(0),
failures: *NewAtomicInt(0),
active: *NewAtomicBool(true),
partitionChanged: *NewAtomicBool(false),
supportsFloat: *NewAtomicBool(nv.supportsFloat),
supportsBatchIndex: *NewAtomicBool(nv.supportsBatchIndex),
supportsReplicas: *NewAtomicBool(nv.supportsReplicas),
supportsGeo: *NewAtomicBool(nv.supportsGeo),
supportsPeers: *NewAtomicBool(nv.supportsPeers),
supportsLUTNow: *NewAtomicBool(nv.supportsLUTNow),
supportsTruncateNamespace: *NewAtomicBool(nv.supportsTruncateNamespace),
}
newNode.aliases.Store(nv.aliases)
newNode._sessionToken.Store(nv.sessionToken)
newNode.racks.Store(map[string]int{})
// this will reset to zero on first aggregation on the cluster,
// therefore will only be counted once.
atomic.AddInt64(&newNode.stats.NodeAdded, 1)
return newNode
} | go | func newNode(cluster *Cluster, nv *nodeValidator) *Node {
newNode := &Node{
cluster: cluster,
name: nv.name,
// address: nv.primaryAddress,
host: nv.primaryHost,
// Assign host to first IP alias because the server identifies nodes
// by IP address (not hostname).
connections: *newConnectionHeap(cluster.clientPolicy.ConnectionQueueSize),
connectionCount: *NewAtomicInt(0),
peersGeneration: *NewAtomicInt(-1),
partitionGeneration: *NewAtomicInt(-2),
referenceCount: *NewAtomicInt(0),
failures: *NewAtomicInt(0),
active: *NewAtomicBool(true),
partitionChanged: *NewAtomicBool(false),
supportsFloat: *NewAtomicBool(nv.supportsFloat),
supportsBatchIndex: *NewAtomicBool(nv.supportsBatchIndex),
supportsReplicas: *NewAtomicBool(nv.supportsReplicas),
supportsGeo: *NewAtomicBool(nv.supportsGeo),
supportsPeers: *NewAtomicBool(nv.supportsPeers),
supportsLUTNow: *NewAtomicBool(nv.supportsLUTNow),
supportsTruncateNamespace: *NewAtomicBool(nv.supportsTruncateNamespace),
}
newNode.aliases.Store(nv.aliases)
newNode._sessionToken.Store(nv.sessionToken)
newNode.racks.Store(map[string]int{})
// this will reset to zero on first aggregation on the cluster,
// therefore will only be counted once.
atomic.AddInt64(&newNode.stats.NodeAdded, 1)
return newNode
} | [
"func",
"newNode",
"(",
"cluster",
"*",
"Cluster",
",",
"nv",
"*",
"nodeValidator",
")",
"*",
"Node",
"{",
"newNode",
":=",
"&",
"Node",
"{",
"cluster",
":",
"cluster",
",",
"name",
":",
"nv",
".",
"name",
",",
"// address: nv.primaryAddress,",
"host",
":",
"nv",
".",
"primaryHost",
",",
"// Assign host to first IP alias because the server identifies nodes",
"// by IP address (not hostname).",
"connections",
":",
"*",
"newConnectionHeap",
"(",
"cluster",
".",
"clientPolicy",
".",
"ConnectionQueueSize",
")",
",",
"connectionCount",
":",
"*",
"NewAtomicInt",
"(",
"0",
")",
",",
"peersGeneration",
":",
"*",
"NewAtomicInt",
"(",
"-",
"1",
")",
",",
"partitionGeneration",
":",
"*",
"NewAtomicInt",
"(",
"-",
"2",
")",
",",
"referenceCount",
":",
"*",
"NewAtomicInt",
"(",
"0",
")",
",",
"failures",
":",
"*",
"NewAtomicInt",
"(",
"0",
")",
",",
"active",
":",
"*",
"NewAtomicBool",
"(",
"true",
")",
",",
"partitionChanged",
":",
"*",
"NewAtomicBool",
"(",
"false",
")",
",",
"supportsFloat",
":",
"*",
"NewAtomicBool",
"(",
"nv",
".",
"supportsFloat",
")",
",",
"supportsBatchIndex",
":",
"*",
"NewAtomicBool",
"(",
"nv",
".",
"supportsBatchIndex",
")",
",",
"supportsReplicas",
":",
"*",
"NewAtomicBool",
"(",
"nv",
".",
"supportsReplicas",
")",
",",
"supportsGeo",
":",
"*",
"NewAtomicBool",
"(",
"nv",
".",
"supportsGeo",
")",
",",
"supportsPeers",
":",
"*",
"NewAtomicBool",
"(",
"nv",
".",
"supportsPeers",
")",
",",
"supportsLUTNow",
":",
"*",
"NewAtomicBool",
"(",
"nv",
".",
"supportsLUTNow",
")",
",",
"supportsTruncateNamespace",
":",
"*",
"NewAtomicBool",
"(",
"nv",
".",
"supportsTruncateNamespace",
")",
",",
"}",
"\n\n",
"newNode",
".",
"aliases",
".",
"Store",
"(",
"nv",
".",
"aliases",
")",
"\n",
"newNode",
".",
"_sessionToken",
".",
"Store",
"(",
"nv",
".",
"sessionToken",
")",
"\n",
"newNode",
".",
"racks",
".",
"Store",
"(",
"map",
"[",
"string",
"]",
"int",
"{",
"}",
")",
"\n\n",
"// this will reset to zero on first aggregation on the cluster,",
"// therefore will only be counted once.",
"atomic",
".",
"AddInt64",
"(",
"&",
"newNode",
".",
"stats",
".",
"NodeAdded",
",",
"1",
")",
"\n\n",
"return",
"newNode",
"\n",
"}"
]
| // NewNode initializes a server node with connection parameters. | [
"NewNode",
"initializes",
"a",
"server",
"node",
"with",
"connection",
"parameters",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L73-L109 |
9,964 | aerospike/aerospike-client-go | node.go | refreshSessionToken | func (nd *Node) refreshSessionToken() error {
// no session token to refresh
if !nd.cluster.clientPolicy.RequiresAuthentication() || nd.cluster.clientPolicy.AuthMode != AuthModeExternal {
return nil
}
var deadline time.Time
deadlineIfc := nd._sessionExpiration.Load()
if deadlineIfc != nil {
deadline = deadlineIfc.(time.Time)
}
if deadline.IsZero() || time.Now().Before(deadline) {
return nil
}
nd.tendConnLock.Lock()
defer nd.tendConnLock.Unlock()
if err := nd.initTendConn(nd.cluster.clientPolicy.LoginTimeout); err != nil {
return err
}
command := newLoginCommand(nd.tendConn.dataBuffer)
if err := command.login(&nd.cluster.clientPolicy, nd.tendConn, nd.cluster.Password()); err != nil {
// Socket not authenticated. Do not put back into pool.
nd.tendConn.Close()
return err
}
nd._sessionToken.Store(command.SessionToken)
nd._sessionExpiration.Store(command.SessionExpiration)
return nil
} | go | func (nd *Node) refreshSessionToken() error {
// no session token to refresh
if !nd.cluster.clientPolicy.RequiresAuthentication() || nd.cluster.clientPolicy.AuthMode != AuthModeExternal {
return nil
}
var deadline time.Time
deadlineIfc := nd._sessionExpiration.Load()
if deadlineIfc != nil {
deadline = deadlineIfc.(time.Time)
}
if deadline.IsZero() || time.Now().Before(deadline) {
return nil
}
nd.tendConnLock.Lock()
defer nd.tendConnLock.Unlock()
if err := nd.initTendConn(nd.cluster.clientPolicy.LoginTimeout); err != nil {
return err
}
command := newLoginCommand(nd.tendConn.dataBuffer)
if err := command.login(&nd.cluster.clientPolicy, nd.tendConn, nd.cluster.Password()); err != nil {
// Socket not authenticated. Do not put back into pool.
nd.tendConn.Close()
return err
}
nd._sessionToken.Store(command.SessionToken)
nd._sessionExpiration.Store(command.SessionExpiration)
return nil
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"refreshSessionToken",
"(",
")",
"error",
"{",
"// no session token to refresh",
"if",
"!",
"nd",
".",
"cluster",
".",
"clientPolicy",
".",
"RequiresAuthentication",
"(",
")",
"||",
"nd",
".",
"cluster",
".",
"clientPolicy",
".",
"AuthMode",
"!=",
"AuthModeExternal",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"var",
"deadline",
"time",
".",
"Time",
"\n",
"deadlineIfc",
":=",
"nd",
".",
"_sessionExpiration",
".",
"Load",
"(",
")",
"\n",
"if",
"deadlineIfc",
"!=",
"nil",
"{",
"deadline",
"=",
"deadlineIfc",
".",
"(",
"time",
".",
"Time",
")",
"\n",
"}",
"\n\n",
"if",
"deadline",
".",
"IsZero",
"(",
")",
"||",
"time",
".",
"Now",
"(",
")",
".",
"Before",
"(",
"deadline",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"nd",
".",
"tendConnLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"nd",
".",
"tendConnLock",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"err",
":=",
"nd",
".",
"initTendConn",
"(",
"nd",
".",
"cluster",
".",
"clientPolicy",
".",
"LoginTimeout",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"command",
":=",
"newLoginCommand",
"(",
"nd",
".",
"tendConn",
".",
"dataBuffer",
")",
"\n",
"if",
"err",
":=",
"command",
".",
"login",
"(",
"&",
"nd",
".",
"cluster",
".",
"clientPolicy",
",",
"nd",
".",
"tendConn",
",",
"nd",
".",
"cluster",
".",
"Password",
"(",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"// Socket not authenticated. Do not put back into pool.",
"nd",
".",
"tendConn",
".",
"Close",
"(",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"nd",
".",
"_sessionToken",
".",
"Store",
"(",
"command",
".",
"SessionToken",
")",
"\n",
"nd",
".",
"_sessionExpiration",
".",
"Store",
"(",
"command",
".",
"SessionExpiration",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // refreshSessionToken refreshes the session token if it has been expired | [
"refreshSessionToken",
"refreshes",
"the",
"session",
"token",
"if",
"it",
"has",
"been",
"expired"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L203-L237 |
9,965 | aerospike/aerospike-client-go | node.go | GetConnection | func (nd *Node) GetConnection(timeout time.Duration) (conn *Connection, err error) {
if timeout == 0 {
timeout = _DEFAULT_TIMEOUT
}
deadline := time.Now().Add(timeout)
return nd.getConnection(deadline, timeout)
} | go | func (nd *Node) GetConnection(timeout time.Duration) (conn *Connection, err error) {
if timeout == 0 {
timeout = _DEFAULT_TIMEOUT
}
deadline := time.Now().Add(timeout)
return nd.getConnection(deadline, timeout)
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"GetConnection",
"(",
"timeout",
"time",
".",
"Duration",
")",
"(",
"conn",
"*",
"Connection",
",",
"err",
"error",
")",
"{",
"if",
"timeout",
"==",
"0",
"{",
"timeout",
"=",
"_DEFAULT_TIMEOUT",
"\n",
"}",
"\n",
"deadline",
":=",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"timeout",
")",
"\n\n",
"return",
"nd",
".",
"getConnection",
"(",
"deadline",
",",
"timeout",
")",
"\n",
"}"
]
| // GetConnection gets a connection to the node.
// If no pooled connection is available, a new connection will be created, unless
// ClientPolicy.MaxQueueSize number of connections are already created.
// This method will retry to retrieve a connection in case the connection pool
// is empty, until timeout is reached. | [
"GetConnection",
"gets",
"a",
"connection",
"to",
"the",
"node",
".",
"If",
"no",
"pooled",
"connection",
"is",
"available",
"a",
"new",
"connection",
"will",
"be",
"created",
"unless",
"ClientPolicy",
".",
"MaxQueueSize",
"number",
"of",
"connections",
"are",
"already",
"created",
".",
"This",
"method",
"will",
"retry",
"to",
"retrieve",
"a",
"connection",
"in",
"case",
"the",
"connection",
"pool",
"is",
"empty",
"until",
"timeout",
"is",
"reached",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L492-L499 |
9,966 | aerospike/aerospike-client-go | node.go | getConnection | func (nd *Node) getConnection(deadline time.Time, timeout time.Duration) (conn *Connection, err error) {
return nd.getConnectionWithHint(deadline, timeout, 0)
} | go | func (nd *Node) getConnection(deadline time.Time, timeout time.Duration) (conn *Connection, err error) {
return nd.getConnectionWithHint(deadline, timeout, 0)
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"getConnection",
"(",
"deadline",
"time",
".",
"Time",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"conn",
"*",
"Connection",
",",
"err",
"error",
")",
"{",
"return",
"nd",
".",
"getConnectionWithHint",
"(",
"deadline",
",",
"timeout",
",",
"0",
")",
"\n",
"}"
]
| // getConnection gets a connection to the node.
// If no pooled connection is available, a new connection will be created. | [
"getConnection",
"gets",
"a",
"connection",
"to",
"the",
"node",
".",
"If",
"no",
"pooled",
"connection",
"is",
"available",
"a",
"new",
"connection",
"will",
"be",
"created",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L503-L505 |
9,967 | aerospike/aerospike-client-go | node.go | connectionLimitReached | func (nd *Node) connectionLimitReached() (res bool) {
if nd.cluster.clientPolicy.LimitConnectionsToQueueSize {
cc := nd.connectionCount.IncrementAndGet()
if cc > nd.cluster.clientPolicy.ConnectionQueueSize {
res = true
}
nd.connectionCount.DecrementAndGet()
}
return res
} | go | func (nd *Node) connectionLimitReached() (res bool) {
if nd.cluster.clientPolicy.LimitConnectionsToQueueSize {
cc := nd.connectionCount.IncrementAndGet()
if cc > nd.cluster.clientPolicy.ConnectionQueueSize {
res = true
}
nd.connectionCount.DecrementAndGet()
}
return res
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"connectionLimitReached",
"(",
")",
"(",
"res",
"bool",
")",
"{",
"if",
"nd",
".",
"cluster",
".",
"clientPolicy",
".",
"LimitConnectionsToQueueSize",
"{",
"cc",
":=",
"nd",
".",
"connectionCount",
".",
"IncrementAndGet",
"(",
")",
"\n",
"if",
"cc",
">",
"nd",
".",
"cluster",
".",
"clientPolicy",
".",
"ConnectionQueueSize",
"{",
"res",
"=",
"true",
"\n",
"}",
"\n\n",
"nd",
".",
"connectionCount",
".",
"DecrementAndGet",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"res",
"\n",
"}"
]
| // connectionLimitReached return true if connection pool is fully serviced. | [
"connectionLimitReached",
"return",
"true",
"if",
"connection",
"pool",
"is",
"fully",
"serviced",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L508-L519 |
9,968 | aerospike/aerospike-client-go | node.go | newConnection | func (nd *Node) newConnection(overrideThreshold bool) (*Connection, error) {
// if connection count is limited and enough connections are already created, don't create a new one
cc := nd.connectionCount.IncrementAndGet()
if nd.cluster.clientPolicy.LimitConnectionsToQueueSize && cc > nd.cluster.clientPolicy.ConnectionQueueSize {
nd.connectionCount.DecrementAndGet()
atomic.AddInt64(&nd.stats.ConnectionsPoolEmpty, 1)
return nil, ErrTooManyConnectionsForNode
}
// Check for opening connection threshold
if !overrideThreshold && nd.cluster.clientPolicy.OpeningConnectionThreshold > 0 {
ct := nd.cluster.connectionThreshold.IncrementAndGet()
if ct > nd.cluster.clientPolicy.OpeningConnectionThreshold {
nd.cluster.connectionThreshold.DecrementAndGet()
return nil, ErrTooManyOpeningConnections
}
defer nd.cluster.connectionThreshold.DecrementAndGet()
}
atomic.AddInt64(&nd.stats.ConnectionsAttempts, 1)
conn, err := NewConnection(&nd.cluster.clientPolicy, nd.host)
if err != nil {
nd.connectionCount.DecrementAndGet()
atomic.AddInt64(&nd.stats.ConnectionsFailed, 1)
return nil, err
}
conn.node = nd
// need to authenticate
if err = conn.login(nd.sessionToken()); err != nil {
atomic.AddInt64(&nd.stats.ConnectionsFailed, 1)
// Socket not authenticated. Do not put back into pool.
conn.Close()
return nil, err
}
atomic.AddInt64(&nd.stats.ConnectionsSuccessful, 1)
return conn, nil
} | go | func (nd *Node) newConnection(overrideThreshold bool) (*Connection, error) {
// if connection count is limited and enough connections are already created, don't create a new one
cc := nd.connectionCount.IncrementAndGet()
if nd.cluster.clientPolicy.LimitConnectionsToQueueSize && cc > nd.cluster.clientPolicy.ConnectionQueueSize {
nd.connectionCount.DecrementAndGet()
atomic.AddInt64(&nd.stats.ConnectionsPoolEmpty, 1)
return nil, ErrTooManyConnectionsForNode
}
// Check for opening connection threshold
if !overrideThreshold && nd.cluster.clientPolicy.OpeningConnectionThreshold > 0 {
ct := nd.cluster.connectionThreshold.IncrementAndGet()
if ct > nd.cluster.clientPolicy.OpeningConnectionThreshold {
nd.cluster.connectionThreshold.DecrementAndGet()
return nil, ErrTooManyOpeningConnections
}
defer nd.cluster.connectionThreshold.DecrementAndGet()
}
atomic.AddInt64(&nd.stats.ConnectionsAttempts, 1)
conn, err := NewConnection(&nd.cluster.clientPolicy, nd.host)
if err != nil {
nd.connectionCount.DecrementAndGet()
atomic.AddInt64(&nd.stats.ConnectionsFailed, 1)
return nil, err
}
conn.node = nd
// need to authenticate
if err = conn.login(nd.sessionToken()); err != nil {
atomic.AddInt64(&nd.stats.ConnectionsFailed, 1)
// Socket not authenticated. Do not put back into pool.
conn.Close()
return nil, err
}
atomic.AddInt64(&nd.stats.ConnectionsSuccessful, 1)
return conn, nil
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"newConnection",
"(",
"overrideThreshold",
"bool",
")",
"(",
"*",
"Connection",
",",
"error",
")",
"{",
"// if connection count is limited and enough connections are already created, don't create a new one",
"cc",
":=",
"nd",
".",
"connectionCount",
".",
"IncrementAndGet",
"(",
")",
"\n",
"if",
"nd",
".",
"cluster",
".",
"clientPolicy",
".",
"LimitConnectionsToQueueSize",
"&&",
"cc",
">",
"nd",
".",
"cluster",
".",
"clientPolicy",
".",
"ConnectionQueueSize",
"{",
"nd",
".",
"connectionCount",
".",
"DecrementAndGet",
"(",
")",
"\n",
"atomic",
".",
"AddInt64",
"(",
"&",
"nd",
".",
"stats",
".",
"ConnectionsPoolEmpty",
",",
"1",
")",
"\n\n",
"return",
"nil",
",",
"ErrTooManyConnectionsForNode",
"\n",
"}",
"\n\n",
"// Check for opening connection threshold",
"if",
"!",
"overrideThreshold",
"&&",
"nd",
".",
"cluster",
".",
"clientPolicy",
".",
"OpeningConnectionThreshold",
">",
"0",
"{",
"ct",
":=",
"nd",
".",
"cluster",
".",
"connectionThreshold",
".",
"IncrementAndGet",
"(",
")",
"\n",
"if",
"ct",
">",
"nd",
".",
"cluster",
".",
"clientPolicy",
".",
"OpeningConnectionThreshold",
"{",
"nd",
".",
"cluster",
".",
"connectionThreshold",
".",
"DecrementAndGet",
"(",
")",
"\n\n",
"return",
"nil",
",",
"ErrTooManyOpeningConnections",
"\n",
"}",
"\n\n",
"defer",
"nd",
".",
"cluster",
".",
"connectionThreshold",
".",
"DecrementAndGet",
"(",
")",
"\n",
"}",
"\n\n",
"atomic",
".",
"AddInt64",
"(",
"&",
"nd",
".",
"stats",
".",
"ConnectionsAttempts",
",",
"1",
")",
"\n",
"conn",
",",
"err",
":=",
"NewConnection",
"(",
"&",
"nd",
".",
"cluster",
".",
"clientPolicy",
",",
"nd",
".",
"host",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"nd",
".",
"connectionCount",
".",
"DecrementAndGet",
"(",
")",
"\n",
"atomic",
".",
"AddInt64",
"(",
"&",
"nd",
".",
"stats",
".",
"ConnectionsFailed",
",",
"1",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"conn",
".",
"node",
"=",
"nd",
"\n\n",
"// need to authenticate",
"if",
"err",
"=",
"conn",
".",
"login",
"(",
"nd",
".",
"sessionToken",
"(",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"atomic",
".",
"AddInt64",
"(",
"&",
"nd",
".",
"stats",
".",
"ConnectionsFailed",
",",
"1",
")",
"\n\n",
"// Socket not authenticated. Do not put back into pool.",
"conn",
".",
"Close",
"(",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"atomic",
".",
"AddInt64",
"(",
"&",
"nd",
".",
"stats",
".",
"ConnectionsSuccessful",
",",
"1",
")",
"\n\n",
"return",
"conn",
",",
"nil",
"\n",
"}"
]
| // newConnection will make a new connection for the node. | [
"newConnection",
"will",
"make",
"a",
"new",
"connection",
"for",
"the",
"node",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L522-L565 |
9,969 | aerospike/aerospike-client-go | node.go | makeConnectionForPool | func (nd *Node) makeConnectionForPool(deadline time.Time, hint byte) {
if deadline.IsZero() {
deadline = time.Now().Add(_DEFAULT_TIMEOUT)
}
// don't even try to make a new connection if connection limit is reached
if nd.connectionLimitReached() {
return
}
L:
// don't loop forever; free the goroutine after the deadline
if time.Now().After(deadline) {
return
}
conn, err := nd.newConnection(false)
if err != nil {
// The following check can help break the loop under heavy load and remove
// quite a lot of latency.
if err == ErrTooManyConnectionsForNode {
// The connection pool is already full. No need for more connections.
return
}
Logger.Error("Error trying to making a connection to the node %s: %s", nd.String(), err.Error())
time.Sleep(time.Millisecond)
goto L
}
nd.putConnectionWithHint(conn, hint)
} | go | func (nd *Node) makeConnectionForPool(deadline time.Time, hint byte) {
if deadline.IsZero() {
deadline = time.Now().Add(_DEFAULT_TIMEOUT)
}
// don't even try to make a new connection if connection limit is reached
if nd.connectionLimitReached() {
return
}
L:
// don't loop forever; free the goroutine after the deadline
if time.Now().After(deadline) {
return
}
conn, err := nd.newConnection(false)
if err != nil {
// The following check can help break the loop under heavy load and remove
// quite a lot of latency.
if err == ErrTooManyConnectionsForNode {
// The connection pool is already full. No need for more connections.
return
}
Logger.Error("Error trying to making a connection to the node %s: %s", nd.String(), err.Error())
time.Sleep(time.Millisecond)
goto L
}
nd.putConnectionWithHint(conn, hint)
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"makeConnectionForPool",
"(",
"deadline",
"time",
".",
"Time",
",",
"hint",
"byte",
")",
"{",
"if",
"deadline",
".",
"IsZero",
"(",
")",
"{",
"deadline",
"=",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"_DEFAULT_TIMEOUT",
")",
"\n",
"}",
"\n\n",
"// don't even try to make a new connection if connection limit is reached",
"if",
"nd",
".",
"connectionLimitReached",
"(",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"L",
":",
"// don't loop forever; free the goroutine after the deadline",
"if",
"time",
".",
"Now",
"(",
")",
".",
"After",
"(",
"deadline",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"conn",
",",
"err",
":=",
"nd",
".",
"newConnection",
"(",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// The following check can help break the loop under heavy load and remove",
"// quite a lot of latency.",
"if",
"err",
"==",
"ErrTooManyConnectionsForNode",
"{",
"// The connection pool is already full. No need for more connections.",
"return",
"\n",
"}",
"\n\n",
"Logger",
".",
"Error",
"(",
"\"",
"\"",
",",
"nd",
".",
"String",
"(",
")",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n\n",
"time",
".",
"Sleep",
"(",
"time",
".",
"Millisecond",
")",
"\n",
"goto",
"L",
"\n",
"}",
"\n\n",
"nd",
".",
"putConnectionWithHint",
"(",
"conn",
",",
"hint",
")",
"\n",
"}"
]
| // makeConnectionForPool will try to open a connection until deadline.
// if no deadline is defined, it will only try for _DEFAULT_TIMEOUT. | [
"makeConnectionForPool",
"will",
"try",
"to",
"open",
"a",
"connection",
"until",
"deadline",
".",
"if",
"no",
"deadline",
"is",
"defined",
"it",
"will",
"only",
"try",
"for",
"_DEFAULT_TIMEOUT",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L569-L601 |
9,970 | aerospike/aerospike-client-go | node.go | getConnectionWithHint | func (nd *Node) getConnectionWithHint(deadline time.Time, timeout time.Duration, hint byte) (conn *Connection, err error) {
var socketDeadline time.Time
connReqd := false
L:
// try to get a valid connection from the connection pool
for conn = nd.connections.Poll(hint); conn != nil; conn = nd.connections.Poll(hint) {
if conn.IsConnected() {
break
}
conn.Close()
conn = nil
}
// don't loop forever; return the goroutine after deadline.
// deadline will always be set when requesting for a connection.
if connReqd && time.Now().After(socketDeadline) {
atomic.AddInt64(&nd.stats.ConnectionsPoolEmpty, 1)
return nil, ErrConnectionPoolEmpty
}
if conn == nil {
if !connReqd {
go nd.makeConnectionForPool(deadline, hint)
// do not request to open a connection more than once.
connReqd = true
// only try to set a deadline once without a penalty on each run.
// most call to this function will find a connection in the queue.
if timeout > 0 {
socketDeadline = time.Now().Add(timeout)
} else {
socketDeadline = time.Now().Add(_DEFAULT_TIMEOUT)
}
}
time.Sleep(time.Millisecond)
goto L
}
if err = conn.SetTimeout(deadline, timeout); err != nil {
atomic.AddInt64(&nd.stats.ConnectionsFailed, 1)
// Do not put back into pool.
conn.Close()
return nil, err
}
conn.setIdleTimeout(nd.cluster.clientPolicy.IdleTimeout)
conn.refresh()
return conn, nil
} | go | func (nd *Node) getConnectionWithHint(deadline time.Time, timeout time.Duration, hint byte) (conn *Connection, err error) {
var socketDeadline time.Time
connReqd := false
L:
// try to get a valid connection from the connection pool
for conn = nd.connections.Poll(hint); conn != nil; conn = nd.connections.Poll(hint) {
if conn.IsConnected() {
break
}
conn.Close()
conn = nil
}
// don't loop forever; return the goroutine after deadline.
// deadline will always be set when requesting for a connection.
if connReqd && time.Now().After(socketDeadline) {
atomic.AddInt64(&nd.stats.ConnectionsPoolEmpty, 1)
return nil, ErrConnectionPoolEmpty
}
if conn == nil {
if !connReqd {
go nd.makeConnectionForPool(deadline, hint)
// do not request to open a connection more than once.
connReqd = true
// only try to set a deadline once without a penalty on each run.
// most call to this function will find a connection in the queue.
if timeout > 0 {
socketDeadline = time.Now().Add(timeout)
} else {
socketDeadline = time.Now().Add(_DEFAULT_TIMEOUT)
}
}
time.Sleep(time.Millisecond)
goto L
}
if err = conn.SetTimeout(deadline, timeout); err != nil {
atomic.AddInt64(&nd.stats.ConnectionsFailed, 1)
// Do not put back into pool.
conn.Close()
return nil, err
}
conn.setIdleTimeout(nd.cluster.clientPolicy.IdleTimeout)
conn.refresh()
return conn, nil
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"getConnectionWithHint",
"(",
"deadline",
"time",
".",
"Time",
",",
"timeout",
"time",
".",
"Duration",
",",
"hint",
"byte",
")",
"(",
"conn",
"*",
"Connection",
",",
"err",
"error",
")",
"{",
"var",
"socketDeadline",
"time",
".",
"Time",
"\n",
"connReqd",
":=",
"false",
"\n\n",
"L",
":",
"// try to get a valid connection from the connection pool",
"for",
"conn",
"=",
"nd",
".",
"connections",
".",
"Poll",
"(",
"hint",
")",
";",
"conn",
"!=",
"nil",
";",
"conn",
"=",
"nd",
".",
"connections",
".",
"Poll",
"(",
"hint",
")",
"{",
"if",
"conn",
".",
"IsConnected",
"(",
")",
"{",
"break",
"\n",
"}",
"\n",
"conn",
".",
"Close",
"(",
")",
"\n",
"conn",
"=",
"nil",
"\n",
"}",
"\n\n",
"// don't loop forever; return the goroutine after deadline.",
"// deadline will always be set when requesting for a connection.",
"if",
"connReqd",
"&&",
"time",
".",
"Now",
"(",
")",
".",
"After",
"(",
"socketDeadline",
")",
"{",
"atomic",
".",
"AddInt64",
"(",
"&",
"nd",
".",
"stats",
".",
"ConnectionsPoolEmpty",
",",
"1",
")",
"\n\n",
"return",
"nil",
",",
"ErrConnectionPoolEmpty",
"\n",
"}",
"\n\n",
"if",
"conn",
"==",
"nil",
"{",
"if",
"!",
"connReqd",
"{",
"go",
"nd",
".",
"makeConnectionForPool",
"(",
"deadline",
",",
"hint",
")",
"\n\n",
"// do not request to open a connection more than once.",
"connReqd",
"=",
"true",
"\n\n",
"// only try to set a deadline once without a penalty on each run.",
"// most call to this function will find a connection in the queue.",
"if",
"timeout",
">",
"0",
"{",
"socketDeadline",
"=",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"timeout",
")",
"\n",
"}",
"else",
"{",
"socketDeadline",
"=",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"_DEFAULT_TIMEOUT",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"time",
".",
"Sleep",
"(",
"time",
".",
"Millisecond",
")",
"\n",
"goto",
"L",
"\n",
"}",
"\n\n",
"if",
"err",
"=",
"conn",
".",
"SetTimeout",
"(",
"deadline",
",",
"timeout",
")",
";",
"err",
"!=",
"nil",
"{",
"atomic",
".",
"AddInt64",
"(",
"&",
"nd",
".",
"stats",
".",
"ConnectionsFailed",
",",
"1",
")",
"\n\n",
"// Do not put back into pool.",
"conn",
".",
"Close",
"(",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"conn",
".",
"setIdleTimeout",
"(",
"nd",
".",
"cluster",
".",
"clientPolicy",
".",
"IdleTimeout",
")",
"\n",
"conn",
".",
"refresh",
"(",
")",
"\n\n",
"return",
"conn",
",",
"nil",
"\n",
"}"
]
| // getConnectionWithHint gets a connection to the node.
// If no pooled connection is available, a new connection will be created. | [
"getConnectionWithHint",
"gets",
"a",
"connection",
"to",
"the",
"node",
".",
"If",
"no",
"pooled",
"connection",
"is",
"available",
"a",
"new",
"connection",
"will",
"be",
"created",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L605-L660 |
9,971 | aerospike/aerospike-client-go | node.go | putConnectionWithHint | func (nd *Node) putConnectionWithHint(conn *Connection, hint byte) bool {
conn.refresh()
if !nd.active.Get() || !nd.connections.Offer(conn, hint) {
conn.Close()
return false
}
return true
} | go | func (nd *Node) putConnectionWithHint(conn *Connection, hint byte) bool {
conn.refresh()
if !nd.active.Get() || !nd.connections.Offer(conn, hint) {
conn.Close()
return false
}
return true
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"putConnectionWithHint",
"(",
"conn",
"*",
"Connection",
",",
"hint",
"byte",
")",
"bool",
"{",
"conn",
".",
"refresh",
"(",
")",
"\n",
"if",
"!",
"nd",
".",
"active",
".",
"Get",
"(",
")",
"||",
"!",
"nd",
".",
"connections",
".",
"Offer",
"(",
"conn",
",",
"hint",
")",
"{",
"conn",
".",
"Close",
"(",
")",
"\n",
"return",
"false",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
]
| // PutConnection puts back a connection to the pool.
// If connection pool is full, the connection will be
// closed and discarded. | [
"PutConnection",
"puts",
"back",
"a",
"connection",
"to",
"the",
"pool",
".",
"If",
"connection",
"pool",
"is",
"full",
"the",
"connection",
"will",
"be",
"closed",
"and",
"discarded",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L665-L672 |
9,972 | aerospike/aerospike-client-go | node.go | IsActive | func (nd *Node) IsActive() bool {
return nd != nil && nd.active.Get() && nd.partitionGeneration.Get() >= -1
} | go | func (nd *Node) IsActive() bool {
return nd != nil && nd.active.Get() && nd.partitionGeneration.Get() >= -1
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"IsActive",
"(",
")",
"bool",
"{",
"return",
"nd",
"!=",
"nil",
"&&",
"nd",
".",
"active",
".",
"Get",
"(",
")",
"&&",
"nd",
".",
"partitionGeneration",
".",
"Get",
"(",
")",
">=",
"-",
"1",
"\n",
"}"
]
| // IsActive Checks if the node is active. | [
"IsActive",
"Checks",
"if",
"the",
"node",
"is",
"active",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L692-L694 |
9,973 | aerospike/aerospike-client-go | node.go | addAlias | func (nd *Node) addAlias(aliasToAdd *Host) {
// Aliases are only referenced in the cluster tend goroutine,
// so synchronization is not necessary.
aliases := nd.GetAliases()
if aliases == nil {
aliases = []*Host{}
}
aliases = append(aliases, aliasToAdd)
nd.setAliases(aliases)
} | go | func (nd *Node) addAlias(aliasToAdd *Host) {
// Aliases are only referenced in the cluster tend goroutine,
// so synchronization is not necessary.
aliases := nd.GetAliases()
if aliases == nil {
aliases = []*Host{}
}
aliases = append(aliases, aliasToAdd)
nd.setAliases(aliases)
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"addAlias",
"(",
"aliasToAdd",
"*",
"Host",
")",
"{",
"// Aliases are only referenced in the cluster tend goroutine,",
"// so synchronization is not necessary.",
"aliases",
":=",
"nd",
".",
"GetAliases",
"(",
")",
"\n",
"if",
"aliases",
"==",
"nil",
"{",
"aliases",
"=",
"[",
"]",
"*",
"Host",
"{",
"}",
"\n",
"}",
"\n\n",
"aliases",
"=",
"append",
"(",
"aliases",
",",
"aliasToAdd",
")",
"\n",
"nd",
".",
"setAliases",
"(",
"aliases",
")",
"\n",
"}"
]
| // AddAlias adds an alias for the node | [
"AddAlias",
"adds",
"an",
"alias",
"for",
"the",
"node"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L712-L722 |
9,974 | aerospike/aerospike-client-go | node.go | Close | func (nd *Node) Close() {
nd.active.Set(false)
atomic.AddInt64(&nd.stats.NodeRemoved, 1)
nd.closeConnections()
} | go | func (nd *Node) Close() {
nd.active.Set(false)
atomic.AddInt64(&nd.stats.NodeRemoved, 1)
nd.closeConnections()
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"Close",
"(",
")",
"{",
"nd",
".",
"active",
".",
"Set",
"(",
"false",
")",
"\n",
"atomic",
".",
"AddInt64",
"(",
"&",
"nd",
".",
"stats",
".",
"NodeRemoved",
",",
"1",
")",
"\n",
"nd",
".",
"closeConnections",
"(",
")",
"\n",
"}"
]
| // Close marks node as inactive and closes all of its pooled connections. | [
"Close",
"marks",
"node",
"as",
"inactive",
"and",
"closes",
"all",
"of",
"its",
"pooled",
"connections",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L725-L729 |
9,975 | aerospike/aerospike-client-go | node.go | Equals | func (nd *Node) Equals(other *Node) bool {
return nd != nil && other != nil && (nd == other || nd.name == other.name)
} | go | func (nd *Node) Equals(other *Node) bool {
return nd != nil && other != nil && (nd == other || nd.name == other.name)
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"Equals",
"(",
"other",
"*",
"Node",
")",
"bool",
"{",
"return",
"nd",
"!=",
"nil",
"&&",
"other",
"!=",
"nil",
"&&",
"(",
"nd",
"==",
"other",
"||",
"nd",
".",
"name",
"==",
"other",
".",
"name",
")",
"\n",
"}"
]
| // Equals compares equality of two nodes based on their names. | [
"Equals",
"compares",
"equality",
"of",
"two",
"nodes",
"based",
"on",
"their",
"names",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L751-L753 |
9,976 | aerospike/aerospike-client-go | node.go | MigrationInProgress | func (nd *Node) MigrationInProgress() (bool, error) {
values, err := nd.RequestStats(&nd.cluster.infoPolicy)
if err != nil {
return false, err
}
// if the migrate_partitions_remaining exists and is not `0`, then migration is in progress
if migration, exists := values["migrate_partitions_remaining"]; exists && migration != "0" {
return true, nil
}
// migration not in progress
return false, nil
} | go | func (nd *Node) MigrationInProgress() (bool, error) {
values, err := nd.RequestStats(&nd.cluster.infoPolicy)
if err != nil {
return false, err
}
// if the migrate_partitions_remaining exists and is not `0`, then migration is in progress
if migration, exists := values["migrate_partitions_remaining"]; exists && migration != "0" {
return true, nil
}
// migration not in progress
return false, nil
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"MigrationInProgress",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"values",
",",
"err",
":=",
"nd",
".",
"RequestStats",
"(",
"&",
"nd",
".",
"cluster",
".",
"infoPolicy",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"// if the migrate_partitions_remaining exists and is not `0`, then migration is in progress",
"if",
"migration",
",",
"exists",
":=",
"values",
"[",
"\"",
"\"",
"]",
";",
"exists",
"&&",
"migration",
"!=",
"\"",
"\"",
"{",
"return",
"true",
",",
"nil",
"\n",
"}",
"\n\n",
"// migration not in progress",
"return",
"false",
",",
"nil",
"\n",
"}"
]
| // MigrationInProgress determines if the node is participating in a data migration | [
"MigrationInProgress",
"determines",
"if",
"the",
"node",
"is",
"participating",
"in",
"a",
"data",
"migration"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L756-L769 |
9,977 | aerospike/aerospike-client-go | node.go | initTendConn | func (nd *Node) initTendConn(timeout time.Duration) error {
var deadline time.Time
if timeout > 0 {
deadline = time.Now().Add(timeout)
}
if nd.tendConn == nil || !nd.tendConn.IsConnected() {
// Tend connection required a long timeout
tendConn, err := nd.getConnection(deadline, timeout)
if err != nil {
return err
}
nd.tendConn = tendConn
}
// Set timeout for tend conn
return nd.tendConn.SetTimeout(deadline, timeout)
} | go | func (nd *Node) initTendConn(timeout time.Duration) error {
var deadline time.Time
if timeout > 0 {
deadline = time.Now().Add(timeout)
}
if nd.tendConn == nil || !nd.tendConn.IsConnected() {
// Tend connection required a long timeout
tendConn, err := nd.getConnection(deadline, timeout)
if err != nil {
return err
}
nd.tendConn = tendConn
}
// Set timeout for tend conn
return nd.tendConn.SetTimeout(deadline, timeout)
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"initTendConn",
"(",
"timeout",
"time",
".",
"Duration",
")",
"error",
"{",
"var",
"deadline",
"time",
".",
"Time",
"\n",
"if",
"timeout",
">",
"0",
"{",
"deadline",
"=",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"timeout",
")",
"\n",
"}",
"\n\n",
"if",
"nd",
".",
"tendConn",
"==",
"nil",
"||",
"!",
"nd",
".",
"tendConn",
".",
"IsConnected",
"(",
")",
"{",
"// Tend connection required a long timeout",
"tendConn",
",",
"err",
":=",
"nd",
".",
"getConnection",
"(",
"deadline",
",",
"timeout",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"nd",
".",
"tendConn",
"=",
"tendConn",
"\n",
"}",
"\n\n",
"// Set timeout for tend conn",
"return",
"nd",
".",
"tendConn",
".",
"SetTimeout",
"(",
"deadline",
",",
"timeout",
")",
"\n",
"}"
]
| // initTendConn sets up a connection to be used for info requests.
// The same connection will be used for tend. | [
"initTendConn",
"sets",
"up",
"a",
"connection",
"to",
"be",
"used",
"for",
"info",
"requests",
".",
"The",
"same",
"connection",
"will",
"be",
"used",
"for",
"tend",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L800-L818 |
9,978 | aerospike/aerospike-client-go | node.go | requestInfoWithRetry | func (nd *Node) requestInfoWithRetry(policy *InfoPolicy, n int, name ...string) (res map[string]string, err error) {
for i := 0; i < n; i++ {
if res, err = nd.requestInfo(policy.Timeout, name...); err == nil {
return res, nil
}
Logger.Error("Error occurred while fetching info from the server node %s: %s", nd.host.String(), err.Error())
time.Sleep(100 * time.Millisecond)
}
// return the last error
return nil, err
} | go | func (nd *Node) requestInfoWithRetry(policy *InfoPolicy, n int, name ...string) (res map[string]string, err error) {
for i := 0; i < n; i++ {
if res, err = nd.requestInfo(policy.Timeout, name...); err == nil {
return res, nil
}
Logger.Error("Error occurred while fetching info from the server node %s: %s", nd.host.String(), err.Error())
time.Sleep(100 * time.Millisecond)
}
// return the last error
return nil, err
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"requestInfoWithRetry",
"(",
"policy",
"*",
"InfoPolicy",
",",
"n",
"int",
",",
"name",
"...",
"string",
")",
"(",
"res",
"map",
"[",
"string",
"]",
"string",
",",
"err",
"error",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{",
"if",
"res",
",",
"err",
"=",
"nd",
".",
"requestInfo",
"(",
"policy",
".",
"Timeout",
",",
"name",
"...",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"res",
",",
"nil",
"\n",
"}",
"\n\n",
"Logger",
".",
"Error",
"(",
"\"",
"\"",
",",
"nd",
".",
"host",
".",
"String",
"(",
")",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"time",
".",
"Sleep",
"(",
"100",
"*",
"time",
".",
"Millisecond",
")",
"\n",
"}",
"\n\n",
"// return the last error",
"return",
"nil",
",",
"err",
"\n",
"}"
]
| // requestInfoWithRetry gets info values by name from the specified database server node.
// It will try at least N times before returning an error. | [
"requestInfoWithRetry",
"gets",
"info",
"values",
"by",
"name",
"from",
"the",
"specified",
"database",
"server",
"node",
".",
"It",
"will",
"try",
"at",
"least",
"N",
"times",
"before",
"returning",
"an",
"error",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L822-L834 |
9,979 | aerospike/aerospike-client-go | node.go | requestRawInfo | func (nd *Node) requestRawInfo(policy *InfoPolicy, name ...string) (*info, error) {
nd.tendConnLock.Lock()
defer nd.tendConnLock.Unlock()
if err := nd.initTendConn(policy.Timeout); err != nil {
return nil, err
}
response, err := newInfo(nd.tendConn, name...)
if err != nil {
nd.tendConn.Close()
return nil, err
}
return response, nil
} | go | func (nd *Node) requestRawInfo(policy *InfoPolicy, name ...string) (*info, error) {
nd.tendConnLock.Lock()
defer nd.tendConnLock.Unlock()
if err := nd.initTendConn(policy.Timeout); err != nil {
return nil, err
}
response, err := newInfo(nd.tendConn, name...)
if err != nil {
nd.tendConn.Close()
return nil, err
}
return response, nil
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"requestRawInfo",
"(",
"policy",
"*",
"InfoPolicy",
",",
"name",
"...",
"string",
")",
"(",
"*",
"info",
",",
"error",
")",
"{",
"nd",
".",
"tendConnLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"nd",
".",
"tendConnLock",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"err",
":=",
"nd",
".",
"initTendConn",
"(",
"policy",
".",
"Timeout",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"response",
",",
"err",
":=",
"newInfo",
"(",
"nd",
".",
"tendConn",
",",
"name",
"...",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"nd",
".",
"tendConn",
".",
"Close",
"(",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"response",
",",
"nil",
"\n",
"}"
]
| // requestRawInfo gets info values by name from the specified database server node.
// It won't parse the results. | [
"requestRawInfo",
"gets",
"info",
"values",
"by",
"name",
"from",
"the",
"specified",
"database",
"server",
"node",
".",
"It",
"won",
"t",
"parse",
"the",
"results",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L860-L874 |
9,980 | aerospike/aerospike-client-go | node.go | RequestStats | func (node *Node) RequestStats(policy *InfoPolicy) (map[string]string, error) {
infoMap, err := node.RequestInfo(policy, "statistics")
if err != nil {
return nil, err
}
res := map[string]string{}
v, exists := infoMap["statistics"]
if !exists {
return res, nil
}
values := strings.Split(v, ";")
for i := range values {
kv := strings.Split(values[i], "=")
if len(kv) > 1 {
res[kv[0]] = kv[1]
}
}
return res, nil
} | go | func (node *Node) RequestStats(policy *InfoPolicy) (map[string]string, error) {
infoMap, err := node.RequestInfo(policy, "statistics")
if err != nil {
return nil, err
}
res := map[string]string{}
v, exists := infoMap["statistics"]
if !exists {
return res, nil
}
values := strings.Split(v, ";")
for i := range values {
kv := strings.Split(values[i], "=")
if len(kv) > 1 {
res[kv[0]] = kv[1]
}
}
return res, nil
} | [
"func",
"(",
"node",
"*",
"Node",
")",
"RequestStats",
"(",
"policy",
"*",
"InfoPolicy",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"infoMap",
",",
"err",
":=",
"node",
".",
"RequestInfo",
"(",
"policy",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"res",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n\n",
"v",
",",
"exists",
":=",
"infoMap",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"!",
"exists",
"{",
"return",
"res",
",",
"nil",
"\n",
"}",
"\n\n",
"values",
":=",
"strings",
".",
"Split",
"(",
"v",
",",
"\"",
"\"",
")",
"\n",
"for",
"i",
":=",
"range",
"values",
"{",
"kv",
":=",
"strings",
".",
"Split",
"(",
"values",
"[",
"i",
"]",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"kv",
")",
">",
"1",
"{",
"res",
"[",
"kv",
"[",
"0",
"]",
"]",
"=",
"kv",
"[",
"1",
"]",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"res",
",",
"nil",
"\n",
"}"
]
| // RequestStats returns statistics for the specified node as a map | [
"RequestStats",
"returns",
"statistics",
"for",
"the",
"specified",
"node",
"as",
"a",
"map"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L877-L899 |
9,981 | aerospike/aerospike-client-go | node.go | sessionToken | func (nd *Node) sessionToken() []byte {
var deadline time.Time
deadlineIfc := nd._sessionExpiration.Load()
if deadlineIfc != nil {
deadline = deadlineIfc.(time.Time)
}
if deadline.IsZero() || time.Now().After(deadline) {
return nil
}
st := nd._sessionToken.Load()
if st != nil {
return st.([]byte)
}
return nil
} | go | func (nd *Node) sessionToken() []byte {
var deadline time.Time
deadlineIfc := nd._sessionExpiration.Load()
if deadlineIfc != nil {
deadline = deadlineIfc.(time.Time)
}
if deadline.IsZero() || time.Now().After(deadline) {
return nil
}
st := nd._sessionToken.Load()
if st != nil {
return st.([]byte)
}
return nil
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"sessionToken",
"(",
")",
"[",
"]",
"byte",
"{",
"var",
"deadline",
"time",
".",
"Time",
"\n",
"deadlineIfc",
":=",
"nd",
".",
"_sessionExpiration",
".",
"Load",
"(",
")",
"\n",
"if",
"deadlineIfc",
"!=",
"nil",
"{",
"deadline",
"=",
"deadlineIfc",
".",
"(",
"time",
".",
"Time",
")",
"\n",
"}",
"\n\n",
"if",
"deadline",
".",
"IsZero",
"(",
")",
"||",
"time",
".",
"Now",
"(",
")",
".",
"After",
"(",
"deadline",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"st",
":=",
"nd",
".",
"_sessionToken",
".",
"Load",
"(",
")",
"\n",
"if",
"st",
"!=",
"nil",
"{",
"return",
"st",
".",
"(",
"[",
"]",
"byte",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
| // sessionToken returns the session token for the node.
// It will return nil if the session has expired. | [
"sessionToken",
"returns",
"the",
"session",
"token",
"for",
"the",
"node",
".",
"It",
"will",
"return",
"nil",
"if",
"the",
"session",
"has",
"expired",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L903-L919 |
9,982 | aerospike/aerospike-client-go | node.go | Rack | func (nd *Node) Rack(namespace string) (int, error) {
racks := nd.racks.Load().(map[string]int)
v, exists := racks[namespace]
if exists {
return v, nil
}
return -1, newAerospikeNodeError(nd, RACK_NOT_DEFINED)
} | go | func (nd *Node) Rack(namespace string) (int, error) {
racks := nd.racks.Load().(map[string]int)
v, exists := racks[namespace]
if exists {
return v, nil
}
return -1, newAerospikeNodeError(nd, RACK_NOT_DEFINED)
} | [
"func",
"(",
"nd",
"*",
"Node",
")",
"Rack",
"(",
"namespace",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"racks",
":=",
"nd",
".",
"racks",
".",
"Load",
"(",
")",
".",
"(",
"map",
"[",
"string",
"]",
"int",
")",
"\n",
"v",
",",
"exists",
":=",
"racks",
"[",
"namespace",
"]",
"\n\n",
"if",
"exists",
"{",
"return",
"v",
",",
"nil",
"\n",
"}",
"\n\n",
"return",
"-",
"1",
",",
"newAerospikeNodeError",
"(",
"nd",
",",
"RACK_NOT_DEFINED",
")",
"\n",
"}"
]
| // Rack returns the rack number for the namespace. | [
"Rack",
"returns",
"the",
"rack",
"number",
"for",
"the",
"namespace",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/node.go#L922-L931 |
9,983 | aerospike/aerospike-client-go | partition.go | newPartitionByKey | func newPartitionByKey(key *Key) Partition {
return Partition{
Namespace: key.namespace,
// CAN'T USE MOD directly - mod will give negative numbers.
// First AND makes positive and negative correctly, then mod.
// For any x, y : x % 2^y = x & (2^y - 1); the second method is twice as fast
PartitionId: int(Buffer.LittleBytesToInt32(key.digest[:], 0)&0xFFFF) & (_PARTITIONS - 1),
}
} | go | func newPartitionByKey(key *Key) Partition {
return Partition{
Namespace: key.namespace,
// CAN'T USE MOD directly - mod will give negative numbers.
// First AND makes positive and negative correctly, then mod.
// For any x, y : x % 2^y = x & (2^y - 1); the second method is twice as fast
PartitionId: int(Buffer.LittleBytesToInt32(key.digest[:], 0)&0xFFFF) & (_PARTITIONS - 1),
}
} | [
"func",
"newPartitionByKey",
"(",
"key",
"*",
"Key",
")",
"Partition",
"{",
"return",
"Partition",
"{",
"Namespace",
":",
"key",
".",
"namespace",
",",
"// CAN'T USE MOD directly - mod will give negative numbers.",
"// First AND makes positive and negative correctly, then mod.",
"// For any x, y : x % 2^y = x & (2^y - 1); the second method is twice as fast",
"PartitionId",
":",
"int",
"(",
"Buffer",
".",
"LittleBytesToInt32",
"(",
"key",
".",
"digest",
"[",
":",
"]",
",",
"0",
")",
"&",
"0xFFFF",
")",
"&",
"(",
"_PARTITIONS",
"-",
"1",
")",
",",
"}",
"\n",
"}"
]
| // newPartitionByKey initializes a partition and determines the Partition Id
// from key digest automatically. It return the struct itself, and not the address | [
"newPartitionByKey",
"initializes",
"a",
"partition",
"and",
"determines",
"the",
"Partition",
"Id",
"from",
"key",
"digest",
"automatically",
".",
"It",
"return",
"the",
"struct",
"itself",
"and",
"not",
"the",
"address"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/partition.go#L38-L47 |
9,984 | aerospike/aerospike-client-go | partition.go | NewPartition | func NewPartition(namespace string, partitionID int) *Partition {
return &Partition{
Namespace: namespace,
PartitionId: partitionID,
}
} | go | func NewPartition(namespace string, partitionID int) *Partition {
return &Partition{
Namespace: namespace,
PartitionId: partitionID,
}
} | [
"func",
"NewPartition",
"(",
"namespace",
"string",
",",
"partitionID",
"int",
")",
"*",
"Partition",
"{",
"return",
"&",
"Partition",
"{",
"Namespace",
":",
"namespace",
",",
"PartitionId",
":",
"partitionID",
",",
"}",
"\n",
"}"
]
| // NewPartition generates a partition instance. | [
"NewPartition",
"generates",
"a",
"partition",
"instance",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/partition.go#L50-L55 |
9,985 | aerospike/aerospike-client-go | partition.go | Equals | func (ptn *Partition) Equals(other *Partition) bool {
return ptn.PartitionId == other.PartitionId && ptn.Namespace == other.Namespace
} | go | func (ptn *Partition) Equals(other *Partition) bool {
return ptn.PartitionId == other.PartitionId && ptn.Namespace == other.Namespace
} | [
"func",
"(",
"ptn",
"*",
"Partition",
")",
"Equals",
"(",
"other",
"*",
"Partition",
")",
"bool",
"{",
"return",
"ptn",
".",
"PartitionId",
"==",
"other",
".",
"PartitionId",
"&&",
"ptn",
".",
"Namespace",
"==",
"other",
".",
"Namespace",
"\n",
"}"
]
| // Equals checks equality of two partitions. | [
"Equals",
"checks",
"equality",
"of",
"two",
"partitions",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/partition.go#L63-L65 |
9,986 | aerospike/aerospike-client-go | command.go | setWrite | func (cmd *baseCommand) setWrite(policy *WritePolicy, operation OperationType, key *Key, bins []*Bin, binMap BinMap) error {
cmd.begin()
fieldCount, err := cmd.estimateKeySize(key, policy.SendKey)
if err != nil {
return err
}
if binMap == nil {
for i := range bins {
if err := cmd.estimateOperationSizeForBin(bins[i]); err != nil {
return err
}
}
} else {
for name, value := range binMap {
if err := cmd.estimateOperationSizeForBinNameAndValue(name, value); err != nil {
return err
}
}
}
if err := cmd.sizeBuffer(); err != nil {
return err
}
if binMap == nil {
cmd.writeHeaderWithPolicy(policy, 0, _INFO2_WRITE, fieldCount, len(bins))
} else {
cmd.writeHeaderWithPolicy(policy, 0, _INFO2_WRITE, fieldCount, len(binMap))
}
cmd.writeKey(key, policy.SendKey)
if binMap == nil {
for i := range bins {
if err := cmd.writeOperationForBin(bins[i], operation); err != nil {
return err
}
}
} else {
for name, value := range binMap {
if err := cmd.writeOperationForBinNameAndValue(name, value, operation); err != nil {
return err
}
}
}
cmd.end()
return nil
} | go | func (cmd *baseCommand) setWrite(policy *WritePolicy, operation OperationType, key *Key, bins []*Bin, binMap BinMap) error {
cmd.begin()
fieldCount, err := cmd.estimateKeySize(key, policy.SendKey)
if err != nil {
return err
}
if binMap == nil {
for i := range bins {
if err := cmd.estimateOperationSizeForBin(bins[i]); err != nil {
return err
}
}
} else {
for name, value := range binMap {
if err := cmd.estimateOperationSizeForBinNameAndValue(name, value); err != nil {
return err
}
}
}
if err := cmd.sizeBuffer(); err != nil {
return err
}
if binMap == nil {
cmd.writeHeaderWithPolicy(policy, 0, _INFO2_WRITE, fieldCount, len(bins))
} else {
cmd.writeHeaderWithPolicy(policy, 0, _INFO2_WRITE, fieldCount, len(binMap))
}
cmd.writeKey(key, policy.SendKey)
if binMap == nil {
for i := range bins {
if err := cmd.writeOperationForBin(bins[i], operation); err != nil {
return err
}
}
} else {
for name, value := range binMap {
if err := cmd.writeOperationForBinNameAndValue(name, value, operation); err != nil {
return err
}
}
}
cmd.end()
return nil
} | [
"func",
"(",
"cmd",
"*",
"baseCommand",
")",
"setWrite",
"(",
"policy",
"*",
"WritePolicy",
",",
"operation",
"OperationType",
",",
"key",
"*",
"Key",
",",
"bins",
"[",
"]",
"*",
"Bin",
",",
"binMap",
"BinMap",
")",
"error",
"{",
"cmd",
".",
"begin",
"(",
")",
"\n",
"fieldCount",
",",
"err",
":=",
"cmd",
".",
"estimateKeySize",
"(",
"key",
",",
"policy",
".",
"SendKey",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"binMap",
"==",
"nil",
"{",
"for",
"i",
":=",
"range",
"bins",
"{",
"if",
"err",
":=",
"cmd",
".",
"estimateOperationSizeForBin",
"(",
"bins",
"[",
"i",
"]",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"else",
"{",
"for",
"name",
",",
"value",
":=",
"range",
"binMap",
"{",
"if",
"err",
":=",
"cmd",
".",
"estimateOperationSizeForBinNameAndValue",
"(",
"name",
",",
"value",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"cmd",
".",
"sizeBuffer",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"binMap",
"==",
"nil",
"{",
"cmd",
".",
"writeHeaderWithPolicy",
"(",
"policy",
",",
"0",
",",
"_INFO2_WRITE",
",",
"fieldCount",
",",
"len",
"(",
"bins",
")",
")",
"\n",
"}",
"else",
"{",
"cmd",
".",
"writeHeaderWithPolicy",
"(",
"policy",
",",
"0",
",",
"_INFO2_WRITE",
",",
"fieldCount",
",",
"len",
"(",
"binMap",
")",
")",
"\n",
"}",
"\n\n",
"cmd",
".",
"writeKey",
"(",
"key",
",",
"policy",
".",
"SendKey",
")",
"\n\n",
"if",
"binMap",
"==",
"nil",
"{",
"for",
"i",
":=",
"range",
"bins",
"{",
"if",
"err",
":=",
"cmd",
".",
"writeOperationForBin",
"(",
"bins",
"[",
"i",
"]",
",",
"operation",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"else",
"{",
"for",
"name",
",",
"value",
":=",
"range",
"binMap",
"{",
"if",
"err",
":=",
"cmd",
".",
"writeOperationForBinNameAndValue",
"(",
"name",
",",
"value",
",",
"operation",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"cmd",
".",
"end",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Writes the command for write operations | [
"Writes",
"the",
"command",
"for",
"write",
"operations"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/command.go#L116-L166 |
9,987 | aerospike/aerospike-client-go | command.go | setDelete | func (cmd *baseCommand) setDelete(policy *WritePolicy, key *Key) error {
cmd.begin()
fieldCount, err := cmd.estimateKeySize(key, false)
if err != nil {
return err
}
if err := cmd.sizeBuffer(); err != nil {
return err
}
cmd.writeHeaderWithPolicy(policy, 0, _INFO2_WRITE|_INFO2_DELETE, fieldCount, 0)
cmd.writeKey(key, false)
cmd.end()
return nil
} | go | func (cmd *baseCommand) setDelete(policy *WritePolicy, key *Key) error {
cmd.begin()
fieldCount, err := cmd.estimateKeySize(key, false)
if err != nil {
return err
}
if err := cmd.sizeBuffer(); err != nil {
return err
}
cmd.writeHeaderWithPolicy(policy, 0, _INFO2_WRITE|_INFO2_DELETE, fieldCount, 0)
cmd.writeKey(key, false)
cmd.end()
return nil
} | [
"func",
"(",
"cmd",
"*",
"baseCommand",
")",
"setDelete",
"(",
"policy",
"*",
"WritePolicy",
",",
"key",
"*",
"Key",
")",
"error",
"{",
"cmd",
".",
"begin",
"(",
")",
"\n",
"fieldCount",
",",
"err",
":=",
"cmd",
".",
"estimateKeySize",
"(",
"key",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
":=",
"cmd",
".",
"sizeBuffer",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"cmd",
".",
"writeHeaderWithPolicy",
"(",
"policy",
",",
"0",
",",
"_INFO2_WRITE",
"|",
"_INFO2_DELETE",
",",
"fieldCount",
",",
"0",
")",
"\n",
"cmd",
".",
"writeKey",
"(",
"key",
",",
"false",
")",
"\n",
"cmd",
".",
"end",
"(",
")",
"\n",
"return",
"nil",
"\n\n",
"}"
]
| // Writes the command for delete operations | [
"Writes",
"the",
"command",
"for",
"delete",
"operations"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/command.go#L169-L183 |
9,988 | aerospike/aerospike-client-go | command.go | setTouch | func (cmd *baseCommand) setTouch(policy *WritePolicy, key *Key) error {
cmd.begin()
fieldCount, err := cmd.estimateKeySize(key, policy.SendKey)
if err != nil {
return err
}
cmd.estimateOperationSize()
if err := cmd.sizeBuffer(); err != nil {
return err
}
cmd.writeHeaderWithPolicy(policy, 0, _INFO2_WRITE, fieldCount, 1)
cmd.writeKey(key, policy.SendKey)
cmd.writeOperationForOperationType(_TOUCH)
cmd.end()
return nil
} | go | func (cmd *baseCommand) setTouch(policy *WritePolicy, key *Key) error {
cmd.begin()
fieldCount, err := cmd.estimateKeySize(key, policy.SendKey)
if err != nil {
return err
}
cmd.estimateOperationSize()
if err := cmd.sizeBuffer(); err != nil {
return err
}
cmd.writeHeaderWithPolicy(policy, 0, _INFO2_WRITE, fieldCount, 1)
cmd.writeKey(key, policy.SendKey)
cmd.writeOperationForOperationType(_TOUCH)
cmd.end()
return nil
} | [
"func",
"(",
"cmd",
"*",
"baseCommand",
")",
"setTouch",
"(",
"policy",
"*",
"WritePolicy",
",",
"key",
"*",
"Key",
")",
"error",
"{",
"cmd",
".",
"begin",
"(",
")",
"\n",
"fieldCount",
",",
"err",
":=",
"cmd",
".",
"estimateKeySize",
"(",
"key",
",",
"policy",
".",
"SendKey",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"cmd",
".",
"estimateOperationSize",
"(",
")",
"\n",
"if",
"err",
":=",
"cmd",
".",
"sizeBuffer",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"cmd",
".",
"writeHeaderWithPolicy",
"(",
"policy",
",",
"0",
",",
"_INFO2_WRITE",
",",
"fieldCount",
",",
"1",
")",
"\n",
"cmd",
".",
"writeKey",
"(",
"key",
",",
"policy",
".",
"SendKey",
")",
"\n",
"cmd",
".",
"writeOperationForOperationType",
"(",
"_TOUCH",
")",
"\n",
"cmd",
".",
"end",
"(",
")",
"\n",
"return",
"nil",
"\n\n",
"}"
]
| // Writes the command for touch operations | [
"Writes",
"the",
"command",
"for",
"touch",
"operations"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/command.go#L186-L203 |
9,989 | aerospike/aerospike-client-go | command.go | setExists | func (cmd *baseCommand) setExists(policy *BasePolicy, key *Key) error {
cmd.begin()
fieldCount, err := cmd.estimateKeySize(key, false)
if err != nil {
return err
}
if err := cmd.sizeBuffer(); err != nil {
return err
}
cmd.writeHeader(policy, _INFO1_READ|_INFO1_NOBINDATA, 0, fieldCount, 0)
cmd.writeKey(key, false)
cmd.end()
return nil
} | go | func (cmd *baseCommand) setExists(policy *BasePolicy, key *Key) error {
cmd.begin()
fieldCount, err := cmd.estimateKeySize(key, false)
if err != nil {
return err
}
if err := cmd.sizeBuffer(); err != nil {
return err
}
cmd.writeHeader(policy, _INFO1_READ|_INFO1_NOBINDATA, 0, fieldCount, 0)
cmd.writeKey(key, false)
cmd.end()
return nil
} | [
"func",
"(",
"cmd",
"*",
"baseCommand",
")",
"setExists",
"(",
"policy",
"*",
"BasePolicy",
",",
"key",
"*",
"Key",
")",
"error",
"{",
"cmd",
".",
"begin",
"(",
")",
"\n",
"fieldCount",
",",
"err",
":=",
"cmd",
".",
"estimateKeySize",
"(",
"key",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
":=",
"cmd",
".",
"sizeBuffer",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"cmd",
".",
"writeHeader",
"(",
"policy",
",",
"_INFO1_READ",
"|",
"_INFO1_NOBINDATA",
",",
"0",
",",
"fieldCount",
",",
"0",
")",
"\n",
"cmd",
".",
"writeKey",
"(",
"key",
",",
"false",
")",
"\n",
"cmd",
".",
"end",
"(",
")",
"\n",
"return",
"nil",
"\n\n",
"}"
]
| // Writes the command for exist operations | [
"Writes",
"the",
"command",
"for",
"exist",
"operations"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/command.go#L206-L220 |
9,990 | aerospike/aerospike-client-go | command.go | setReadHeader | func (cmd *baseCommand) setReadHeader(policy *BasePolicy, key *Key) error {
cmd.begin()
fieldCount, err := cmd.estimateKeySize(key, false)
if err != nil {
return err
}
cmd.estimateOperationSizeForBinName("")
if err := cmd.sizeBuffer(); err != nil {
return err
}
cmd.writeHeader(policy, _INFO1_READ|_INFO1_NOBINDATA, 0, fieldCount, 1)
cmd.writeKey(key, false)
cmd.writeOperationForBinName("", _READ)
cmd.end()
return nil
} | go | func (cmd *baseCommand) setReadHeader(policy *BasePolicy, key *Key) error {
cmd.begin()
fieldCount, err := cmd.estimateKeySize(key, false)
if err != nil {
return err
}
cmd.estimateOperationSizeForBinName("")
if err := cmd.sizeBuffer(); err != nil {
return err
}
cmd.writeHeader(policy, _INFO1_READ|_INFO1_NOBINDATA, 0, fieldCount, 1)
cmd.writeKey(key, false)
cmd.writeOperationForBinName("", _READ)
cmd.end()
return nil
} | [
"func",
"(",
"cmd",
"*",
"baseCommand",
")",
"setReadHeader",
"(",
"policy",
"*",
"BasePolicy",
",",
"key",
"*",
"Key",
")",
"error",
"{",
"cmd",
".",
"begin",
"(",
")",
"\n",
"fieldCount",
",",
"err",
":=",
"cmd",
".",
"estimateKeySize",
"(",
"key",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"cmd",
".",
"estimateOperationSizeForBinName",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
":=",
"cmd",
".",
"sizeBuffer",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"cmd",
".",
"writeHeader",
"(",
"policy",
",",
"_INFO1_READ",
"|",
"_INFO1_NOBINDATA",
",",
"0",
",",
"fieldCount",
",",
"1",
")",
"\n\n",
"cmd",
".",
"writeKey",
"(",
"key",
",",
"false",
")",
"\n",
"cmd",
".",
"writeOperationForBinName",
"(",
"\"",
"\"",
",",
"_READ",
")",
"\n",
"cmd",
".",
"end",
"(",
")",
"\n",
"return",
"nil",
"\n\n",
"}"
]
| // Writes the command for getting metadata operations | [
"Writes",
"the",
"command",
"for",
"getting",
"metadata",
"operations"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/command.go#L269-L287 |
9,991 | aerospike/aerospike-client-go | command.go | setOperate | func (cmd *baseCommand) setOperate(policy *WritePolicy, key *Key, operations []*Operation) (bool, error) {
if len(operations) == 0 {
return false, NewAerospikeError(PARAMETER_ERROR, "No operations were passed.")
}
cmd.begin()
fieldCount := 0
readAttr := 0
writeAttr := 0
hasWrite := false
readBin := false
readHeader := false
RespondPerEachOp := policy.RespondPerEachOp
for i := range operations {
switch operations[i].opType {
case _MAP_READ:
// Map operations require RespondPerEachOp to be true.
RespondPerEachOp = true
// Fall through to read.
fallthrough
case _READ, _CDT_READ:
if !operations[i].headerOnly {
readAttr |= _INFO1_READ
// Read all bins if no bin is specified.
if operations[i].binName == "" {
readAttr |= _INFO1_GET_ALL
}
readBin = true
} else {
readAttr |= _INFO1_READ
readHeader = true
}
case _MAP_MODIFY:
// Map operations require RespondPerEachOp to be true.
RespondPerEachOp = true
// Fall through to default.
fallthrough
default:
writeAttr = _INFO2_WRITE
hasWrite = true
}
cmd.estimateOperationSizeForOperation(operations[i])
}
ksz, err := cmd.estimateKeySize(key, policy.SendKey && hasWrite)
if err != nil {
return hasWrite, err
}
fieldCount += ksz
if err := cmd.sizeBuffer(); err != nil {
return hasWrite, err
}
if readHeader && !readBin {
readAttr |= _INFO1_NOBINDATA
}
if RespondPerEachOp {
writeAttr |= _INFO2_RESPOND_ALL_OPS
}
if writeAttr != 0 {
cmd.writeHeaderWithPolicy(policy, readAttr, writeAttr, fieldCount, len(operations))
} else {
cmd.writeHeader(&policy.BasePolicy, readAttr, writeAttr, fieldCount, len(operations))
}
cmd.writeKey(key, policy.SendKey && hasWrite)
for _, operation := range operations {
if err := cmd.writeOperationForOperation(operation); err != nil {
return hasWrite, err
}
}
cmd.end()
return hasWrite, nil
} | go | func (cmd *baseCommand) setOperate(policy *WritePolicy, key *Key, operations []*Operation) (bool, error) {
if len(operations) == 0 {
return false, NewAerospikeError(PARAMETER_ERROR, "No operations were passed.")
}
cmd.begin()
fieldCount := 0
readAttr := 0
writeAttr := 0
hasWrite := false
readBin := false
readHeader := false
RespondPerEachOp := policy.RespondPerEachOp
for i := range operations {
switch operations[i].opType {
case _MAP_READ:
// Map operations require RespondPerEachOp to be true.
RespondPerEachOp = true
// Fall through to read.
fallthrough
case _READ, _CDT_READ:
if !operations[i].headerOnly {
readAttr |= _INFO1_READ
// Read all bins if no bin is specified.
if operations[i].binName == "" {
readAttr |= _INFO1_GET_ALL
}
readBin = true
} else {
readAttr |= _INFO1_READ
readHeader = true
}
case _MAP_MODIFY:
// Map operations require RespondPerEachOp to be true.
RespondPerEachOp = true
// Fall through to default.
fallthrough
default:
writeAttr = _INFO2_WRITE
hasWrite = true
}
cmd.estimateOperationSizeForOperation(operations[i])
}
ksz, err := cmd.estimateKeySize(key, policy.SendKey && hasWrite)
if err != nil {
return hasWrite, err
}
fieldCount += ksz
if err := cmd.sizeBuffer(); err != nil {
return hasWrite, err
}
if readHeader && !readBin {
readAttr |= _INFO1_NOBINDATA
}
if RespondPerEachOp {
writeAttr |= _INFO2_RESPOND_ALL_OPS
}
if writeAttr != 0 {
cmd.writeHeaderWithPolicy(policy, readAttr, writeAttr, fieldCount, len(operations))
} else {
cmd.writeHeader(&policy.BasePolicy, readAttr, writeAttr, fieldCount, len(operations))
}
cmd.writeKey(key, policy.SendKey && hasWrite)
for _, operation := range operations {
if err := cmd.writeOperationForOperation(operation); err != nil {
return hasWrite, err
}
}
cmd.end()
return hasWrite, nil
} | [
"func",
"(",
"cmd",
"*",
"baseCommand",
")",
"setOperate",
"(",
"policy",
"*",
"WritePolicy",
",",
"key",
"*",
"Key",
",",
"operations",
"[",
"]",
"*",
"Operation",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"len",
"(",
"operations",
")",
"==",
"0",
"{",
"return",
"false",
",",
"NewAerospikeError",
"(",
"PARAMETER_ERROR",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"cmd",
".",
"begin",
"(",
")",
"\n",
"fieldCount",
":=",
"0",
"\n",
"readAttr",
":=",
"0",
"\n",
"writeAttr",
":=",
"0",
"\n",
"hasWrite",
":=",
"false",
"\n",
"readBin",
":=",
"false",
"\n",
"readHeader",
":=",
"false",
"\n",
"RespondPerEachOp",
":=",
"policy",
".",
"RespondPerEachOp",
"\n\n",
"for",
"i",
":=",
"range",
"operations",
"{",
"switch",
"operations",
"[",
"i",
"]",
".",
"opType",
"{",
"case",
"_MAP_READ",
":",
"// Map operations require RespondPerEachOp to be true.",
"RespondPerEachOp",
"=",
"true",
"\n",
"// Fall through to read.",
"fallthrough",
"\n",
"case",
"_READ",
",",
"_CDT_READ",
":",
"if",
"!",
"operations",
"[",
"i",
"]",
".",
"headerOnly",
"{",
"readAttr",
"|=",
"_INFO1_READ",
"\n\n",
"// Read all bins if no bin is specified.",
"if",
"operations",
"[",
"i",
"]",
".",
"binName",
"==",
"\"",
"\"",
"{",
"readAttr",
"|=",
"_INFO1_GET_ALL",
"\n",
"}",
"\n",
"readBin",
"=",
"true",
"\n",
"}",
"else",
"{",
"readAttr",
"|=",
"_INFO1_READ",
"\n",
"readHeader",
"=",
"true",
"\n",
"}",
"\n",
"case",
"_MAP_MODIFY",
":",
"// Map operations require RespondPerEachOp to be true.",
"RespondPerEachOp",
"=",
"true",
"\n",
"// Fall through to default.",
"fallthrough",
"\n",
"default",
":",
"writeAttr",
"=",
"_INFO2_WRITE",
"\n",
"hasWrite",
"=",
"true",
"\n",
"}",
"\n",
"cmd",
".",
"estimateOperationSizeForOperation",
"(",
"operations",
"[",
"i",
"]",
")",
"\n",
"}",
"\n\n",
"ksz",
",",
"err",
":=",
"cmd",
".",
"estimateKeySize",
"(",
"key",
",",
"policy",
".",
"SendKey",
"&&",
"hasWrite",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"hasWrite",
",",
"err",
"\n",
"}",
"\n",
"fieldCount",
"+=",
"ksz",
"\n\n",
"if",
"err",
":=",
"cmd",
".",
"sizeBuffer",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"hasWrite",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"readHeader",
"&&",
"!",
"readBin",
"{",
"readAttr",
"|=",
"_INFO1_NOBINDATA",
"\n",
"}",
"\n\n",
"if",
"RespondPerEachOp",
"{",
"writeAttr",
"|=",
"_INFO2_RESPOND_ALL_OPS",
"\n",
"}",
"\n\n",
"if",
"writeAttr",
"!=",
"0",
"{",
"cmd",
".",
"writeHeaderWithPolicy",
"(",
"policy",
",",
"readAttr",
",",
"writeAttr",
",",
"fieldCount",
",",
"len",
"(",
"operations",
")",
")",
"\n",
"}",
"else",
"{",
"cmd",
".",
"writeHeader",
"(",
"&",
"policy",
".",
"BasePolicy",
",",
"readAttr",
",",
"writeAttr",
",",
"fieldCount",
",",
"len",
"(",
"operations",
")",
")",
"\n",
"}",
"\n",
"cmd",
".",
"writeKey",
"(",
"key",
",",
"policy",
".",
"SendKey",
"&&",
"hasWrite",
")",
"\n\n",
"for",
"_",
",",
"operation",
":=",
"range",
"operations",
"{",
"if",
"err",
":=",
"cmd",
".",
"writeOperationForOperation",
"(",
"operation",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"hasWrite",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"cmd",
".",
"end",
"(",
")",
"\n\n",
"return",
"hasWrite",
",",
"nil",
"\n",
"}"
]
| // Implements different command operations | [
"Implements",
"different",
"command",
"operations"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/command.go#L290-L370 |
9,992 | aerospike/aerospike-client-go | command.go | writeHeader | func (cmd *baseCommand) writeHeader(policy *BasePolicy, readAttr int, writeAttr int, fieldCount int, operationCount int) {
infoAttr := 0
if policy.LinearizeRead {
infoAttr |= _INFO3_LINEARIZE_READ
}
if policy.ConsistencyLevel == CONSISTENCY_ALL {
readAttr |= _INFO1_CONSISTENCY_ALL
}
// Write all header data except total size which must be written last.
cmd.dataBuffer[8] = _MSG_REMAINING_HEADER_SIZE // Message header length.
cmd.dataBuffer[9] = byte(readAttr)
cmd.dataBuffer[10] = byte(writeAttr)
cmd.dataBuffer[11] = byte(infoAttr)
for i := 12; i < 26; i++ {
cmd.dataBuffer[i] = 0
}
cmd.dataOffset = 26
cmd.WriteInt16(int16(fieldCount))
cmd.WriteInt16(int16(operationCount))
cmd.dataOffset = int(_MSG_TOTAL_HEADER_SIZE)
} | go | func (cmd *baseCommand) writeHeader(policy *BasePolicy, readAttr int, writeAttr int, fieldCount int, operationCount int) {
infoAttr := 0
if policy.LinearizeRead {
infoAttr |= _INFO3_LINEARIZE_READ
}
if policy.ConsistencyLevel == CONSISTENCY_ALL {
readAttr |= _INFO1_CONSISTENCY_ALL
}
// Write all header data except total size which must be written last.
cmd.dataBuffer[8] = _MSG_REMAINING_HEADER_SIZE // Message header length.
cmd.dataBuffer[9] = byte(readAttr)
cmd.dataBuffer[10] = byte(writeAttr)
cmd.dataBuffer[11] = byte(infoAttr)
for i := 12; i < 26; i++ {
cmd.dataBuffer[i] = 0
}
cmd.dataOffset = 26
cmd.WriteInt16(int16(fieldCount))
cmd.WriteInt16(int16(operationCount))
cmd.dataOffset = int(_MSG_TOTAL_HEADER_SIZE)
} | [
"func",
"(",
"cmd",
"*",
"baseCommand",
")",
"writeHeader",
"(",
"policy",
"*",
"BasePolicy",
",",
"readAttr",
"int",
",",
"writeAttr",
"int",
",",
"fieldCount",
"int",
",",
"operationCount",
"int",
")",
"{",
"infoAttr",
":=",
"0",
"\n",
"if",
"policy",
".",
"LinearizeRead",
"{",
"infoAttr",
"|=",
"_INFO3_LINEARIZE_READ",
"\n",
"}",
"\n\n",
"if",
"policy",
".",
"ConsistencyLevel",
"==",
"CONSISTENCY_ALL",
"{",
"readAttr",
"|=",
"_INFO1_CONSISTENCY_ALL",
"\n",
"}",
"\n\n",
"// Write all header data except total size which must be written last.",
"cmd",
".",
"dataBuffer",
"[",
"8",
"]",
"=",
"_MSG_REMAINING_HEADER_SIZE",
"// Message header length.",
"\n",
"cmd",
".",
"dataBuffer",
"[",
"9",
"]",
"=",
"byte",
"(",
"readAttr",
")",
"\n",
"cmd",
".",
"dataBuffer",
"[",
"10",
"]",
"=",
"byte",
"(",
"writeAttr",
")",
"\n",
"cmd",
".",
"dataBuffer",
"[",
"11",
"]",
"=",
"byte",
"(",
"infoAttr",
")",
"\n\n",
"for",
"i",
":=",
"12",
";",
"i",
"<",
"26",
";",
"i",
"++",
"{",
"cmd",
".",
"dataBuffer",
"[",
"i",
"]",
"=",
"0",
"\n",
"}",
"\n",
"cmd",
".",
"dataOffset",
"=",
"26",
"\n",
"cmd",
".",
"WriteInt16",
"(",
"int16",
"(",
"fieldCount",
")",
")",
"\n",
"cmd",
".",
"WriteInt16",
"(",
"int16",
"(",
"operationCount",
")",
")",
"\n",
"cmd",
".",
"dataOffset",
"=",
"int",
"(",
"_MSG_TOTAL_HEADER_SIZE",
")",
"\n",
"}"
]
| // Generic header write. | [
"Generic",
"header",
"write",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/command.go#L1079-L1102 |
9,993 | aerospike/aerospike-client-go | command.go | writeHeaderWithPolicy | func (cmd *baseCommand) writeHeaderWithPolicy(policy *WritePolicy, readAttr int, writeAttr int, fieldCount int, operationCount int) {
// Set flags.
generation := uint32(0)
infoAttr := 0
switch policy.RecordExistsAction {
case UPDATE:
case UPDATE_ONLY:
infoAttr |= _INFO3_UPDATE_ONLY
case REPLACE:
infoAttr |= _INFO3_CREATE_OR_REPLACE
case REPLACE_ONLY:
infoAttr |= _INFO3_REPLACE_ONLY
case CREATE_ONLY:
writeAttr |= _INFO2_CREATE_ONLY
}
switch policy.GenerationPolicy {
case NONE:
case EXPECT_GEN_EQUAL:
generation = policy.Generation
writeAttr |= _INFO2_GENERATION
case EXPECT_GEN_GT:
generation = policy.Generation
writeAttr |= _INFO2_GENERATION_GT
}
if policy.CommitLevel == COMMIT_MASTER {
infoAttr |= _INFO3_COMMIT_MASTER
}
if policy.LinearizeRead {
infoAttr |= _INFO3_LINEARIZE_READ
}
if policy.ConsistencyLevel == CONSISTENCY_ALL {
readAttr |= _INFO1_CONSISTENCY_ALL
}
if policy.DurableDelete {
writeAttr |= _INFO2_DURABLE_DELETE
}
// Write all header data except total size which must be written last.
cmd.dataBuffer[8] = _MSG_REMAINING_HEADER_SIZE // Message header length.
cmd.dataBuffer[9] = byte(readAttr)
cmd.dataBuffer[10] = byte(writeAttr)
cmd.dataBuffer[11] = byte(infoAttr)
cmd.dataBuffer[12] = 0 // unused
cmd.dataBuffer[13] = 0 // clear the result code
cmd.dataOffset = 14
cmd.WriteUint32(generation)
cmd.dataOffset = 18
cmd.WriteUint32(policy.Expiration)
// Initialize timeout. It will be written later.
cmd.dataBuffer[22] = 0
cmd.dataBuffer[23] = 0
cmd.dataBuffer[24] = 0
cmd.dataBuffer[25] = 0
cmd.dataOffset = 26
cmd.WriteInt16(int16(fieldCount))
cmd.WriteInt16(int16(operationCount))
cmd.dataOffset = int(_MSG_TOTAL_HEADER_SIZE)
} | go | func (cmd *baseCommand) writeHeaderWithPolicy(policy *WritePolicy, readAttr int, writeAttr int, fieldCount int, operationCount int) {
// Set flags.
generation := uint32(0)
infoAttr := 0
switch policy.RecordExistsAction {
case UPDATE:
case UPDATE_ONLY:
infoAttr |= _INFO3_UPDATE_ONLY
case REPLACE:
infoAttr |= _INFO3_CREATE_OR_REPLACE
case REPLACE_ONLY:
infoAttr |= _INFO3_REPLACE_ONLY
case CREATE_ONLY:
writeAttr |= _INFO2_CREATE_ONLY
}
switch policy.GenerationPolicy {
case NONE:
case EXPECT_GEN_EQUAL:
generation = policy.Generation
writeAttr |= _INFO2_GENERATION
case EXPECT_GEN_GT:
generation = policy.Generation
writeAttr |= _INFO2_GENERATION_GT
}
if policy.CommitLevel == COMMIT_MASTER {
infoAttr |= _INFO3_COMMIT_MASTER
}
if policy.LinearizeRead {
infoAttr |= _INFO3_LINEARIZE_READ
}
if policy.ConsistencyLevel == CONSISTENCY_ALL {
readAttr |= _INFO1_CONSISTENCY_ALL
}
if policy.DurableDelete {
writeAttr |= _INFO2_DURABLE_DELETE
}
// Write all header data except total size which must be written last.
cmd.dataBuffer[8] = _MSG_REMAINING_HEADER_SIZE // Message header length.
cmd.dataBuffer[9] = byte(readAttr)
cmd.dataBuffer[10] = byte(writeAttr)
cmd.dataBuffer[11] = byte(infoAttr)
cmd.dataBuffer[12] = 0 // unused
cmd.dataBuffer[13] = 0 // clear the result code
cmd.dataOffset = 14
cmd.WriteUint32(generation)
cmd.dataOffset = 18
cmd.WriteUint32(policy.Expiration)
// Initialize timeout. It will be written later.
cmd.dataBuffer[22] = 0
cmd.dataBuffer[23] = 0
cmd.dataBuffer[24] = 0
cmd.dataBuffer[25] = 0
cmd.dataOffset = 26
cmd.WriteInt16(int16(fieldCount))
cmd.WriteInt16(int16(operationCount))
cmd.dataOffset = int(_MSG_TOTAL_HEADER_SIZE)
} | [
"func",
"(",
"cmd",
"*",
"baseCommand",
")",
"writeHeaderWithPolicy",
"(",
"policy",
"*",
"WritePolicy",
",",
"readAttr",
"int",
",",
"writeAttr",
"int",
",",
"fieldCount",
"int",
",",
"operationCount",
"int",
")",
"{",
"// Set flags.",
"generation",
":=",
"uint32",
"(",
"0",
")",
"\n",
"infoAttr",
":=",
"0",
"\n\n",
"switch",
"policy",
".",
"RecordExistsAction",
"{",
"case",
"UPDATE",
":",
"case",
"UPDATE_ONLY",
":",
"infoAttr",
"|=",
"_INFO3_UPDATE_ONLY",
"\n",
"case",
"REPLACE",
":",
"infoAttr",
"|=",
"_INFO3_CREATE_OR_REPLACE",
"\n",
"case",
"REPLACE_ONLY",
":",
"infoAttr",
"|=",
"_INFO3_REPLACE_ONLY",
"\n",
"case",
"CREATE_ONLY",
":",
"writeAttr",
"|=",
"_INFO2_CREATE_ONLY",
"\n",
"}",
"\n\n",
"switch",
"policy",
".",
"GenerationPolicy",
"{",
"case",
"NONE",
":",
"case",
"EXPECT_GEN_EQUAL",
":",
"generation",
"=",
"policy",
".",
"Generation",
"\n",
"writeAttr",
"|=",
"_INFO2_GENERATION",
"\n",
"case",
"EXPECT_GEN_GT",
":",
"generation",
"=",
"policy",
".",
"Generation",
"\n",
"writeAttr",
"|=",
"_INFO2_GENERATION_GT",
"\n",
"}",
"\n\n",
"if",
"policy",
".",
"CommitLevel",
"==",
"COMMIT_MASTER",
"{",
"infoAttr",
"|=",
"_INFO3_COMMIT_MASTER",
"\n",
"}",
"\n\n",
"if",
"policy",
".",
"LinearizeRead",
"{",
"infoAttr",
"|=",
"_INFO3_LINEARIZE_READ",
"\n",
"}",
"\n\n",
"if",
"policy",
".",
"ConsistencyLevel",
"==",
"CONSISTENCY_ALL",
"{",
"readAttr",
"|=",
"_INFO1_CONSISTENCY_ALL",
"\n",
"}",
"\n\n",
"if",
"policy",
".",
"DurableDelete",
"{",
"writeAttr",
"|=",
"_INFO2_DURABLE_DELETE",
"\n",
"}",
"\n\n",
"// Write all header data except total size which must be written last.",
"cmd",
".",
"dataBuffer",
"[",
"8",
"]",
"=",
"_MSG_REMAINING_HEADER_SIZE",
"// Message header length.",
"\n",
"cmd",
".",
"dataBuffer",
"[",
"9",
"]",
"=",
"byte",
"(",
"readAttr",
")",
"\n",
"cmd",
".",
"dataBuffer",
"[",
"10",
"]",
"=",
"byte",
"(",
"writeAttr",
")",
"\n",
"cmd",
".",
"dataBuffer",
"[",
"11",
"]",
"=",
"byte",
"(",
"infoAttr",
")",
"\n",
"cmd",
".",
"dataBuffer",
"[",
"12",
"]",
"=",
"0",
"// unused",
"\n",
"cmd",
".",
"dataBuffer",
"[",
"13",
"]",
"=",
"0",
"// clear the result code",
"\n",
"cmd",
".",
"dataOffset",
"=",
"14",
"\n",
"cmd",
".",
"WriteUint32",
"(",
"generation",
")",
"\n",
"cmd",
".",
"dataOffset",
"=",
"18",
"\n",
"cmd",
".",
"WriteUint32",
"(",
"policy",
".",
"Expiration",
")",
"\n\n",
"// Initialize timeout. It will be written later.",
"cmd",
".",
"dataBuffer",
"[",
"22",
"]",
"=",
"0",
"\n",
"cmd",
".",
"dataBuffer",
"[",
"23",
"]",
"=",
"0",
"\n",
"cmd",
".",
"dataBuffer",
"[",
"24",
"]",
"=",
"0",
"\n",
"cmd",
".",
"dataBuffer",
"[",
"25",
"]",
"=",
"0",
"\n\n",
"cmd",
".",
"dataOffset",
"=",
"26",
"\n",
"cmd",
".",
"WriteInt16",
"(",
"int16",
"(",
"fieldCount",
")",
")",
"\n",
"cmd",
".",
"WriteInt16",
"(",
"int16",
"(",
"operationCount",
")",
")",
"\n",
"cmd",
".",
"dataOffset",
"=",
"int",
"(",
"_MSG_TOTAL_HEADER_SIZE",
")",
"\n",
"}"
]
| // Header write for write operations. | [
"Header",
"write",
"for",
"write",
"operations",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/command.go#L1105-L1170 |
9,994 | aerospike/aerospike-client-go | record.go | String | func (rc *Record) String() string {
return fmt.Sprintf("%s %v", rc.Key, rc.Bins)
} | go | func (rc *Record) String() string {
return fmt.Sprintf("%s %v", rc.Key, rc.Bins)
} | [
"func",
"(",
"rc",
"*",
"Record",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"rc",
".",
"Key",
",",
"rc",
".",
"Bins",
")",
"\n",
"}"
]
| // String implements the Stringer interface.
// Returns string representation of record. | [
"String",
"implements",
"the",
"Stringer",
"interface",
".",
"Returns",
"string",
"representation",
"of",
"record",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/record.go#L59-L61 |
9,995 | aerospike/aerospike-client-go | pkg/bcrypt/cipher.go | streamtoword | func streamtoword(data []byte, off int) (uint, int) {
var word uint
for i := 0; i < 4; i++ {
word = (word << 8) | uint(data[off]&0xff)
off = (off + 1) % len(data)
}
return word, off
} | go | func streamtoword(data []byte, off int) (uint, int) {
var word uint
for i := 0; i < 4; i++ {
word = (word << 8) | uint(data[off]&0xff)
off = (off + 1) % len(data)
}
return word, off
} | [
"func",
"streamtoword",
"(",
"data",
"[",
"]",
"byte",
",",
"off",
"int",
")",
"(",
"uint",
",",
"int",
")",
"{",
"var",
"word",
"uint",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"4",
";",
"i",
"++",
"{",
"word",
"=",
"(",
"word",
"<<",
"8",
")",
"|",
"uint",
"(",
"data",
"[",
"off",
"]",
"&",
"0xff",
")",
"\n",
"off",
"=",
"(",
"off",
"+",
"1",
")",
"%",
"len",
"(",
"data",
")",
"\n",
"}",
"\n\n",
"return",
"word",
",",
"off",
"\n",
"}"
]
| /**
* Cycically extract a word of key material
* @param data the string to extract the data from
* @param off the current offset into the data
* @return the next word of material from data and the next offset into the data
*/ | [
"Cycically",
"extract",
"a",
"word",
"of",
"key",
"material"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/pkg/bcrypt/cipher.go#L301-L309 |
9,996 | aerospike/aerospike-client-go | pkg/bcrypt/cipher.go | key | func (c *cipher) key(key []byte) {
var word uint
off := 0
lr := []uint{0, 0}
plen := len(c.P)
slen := len(c.S)
for i := 0; i < plen; i++ {
word, off = streamtoword(key, off)
c.P[i] = c.P[i] ^ word
}
for i := 0; i < plen; i += 2 {
c.encipher(lr, 0)
c.P[i] = lr[0]
c.P[i+1] = lr[1]
}
for i := 0; i < slen; i += 2 {
c.encipher(lr, 0)
c.S[i] = lr[0]
c.S[i+1] = lr[1]
}
} | go | func (c *cipher) key(key []byte) {
var word uint
off := 0
lr := []uint{0, 0}
plen := len(c.P)
slen := len(c.S)
for i := 0; i < plen; i++ {
word, off = streamtoword(key, off)
c.P[i] = c.P[i] ^ word
}
for i := 0; i < plen; i += 2 {
c.encipher(lr, 0)
c.P[i] = lr[0]
c.P[i+1] = lr[1]
}
for i := 0; i < slen; i += 2 {
c.encipher(lr, 0)
c.S[i] = lr[0]
c.S[i+1] = lr[1]
}
} | [
"func",
"(",
"c",
"*",
"cipher",
")",
"key",
"(",
"key",
"[",
"]",
"byte",
")",
"{",
"var",
"word",
"uint",
"\n",
"off",
":=",
"0",
"\n",
"lr",
":=",
"[",
"]",
"uint",
"{",
"0",
",",
"0",
"}",
"\n",
"plen",
":=",
"len",
"(",
"c",
".",
"P",
")",
"\n",
"slen",
":=",
"len",
"(",
"c",
".",
"S",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"plen",
";",
"i",
"++",
"{",
"word",
",",
"off",
"=",
"streamtoword",
"(",
"key",
",",
"off",
")",
"\n",
"c",
".",
"P",
"[",
"i",
"]",
"=",
"c",
".",
"P",
"[",
"i",
"]",
"^",
"word",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"plen",
";",
"i",
"+=",
"2",
"{",
"c",
".",
"encipher",
"(",
"lr",
",",
"0",
")",
"\n",
"c",
".",
"P",
"[",
"i",
"]",
"=",
"lr",
"[",
"0",
"]",
"\n",
"c",
".",
"P",
"[",
"i",
"+",
"1",
"]",
"=",
"lr",
"[",
"1",
"]",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"slen",
";",
"i",
"+=",
"2",
"{",
"c",
".",
"encipher",
"(",
"lr",
",",
"0",
")",
"\n",
"c",
".",
"S",
"[",
"i",
"]",
"=",
"lr",
"[",
"0",
"]",
"\n",
"c",
".",
"S",
"[",
"i",
"+",
"1",
"]",
"=",
"lr",
"[",
"1",
"]",
"\n",
"}",
"\n",
"}"
]
| /**
* Key the Blowfish cipher
* @param key an array containing the key
*/ | [
"Key",
"the",
"Blowfish",
"cipher"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/pkg/bcrypt/cipher.go#L315-L338 |
9,997 | aerospike/aerospike-client-go | pkg/bcrypt/cipher.go | crypt_raw | func crypt_raw(password []byte, salt []byte, log_rounds uint) []byte {
c := &cipher{P: p_orig, S: s_orig, data: bf_crypt_ciphertext}
rounds := 1 << log_rounds
c.ekskey(salt, password)
for i := 0; i < rounds; i++ {
c.key(password)
c.key(salt)
}
for i := 0; i < 64; i++ {
for j := 0; j < (6 >> 1); j++ {
c.encipher(c.data[:], j<<1)
}
}
ret := make([]byte, 24)
for i := 0; i < 6; i++ {
k := i << 2
ret[k] = (byte)((c.data[i] >> 24) & 0xff)
ret[k+1] = (byte)((c.data[i] >> 16) & 0xff)
ret[k+2] = (byte)((c.data[i] >> 8) & 0xff)
ret[k+3] = (byte)(c.data[i] & 0xff)
}
return ret
} | go | func crypt_raw(password []byte, salt []byte, log_rounds uint) []byte {
c := &cipher{P: p_orig, S: s_orig, data: bf_crypt_ciphertext}
rounds := 1 << log_rounds
c.ekskey(salt, password)
for i := 0; i < rounds; i++ {
c.key(password)
c.key(salt)
}
for i := 0; i < 64; i++ {
for j := 0; j < (6 >> 1); j++ {
c.encipher(c.data[:], j<<1)
}
}
ret := make([]byte, 24)
for i := 0; i < 6; i++ {
k := i << 2
ret[k] = (byte)((c.data[i] >> 24) & 0xff)
ret[k+1] = (byte)((c.data[i] >> 16) & 0xff)
ret[k+2] = (byte)((c.data[i] >> 8) & 0xff)
ret[k+3] = (byte)(c.data[i] & 0xff)
}
return ret
} | [
"func",
"crypt_raw",
"(",
"password",
"[",
"]",
"byte",
",",
"salt",
"[",
"]",
"byte",
",",
"log_rounds",
"uint",
")",
"[",
"]",
"byte",
"{",
"c",
":=",
"&",
"cipher",
"{",
"P",
":",
"p_orig",
",",
"S",
":",
"s_orig",
",",
"data",
":",
"bf_crypt_ciphertext",
"}",
"\n\n",
"rounds",
":=",
"1",
"<<",
"log_rounds",
"\n",
"c",
".",
"ekskey",
"(",
"salt",
",",
"password",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"rounds",
";",
"i",
"++",
"{",
"c",
".",
"key",
"(",
"password",
")",
"\n",
"c",
".",
"key",
"(",
"salt",
")",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"64",
";",
"i",
"++",
"{",
"for",
"j",
":=",
"0",
";",
"j",
"<",
"(",
"6",
">>",
"1",
")",
";",
"j",
"++",
"{",
"c",
".",
"encipher",
"(",
"c",
".",
"data",
"[",
":",
"]",
",",
"j",
"<<",
"1",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"ret",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"24",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"6",
";",
"i",
"++",
"{",
"k",
":=",
"i",
"<<",
"2",
"\n",
"ret",
"[",
"k",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"c",
".",
"data",
"[",
"i",
"]",
">>",
"24",
")",
"&",
"0xff",
")",
"\n",
"ret",
"[",
"k",
"+",
"1",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"c",
".",
"data",
"[",
"i",
"]",
">>",
"16",
")",
"&",
"0xff",
")",
"\n",
"ret",
"[",
"k",
"+",
"2",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"c",
".",
"data",
"[",
"i",
"]",
">>",
"8",
")",
"&",
"0xff",
")",
"\n",
"ret",
"[",
"k",
"+",
"3",
"]",
"=",
"(",
"byte",
")",
"(",
"c",
".",
"data",
"[",
"i",
"]",
"&",
"0xff",
")",
"\n",
"}",
"\n",
"return",
"ret",
"\n",
"}"
]
| /**
* Perform the central password hashing step in the
* bcrypt scheme
* @param password the password to hash
* @param salt the binary salt to hash with the password
* @param log_rounds the binary logarithm of the number
* of rounds of hashing to apply
* @return an array containing the binary hashed password
*/ | [
"Perform",
"the",
"central",
"password",
"hashing",
"step",
"in",
"the",
"bcrypt",
"scheme"
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/pkg/bcrypt/cipher.go#L390-L415 |
9,998 | aerospike/aerospike-client-go | types/message.go | NewMessage | func NewMessage(mtype messageType, data []byte) *Message {
return &Message{
MessageHeader: MessageHeader{
Version: uint8(2),
Type: uint8(mtype),
DataLen: msgLenToBytes(int64(len(data))),
},
Data: data,
}
} | go | func NewMessage(mtype messageType, data []byte) *Message {
return &Message{
MessageHeader: MessageHeader{
Version: uint8(2),
Type: uint8(mtype),
DataLen: msgLenToBytes(int64(len(data))),
},
Data: data,
}
} | [
"func",
"NewMessage",
"(",
"mtype",
"messageType",
",",
"data",
"[",
"]",
"byte",
")",
"*",
"Message",
"{",
"return",
"&",
"Message",
"{",
"MessageHeader",
":",
"MessageHeader",
"{",
"Version",
":",
"uint8",
"(",
"2",
")",
",",
"Type",
":",
"uint8",
"(",
"mtype",
")",
",",
"DataLen",
":",
"msgLenToBytes",
"(",
"int64",
"(",
"len",
"(",
"data",
")",
")",
")",
",",
"}",
",",
"Data",
":",
"data",
",",
"}",
"\n",
"}"
]
| // NewMessage generates a new Message instance. | [
"NewMessage",
"generates",
"a",
"new",
"Message",
"instance",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/types/message.go#L50-L59 |
9,999 | aerospike/aerospike-client-go | types/message.go | Resize | func (msg *Message) Resize(newSize int64) error {
if newSize > maxAllowedBufferSize || newSize < 0 {
return fmt.Errorf("Requested new buffer size is invalid. Requested: %d, allowed: 0..%d", newSize, maxAllowedBufferSize)
}
if int64(len(msg.Data)) == newSize {
return nil
}
msg.Data = make([]byte, newSize)
return nil
} | go | func (msg *Message) Resize(newSize int64) error {
if newSize > maxAllowedBufferSize || newSize < 0 {
return fmt.Errorf("Requested new buffer size is invalid. Requested: %d, allowed: 0..%d", newSize, maxAllowedBufferSize)
}
if int64(len(msg.Data)) == newSize {
return nil
}
msg.Data = make([]byte, newSize)
return nil
} | [
"func",
"(",
"msg",
"*",
"Message",
")",
"Resize",
"(",
"newSize",
"int64",
")",
"error",
"{",
"if",
"newSize",
">",
"maxAllowedBufferSize",
"||",
"newSize",
"<",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"newSize",
",",
"maxAllowedBufferSize",
")",
"\n",
"}",
"\n",
"if",
"int64",
"(",
"len",
"(",
"msg",
".",
"Data",
")",
")",
"==",
"newSize",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"msg",
".",
"Data",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"newSize",
")",
"\n",
"return",
"nil",
"\n",
"}"
]
| // Resize changes the internal buffer size for the message. | [
"Resize",
"changes",
"the",
"internal",
"buffer",
"size",
"for",
"the",
"message",
"."
]
| f257953b1650505cf4c357fcc4f032d160ebb07e | https://github.com/aerospike/aerospike-client-go/blob/f257953b1650505cf4c357fcc4f032d160ebb07e/types/message.go#L64-L73 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.