id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
10,900
dutchcoders/goftp
ftp.go
Walk
func (ftp *FTP) Walk(path string, walkFn WalkFunc) (err error) { /* if err = walkFn(path, os.ModeDir, nil); err != nil { if err == filepath.SkipDir { return nil } } */ if ftp.debug { log.Printf("Walking: '%s'\n", path) } var lines []string if lines, err = ftp.List(path); err != nil { return }...
go
func (ftp *FTP) Walk(path string, walkFn WalkFunc) (err error) { /* if err = walkFn(path, os.ModeDir, nil); err != nil { if err == filepath.SkipDir { return nil } } */ if ftp.debug { log.Printf("Walking: '%s'\n", path) } var lines []string if lines, err = ftp.List(path); err != nil { return }...
[ "func", "(", "ftp", "*", "FTP", ")", "Walk", "(", "path", "string", ",", "walkFn", "WalkFunc", ")", "(", "err", "error", ")", "{", "/*\n\t\tif err = walkFn(path, os.ModeDir, nil); err != nil {\n\t\t\tif err == filepath.SkipDir {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t*/", "if...
// Walk walks recursively through path and call walkfunc for each file
[ "Walk", "walks", "recursively", "through", "path", "and", "call", "walkfunc", "for", "each", "file" ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L64-L102
10,901
dutchcoders/goftp
ftp.go
Quit
func (ftp *FTP) Quit() (err error) { if _, err := ftp.cmd(StatusConnectionClosing, "QUIT"); err != nil { return err } ftp.conn.Close() ftp.conn = nil return nil }
go
func (ftp *FTP) Quit() (err error) { if _, err := ftp.cmd(StatusConnectionClosing, "QUIT"); err != nil { return err } ftp.conn.Close() ftp.conn = nil return nil }
[ "func", "(", "ftp", "*", "FTP", ")", "Quit", "(", ")", "(", "err", "error", ")", "{", "if", "_", ",", "err", ":=", "ftp", ".", "cmd", "(", "StatusConnectionClosing", ",", "\"", "\"", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}"...
// Quit sends quit to the server and close the connection. No need to Close after this.
[ "Quit", "sends", "quit", "to", "the", "server", "and", "close", "the", "connection", ".", "No", "need", "to", "Close", "after", "this", "." ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L105-L114
10,902
dutchcoders/goftp
ftp.go
RawCmd
func (ftp *FTP) RawCmd(command string, args ...interface{}) (code int, line string) { if ftp.debug { log.Printf("Raw-> %s\n", fmt.Sprintf(command, args...)) } code = -1 var err error if err = ftp.send(command, args...); err != nil { return code, "" } if line, err = ftp.receive(); err != nil { return code,...
go
func (ftp *FTP) RawCmd(command string, args ...interface{}) (code int, line string) { if ftp.debug { log.Printf("Raw-> %s\n", fmt.Sprintf(command, args...)) } code = -1 var err error if err = ftp.send(command, args...); err != nil { return code, "" } if line, err = ftp.receive(); err != nil { return code,...
[ "func", "(", "ftp", "*", "FTP", ")", "RawCmd", "(", "command", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "code", "int", ",", "line", "string", ")", "{", "if", "ftp", ".", "debug", "{", "log", ".", "Printf", "(", "\"", "\\n", ...
// RawCmd sends raw commands to the remote server. Returns response code as int and response as string.
[ "RawCmd", "sends", "raw", "commands", "to", "the", "remote", "server", ".", "Returns", "response", "code", "as", "int", "and", "response", "as", "string", "." ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L123-L141
10,903
dutchcoders/goftp
ftp.go
cmd
func (ftp *FTP) cmd(expects string, command string, args ...interface{}) (line string, err error) { if err = ftp.send(command, args...); err != nil { return } if line, err = ftp.receive(); err != nil { return } if !strings.HasPrefix(line, expects) { err = errors.New(line) return } return }
go
func (ftp *FTP) cmd(expects string, command string, args ...interface{}) (line string, err error) { if err = ftp.send(command, args...); err != nil { return } if line, err = ftp.receive(); err != nil { return } if !strings.HasPrefix(line, expects) { err = errors.New(line) return } return }
[ "func", "(", "ftp", "*", "FTP", ")", "cmd", "(", "expects", "string", ",", "command", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "line", "string", ",", "err", "error", ")", "{", "if", "err", "=", "ftp", ".", "send", "(", "comm...
// private function to send command and compare return code with expects
[ "private", "function", "to", "send", "command", "and", "compare", "return", "code", "with", "expects" ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L144-L159
10,904
dutchcoders/goftp
ftp.go
Rename
func (ftp *FTP) Rename(from string, to string) (err error) { if _, err = ftp.cmd(StatusActionPending, "RNFR %s", from); err != nil { return } if _, err = ftp.cmd(StatusActionOK, "RNTO %s", to); err != nil { return } return }
go
func (ftp *FTP) Rename(from string, to string) (err error) { if _, err = ftp.cmd(StatusActionPending, "RNFR %s", from); err != nil { return } if _, err = ftp.cmd(StatusActionOK, "RNTO %s", to); err != nil { return } return }
[ "func", "(", "ftp", "*", "FTP", ")", "Rename", "(", "from", "string", ",", "to", "string", ")", "(", "err", "error", ")", "{", "if", "_", ",", "err", "=", "ftp", ".", "cmd", "(", "StatusActionPending", ",", "\"", "\"", ",", "from", ")", ";", "e...
// Rename file on the remote host
[ "Rename", "file", "on", "the", "remote", "host" ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L162-L172
10,905
dutchcoders/goftp
ftp.go
Mkd
func (ftp *FTP) Mkd(path string) error { _, err := ftp.cmd(StatusPathCreated, "MKD %s", path) return err }
go
func (ftp *FTP) Mkd(path string) error { _, err := ftp.cmd(StatusPathCreated, "MKD %s", path) return err }
[ "func", "(", "ftp", "*", "FTP", ")", "Mkd", "(", "path", "string", ")", "error", "{", "_", ",", "err", ":=", "ftp", ".", "cmd", "(", "StatusPathCreated", ",", "\"", "\"", ",", "path", ")", "\n", "return", "err", "\n", "}" ]
// Mkd makes a directory on the remote host
[ "Mkd", "makes", "a", "directory", "on", "the", "remote", "host" ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L175-L178
10,906
dutchcoders/goftp
ftp.go
Pwd
func (ftp *FTP) Pwd() (path string, err error) { var line string if line, err = ftp.cmd(StatusPathCreated, "PWD"); err != nil { return } res := RePwdPath.FindAllStringSubmatch(line[4:], -1) path = res[0][1] return }
go
func (ftp *FTP) Pwd() (path string, err error) { var line string if line, err = ftp.cmd(StatusPathCreated, "PWD"); err != nil { return } res := RePwdPath.FindAllStringSubmatch(line[4:], -1) path = res[0][1] return }
[ "func", "(", "ftp", "*", "FTP", ")", "Pwd", "(", ")", "(", "path", "string", ",", "err", "error", ")", "{", "var", "line", "string", "\n", "if", "line", ",", "err", "=", "ftp", ".", "cmd", "(", "StatusPathCreated", ",", "\"", "\"", ")", ";", "e...
// Pwd gets current path on the remote host
[ "Pwd", "gets", "current", "path", "on", "the", "remote", "host" ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L187-L197
10,907
dutchcoders/goftp
ftp.go
Cwd
func (ftp *FTP) Cwd(path string) (err error) { _, err = ftp.cmd(StatusActionOK, "CWD %s", path) return }
go
func (ftp *FTP) Cwd(path string) (err error) { _, err = ftp.cmd(StatusActionOK, "CWD %s", path) return }
[ "func", "(", "ftp", "*", "FTP", ")", "Cwd", "(", "path", "string", ")", "(", "err", "error", ")", "{", "_", ",", "err", "=", "ftp", ".", "cmd", "(", "StatusActionOK", ",", "\"", "\"", ",", "path", ")", "\n", "return", "\n", "}" ]
// Cwd changes current working directory on remote host to path
[ "Cwd", "changes", "current", "working", "directory", "on", "remote", "host", "to", "path" ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L200-L203
10,908
dutchcoders/goftp
ftp.go
Dele
func (ftp *FTP) Dele(path string) (err error) { if err = ftp.send("DELE %s", path); err != nil { return } var line string if line, err = ftp.receive(); err != nil { return } if !strings.HasPrefix(line, StatusActionOK) { return errors.New(line) } return }
go
func (ftp *FTP) Dele(path string) (err error) { if err = ftp.send("DELE %s", path); err != nil { return } var line string if line, err = ftp.receive(); err != nil { return } if !strings.HasPrefix(line, StatusActionOK) { return errors.New(line) } return }
[ "func", "(", "ftp", "*", "FTP", ")", "Dele", "(", "path", "string", ")", "(", "err", "error", ")", "{", "if", "err", "=", "ftp", ".", "send", "(", "\"", "\"", ",", "path", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "var",...
// Dele deletes path on remote host
[ "Dele", "deletes", "path", "on", "remote", "host" ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L206-L221
10,909
dutchcoders/goftp
ftp.go
AuthTLS
func (ftp *FTP) AuthTLS(config *tls.Config) error { if _, err := ftp.cmd("234", "AUTH TLS"); err != nil { return err } // wrap tls on existing connection ftp.tlsconfig = config ftp.conn = tls.Client(ftp.conn, config) ftp.writer = bufio.NewWriter(ftp.conn) ftp.reader = bufio.NewReader(ftp.conn) if _, err :=...
go
func (ftp *FTP) AuthTLS(config *tls.Config) error { if _, err := ftp.cmd("234", "AUTH TLS"); err != nil { return err } // wrap tls on existing connection ftp.tlsconfig = config ftp.conn = tls.Client(ftp.conn, config) ftp.writer = bufio.NewWriter(ftp.conn) ftp.reader = bufio.NewReader(ftp.conn) if _, err :=...
[ "func", "(", "ftp", "*", "FTP", ")", "AuthTLS", "(", "config", "*", "tls", ".", "Config", ")", "error", "{", "if", "_", ",", "err", ":=", "ftp", ".", "cmd", "(", "\"", "\"", ",", "\"", "\"", ")", ";", "err", "!=", "nil", "{", "return", "err",...
// AuthTLS secures the ftp connection by using TLS
[ "AuthTLS", "secures", "the", "ftp", "connection", "by", "using", "TLS" ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L224-L245
10,910
dutchcoders/goftp
ftp.go
ReadAndDiscard
func (ftp *FTP) ReadAndDiscard() (int, error) { var i int bufferSize := ftp.reader.Buffered() for i = 0; i < bufferSize; i++ { if _, err := ftp.reader.ReadByte(); err != nil { return i, err } } return i, nil }
go
func (ftp *FTP) ReadAndDiscard() (int, error) { var i int bufferSize := ftp.reader.Buffered() for i = 0; i < bufferSize; i++ { if _, err := ftp.reader.ReadByte(); err != nil { return i, err } } return i, nil }
[ "func", "(", "ftp", "*", "FTP", ")", "ReadAndDiscard", "(", ")", "(", "int", ",", "error", ")", "{", "var", "i", "int", "\n", "bufferSize", ":=", "ftp", ".", "reader", ".", "Buffered", "(", ")", "\n", "for", "i", "=", "0", ";", "i", "<", "buffe...
// ReadAndDiscard reads all the buffered bytes and returns the number of bytes // that cleared from the buffer
[ "ReadAndDiscard", "reads", "all", "the", "buffered", "bytes", "and", "returns", "the", "number", "of", "bytes", "that", "cleared", "from", "the", "buffer" ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L249-L258
10,911
dutchcoders/goftp
ftp.go
Type
func (ftp *FTP) Type(t TypeCode) error { _, err := ftp.cmd(StatusOK, "TYPE %s", t) return err }
go
func (ftp *FTP) Type(t TypeCode) error { _, err := ftp.cmd(StatusOK, "TYPE %s", t) return err }
[ "func", "(", "ftp", "*", "FTP", ")", "Type", "(", "t", "TypeCode", ")", "error", "{", "_", ",", "err", ":=", "ftp", ".", "cmd", "(", "StatusOK", ",", "\"", "\"", ",", "t", ")", "\n", "return", "err", "\n", "}" ]
// Type changes transfer type.
[ "Type", "changes", "transfer", "type", "." ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L261-L264
10,912
dutchcoders/goftp
ftp.go
Pasv
func (ftp *FTP) Pasv() (port int, err error) { doneChan := make(chan int, 1) go func() { defer func() { doneChan <- 1 }() var line string if line, err = ftp.cmd("227", "PASV"); err != nil { return } re := regexp.MustCompile(`\((.*)\)`) res := re.FindAllStringSubmatch(line, -1) if len(res) == 0 |...
go
func (ftp *FTP) Pasv() (port int, err error) { doneChan := make(chan int, 1) go func() { defer func() { doneChan <- 1 }() var line string if line, err = ftp.cmd("227", "PASV"); err != nil { return } re := regexp.MustCompile(`\((.*)\)`) res := re.FindAllStringSubmatch(line, -1) if len(res) == 0 |...
[ "func", "(", "ftp", "*", "FTP", ")", "Pasv", "(", ")", "(", "port", "int", ",", "err", "error", ")", "{", "doneChan", ":=", "make", "(", "chan", "int", ",", "1", ")", "\n", "go", "func", "(", ")", "{", "defer", "func", "(", ")", "{", "doneCha...
// Pasv enables passive data connection and returns port number
[ "Pasv", "enables", "passive", "data", "connection", "and", "returns", "port", "number" ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L377-L415
10,913
dutchcoders/goftp
ftp.go
newConnection
func (ftp *FTP) newConnection(port int) (conn net.Conn, err error) { addr := fmt.Sprintf("%s:%d", strings.Split(ftp.addr, ":")[0], port) if ftp.debug { log.Printf("Connecting to %s\n", addr) } if conn, err = net.Dial("tcp", addr); err != nil { return } if ftp.tlsconfig != nil { conn = tls.Client(conn, ft...
go
func (ftp *FTP) newConnection(port int) (conn net.Conn, err error) { addr := fmt.Sprintf("%s:%d", strings.Split(ftp.addr, ":")[0], port) if ftp.debug { log.Printf("Connecting to %s\n", addr) } if conn, err = net.Dial("tcp", addr); err != nil { return } if ftp.tlsconfig != nil { conn = tls.Client(conn, ft...
[ "func", "(", "ftp", "*", "FTP", ")", "newConnection", "(", "port", "int", ")", "(", "conn", "net", ".", "Conn", ",", "err", "error", ")", "{", "addr", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "strings", ".", "Split", "(", "ftp", ".", ...
// open new data connection
[ "open", "new", "data", "connection" ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L418-L434
10,914
dutchcoders/goftp
ftp.go
Stor
func (ftp *FTP) Stor(path string, r io.Reader) (err error) { if err = ftp.Type(TypeImage); err != nil { return } var port int if port, err = ftp.Pasv(); err != nil { return } if err = ftp.send("STOR %s", path); err != nil { return } var pconn net.Conn if pconn, err = ftp.newConnection(port); err != ni...
go
func (ftp *FTP) Stor(path string, r io.Reader) (err error) { if err = ftp.Type(TypeImage); err != nil { return } var port int if port, err = ftp.Pasv(); err != nil { return } if err = ftp.send("STOR %s", path); err != nil { return } var pconn net.Conn if pconn, err = ftp.newConnection(port); err != ni...
[ "func", "(", "ftp", "*", "FTP", ")", "Stor", "(", "path", "string", ",", "r", "io", ".", "Reader", ")", "(", "err", "error", ")", "{", "if", "err", "=", "ftp", ".", "Type", "(", "TypeImage", ")", ";", "err", "!=", "nil", "{", "return", "\n", ...
// Stor uploads file to remote host path, from r
[ "Stor", "uploads", "file", "to", "remote", "host", "path", "from", "r" ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L437-L483
10,915
dutchcoders/goftp
ftp.go
Syst
func (ftp *FTP) Syst() (line string, err error) { if err := ftp.send("SYST"); err != nil { return "", err } if line, err = ftp.receive(); err != nil { return } if !strings.HasPrefix(line, StatusSystemType) { err = errors.New(line) return } return strings.SplitN(strings.TrimSpace(line), " ", 2)[1], nil }
go
func (ftp *FTP) Syst() (line string, err error) { if err := ftp.send("SYST"); err != nil { return "", err } if line, err = ftp.receive(); err != nil { return } if !strings.HasPrefix(line, StatusSystemType) { err = errors.New(line) return } return strings.SplitN(strings.TrimSpace(line), " ", 2)[1], nil }
[ "func", "(", "ftp", "*", "FTP", ")", "Syst", "(", ")", "(", "line", "string", ",", "err", "error", ")", "{", "if", "err", ":=", "ftp", ".", "send", "(", "\"", "\"", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", ...
// Syst returns the system type of the remote host
[ "Syst", "returns", "the", "system", "type", "of", "the", "remote", "host" ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L486-L499
10,916
dutchcoders/goftp
ftp.go
Stat
func (ftp *FTP) Stat(path string) ([]string, error) { if err := ftp.send("STAT %s", path); err != nil { return nil, err } stat, err := ftp.receive() if err != nil { return nil, err } if !strings.HasPrefix(stat, StatusFileStatus) && !strings.HasPrefix(stat, StatusDirectoryStatus) && !strings.HasPrefix(stat,...
go
func (ftp *FTP) Stat(path string) ([]string, error) { if err := ftp.send("STAT %s", path); err != nil { return nil, err } stat, err := ftp.receive() if err != nil { return nil, err } if !strings.HasPrefix(stat, StatusFileStatus) && !strings.HasPrefix(stat, StatusDirectoryStatus) && !strings.HasPrefix(stat,...
[ "func", "(", "ftp", "*", "FTP", ")", "Stat", "(", "path", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "if", "err", ":=", "ftp", ".", "send", "(", "\"", "\"", ",", "path", ")", ";", "err", "!=", "nil", "{", "return", "nil",...
// Stat gets the status of path from the remote host
[ "Stat", "gets", "the", "status", "of", "path", "from", "the", "remote", "host" ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L513-L546
10,917
dutchcoders/goftp
ftp.go
Retr
func (ftp *FTP) Retr(path string, retrFn RetrFunc) (s string, err error) { if err = ftp.Type(TypeImage); err != nil { return } var port int if port, err = ftp.Pasv(); err != nil { return } if err = ftp.send("RETR %s", path); err != nil { return } var pconn net.Conn if pconn, err = ftp.newConnection(po...
go
func (ftp *FTP) Retr(path string, retrFn RetrFunc) (s string, err error) { if err = ftp.Type(TypeImage); err != nil { return } var port int if port, err = ftp.Pasv(); err != nil { return } if err = ftp.send("RETR %s", path); err != nil { return } var pconn net.Conn if pconn, err = ftp.newConnection(po...
[ "func", "(", "ftp", "*", "FTP", ")", "Retr", "(", "path", "string", ",", "retrFn", "RetrFunc", ")", "(", "s", "string", ",", "err", "error", ")", "{", "if", "err", "=", "ftp", ".", "Type", "(", "TypeImage", ")", ";", "err", "!=", "nil", "{", "r...
// Retr retrieves file from remote host at path, using retrFn to read from the remote file.
[ "Retr", "retrieves", "file", "from", "remote", "host", "at", "path", "using", "retrFn", "to", "read", "from", "the", "remote", "file", "." ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L549-L595
10,918
dutchcoders/goftp
ftp.go
Size
func (ftp *FTP) Size(path string) (size int, err error) { line, err := ftp.cmd("213", "SIZE %s", path) if err != nil { return 0, err } return strconv.Atoi(line[4 : len(line)-2]) }
go
func (ftp *FTP) Size(path string) (size int, err error) { line, err := ftp.cmd("213", "SIZE %s", path) if err != nil { return 0, err } return strconv.Atoi(line[4 : len(line)-2]) }
[ "func", "(", "ftp", "*", "FTP", ")", "Size", "(", "path", "string", ")", "(", "size", "int", ",", "err", "error", ")", "{", "line", ",", "err", ":=", "ftp", ".", "cmd", "(", "\"", "\"", ",", "\"", "\"", ",", "path", ")", "\n\n", "if", "err", ...
// Size returns the size of a file.
[ "Size", "returns", "the", "size", "of", "a", "file", "." ]
ed59a591ce14ff6c19c49be14294528d11a88c37
https://github.com/dutchcoders/goftp/blob/ed59a591ce14ff6c19c49be14294528d11a88c37/ftp.go#L767-L775
10,919
zabawaba99/firego
transaction.go
Transaction
func (fb *Firebase) Transaction(fn TransactionFn) error { // fetch etag and current value headers, body, err := fb.doRequest("GET", nil, withHeader("X-Firebase-ETag", "true")) if err != nil { return err } etag, snapshot, err := getTransactionParams(headers, body) if err != nil { return err } // set the er...
go
func (fb *Firebase) Transaction(fn TransactionFn) error { // fetch etag and current value headers, body, err := fb.doRequest("GET", nil, withHeader("X-Firebase-ETag", "true")) if err != nil { return err } etag, snapshot, err := getTransactionParams(headers, body) if err != nil { return err } // set the er...
[ "func", "(", "fb", "*", "Firebase", ")", "Transaction", "(", "fn", "TransactionFn", ")", "error", "{", "// fetch etag and current value", "headers", ",", "body", ",", "err", ":=", "fb", ".", "doRequest", "(", "\"", "\"", ",", "nil", ",", "withHeader", "(",...
// Transaction runs a transaction on the data at this location. The TransactionFn parameter // will be called, possibly multiple times, with the current data at this location. // It is responsible for inspecting that data and specifying either the desired new data // at the location or that the transaction should be ab...
[ "Transaction", "runs", "a", "transaction", "on", "the", "data", "at", "this", "location", ".", "The", "TransactionFn", "parameter", "will", "be", "called", "possibly", "multiple", "times", "with", "the", "current", "data", "at", "this", "location", ".", "It", ...
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/transaction.go#L36-L82
10,920
zabawaba99/firego
firebase.go
New
func New(url string, client *http.Client) *Firebase { fb := &Firebase{ url: sanitizeURL(url), params: _url.Values{}, clientTimeout: TimeoutDuration, stopWatching: make(chan struct{}), watchHeartbeat: defaultHeartbeat, eventFuncs: map[string]chan struct{}{}, } if client == nil { ...
go
func New(url string, client *http.Client) *Firebase { fb := &Firebase{ url: sanitizeURL(url), params: _url.Values{}, clientTimeout: TimeoutDuration, stopWatching: make(chan struct{}), watchHeartbeat: defaultHeartbeat, eventFuncs: map[string]chan struct{}{}, } if client == nil { ...
[ "func", "New", "(", "url", "string", ",", "client", "*", "http", ".", "Client", ")", "*", "Firebase", "{", "fb", ":=", "&", "Firebase", "{", "url", ":", "sanitizeURL", "(", "url", ")", ",", "params", ":", "_url", ".", "Values", "{", "}", ",", "cl...
// New creates a new Firebase reference, // if client is nil, http.DefaultClient is used.
[ "New", "creates", "a", "new", "Firebase", "reference", "if", "client", "is", "nil", "http", ".", "DefaultClient", "is", "used", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/firebase.go#L69-L97
10,921
zabawaba99/firego
firebase.go
Auth
func (fb *Firebase) Auth(token string) { fb.paramsMtx.Lock() fb.params.Set(authParam, token) fb.paramsMtx.Unlock() }
go
func (fb *Firebase) Auth(token string) { fb.paramsMtx.Lock() fb.params.Set(authParam, token) fb.paramsMtx.Unlock() }
[ "func", "(", "fb", "*", "Firebase", ")", "Auth", "(", "token", "string", ")", "{", "fb", ".", "paramsMtx", ".", "Lock", "(", ")", "\n", "fb", ".", "params", ".", "Set", "(", "authParam", ",", "token", ")", "\n", "fb", ".", "paramsMtx", ".", "Unlo...
// Auth sets the custom Firebase token used to authenticate to Firebase.
[ "Auth", "sets", "the", "custom", "Firebase", "token", "used", "to", "authenticate", "to", "Firebase", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/firebase.go#L100-L104
10,922
zabawaba99/firego
firebase.go
Unauth
func (fb *Firebase) Unauth() { fb.paramsMtx.Lock() fb.params.Del(authParam) fb.paramsMtx.Unlock() }
go
func (fb *Firebase) Unauth() { fb.paramsMtx.Lock() fb.params.Del(authParam) fb.paramsMtx.Unlock() }
[ "func", "(", "fb", "*", "Firebase", ")", "Unauth", "(", ")", "{", "fb", ".", "paramsMtx", ".", "Lock", "(", ")", "\n", "fb", ".", "params", ".", "Del", "(", "authParam", ")", "\n", "fb", ".", "paramsMtx", ".", "Unlock", "(", ")", "\n", "}" ]
// Unauth removes the current token being used to authenticate to Firebase.
[ "Unauth", "removes", "the", "current", "token", "being", "used", "to", "authenticate", "to", "Firebase", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/firebase.go#L107-L111
10,923
zabawaba99/firego
firebase.go
Ref
func (fb *Firebase) Ref(path string) (*Firebase, error) { newFB := fb.copy() parsedURL, err := _url.Parse(fb.url) if err != nil { return newFB, err } newFB.url = parsedURL.Scheme + "://" + parsedURL.Host + "/" + strings.Trim(path, "/") return newFB, nil }
go
func (fb *Firebase) Ref(path string) (*Firebase, error) { newFB := fb.copy() parsedURL, err := _url.Parse(fb.url) if err != nil { return newFB, err } newFB.url = parsedURL.Scheme + "://" + parsedURL.Host + "/" + strings.Trim(path, "/") return newFB, nil }
[ "func", "(", "fb", "*", "Firebase", ")", "Ref", "(", "path", "string", ")", "(", "*", "Firebase", ",", "error", ")", "{", "newFB", ":=", "fb", ".", "copy", "(", ")", "\n", "parsedURL", ",", "err", ":=", "_url", ".", "Parse", "(", "fb", ".", "ur...
// Ref returns a copy of an existing Firebase reference with a new path.
[ "Ref", "returns", "a", "copy", "of", "an", "existing", "Firebase", "reference", "with", "a", "new", "path", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/firebase.go#L114-L122
10,924
zabawaba99/firego
firebase.go
Push
func (fb *Firebase) Push(v interface{}) (*Firebase, error) { bytes, err := json.Marshal(v) if err != nil { return nil, err } _, bytes, err = fb.doRequest("POST", bytes) if err != nil { return nil, err } var m map[string]string if err := json.Unmarshal(bytes, &m); err != nil { return nil, err } newRef :=...
go
func (fb *Firebase) Push(v interface{}) (*Firebase, error) { bytes, err := json.Marshal(v) if err != nil { return nil, err } _, bytes, err = fb.doRequest("POST", bytes) if err != nil { return nil, err } var m map[string]string if err := json.Unmarshal(bytes, &m); err != nil { return nil, err } newRef :=...
[ "func", "(", "fb", "*", "Firebase", ")", "Push", "(", "v", "interface", "{", "}", ")", "(", "*", "Firebase", ",", "error", ")", "{", "bytes", ",", "err", ":=", "json", ".", "Marshal", "(", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return"...
// Push creates a reference to an auto-generated child location.
[ "Push", "creates", "a", "reference", "to", "an", "auto", "-", "generated", "child", "location", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/firebase.go#L135-L151
10,925
zabawaba99/firego
firebase.go
Remove
func (fb *Firebase) Remove() error { _, _, err := fb.doRequest("DELETE", nil) if err != nil { return err } return nil }
go
func (fb *Firebase) Remove() error { _, _, err := fb.doRequest("DELETE", nil) if err != nil { return err } return nil }
[ "func", "(", "fb", "*", "Firebase", ")", "Remove", "(", ")", "error", "{", "_", ",", "_", ",", "err", ":=", "fb", ".", "doRequest", "(", "\"", "\"", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "retu...
// Remove the Firebase reference from the cloud.
[ "Remove", "the", "Firebase", "reference", "from", "the", "cloud", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/firebase.go#L154-L160
10,926
zabawaba99/firego
firebase.go
Set
func (fb *Firebase) Set(v interface{}) error { bytes, err := json.Marshal(v) if err != nil { return err } _, _, err = fb.doRequest("PUT", bytes) return err }
go
func (fb *Firebase) Set(v interface{}) error { bytes, err := json.Marshal(v) if err != nil { return err } _, _, err = fb.doRequest("PUT", bytes) return err }
[ "func", "(", "fb", "*", "Firebase", ")", "Set", "(", "v", "interface", "{", "}", ")", "error", "{", "bytes", ",", "err", ":=", "json", ".", "Marshal", "(", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "_", ...
// Set the value of the Firebase reference.
[ "Set", "the", "value", "of", "the", "Firebase", "reference", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/firebase.go#L163-L170
10,927
zabawaba99/firego
firebase.go
Value
func (fb *Firebase) Value(v interface{}) error { _, bytes, err := fb.doRequest("GET", nil) if err != nil { return err } return json.Unmarshal(bytes, v) }
go
func (fb *Firebase) Value(v interface{}) error { _, bytes, err := fb.doRequest("GET", nil) if err != nil { return err } return json.Unmarshal(bytes, v) }
[ "func", "(", "fb", "*", "Firebase", ")", "Value", "(", "v", "interface", "{", "}", ")", "error", "{", "_", ",", "bytes", ",", "err", ":=", "fb", ".", "doRequest", "(", "\"", "\"", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// Value gets the value of the Firebase reference.
[ "Value", "gets", "the", "value", "of", "the", "Firebase", "reference", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/firebase.go#L183-L189
10,928
zabawaba99/firego
firebase.go
String
func (fb *Firebase) String() string { path := fb.url + "/.json" fb.paramsMtx.RLock() if len(fb.params) > 0 { path += "?" + fb.params.Encode() } fb.paramsMtx.RUnlock() return path }
go
func (fb *Firebase) String() string { path := fb.url + "/.json" fb.paramsMtx.RLock() if len(fb.params) > 0 { path += "?" + fb.params.Encode() } fb.paramsMtx.RUnlock() return path }
[ "func", "(", "fb", "*", "Firebase", ")", "String", "(", ")", "string", "{", "path", ":=", "fb", ".", "url", "+", "\"", "\"", "\n\n", "fb", ".", "paramsMtx", ".", "RLock", "(", ")", "\n", "if", "len", "(", "fb", ".", "params", ")", ">", "0", "...
// String returns the string representation of the // Firebase reference.
[ "String", "returns", "the", "string", "representation", "of", "the", "Firebase", "reference", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/firebase.go#L193-L202
10,929
zabawaba99/firego
firebase.go
Child
func (fb *Firebase) Child(child string) *Firebase { c := fb.copy() c.url = c.url + "/" + child return c }
go
func (fb *Firebase) Child(child string) *Firebase { c := fb.copy() c.url = c.url + "/" + child return c }
[ "func", "(", "fb", "*", "Firebase", ")", "Child", "(", "child", "string", ")", "*", "Firebase", "{", "c", ":=", "fb", ".", "copy", "(", ")", "\n", "c", ".", "url", "=", "c", ".", "url", "+", "\"", "\"", "+", "child", "\n", "return", "c", "\n"...
// Child creates a new Firebase reference for the requested // child with the same configuration as the parent.
[ "Child", "creates", "a", "new", "Firebase", "reference", "for", "the", "requested", "child", "with", "the", "same", "configuration", "as", "the", "parent", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/firebase.go#L206-L210
10,930
zabawaba99/firego
watch.go
Value
func (e Event) Value(v interface{}) error { var tmp struct { Data interface{} `json:"data"` } tmp.Data = &v return json.Unmarshal(e.rawData, &tmp) }
go
func (e Event) Value(v interface{}) error { var tmp struct { Data interface{} `json:"data"` } tmp.Data = &v return json.Unmarshal(e.rawData, &tmp) }
[ "func", "(", "e", "Event", ")", "Value", "(", "v", "interface", "{", "}", ")", "error", "{", "var", "tmp", "struct", "{", "Data", "interface", "{", "}", "`json:\"data\"`", "\n", "}", "\n", "tmp", ".", "Data", "=", "&", "v", "\n", "return", "json", ...
// Value converts the raw payload of the event into the given interface.
[ "Value", "converts", "the", "raw", "payload", "of", "the", "event", "into", "the", "given", "interface", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/watch.go#L45-L51
10,931
zabawaba99/firego
watch.go
StopWatching
func (fb *Firebase) StopWatching() { fb.watchMtx.Lock() defer fb.watchMtx.Unlock() if fb.watching { // flip the bit back to not watching fb.watching = false // signal connection to terminal fb.stopWatching <- struct{}{} } }
go
func (fb *Firebase) StopWatching() { fb.watchMtx.Lock() defer fb.watchMtx.Unlock() if fb.watching { // flip the bit back to not watching fb.watching = false // signal connection to terminal fb.stopWatching <- struct{}{} } }
[ "func", "(", "fb", "*", "Firebase", ")", "StopWatching", "(", ")", "{", "fb", ".", "watchMtx", ".", "Lock", "(", ")", "\n", "defer", "fb", ".", "watchMtx", ".", "Unlock", "(", ")", "\n\n", "if", "fb", ".", "watching", "{", "// flip the bit back to not ...
// StopWatching stops tears down all connections that are watching.
[ "StopWatching", "stops", "tears", "down", "all", "connections", "that", "are", "watching", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/watch.go#L54-L64
10,932
zabawaba99/firego
watch.go
Watch
func (fb *Firebase) Watch(notifications chan Event) error { fb.watchMtx.Lock() if fb.watching { fb.watchMtx.Unlock() close(notifications) return nil } fb.watching = true fb.watchMtx.Unlock() stop := make(chan struct{}) events, err := fb.watch(stop) if err != nil { return err } var closedManually boo...
go
func (fb *Firebase) Watch(notifications chan Event) error { fb.watchMtx.Lock() if fb.watching { fb.watchMtx.Unlock() close(notifications) return nil } fb.watching = true fb.watchMtx.Unlock() stop := make(chan struct{}) events, err := fb.watch(stop) if err != nil { return err } var closedManually boo...
[ "func", "(", "fb", "*", "Firebase", ")", "Watch", "(", "notifications", "chan", "Event", ")", "error", "{", "fb", ".", "watchMtx", ".", "Lock", "(", ")", "\n", "if", "fb", ".", "watching", "{", "fb", ".", "watchMtx", ".", "Unlock", "(", ")", "\n", ...
// Watch listens for changes on a firebase instance and // passes over to the given chan. // // Only one connection can be established at a time. The // second call to this function without a call to fb.StopWatching // will close the channel given and return nil immediately.
[ "Watch", "listens", "for", "changes", "on", "a", "firebase", "instance", "and", "passes", "over", "to", "the", "given", "chan", ".", "Only", "one", "connection", "can", "be", "established", "at", "a", "time", ".", "The", "second", "call", "to", "this", "...
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/watch.go#L78-L115
10,933
zabawaba99/firego
sync/node.go
NewNode
func NewNode(key string, data interface{}) *Node { n := &Node{ Key: key, } n.mtx.Lock() n.Children = map[string]*Node{} n.mtx.Unlock() if data == nil { return n } switch val := reflect.ValueOf(data); val.Kind() { case reflect.Map: for _, k := range val.MapKeys() { v := val.MapIndex(k) key := fmt...
go
func NewNode(key string, data interface{}) *Node { n := &Node{ Key: key, } n.mtx.Lock() n.Children = map[string]*Node{} n.mtx.Unlock() if data == nil { return n } switch val := reflect.ValueOf(data); val.Kind() { case reflect.Map: for _, k := range val.MapKeys() { v := val.MapIndex(k) key := fmt...
[ "func", "NewNode", "(", "key", "string", ",", "data", "interface", "{", "}", ")", "*", "Node", "{", "n", ":=", "&", "Node", "{", "Key", ":", "key", ",", "}", "\n\n", "n", ".", "mtx", ".", "Lock", "(", ")", "\n", "n", ".", "Children", "=", "ma...
// NewNode converts the given data into a node.
[ "NewNode", "converts", "the", "given", "data", "into", "a", "node", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/sync/node.go#L26-L75
10,934
zabawaba99/firego
sync/node.go
Objectify
func (n *Node) Objectify() interface{} { n.mtx.RLock() defer n.mtx.RUnlock() if n.isNil() { return nil } if n.Value != nil { return n.Value } if n.sliceKids { obj := make([]interface{}, len(n.Children)) for k, v := range n.Children { index, err := strconv.Atoi(k) if err != nil { continue ...
go
func (n *Node) Objectify() interface{} { n.mtx.RLock() defer n.mtx.RUnlock() if n.isNil() { return nil } if n.Value != nil { return n.Value } if n.sliceKids { obj := make([]interface{}, len(n.Children)) for k, v := range n.Children { index, err := strconv.Atoi(k) if err != nil { continue ...
[ "func", "(", "n", "*", "Node", ")", "Objectify", "(", ")", "interface", "{", "}", "{", "n", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "n", ".", "mtx", ".", "RUnlock", "(", ")", "\n\n", "if", "n", ".", "isNil", "(", ")", "{", "return"...
// Objectify turns the node and all its children into a go type. // If a node was created from a slice initially, a slice will be return. // If a node has child nodes, a map will be returned. // Otherwise, a primitive type will be returned.
[ "Objectify", "turns", "the", "node", "and", "all", "its", "children", "into", "a", "go", "type", ".", "If", "a", "node", "was", "created", "from", "a", "slice", "initially", "a", "slice", "will", "be", "return", ".", "If", "a", "node", "has", "child", ...
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/sync/node.go#L86-L116
10,935
zabawaba99/firego
event_callback.go
ChildAdded
func (fb *Firebase) ChildAdded(fn ChildEventFunc) error { return fb.addEventFunc(fn, fn.childAdded) }
go
func (fb *Firebase) ChildAdded(fn ChildEventFunc) error { return fb.addEventFunc(fn, fn.childAdded) }
[ "func", "(", "fb", "*", "Firebase", ")", "ChildAdded", "(", "fn", "ChildEventFunc", ")", "error", "{", "return", "fb", ".", "addEventFunc", "(", "fn", ",", "fn", ".", "childAdded", ")", "\n", "}" ]
// ChildAdded listens on the firebase instance and executes the callback // for every child that is added. // // You cannot set the same function twice on a Firebase reference, if you do // the first function will be overridden and you will not be able to close the // connection.
[ "ChildAdded", "listens", "on", "the", "firebase", "instance", "and", "executes", "the", "callback", "for", "every", "child", "that", "is", "added", ".", "You", "cannot", "set", "the", "same", "function", "twice", "on", "a", "Firebase", "reference", "if", "yo...
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/event_callback.go#L25-L27
10,936
zabawaba99/firego
event_callback.go
ChildChanged
func (fb *Firebase) ChildChanged(fn ChildEventFunc) error { return fb.addEventFunc(fn, fn.childChanged) }
go
func (fb *Firebase) ChildChanged(fn ChildEventFunc) error { return fb.addEventFunc(fn, fn.childChanged) }
[ "func", "(", "fb", "*", "Firebase", ")", "ChildChanged", "(", "fn", "ChildEventFunc", ")", "error", "{", "return", "fb", ".", "addEventFunc", "(", "fn", ",", "fn", ".", "childChanged", ")", "\n", "}" ]
// ChildChanged listens on the firebase instance and executes the callback // for every child that is changed. // // You cannot set the same function twice on a Firebase reference, if you do // the first function will be overridden and you will not be able to close the // connection.
[ "ChildChanged", "listens", "on", "the", "firebase", "instance", "and", "executes", "the", "callback", "for", "every", "child", "that", "is", "changed", ".", "You", "cannot", "set", "the", "same", "function", "twice", "on", "a", "Firebase", "reference", "if", ...
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/event_callback.go#L84-L86
10,937
zabawaba99/firego
event_callback.go
ChildRemoved
func (fb *Firebase) ChildRemoved(fn ChildEventFunc) error { return fb.addEventFunc(fn, fn.childRemoved) }
go
func (fb *Firebase) ChildRemoved(fn ChildEventFunc) error { return fb.addEventFunc(fn, fn.childRemoved) }
[ "func", "(", "fb", "*", "Firebase", ")", "ChildRemoved", "(", "fn", "ChildEventFunc", ")", "error", "{", "return", "fb", ".", "addEventFunc", "(", "fn", ",", "fn", ".", "childRemoved", ")", "\n", "}" ]
// ChildRemoved listens on the firebase instance and executes the callback // for every child that is deleted. // // You cannot set the same function twice on a Firebase reference, if you do // the first function will be overridden and you will not be able to close the // connection.
[ "ChildRemoved", "listens", "on", "the", "firebase", "instance", "and", "executes", "the", "callback", "for", "every", "child", "that", "is", "deleted", ".", "You", "cannot", "set", "the", "same", "function", "twice", "on", "a", "Firebase", "reference", "if", ...
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/event_callback.go#L151-L153
10,938
zabawaba99/firego
event_callback.go
RemoveEventFunc
func (fb *Firebase) RemoveEventFunc(fn ChildEventFunc) { fb.eventMtx.Lock() defer fb.eventMtx.Unlock() key := fmt.Sprintf("%v", fn) stop, ok := fb.eventFuncs[key] if !ok { return } delete(fb.eventFuncs, key) close(stop) }
go
func (fb *Firebase) RemoveEventFunc(fn ChildEventFunc) { fb.eventMtx.Lock() defer fb.eventMtx.Unlock() key := fmt.Sprintf("%v", fn) stop, ok := fb.eventFuncs[key] if !ok { return } delete(fb.eventFuncs, key) close(stop) }
[ "func", "(", "fb", "*", "Firebase", ")", "RemoveEventFunc", "(", "fn", "ChildEventFunc", ")", "{", "fb", ".", "eventMtx", ".", "Lock", "(", ")", "\n", "defer", "fb", ".", "eventMtx", ".", "Unlock", "(", ")", "\n\n", "key", ":=", "fmt", ".", "Sprintf"...
// RemoveEventFunc removes the given function from the firebase // reference.
[ "RemoveEventFunc", "removes", "the", "given", "function", "from", "the", "firebase", "reference", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/event_callback.go#L276-L288
10,939
zabawaba99/firego
sync/database.go
Add
func (d *Database) Add(path string, n *Node) { d.mtx.Lock() defer d.mtx.Unlock() if path == "" { d.root = n return } rabbitHole := strings.Split(path, "/") current := d.root for i := 0; i < len(rabbitHole)-1; i++ { step := rabbitHole[i] next, ok := current.Children[step] if !ok { next = &Node{ ...
go
func (d *Database) Add(path string, n *Node) { d.mtx.Lock() defer d.mtx.Unlock() if path == "" { d.root = n return } rabbitHole := strings.Split(path, "/") current := d.root for i := 0; i < len(rabbitHole)-1; i++ { step := rabbitHole[i] next, ok := current.Children[step] if !ok { next = &Node{ ...
[ "func", "(", "d", "*", "Database", ")", "Add", "(", "path", "string", ",", "n", "*", "Node", ")", "{", "d", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "if", "path", "==", "\"", "\"", ...
// Add puts a Node into the database.
[ "Add", "puts", "a", "Node", "into", "the", "database", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/sync/database.go#L25-L54
10,940
zabawaba99/firego
sync/database.go
Del
func (d *Database) Del(path string) { d.mtx.Lock() defer d.mtx.Unlock() if path == "" { d.root = &Node{ Children: map[string]*Node{}, } return } rabbitHole := strings.Split(path, "/") current := d.root // traverse to target node's parent var delIdx int for ; delIdx < len(rabbitHole)-1; delIdx++ { ...
go
func (d *Database) Del(path string) { d.mtx.Lock() defer d.mtx.Unlock() if path == "" { d.root = &Node{ Children: map[string]*Node{}, } return } rabbitHole := strings.Split(path, "/") current := d.root // traverse to target node's parent var delIdx int for ; delIdx < len(rabbitHole)-1; delIdx++ { ...
[ "func", "(", "d", "*", "Database", ")", "Del", "(", "path", "string", ")", "{", "d", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "if", "path", "==", "\"", "\"", "{", "d", ".", "root", ...
// Del removes the node at the given path.
[ "Del", "removes", "the", "node", "at", "the", "given", "path", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/sync/database.go#L88-L126
10,941
zabawaba99/firego
sync/database.go
Get
func (d *Database) Get(path string) *Node { d.mtx.RLock() defer d.mtx.RUnlock() current := d.root if path == "" { return current } rabbitHole := strings.Split(path, "/") for i := 0; i < len(rabbitHole); i++ { var ok bool current, ok = current.Children[rabbitHole[i]] if !ok { return nil } } retur...
go
func (d *Database) Get(path string) *Node { d.mtx.RLock() defer d.mtx.RUnlock() current := d.root if path == "" { return current } rabbitHole := strings.Split(path, "/") for i := 0; i < len(rabbitHole); i++ { var ok bool current, ok = current.Children[rabbitHole[i]] if !ok { return nil } } retur...
[ "func", "(", "d", "*", "Database", ")", "Get", "(", "path", "string", ")", "*", "Node", "{", "d", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mtx", ".", "RUnlock", "(", ")", "\n\n", "current", ":=", "d", ".", "root", "\n", "...
// Get fetches a node at a given path.
[ "Get", "fetches", "a", "node", "at", "a", "given", "path", "." ]
3bcc4b6a45996b7c44e53ebe85e156de7c8c2819
https://github.com/zabawaba99/firego/blob/3bcc4b6a45996b7c44e53ebe85e156de7c8c2819/sync/database.go#L129-L147
10,942
influxdata/influxql
parse_tree.go
Group
func (t *ParseTree) Group(tokens ...Token) *ParseTree { for _, tok := range tokens { // Look for the parse tree for this token. if subtree := t.Tokens[tok]; subtree != nil { t = subtree continue } // No subtree exists yet. Verify that we don't have a conflicting // statement. if _, conflict := t.Han...
go
func (t *ParseTree) Group(tokens ...Token) *ParseTree { for _, tok := range tokens { // Look for the parse tree for this token. if subtree := t.Tokens[tok]; subtree != nil { t = subtree continue } // No subtree exists yet. Verify that we don't have a conflicting // statement. if _, conflict := t.Han...
[ "func", "(", "t", "*", "ParseTree", ")", "Group", "(", "tokens", "...", "Token", ")", "*", "ParseTree", "{", "for", "_", ",", "tok", ":=", "range", "tokens", "{", "// Look for the parse tree for this token.", "if", "subtree", ":=", "t", ".", "Tokens", "[",...
// Group groups together a set of related handlers with a common token prefix.
[ "Group", "groups", "together", "a", "set", "of", "related", "handlers", "with", "a", "common", "token", "prefix", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parse_tree.go#L21-L46
10,943
influxdata/influxql
parse_tree.go
Handle
func (t *ParseTree) Handle(tok Token, fn func(*Parser) (Statement, error)) { // Verify that there is no conflict for this token in this parse tree. if _, conflict := t.Tokens[tok]; conflict { panic(fmt.Sprintf("conflict for token %s", tok)) } if _, conflict := t.Handlers[tok]; conflict { panic(fmt.Sprintf("con...
go
func (t *ParseTree) Handle(tok Token, fn func(*Parser) (Statement, error)) { // Verify that there is no conflict for this token in this parse tree. if _, conflict := t.Tokens[tok]; conflict { panic(fmt.Sprintf("conflict for token %s", tok)) } if _, conflict := t.Handlers[tok]; conflict { panic(fmt.Sprintf("con...
[ "func", "(", "t", "*", "ParseTree", ")", "Handle", "(", "tok", "Token", ",", "fn", "func", "(", "*", "Parser", ")", "(", "Statement", ",", "error", ")", ")", "{", "// Verify that there is no conflict for this token in this parse tree.", "if", "_", ",", "confli...
// Handle registers a handler to be invoked when seeing the given token.
[ "Handle", "registers", "a", "handler", "to", "be", "invoked", "when", "seeing", "the", "given", "token", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parse_tree.go#L49-L64
10,944
influxdata/influxql
parse_tree.go
Parse
func (t *ParseTree) Parse(p *Parser) (Statement, error) { for { tok, pos, lit := p.ScanIgnoreWhitespace() if subtree := t.Tokens[tok]; subtree != nil { t = subtree continue } if stmt := t.Handlers[tok]; stmt != nil { return stmt(p) } // There were no registered handlers. Return the valid tokens ...
go
func (t *ParseTree) Parse(p *Parser) (Statement, error) { for { tok, pos, lit := p.ScanIgnoreWhitespace() if subtree := t.Tokens[tok]; subtree != nil { t = subtree continue } if stmt := t.Handlers[tok]; stmt != nil { return stmt(p) } // There were no registered handlers. Return the valid tokens ...
[ "func", "(", "t", "*", "ParseTree", ")", "Parse", "(", "p", "*", "Parser", ")", "(", "Statement", ",", "error", ")", "{", "for", "{", "tok", ",", "pos", ",", "lit", ":=", "p", ".", "ScanIgnoreWhitespace", "(", ")", "\n", "if", "subtree", ":=", "t...
// Parse parses a statement using the language defined in the parse tree.
[ "Parse", "parses", "a", "statement", "using", "the", "language", "defined", "in", "the", "parse", "tree", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parse_tree.go#L67-L82
10,945
influxdata/influxql
scanner.go
NewScanner
func NewScanner(r io.Reader) *Scanner { return &Scanner{r: &reader{r: bufio.NewReader(r)}} }
go
func NewScanner(r io.Reader) *Scanner { return &Scanner{r: &reader{r: bufio.NewReader(r)}} }
[ "func", "NewScanner", "(", "r", "io", ".", "Reader", ")", "*", "Scanner", "{", "return", "&", "Scanner", "{", "r", ":", "&", "reader", "{", "r", ":", "bufio", ".", "NewReader", "(", "r", ")", "}", "}", "\n", "}" ]
// NewScanner returns a new instance of Scanner.
[ "NewScanner", "returns", "a", "new", "instance", "of", "Scanner", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L17-L19
10,946
influxdata/influxql
scanner.go
scanWhitespace
func (s *Scanner) scanWhitespace() (tok Token, pos Pos, lit string) { // Create a buffer and read the current character into it. var buf bytes.Buffer ch, pos := s.r.curr() _, _ = buf.WriteRune(ch) // Read every subsequent whitespace character into the buffer. // Non-whitespace characters and EOF will cause the l...
go
func (s *Scanner) scanWhitespace() (tok Token, pos Pos, lit string) { // Create a buffer and read the current character into it. var buf bytes.Buffer ch, pos := s.r.curr() _, _ = buf.WriteRune(ch) // Read every subsequent whitespace character into the buffer. // Non-whitespace characters and EOF will cause the l...
[ "func", "(", "s", "*", "Scanner", ")", "scanWhitespace", "(", ")", "(", "tok", "Token", ",", "pos", "Pos", ",", "lit", "string", ")", "{", "// Create a buffer and read the current character into it.", "var", "buf", "bytes", ".", "Buffer", "\n", "ch", ",", "p...
// scanWhitespace consumes the current rune and all contiguous whitespace.
[ "scanWhitespace", "consumes", "the", "current", "rune", "and", "all", "contiguous", "whitespace", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L140-L161
10,947
influxdata/influxql
scanner.go
skipUntilNewline
func (s *Scanner) skipUntilNewline() { for { if ch, _ := s.r.read(); ch == '\n' || ch == eof { return } } }
go
func (s *Scanner) skipUntilNewline() { for { if ch, _ := s.r.read(); ch == '\n' || ch == eof { return } } }
[ "func", "(", "s", "*", "Scanner", ")", "skipUntilNewline", "(", ")", "{", "for", "{", "if", "ch", ",", "_", ":=", "s", ".", "r", ".", "read", "(", ")", ";", "ch", "==", "'\\n'", "||", "ch", "==", "eof", "{", "return", "\n", "}", "\n", "}", ...
// skipUntilNewline skips characters until it reaches a newline.
[ "skipUntilNewline", "skips", "characters", "until", "it", "reaches", "a", "newline", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L164-L170
10,948
influxdata/influxql
scanner.go
scanString
func (s *Scanner) scanString() (tok Token, pos Pos, lit string) { s.r.unread() _, pos = s.r.curr() var err error lit, err = ScanString(s.r) if err == errBadString { return BADSTRING, pos, lit } else if err == errBadEscape { _, pos = s.r.curr() return BADESCAPE, pos, lit } return STRING, pos, lit }
go
func (s *Scanner) scanString() (tok Token, pos Pos, lit string) { s.r.unread() _, pos = s.r.curr() var err error lit, err = ScanString(s.r) if err == errBadString { return BADSTRING, pos, lit } else if err == errBadEscape { _, pos = s.r.curr() return BADESCAPE, pos, lit } return STRING, pos, lit }
[ "func", "(", "s", "*", "Scanner", ")", "scanString", "(", ")", "(", "tok", "Token", ",", "pos", "Pos", ",", "lit", "string", ")", "{", "s", ".", "r", ".", "unread", "(", ")", "\n", "_", ",", "pos", "=", "s", ".", "r", ".", "curr", "(", ")",...
// scanString consumes a contiguous string of non-quote characters. // Quote characters can be consumed if they're first escaped with a backslash.
[ "scanString", "consumes", "a", "contiguous", "string", "of", "non", "-", "quote", "characters", ".", "Quote", "characters", "can", "be", "consumed", "if", "they", "re", "first", "escaped", "with", "a", "backslash", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L229-L242
10,949
influxdata/influxql
scanner.go
ScanRegex
func (s *Scanner) ScanRegex() (tok Token, pos Pos, lit string) { _, pos = s.r.curr() // Start & end sentinels. start, end := '/', '/' // Valid escape chars. escapes := map[rune]rune{'/': '/'} b, err := ScanDelimited(s.r, start, end, escapes, true) if err == errBadEscape { _, pos = s.r.curr() return BADESC...
go
func (s *Scanner) ScanRegex() (tok Token, pos Pos, lit string) { _, pos = s.r.curr() // Start & end sentinels. start, end := '/', '/' // Valid escape chars. escapes := map[rune]rune{'/': '/'} b, err := ScanDelimited(s.r, start, end, escapes, true) if err == errBadEscape { _, pos = s.r.curr() return BADESC...
[ "func", "(", "s", "*", "Scanner", ")", "ScanRegex", "(", ")", "(", "tok", "Token", ",", "pos", "Pos", ",", "lit", "string", ")", "{", "_", ",", "pos", "=", "s", ".", "r", ".", "curr", "(", ")", "\n\n", "// Start & end sentinels.", "start", ",", "...
// ScanRegex consumes a token to find escapes
[ "ScanRegex", "consumes", "a", "token", "to", "find", "escapes" ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L245-L262
10,950
influxdata/influxql
scanner.go
scanNumber
func (s *Scanner) scanNumber() (tok Token, pos Pos, lit string) { var buf bytes.Buffer // Check if the initial rune is a ".". ch, pos := s.r.curr() if ch == '.' { // Peek and see if the next rune is a digit. ch1, _ := s.r.read() s.r.unread() if !isDigit(ch1) { return ILLEGAL, pos, "." } // Unread t...
go
func (s *Scanner) scanNumber() (tok Token, pos Pos, lit string) { var buf bytes.Buffer // Check if the initial rune is a ".". ch, pos := s.r.curr() if ch == '.' { // Peek and see if the next rune is a digit. ch1, _ := s.r.read() s.r.unread() if !isDigit(ch1) { return ILLEGAL, pos, "." } // Unread t...
[ "func", "(", "s", "*", "Scanner", ")", "scanNumber", "(", ")", "(", "tok", "Token", ",", "pos", "Pos", ",", "lit", "string", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n\n", "// Check if the initial rune is a \".\".", "ch", ",", "pos", ":=", "s", ...
// scanNumber consumes anything that looks like the start of a number.
[ "scanNumber", "consumes", "anything", "that", "looks", "like", "the", "start", "of", "a", "number", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L265-L332
10,951
influxdata/influxql
scanner.go
scanDigits
func (s *Scanner) scanDigits() string { var buf bytes.Buffer for { ch, _ := s.r.read() if !isDigit(ch) { s.r.unread() break } _, _ = buf.WriteRune(ch) } return buf.String() }
go
func (s *Scanner) scanDigits() string { var buf bytes.Buffer for { ch, _ := s.r.read() if !isDigit(ch) { s.r.unread() break } _, _ = buf.WriteRune(ch) } return buf.String() }
[ "func", "(", "s", "*", "Scanner", ")", "scanDigits", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "for", "{", "ch", ",", "_", ":=", "s", ".", "r", ".", "read", "(", ")", "\n", "if", "!", "isDigit", "(", "ch", ")", "{",...
// scanDigits consumes a contiguous series of digits.
[ "scanDigits", "consumes", "a", "contiguous", "series", "of", "digits", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L335-L346
10,952
influxdata/influxql
scanner.go
ScanRegex
func (s *bufScanner) ScanRegex() (tok Token, pos Pos, lit string) { return s.scanFunc(s.s.ScanRegex) }
go
func (s *bufScanner) ScanRegex() (tok Token, pos Pos, lit string) { return s.scanFunc(s.s.ScanRegex) }
[ "func", "(", "s", "*", "bufScanner", ")", "ScanRegex", "(", ")", "(", "tok", "Token", ",", "pos", "Pos", ",", "lit", "string", ")", "{", "return", "s", ".", "scanFunc", "(", "s", ".", "s", ".", "ScanRegex", ")", "\n", "}" ]
// ScanRegex reads a regex token from the scanner.
[ "ScanRegex", "reads", "a", "regex", "token", "from", "the", "scanner", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L387-L389
10,953
influxdata/influxql
scanner.go
scanFunc
func (s *bufScanner) scanFunc(scan func() (Token, Pos, string)) (tok Token, pos Pos, lit string) { // If we have unread tokens then read them off the buffer first. if s.n > 0 { s.n-- return s.curr() } // Move buffer position forward and save the token. s.i = (s.i + 1) % len(s.buf) buf := &s.buf[s.i] buf.tok...
go
func (s *bufScanner) scanFunc(scan func() (Token, Pos, string)) (tok Token, pos Pos, lit string) { // If we have unread tokens then read them off the buffer first. if s.n > 0 { s.n-- return s.curr() } // Move buffer position forward and save the token. s.i = (s.i + 1) % len(s.buf) buf := &s.buf[s.i] buf.tok...
[ "func", "(", "s", "*", "bufScanner", ")", "scanFunc", "(", "scan", "func", "(", ")", "(", "Token", ",", "Pos", ",", "string", ")", ")", "(", "tok", "Token", ",", "pos", "Pos", ",", "lit", "string", ")", "{", "// If we have unread tokens then read them of...
// scanFunc uses the provided function to scan the next token.
[ "scanFunc", "uses", "the", "provided", "function", "to", "scan", "the", "next", "token", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L392-L405
10,954
influxdata/influxql
scanner.go
ReadRune
func (r *reader) ReadRune() (ch rune, size int, err error) { ch, _ = r.read() if ch == eof { err = io.EOF } return }
go
func (r *reader) ReadRune() (ch rune, size int, err error) { ch, _ = r.read() if ch == eof { err = io.EOF } return }
[ "func", "(", "r", "*", "reader", ")", "ReadRune", "(", ")", "(", "ch", "rune", ",", "size", "int", ",", "err", "error", ")", "{", "ch", ",", "_", "=", "r", ".", "read", "(", ")", "\n", "if", "ch", "==", "eof", "{", "err", "=", "io", ".", ...
// ReadRune reads the next rune from the reader. // This is a wrapper function to implement the io.RuneReader interface. // Note that this function does not return size.
[ "ReadRune", "reads", "the", "next", "rune", "from", "the", "reader", ".", "This", "is", "a", "wrapper", "function", "to", "implement", "the", "io", ".", "RuneReader", "interface", ".", "Note", "that", "this", "function", "does", "not", "return", "size", "....
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L433-L439
10,955
influxdata/influxql
scanner.go
read
func (r *reader) read() (ch rune, pos Pos) { // If we have unread characters then read them off the buffer first. if r.n > 0 { r.n-- return r.curr() } // Read next rune from underlying reader. // Any error (including io.EOF) should return as EOF. ch, _, err := r.r.ReadRune() if err != nil { ch = eof } el...
go
func (r *reader) read() (ch rune, pos Pos) { // If we have unread characters then read them off the buffer first. if r.n > 0 { r.n-- return r.curr() } // Read next rune from underlying reader. // Any error (including io.EOF) should return as EOF. ch, _, err := r.r.ReadRune() if err != nil { ch = eof } el...
[ "func", "(", "r", "*", "reader", ")", "read", "(", ")", "(", "ch", "rune", ",", "pos", "Pos", ")", "{", "// If we have unread characters then read them off the buffer first.", "if", "r", ".", "n", ">", "0", "{", "r", ".", "n", "--", "\n", "return", "r", ...
// read reads the next rune from the reader.
[ "read", "reads", "the", "next", "rune", "from", "the", "reader", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L449-L491
10,956
influxdata/influxql
scanner.go
curr
func (r *reader) curr() (ch rune, pos Pos) { i := (r.i - r.n + len(r.buf)) % len(r.buf) buf := &r.buf[i] return buf.ch, buf.pos }
go
func (r *reader) curr() (ch rune, pos Pos) { i := (r.i - r.n + len(r.buf)) % len(r.buf) buf := &r.buf[i] return buf.ch, buf.pos }
[ "func", "(", "r", "*", "reader", ")", "curr", "(", ")", "(", "ch", "rune", ",", "pos", "Pos", ")", "{", "i", ":=", "(", "r", ".", "i", "-", "r", ".", "n", "+", "len", "(", "r", ".", "buf", ")", ")", "%", "len", "(", "r", ".", "buf", "...
// curr returns the last read character and position.
[ "curr", "returns", "the", "last", "read", "character", "and", "position", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L499-L503
10,957
influxdata/influxql
scanner.go
ScanDelimited
func ScanDelimited(r io.RuneScanner, start, end rune, escapes map[rune]rune, escapesPassThru bool) ([]byte, error) { // Scan start delimiter. if ch, _, err := r.ReadRune(); err != nil { return nil, err } else if ch != start { return nil, fmt.Errorf("expected %s; found %s", string(start), string(ch)) } var buf...
go
func ScanDelimited(r io.RuneScanner, start, end rune, escapes map[rune]rune, escapesPassThru bool) ([]byte, error) { // Scan start delimiter. if ch, _, err := r.ReadRune(); err != nil { return nil, err } else if ch != start { return nil, fmt.Errorf("expected %s; found %s", string(start), string(ch)) } var buf...
[ "func", "ScanDelimited", "(", "r", "io", ".", "RuneScanner", ",", "start", ",", "end", "rune", ",", "escapes", "map", "[", "rune", "]", "rune", ",", "escapesPassThru", "bool", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Scan start delimiter."...
// ScanDelimited reads a delimited set of runes
[ "ScanDelimited", "reads", "a", "delimited", "set", "of", "runes" ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L509-L555
10,958
influxdata/influxql
scanner.go
ScanString
func ScanString(r io.RuneScanner) (string, error) { ending, _, err := r.ReadRune() if err != nil { return "", errBadString } var buf bytes.Buffer for { ch0, _, err := r.ReadRune() if ch0 == ending { return buf.String(), nil } else if err != nil || ch0 == '\n' { return buf.String(), errBadString } ...
go
func ScanString(r io.RuneScanner) (string, error) { ending, _, err := r.ReadRune() if err != nil { return "", errBadString } var buf bytes.Buffer for { ch0, _, err := r.ReadRune() if ch0 == ending { return buf.String(), nil } else if err != nil || ch0 == '\n' { return buf.String(), errBadString } ...
[ "func", "ScanString", "(", "r", "io", ".", "RuneScanner", ")", "(", "string", ",", "error", ")", "{", "ending", ",", "_", ",", "err", ":=", "r", ".", "ReadRune", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "errBadStr...
// ScanString reads a quoted string from a rune reader.
[ "ScanString", "reads", "a", "quoted", "string", "from", "a", "rune", "reader", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L558-L590
10,959
influxdata/influxql
scanner.go
ScanBareIdent
func ScanBareIdent(r io.RuneScanner) string { // Read every ident character into the buffer. // Non-ident characters and EOF will cause the loop to exit. var buf bytes.Buffer for { ch, _, err := r.ReadRune() if err != nil { break } else if !isIdentChar(ch) { r.UnreadRune() break } else { _, _ = ...
go
func ScanBareIdent(r io.RuneScanner) string { // Read every ident character into the buffer. // Non-ident characters and EOF will cause the loop to exit. var buf bytes.Buffer for { ch, _, err := r.ReadRune() if err != nil { break } else if !isIdentChar(ch) { r.UnreadRune() break } else { _, _ = ...
[ "func", "ScanBareIdent", "(", "r", "io", ".", "RuneScanner", ")", "string", "{", "// Read every ident character into the buffer.", "// Non-ident characters and EOF will cause the loop to exit.", "var", "buf", "bytes", ".", "Buffer", "\n", "for", "{", "ch", ",", "_", ","...
// ScanBareIdent reads bare identifier from a rune reader.
[ "ScanBareIdent", "reads", "bare", "identifier", "from", "a", "rune", "reader", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/scanner.go#L596-L612
10,960
influxdata/influxql
sanitize.go
Sanitize
func Sanitize(query string) string { if matches := sanitizeSetPassword.FindAllStringSubmatchIndex(query, -1); matches != nil { var buf bytes.Buffer i := 0 for _, match := range matches { buf.WriteString(query[i:match[2]]) buf.WriteString("[REDACTED]") i = match[3] } buf.WriteString(query[i:]) quer...
go
func Sanitize(query string) string { if matches := sanitizeSetPassword.FindAllStringSubmatchIndex(query, -1); matches != nil { var buf bytes.Buffer i := 0 for _, match := range matches { buf.WriteString(query[i:match[2]]) buf.WriteString("[REDACTED]") i = match[3] } buf.WriteString(query[i:]) quer...
[ "func", "Sanitize", "(", "query", "string", ")", "string", "{", "if", "matches", ":=", "sanitizeSetPassword", ".", "FindAllStringSubmatchIndex", "(", "query", ",", "-", "1", ")", ";", "matches", "!=", "nil", "{", "var", "buf", "bytes", ".", "Buffer", "\n",...
// Sanitize attempts to sanitize passwords out of a raw query. // It looks for patterns that may be related to the SET PASSWORD and CREATE USER // statements and will redact the password that should be there. It will attempt // to redact information from common invalid queries too, but it's not guaranteed // to succeed...
[ "Sanitize", "attempts", "to", "sanitize", "passwords", "out", "of", "a", "raw", "query", ".", "It", "looks", "for", "patterns", "that", "may", "be", "related", "to", "the", "SET", "PASSWORD", "and", "CREATE", "USER", "statements", "and", "will", "redact", ...
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/sanitize.go#L22-L47
10,961
influxdata/influxql
ast.go
InspectDataType
func InspectDataType(v interface{}) DataType { switch v.(type) { case float64: return Float case int64, int32, int: return Integer case string: return String case bool: return Boolean case uint64: return Unsigned case time.Time: return Time case time.Duration: return Duration default: return Un...
go
func InspectDataType(v interface{}) DataType { switch v.(type) { case float64: return Float case int64, int32, int: return Integer case string: return String case bool: return Boolean case uint64: return Unsigned case time.Time: return Time case time.Duration: return Duration default: return Un...
[ "func", "InspectDataType", "(", "v", "interface", "{", "}", ")", "DataType", "{", "switch", "v", ".", "(", "type", ")", "{", "case", "float64", ":", "return", "Float", "\n", "case", "int64", ",", "int32", ",", "int", ":", "return", "Integer", "\n", "...
// InspectDataType returns the data type of a given value.
[ "InspectDataType", "returns", "the", "data", "type", "of", "a", "given", "value", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L76-L95
10,962
influxdata/influxql
ast.go
DataTypeFromString
func DataTypeFromString(s string) DataType { switch s { case "float": return Float case "integer": return Integer case "unsigned": return Unsigned case "string": return String case "boolean": return Boolean case "time": return Time case "duration": return Duration case "tag": return Tag case "...
go
func DataTypeFromString(s string) DataType { switch s { case "float": return Float case "integer": return Integer case "unsigned": return Unsigned case "string": return String case "boolean": return Boolean case "time": return Time case "duration": return Duration case "tag": return Tag case "...
[ "func", "DataTypeFromString", "(", "s", "string", ")", "DataType", "{", "switch", "s", "{", "case", "\"", "\"", ":", "return", "Float", "\n", "case", "\"", "\"", ":", "return", "Integer", "\n", "case", "\"", "\"", ":", "return", "Unsigned", "\n", "case...
// DataTypeFromString returns a data type given the string representation of that // data type.
[ "DataTypeFromString", "returns", "a", "data", "type", "given", "the", "string", "representation", "of", "that", "data", "type", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L99-L122
10,963
influxdata/influxql
ast.go
Zero
func (d DataType) Zero() interface{} { switch d { case Float: return zeroFloat64 case Integer: return zeroInt64 case Unsigned: return zeroUint64 case String, Tag: return zeroString case Boolean: return zeroBoolean case Time: return zeroTime case Duration: return zeroDuration } return nil }
go
func (d DataType) Zero() interface{} { switch d { case Float: return zeroFloat64 case Integer: return zeroInt64 case Unsigned: return zeroUint64 case String, Tag: return zeroString case Boolean: return zeroBoolean case Time: return zeroTime case Duration: return zeroDuration } return nil }
[ "func", "(", "d", "DataType", ")", "Zero", "(", ")", "interface", "{", "}", "{", "switch", "d", "{", "case", "Float", ":", "return", "zeroFloat64", "\n", "case", "Integer", ":", "return", "zeroInt64", "\n", "case", "Unsigned", ":", "return", "zeroUint64"...
// Zero returns the zero value for the DataType. // The return value of this method, when sent back to InspectDataType, // may not produce the same value.
[ "Zero", "returns", "the", "zero", "value", "for", "the", "DataType", ".", "The", "return", "value", "of", "this", "method", "when", "sent", "back", "to", "InspectDataType", "may", "not", "produce", "the", "same", "value", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L154-L172
10,964
influxdata/influxql
ast.go
String
func (d DataType) String() string { switch d { case Float: return "float" case Integer: return "integer" case Unsigned: return "unsigned" case String: return "string" case Boolean: return "boolean" case Time: return "time" case Duration: return "duration" case Tag: return "tag" case AnyField: ...
go
func (d DataType) String() string { switch d { case Float: return "float" case Integer: return "integer" case Unsigned: return "unsigned" case String: return "string" case Boolean: return "boolean" case Time: return "time" case Duration: return "duration" case Tag: return "tag" case AnyField: ...
[ "func", "(", "d", "DataType", ")", "String", "(", ")", "string", "{", "switch", "d", "{", "case", "Float", ":", "return", "\"", "\"", "\n", "case", "Integer", ":", "return", "\"", "\"", "\n", "case", "Unsigned", ":", "return", "\"", "\"", "\n", "ca...
// String returns the human-readable string representation of the DataType.
[ "String", "returns", "the", "human", "-", "readable", "string", "representation", "of", "the", "DataType", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L175-L197
10,965
influxdata/influxql
ast.go
String
func (a Statements) String() string { var str []string for _, stmt := range a { str = append(str, stmt.String()) } return strings.Join(str, ";\n") }
go
func (a Statements) String() string { var str []string for _, stmt := range a { str = append(str, stmt.String()) } return strings.Join(str, ";\n") }
[ "func", "(", "a", "Statements", ")", "String", "(", ")", "string", "{", "var", "str", "[", "]", "string", "\n", "for", "_", ",", "stmt", ":=", "range", "a", "{", "str", "=", "append", "(", "str", ",", "stmt", ".", "String", "(", ")", ")", "\n",...
// String returns a string representation of the statements.
[ "String", "returns", "a", "string", "representation", "of", "the", "statements", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L297-L303
10,966
influxdata/influxql
ast.go
String
func (a Sources) String() string { var buf bytes.Buffer ubound := len(a) - 1 for i, src := range a { _, _ = buf.WriteString(src.String()) if i < ubound { _, _ = buf.WriteString(", ") } } return buf.String() }
go
func (a Sources) String() string { var buf bytes.Buffer ubound := len(a) - 1 for i, src := range a { _, _ = buf.WriteString(src.String()) if i < ubound { _, _ = buf.WriteString(", ") } } return buf.String() }
[ "func", "(", "a", "Sources", ")", "String", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n\n", "ubound", ":=", "len", "(", "a", ")", "-", "1", "\n", "for", "i", ",", "src", ":=", "range", "a", "{", "_", ",", "_", "=", "buf...
// String returns a string representation of a Sources array.
[ "String", "returns", "a", "string", "representation", "of", "a", "Sources", "array", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L446-L458
10,967
influxdata/influxql
ast.go
Measurements
func (a Sources) Measurements() []*Measurement { mms := make([]*Measurement, 0, len(a)) for _, src := range a { switch src := src.(type) { case *Measurement: mms = append(mms, src) case *SubQuery: mms = append(mms, src.Statement.Sources.Measurements()...) } } return mms }
go
func (a Sources) Measurements() []*Measurement { mms := make([]*Measurement, 0, len(a)) for _, src := range a { switch src := src.(type) { case *Measurement: mms = append(mms, src) case *SubQuery: mms = append(mms, src.Statement.Sources.Measurements()...) } } return mms }
[ "func", "(", "a", "Sources", ")", "Measurements", "(", ")", "[", "]", "*", "Measurement", "{", "mms", ":=", "make", "(", "[", "]", "*", "Measurement", ",", "0", ",", "len", "(", "a", ")", ")", "\n", "for", "_", ",", "src", ":=", "range", "a", ...
// Measurements returns all measurements including ones embedded in subqueries.
[ "Measurements", "returns", "all", "measurements", "including", "ones", "embedded", "in", "subqueries", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L461-L472
10,968
influxdata/influxql
ast.go
MarshalBinary
func (a Sources) MarshalBinary() ([]byte, error) { var pb internal.Measurements pb.Items = make([]*internal.Measurement, len(a)) for i, source := range a { pb.Items[i] = encodeMeasurement(source.(*Measurement)) } return proto.Marshal(&pb) }
go
func (a Sources) MarshalBinary() ([]byte, error) { var pb internal.Measurements pb.Items = make([]*internal.Measurement, len(a)) for i, source := range a { pb.Items[i] = encodeMeasurement(source.(*Measurement)) } return proto.Marshal(&pb) }
[ "func", "(", "a", "Sources", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "pb", "internal", ".", "Measurements", "\n", "pb", ".", "Items", "=", "make", "(", "[", "]", "*", "internal", ".", "Measurement", ","...
// MarshalBinary encodes a list of sources to a binary format.
[ "MarshalBinary", "encodes", "a", "list", "of", "sources", "to", "a", "binary", "format", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L475-L482
10,969
influxdata/influxql
ast.go
UnmarshalBinary
func (a *Sources) UnmarshalBinary(buf []byte) error { var pb internal.Measurements if err := proto.Unmarshal(buf, &pb); err != nil { return err } *a = make(Sources, len(pb.GetItems())) for i := range pb.GetItems() { mm, err := decodeMeasurement(pb.GetItems()[i]) if err != nil { return err } (*a)[i] = ...
go
func (a *Sources) UnmarshalBinary(buf []byte) error { var pb internal.Measurements if err := proto.Unmarshal(buf, &pb); err != nil { return err } *a = make(Sources, len(pb.GetItems())) for i := range pb.GetItems() { mm, err := decodeMeasurement(pb.GetItems()[i]) if err != nil { return err } (*a)[i] = ...
[ "func", "(", "a", "*", "Sources", ")", "UnmarshalBinary", "(", "buf", "[", "]", "byte", ")", "error", "{", "var", "pb", "internal", ".", "Measurements", "\n", "if", "err", ":=", "proto", ".", "Unmarshal", "(", "buf", ",", "&", "pb", ")", ";", "err"...
// UnmarshalBinary decodes binary data into a list of sources.
[ "UnmarshalBinary", "decodes", "binary", "data", "into", "a", "list", "of", "sources", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L485-L499
10,970
influxdata/influxql
ast.go
RequiredPrivileges
func (a Sources) RequiredPrivileges() (ExecutionPrivileges, error) { var ep ExecutionPrivileges for _, source := range a { switch source := source.(type) { case *Measurement: ep = append(ep, ExecutionPrivilege{ Name: source.Database, Privilege: ReadPrivilege, }) case *SubQuery: privs, err ...
go
func (a Sources) RequiredPrivileges() (ExecutionPrivileges, error) { var ep ExecutionPrivileges for _, source := range a { switch source := source.(type) { case *Measurement: ep = append(ep, ExecutionPrivilege{ Name: source.Database, Privilege: ReadPrivilege, }) case *SubQuery: privs, err ...
[ "func", "(", "a", "Sources", ")", "RequiredPrivileges", "(", ")", "(", "ExecutionPrivileges", ",", "error", ")", "{", "var", "ep", "ExecutionPrivileges", "\n", "for", "_", ",", "source", ":=", "range", "a", "{", "switch", "source", ":=", "source", ".", "...
// RequiredPrivileges recursively returns a list of execution privileges required.
[ "RequiredPrivileges", "recursively", "returns", "a", "list", "of", "execution", "privileges", "required", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L502-L522
10,971
influxdata/influxql
ast.go
String
func (field *SortField) String() string { var buf bytes.Buffer if field.Name != "" { _, _ = buf.WriteString(field.Name) _, _ = buf.WriteString(" ") } if field.Ascending { _, _ = buf.WriteString("ASC") } else { _, _ = buf.WriteString("DESC") } return buf.String() }
go
func (field *SortField) String() string { var buf bytes.Buffer if field.Name != "" { _, _ = buf.WriteString(field.Name) _, _ = buf.WriteString(" ") } if field.Ascending { _, _ = buf.WriteString("ASC") } else { _, _ = buf.WriteString("DESC") } return buf.String() }
[ "func", "(", "field", "*", "SortField", ")", "String", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "if", "field", ".", "Name", "!=", "\"", "\"", "{", "_", ",", "_", "=", "buf", ".", "WriteString", "(", "field", ".", "Name...
// String returns a string representation of a sort field.
[ "String", "returns", "a", "string", "representation", "of", "a", "sort", "field", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L550-L562
10,972
influxdata/influxql
ast.go
String
func (a SortFields) String() string { fields := make([]string, 0, len(a)) for _, field := range a { fields = append(fields, field.String()) } return strings.Join(fields, ", ") }
go
func (a SortFields) String() string { fields := make([]string, 0, len(a)) for _, field := range a { fields = append(fields, field.String()) } return strings.Join(fields, ", ") }
[ "func", "(", "a", "SortFields", ")", "String", "(", ")", "string", "{", "fields", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "a", ")", ")", "\n", "for", "_", ",", "field", ":=", "range", "a", "{", "fields", "=", "append",...
// String returns a string representation of sort fields.
[ "String", "returns", "a", "string", "representation", "of", "sort", "fields", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L568-L574
10,973
influxdata/influxql
ast.go
String
func (s *CreateDatabaseStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("CREATE DATABASE ") _, _ = buf.WriteString(QuoteIdent(s.Name)) if s.RetentionPolicyCreate { _, _ = buf.WriteString(" WITH") if s.RetentionPolicyDuration != nil { _, _ = buf.WriteString(" DURATION ") _, _ = buf....
go
func (s *CreateDatabaseStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("CREATE DATABASE ") _, _ = buf.WriteString(QuoteIdent(s.Name)) if s.RetentionPolicyCreate { _, _ = buf.WriteString(" WITH") if s.RetentionPolicyDuration != nil { _, _ = buf.WriteString(" DURATION ") _, _ = buf....
[ "func", "(", "s", "*", "CreateDatabaseStatement", ")", "String", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "_", ",", "_", "=", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "_", ",", "_", "=", "buf", ".", "Writ...
// String returns a string representation of the create database statement.
[ "String", "returns", "a", "string", "representation", "of", "the", "create", "database", "statement", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L598-L623
10,974
influxdata/influxql
ast.go
String
func (s *DropRetentionPolicyStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("DROP RETENTION POLICY ") _, _ = buf.WriteString(QuoteIdent(s.Name)) _, _ = buf.WriteString(" ON ") _, _ = buf.WriteString(QuoteIdent(s.Database)) return buf.String() }
go
func (s *DropRetentionPolicyStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("DROP RETENTION POLICY ") _, _ = buf.WriteString(QuoteIdent(s.Name)) _, _ = buf.WriteString(" ON ") _, _ = buf.WriteString(QuoteIdent(s.Database)) return buf.String() }
[ "func", "(", "s", "*", "DropRetentionPolicyStatement", ")", "String", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "_", ",", "_", "=", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "_", ",", "_", "=", "buf", ".", ...
// String returns a string representation of the drop retention policy statement.
[ "String", "returns", "a", "string", "representation", "of", "the", "drop", "retention", "policy", "statement", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L659-L666
10,975
influxdata/influxql
ast.go
String
func (s *CreateUserStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("CREATE USER ") _, _ = buf.WriteString(QuoteIdent(s.Name)) _, _ = buf.WriteString(" WITH PASSWORD ") _, _ = buf.WriteString("[REDACTED]") if s.Admin { _, _ = buf.WriteString(" WITH ALL PRIVILEGES") } return buf.String(...
go
func (s *CreateUserStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("CREATE USER ") _, _ = buf.WriteString(QuoteIdent(s.Name)) _, _ = buf.WriteString(" WITH PASSWORD ") _, _ = buf.WriteString("[REDACTED]") if s.Admin { _, _ = buf.WriteString(" WITH ALL PRIVILEGES") } return buf.String(...
[ "func", "(", "s", "*", "CreateUserStatement", ")", "String", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "_", ",", "_", "=", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "_", ",", "_", "=", "buf", ".", "WriteStr...
// String returns a string representation of the create user statement.
[ "String", "returns", "a", "string", "representation", "of", "the", "create", "user", "statement", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L691-L701
10,976
influxdata/influxql
ast.go
String
func (s *GrantAdminStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("GRANT ALL PRIVILEGES TO ") _, _ = buf.WriteString(QuoteIdent(s.User)) return buf.String() }
go
func (s *GrantAdminStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("GRANT ALL PRIVILEGES TO ") _, _ = buf.WriteString(QuoteIdent(s.User)) return buf.String() }
[ "func", "(", "s", "*", "GrantAdminStatement", ")", "String", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "_", ",", "_", "=", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "_", ",", "_", "=", "buf", ".", "WriteStr...
// String returns a string representation of the grant admin statement.
[ "String", "returns", "a", "string", "representation", "of", "the", "grant", "admin", "statement", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L800-L805
10,977
influxdata/influxql
ast.go
String
func (s *KillQueryStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("KILL QUERY ") _, _ = buf.WriteString(strconv.FormatUint(s.QueryID, 10)) if s.Host != "" { _, _ = buf.WriteString(" ON ") _, _ = buf.WriteString(QuoteIdent(s.Host)) } return buf.String() }
go
func (s *KillQueryStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("KILL QUERY ") _, _ = buf.WriteString(strconv.FormatUint(s.QueryID, 10)) if s.Host != "" { _, _ = buf.WriteString(" ON ") _, _ = buf.WriteString(QuoteIdent(s.Host)) } return buf.String() }
[ "func", "(", "s", "*", "KillQueryStatement", ")", "String", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "_", ",", "_", "=", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "_", ",", "_", "=", "buf", ".", "WriteStri...
// String returns a string representation of the kill query statement.
[ "String", "returns", "a", "string", "representation", "of", "the", "kill", "query", "statement", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L822-L831
10,978
influxdata/influxql
ast.go
String
func (s *SetPasswordUserStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("SET PASSWORD FOR ") _, _ = buf.WriteString(QuoteIdent(s.Name)) _, _ = buf.WriteString(" = ") _, _ = buf.WriteString("[REDACTED]") return buf.String() }
go
func (s *SetPasswordUserStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("SET PASSWORD FOR ") _, _ = buf.WriteString(QuoteIdent(s.Name)) _, _ = buf.WriteString(" = ") _, _ = buf.WriteString("[REDACTED]") return buf.String() }
[ "func", "(", "s", "*", "SetPasswordUserStatement", ")", "String", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "_", ",", "_", "=", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "_", ",", "_", "=", "buf", ".", "Wri...
// String returns a string representation of the set password statement.
[ "String", "returns", "a", "string", "representation", "of", "the", "set", "password", "statement", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L848-L855
10,979
influxdata/influxql
ast.go
String
func (s *RevokeStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("REVOKE ") _, _ = buf.WriteString(s.Privilege.String()) _, _ = buf.WriteString(" ON ") _, _ = buf.WriteString(QuoteIdent(s.On)) _, _ = buf.WriteString(" FROM ") _, _ = buf.WriteString(QuoteIdent(s.User)) return buf.String() ...
go
func (s *RevokeStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("REVOKE ") _, _ = buf.WriteString(s.Privilege.String()) _, _ = buf.WriteString(" ON ") _, _ = buf.WriteString(QuoteIdent(s.On)) _, _ = buf.WriteString(" FROM ") _, _ = buf.WriteString(QuoteIdent(s.User)) return buf.String() ...
[ "func", "(", "s", "*", "RevokeStatement", ")", "String", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "_", ",", "_", "=", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "_", ",", "_", "=", "buf", ".", "WriteString"...
// String returns a string representation of the revoke statement.
[ "String", "returns", "a", "string", "representation", "of", "the", "revoke", "statement", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L875-L884
10,980
influxdata/influxql
ast.go
String
func (s *AlterRetentionPolicyStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("ALTER RETENTION POLICY ") _, _ = buf.WriteString(QuoteIdent(s.Name)) _, _ = buf.WriteString(" ON ") _, _ = buf.WriteString(QuoteIdent(s.Database)) if s.Duration != nil { _, _ = buf.WriteString(" DURATION ") ...
go
func (s *AlterRetentionPolicyStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("ALTER RETENTION POLICY ") _, _ = buf.WriteString(QuoteIdent(s.Name)) _, _ = buf.WriteString(" ON ") _, _ = buf.WriteString(QuoteIdent(s.Database)) if s.Duration != nil { _, _ = buf.WriteString(" DURATION ") ...
[ "func", "(", "s", "*", "AlterRetentionPolicyStatement", ")", "String", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "_", ",", "_", "=", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "_", ",", "_", "=", "buf", ".", ...
// String returns a string representation of the alter retention policy statement.
[ "String", "returns", "a", "string", "representation", "of", "the", "alter", "retention", "policy", "statement", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L989-L1016
10,981
influxdata/influxql
ast.go
TimeAscending
func (s *SelectStatement) TimeAscending() bool { return len(s.SortFields) == 0 || s.SortFields[0].Ascending }
go
func (s *SelectStatement) TimeAscending() bool { return len(s.SortFields) == 0 || s.SortFields[0].Ascending }
[ "func", "(", "s", "*", "SelectStatement", ")", "TimeAscending", "(", ")", "bool", "{", "return", "len", "(", "s", ".", "SortFields", ")", "==", "0", "||", "s", ".", "SortFields", "[", "0", "]", ".", "Ascending", "\n", "}" ]
// TimeAscending returns true if the time field is sorted in chronological order.
[ "TimeAscending", "returns", "true", "if", "the", "time", "field", "is", "sorted", "in", "chronological", "order", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1108-L1110
10,982
influxdata/influxql
ast.go
Clone
func (s *SelectStatement) Clone() *SelectStatement { clone := *s clone.Fields = make(Fields, 0, len(s.Fields)) clone.Dimensions = make(Dimensions, 0, len(s.Dimensions)) clone.Sources = cloneSources(s.Sources) clone.SortFields = make(SortFields, 0, len(s.SortFields)) clone.Condition = CloneExpr(s.Condition) if s...
go
func (s *SelectStatement) Clone() *SelectStatement { clone := *s clone.Fields = make(Fields, 0, len(s.Fields)) clone.Dimensions = make(Dimensions, 0, len(s.Dimensions)) clone.Sources = cloneSources(s.Sources) clone.SortFields = make(SortFields, 0, len(s.SortFields)) clone.Condition = CloneExpr(s.Condition) if s...
[ "func", "(", "s", "*", "SelectStatement", ")", "Clone", "(", ")", "*", "SelectStatement", "{", "clone", ":=", "*", "s", "\n", "clone", ".", "Fields", "=", "make", "(", "Fields", ",", "0", ",", "len", "(", "s", ".", "Fields", ")", ")", "\n", "clon...
// Clone returns a deep copy of the statement.
[ "Clone", "returns", "a", "deep", "copy", "of", "the", "statement", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1121-L1149
10,983
influxdata/influxql
ast.go
matchRegex
func matchRegex(re *syntax.Regexp) ([]string, bool) { // Exit if we see a case-insensitive flag as it is not something we support at this time. if re.Flags&syntax.FoldCase != 0 { return nil, false } switch re.Op { case syntax.OpLiteral: // We can rewrite this regex. return []string{string(re.Rune)}, true c...
go
func matchRegex(re *syntax.Regexp) ([]string, bool) { // Exit if we see a case-insensitive flag as it is not something we support at this time. if re.Flags&syntax.FoldCase != 0 { return nil, false } switch re.Op { case syntax.OpLiteral: // We can rewrite this regex. return []string{string(re.Rune)}, true c...
[ "func", "matchRegex", "(", "re", "*", "syntax", ".", "Regexp", ")", "(", "[", "]", "string", ",", "bool", ")", "{", "// Exit if we see a case-insensitive flag as it is not something we support at this time.", "if", "re", ".", "Flags", "&", "syntax", ".", "FoldCase",...
// matchRegex will match a regular expression to literals if possible.
[ "matchRegex", "will", "match", "a", "regular", "expression", "to", "literals", "if", "possible", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1518-L1595
10,984
influxdata/influxql
ast.go
RewriteTimeFields
func (s *SelectStatement) RewriteTimeFields() { for i := 0; i < len(s.Fields); i++ { switch expr := s.Fields[i].Expr.(type) { case *VarRef: if expr.Val == "time" { s.TimeAlias = s.Fields[i].Alias s.Fields = append(s.Fields[:i], s.Fields[i+1:]...) } } } }
go
func (s *SelectStatement) RewriteTimeFields() { for i := 0; i < len(s.Fields); i++ { switch expr := s.Fields[i].Expr.(type) { case *VarRef: if expr.Val == "time" { s.TimeAlias = s.Fields[i].Alias s.Fields = append(s.Fields[:i], s.Fields[i+1:]...) } } } }
[ "func", "(", "s", "*", "SelectStatement", ")", "RewriteTimeFields", "(", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "s", ".", "Fields", ")", ";", "i", "++", "{", "switch", "expr", ":=", "s", ".", "Fields", "[", "i", "]", ".", ...
// RewriteTimeFields removes any "time" field references.
[ "RewriteTimeFields", "removes", "any", "time", "field", "references", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1618-L1628
10,985
influxdata/influxql
ast.go
ColumnNames
func (s *SelectStatement) ColumnNames() []string { // First walk each field to determine the number of columns. columnFields := Fields{} for _, field := range s.Fields { columnFields = append(columnFields, field) switch f := field.Expr.(type) { case *Call: if s.Target == nil && (f.Name == "top" || f.Name =...
go
func (s *SelectStatement) ColumnNames() []string { // First walk each field to determine the number of columns. columnFields := Fields{} for _, field := range s.Fields { columnFields = append(columnFields, field) switch f := field.Expr.(type) { case *Call: if s.Target == nil && (f.Name == "top" || f.Name =...
[ "func", "(", "s", "*", "SelectStatement", ")", "ColumnNames", "(", ")", "[", "]", "string", "{", "// First walk each field to determine the number of columns.", "columnFields", ":=", "Fields", "{", "}", "\n", "for", "_", ",", "field", ":=", "range", "s", ".", ...
// ColumnNames will walk all fields and functions and return the appropriate field names for the select statement // while maintaining order of the field names.
[ "ColumnNames", "will", "walk", "all", "fields", "and", "functions", "and", "return", "the", "appropriate", "field", "names", "for", "the", "select", "statement", "while", "maintaining", "order", "of", "the", "field", "names", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1632-L1698
10,986
influxdata/influxql
ast.go
FieldExprByName
func (s *SelectStatement) FieldExprByName(name string) (int, Expr) { for i, f := range s.Fields { if f.Name() == name { return i, f.Expr } else if call, ok := f.Expr.(*Call); ok && (call.Name == "top" || call.Name == "bottom") && len(call.Args) > 2 { for _, arg := range call.Args[1 : len(call.Args)-1] { ...
go
func (s *SelectStatement) FieldExprByName(name string) (int, Expr) { for i, f := range s.Fields { if f.Name() == name { return i, f.Expr } else if call, ok := f.Expr.(*Call); ok && (call.Name == "top" || call.Name == "bottom") && len(call.Args) > 2 { for _, arg := range call.Args[1 : len(call.Args)-1] { ...
[ "func", "(", "s", "*", "SelectStatement", ")", "FieldExprByName", "(", "name", "string", ")", "(", "int", ",", "Expr", ")", "{", "for", "i", ",", "f", ":=", "range", "s", ".", "Fields", "{", "if", "f", ".", "Name", "(", ")", "==", "name", "{", ...
// FieldExprByName returns the expression that matches the field name and the // index where this was found. If the name matches one of the arguments to // "top" or "bottom", the variable reference inside of the function is returned // and the index is of the function call rather than the variable reference. // If no e...
[ "FieldExprByName", "returns", "the", "expression", "that", "matches", "the", "field", "name", "and", "the", "index", "where", "this", "was", "found", ".", "If", "the", "name", "matches", "one", "of", "the", "arguments", "to", "top", "or", "bottom", "the", ...
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1706-L1719
10,987
influxdata/influxql
ast.go
Reduce
func (s *SelectStatement) Reduce(valuer Valuer) *SelectStatement { stmt := s.Clone() stmt.Condition = Reduce(stmt.Condition, valuer) for _, d := range stmt.Dimensions { d.Expr = Reduce(d.Expr, valuer) } for _, source := range stmt.Sources { switch source := source.(type) { case *SubQuery: source.Statemen...
go
func (s *SelectStatement) Reduce(valuer Valuer) *SelectStatement { stmt := s.Clone() stmt.Condition = Reduce(stmt.Condition, valuer) for _, d := range stmt.Dimensions { d.Expr = Reduce(d.Expr, valuer) } for _, source := range stmt.Sources { switch source := source.(type) { case *SubQuery: source.Statemen...
[ "func", "(", "s", "*", "SelectStatement", ")", "Reduce", "(", "valuer", "Valuer", ")", "*", "SelectStatement", "{", "stmt", ":=", "s", ".", "Clone", "(", ")", "\n", "stmt", ".", "Condition", "=", "Reduce", "(", "stmt", ".", "Condition", ",", "valuer", ...
// Reduce calls the Reduce function on the different components of the // SelectStatement to reduce the statement.
[ "Reduce", "calls", "the", "Reduce", "function", "on", "the", "different", "components", "of", "the", "SelectStatement", "to", "reduce", "the", "statement", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1723-L1737
10,988
influxdata/influxql
ast.go
String
func (s *SelectStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("SELECT ") _, _ = buf.WriteString(s.Fields.String()) if s.Target != nil { _, _ = buf.WriteString(" ") _, _ = buf.WriteString(s.Target.String()) } if len(s.Sources) > 0 { _, _ = buf.WriteString(" FROM ") _, _ = buf.Wri...
go
func (s *SelectStatement) String() string { var buf bytes.Buffer _, _ = buf.WriteString("SELECT ") _, _ = buf.WriteString(s.Fields.String()) if s.Target != nil { _, _ = buf.WriteString(" ") _, _ = buf.WriteString(s.Target.String()) } if len(s.Sources) > 0 { _, _ = buf.WriteString(" FROM ") _, _ = buf.Wri...
[ "func", "(", "s", "*", "SelectStatement", ")", "String", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "_", ",", "_", "=", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "_", ",", "_", "=", "buf", ".", "WriteString"...
// String returns a string representation of the select statement.
[ "String", "returns", "a", "string", "representation", "of", "the", "select", "statement", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1740-L1792
10,989
influxdata/influxql
ast.go
HasFieldWildcard
func (s *SelectStatement) HasFieldWildcard() (hasWildcard bool) { WalkFunc(s.Fields, func(n Node) { if hasWildcard { return } switch n.(type) { case *Wildcard, *RegexLiteral: hasWildcard = true } }) return hasWildcard }
go
func (s *SelectStatement) HasFieldWildcard() (hasWildcard bool) { WalkFunc(s.Fields, func(n Node) { if hasWildcard { return } switch n.(type) { case *Wildcard, *RegexLiteral: hasWildcard = true } }) return hasWildcard }
[ "func", "(", "s", "*", "SelectStatement", ")", "HasFieldWildcard", "(", ")", "(", "hasWildcard", "bool", ")", "{", "WalkFunc", "(", "s", ".", "Fields", ",", "func", "(", "n", "Node", ")", "{", "if", "hasWildcard", "{", "return", "\n", "}", "\n", "swi...
// HasFieldWildcard returns whether or not the select statement has at least 1 wildcard in the fields.
[ "HasFieldWildcard", "returns", "whether", "or", "not", "the", "select", "statement", "has", "at", "least", "1", "wildcard", "in", "the", "fields", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1817-L1828
10,990
influxdata/influxql
ast.go
HasDimensionWildcard
func (s *SelectStatement) HasDimensionWildcard() bool { for _, d := range s.Dimensions { switch d.Expr.(type) { case *Wildcard, *RegexLiteral: return true } } return false }
go
func (s *SelectStatement) HasDimensionWildcard() bool { for _, d := range s.Dimensions { switch d.Expr.(type) { case *Wildcard, *RegexLiteral: return true } } return false }
[ "func", "(", "s", "*", "SelectStatement", ")", "HasDimensionWildcard", "(", ")", "bool", "{", "for", "_", ",", "d", ":=", "range", "s", ".", "Dimensions", "{", "switch", "d", ".", "Expr", ".", "(", "type", ")", "{", "case", "*", "Wildcard", ",", "*...
// HasDimensionWildcard returns whether or not the select statement has // at least 1 wildcard in the dimensions aka `GROUP BY`.
[ "HasDimensionWildcard", "returns", "whether", "or", "not", "the", "select", "statement", "has", "at", "least", "1", "wildcard", "in", "the", "dimensions", "aka", "GROUP", "BY", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1832-L1841
10,991
influxdata/influxql
ast.go
GroupByInterval
func (s *SelectStatement) GroupByInterval() (time.Duration, error) { // return if we've already pulled it out if s.groupByInterval != 0 { return s.groupByInterval, nil } // Ignore if there are no dimensions. if len(s.Dimensions) == 0 { return 0, nil } for _, d := range s.Dimensions { if call, ok := d.Exp...
go
func (s *SelectStatement) GroupByInterval() (time.Duration, error) { // return if we've already pulled it out if s.groupByInterval != 0 { return s.groupByInterval, nil } // Ignore if there are no dimensions. if len(s.Dimensions) == 0 { return 0, nil } for _, d := range s.Dimensions { if call, ok := d.Exp...
[ "func", "(", "s", "*", "SelectStatement", ")", "GroupByInterval", "(", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "// return if we've already pulled it out", "if", "s", ".", "groupByInterval", "!=", "0", "{", "return", "s", ".", "groupByInterva...
// GroupByInterval extracts the time interval, if specified.
[ "GroupByInterval", "extracts", "the", "time", "interval", "if", "specified", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1844-L1872
10,992
influxdata/influxql
ast.go
GroupByOffset
func (s *SelectStatement) GroupByOffset() (time.Duration, error) { interval, err := s.GroupByInterval() if err != nil { return 0, err } // Ignore if there are no dimensions. if len(s.Dimensions) == 0 { return 0, nil } for _, d := range s.Dimensions { if call, ok := d.Expr.(*Call); ok && call.Name == "tim...
go
func (s *SelectStatement) GroupByOffset() (time.Duration, error) { interval, err := s.GroupByInterval() if err != nil { return 0, err } // Ignore if there are no dimensions. if len(s.Dimensions) == 0 { return 0, nil } for _, d := range s.Dimensions { if call, ok := d.Expr.(*Call); ok && call.Name == "tim...
[ "func", "(", "s", "*", "SelectStatement", ")", "GroupByOffset", "(", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "interval", ",", "err", ":=", "s", ".", "GroupByInterval", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ...
// GroupByOffset extracts the time interval offset, if specified.
[ "GroupByOffset", "extracts", "the", "time", "interval", "offset", "if", "specified", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1875-L1902
10,993
influxdata/influxql
ast.go
SetTimeRange
func (s *SelectStatement) SetTimeRange(start, end time.Time) error { cond := fmt.Sprintf("time >= '%s' AND time < '%s'", start.UTC().Format(time.RFC3339Nano), end.UTC().Format(time.RFC3339Nano)) if s.Condition != nil { cond = fmt.Sprintf("%s AND %s", s.rewriteWithoutTimeDimensions(), cond) } expr, err := NewPars...
go
func (s *SelectStatement) SetTimeRange(start, end time.Time) error { cond := fmt.Sprintf("time >= '%s' AND time < '%s'", start.UTC().Format(time.RFC3339Nano), end.UTC().Format(time.RFC3339Nano)) if s.Condition != nil { cond = fmt.Sprintf("%s AND %s", s.rewriteWithoutTimeDimensions(), cond) } expr, err := NewPars...
[ "func", "(", "s", "*", "SelectStatement", ")", "SetTimeRange", "(", "start", ",", "end", "time", ".", "Time", ")", "error", "{", "cond", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "start", ".", "UTC", "(", ")", ".", "Format", "(", "time", ...
// SetTimeRange sets the start and end time of the select statement to [start, end). i.e. start inclusive, end exclusive. // This is used commonly for continuous queries so the start and end are in buckets.
[ "SetTimeRange", "sets", "the", "start", "and", "end", "time", "of", "the", "select", "statement", "to", "[", "start", "end", ")", ".", "i", ".", "e", ".", "start", "inclusive", "end", "exclusive", ".", "This", "is", "used", "commonly", "for", "continuous...
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1906-L1921
10,994
influxdata/influxql
ast.go
rewriteWithoutTimeDimensions
func (s *SelectStatement) rewriteWithoutTimeDimensions() string { n := RewriteFunc(s.Condition, func(n Node) Node { switch n := n.(type) { case *BinaryExpr: if n.LHS.String() == "time" { return &BooleanLiteral{Val: true} } return n case *Call: return &BooleanLiteral{Val: true} default: retur...
go
func (s *SelectStatement) rewriteWithoutTimeDimensions() string { n := RewriteFunc(s.Condition, func(n Node) Node { switch n := n.(type) { case *BinaryExpr: if n.LHS.String() == "time" { return &BooleanLiteral{Val: true} } return n case *Call: return &BooleanLiteral{Val: true} default: retur...
[ "func", "(", "s", "*", "SelectStatement", ")", "rewriteWithoutTimeDimensions", "(", ")", "string", "{", "n", ":=", "RewriteFunc", "(", "s", ".", "Condition", ",", "func", "(", "n", "Node", ")", "Node", "{", "switch", "n", ":=", "n", ".", "(", "type", ...
// rewriteWithoutTimeDimensions will remove any WHERE time... clauses from the select statement. // This is necessary when setting an explicit time range to override any that previously existed.
[ "rewriteWithoutTimeDimensions", "will", "remove", "any", "WHERE", "time", "...", "clauses", "from", "the", "select", "statement", ".", "This", "is", "necessary", "when", "setting", "an", "explicit", "time", "range", "to", "override", "any", "that", "previously", ...
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1925-L1941
10,995
influxdata/influxql
ast.go
walkNames
func walkNames(exp Expr) []string { switch expr := exp.(type) { case *VarRef: return []string{expr.Val} case *Call: var a []string for _, expr := range expr.Args { if ref, ok := expr.(*VarRef); ok { a = append(a, ref.Val) } } return a case *BinaryExpr: var ret []string ret = append(ret, walk...
go
func walkNames(exp Expr) []string { switch expr := exp.(type) { case *VarRef: return []string{expr.Val} case *Call: var a []string for _, expr := range expr.Args { if ref, ok := expr.(*VarRef); ok { a = append(a, ref.Val) } } return a case *BinaryExpr: var ret []string ret = append(ret, walk...
[ "func", "walkNames", "(", "exp", "Expr", ")", "[", "]", "string", "{", "switch", "expr", ":=", "exp", ".", "(", "type", ")", "{", "case", "*", "VarRef", ":", "return", "[", "]", "string", "{", "expr", ".", "Val", "}", "\n", "case", "*", "Call", ...
// walkNames will walk the Expr and return the identifier names used.
[ "walkNames", "will", "walk", "the", "Expr", "and", "return", "the", "identifier", "names", "used", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L1976-L1998
10,996
influxdata/influxql
ast.go
walkRefs
func walkRefs(exp Expr) []VarRef { refs := make(map[VarRef]struct{}) var walk func(exp Expr) walk = func(exp Expr) { switch expr := exp.(type) { case *VarRef: refs[*expr] = struct{}{} case *Call: for _, expr := range expr.Args { if ref, ok := expr.(*VarRef); ok { refs[*ref] = struct{}{} } ...
go
func walkRefs(exp Expr) []VarRef { refs := make(map[VarRef]struct{}) var walk func(exp Expr) walk = func(exp Expr) { switch expr := exp.(type) { case *VarRef: refs[*expr] = struct{}{} case *Call: for _, expr := range expr.Args { if ref, ok := expr.(*VarRef); ok { refs[*ref] = struct{}{} } ...
[ "func", "walkRefs", "(", "exp", "Expr", ")", "[", "]", "VarRef", "{", "refs", ":=", "make", "(", "map", "[", "VarRef", "]", "struct", "{", "}", ")", "\n", "var", "walk", "func", "(", "exp", "Expr", ")", "\n", "walk", "=", "func", "(", "exp", "E...
// walkRefs will walk the Expr and return the var refs used.
[ "walkRefs", "will", "walk", "the", "Expr", "and", "return", "the", "var", "refs", "used", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L2001-L2029
10,997
influxdata/influxql
ast.go
ExprNames
func ExprNames(expr Expr) []VarRef { m := make(map[VarRef]struct{}) for _, ref := range walkRefs(expr) { if ref.Val == "time" { continue } m[ref] = struct{}{} } a := make([]VarRef, 0, len(m)) for k := range m { a = append(a, k) } sort.Sort(VarRefs(a)) return a }
go
func ExprNames(expr Expr) []VarRef { m := make(map[VarRef]struct{}) for _, ref := range walkRefs(expr) { if ref.Val == "time" { continue } m[ref] = struct{}{} } a := make([]VarRef, 0, len(m)) for k := range m { a = append(a, k) } sort.Sort(VarRefs(a)) return a }
[ "func", "ExprNames", "(", "expr", "Expr", ")", "[", "]", "VarRef", "{", "m", ":=", "make", "(", "map", "[", "VarRef", "]", "struct", "{", "}", ")", "\n", "for", "_", ",", "ref", ":=", "range", "walkRefs", "(", "expr", ")", "{", "if", "ref", "."...
// ExprNames returns a list of non-"time" field names from an expression.
[ "ExprNames", "returns", "a", "list", "of", "non", "-", "time", "field", "names", "from", "an", "expression", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L2032-L2048
10,998
influxdata/influxql
ast.go
String
func (t *Target) String() string { if t == nil { return "" } var buf bytes.Buffer _, _ = buf.WriteString("INTO ") _, _ = buf.WriteString(t.Measurement.String()) if t.Measurement.Name == "" { _, _ = buf.WriteString(":MEASUREMENT") } return buf.String() }
go
func (t *Target) String() string { if t == nil { return "" } var buf bytes.Buffer _, _ = buf.WriteString("INTO ") _, _ = buf.WriteString(t.Measurement.String()) if t.Measurement.Name == "" { _, _ = buf.WriteString(":MEASUREMENT") } return buf.String() }
[ "func", "(", "t", "*", "Target", ")", "String", "(", ")", "string", "{", "if", "t", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n\n", "var", "buf", "bytes", ".", "Buffer", "\n", "_", ",", "_", "=", "buf", ".", "WriteString", "(", "\"",...
// String returns a string representation of the Target.
[ "String", "returns", "a", "string", "representation", "of", "the", "Target", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L2057-L2070
10,999
influxdata/influxql
ast.go
String
func (e *ExplainStatement) String() string { var buf bytes.Buffer buf.WriteString("EXPLAIN ") if e.Analyze { buf.WriteString("ANALYZE ") } buf.WriteString(e.Statement.String()) return buf.String() }
go
func (e *ExplainStatement) String() string { var buf bytes.Buffer buf.WriteString("EXPLAIN ") if e.Analyze { buf.WriteString("ANALYZE ") } buf.WriteString(e.Statement.String()) return buf.String() }
[ "func", "(", "e", "*", "ExplainStatement", ")", "String", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "if", "e", ".", "Analyze", "{", "buf", ".", "WriteString", "(", "\...
// String returns a string representation of the explain statement.
[ "String", "returns", "a", "string", "representation", "of", "the", "explain", "statement", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/ast.go#L2080-L2088