repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
swaggo/gin-swagger
swagger.go
DisablingCustomWrapHandler
func DisablingCustomWrapHandler(config *Config, h *webdav.Handler, envName string) gin.HandlerFunc { eFlag := os.Getenv(envName) if eFlag != "" { return func(c *gin.Context) { // Simulate behavior when route unspecified and // return 404 HTTP code c.String(404, "") } } return CustomWrapHandler(config,...
go
func DisablingCustomWrapHandler(config *Config, h *webdav.Handler, envName string) gin.HandlerFunc { eFlag := os.Getenv(envName) if eFlag != "" { return func(c *gin.Context) { // Simulate behavior when route unspecified and // return 404 HTTP code c.String(404, "") } } return CustomWrapHandler(config,...
[ "func", "DisablingCustomWrapHandler", "(", "config", "*", "Config", ",", "h", "*", "webdav", ".", "Handler", ",", "envName", "string", ")", "gin", ".", "HandlerFunc", "{", "eFlag", ":=", "os", ".", "Getenv", "(", "envName", ")", "\n", "if", "eFlag", "!="...
// DisablingCustomWrapHandler turn handler off // if specified environment variable passed
[ "DisablingCustomWrapHandler", "turn", "handler", "off", "if", "specified", "environment", "variable", "passed" ]
dbf6ef410096ed3b4a467a14040e019fd7a0f85a
https://github.com/swaggo/gin-swagger/blob/dbf6ef410096ed3b4a467a14040e019fd7a0f85a/swagger.go#L110-L121
train
gocql/gocql
filters.go
DataCentreHostFilter
func DataCentreHostFilter(dataCentre string) HostFilter { return HostFilterFunc(func(host *HostInfo) bool { return host.DataCenter() == dataCentre }) }
go
func DataCentreHostFilter(dataCentre string) HostFilter { return HostFilterFunc(func(host *HostInfo) bool { return host.DataCenter() == dataCentre }) }
[ "func", "DataCentreHostFilter", "(", "dataCentre", "string", ")", "HostFilter", "{", "return", "HostFilterFunc", "(", "func", "(", "host", "*", "HostInfo", ")", "bool", "{", "return", "host", ".", "DataCenter", "(", ")", "==", "dataCentre", "\n", "}", ")", ...
// DataCentreHostFilter filters all hosts such that they are in the same data centre // as the supplied data centre.
[ "DataCentreHostFilter", "filters", "all", "hosts", "such", "that", "they", "are", "in", "the", "same", "data", "centre", "as", "the", "supplied", "data", "centre", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/filters.go#L34-L38
train
gocql/gocql
filters.go
WhiteListHostFilter
func WhiteListHostFilter(hosts ...string) HostFilter { hostInfos, err := addrsToHosts(hosts, 9042) if err != nil { // dont want to panic here, but rather not break the API panic(fmt.Errorf("unable to lookup host info from address: %v", err)) } m := make(map[string]bool, len(hostInfos)) for _, host := range ho...
go
func WhiteListHostFilter(hosts ...string) HostFilter { hostInfos, err := addrsToHosts(hosts, 9042) if err != nil { // dont want to panic here, but rather not break the API panic(fmt.Errorf("unable to lookup host info from address: %v", err)) } m := make(map[string]bool, len(hostInfos)) for _, host := range ho...
[ "func", "WhiteListHostFilter", "(", "hosts", "...", "string", ")", "HostFilter", "{", "hostInfos", ",", "err", ":=", "addrsToHosts", "(", "hosts", ",", "9042", ")", "\n", "if", "err", "!=", "nil", "{", "// dont want to panic here, but rather not break the API", "p...
// WhiteListHostFilter filters incoming hosts by checking that their address is // in the initial hosts whitelist.
[ "WhiteListHostFilter", "filters", "incoming", "hosts", "by", "checking", "that", "their", "address", "is", "in", "the", "initial", "hosts", "whitelist", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/filters.go#L42-L57
train
gocql/gocql
helpers.go
TupleColumnName
func TupleColumnName(c string, n int) string { return fmt.Sprintf("%s[%d]", c, n) }
go
func TupleColumnName(c string, n int) string { return fmt.Sprintf("%s[%d]", c, n) }
[ "func", "TupleColumnName", "(", "c", "string", ",", "n", "int", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ",", "n", ")", "\n", "}" ]
// TupeColumnName will return the column name of a tuple value in a column named // c at index n. It should be used if a specific element within a tuple is needed // to be extracted from a map returned from SliceMap or MapScan.
[ "TupeColumnName", "will", "return", "the", "column", "name", "of", "a", "tuple", "value", "in", "a", "column", "named", "c", "at", "index", "n", ".", "It", "should", "be", "used", "if", "a", "specific", "element", "within", "a", "tuple", "is", "needed", ...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/helpers.go#L292-L294
train
gocql/gocql
cluster.go
NewCluster
func NewCluster(hosts ...string) *ClusterConfig { cfg := &ClusterConfig{ Hosts: hosts, CQLVersion: "3.0.0", Timeout: 600 * time.Millisecond, ConnectTimeout: 600 * time.Millisecond, Port: 9042, NumConns: 2, Consistency: ...
go
func NewCluster(hosts ...string) *ClusterConfig { cfg := &ClusterConfig{ Hosts: hosts, CQLVersion: "3.0.0", Timeout: 600 * time.Millisecond, ConnectTimeout: 600 * time.Millisecond, Port: 9042, NumConns: 2, Consistency: ...
[ "func", "NewCluster", "(", "hosts", "...", "string", ")", "*", "ClusterConfig", "{", "cfg", ":=", "&", "ClusterConfig", "{", "Hosts", ":", "hosts", ",", "CQLVersion", ":", "\"", "\"", ",", "Timeout", ":", "600", "*", "time", ".", "Millisecond", ",", "C...
// NewCluster generates a new config for the default cluster implementation. // // The supplied hosts are used to initially connect to the cluster then the rest of // the ring will be automatically discovered. It is recommended to use the value set in // the Cassandra config for broadcast_address or listen_address, an ...
[ "NewCluster", "generates", "a", "new", "config", "for", "the", "default", "cluster", "implementation", ".", "The", "supplied", "hosts", "are", "used", "to", "initially", "connect", "to", "the", "cluster", "then", "the", "rest", "of", "the", "ring", "will", "...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/cluster.go#L160-L180
train
gocql/gocql
cluster.go
translateAddressPort
func (cfg *ClusterConfig) translateAddressPort(addr net.IP, port int) (net.IP, int) { if cfg.AddressTranslator == nil || len(addr) == 0 { return addr, port } newAddr, newPort := cfg.AddressTranslator.Translate(addr, port) if gocqlDebug { Logger.Printf("gocql: translating address '%v:%d' to '%v:%d'", addr, port,...
go
func (cfg *ClusterConfig) translateAddressPort(addr net.IP, port int) (net.IP, int) { if cfg.AddressTranslator == nil || len(addr) == 0 { return addr, port } newAddr, newPort := cfg.AddressTranslator.Translate(addr, port) if gocqlDebug { Logger.Printf("gocql: translating address '%v:%d' to '%v:%d'", addr, port,...
[ "func", "(", "cfg", "*", "ClusterConfig", ")", "translateAddressPort", "(", "addr", "net", ".", "IP", ",", "port", "int", ")", "(", "net", ".", "IP", ",", "int", ")", "{", "if", "cfg", ".", "AddressTranslator", "==", "nil", "||", "len", "(", "addr", ...
// translateAddressPort is a helper method that will use the given AddressTranslator // if defined, to translate the given address and port into a possibly new address // and port, If no AddressTranslator or if an error occurs, the given address and // port will be returned.
[ "translateAddressPort", "is", "a", "helper", "method", "that", "will", "use", "the", "given", "AddressTranslator", "if", "defined", "to", "translate", "the", "given", "address", "and", "port", "into", "a", "possibly", "new", "address", "and", "port", "If", "no...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/cluster.go#L192-L201
train
gocql/gocql
frame.go
ParseConsistencyWrapper
func ParseConsistencyWrapper(s string) (consistency Consistency, err error) { err = consistency.UnmarshalText([]byte(strings.ToUpper(s))) return }
go
func ParseConsistencyWrapper(s string) (consistency Consistency, err error) { err = consistency.UnmarshalText([]byte(strings.ToUpper(s))) return }
[ "func", "ParseConsistencyWrapper", "(", "s", "string", ")", "(", "consistency", "Consistency", ",", "err", "error", ")", "{", "err", "=", "consistency", ".", "UnmarshalText", "(", "[", "]", "byte", "(", "strings", ".", "ToUpper", "(", "s", ")", ")", ")",...
// ParseConsistencyWrapper wraps gocql.ParseConsistency to provide an err // return instead of a panic
[ "ParseConsistencyWrapper", "wraps", "gocql", ".", "ParseConsistency", "to", "provide", "an", "err", "return", "instead", "of", "a", "panic" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/frame.go#L253-L256
train
gocql/gocql
frame.go
readFrame
func (f *framer) readFrame(head *frameHeader) error { if head.length < 0 { return fmt.Errorf("frame body length can not be less than 0: %d", head.length) } else if head.length > maxFrameSize { // need to free up the connection to be used again _, err := io.CopyN(ioutil.Discard, f.r, int64(head.length)) if err...
go
func (f *framer) readFrame(head *frameHeader) error { if head.length < 0 { return fmt.Errorf("frame body length can not be less than 0: %d", head.length) } else if head.length > maxFrameSize { // need to free up the connection to be used again _, err := io.CopyN(ioutil.Discard, f.r, int64(head.length)) if err...
[ "func", "(", "f", "*", "framer", ")", "readFrame", "(", "head", "*", "frameHeader", ")", "error", "{", "if", "head", ".", "length", "<", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "head", ".", "length", ")", "\n", "}", "else"...
// reads a frame form the wire into the framers buffer
[ "reads", "a", "frame", "form", "the", "wire", "into", "the", "framers", "buffer" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/frame.go#L504-L542
train
gocql/gocql
frame.go
writeInt
func (f *framer) writeInt(n int32) { f.wbuf = appendInt(f.wbuf, n) }
go
func (f *framer) writeInt(n int32) { f.wbuf = appendInt(f.wbuf, n) }
[ "func", "(", "f", "*", "framer", ")", "writeInt", "(", "n", "int32", ")", "{", "f", ".", "wbuf", "=", "appendInt", "(", "f", ".", "wbuf", ",", "n", ")", "\n", "}" ]
// these are protocol level binary types
[ "these", "are", "protocol", "level", "binary", "types" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/frame.go#L2011-L2013
train
gocql/gocql
control.go
query
func (c *controlConn) query(statement string, values ...interface{}) (iter *Iter) { q := c.session.Query(statement, values...).Consistency(One).RoutingKey([]byte{}).Trace(nil) for { iter = c.withConn(func(conn *Conn) *Iter { return conn.executeQuery(context.TODO(), q) }) if gocqlDebug && iter.err != nil { ...
go
func (c *controlConn) query(statement string, values ...interface{}) (iter *Iter) { q := c.session.Query(statement, values...).Consistency(One).RoutingKey([]byte{}).Trace(nil) for { iter = c.withConn(func(conn *Conn) *Iter { return conn.executeQuery(context.TODO(), q) }) if gocqlDebug && iter.err != nil { ...
[ "func", "(", "c", "*", "controlConn", ")", "query", "(", "statement", "string", ",", "values", "...", "interface", "{", "}", ")", "(", "iter", "*", "Iter", ")", "{", "q", ":=", "c", ".", "session", ".", "Query", "(", "statement", ",", "values", ".....
// query will return nil if the connection is closed or nil
[ "query", "will", "return", "nil", "if", "the", "connection", "is", "closed", "or", "nil" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/control.go#L450-L469
train
gocql/gocql
session.go
NewSession
func NewSession(cfg ClusterConfig) (*Session, error) { // Check that hosts in the ClusterConfig is not empty if len(cfg.Hosts) < 1 { return nil, ErrNoHosts } // Check that either Authenticator is set or AuthProvider, not both if cfg.Authenticator != nil && cfg.AuthProvider != nil { return nil, errors.New("Can...
go
func NewSession(cfg ClusterConfig) (*Session, error) { // Check that hosts in the ClusterConfig is not empty if len(cfg.Hosts) < 1 { return nil, ErrNoHosts } // Check that either Authenticator is set or AuthProvider, not both if cfg.Authenticator != nil && cfg.AuthProvider != nil { return nil, errors.New("Can...
[ "func", "NewSession", "(", "cfg", "ClusterConfig", ")", "(", "*", "Session", ",", "error", ")", "{", "// Check that hosts in the ClusterConfig is not empty", "if", "len", "(", "cfg", ".", "Hosts", ")", "<", "1", "{", "return", "nil", ",", "ErrNoHosts", "\n", ...
// NewSession wraps an existing Node.
[ "NewSession", "wraps", "an", "existing", "Node", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L105-L174
train
gocql/gocql
session.go
SetConsistency
func (s *Session) SetConsistency(cons Consistency) { s.mu.Lock() s.cons = cons s.mu.Unlock() }
go
func (s *Session) SetConsistency(cons Consistency) { s.mu.Lock() s.cons = cons s.mu.Unlock() }
[ "func", "(", "s", "*", "Session", ")", "SetConsistency", "(", "cons", "Consistency", ")", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "s", ".", "cons", "=", "cons", "\n", "s", ".", "mu", ".", "Unlock", "(", ")", "\n", "}" ]
// SetConsistency sets the default consistency level for this session. This // setting can also be changed on a per-query basis and the default value // is Quorum.
[ "SetConsistency", "sets", "the", "default", "consistency", "level", "for", "this", "session", ".", "This", "setting", "can", "also", "be", "changed", "on", "a", "per", "-", "query", "basis", "and", "the", "default", "value", "is", "Quorum", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L295-L299
train
gocql/gocql
session.go
SetPageSize
func (s *Session) SetPageSize(n int) { s.mu.Lock() s.pageSize = n s.mu.Unlock() }
go
func (s *Session) SetPageSize(n int) { s.mu.Lock() s.pageSize = n s.mu.Unlock() }
[ "func", "(", "s", "*", "Session", ")", "SetPageSize", "(", "n", "int", ")", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "s", ".", "pageSize", "=", "n", "\n", "s", ".", "mu", ".", "Unlock", "(", ")", "\n", "}" ]
// SetPageSize sets the default page size for this session. A value <= 0 will // disable paging. This setting can also be changed on a per-query basis.
[ "SetPageSize", "sets", "the", "default", "page", "size", "for", "this", "session", ".", "A", "value", "<", "=", "0", "will", "disable", "paging", ".", "This", "setting", "can", "also", "be", "changed", "on", "a", "per", "-", "query", "basis", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L303-L307
train
gocql/gocql
session.go
SetTrace
func (s *Session) SetTrace(trace Tracer) { s.mu.Lock() s.trace = trace s.mu.Unlock() }
go
func (s *Session) SetTrace(trace Tracer) { s.mu.Lock() s.trace = trace s.mu.Unlock() }
[ "func", "(", "s", "*", "Session", ")", "SetTrace", "(", "trace", "Tracer", ")", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "s", ".", "trace", "=", "trace", "\n", "s", ".", "mu", ".", "Unlock", "(", ")", "\n", "}" ]
// SetTrace sets the default tracer for this session. This setting can also // be changed on a per-query basis.
[ "SetTrace", "sets", "the", "default", "tracer", "for", "this", "session", ".", "This", "setting", "can", "also", "be", "changed", "on", "a", "per", "-", "query", "basis", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L321-L325
train
gocql/gocql
session.go
Query
func (s *Session) Query(stmt string, values ...interface{}) *Query { qry := queryPool.Get().(*Query) qry.session = s qry.stmt = stmt qry.values = values qry.defaultsFromSession() return qry }
go
func (s *Session) Query(stmt string, values ...interface{}) *Query { qry := queryPool.Get().(*Query) qry.session = s qry.stmt = stmt qry.values = values qry.defaultsFromSession() return qry }
[ "func", "(", "s", "*", "Session", ")", "Query", "(", "stmt", "string", ",", "values", "...", "interface", "{", "}", ")", "*", "Query", "{", "qry", ":=", "queryPool", ".", "Get", "(", ")", ".", "(", "*", "Query", ")", "\n", "qry", ".", "session", ...
// Query generates a new query object for interacting with the database. // Further details of the query may be tweaked using the resulting query // value before the query is executed. Query is automatically prepared // if it has not previously been executed.
[ "Query", "generates", "a", "new", "query", "object", "for", "interacting", "with", "the", "database", ".", "Further", "details", "of", "the", "query", "may", "be", "tweaked", "using", "the", "resulting", "query", "value", "before", "the", "query", "is", "exe...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L331-L338
train
gocql/gocql
session.go
Bind
func (s *Session) Bind(stmt string, b func(q *QueryInfo) ([]interface{}, error)) *Query { qry := queryPool.Get().(*Query) qry.session = s qry.stmt = stmt qry.binding = b qry.defaultsFromSession() return qry }
go
func (s *Session) Bind(stmt string, b func(q *QueryInfo) ([]interface{}, error)) *Query { qry := queryPool.Get().(*Query) qry.session = s qry.stmt = stmt qry.binding = b qry.defaultsFromSession() return qry }
[ "func", "(", "s", "*", "Session", ")", "Bind", "(", "stmt", "string", ",", "b", "func", "(", "q", "*", "QueryInfo", ")", "(", "[", "]", "interface", "{", "}", ",", "error", ")", ")", "*", "Query", "{", "qry", ":=", "queryPool", ".", "Get", "(",...
// Bind generates a new query object based on the query statement passed in. // The query is automatically prepared if it has not previously been executed. // The binding callback allows the application to define which query argument // values will be marshalled as part of the query execution. // During execution, the ...
[ "Bind", "generates", "a", "new", "query", "object", "based", "on", "the", "query", "statement", "passed", "in", ".", "The", "query", "is", "automatically", "prepared", "if", "it", "has", "not", "previously", "been", "executed", ".", "The", "binding", "callba...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L353-L360
train
gocql/gocql
session.go
Close
func (s *Session) Close() { s.closeMu.Lock() defer s.closeMu.Unlock() if s.isClosed { return } s.isClosed = true if s.pool != nil { s.pool.Close() } if s.control != nil { s.control.close() } if s.nodeEvents != nil { s.nodeEvents.stop() } if s.schemaEvents != nil { s.schemaEvents.stop() } i...
go
func (s *Session) Close() { s.closeMu.Lock() defer s.closeMu.Unlock() if s.isClosed { return } s.isClosed = true if s.pool != nil { s.pool.Close() } if s.control != nil { s.control.close() } if s.nodeEvents != nil { s.nodeEvents.stop() } if s.schemaEvents != nil { s.schemaEvents.stop() } i...
[ "func", "(", "s", "*", "Session", ")", "Close", "(", ")", "{", "s", ".", "closeMu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "closeMu", ".", "Unlock", "(", ")", "\n", "if", "s", ".", "isClosed", "{", "return", "\n", "}", "\n", "s", "."...
// Close closes all connections. The session is unusable after this // operation.
[ "Close", "closes", "all", "connections", ".", "The", "session", "is", "unusable", "after", "this", "operation", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L364-L392
train
gocql/gocql
session.go
KeyspaceMetadata
func (s *Session) KeyspaceMetadata(keyspace string) (*KeyspaceMetadata, error) { // fail fast if s.Closed() { return nil, ErrSessionClosed } else if keyspace == "" { return nil, ErrNoKeyspace } return s.schemaDescriber.getSchema(keyspace) }
go
func (s *Session) KeyspaceMetadata(keyspace string) (*KeyspaceMetadata, error) { // fail fast if s.Closed() { return nil, ErrSessionClosed } else if keyspace == "" { return nil, ErrNoKeyspace } return s.schemaDescriber.getSchema(keyspace) }
[ "func", "(", "s", "*", "Session", ")", "KeyspaceMetadata", "(", "keyspace", "string", ")", "(", "*", "KeyspaceMetadata", ",", "error", ")", "{", "// fail fast", "if", "s", ".", "Closed", "(", ")", "{", "return", "nil", ",", "ErrSessionClosed", "\n", "}",...
// KeyspaceMetadata returns the schema metadata for the keyspace specified. Returns an error if the keyspace does not exist.
[ "KeyspaceMetadata", "returns", "the", "schema", "metadata", "for", "the", "keyspace", "specified", ".", "Returns", "an", "error", "if", "the", "keyspace", "does", "not", "exist", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L425-L434
train
gocql/gocql
session.go
ExecuteBatch
func (s *Session) ExecuteBatch(batch *Batch) error { iter := s.executeBatch(batch) return iter.Close() }
go
func (s *Session) ExecuteBatch(batch *Batch) error { iter := s.executeBatch(batch) return iter.Close() }
[ "func", "(", "s", "*", "Session", ")", "ExecuteBatch", "(", "batch", "*", "Batch", ")", "error", "{", "iter", ":=", "s", ".", "executeBatch", "(", "batch", ")", "\n", "return", "iter", ".", "Close", "(", ")", "\n", "}" ]
// ExecuteBatch executes a batch operation and returns nil if successful // otherwise an error is returned describing the failure.
[ "ExecuteBatch", "executes", "a", "batch", "operation", "and", "returns", "nil", "if", "successful", "otherwise", "an", "error", "is", "returned", "describing", "the", "failure", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L613-L616
train
gocql/gocql
session.go
MapExecuteBatchCAS
func (s *Session) MapExecuteBatchCAS(batch *Batch, dest map[string]interface{}) (applied bool, iter *Iter, err error) { iter = s.executeBatch(batch) if err := iter.checkErrAndNotFound(); err != nil { iter.Close() return false, nil, err } iter.MapScan(dest) applied = dest["[applied]"].(bool) delete(dest, "[app...
go
func (s *Session) MapExecuteBatchCAS(batch *Batch, dest map[string]interface{}) (applied bool, iter *Iter, err error) { iter = s.executeBatch(batch) if err := iter.checkErrAndNotFound(); err != nil { iter.Close() return false, nil, err } iter.MapScan(dest) applied = dest["[applied]"].(bool) delete(dest, "[app...
[ "func", "(", "s", "*", "Session", ")", "MapExecuteBatchCAS", "(", "batch", "*", "Batch", ",", "dest", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "applied", "bool", ",", "iter", "*", "Iter", ",", "err", "error", ")", "{", "iter", "=...
// MapExecuteBatchCAS executes a batch operation much like ExecuteBatchCAS, // however it accepts a map rather than a list of arguments for the initial // scan.
[ "MapExecuteBatchCAS", "executes", "a", "batch", "operation", "much", "like", "ExecuteBatchCAS", "however", "it", "accepts", "a", "map", "rather", "than", "a", "list", "of", "arguments", "for", "the", "initial", "scan", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L643-L657
train
gocql/gocql
session.go
Attempts
func (q *Query) Attempts() int { q.metrics.l.Lock() var attempts int for _, metric := range q.metrics.m { attempts += metric.Attempts } q.metrics.l.Unlock() return attempts }
go
func (q *Query) Attempts() int { q.metrics.l.Lock() var attempts int for _, metric := range q.metrics.m { attempts += metric.Attempts } q.metrics.l.Unlock() return attempts }
[ "func", "(", "q", "*", "Query", ")", "Attempts", "(", ")", "int", "{", "q", ".", "metrics", ".", "l", ".", "Lock", "(", ")", "\n", "var", "attempts", "int", "\n", "for", "_", ",", "metric", ":=", "range", "q", ".", "metrics", ".", "m", "{", "...
//Attempts returns the number of times the query was executed.
[ "Attempts", "returns", "the", "number", "of", "times", "the", "query", "was", "executed", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L740-L748
train
gocql/gocql
session.go
Latency
func (q *Query) Latency() int64 { q.metrics.l.Lock() var attempts int var latency int64 for _, metric := range q.metrics.m { attempts += metric.Attempts latency += metric.TotalLatency } q.metrics.l.Unlock() if attempts > 0 { return latency / int64(attempts) } return 0 }
go
func (q *Query) Latency() int64 { q.metrics.l.Lock() var attempts int var latency int64 for _, metric := range q.metrics.m { attempts += metric.Attempts latency += metric.TotalLatency } q.metrics.l.Unlock() if attempts > 0 { return latency / int64(attempts) } return 0 }
[ "func", "(", "q", "*", "Query", ")", "Latency", "(", ")", "int64", "{", "q", ".", "metrics", ".", "l", ".", "Lock", "(", ")", "\n", "var", "attempts", "int", "\n", "var", "latency", "int64", "\n", "for", "_", ",", "metric", ":=", "range", "q", ...
//Latency returns the average amount of nanoseconds per attempt of the query.
[ "Latency", "returns", "the", "average", "amount", "of", "nanoseconds", "per", "attempt", "of", "the", "query", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L758-L771
train
gocql/gocql
session.go
Consistency
func (q *Query) Consistency(c Consistency) *Query { q.cons = c return q }
go
func (q *Query) Consistency(c Consistency) *Query { q.cons = c return q }
[ "func", "(", "q", "*", "Query", ")", "Consistency", "(", "c", "Consistency", ")", "*", "Query", "{", "q", ".", "cons", "=", "c", "\n", "return", "q", "\n", "}" ]
// Consistency sets the consistency level for this query. If no consistency // level have been set, the default consistency level of the cluster // is used.
[ "Consistency", "sets", "the", "consistency", "level", "for", "this", "query", ".", "If", "no", "consistency", "level", "have", "been", "set", "the", "default", "consistency", "level", "of", "the", "cluster", "is", "used", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L783-L786
train
gocql/gocql
session.go
Keyspace
func (q *Query) Keyspace() string { if q.session == nil { return "" } // TODO(chbannis): this should be parsed from the query or we should let // this be set by users. return q.session.cfg.Keyspace }
go
func (q *Query) Keyspace() string { if q.session == nil { return "" } // TODO(chbannis): this should be parsed from the query or we should let // this be set by users. return q.session.cfg.Keyspace }
[ "func", "(", "q", "*", "Query", ")", "Keyspace", "(", ")", "string", "{", "if", "q", ".", "session", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "// TODO(chbannis): this should be parsed from the query or we should let", "// this be set by users.", "r...
// Keyspace returns the keyspace the query will be executed against.
[ "Keyspace", "returns", "the", "keyspace", "the", "query", "will", "be", "executed", "against", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L914-L921
train
gocql/gocql
session.go
GetRoutingKey
func (q *Query) GetRoutingKey() ([]byte, error) { if q.routingKey != nil { return q.routingKey, nil } else if q.binding != nil && len(q.values) == 0 { // If this query was created using session.Bind we wont have the query // values yet, so we have to pass down to the next policy. // TODO: Remove this and hand...
go
func (q *Query) GetRoutingKey() ([]byte, error) { if q.routingKey != nil { return q.routingKey, nil } else if q.binding != nil && len(q.values) == 0 { // If this query was created using session.Bind we wont have the query // values yet, so we have to pass down to the next policy. // TODO: Remove this and hand...
[ "func", "(", "q", "*", "Query", ")", "GetRoutingKey", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "q", ".", "routingKey", "!=", "nil", "{", "return", "q", ".", "routingKey", ",", "nil", "\n", "}", "else", "if", "q", ".", "bin...
// GetRoutingKey gets the routing key to use for routing this query. If // a routing key has not been explicitly set, then the routing key will // be constructed if possible using the keyspace's schema and the query // info for this query statement. If the routing key cannot be determined // then nil will be returned w...
[ "GetRoutingKey", "gets", "the", "routing", "key", "to", "use", "for", "routing", "this", "query", ".", "If", "a", "routing", "key", "has", "not", "been", "explicitly", "set", "then", "the", "routing", "key", "will", "be", "constructed", "if", "possible", "...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L929-L985
train
gocql/gocql
session.go
SetSpeculativeExecutionPolicy
func (q *Query) SetSpeculativeExecutionPolicy(sp SpeculativeExecutionPolicy) *Query { q.spec = sp return q }
go
func (q *Query) SetSpeculativeExecutionPolicy(sp SpeculativeExecutionPolicy) *Query { q.spec = sp return q }
[ "func", "(", "q", "*", "Query", ")", "SetSpeculativeExecutionPolicy", "(", "sp", "SpeculativeExecutionPolicy", ")", "*", "Query", "{", "q", ".", "spec", "=", "sp", "\n", "return", "q", "\n", "}" ]
// SetSpeculativeExecutionPolicy sets the execution policy
[ "SetSpeculativeExecutionPolicy", "sets", "the", "execution", "policy" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1024-L1027
train
gocql/gocql
session.go
Iter
func (q *Query) Iter() *Iter { if isUseStatement(q.stmt) { return &Iter{err: ErrUseStmt} } return q.session.executeQuery(q) }
go
func (q *Query) Iter() *Iter { if isUseStatement(q.stmt) { return &Iter{err: ErrUseStmt} } return q.session.executeQuery(q) }
[ "func", "(", "q", "*", "Query", ")", "Iter", "(", ")", "*", "Iter", "{", "if", "isUseStatement", "(", "q", ".", "stmt", ")", "{", "return", "&", "Iter", "{", "err", ":", "ErrUseStmt", "}", "\n", "}", "\n", "return", "q", ".", "session", ".", "e...
// Iter executes the query and returns an iterator capable of iterating // over all results.
[ "Iter", "executes", "the", "query", "and", "returns", "an", "iterator", "capable", "of", "iterating", "over", "all", "results", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1099-L1104
train
gocql/gocql
session.go
MapScan
func (q *Query) MapScan(m map[string]interface{}) error { iter := q.Iter() if err := iter.checkErrAndNotFound(); err != nil { return err } iter.MapScan(m) return iter.Close() }
go
func (q *Query) MapScan(m map[string]interface{}) error { iter := q.Iter() if err := iter.checkErrAndNotFound(); err != nil { return err } iter.MapScan(m) return iter.Close() }
[ "func", "(", "q", "*", "Query", ")", "MapScan", "(", "m", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "iter", ":=", "q", ".", "Iter", "(", ")", "\n", "if", "err", ":=", "iter", ".", "checkErrAndNotFound", "(", ")", ";", ...
// MapScan executes the query, copies the columns of the first selected // row into the map pointed at by m and discards the rest. If no rows // were selected, ErrNotFound is returned.
[ "MapScan", "executes", "the", "query", "copies", "the", "columns", "of", "the", "first", "selected", "row", "into", "the", "map", "pointed", "at", "by", "m", "and", "discards", "the", "rest", ".", "If", "no", "rows", "were", "selected", "ErrNotFound", "is"...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1109-L1116
train
gocql/gocql
session.go
Scan
func (q *Query) Scan(dest ...interface{}) error { iter := q.Iter() if err := iter.checkErrAndNotFound(); err != nil { return err } iter.Scan(dest...) return iter.Close() }
go
func (q *Query) Scan(dest ...interface{}) error { iter := q.Iter() if err := iter.checkErrAndNotFound(); err != nil { return err } iter.Scan(dest...) return iter.Close() }
[ "func", "(", "q", "*", "Query", ")", "Scan", "(", "dest", "...", "interface", "{", "}", ")", "error", "{", "iter", ":=", "q", ".", "Iter", "(", ")", "\n", "if", "err", ":=", "iter", ".", "checkErrAndNotFound", "(", ")", ";", "err", "!=", "nil", ...
// Scan executes the query, copies the columns of the first selected // row into the values pointed at by dest and discards the rest. If no rows // were selected, ErrNotFound is returned.
[ "Scan", "executes", "the", "query", "copies", "the", "columns", "of", "the", "first", "selected", "row", "into", "the", "values", "pointed", "at", "by", "dest", "and", "discards", "the", "rest", ".", "If", "no", "rows", "were", "selected", "ErrNotFound", "...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1121-L1128
train
gocql/gocql
session.go
Scan
func (iter *Iter) Scan(dest ...interface{}) bool { if iter.err != nil { return false } if iter.pos >= iter.numRows { if iter.next != nil { *iter = *iter.next.fetch() return iter.Scan(dest...) } return false } if iter.next != nil && iter.pos >= iter.next.pos { go iter.next.fetch() } // currentl...
go
func (iter *Iter) Scan(dest ...interface{}) bool { if iter.err != nil { return false } if iter.pos >= iter.numRows { if iter.next != nil { *iter = *iter.next.fetch() return iter.Scan(dest...) } return false } if iter.next != nil && iter.pos >= iter.next.pos { go iter.next.fetch() } // currentl...
[ "func", "(", "iter", "*", "Iter", ")", "Scan", "(", "dest", "...", "interface", "{", "}", ")", "bool", "{", "if", "iter", ".", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n\n", "if", "iter", ".", "pos", ">=", "iter", ".", "numRows", ...
// Scan consumes the next row of the iterator and copies the columns of the // current row into the values pointed at by dest. Use nil as a dest value // to skip the corresponding column. Scan might send additional queries // to the database to retrieve the next set of rows if paging was enabled. // // Scan returns tru...
[ "Scan", "consumes", "the", "next", "row", "of", "the", "iterator", "and", "copies", "the", "columns", "of", "the", "current", "row", "into", "the", "values", "pointed", "at", "by", "dest", ".", "Use", "nil", "as", "a", "dest", "value", "to", "skip", "t...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1348-L1392
train
gocql/gocql
session.go
Warnings
func (iter *Iter) Warnings() []string { if iter.framer != nil { return iter.framer.header.warnings } return nil }
go
func (iter *Iter) Warnings() []string { if iter.framer != nil { return iter.framer.header.warnings } return nil }
[ "func", "(", "iter", "*", "Iter", ")", "Warnings", "(", ")", "[", "]", "string", "{", "if", "iter", ".", "framer", "!=", "nil", "{", "return", "iter", ".", "framer", ".", "header", ".", "warnings", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Warnings returns any warnings generated if given in the response from Cassandra. // // This is only available starting with CQL Protocol v4.
[ "Warnings", "returns", "any", "warnings", "generated", "if", "given", "in", "the", "response", "from", "Cassandra", ".", "This", "is", "only", "available", "starting", "with", "CQL", "Protocol", "v4", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1408-L1413
train
gocql/gocql
session.go
WillSwitchPage
func (iter *Iter) WillSwitchPage() bool { return iter.pos >= iter.numRows && iter.next != nil }
go
func (iter *Iter) WillSwitchPage() bool { return iter.pos >= iter.numRows && iter.next != nil }
[ "func", "(", "iter", "*", "Iter", ")", "WillSwitchPage", "(", ")", "bool", "{", "return", "iter", ".", "pos", ">=", "iter", ".", "numRows", "&&", "iter", ".", "next", "!=", "nil", "\n", "}" ]
// WillSwitchPage detects if iterator reached end of current page // and the next page is available.
[ "WillSwitchPage", "detects", "if", "iterator", "reached", "end", "of", "current", "page", "and", "the", "next", "page", "is", "available", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1429-L1431
train
gocql/gocql
session.go
NewBatch
func (s *Session) NewBatch(typ BatchType) *Batch { s.mu.RLock() batch := &Batch{ Type: typ, rt: s.cfg.RetryPolicy, serialCons: s.cfg.SerialConsistency, observer: s.batchObserver, Cons: s.cons, defaultTimestamp: s.cfg.DefaultTimestamp, keyspace: ...
go
func (s *Session) NewBatch(typ BatchType) *Batch { s.mu.RLock() batch := &Batch{ Type: typ, rt: s.cfg.RetryPolicy, serialCons: s.cfg.SerialConsistency, observer: s.batchObserver, Cons: s.cons, defaultTimestamp: s.cfg.DefaultTimestamp, keyspace: ...
[ "func", "(", "s", "*", "Session", ")", "NewBatch", "(", "typ", "BatchType", ")", "*", "Batch", "{", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "batch", ":=", "&", "Batch", "{", "Type", ":", "typ", ",", "rt", ":", "s", ".", "cfg", ".", "Ret...
// NewBatch creates a new batch operation using defaults defined in the cluster
[ "NewBatch", "creates", "a", "new", "batch", "operation", "using", "defaults", "defined", "in", "the", "cluster" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1499-L1515
train
gocql/gocql
session.go
Observer
func (b *Batch) Observer(observer BatchObserver) *Batch { b.observer = observer return b }
go
func (b *Batch) Observer(observer BatchObserver) *Batch { b.observer = observer return b }
[ "func", "(", "b", "*", "Batch", ")", "Observer", "(", "observer", "BatchObserver", ")", "*", "Batch", "{", "b", ".", "observer", "=", "observer", "\n", "return", "b", "\n", "}" ]
// Observer enables batch-level observer on this batch. // The provided observer will be called every time this batched query is executed.
[ "Observer", "enables", "batch", "-", "level", "observer", "on", "this", "batch", ".", "The", "provided", "observer", "will", "be", "called", "every", "time", "this", "batched", "query", "is", "executed", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1532-L1535
train
gocql/gocql
session.go
Attempts
func (b *Batch) Attempts() int { b.metrics.l.Lock() defer b.metrics.l.Unlock() var attempts int for _, metric := range b.metrics.m { attempts += metric.Attempts } return attempts }
go
func (b *Batch) Attempts() int { b.metrics.l.Lock() defer b.metrics.l.Unlock() var attempts int for _, metric := range b.metrics.m { attempts += metric.Attempts } return attempts }
[ "func", "(", "b", "*", "Batch", ")", "Attempts", "(", ")", "int", "{", "b", ".", "metrics", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "metrics", ".", "l", ".", "Unlock", "(", ")", "\n\n", "var", "attempts", "int", "\n", "for", ...
// Attempts returns the number of attempts made to execute the batch.
[ "Attempts", "returns", "the", "number", "of", "attempts", "made", "to", "execute", "the", "batch", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1542-L1551
train
gocql/gocql
session.go
Latency
func (b *Batch) Latency() int64 { b.metrics.l.Lock() defer b.metrics.l.Unlock() var ( attempts int latency int64 ) for _, metric := range b.metrics.m { attempts += metric.Attempts latency += metric.TotalLatency } if attempts > 0 { return latency / int64(attempts) } return 0 }
go
func (b *Batch) Latency() int64 { b.metrics.l.Lock() defer b.metrics.l.Unlock() var ( attempts int latency int64 ) for _, metric := range b.metrics.m { attempts += metric.Attempts latency += metric.TotalLatency } if attempts > 0 { return latency / int64(attempts) } return 0 }
[ "func", "(", "b", "*", "Batch", ")", "Latency", "(", ")", "int64", "{", "b", ".", "metrics", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "metrics", ".", "l", ".", "Unlock", "(", ")", "\n\n", "var", "(", "attempts", "int", "\n", ...
//Latency returns the average number of nanoseconds to execute a single attempt of the batch.
[ "Latency", "returns", "the", "average", "number", "of", "nanoseconds", "to", "execute", "a", "single", "attempt", "of", "the", "batch", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1561-L1577
train
gocql/gocql
session.go
Query
func (b *Batch) Query(stmt string, args ...interface{}) { b.Entries = append(b.Entries, BatchEntry{Stmt: stmt, Args: args}) }
go
func (b *Batch) Query(stmt string, args ...interface{}) { b.Entries = append(b.Entries, BatchEntry{Stmt: stmt, Args: args}) }
[ "func", "(", "b", "*", "Batch", ")", "Query", "(", "stmt", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "b", ".", "Entries", "=", "append", "(", "b", ".", "Entries", ",", "BatchEntry", "{", "Stmt", ":", "stmt", ",", "Args", ":",...
// Query adds the query to the batch operation
[ "Query", "adds", "the", "query", "to", "the", "batch", "operation" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1624-L1626
train
gocql/gocql
session.go
Bind
func (b *Batch) Bind(stmt string, bind func(q *QueryInfo) ([]interface{}, error)) { b.Entries = append(b.Entries, BatchEntry{Stmt: stmt, binding: bind}) }
go
func (b *Batch) Bind(stmt string, bind func(q *QueryInfo) ([]interface{}, error)) { b.Entries = append(b.Entries, BatchEntry{Stmt: stmt, binding: bind}) }
[ "func", "(", "b", "*", "Batch", ")", "Bind", "(", "stmt", "string", ",", "bind", "func", "(", "q", "*", "QueryInfo", ")", "(", "[", "]", "interface", "{", "}", ",", "error", ")", ")", "{", "b", ".", "Entries", "=", "append", "(", "b", ".", "E...
// Bind adds the query to the batch operation and correlates it with a binding callback // that will be invoked when the batch is executed. The binding callback allows the application // to define which query argument values will be marshalled as part of the batch execution.
[ "Bind", "adds", "the", "query", "to", "the", "batch", "operation", "and", "correlates", "it", "with", "a", "binding", "callback", "that", "will", "be", "invoked", "when", "the", "batch", "is", "executed", ".", "The", "binding", "callback", "allows", "the", ...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1631-L1633
train
gocql/gocql
session.go
RetryPolicy
func (b *Batch) RetryPolicy(r RetryPolicy) *Batch { b.rt = r return b }
go
func (b *Batch) RetryPolicy(r RetryPolicy) *Batch { b.rt = r return b }
[ "func", "(", "b", "*", "Batch", ")", "RetryPolicy", "(", "r", "RetryPolicy", ")", "*", "Batch", "{", "b", ".", "rt", "=", "r", "\n", "return", "b", "\n", "}" ]
// RetryPolicy sets the retry policy to use when executing the batch operation
[ "RetryPolicy", "sets", "the", "retry", "policy", "to", "use", "when", "executing", "the", "batch", "operation" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1640-L1643
train
gocql/gocql
session.go
WithContext
func (b *Batch) WithContext(ctx context.Context) *Batch { b2 := *b b2.context = ctx return &b2 }
go
func (b *Batch) WithContext(ctx context.Context) *Batch { b2 := *b b2.context = ctx return &b2 }
[ "func", "(", "b", "*", "Batch", ")", "WithContext", "(", "ctx", "context", ".", "Context", ")", "*", "Batch", "{", "b2", ":=", "*", "b", "\n", "b2", ".", "context", "=", "ctx", "\n", "return", "&", "b2", "\n", "}" ]
// WithContext returns a shallow copy of b with its context // set to ctx. // // The provided context controls the entire lifetime of executing a // query, queries will be canceled and return once the context is // canceled.
[ "WithContext", "returns", "a", "shallow", "copy", "of", "b", "with", "its", "context", "set", "to", "ctx", ".", "The", "provided", "context", "controls", "the", "entire", "lifetime", "of", "executing", "a", "query", "queries", "will", "be", "canceled", "and"...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1655-L1659
train
gocql/gocql
session.go
NewTraceWriter
func NewTraceWriter(session *Session, w io.Writer) Tracer { return &traceWriter{session: session, w: w} }
go
func NewTraceWriter(session *Session, w io.Writer) Tracer { return &traceWriter{session: session, w: w} }
[ "func", "NewTraceWriter", "(", "session", "*", "Session", ",", "w", "io", ".", "Writer", ")", "Tracer", "{", "return", "&", "traceWriter", "{", "session", ":", "session", ",", "w", ":", "w", "}", "\n", "}" ]
// NewTraceWriter returns a simple Tracer implementation that outputs // the event log in a textual format.
[ "NewTraceWriter", "returns", "a", "simple", "Tracer", "implementation", "that", "outputs", "the", "event", "log", "in", "a", "textual", "format", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/session.go#L1817-L1819
train
gocql/gocql
host_source.go
checkSystemSchema
func checkSystemSchema(control *controlConn) (bool, error) { iter := control.query("SELECT * FROM system_schema.keyspaces") if err := iter.err; err != nil { if errf, ok := err.(*errorFrame); ok { if errf.code == errSyntax { return false, nil } } return false, err } return true, nil }
go
func checkSystemSchema(control *controlConn) (bool, error) { iter := control.query("SELECT * FROM system_schema.keyspaces") if err := iter.err; err != nil { if errf, ok := err.(*errorFrame); ok { if errf.code == errSyntax { return false, nil } } return false, err } return true, nil }
[ "func", "checkSystemSchema", "(", "control", "*", "controlConn", ")", "(", "bool", ",", "error", ")", "{", "iter", ":=", "control", ".", "query", "(", "\"", "\"", ")", "\n", "if", "err", ":=", "iter", ".", "err", ";", "err", "!=", "nil", "{", "if",...
// Returns true if we are using system_schema.keyspaces instead of system.schema_keyspaces
[ "Returns", "true", "if", "we", "are", "using", "system_schema", ".", "keyspaces", "instead", "of", "system", ".", "schema_keyspaces" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/host_source.go#L436-L449
train
gocql/gocql
host_source.go
getClusterPeerInfo
func (r *ringDescriber) getClusterPeerInfo() ([]*HostInfo, error) { var hosts []*HostInfo iter := r.session.control.withConnHost(func(ch *connHost) *Iter { hosts = append(hosts, ch.host) return ch.conn.query(context.TODO(), "SELECT * FROM system.peers") }) if iter == nil { return nil, errNoControl } rows,...
go
func (r *ringDescriber) getClusterPeerInfo() ([]*HostInfo, error) { var hosts []*HostInfo iter := r.session.control.withConnHost(func(ch *connHost) *Iter { hosts = append(hosts, ch.host) return ch.conn.query(context.TODO(), "SELECT * FROM system.peers") }) if iter == nil { return nil, errNoControl } rows,...
[ "func", "(", "r", "*", "ringDescriber", ")", "getClusterPeerInfo", "(", ")", "(", "[", "]", "*", "HostInfo", ",", "error", ")", "{", "var", "hosts", "[", "]", "*", "HostInfo", "\n", "iter", ":=", "r", ".", "session", ".", "control", ".", "withConnHos...
// Ask the control node for host info on all it's known peers
[ "Ask", "the", "control", "node", "for", "host", "info", "on", "all", "it", "s", "known", "peers" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/host_source.go#L559-L592
train
gocql/gocql
host_source.go
isValidPeer
func isValidPeer(host *HostInfo) bool { return !(len(host.RPCAddress()) == 0 || host.hostId == "" || host.dataCenter == "" || host.rack == "" || len(host.tokens) == 0) }
go
func isValidPeer(host *HostInfo) bool { return !(len(host.RPCAddress()) == 0 || host.hostId == "" || host.dataCenter == "" || host.rack == "" || len(host.tokens) == 0) }
[ "func", "isValidPeer", "(", "host", "*", "HostInfo", ")", "bool", "{", "return", "!", "(", "len", "(", "host", ".", "RPCAddress", "(", ")", ")", "==", "0", "||", "host", ".", "hostId", "==", "\"", "\"", "||", "host", ".", "dataCenter", "==", "\"", ...
// Return true if the host is a valid peer
[ "Return", "true", "if", "the", "host", "is", "a", "valid", "peer" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/host_source.go#L595-L601
train
gocql/gocql
host_source.go
GetHosts
func (r *ringDescriber) GetHosts() ([]*HostInfo, string, error) { r.mu.Lock() defer r.mu.Unlock() hosts, err := r.getClusterPeerInfo() if err != nil { return r.prevHosts, r.prevPartitioner, err } var partitioner string if len(hosts) > 0 { partitioner = hosts[0].Partitioner() } return hosts, partitioner,...
go
func (r *ringDescriber) GetHosts() ([]*HostInfo, string, error) { r.mu.Lock() defer r.mu.Unlock() hosts, err := r.getClusterPeerInfo() if err != nil { return r.prevHosts, r.prevPartitioner, err } var partitioner string if len(hosts) > 0 { partitioner = hosts[0].Partitioner() } return hosts, partitioner,...
[ "func", "(", "r", "*", "ringDescriber", ")", "GetHosts", "(", ")", "(", "[", "]", "*", "HostInfo", ",", "string", ",", "error", ")", "{", "r", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "...
// Return a list of hosts the cluster knows about
[ "Return", "a", "list", "of", "hosts", "the", "cluster", "knows", "about" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/host_source.go#L604-L619
train
gocql/gocql
conn.go
JoinHostPort
func JoinHostPort(addr string, port int) string { addr = strings.TrimSpace(addr) if _, _, err := net.SplitHostPort(addr); err != nil { addr = net.JoinHostPort(addr, strconv.Itoa(port)) } return addr }
go
func JoinHostPort(addr string, port int) string { addr = strings.TrimSpace(addr) if _, _, err := net.SplitHostPort(addr); err != nil { addr = net.JoinHostPort(addr, strconv.Itoa(port)) } return addr }
[ "func", "JoinHostPort", "(", "addr", "string", ",", "port", "int", ")", "string", "{", "addr", "=", "strings", ".", "TrimSpace", "(", "addr", ")", "\n", "if", "_", ",", "_", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "addr", ")", ";", "err...
//JoinHostPort is a utility to return a address string that can be used //gocql.Conn to form a connection with a host.
[ "JoinHostPort", "is", "a", "utility", "to", "return", "a", "address", "string", "that", "can", "be", "used", "gocql", ".", "Conn", "to", "form", "a", "connection", "with", "a", "host", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/conn.go#L46-L52
train
gocql/gocql
conn.go
connect
func (s *Session) connect(host *HostInfo, errorHandler ConnErrorHandler) (*Conn, error) { return s.dial(host, s.connCfg, errorHandler) }
go
func (s *Session) connect(host *HostInfo, errorHandler ConnErrorHandler) (*Conn, error) { return s.dial(host, s.connCfg, errorHandler) }
[ "func", "(", "s", "*", "Session", ")", "connect", "(", "host", "*", "HostInfo", ",", "errorHandler", "ConnErrorHandler", ")", "(", "*", "Conn", ",", "error", ")", "{", "return", "s", ".", "dial", "(", "host", ",", "s", ".", "connCfg", ",", "errorHand...
// connect establishes a connection to a Cassandra node using session's connection config.
[ "connect", "establishes", "a", "connection", "to", "a", "Cassandra", "node", "using", "session", "s", "connection", "config", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/conn.go#L163-L165
train
gocql/gocql
conn.go
dial
func (s *Session) dial(host *HostInfo, connConfig *ConnConfig, errorHandler ConnErrorHandler) (*Conn, error) { var obs ObservedConnect if s.connectObserver != nil { obs.Host = host obs.Start = time.Now() } conn, err := s.dialWithoutObserver(host, connConfig, errorHandler) if s.connectObserver != nil { obs....
go
func (s *Session) dial(host *HostInfo, connConfig *ConnConfig, errorHandler ConnErrorHandler) (*Conn, error) { var obs ObservedConnect if s.connectObserver != nil { obs.Host = host obs.Start = time.Now() } conn, err := s.dialWithoutObserver(host, connConfig, errorHandler) if s.connectObserver != nil { obs....
[ "func", "(", "s", "*", "Session", ")", "dial", "(", "host", "*", "HostInfo", ",", "connConfig", "*", "ConnConfig", ",", "errorHandler", "ConnErrorHandler", ")", "(", "*", "Conn", ",", "error", ")", "{", "var", "obs", "ObservedConnect", "\n", "if", "s", ...
// dial establishes a connection to a Cassandra node and notifies the session's connectObserver.
[ "dial", "establishes", "a", "connection", "to", "a", "Cassandra", "node", "and", "notifies", "the", "session", "s", "connectObserver", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/conn.go#L168-L184
train
gocql/gocql
conn.go
serve
func (c *Conn) serve() { var err error for err == nil { err = c.recv() } c.closeWithError(err) }
go
func (c *Conn) serve() { var err error for err == nil { err = c.recv() } c.closeWithError(err) }
[ "func", "(", "c", "*", "Conn", ")", "serve", "(", ")", "{", "var", "err", "error", "\n", "for", "err", "==", "nil", "{", "err", "=", "c", ".", "recv", "(", ")", "\n", "}", "\n\n", "c", ".", "closeWithError", "(", "err", ")", "\n", "}" ]
// Serve starts the stream multiplexer for this connection, which is required // to execute any queries. This method runs as long as the connection is // open and is therefore usually called in a separate goroutine.
[ "Serve", "starts", "the", "stream", "multiplexer", "for", "this", "connection", "which", "is", "required", "to", "execute", "any", "queries", ".", "This", "method", "runs", "as", "long", "as", "the", "connection", "is", "open", "and", "is", "therefore", "usu...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/conn.go#L509-L516
train
gocql/gocql
token.go
ParseString
func (p murmur3Partitioner) ParseString(str string) token { val, _ := strconv.ParseInt(str, 10, 64) return murmur3Token(val) }
go
func (p murmur3Partitioner) ParseString(str string) token { val, _ := strconv.ParseInt(str, 10, 64) return murmur3Token(val) }
[ "func", "(", "p", "murmur3Partitioner", ")", "ParseString", "(", "str", "string", ")", "token", "{", "val", ",", "_", ":=", "strconv", ".", "ParseInt", "(", "str", ",", "10", ",", "64", ")", "\n", "return", "murmur3Token", "(", "val", ")", "\n", "}" ...
// murmur3 little-endian, 128-bit hash, but returns only h1
[ "murmur3", "little", "-", "endian", "128", "-", "bit", "hash", "but", "returns", "only", "h1" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/token.go#L46-L49
train
gocql/gocql
events.go
flush
func (e *eventDebouncer) flush() { if len(e.events) == 0 { return } // if the flush interval is faster than the callback then we will end up calling // the callback multiple times, probably a bad idea. In this case we could drop // frames? go e.callback(e.events) e.events = make([]frame, 0, eventBufferSize) }
go
func (e *eventDebouncer) flush() { if len(e.events) == 0 { return } // if the flush interval is faster than the callback then we will end up calling // the callback multiple times, probably a bad idea. In this case we could drop // frames? go e.callback(e.events) e.events = make([]frame, 0, eventBufferSize) }
[ "func", "(", "e", "*", "eventDebouncer", ")", "flush", "(", ")", "{", "if", "len", "(", "e", ".", "events", ")", "==", "0", "{", "return", "\n", "}", "\n\n", "// if the flush interval is faster than the callback then we will end up calling", "// the callback multipl...
// flush must be called with mu locked
[ "flush", "must", "be", "called", "with", "mu", "locked" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/events.go#L56-L66
train
gocql/gocql
uuid.go
UUIDFromBytes
func UUIDFromBytes(input []byte) (UUID, error) { var u UUID if len(input) != 16 { return u, errors.New("UUIDs must be exactly 16 bytes long") } copy(u[:], input) return u, nil }
go
func UUIDFromBytes(input []byte) (UUID, error) { var u UUID if len(input) != 16 { return u, errors.New("UUIDs must be exactly 16 bytes long") } copy(u[:], input) return u, nil }
[ "func", "UUIDFromBytes", "(", "input", "[", "]", "byte", ")", "(", "UUID", ",", "error", ")", "{", "var", "u", "UUID", "\n", "if", "len", "(", "input", ")", "!=", "16", "{", "return", "u", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", ...
// UUIDFromBytes converts a raw byte slice to an UUID.
[ "UUIDFromBytes", "converts", "a", "raw", "byte", "slice", "to", "an", "UUID", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/uuid.go#L88-L96
train
gocql/gocql
uuid.go
Variant
func (u UUID) Variant() int { x := u[8] if x&0x80 == 0 { return VariantNCSCompat } if x&0x40 == 0 { return VariantIETF } if x&0x20 == 0 { return VariantMicrosoft } return VariantFuture }
go
func (u UUID) Variant() int { x := u[8] if x&0x80 == 0 { return VariantNCSCompat } if x&0x40 == 0 { return VariantIETF } if x&0x20 == 0 { return VariantMicrosoft } return VariantFuture }
[ "func", "(", "u", "UUID", ")", "Variant", "(", ")", "int", "{", "x", ":=", "u", "[", "8", "]", "\n", "if", "x", "&", "0x80", "==", "0", "{", "return", "VariantNCSCompat", "\n", "}", "\n", "if", "x", "&", "0x40", "==", "0", "{", "return", "Var...
// Variant returns the variant of this UUID. This package will only generate // UUIDs in the IETF variant.
[ "Variant", "returns", "the", "variant", "of", "this", "UUID", ".", "This", "package", "will", "only", "generate", "UUIDs", "in", "the", "IETF", "variant", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/uuid.go#L182-L194
train
gocql/gocql
uuid.go
Time
func (u UUID) Time() time.Time { if u.Version() != 1 { return time.Time{} } t := u.Timestamp() sec := t / 1e7 nsec := (t % 1e7) * 100 return time.Unix(sec+timeBase, nsec).UTC() }
go
func (u UUID) Time() time.Time { if u.Version() != 1 { return time.Time{} } t := u.Timestamp() sec := t / 1e7 nsec := (t % 1e7) * 100 return time.Unix(sec+timeBase, nsec).UTC() }
[ "func", "(", "u", "UUID", ")", "Time", "(", ")", "time", ".", "Time", "{", "if", "u", ".", "Version", "(", ")", "!=", "1", "{", "return", "time", ".", "Time", "{", "}", "\n", "}", "\n", "t", ":=", "u", ".", "Timestamp", "(", ")", "\n", "sec...
// Time is like Timestamp, except that it returns a time.Time.
[ "Time", "is", "like", "Timestamp", "except", "that", "it", "returns", "a", "time", ".", "Time", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/uuid.go#L235-L243
train
gocql/gocql
uuid.go
UnmarshalJSON
func (u *UUID) UnmarshalJSON(data []byte) error { str := strings.Trim(string(data), `"`) if len(str) > 36 { return fmt.Errorf("invalid JSON UUID %s", str) } parsed, err := ParseUUID(str) if err == nil { copy(u[:], parsed[:]) } return err }
go
func (u *UUID) UnmarshalJSON(data []byte) error { str := strings.Trim(string(data), `"`) if len(str) > 36 { return fmt.Errorf("invalid JSON UUID %s", str) } parsed, err := ParseUUID(str) if err == nil { copy(u[:], parsed[:]) } return err }
[ "func", "(", "u", "*", "UUID", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "str", ":=", "strings", ".", "Trim", "(", "string", "(", "data", ")", ",", "`\"`", ")", "\n", "if", "len", "(", "str", ")", ">", "36", "{", ...
// Unmarshaling for JSON
[ "Unmarshaling", "for", "JSON" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/uuid.go#L251-L263
train
gocql/gocql
metadata.go
newSchemaDescriber
func newSchemaDescriber(session *Session) *schemaDescriber { return &schemaDescriber{ session: session, cache: map[string]*KeyspaceMetadata{}, } }
go
func newSchemaDescriber(session *Session) *schemaDescriber { return &schemaDescriber{ session: session, cache: map[string]*KeyspaceMetadata{}, } }
[ "func", "newSchemaDescriber", "(", "session", "*", "Session", ")", "*", "schemaDescriber", "{", "return", "&", "schemaDescriber", "{", "session", ":", "session", ",", "cache", ":", "map", "[", "string", "]", "*", "KeyspaceMetadata", "{", "}", ",", "}", "\n...
// creates a session bound schema describer which will query and cache // keyspace metadata
[ "creates", "a", "session", "bound", "schema", "describer", "which", "will", "query", "and", "cache", "keyspace", "metadata" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/metadata.go#L183-L188
train
gocql/gocql
metadata.go
getSchema
func (s *schemaDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, error) { s.mu.Lock() defer s.mu.Unlock() metadata, found := s.cache[keyspaceName] if !found { // refresh the cache for this keyspace err := s.refreshSchema(keyspaceName) if err != nil { return nil, err } metadata = s.cache[k...
go
func (s *schemaDescriber) getSchema(keyspaceName string) (*KeyspaceMetadata, error) { s.mu.Lock() defer s.mu.Unlock() metadata, found := s.cache[keyspaceName] if !found { // refresh the cache for this keyspace err := s.refreshSchema(keyspaceName) if err != nil { return nil, err } metadata = s.cache[k...
[ "func", "(", "s", "*", "schemaDescriber", ")", "getSchema", "(", "keyspaceName", "string", ")", "(", "*", "KeyspaceMetadata", ",", "error", ")", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n...
// returns the cached KeyspaceMetadata held by the describer for the named // keyspace.
[ "returns", "the", "cached", "KeyspaceMetadata", "held", "by", "the", "describer", "for", "the", "named", "keyspace", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/metadata.go#L192-L208
train
gocql/gocql
metadata.go
clearSchema
func (s *schemaDescriber) clearSchema(keyspaceName string) { s.mu.Lock() defer s.mu.Unlock() delete(s.cache, keyspaceName) }
go
func (s *schemaDescriber) clearSchema(keyspaceName string) { s.mu.Lock() defer s.mu.Unlock() delete(s.cache, keyspaceName) }
[ "func", "(", "s", "*", "schemaDescriber", ")", "clearSchema", "(", "keyspaceName", "string", ")", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "delete", "(", "s", ".", "cache", ",", "...
// clears the already cached keyspace metadata
[ "clears", "the", "already", "cached", "keyspace", "metadata" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/metadata.go#L211-L216
train
gocql/gocql
metadata.go
refreshSchema
func (s *schemaDescriber) refreshSchema(keyspaceName string) error { var err error // query the system keyspace for schema data // TODO retrieve concurrently keyspace, err := getKeyspaceMetadata(s.session, keyspaceName) if err != nil { return err } tables, err := getTableMetadata(s.session, keyspaceName) if ...
go
func (s *schemaDescriber) refreshSchema(keyspaceName string) error { var err error // query the system keyspace for schema data // TODO retrieve concurrently keyspace, err := getKeyspaceMetadata(s.session, keyspaceName) if err != nil { return err } tables, err := getTableMetadata(s.session, keyspaceName) if ...
[ "func", "(", "s", "*", "schemaDescriber", ")", "refreshSchema", "(", "keyspaceName", "string", ")", "error", "{", "var", "err", "error", "\n\n", "// query the system keyspace for schema data", "// TODO retrieve concurrently", "keyspace", ",", "err", ":=", "getKeyspaceMe...
// forcibly updates the current KeyspaceMetadata held by the schema describer // for a given named keyspace.
[ "forcibly", "updates", "the", "current", "KeyspaceMetadata", "held", "by", "the", "schema", "describer", "for", "a", "given", "named", "keyspace", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/metadata.go#L220-L257
train
gocql/gocql
metadata.go
compileMetadata
func compileMetadata( protoVersion int, keyspace *KeyspaceMetadata, tables []TableMetadata, columns []ColumnMetadata, functions []FunctionMetadata, aggregates []AggregateMetadata, views []ViewMetadata, ) { keyspace.Tables = make(map[string]*TableMetadata) for i := range tables { tables[i].Columns = make(map[...
go
func compileMetadata( protoVersion int, keyspace *KeyspaceMetadata, tables []TableMetadata, columns []ColumnMetadata, functions []FunctionMetadata, aggregates []AggregateMetadata, views []ViewMetadata, ) { keyspace.Tables = make(map[string]*TableMetadata) for i := range tables { tables[i].Columns = make(map[...
[ "func", "compileMetadata", "(", "protoVersion", "int", ",", "keyspace", "*", "KeyspaceMetadata", ",", "tables", "[", "]", "TableMetadata", ",", "columns", "[", "]", "ColumnMetadata", ",", "functions", "[", "]", "FunctionMetadata", ",", "aggregates", "[", "]", ...
// "compiles" derived information about keyspace, table, and column metadata // for a keyspace from the basic queried metadata objects returned by // getKeyspaceMetadata, getTableMetadata, and getColumnMetadata respectively; // Links the metadata objects together and derives the column composition of // the partition k...
[ "compiles", "derived", "information", "about", "keyspace", "table", "and", "column", "metadata", "for", "a", "keyspace", "from", "the", "basic", "queried", "metadata", "objects", "returned", "by", "getKeyspaceMetadata", "getTableMetadata", "and", "getColumnMetadata", ...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/metadata.go#L264-L331
train
gocql/gocql
metadata.go
compileV2Metadata
func compileV2Metadata(tables []TableMetadata) { for i := range tables { table := &tables[i] clusteringColumnCount := componentColumnCountOfType(table.Columns, ColumnClusteringKey) table.ClusteringColumns = make([]*ColumnMetadata, clusteringColumnCount) if table.KeyValidator != "" { keyValidatorParsed := ...
go
func compileV2Metadata(tables []TableMetadata) { for i := range tables { table := &tables[i] clusteringColumnCount := componentColumnCountOfType(table.Columns, ColumnClusteringKey) table.ClusteringColumns = make([]*ColumnMetadata, clusteringColumnCount) if table.KeyValidator != "" { keyValidatorParsed := ...
[ "func", "compileV2Metadata", "(", "tables", "[", "]", "TableMetadata", ")", "{", "for", "i", ":=", "range", "tables", "{", "table", ":=", "&", "tables", "[", "i", "]", "\n\n", "clusteringColumnCount", ":=", "componentColumnCountOfType", "(", "table", ".", "C...
// The simpler compile case for V2+ protocol
[ "The", "simpler", "compile", "case", "for", "V2", "+", "protocol" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/metadata.go#L445-L469
train
gocql/gocql
metadata.go
componentColumnCountOfType
func componentColumnCountOfType(columns map[string]*ColumnMetadata, kind ColumnKind) int { maxComponentIndex := -1 for _, column := range columns { if column.Kind == kind && column.ComponentIndex > maxComponentIndex { maxComponentIndex = column.ComponentIndex } } return maxComponentIndex + 1 }
go
func componentColumnCountOfType(columns map[string]*ColumnMetadata, kind ColumnKind) int { maxComponentIndex := -1 for _, column := range columns { if column.Kind == kind && column.ComponentIndex > maxComponentIndex { maxComponentIndex = column.ComponentIndex } } return maxComponentIndex + 1 }
[ "func", "componentColumnCountOfType", "(", "columns", "map", "[", "string", "]", "*", "ColumnMetadata", ",", "kind", "ColumnKind", ")", "int", "{", "maxComponentIndex", ":=", "-", "1", "\n", "for", "_", ",", "column", ":=", "range", "columns", "{", "if", "...
// returns the count of coluns with the given "kind" value.
[ "returns", "the", "count", "of", "coluns", "with", "the", "given", "kind", "value", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/metadata.go#L472-L480
train
gocql/gocql
metadata.go
getKeyspaceMetadata
func getKeyspaceMetadata(session *Session, keyspaceName string) (*KeyspaceMetadata, error) { keyspace := &KeyspaceMetadata{Name: keyspaceName} if session.useSystemSchema { // Cassandra 3.x+ const stmt = ` SELECT durable_writes, replication FROM system_schema.keyspaces WHERE keyspace_name = ?` var replicat...
go
func getKeyspaceMetadata(session *Session, keyspaceName string) (*KeyspaceMetadata, error) { keyspace := &KeyspaceMetadata{Name: keyspaceName} if session.useSystemSchema { // Cassandra 3.x+ const stmt = ` SELECT durable_writes, replication FROM system_schema.keyspaces WHERE keyspace_name = ?` var replicat...
[ "func", "getKeyspaceMetadata", "(", "session", "*", "Session", ",", "keyspaceName", "string", ")", "(", "*", "KeyspaceMetadata", ",", "error", ")", "{", "keyspace", ":=", "&", "KeyspaceMetadata", "{", "Name", ":", "keyspaceName", "}", "\n\n", "if", "session", ...
// query only for the keyspace metadata for the specified keyspace from system.schema_keyspace
[ "query", "only", "for", "the", "keyspace", "metadata", "for", "the", "specified", "keyspace", "from", "system", ".", "schema_keyspace" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/metadata.go#L483-L540
train
gocql/gocql
metadata.go
getColumnMetadata
func getColumnMetadata(session *Session, keyspaceName string) ([]ColumnMetadata, error) { var ( columns []ColumnMetadata err error ) // Deal with differences in protocol versions if session.cfg.ProtoVersion == 1 { columns, err = session.scanColumnMetadataV1(keyspaceName) } else if session.useSystemSchem...
go
func getColumnMetadata(session *Session, keyspaceName string) ([]ColumnMetadata, error) { var ( columns []ColumnMetadata err error ) // Deal with differences in protocol versions if session.cfg.ProtoVersion == 1 { columns, err = session.scanColumnMetadataV1(keyspaceName) } else if session.useSystemSchem...
[ "func", "getColumnMetadata", "(", "session", "*", "Session", ",", "keyspaceName", "string", ")", "(", "[", "]", "ColumnMetadata", ",", "error", ")", "{", "var", "(", "columns", "[", "]", "ColumnMetadata", "\n", "err", "error", "\n", ")", "\n\n", "// Deal w...
// query for only the column metadata in the specified keyspace from system.schema_columns
[ "query", "for", "only", "the", "column", "metadata", "in", "the", "specified", "keyspace", "from", "system", ".", "schema_columns" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/metadata.go#L841-L861
train
gocql/gocql
metadata.go
parseType
func parseType(def string) typeParserResult { parser := &typeParser{input: def} return parser.parse() }
go
func parseType(def string) typeParserResult { parser := &typeParser{input: def} return parser.parse() }
[ "func", "parseType", "(", "def", "string", ")", "typeParserResult", "{", "parser", ":=", "&", "typeParser", "{", "input", ":", "def", "}", "\n", "return", "parser", ".", "parse", "(", ")", "\n", "}" ]
// Parse the type definition used for validator and comparator schema data
[ "Parse", "the", "type", "definition", "used", "for", "validator", "and", "comparator", "schema", "data" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/metadata.go#L1043-L1046
train
gocql/gocql
connectionpool.go
Pick
func (pool *hostConnPool) Pick() *Conn { pool.mu.RLock() defer pool.mu.RUnlock() if pool.closed { return nil } size := len(pool.conns) if size < pool.size { // try to fill the pool go pool.fill() if size == 0 { return nil } } pos := int(atomic.AddUint32(&pool.pos, 1) - 1) var ( leastBusyCon...
go
func (pool *hostConnPool) Pick() *Conn { pool.mu.RLock() defer pool.mu.RUnlock() if pool.closed { return nil } size := len(pool.conns) if size < pool.size { // try to fill the pool go pool.fill() if size == 0 { return nil } } pos := int(atomic.AddUint32(&pool.pos, 1) - 1) var ( leastBusyCon...
[ "func", "(", "pool", "*", "hostConnPool", ")", "Pick", "(", ")", "*", "Conn", "{", "pool", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "pool", ".", "mu", ".", "RUnlock", "(", ")", "\n\n", "if", "pool", ".", "closed", "{", "return", "nil", ...
// Pick a connection from this connection pool for the given query.
[ "Pick", "a", "connection", "from", "this", "connection", "pool", "for", "the", "given", "query", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/connectionpool.go#L297-L332
train
gocql/gocql
connectionpool.go
Size
func (pool *hostConnPool) Size() int { pool.mu.RLock() defer pool.mu.RUnlock() return len(pool.conns) }
go
func (pool *hostConnPool) Size() int { pool.mu.RLock() defer pool.mu.RUnlock() return len(pool.conns) }
[ "func", "(", "pool", "*", "hostConnPool", ")", "Size", "(", ")", "int", "{", "pool", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "pool", ".", "mu", ".", "RUnlock", "(", ")", "\n\n", "return", "len", "(", "pool", ".", "conns", ")", "\n", "...
//Size returns the number of connections currently active in the pool
[ "Size", "returns", "the", "number", "of", "connections", "currently", "active", "in", "the", "pool" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/connectionpool.go#L335-L340
train
gocql/gocql
connectionpool.go
Close
func (pool *hostConnPool) Close() { pool.mu.Lock() if pool.closed { pool.mu.Unlock() return } pool.closed = true // ensure we dont try to reacquire the lock in handleError // TODO: improve this as the following can happen // 1) we have locked pool.mu write lock // 2) conn.Close calls conn.closeWithError(n...
go
func (pool *hostConnPool) Close() { pool.mu.Lock() if pool.closed { pool.mu.Unlock() return } pool.closed = true // ensure we dont try to reacquire the lock in handleError // TODO: improve this as the following can happen // 1) we have locked pool.mu write lock // 2) conn.Close calls conn.closeWithError(n...
[ "func", "(", "pool", "*", "hostConnPool", ")", "Close", "(", ")", "{", "pool", ".", "mu", ".", "Lock", "(", ")", "\n\n", "if", "pool", ".", "closed", "{", "pool", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "\n", "}", "\n", "pool", ".",...
//Close the connection pool
[ "Close", "the", "connection", "pool" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/connectionpool.go#L343-L371
train
gocql/gocql
connectionpool.go
fill
func (pool *hostConnPool) fill() { pool.mu.RLock() // avoid filling a closed pool, or concurrent filling if pool.closed || pool.filling { pool.mu.RUnlock() return } // determine the filling work to be done startCount := len(pool.conns) fillCount := pool.size - startCount // avoid filling a full (or overfu...
go
func (pool *hostConnPool) fill() { pool.mu.RLock() // avoid filling a closed pool, or concurrent filling if pool.closed || pool.filling { pool.mu.RUnlock() return } // determine the filling work to be done startCount := len(pool.conns) fillCount := pool.size - startCount // avoid filling a full (or overfu...
[ "func", "(", "pool", "*", "hostConnPool", ")", "fill", "(", ")", "{", "pool", ".", "mu", ".", "RLock", "(", ")", "\n", "// avoid filling a closed pool, or concurrent filling", "if", "pool", ".", "closed", "||", "pool", ".", "filling", "{", "pool", ".", "mu...
// Fill the connection pool
[ "Fill", "the", "connection", "pool" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/connectionpool.go#L374-L443
train
gocql/gocql
connectionpool.go
fillingStopped
func (pool *hostConnPool) fillingStopped(hadError bool) { if hadError { // wait for some time to avoid back-to-back filling // this provides some time between failed attempts // to fill the pool for the host to recover time.Sleep(time.Duration(rand.Int31n(100)+31) * time.Millisecond) } pool.mu.Lock() pool....
go
func (pool *hostConnPool) fillingStopped(hadError bool) { if hadError { // wait for some time to avoid back-to-back filling // this provides some time between failed attempts // to fill the pool for the host to recover time.Sleep(time.Duration(rand.Int31n(100)+31) * time.Millisecond) } pool.mu.Lock() pool....
[ "func", "(", "pool", "*", "hostConnPool", ")", "fillingStopped", "(", "hadError", "bool", ")", "{", "if", "hadError", "{", "// wait for some time to avoid back-to-back filling", "// this provides some time between failed attempts", "// to fill the pool for the host to recover", "...
// transition back to a not-filling state.
[ "transition", "back", "to", "a", "not", "-", "filling", "state", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/connectionpool.go#L459-L470
train
gocql/gocql
connectionpool.go
connectMany
func (pool *hostConnPool) connectMany(count int) error { if count == 0 { return nil } var ( wg sync.WaitGroup mu sync.Mutex connectErr error ) wg.Add(count) for i := 0; i < count; i++ { go func() { defer wg.Done() err := pool.connect() pool.logConnectErr(err) if err != nil { ...
go
func (pool *hostConnPool) connectMany(count int) error { if count == 0 { return nil } var ( wg sync.WaitGroup mu sync.Mutex connectErr error ) wg.Add(count) for i := 0; i < count; i++ { go func() { defer wg.Done() err := pool.connect() pool.logConnectErr(err) if err != nil { ...
[ "func", "(", "pool", "*", "hostConnPool", ")", "connectMany", "(", "count", "int", ")", "error", "{", "if", "count", "==", "0", "{", "return", "nil", "\n", "}", "\n", "var", "(", "wg", "sync", ".", "WaitGroup", "\n", "mu", "sync", ".", "Mutex", "\n...
// connectMany creates new connections concurrent.
[ "connectMany", "creates", "new", "connections", "concurrent", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/connectionpool.go#L473-L499
train
gocql/gocql
connectionpool.go
connect
func (pool *hostConnPool) connect() (err error) { // TODO: provide a more robust connection retry mechanism, we should also // be able to detect hosts that come up by trying to connect to downed ones. // try to connect var conn *Conn reconnectionPolicy := pool.session.cfg.ReconnectionPolicy for i := 0; i < reconn...
go
func (pool *hostConnPool) connect() (err error) { // TODO: provide a more robust connection retry mechanism, we should also // be able to detect hosts that come up by trying to connect to downed ones. // try to connect var conn *Conn reconnectionPolicy := pool.session.cfg.ReconnectionPolicy for i := 0; i < reconn...
[ "func", "(", "pool", "*", "hostConnPool", ")", "connect", "(", ")", "(", "err", "error", ")", "{", "// TODO: provide a more robust connection retry mechanism, we should also", "// be able to detect hosts that come up by trying to connect to downed ones.", "// try to connect", "var"...
// create a new connection to the host and add it to the pool
[ "create", "a", "new", "connection", "to", "the", "host", "and", "add", "it", "to", "the", "pool" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/connectionpool.go#L502-L551
train
gocql/gocql
connectionpool.go
HandleError
func (pool *hostConnPool) HandleError(conn *Conn, err error, closed bool) { if !closed { // still an open connection, so continue using it return } // TODO: track the number of errors per host and detect when a host is dead, // then also have something which can detect when a host comes back. pool.mu.Lock() ...
go
func (pool *hostConnPool) HandleError(conn *Conn, err error, closed bool) { if !closed { // still an open connection, so continue using it return } // TODO: track the number of errors per host and detect when a host is dead, // then also have something which can detect when a host comes back. pool.mu.Lock() ...
[ "func", "(", "pool", "*", "hostConnPool", ")", "HandleError", "(", "conn", "*", "Conn", ",", "err", "error", ",", "closed", "bool", ")", "{", "if", "!", "closed", "{", "// still an open connection, so continue using it", "return", "\n", "}", "\n\n", "// TODO: ...
// handle any error from a Conn
[ "handle", "any", "error", "from", "a", "Conn" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/connectionpool.go#L554-L581
train
gocql/gocql
marshal.go
Marshal
func Marshal(info TypeInfo, value interface{}) ([]byte, error) { if info.Version() < protoVersion1 { panic("protocol version not set") } if valueRef := reflect.ValueOf(value); valueRef.Kind() == reflect.Ptr { if valueRef.IsNil() { return nil, nil } else if v, ok := value.(Marshaler); ok { return v.Marsh...
go
func Marshal(info TypeInfo, value interface{}) ([]byte, error) { if info.Version() < protoVersion1 { panic("protocol version not set") } if valueRef := reflect.ValueOf(value); valueRef.Kind() == reflect.Ptr { if valueRef.IsNil() { return nil, nil } else if v, ok := value.(Marshaler); ok { return v.Marsh...
[ "func", "Marshal", "(", "info", "TypeInfo", ",", "value", "interface", "{", "}", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "info", ".", "Version", "(", ")", "<", "protoVersion1", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\...
// Marshal returns the CQL encoding of the value for the Cassandra // internal type described by the info parameter.
[ "Marshal", "returns", "the", "CQL", "encoding", "of", "the", "value", "for", "the", "Cassandra", "internal", "type", "described", "by", "the", "info", "parameter", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/marshal.go#L47-L116
train
gocql/gocql
marshal.go
Unmarshal
func Unmarshal(info TypeInfo, data []byte, value interface{}) error { if v, ok := value.(Unmarshaler); ok { return v.UnmarshalCQL(info, data) } if isNullableValue(value) { return unmarshalNullable(info, data, value) } switch info.Type() { case TypeVarchar, TypeAscii, TypeBlob, TypeText: return unmarshalVa...
go
func Unmarshal(info TypeInfo, data []byte, value interface{}) error { if v, ok := value.(Unmarshaler); ok { return v.UnmarshalCQL(info, data) } if isNullableValue(value) { return unmarshalNullable(info, data, value) } switch info.Type() { case TypeVarchar, TypeAscii, TypeBlob, TypeText: return unmarshalVa...
[ "func", "Unmarshal", "(", "info", "TypeInfo", ",", "data", "[", "]", "byte", ",", "value", "interface", "{", "}", ")", "error", "{", "if", "v", ",", "ok", ":=", "value", ".", "(", "Unmarshaler", ")", ";", "ok", "{", "return", "v", ".", "UnmarshalCQ...
// Unmarshal parses the CQL encoded data based on the info parameter that // describes the Cassandra internal data type and stores the result in the // value pointed by value.
[ "Unmarshal", "parses", "the", "CQL", "encoded", "data", "based", "on", "the", "info", "parameter", "that", "describes", "the", "Cassandra", "internal", "data", "type", "and", "stores", "the", "result", "in", "the", "value", "pointed", "by", "value", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/marshal.go#L121-L182
train
gocql/gocql
marshal.go
encBigInt2C
func encBigInt2C(n *big.Int) []byte { switch n.Sign() { case 0: return []byte{0} case 1: b := n.Bytes() if b[0]&0x80 > 0 { b = append([]byte{0}, b...) } return b case -1: length := uint(n.BitLen()/8+1) * 8 b := new(big.Int).Add(n, new(big.Int).Lsh(bigOne, length)).Bytes() // When the most signifi...
go
func encBigInt2C(n *big.Int) []byte { switch n.Sign() { case 0: return []byte{0} case 1: b := n.Bytes() if b[0]&0x80 > 0 { b = append([]byte{0}, b...) } return b case -1: length := uint(n.BitLen()/8+1) * 8 b := new(big.Int).Add(n, new(big.Int).Lsh(bigOne, length)).Bytes() // When the most signifi...
[ "func", "encBigInt2C", "(", "n", "*", "big", ".", "Int", ")", "[", "]", "byte", "{", "switch", "n", ".", "Sign", "(", ")", "{", "case", "0", ":", "return", "[", "]", "byte", "{", "0", "}", "\n", "case", "1", ":", "b", ":=", "n", ".", "Bytes...
// encBigInt2C returns the big-endian two's complement // form of n.
[ "encBigInt2C", "returns", "the", "big", "-", "endian", "two", "s", "complement", "form", "of", "n", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/marshal.go#L1073-L1095
train
gocql/gocql
marshal.go
unmarshalTuple
func unmarshalTuple(info TypeInfo, data []byte, value interface{}) error { if v, ok := value.(Unmarshaler); ok { return v.UnmarshalCQL(info, data) } tuple := info.(TupleTypeInfo) switch v := value.(type) { case []interface{}: for i, elem := range tuple.Elems { // each element inside data is a [bytes] va...
go
func unmarshalTuple(info TypeInfo, data []byte, value interface{}) error { if v, ok := value.(Unmarshaler); ok { return v.UnmarshalCQL(info, data) } tuple := info.(TupleTypeInfo) switch v := value.(type) { case []interface{}: for i, elem := range tuple.Elems { // each element inside data is a [bytes] va...
[ "func", "unmarshalTuple", "(", "info", "TypeInfo", ",", "data", "[", "]", "byte", ",", "value", "interface", "{", "}", ")", "error", "{", "if", "v", ",", "ok", ":=", "value", ".", "(", "Unmarshaler", ")", ";", "ok", "{", "return", "v", ".", "Unmars...
// currently only support unmarshal into a list of values, this makes it possible // to support tuples without changing the query API. In the future this can be extend // to allow unmarshalling into custom tuple types.
[ "currently", "only", "support", "unmarshal", "into", "a", "list", "of", "values", "this", "makes", "it", "possible", "to", "support", "tuples", "without", "changing", "the", "query", "API", ".", "In", "the", "future", "this", "can", "be", "extend", "to", "...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/marshal.go#L1867-L1945
train
gocql/gocql
marshal.go
String
func (t Type) String() string { switch t { case TypeCustom: return "custom" case TypeAscii: return "ascii" case TypeBigInt: return "bigint" case TypeBlob: return "blob" case TypeBoolean: return "boolean" case TypeCounter: return "counter" case TypeDecimal: return "decimal" case TypeDouble: retu...
go
func (t Type) String() string { switch t { case TypeCustom: return "custom" case TypeAscii: return "ascii" case TypeBigInt: return "bigint" case TypeBlob: return "blob" case TypeBoolean: return "boolean" case TypeCounter: return "counter" case TypeDecimal: return "decimal" case TypeDouble: retu...
[ "func", "(", "t", "Type", ")", "String", "(", ")", "string", "{", "switch", "t", "{", "case", "TypeCustom", ":", "return", "\"", "\"", "\n", "case", "TypeAscii", ":", "return", "\"", "\"", "\n", "case", "TypeBigInt", ":", "return", "\"", "\"", "\n", ...
// String returns the name of the identifier.
[ "String", "returns", "the", "name", "of", "the", "identifier", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/marshal.go#L2326-L2383
train
gocql/gocql
policies.go
add
func (c *cowHostList) add(host *HostInfo) bool { c.mu.Lock() l := c.get() if n := len(l); n == 0 { l = []*HostInfo{host} } else { newL := make([]*HostInfo, n+1) for i := 0; i < n; i++ { if host.Equal(l[i]) { c.mu.Unlock() return false } newL[i] = l[i] } newL[n] = host l = newL } c.l...
go
func (c *cowHostList) add(host *HostInfo) bool { c.mu.Lock() l := c.get() if n := len(l); n == 0 { l = []*HostInfo{host} } else { newL := make([]*HostInfo, n+1) for i := 0; i < n; i++ { if host.Equal(l[i]) { c.mu.Unlock() return false } newL[i] = l[i] } newL[n] = host l = newL } c.l...
[ "func", "(", "c", "*", "cowHostList", ")", "add", "(", "host", "*", "HostInfo", ")", "bool", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "l", ":=", "c", ".", "get", "(", ")", "\n\n", "if", "n", ":=", "len", "(", "l", ")", ";", "n", ...
// add will add a host if it not already in the list
[ "add", "will", "add", "a", "host", "if", "it", "not", "already", "in", "the", "list" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/policies.go#L47-L69
train
gocql/gocql
policies.go
Attempt
func (s *SimpleRetryPolicy) Attempt(q RetryableQuery) bool { return q.Attempts() <= s.NumRetries }
go
func (s *SimpleRetryPolicy) Attempt(q RetryableQuery) bool { return q.Attempts() <= s.NumRetries }
[ "func", "(", "s", "*", "SimpleRetryPolicy", ")", "Attempt", "(", "q", "RetryableQuery", ")", "bool", "{", "return", "q", ".", "Attempts", "(", ")", "<=", "s", ".", "NumRetries", "\n", "}" ]
// Attempt tells gocql to attempt the query again based on query.Attempts being less // than the NumRetries defined in the policy.
[ "Attempt", "tells", "gocql", "to", "attempt", "the", "query", "again", "based", "on", "query", ".", "Attempts", "being", "less", "than", "the", "NumRetries", "defined", "in", "the", "policy", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/policies.go#L179-L181
train
gocql/gocql
policies.go
getExponentialTime
func getExponentialTime(min time.Duration, max time.Duration, attempts int) time.Duration { if min <= 0 { min = 100 * time.Millisecond } if max <= 0 { max = 10 * time.Second } minFloat := float64(min) napDuration := minFloat * math.Pow(2, float64(attempts-1)) // add some jitter napDuration += rand.Float64()...
go
func getExponentialTime(min time.Duration, max time.Duration, attempts int) time.Duration { if min <= 0 { min = 100 * time.Millisecond } if max <= 0 { max = 10 * time.Second } minFloat := float64(min) napDuration := minFloat * math.Pow(2, float64(attempts-1)) // add some jitter napDuration += rand.Float64()...
[ "func", "getExponentialTime", "(", "min", "time", ".", "Duration", ",", "max", "time", ".", "Duration", ",", "attempts", "int", ")", "time", ".", "Duration", "{", "if", "min", "<=", "0", "{", "min", "=", "100", "*", "time", ".", "Millisecond", "\n", ...
// used to calculate exponentially growing time
[ "used", "to", "calculate", "exponentially", "growing", "time" ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/policies.go#L202-L217
train
gocql/gocql
policies.go
TokenAwareHostPolicy
func TokenAwareHostPolicy(fallback HostSelectionPolicy, opts ...func(*tokenAwareHostPolicy)) HostSelectionPolicy { p := &tokenAwareHostPolicy{fallback: fallback} for _, opt := range opts { opt(p) } return p }
go
func TokenAwareHostPolicy(fallback HostSelectionPolicy, opts ...func(*tokenAwareHostPolicy)) HostSelectionPolicy { p := &tokenAwareHostPolicy{fallback: fallback} for _, opt := range opts { opt(p) } return p }
[ "func", "TokenAwareHostPolicy", "(", "fallback", "HostSelectionPolicy", ",", "opts", "...", "func", "(", "*", "tokenAwareHostPolicy", ")", ")", "HostSelectionPolicy", "{", "p", ":=", "&", "tokenAwareHostPolicy", "{", "fallback", ":", "fallback", "}", "\n", "for", ...
// TokenAwareHostPolicy is a token aware host selection policy, where hosts are // selected based on the partition key, so queries are sent to the host which // owns the partition. Fallback is used when routing information is not available.
[ "TokenAwareHostPolicy", "is", "a", "token", "aware", "host", "selection", "policy", "where", "hosts", "are", "selected", "based", "on", "the", "partition", "key", "so", "queries", "are", "sent", "to", "the", "host", "which", "owns", "the", "partition", ".", ...
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/policies.go#L393-L399
train
gocql/gocql
address_translators.go
IdentityTranslator
func IdentityTranslator() AddressTranslator { return AddressTranslatorFunc(func(addr net.IP, port int) (net.IP, int) { return addr, port }) }
go
func IdentityTranslator() AddressTranslator { return AddressTranslatorFunc(func(addr net.IP, port int) (net.IP, int) { return addr, port }) }
[ "func", "IdentityTranslator", "(", ")", "AddressTranslator", "{", "return", "AddressTranslatorFunc", "(", "func", "(", "addr", "net", ".", "IP", ",", "port", "int", ")", "(", "net", ".", "IP", ",", "int", ")", "{", "return", "addr", ",", "port", "\n", ...
// IdentityTranslator will do nothing but return what it was provided. It is essentially a no-op.
[ "IdentityTranslator", "will", "do", "nothing", "but", "return", "what", "it", "was", "provided", ".", "It", "is", "essentially", "a", "no", "-", "op", "." ]
b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac
https://github.com/gocql/gocql/blob/b99afaf3b1639e5264f5e1cabf04fdb2e5ed57ac/address_translators.go#L22-L26
train
denisenkom/go-mssqldb
tds.go
normalizeOdbcKey
func normalizeOdbcKey(s string) string { return strings.ToLower(strings.TrimRightFunc(s, unicode.IsSpace)) }
go
func normalizeOdbcKey(s string) string { return strings.ToLower(strings.TrimRightFunc(s, unicode.IsSpace)) }
[ "func", "normalizeOdbcKey", "(", "s", "string", ")", "string", "{", "return", "strings", ".", "ToLower", "(", "strings", ".", "TrimRightFunc", "(", "s", ",", "unicode", ".", "IsSpace", ")", ")", "\n", "}" ]
// Normalizes the given string as an ODBC-format key
[ "Normalizes", "the", "given", "string", "as", "an", "ODBC", "-", "format", "key" ]
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/tds.go#L867-L869
train
denisenkom/go-mssqldb
tds.go
dialConnection
func dialConnection(ctx context.Context, c *Connector, p connectParams) (conn net.Conn, err error) { var ips []net.IP ips, err = net.LookupIP(p.host) if err != nil { ip := net.ParseIP(p.host) if ip == nil { return nil, err } ips = []net.IP{ip} } if len(ips) == 1 { d := c.getDialer(&p) addr := net.Jo...
go
func dialConnection(ctx context.Context, c *Connector, p connectParams) (conn net.Conn, err error) { var ips []net.IP ips, err = net.LookupIP(p.host) if err != nil { ip := net.ParseIP(p.host) if ip == nil { return nil, err } ips = []net.IP{ip} } if len(ips) == 1 { d := c.getDialer(&p) addr := net.Jo...
[ "func", "dialConnection", "(", "ctx", "context", ".", "Context", ",", "c", "*", "Connector", ",", "p", "connectParams", ")", "(", "conn", "net", ".", "Conn", ",", "err", "error", ")", "{", "var", "ips", "[", "]", "net", ".", "IP", "\n", "ips", ",",...
// SQL Server AlwaysOn Availability Group Listeners are bound by DNS to a // list of IP addresses. So if there is more than one, try them all and // use the first one that allows a connection.
[ "SQL", "Server", "AlwaysOn", "Availability", "Group", "Listeners", "are", "bound", "by", "DNS", "to", "a", "list", "of", "IP", "addresses", ".", "So", "if", "there", "is", "more", "than", "one", "try", "them", "all", "and", "use", "the", "first", "one", ...
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/tds.go#L1114-L1174
train
denisenkom/go-mssqldb
mssql_go110.go
Connect
func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) { conn, err := c.driver.connect(ctx, c, c.params) if err == nil { err = conn.ResetSession(ctx) } return conn, err }
go
func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) { conn, err := c.driver.connect(ctx, c, c.params) if err == nil { err = conn.ResetSession(ctx) } return conn, err }
[ "func", "(", "c", "*", "Connector", ")", "Connect", "(", "ctx", "context", ".", "Context", ")", "(", "driver", ".", "Conn", ",", "error", ")", "{", "conn", ",", "err", ":=", "c", ".", "driver", ".", "connect", "(", "ctx", ",", "c", ",", "c", "....
// Connect to the server and return a TDS connection.
[ "Connect", "to", "the", "server", "and", "return", "a", "TDS", "connection", "." ]
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/mssql_go110.go#L36-L42
train
denisenkom/go-mssqldb
batch/batch.go
Split
func Split(sql, separator string) []string { if len(separator) == 0 || len(sql) < len(separator) { return []string{sql} } l := &lexer{ Sql: sql, Sep: separator, At: 0, } state := stateWhitespace for state != nil { state = state(l) } l.AddCurrent(1) return l.Batch }
go
func Split(sql, separator string) []string { if len(separator) == 0 || len(sql) < len(separator) { return []string{sql} } l := &lexer{ Sql: sql, Sep: separator, At: 0, } state := stateWhitespace for state != nil { state = state(l) } l.AddCurrent(1) return l.Batch }
[ "func", "Split", "(", "sql", ",", "separator", "string", ")", "[", "]", "string", "{", "if", "len", "(", "separator", ")", "==", "0", "||", "len", "(", "sql", ")", "<", "len", "(", "separator", ")", "{", "return", "[", "]", "string", "{", "sql", ...
// Split the provided SQL into multiple sql scripts based on a given // separator, often "GO". It also allows escaping newlines with a // backslash.
[ "Split", "the", "provided", "SQL", "into", "multiple", "sql", "scripts", "based", "on", "a", "given", "separator", "often", "GO", ".", "It", "also", "allows", "escaping", "newlines", "with", "a", "backslash", "." ]
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/batch/batch.go#L20-L35
train
denisenkom/go-mssqldb
bulkcopy.go
AddRow
func (b *Bulk) AddRow(row []interface{}) (err error) { if !b.headerSent { err = b.sendBulkCommand(b.ctx) if err != nil { return } } if len(row) != len(b.bulkColumns) { return fmt.Errorf("Row does not have the same number of columns than the destination table %d %d", len(row), len(b.bulkColumns)) } ...
go
func (b *Bulk) AddRow(row []interface{}) (err error) { if !b.headerSent { err = b.sendBulkCommand(b.ctx) if err != nil { return } } if len(row) != len(b.bulkColumns) { return fmt.Errorf("Row does not have the same number of columns than the destination table %d %d", len(row), len(b.bulkColumns)) } ...
[ "func", "(", "b", "*", "Bulk", ")", "AddRow", "(", "row", "[", "]", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "if", "!", "b", ".", "headerSent", "{", "err", "=", "b", ".", "sendBulkCommand", "(", "b", ".", "ctx", ")", "\n", "...
// AddRow immediately writes the row to the destination table. // The arguments are the row values in the order they were specified.
[ "AddRow", "immediately", "writes", "the", "row", "to", "the", "destination", "table", ".", "The", "arguments", "are", "the", "row", "values", "in", "the", "order", "they", "were", "specified", "." ]
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/bulkcopy.go#L154-L179
train
denisenkom/go-mssqldb
mssql.go
OpenConnector
func (d *Driver) OpenConnector(dsn string) (*Connector, error) { params, err := parseConnectParams(dsn) if err != nil { return nil, err } return &Connector{ params: params, driver: d, }, nil }
go
func (d *Driver) OpenConnector(dsn string) (*Connector, error) { params, err := parseConnectParams(dsn) if err != nil { return nil, err } return &Connector{ params: params, driver: d, }, nil }
[ "func", "(", "d", "*", "Driver", ")", "OpenConnector", "(", "dsn", "string", ")", "(", "*", "Connector", ",", "error", ")", "{", "params", ",", "err", ":=", "parseConnectParams", "(", "dsn", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// OpenConnector opens a new connector. Useful to dial with a context.
[ "OpenConnector", "opens", "a", "new", "connector", ".", "Useful", "to", "dial", "with", "a", "context", "." ]
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/mssql.go#L54-L63
train
denisenkom/go-mssqldb
mssql.go
NewConnector
func NewConnector(dsn string) (*Connector, error) { params, err := parseConnectParams(dsn) if err != nil { return nil, err } c := &Connector{ params: params, driver: driverInstanceNoProcess, } return c, nil }
go
func NewConnector(dsn string) (*Connector, error) { params, err := parseConnectParams(dsn) if err != nil { return nil, err } c := &Connector{ params: params, driver: driverInstanceNoProcess, } return c, nil }
[ "func", "NewConnector", "(", "dsn", "string", ")", "(", "*", "Connector", ",", "error", ")", "{", "params", ",", "err", ":=", "parseConnectParams", "(", "dsn", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", ...
// NewConnector creates a new connector from a DSN. // The returned connector may be used with sql.OpenDB.
[ "NewConnector", "creates", "a", "new", "connector", "from", "a", "DSN", ".", "The", "returned", "connector", "may", "be", "used", "with", "sql", ".", "OpenDB", "." ]
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/mssql.go#L80-L90
train
denisenkom/go-mssqldb
mssql.go
connect
func (d *Driver) connect(ctx context.Context, c *Connector, params connectParams) (*Conn, error) { sess, err := connect(ctx, c, d.log, params) if err != nil { // main server failed, try fail-over partner if params.failOverPartner == "" { return nil, err } params.host = params.failOverPartner if params.f...
go
func (d *Driver) connect(ctx context.Context, c *Connector, params connectParams) (*Conn, error) { sess, err := connect(ctx, c, d.log, params) if err != nil { // main server failed, try fail-over partner if params.failOverPartner == "" { return nil, err } params.host = params.failOverPartner if params.f...
[ "func", "(", "d", "*", "Driver", ")", "connect", "(", "ctx", "context", ".", "Context", ",", "c", "*", "Connector", ",", "params", "connectParams", ")", "(", "*", "Conn", ",", "error", ")", "{", "sess", ",", "err", ":=", "connect", "(", "ctx", ",",...
// connect to the server, using the provided context for dialing only.
[ "connect", "to", "the", "server", "using", "the", "provided", "context", "for", "dialing", "only", "." ]
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/mssql.go#L327-L357
train
denisenkom/go-mssqldb
mssql.go
isProc
func isProc(s string) bool { if len(s) == 0 { return false } const ( outside = iota text escaped ) st := outside var rn1, rPrev rune for _, r := range s { rPrev = rn1 rn1 = r switch r { // No newlines or string sequences. case '\n', '\r', '\'', ';': return false } switch st { case outs...
go
func isProc(s string) bool { if len(s) == 0 { return false } const ( outside = iota text escaped ) st := outside var rn1, rPrev rune for _, r := range s { rPrev = rn1 rn1 = r switch r { // No newlines or string sequences. case '\n', '\r', '\'', ';': return false } switch st { case outs...
[ "func", "isProc", "(", "s", "string", ")", "bool", "{", "if", "len", "(", "s", ")", "==", "0", "{", "return", "false", "\n", "}", "\n", "const", "(", "outside", "=", "iota", "\n", "text", "\n", "escaped", "\n", ")", "\n", "st", ":=", "outside", ...
// isProc takes the query text in s and determines if it is a stored proc name // or SQL text.
[ "isProc", "takes", "the", "query", "text", "in", "s", "and", "determines", "if", "it", "is", "a", "stored", "proc", "name", "or", "SQL", "text", "." ]
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/mssql.go#L485-L535
train
denisenkom/go-mssqldb
mssql.go
ColumnTypeNullable
func (r *Rows) ColumnTypeNullable(index int) (nullable, ok bool) { nullable = r.cols[index].Flags&colFlagNullable != 0 ok = true return }
go
func (r *Rows) ColumnTypeNullable(index int) (nullable, ok bool) { nullable = r.cols[index].Flags&colFlagNullable != 0 ok = true return }
[ "func", "(", "r", "*", "Rows", ")", "ColumnTypeNullable", "(", "index", "int", ")", "(", "nullable", ",", "ok", "bool", ")", "{", "nullable", "=", "r", ".", "cols", "[", "index", "]", ".", "Flags", "&", "colFlagNullable", "!=", "0", "\n", "ok", "="...
// The nullable value should // be true if it is known the column may be null, or false if the column is known // to be not nullable. // If the column nullability is unknown, ok should be false.
[ "The", "nullable", "value", "should", "be", "true", "if", "it", "is", "known", "the", "column", "may", "be", "null", "or", "false", "if", "the", "column", "is", "known", "to", "be", "not", "nullable", ".", "If", "the", "column", "nullability", "is", "u...
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/mssql.go#L779-L783
train
denisenkom/go-mssqldb
mssql.go
Ping
func (c *Conn) Ping(ctx context.Context) error { if !c.connectionGood { return driver.ErrBadConn } stmt := &Stmt{c, `select 1;`, 0, nil} _, err := stmt.ExecContext(ctx, nil) return err }
go
func (c *Conn) Ping(ctx context.Context) error { if !c.connectionGood { return driver.ErrBadConn } stmt := &Stmt{c, `select 1;`, 0, nil} _, err := stmt.ExecContext(ctx, nil) return err }
[ "func", "(", "c", "*", "Conn", ")", "Ping", "(", "ctx", "context", ".", "Context", ")", "error", "{", "if", "!", "c", ".", "connectionGood", "{", "return", "driver", ".", "ErrBadConn", "\n", "}", "\n", "stmt", ":=", "&", "Stmt", "{", "c", ",", "`...
// Ping is used to check if the remote server is available and satisfies the Pinger interface.
[ "Ping", "is", "used", "to", "check", "if", "the", "remote", "server", "is", "available", "and", "satisfies", "the", "Pinger", "interface", "." ]
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/mssql.go#L898-L905
train
denisenkom/go-mssqldb
mssql.go
BeginTx
func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) { if !c.connectionGood { return nil, driver.ErrBadConn } if opts.ReadOnly { return nil, errors.New("Read-only transactions are not supported") } var tdsIsolation isoLevel switch sql.IsolationLevel(opts.Isolation) { case sq...
go
func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) { if !c.connectionGood { return nil, driver.ErrBadConn } if opts.ReadOnly { return nil, errors.New("Read-only transactions are not supported") } var tdsIsolation isoLevel switch sql.IsolationLevel(opts.Isolation) { case sq...
[ "func", "(", "c", "*", "Conn", ")", "BeginTx", "(", "ctx", "context", ".", "Context", ",", "opts", "driver", ".", "TxOptions", ")", "(", "driver", ".", "Tx", ",", "error", ")", "{", "if", "!", "c", ".", "connectionGood", "{", "return", "nil", ",", ...
// BeginTx satisfies ConnBeginTx.
[ "BeginTx", "satisfies", "ConnBeginTx", "." ]
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/mssql.go#L910-L940
train
denisenkom/go-mssqldb
types.go
encodeDateTime
func encodeDateTime(t time.Time) (res []byte) { // base date in days since Jan 1st 1900 basedays := gregorianDays(1900, 1) // days since Jan 1st 1900 (same TZ as t) days := gregorianDays(t.Year(), t.YearDay()) - basedays tm := 300*(t.Second()+t.Minute()*60+t.Hour()*60*60) + t.Nanosecond()*300/1e9 // minimum and m...
go
func encodeDateTime(t time.Time) (res []byte) { // base date in days since Jan 1st 1900 basedays := gregorianDays(1900, 1) // days since Jan 1st 1900 (same TZ as t) days := gregorianDays(t.Year(), t.YearDay()) - basedays tm := 300*(t.Second()+t.Minute()*60+t.Hour()*60*60) + t.Nanosecond()*300/1e9 // minimum and m...
[ "func", "encodeDateTime", "(", "t", "time", ".", "Time", ")", "(", "res", "[", "]", "byte", ")", "{", "// base date in days since Jan 1st 1900", "basedays", ":=", "gregorianDays", "(", "1900", ",", "1", ")", "\n", "// days since Jan 1st 1900 (same TZ as t)", "days...
// encodes datetime value // type identifier is typeDateTimeN
[ "encodes", "datetime", "value", "type", "identifier", "is", "typeDateTimeN" ]
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/types.go#L279-L300
train
denisenkom/go-mssqldb
types.go
encodeTimeInt
func encodeTimeInt(seconds, ns, scale int, buf []byte) { ns_total := int64(seconds)*1000*1000*1000 + int64(ns) t := ns_total / int64(math.Pow10(int(scale)*-1)*1e9) buf[0] = byte(t) buf[1] = byte(t >> 8) buf[2] = byte(t >> 16) buf[3] = byte(t >> 24) buf[4] = byte(t >> 32) }
go
func encodeTimeInt(seconds, ns, scale int, buf []byte) { ns_total := int64(seconds)*1000*1000*1000 + int64(ns) t := ns_total / int64(math.Pow10(int(scale)*-1)*1e9) buf[0] = byte(t) buf[1] = byte(t >> 8) buf[2] = byte(t >> 16) buf[3] = byte(t >> 24) buf[4] = byte(t >> 32) }
[ "func", "encodeTimeInt", "(", "seconds", ",", "ns", ",", "scale", "int", ",", "buf", "[", "]", "byte", ")", "{", "ns_total", ":=", "int64", "(", "seconds", ")", "*", "1000", "*", "1000", "*", "1000", "+", "int64", "(", "ns", ")", "\n", "t", ":=",...
// writes time value into a field buffer // buffer should be at least calcTimeSize long
[ "writes", "time", "value", "into", "a", "field", "buffer", "buffer", "should", "be", "at", "least", "calcTimeSize", "long" ]
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/types.go#L899-L907
train
denisenkom/go-mssqldb
types.go
gregorianDays
func gregorianDays(year, yearday int) int { year0 := year - 1 return year0*365 + year0/4 - year0/100 + year0/400 + yearday - 1 }
go
func gregorianDays(year, yearday int) int { year0 := year - 1 return year0*365 + year0/4 - year0/100 + year0/400 + yearday - 1 }
[ "func", "gregorianDays", "(", "year", ",", "yearday", "int", ")", "int", "{", "year0", ":=", "year", "-", "1", "\n", "return", "year0", "*", "365", "+", "year0", "/", "4", "-", "year0", "/", "100", "+", "year0", "/", "400", "+", "yearday", "-", "...
// returns days since Jan 1st 0001 in Gregorian calendar
[ "returns", "days", "since", "Jan", "1st", "0001", "in", "Gregorian", "calendar" ]
731ef375ac027e24d275c5432221dbec5007a647
https://github.com/denisenkom/go-mssqldb/blob/731ef375ac027e24d275c5432221dbec5007a647/types.go#L966-L969
train
nsqio/go-nsq
config.go
HandlesOption
func (h *structTagsConfig) HandlesOption(c *Config, option string) bool { val := reflect.ValueOf(c).Elem() typ := val.Type() for i := 0; i < typ.NumField(); i++ { field := typ.Field(i) opt := field.Tag.Get("opt") if opt == option { return true } } return false }
go
func (h *structTagsConfig) HandlesOption(c *Config, option string) bool { val := reflect.ValueOf(c).Elem() typ := val.Type() for i := 0; i < typ.NumField(); i++ { field := typ.Field(i) opt := field.Tag.Get("opt") if opt == option { return true } } return false }
[ "func", "(", "h", "*", "structTagsConfig", ")", "HandlesOption", "(", "c", "*", "Config", ",", "option", "string", ")", "bool", "{", "val", ":=", "reflect", ".", "ValueOf", "(", "c", ")", ".", "Elem", "(", ")", "\n", "typ", ":=", "val", ".", "Type"...
// Handle options that are listed in StructTags
[ "Handle", "options", "that", "are", "listed", "in", "StructTags" ]
61f49c096d0d767be61e4de06f724e1cb5fd85d7
https://github.com/nsqio/go-nsq/blob/61f49c096d0d767be61e4de06f724e1cb5fd85d7/config.go#L259-L270
train
nsqio/go-nsq
config.go
Set
func (h *structTagsConfig) Set(c *Config, option string, value interface{}) error { val := reflect.ValueOf(c).Elem() typ := val.Type() for i := 0; i < typ.NumField(); i++ { field := typ.Field(i) opt := field.Tag.Get("opt") if option != opt { continue } min := field.Tag.Get("min") max := field.Tag.Ge...
go
func (h *structTagsConfig) Set(c *Config, option string, value interface{}) error { val := reflect.ValueOf(c).Elem() typ := val.Type() for i := 0; i < typ.NumField(); i++ { field := typ.Field(i) opt := field.Tag.Get("opt") if option != opt { continue } min := field.Tag.Get("min") max := field.Tag.Ge...
[ "func", "(", "h", "*", "structTagsConfig", ")", "Set", "(", "c", "*", "Config", ",", "option", "string", ",", "value", "interface", "{", "}", ")", "error", "{", "val", ":=", "reflect", ".", "ValueOf", "(", "c", ")", ".", "Elem", "(", ")", "\n", "...
// Set values based on parameters in StructTags
[ "Set", "values", "based", "on", "parameters", "in", "StructTags" ]
61f49c096d0d767be61e4de06f724e1cb5fd85d7
https://github.com/nsqio/go-nsq/blob/61f49c096d0d767be61e4de06f724e1cb5fd85d7/config.go#L273-L320
train