id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
133,100
influxdata/influxql
parser.go
parseShowTagValuesStatement
func (p *Parser) parseShowTagValuesStatement() (Statement, error) { stmt := &ShowTagValuesStatement{} var err error if tok, _, _ := p.ScanIgnoreWhitespace(); tok == EXACT { return p.parseShowTagValuesCardinalityStatement(true) } else if tok == CARDINALITY { return p.parseShowTagValuesCardinalityStatement(false...
go
func (p *Parser) parseShowTagValuesStatement() (Statement, error) { stmt := &ShowTagValuesStatement{} var err error if tok, _, _ := p.ScanIgnoreWhitespace(); tok == EXACT { return p.parseShowTagValuesCardinalityStatement(true) } else if tok == CARDINALITY { return p.parseShowTagValuesCardinalityStatement(false...
[ "func", "(", "p", "*", "Parser", ")", "parseShowTagValuesStatement", "(", ")", "(", "Statement", ",", "error", ")", "{", "stmt", ":=", "&", "ShowTagValuesStatement", "{", "}", "\n", "var", "err", "error", "\n\n", "if", "tok", ",", "_", ",", "_", ":=", ...
// parseShowTagValuesStatement parses a string and returns a Statement. // This function assumes the "SHOW TAG VALUES" tokens have already been consumed.
[ "parseShowTagValuesStatement", "parses", "a", "string", "and", "returns", "a", "Statement", ".", "This", "function", "assumes", "the", "SHOW", "TAG", "VALUES", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1263-L1320
133,101
influxdata/influxql
parser.go
parseShowTagValuesCardinalityStatement
func (p *Parser) parseShowTagValuesCardinalityStatement(exact bool) (Statement, error) { var err error stmt := &ShowTagValuesCardinalityStatement{Exact: exact} if stmt.Exact { // Parse remaining CARDINALITY token if tok, pos, lit := p.ScanIgnoreWhitespace(); tok != CARDINALITY { return nil, newParseError(tok...
go
func (p *Parser) parseShowTagValuesCardinalityStatement(exact bool) (Statement, error) { var err error stmt := &ShowTagValuesCardinalityStatement{Exact: exact} if stmt.Exact { // Parse remaining CARDINALITY token if tok, pos, lit := p.ScanIgnoreWhitespace(); tok != CARDINALITY { return nil, newParseError(tok...
[ "func", "(", "p", "*", "Parser", ")", "parseShowTagValuesCardinalityStatement", "(", "exact", "bool", ")", "(", "Statement", ",", "error", ")", "{", "var", "err", "error", "\n", "stmt", ":=", "&", "ShowTagValuesCardinalityStatement", "{", "Exact", ":", "exact"...
// This function assumes the "SHOW TAG VALUES" tokens have already been consumed.
[ "This", "function", "assumes", "the", "SHOW", "TAG", "VALUES", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1323-L1375
133,102
influxdata/influxql
parser.go
parseTagKeyExpr
func (p *Parser) parseTagKeyExpr() (Token, Literal, error) { var err error // Parse required WITH KEY tokens. if err := p.parseTokens([]Token{WITH, KEY}); err != nil { return 0, nil, err } // Parse required IN, EQ, or EQREGEX token. tok, pos, lit := p.ScanIgnoreWhitespace() if tok == IN { // Parse required...
go
func (p *Parser) parseTagKeyExpr() (Token, Literal, error) { var err error // Parse required WITH KEY tokens. if err := p.parseTokens([]Token{WITH, KEY}); err != nil { return 0, nil, err } // Parse required IN, EQ, or EQREGEX token. tok, pos, lit := p.ScanIgnoreWhitespace() if tok == IN { // Parse required...
[ "func", "(", "p", "*", "Parser", ")", "parseTagKeyExpr", "(", ")", "(", "Token", ",", "Literal", ",", "error", ")", "{", "var", "err", "error", "\n\n", "// Parse required WITH KEY tokens.", "if", "err", ":=", "p", ".", "parseTokens", "(", "[", "]", "Toke...
// parseTagKeys parses a string and returns a list of tag keys.
[ "parseTagKeys", "parses", "a", "string", "and", "returns", "a", "list", "of", "tag", "keys", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1378-L1424
133,103
influxdata/influxql
parser.go
parseShowFieldKeyCardinalityStatement
func (p *Parser) parseShowFieldKeyCardinalityStatement() (Statement, error) { var err error var exactCardinality bool requiredTokens := []string{"EXACT", "CARDINALITY"} if tok, _, _ := p.ScanIgnoreWhitespace(); tok == EXACT { exactCardinality = true requiredTokens = requiredTokens[1:] } else { p.Unscan() } ...
go
func (p *Parser) parseShowFieldKeyCardinalityStatement() (Statement, error) { var err error var exactCardinality bool requiredTokens := []string{"EXACT", "CARDINALITY"} if tok, _, _ := p.ScanIgnoreWhitespace(); tok == EXACT { exactCardinality = true requiredTokens = requiredTokens[1:] } else { p.Unscan() } ...
[ "func", "(", "p", "*", "Parser", ")", "parseShowFieldKeyCardinalityStatement", "(", ")", "(", "Statement", ",", "error", ")", "{", "var", "err", "error", "\n", "var", "exactCardinality", "bool", "\n", "requiredTokens", ":=", "[", "]", "string", "{", "\"", ...
// This function assumes the "SHOW FIELD KEY" tokens have already been consumed.
[ "This", "function", "assumes", "the", "SHOW", "FIELD", "KEY", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1440-L1494
133,104
influxdata/influxql
parser.go
parseShowFieldKeysStatement
func (p *Parser) parseShowFieldKeysStatement() (*ShowFieldKeysStatement, error) { stmt := &ShowFieldKeysStatement{} var err error // Parse optional ON clause. if tok, _, _ := p.ScanIgnoreWhitespace(); tok == ON { // Parse the database. stmt.Database, err = p.ParseIdent() if err != nil { return nil, err ...
go
func (p *Parser) parseShowFieldKeysStatement() (*ShowFieldKeysStatement, error) { stmt := &ShowFieldKeysStatement{} var err error // Parse optional ON clause. if tok, _, _ := p.ScanIgnoreWhitespace(); tok == ON { // Parse the database. stmt.Database, err = p.ParseIdent() if err != nil { return nil, err ...
[ "func", "(", "p", "*", "Parser", ")", "parseShowFieldKeysStatement", "(", ")", "(", "*", "ShowFieldKeysStatement", ",", "error", ")", "{", "stmt", ":=", "&", "ShowFieldKeysStatement", "{", "}", "\n", "var", "err", "error", "\n\n", "// Parse optional ON clause.",...
// parseShowFieldKeysStatement parses a string and returns a Statement. // This function assumes the "SHOW FIELD KEYS" tokens have already been consumed.
[ "parseShowFieldKeysStatement", "parses", "a", "string", "and", "returns", "a", "Statement", ".", "This", "function", "assumes", "the", "SHOW", "FIELD", "KEYS", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1498-L1538
133,105
influxdata/influxql
parser.go
parseDropMeasurementStatement
func (p *Parser) parseDropMeasurementStatement() (*DropMeasurementStatement, error) { stmt := &DropMeasurementStatement{} // Parse the name of the measurement to be dropped. lit, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = lit return stmt, nil }
go
func (p *Parser) parseDropMeasurementStatement() (*DropMeasurementStatement, error) { stmt := &DropMeasurementStatement{} // Parse the name of the measurement to be dropped. lit, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = lit return stmt, nil }
[ "func", "(", "p", "*", "Parser", ")", "parseDropMeasurementStatement", "(", ")", "(", "*", "DropMeasurementStatement", ",", "error", ")", "{", "stmt", ":=", "&", "DropMeasurementStatement", "{", "}", "\n\n", "// Parse the name of the measurement to be dropped.", "lit"...
// parseDropMeasurementStatement parses a string and returns a DropMeasurementStatement. // This function assumes the "DROP MEASUREMENT" tokens have already been consumed.
[ "parseDropMeasurementStatement", "parses", "a", "string", "and", "returns", "a", "DropMeasurementStatement", ".", "This", "function", "assumes", "the", "DROP", "MEASUREMENT", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1542-L1553
133,106
influxdata/influxql
parser.go
parseDropShardStatement
func (p *Parser) parseDropShardStatement() (*DropShardStatement, error) { var err error stmt := &DropShardStatement{} // Parse the ID of the shard to be dropped. if stmt.ID, err = p.ParseUInt64(); err != nil { return nil, err } return stmt, nil }
go
func (p *Parser) parseDropShardStatement() (*DropShardStatement, error) { var err error stmt := &DropShardStatement{} // Parse the ID of the shard to be dropped. if stmt.ID, err = p.ParseUInt64(); err != nil { return nil, err } return stmt, nil }
[ "func", "(", "p", "*", "Parser", ")", "parseDropShardStatement", "(", ")", "(", "*", "DropShardStatement", ",", "error", ")", "{", "var", "err", "error", "\n", "stmt", ":=", "&", "DropShardStatement", "{", "}", "\n\n", "// Parse the ID of the shard to be dropped...
// parseDropShardStatement parses a string and returns a // DropShardStatement. This function assumes the "DROP SHARD" tokens // have already been consumed.
[ "parseDropShardStatement", "parses", "a", "string", "and", "returns", "a", "DropShardStatement", ".", "This", "function", "assumes", "the", "DROP", "SHARD", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1606-L1615
133,107
influxdata/influxql
parser.go
parseGrantsForUserStatement
func (p *Parser) parseGrantsForUserStatement() (*ShowGrantsForUserStatement, error) { stmt := &ShowGrantsForUserStatement{} // Parse the name of the user to be displayed. lit, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = lit return stmt, nil }
go
func (p *Parser) parseGrantsForUserStatement() (*ShowGrantsForUserStatement, error) { stmt := &ShowGrantsForUserStatement{} // Parse the name of the user to be displayed. lit, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = lit return stmt, nil }
[ "func", "(", "p", "*", "Parser", ")", "parseGrantsForUserStatement", "(", ")", "(", "*", "ShowGrantsForUserStatement", ",", "error", ")", "{", "stmt", ":=", "&", "ShowGrantsForUserStatement", "{", "}", "\n\n", "// Parse the name of the user to be displayed.", "lit", ...
// parseGrantsForUserStatement parses a string and returns a ShowGrantsForUserStatement. // This function assumes the "SHOW GRANTS" tokens have already been consumed.
[ "parseGrantsForUserStatement", "parses", "a", "string", "and", "returns", "a", "ShowGrantsForUserStatement", ".", "This", "function", "assumes", "the", "SHOW", "GRANTS", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1625-L1636
133,108
influxdata/influxql
parser.go
parseCreateContinuousQueryStatement
func (p *Parser) parseCreateContinuousQueryStatement() (*CreateContinuousQueryStatement, error) { stmt := &CreateContinuousQueryStatement{} // Read the id of the query to create. ident, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = ident // Expect an "ON" keyword. if tok, pos, lit := p...
go
func (p *Parser) parseCreateContinuousQueryStatement() (*CreateContinuousQueryStatement, error) { stmt := &CreateContinuousQueryStatement{} // Read the id of the query to create. ident, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = ident // Expect an "ON" keyword. if tok, pos, lit := p...
[ "func", "(", "p", "*", "Parser", ")", "parseCreateContinuousQueryStatement", "(", ")", "(", "*", "CreateContinuousQueryStatement", ",", "error", ")", "{", "stmt", ":=", "&", "CreateContinuousQueryStatement", "{", "}", "\n\n", "// Read the id of the query to create.", ...
// parseCreateContinuousQueriesStatement parses a string and returns a CreateContinuousQueryStatement. // This function assumes the "CREATE CONTINUOUS" tokens have already been consumed.
[ "parseCreateContinuousQueriesStatement", "parses", "a", "string", "and", "returns", "a", "CreateContinuousQueryStatement", ".", "This", "function", "assumes", "the", "CREATE", "CONTINUOUS", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1646-L1714
133,109
influxdata/influxql
parser.go
parseCreateDatabaseStatement
func (p *Parser) parseCreateDatabaseStatement() (*CreateDatabaseStatement, error) { stmt := &CreateDatabaseStatement{} // Parse the name of the database to be created. lit, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = lit // Look for "WITH" if tok, _, _ := p.ScanIgnoreWhitespace(); to...
go
func (p *Parser) parseCreateDatabaseStatement() (*CreateDatabaseStatement, error) { stmt := &CreateDatabaseStatement{} // Parse the name of the database to be created. lit, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = lit // Look for "WITH" if tok, _, _ := p.ScanIgnoreWhitespace(); to...
[ "func", "(", "p", "*", "Parser", ")", "parseCreateDatabaseStatement", "(", ")", "(", "*", "CreateDatabaseStatement", ",", "error", ")", "{", "stmt", ":=", "&", "CreateDatabaseStatement", "{", "}", "\n\n", "// Parse the name of the database to be created.", "lit", ",...
// parseCreateDatabaseStatement parses a string and returns a CreateDatabaseStatement. // This function assumes the "CREATE DATABASE" tokens have already been consumed.
[ "parseCreateDatabaseStatement", "parses", "a", "string", "and", "returns", "a", "CreateDatabaseStatement", ".", "This", "function", "assumes", "the", "CREATE", "DATABASE", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1718-L1791
133,110
influxdata/influxql
parser.go
parseDropDatabaseStatement
func (p *Parser) parseDropDatabaseStatement() (*DropDatabaseStatement, error) { stmt := &DropDatabaseStatement{} // Parse the name of the database to be dropped. lit, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = lit return stmt, nil }
go
func (p *Parser) parseDropDatabaseStatement() (*DropDatabaseStatement, error) { stmt := &DropDatabaseStatement{} // Parse the name of the database to be dropped. lit, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = lit return stmt, nil }
[ "func", "(", "p", "*", "Parser", ")", "parseDropDatabaseStatement", "(", ")", "(", "*", "DropDatabaseStatement", ",", "error", ")", "{", "stmt", ":=", "&", "DropDatabaseStatement", "{", "}", "\n\n", "// Parse the name of the database to be dropped.", "lit", ",", "...
// parseDropDatabaseStatement parses a string and returns a DropDatabaseStatement. // This function assumes the DROP DATABASE tokens have already been consumed.
[ "parseDropDatabaseStatement", "parses", "a", "string", "and", "returns", "a", "DropDatabaseStatement", ".", "This", "function", "assumes", "the", "DROP", "DATABASE", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1795-L1806
133,111
influxdata/influxql
parser.go
parseDropSubscriptionStatement
func (p *Parser) parseDropSubscriptionStatement() (*DropSubscriptionStatement, error) { stmt := &DropSubscriptionStatement{} // Read the id of the subscription to drop. ident, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = ident // Expect an "ON" keyword. if tok, pos, lit := p.ScanIgnor...
go
func (p *Parser) parseDropSubscriptionStatement() (*DropSubscriptionStatement, error) { stmt := &DropSubscriptionStatement{} // Read the id of the subscription to drop. ident, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = ident // Expect an "ON" keyword. if tok, pos, lit := p.ScanIgnor...
[ "func", "(", "p", "*", "Parser", ")", "parseDropSubscriptionStatement", "(", ")", "(", "*", "DropSubscriptionStatement", ",", "error", ")", "{", "stmt", ":=", "&", "DropSubscriptionStatement", "{", "}", "\n\n", "// Read the id of the subscription to drop.", "ident", ...
// parseDropSubscriptionStatement parses a string and returns a DropSubscriptionStatement. // This function assumes the "DROP SUBSCRIPTION" tokens have already been consumed.
[ "parseDropSubscriptionStatement", "parses", "a", "string", "and", "returns", "a", "DropSubscriptionStatement", ".", "This", "function", "assumes", "the", "DROP", "SUBSCRIPTION", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1810-L1842
133,112
influxdata/influxql
parser.go
parseCreateUserStatement
func (p *Parser) parseCreateUserStatement() (*CreateUserStatement, error) { stmt := &CreateUserStatement{} // Parse name of the user to be created. ident, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = ident // Consume "WITH PASSWORD" tokens if err := p.parseTokens([]Token{WITH, PASSWOR...
go
func (p *Parser) parseCreateUserStatement() (*CreateUserStatement, error) { stmt := &CreateUserStatement{} // Parse name of the user to be created. ident, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = ident // Consume "WITH PASSWORD" tokens if err := p.parseTokens([]Token{WITH, PASSWOR...
[ "func", "(", "p", "*", "Parser", ")", "parseCreateUserStatement", "(", ")", "(", "*", "CreateUserStatement", ",", "error", ")", "{", "stmt", ":=", "&", "CreateUserStatement", "{", "}", "\n\n", "// Parse name of the user to be created.", "ident", ",", "err", ":="...
// parseCreateUserStatement parses a string and returns a CreateUserStatement. // This function assumes the "CREATE USER" tokens have already been consumed.
[ "parseCreateUserStatement", "parses", "a", "string", "and", "returns", "a", "CreateUserStatement", ".", "This", "function", "assumes", "the", "CREATE", "USER", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1871-L1906
133,113
influxdata/influxql
parser.go
parseDropUserStatement
func (p *Parser) parseDropUserStatement() (*DropUserStatement, error) { stmt := &DropUserStatement{} // Parse the name of the user to be dropped. lit, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = lit return stmt, nil }
go
func (p *Parser) parseDropUserStatement() (*DropUserStatement, error) { stmt := &DropUserStatement{} // Parse the name of the user to be dropped. lit, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = lit return stmt, nil }
[ "func", "(", "p", "*", "Parser", ")", "parseDropUserStatement", "(", ")", "(", "*", "DropUserStatement", ",", "error", ")", "{", "stmt", ":=", "&", "DropUserStatement", "{", "}", "\n\n", "// Parse the name of the user to be dropped.", "lit", ",", "err", ":=", ...
// parseDropUserStatement parses a string and returns a DropUserStatement. // This function assumes the DROP USER tokens have already been consumed.
[ "parseDropUserStatement", "parses", "a", "string", "and", "returns", "a", "DropUserStatement", ".", "This", "function", "assumes", "the", "DROP", "USER", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1910-L1921
133,114
influxdata/influxql
parser.go
parseExplainStatement
func (p *Parser) parseExplainStatement() (*ExplainStatement, error) { stmt := &ExplainStatement{} if tok, _, _ := p.ScanIgnoreWhitespace(); tok == ANALYZE { stmt.Analyze = true } else { p.Unscan() } if tok, pos, lit := p.ScanIgnoreWhitespace(); tok != SELECT { return nil, newParseError(tokstr(tok, lit), []...
go
func (p *Parser) parseExplainStatement() (*ExplainStatement, error) { stmt := &ExplainStatement{} if tok, _, _ := p.ScanIgnoreWhitespace(); tok == ANALYZE { stmt.Analyze = true } else { p.Unscan() } if tok, pos, lit := p.ScanIgnoreWhitespace(); tok != SELECT { return nil, newParseError(tokstr(tok, lit), []...
[ "func", "(", "p", "*", "Parser", ")", "parseExplainStatement", "(", ")", "(", "*", "ExplainStatement", ",", "error", ")", "{", "stmt", ":=", "&", "ExplainStatement", "{", "}", "\n\n", "if", "tok", ",", "_", ",", "_", ":=", "p", ".", "ScanIgnoreWhitespa...
// parseExplainStatement parses a string and return an ExplainStatement. // This function assumes the EXPLAIN token has already been consumed.
[ "parseExplainStatement", "parses", "a", "string", "and", "return", "an", "ExplainStatement", ".", "This", "function", "assumes", "the", "EXPLAIN", "token", "has", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1925-L1944
133,115
influxdata/influxql
parser.go
parseShowStatsStatement
func (p *Parser) parseShowStatsStatement() (*ShowStatsStatement, error) { stmt := &ShowStatsStatement{} var err error if tok, _, _ := p.ScanIgnoreWhitespace(); tok == FOR { stmt.Module, err = p.parseString() } else { p.Unscan() } return stmt, err }
go
func (p *Parser) parseShowStatsStatement() (*ShowStatsStatement, error) { stmt := &ShowStatsStatement{} var err error if tok, _, _ := p.ScanIgnoreWhitespace(); tok == FOR { stmt.Module, err = p.parseString() } else { p.Unscan() } return stmt, err }
[ "func", "(", "p", "*", "Parser", ")", "parseShowStatsStatement", "(", ")", "(", "*", "ShowStatsStatement", ",", "error", ")", "{", "stmt", ":=", "&", "ShowStatsStatement", "{", "}", "\n", "var", "err", "error", "\n\n", "if", "tok", ",", "_", ",", "_", ...
// parseShowStatsStatement parses a string and returns a ShowStatsStatement. // This function assumes the "SHOW STATS" tokens have already been consumed.
[ "parseShowStatsStatement", "parses", "a", "string", "and", "returns", "a", "ShowStatsStatement", ".", "This", "function", "assumes", "the", "SHOW", "STATS", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1960-L1971
133,116
influxdata/influxql
parser.go
parseShowDiagnosticsStatement
func (p *Parser) parseShowDiagnosticsStatement() (*ShowDiagnosticsStatement, error) { stmt := &ShowDiagnosticsStatement{} var err error if tok, _, _ := p.ScanIgnoreWhitespace(); tok == FOR { stmt.Module, err = p.parseString() } else { p.Unscan() } return stmt, err }
go
func (p *Parser) parseShowDiagnosticsStatement() (*ShowDiagnosticsStatement, error) { stmt := &ShowDiagnosticsStatement{} var err error if tok, _, _ := p.ScanIgnoreWhitespace(); tok == FOR { stmt.Module, err = p.parseString() } else { p.Unscan() } return stmt, err }
[ "func", "(", "p", "*", "Parser", ")", "parseShowDiagnosticsStatement", "(", ")", "(", "*", "ShowDiagnosticsStatement", ",", "error", ")", "{", "stmt", ":=", "&", "ShowDiagnosticsStatement", "{", "}", "\n", "var", "err", "error", "\n\n", "if", "tok", ",", "...
// parseShowDiagnostics parses a string and returns a ShowDiagnosticsStatement.
[ "parseShowDiagnostics", "parses", "a", "string", "and", "returns", "a", "ShowDiagnosticsStatement", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1974-L1985
133,117
influxdata/influxql
parser.go
parseDropContinuousQueryStatement
func (p *Parser) parseDropContinuousQueryStatement() (*DropContinuousQueryStatement, error) { stmt := &DropContinuousQueryStatement{} // Read the id of the query to drop. ident, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = ident // Expect an "ON" keyword. if tok, pos, lit := p.ScanIgn...
go
func (p *Parser) parseDropContinuousQueryStatement() (*DropContinuousQueryStatement, error) { stmt := &DropContinuousQueryStatement{} // Read the id of the query to drop. ident, err := p.ParseIdent() if err != nil { return nil, err } stmt.Name = ident // Expect an "ON" keyword. if tok, pos, lit := p.ScanIgn...
[ "func", "(", "p", "*", "Parser", ")", "parseDropContinuousQueryStatement", "(", ")", "(", "*", "DropContinuousQueryStatement", ",", "error", ")", "{", "stmt", ":=", "&", "DropContinuousQueryStatement", "{", "}", "\n\n", "// Read the id of the query to drop.", "ident",...
// parseDropContinuousQueriesStatement parses a string and returns a DropContinuousQueryStatement. // This function assumes the "DROP CONTINUOUS" tokens have already been consumed.
[ "parseDropContinuousQueriesStatement", "parses", "a", "string", "and", "returns", "a", "DropContinuousQueryStatement", ".", "This", "function", "assumes", "the", "DROP", "CONTINUOUS", "tokens", "have", "already", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L1989-L2011
133,118
influxdata/influxql
parser.go
parseFields
func (p *Parser) parseFields() (Fields, error) { var fields Fields for { // Parse the field. f, err := p.parseField() if err != nil { return nil, err } // Add new field. fields = append(fields, f) // If there's not a comma next then stop parsing fields. if tok, _, _ := p.Scan(); tok != COMMA { ...
go
func (p *Parser) parseFields() (Fields, error) { var fields Fields for { // Parse the field. f, err := p.parseField() if err != nil { return nil, err } // Add new field. fields = append(fields, f) // If there's not a comma next then stop parsing fields. if tok, _, _ := p.Scan(); tok != COMMA { ...
[ "func", "(", "p", "*", "Parser", ")", "parseFields", "(", ")", "(", "Fields", ",", "error", ")", "{", "var", "fields", "Fields", "\n\n", "for", "{", "// Parse the field.", "f", ",", "err", ":=", "p", ".", "parseField", "(", ")", "\n", "if", "err", ...
// parseFields parses a list of one or more fields.
[ "parseFields", "parses", "a", "list", "of", "one", "or", "more", "fields", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2014-L2034
133,119
influxdata/influxql
parser.go
parseField
func (p *Parser) parseField() (*Field, error) { f := &Field{} // Attempt to parse a regex. re, err := p.parseRegex() if err != nil { return nil, err } else if re != nil { f.Expr = re } else { _, pos, _ := p.ScanIgnoreWhitespace() p.Unscan() // Parse the expression first. expr, err := p.ParseExpr() ...
go
func (p *Parser) parseField() (*Field, error) { f := &Field{} // Attempt to parse a regex. re, err := p.parseRegex() if err != nil { return nil, err } else if re != nil { f.Expr = re } else { _, pos, _ := p.ScanIgnoreWhitespace() p.Unscan() // Parse the expression first. expr, err := p.ParseExpr() ...
[ "func", "(", "p", "*", "Parser", ")", "parseField", "(", ")", "(", "*", "Field", ",", "error", ")", "{", "f", ":=", "&", "Field", "{", "}", "\n\n", "// Attempt to parse a regex.", "re", ",", "err", ":=", "p", ".", "parseRegex", "(", ")", "\n", "if"...
// parseField parses a single field.
[ "parseField", "parses", "a", "single", "field", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2037-L2073
133,120
influxdata/influxql
parser.go
parseAlias
func (p *Parser) parseAlias() (string, error) { // Check if the next token is "AS". If not, then Unscan and exit. if tok, _, _ := p.ScanIgnoreWhitespace(); tok != AS { p.Unscan() return "", nil } // Then we should have the alias identifier. lit, err := p.ParseIdent() if err != nil { return "", err } retu...
go
func (p *Parser) parseAlias() (string, error) { // Check if the next token is "AS". If not, then Unscan and exit. if tok, _, _ := p.ScanIgnoreWhitespace(); tok != AS { p.Unscan() return "", nil } // Then we should have the alias identifier. lit, err := p.ParseIdent() if err != nil { return "", err } retu...
[ "func", "(", "p", "*", "Parser", ")", "parseAlias", "(", ")", "(", "string", ",", "error", ")", "{", "// Check if the next token is \"AS\". If not, then Unscan and exit.", "if", "tok", ",", "_", ",", "_", ":=", "p", ".", "ScanIgnoreWhitespace", "(", ")", ";", ...
// parseAlias parses the "AS IDENT" alias for fields and dimensions.
[ "parseAlias", "parses", "the", "AS", "IDENT", "alias", "for", "fields", "and", "dimensions", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2100-L2113
133,121
influxdata/influxql
parser.go
parseSources
func (p *Parser) parseSources(subqueries bool) (Sources, error) { var sources Sources for { s, err := p.parseSource(subqueries) if err != nil { return nil, err } sources = append(sources, s) if tok, _, _ := p.ScanIgnoreWhitespace(); tok != COMMA { p.Unscan() break } } return sources, nil }
go
func (p *Parser) parseSources(subqueries bool) (Sources, error) { var sources Sources for { s, err := p.parseSource(subqueries) if err != nil { return nil, err } sources = append(sources, s) if tok, _, _ := p.ScanIgnoreWhitespace(); tok != COMMA { p.Unscan() break } } return sources, nil }
[ "func", "(", "p", "*", "Parser", ")", "parseSources", "(", "subqueries", "bool", ")", "(", "Sources", ",", "error", ")", "{", "var", "sources", "Sources", "\n\n", "for", "{", "s", ",", "err", ":=", "p", ".", "parseSource", "(", "subqueries", ")", "\n...
// parseSources parses a comma delimited list of sources.
[ "parseSources", "parses", "a", "comma", "delimited", "list", "of", "sources", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2116-L2133
133,122
influxdata/influxql
parser.go
peekRune
func (p *Parser) peekRune() rune { r, _, _ := p.s.s.r.ReadRune() if r != eof { _ = p.s.s.r.UnreadRune() } return r }
go
func (p *Parser) peekRune() rune { r, _, _ := p.s.s.r.ReadRune() if r != eof { _ = p.s.s.r.UnreadRune() } return r }
[ "func", "(", "p", "*", "Parser", ")", "peekRune", "(", ")", "rune", "{", "r", ",", "_", ",", "_", ":=", "p", ".", "s", ".", "s", ".", "r", ".", "ReadRune", "(", ")", "\n", "if", "r", "!=", "eof", "{", "_", "=", "p", ".", "s", ".", "s", ...
// peekRune returns the next rune that would be read by the scanner.
[ "peekRune", "returns", "the", "next", "rune", "that", "would", "be", "read", "by", "the", "scanner", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2136-L2143
133,123
influxdata/influxql
parser.go
parseCondition
func (p *Parser) parseCondition() (Expr, error) { // Check if the WHERE token exists. if tok, _, _ := p.ScanIgnoreWhitespace(); tok != WHERE { p.Unscan() return nil, nil } // Scan the identifier for the source. expr, err := p.ParseExpr() if err != nil { return nil, err } return expr, nil }
go
func (p *Parser) parseCondition() (Expr, error) { // Check if the WHERE token exists. if tok, _, _ := p.ScanIgnoreWhitespace(); tok != WHERE { p.Unscan() return nil, nil } // Scan the identifier for the source. expr, err := p.ParseExpr() if err != nil { return nil, err } return expr, nil }
[ "func", "(", "p", "*", "Parser", ")", "parseCondition", "(", ")", "(", "Expr", ",", "error", ")", "{", "// Check if the WHERE token exists.", "if", "tok", ",", "_", ",", "_", ":=", "p", ".", "ScanIgnoreWhitespace", "(", ")", ";", "tok", "!=", "WHERE", ...
// parseCondition parses the "WHERE" clause of the query, if it exists.
[ "parseCondition", "parses", "the", "WHERE", "clause", "of", "the", "query", "if", "it", "exists", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2219-L2233
133,124
influxdata/influxql
parser.go
parseDimensions
func (p *Parser) parseDimensions() (Dimensions, error) { // If the next token is not GROUP then exit. if tok, _, _ := p.ScanIgnoreWhitespace(); tok != GROUP { p.Unscan() return nil, nil } // Now the next token should be "BY". if tok, pos, lit := p.ScanIgnoreWhitespace(); tok != BY { return nil, newParseErro...
go
func (p *Parser) parseDimensions() (Dimensions, error) { // If the next token is not GROUP then exit. if tok, _, _ := p.ScanIgnoreWhitespace(); tok != GROUP { p.Unscan() return nil, nil } // Now the next token should be "BY". if tok, pos, lit := p.ScanIgnoreWhitespace(); tok != BY { return nil, newParseErro...
[ "func", "(", "p", "*", "Parser", ")", "parseDimensions", "(", ")", "(", "Dimensions", ",", "error", ")", "{", "// If the next token is not GROUP then exit.", "if", "tok", ",", "_", ",", "_", ":=", "p", ".", "ScanIgnoreWhitespace", "(", ")", ";", "tok", "!=...
// parseDimensions parses the "GROUP BY" clause of the query, if it exists.
[ "parseDimensions", "parses", "the", "GROUP", "BY", "clause", "of", "the", "query", "if", "it", "exists", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2236-L2266
133,125
influxdata/influxql
parser.go
parseDimension
func (p *Parser) parseDimension() (*Dimension, error) { re, err := p.parseRegex() if err != nil { return nil, err } else if re != nil { return &Dimension{Expr: re}, nil } // Parse the expression first. expr, err := p.ParseExpr() if err != nil { return nil, err } // Consume all trailing whitespace. p.c...
go
func (p *Parser) parseDimension() (*Dimension, error) { re, err := p.parseRegex() if err != nil { return nil, err } else if re != nil { return &Dimension{Expr: re}, nil } // Parse the expression first. expr, err := p.ParseExpr() if err != nil { return nil, err } // Consume all trailing whitespace. p.c...
[ "func", "(", "p", "*", "Parser", ")", "parseDimension", "(", ")", "(", "*", "Dimension", ",", "error", ")", "{", "re", ",", "err", ":=", "p", ".", "parseRegex", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "...
// parseDimension parses a single dimension.
[ "parseDimension", "parses", "a", "single", "dimension", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2269-L2287
133,126
influxdata/influxql
parser.go
parseFill
func (p *Parser) parseFill() (FillOption, interface{}, error) { // Parse the expression first. tok, _, lit := p.ScanIgnoreWhitespace() p.Unscan() if tok != IDENT || strings.ToLower(lit) != "fill" { return NullFill, nil, nil } expr, err := p.ParseExpr() if err != nil { return NullFill, nil, err } fill, ok ...
go
func (p *Parser) parseFill() (FillOption, interface{}, error) { // Parse the expression first. tok, _, lit := p.ScanIgnoreWhitespace() p.Unscan() if tok != IDENT || strings.ToLower(lit) != "fill" { return NullFill, nil, nil } expr, err := p.ParseExpr() if err != nil { return NullFill, nil, err } fill, ok ...
[ "func", "(", "p", "*", "Parser", ")", "parseFill", "(", ")", "(", "FillOption", ",", "interface", "{", "}", ",", "error", ")", "{", "// Parse the expression first.", "tok", ",", "_", ",", "lit", ":=", "p", ".", "ScanIgnoreWhitespace", "(", ")", "\n", "...
// parseFill parses the fill call and its options.
[ "parseFill", "parses", "the", "fill", "call", "and", "its", "options", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2290-L2327
133,127
influxdata/influxql
parser.go
parseLocation
func (p *Parser) parseLocation() (*time.Location, error) { // Parse the expression first. tok, _, lit := p.ScanIgnoreWhitespace() p.Unscan() if tok != IDENT || strings.ToLower(lit) != "tz" { return nil, nil } expr, err := p.ParseExpr() if err != nil { return nil, err } tz, ok := expr.(*Call) if !ok { r...
go
func (p *Parser) parseLocation() (*time.Location, error) { // Parse the expression first. tok, _, lit := p.ScanIgnoreWhitespace() p.Unscan() if tok != IDENT || strings.ToLower(lit) != "tz" { return nil, nil } expr, err := p.ParseExpr() if err != nil { return nil, err } tz, ok := expr.(*Call) if !ok { r...
[ "func", "(", "p", "*", "Parser", ")", "parseLocation", "(", ")", "(", "*", "time", ".", "Location", ",", "error", ")", "{", "// Parse the expression first.", "tok", ",", "_", ",", "lit", ":=", "p", ".", "ScanIgnoreWhitespace", "(", ")", "\n", "p", ".",...
// parseLocation parses the timezone call and its arguments.
[ "parseLocation", "parses", "the", "timezone", "call", "and", "its", "arguments", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2330-L2360
133,128
influxdata/influxql
parser.go
ParseOptionalTokenAndInt
func (p *Parser) ParseOptionalTokenAndInt(t Token) (int, error) { // Check if the token exists. if tok, _, _ := p.ScanIgnoreWhitespace(); tok != t { p.Unscan() return 0, nil } // Scan the number. tok, pos, lit := p.ScanIgnoreWhitespace() if tok != INTEGER { return 0, newParseError(tokstr(tok, lit), []strin...
go
func (p *Parser) ParseOptionalTokenAndInt(t Token) (int, error) { // Check if the token exists. if tok, _, _ := p.ScanIgnoreWhitespace(); tok != t { p.Unscan() return 0, nil } // Scan the number. tok, pos, lit := p.ScanIgnoreWhitespace() if tok != INTEGER { return 0, newParseError(tokstr(tok, lit), []strin...
[ "func", "(", "p", "*", "Parser", ")", "ParseOptionalTokenAndInt", "(", "t", "Token", ")", "(", "int", ",", "error", ")", "{", "// Check if the token exists.", "if", "tok", ",", "_", ",", "_", ":=", "p", ".", "ScanIgnoreWhitespace", "(", ")", ";", "tok", ...
// ParseOptionalTokenAndInt parses the specified token followed // by an int, if it exists.
[ "ParseOptionalTokenAndInt", "parses", "the", "specified", "token", "followed", "by", "an", "int", "if", "it", "exists", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2364-L2385
133,129
influxdata/influxql
parser.go
parseOrderBy
func (p *Parser) parseOrderBy() (SortFields, error) { // Return nil result and nil error if no ORDER token at this position. if tok, _, _ := p.ScanIgnoreWhitespace(); tok != ORDER { p.Unscan() return nil, nil } // Parse the required BY token. if tok, pos, lit := p.ScanIgnoreWhitespace(); tok != BY { return ...
go
func (p *Parser) parseOrderBy() (SortFields, error) { // Return nil result and nil error if no ORDER token at this position. if tok, _, _ := p.ScanIgnoreWhitespace(); tok != ORDER { p.Unscan() return nil, nil } // Parse the required BY token. if tok, pos, lit := p.ScanIgnoreWhitespace(); tok != BY { return ...
[ "func", "(", "p", "*", "Parser", ")", "parseOrderBy", "(", ")", "(", "SortFields", ",", "error", ")", "{", "// Return nil result and nil error if no ORDER token at this position.", "if", "tok", ",", "_", ",", "_", ":=", "p", ".", "ScanIgnoreWhitespace", "(", ")"...
// parseOrderBy parses the "ORDER BY" clause of a query, if it exists.
[ "parseOrderBy", "parses", "the", "ORDER", "BY", "clause", "of", "a", "query", "if", "it", "exists", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2388-L2407
133,130
influxdata/influxql
parser.go
parseSortFields
func (p *Parser) parseSortFields() (SortFields, error) { var fields SortFields tok, pos, lit := p.ScanIgnoreWhitespace() switch tok { // The first field after an order by may not have a field name (e.g. ORDER BY ASC) case ASC, DESC: fields = append(fields, &SortField{Ascending: (tok == ASC)}) // If it's a tok...
go
func (p *Parser) parseSortFields() (SortFields, error) { var fields SortFields tok, pos, lit := p.ScanIgnoreWhitespace() switch tok { // The first field after an order by may not have a field name (e.g. ORDER BY ASC) case ASC, DESC: fields = append(fields, &SortField{Ascending: (tok == ASC)}) // If it's a tok...
[ "func", "(", "p", "*", "Parser", ")", "parseSortFields", "(", ")", "(", "SortFields", ",", "error", ")", "{", "var", "fields", "SortFields", "\n\n", "tok", ",", "pos", ",", "lit", ":=", "p", ".", "ScanIgnoreWhitespace", "(", ")", "\n\n", "switch", "tok...
// parseSortFields parses the sort fields for an ORDER BY clause.
[ "parseSortFields", "parses", "the", "sort", "fields", "for", "an", "ORDER", "BY", "clause", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2410-L2459
133,131
influxdata/influxql
parser.go
parseSortField
func (p *Parser) parseSortField() (*SortField, error) { field := &SortField{} // Parse sort field name. ident, err := p.ParseIdent() if err != nil { return nil, err } field.Name = ident // Check for optional ASC or DESC clause. Default is ASC. tok, _, _ := p.ScanIgnoreWhitespace() if tok != ASC && tok != D...
go
func (p *Parser) parseSortField() (*SortField, error) { field := &SortField{} // Parse sort field name. ident, err := p.ParseIdent() if err != nil { return nil, err } field.Name = ident // Check for optional ASC or DESC clause. Default is ASC. tok, _, _ := p.ScanIgnoreWhitespace() if tok != ASC && tok != D...
[ "func", "(", "p", "*", "Parser", ")", "parseSortField", "(", ")", "(", "*", "SortField", ",", "error", ")", "{", "field", ":=", "&", "SortField", "{", "}", "\n\n", "// Parse sort field name.", "ident", ",", "err", ":=", "p", ".", "ParseIdent", "(", ")"...
// parseSortField parses one field of an ORDER BY clause.
[ "parseSortField", "parses", "one", "field", "of", "an", "ORDER", "BY", "clause", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2462-L2481
133,132
influxdata/influxql
parser.go
ParseVarRef
func (p *Parser) ParseVarRef() (*VarRef, error) { // Parse the segments of the variable ref. segments, err := p.parseSegmentedIdents() if err != nil { return nil, err } var dtype DataType if tok, _, _ := p.Scan(); tok == DOUBLECOLON { tok, pos, lit := p.Scan() switch tok { case IDENT: switch strings.T...
go
func (p *Parser) ParseVarRef() (*VarRef, error) { // Parse the segments of the variable ref. segments, err := p.parseSegmentedIdents() if err != nil { return nil, err } var dtype DataType if tok, _, _ := p.Scan(); tok == DOUBLECOLON { tok, pos, lit := p.Scan() switch tok { case IDENT: switch strings.T...
[ "func", "(", "p", "*", "Parser", ")", "ParseVarRef", "(", ")", "(", "*", "VarRef", ",", "error", ")", "{", "// Parse the segments of the variable ref.", "segments", ",", "err", ":=", "p", ".", "parseSegmentedIdents", "(", ")", "\n", "if", "err", "!=", "nil...
// ParseVarRef parses a reference to a measurement or field.
[ "ParseVarRef", "parses", "a", "reference", "to", "a", "measurement", "or", "field", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2484-L2524
133,133
influxdata/influxql
parser.go
ParseExpr
func (p *Parser) ParseExpr() (Expr, error) { var err error // Dummy root node. root := &BinaryExpr{} // Parse a non-binary expression type to start. // This variable will always be the root of the expression tree. root.RHS, err = p.parseUnaryExpr() if err != nil { return nil, err } // Loop over operations ...
go
func (p *Parser) ParseExpr() (Expr, error) { var err error // Dummy root node. root := &BinaryExpr{} // Parse a non-binary expression type to start. // This variable will always be the root of the expression tree. root.RHS, err = p.parseUnaryExpr() if err != nil { return nil, err } // Loop over operations ...
[ "func", "(", "p", "*", "Parser", ")", "ParseExpr", "(", ")", "(", "Expr", ",", "error", ")", "{", "var", "err", "error", "\n", "// Dummy root node.", "root", ":=", "&", "BinaryExpr", "{", "}", "\n\n", "// Parse a non-binary expression type to start.", "// This...
// ParseExpr parses an expression.
[ "ParseExpr", "parses", "an", "expression", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2527-L2580
133,134
influxdata/influxql
parser.go
parseRegex
func (p *Parser) parseRegex() (*RegexLiteral, error) { nextRune := p.peekRune() if isWhitespace(nextRune) { p.consumeWhitespace() } // If the next character is not a '/', then return nils. nextRune = p.peekRune() if nextRune != '/' { return nil, nil } tok, pos, lit := p.s.ScanRegex() if tok == BADESCAPE...
go
func (p *Parser) parseRegex() (*RegexLiteral, error) { nextRune := p.peekRune() if isWhitespace(nextRune) { p.consumeWhitespace() } // If the next character is not a '/', then return nils. nextRune = p.peekRune() if nextRune != '/' { return nil, nil } tok, pos, lit := p.s.ScanRegex() if tok == BADESCAPE...
[ "func", "(", "p", "*", "Parser", ")", "parseRegex", "(", ")", "(", "*", "RegexLiteral", ",", "error", ")", "{", "nextRune", ":=", "p", ".", "peekRune", "(", ")", "\n", "if", "isWhitespace", "(", "nextRune", ")", "{", "p", ".", "consumeWhitespace", "(...
// parseRegex parses a regular expression.
[ "parseRegex", "parses", "a", "regular", "expression", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2754-L2784
133,135
influxdata/influxql
parser.go
parseCall
func (p *Parser) parseCall(name string) (*Call, error) { name = strings.ToLower(name) // Parse first function argument if one exists. var args []Expr re, err := p.parseRegex() if err != nil { return nil, err } else if re != nil { args = append(args, re) } else { // If there's a right paren then just retur...
go
func (p *Parser) parseCall(name string) (*Call, error) { name = strings.ToLower(name) // Parse first function argument if one exists. var args []Expr re, err := p.parseRegex() if err != nil { return nil, err } else if re != nil { args = append(args, re) } else { // If there's a right paren then just retur...
[ "func", "(", "p", "*", "Parser", ")", "parseCall", "(", "name", "string", ")", "(", "*", "Call", ",", "error", ")", "{", "name", "=", "strings", ".", "ToLower", "(", "name", ")", "\n\n", "// Parse first function argument if one exists.", "var", "args", "["...
// parseCall parses a function call. // This function assumes the function name and LPAREN have been consumed.
[ "parseCall", "parses", "a", "function", "call", ".", "This", "function", "assumes", "the", "function", "name", "and", "LPAREN", "have", "been", "consumed", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2788-L2842
133,136
influxdata/influxql
parser.go
ScanIgnoreWhitespace
func (p *Parser) ScanIgnoreWhitespace() (tok Token, pos Pos, lit string) { for { tok, pos, lit = p.Scan() if tok == WS || tok == COMMENT { continue } return } }
go
func (p *Parser) ScanIgnoreWhitespace() (tok Token, pos Pos, lit string) { for { tok, pos, lit = p.Scan() if tok == WS || tok == COMMENT { continue } return } }
[ "func", "(", "p", "*", "Parser", ")", "ScanIgnoreWhitespace", "(", ")", "(", "tok", "Token", ",", "pos", "Pos", ",", "lit", "string", ")", "{", "for", "{", "tok", ",", "pos", ",", "lit", "=", "p", ".", "Scan", "(", ")", "\n", "if", "tok", "==",...
// ScanIgnoreWhitespace scans the next non-whitespace and non-comment token.
[ "ScanIgnoreWhitespace", "scans", "the", "next", "non", "-", "whitespace", "and", "non", "-", "comment", "token", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2893-L2901
133,137
influxdata/influxql
parser.go
consumeWhitespace
func (p *Parser) consumeWhitespace() { if tok, _, _ := p.Scan(); tok != WS { p.Unscan() } }
go
func (p *Parser) consumeWhitespace() { if tok, _, _ := p.Scan(); tok != WS { p.Unscan() } }
[ "func", "(", "p", "*", "Parser", ")", "consumeWhitespace", "(", ")", "{", "if", "tok", ",", "_", ",", "_", ":=", "p", ".", "Scan", "(", ")", ";", "tok", "!=", "WS", "{", "p", ".", "Unscan", "(", ")", "\n", "}", "\n", "}" ]
// consumeWhitespace scans the next token if it's whitespace.
[ "consumeWhitespace", "scans", "the", "next", "token", "if", "it", "s", "whitespace", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L2904-L2908
133,138
influxdata/influxql
parser.go
parseTokens
func (p *Parser) parseTokens(toks []Token) error { for _, expected := range toks { if tok, pos, lit := p.ScanIgnoreWhitespace(); tok != expected { return newParseError(tokstr(tok, lit), []string{tokens[expected]}, pos) } } return nil }
go
func (p *Parser) parseTokens(toks []Token) error { for _, expected := range toks { if tok, pos, lit := p.ScanIgnoreWhitespace(); tok != expected { return newParseError(tokstr(tok, lit), []string{tokens[expected]}, pos) } } return nil }
[ "func", "(", "p", "*", "Parser", ")", "parseTokens", "(", "toks", "[", "]", "Token", ")", "error", "{", "for", "_", ",", "expected", ":=", "range", "toks", "{", "if", "tok", ",", "pos", ",", "lit", ":=", "p", ".", "ScanIgnoreWhitespace", "(", ")", ...
// parseTokens consumes an expected sequence of tokens.
[ "parseTokens", "consumes", "an", "expected", "sequence", "of", "tokens", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L3032-L3039
133,139
influxdata/influxql
parser.go
QuoteIdent
func QuoteIdent(segments ...string) string { var buf bytes.Buffer for i, segment := range segments { needQuote := IdentNeedsQuotes(segment) || ((i < len(segments)-1) && segment != "") || // not last segment && not "" ((i == 0 || i == len(segments)-1) && segment == "") // the first or last segment and an empty...
go
func QuoteIdent(segments ...string) string { var buf bytes.Buffer for i, segment := range segments { needQuote := IdentNeedsQuotes(segment) || ((i < len(segments)-1) && segment != "") || // not last segment && not "" ((i == 0 || i == len(segments)-1) && segment == "") // the first or last segment and an empty...
[ "func", "QuoteIdent", "(", "segments", "...", "string", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "for", "i", ",", "segment", ":=", "range", "segments", "{", "needQuote", ":=", "IdentNeedsQuotes", "(", "segment", ")", "||", "(", "("...
// QuoteIdent returns a quoted identifier from multiple bare identifiers.
[ "QuoteIdent", "returns", "a", "quoted", "identifier", "from", "multiple", "bare", "identifiers", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L3055-L3077
133,140
influxdata/influxql
parser.go
IdentNeedsQuotes
func IdentNeedsQuotes(ident string) bool { // check if this identifier is a keyword tok := Lookup(ident) if tok != IDENT { return true } for i, r := range ident { if i == 0 && !isIdentFirstChar(r) { return true } else if i > 0 && !isIdentChar(r) { return true } } return false }
go
func IdentNeedsQuotes(ident string) bool { // check if this identifier is a keyword tok := Lookup(ident) if tok != IDENT { return true } for i, r := range ident { if i == 0 && !isIdentFirstChar(r) { return true } else if i > 0 && !isIdentChar(r) { return true } } return false }
[ "func", "IdentNeedsQuotes", "(", "ident", "string", ")", "bool", "{", "// check if this identifier is a keyword", "tok", ":=", "Lookup", "(", "ident", ")", "\n", "if", "tok", "!=", "IDENT", "{", "return", "true", "\n", "}", "\n", "for", "i", ",", "r", ":="...
// IdentNeedsQuotes returns true if the ident string given would require quotes.
[ "IdentNeedsQuotes", "returns", "true", "if", "the", "ident", "string", "given", "would", "require", "quotes", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L3080-L3094
133,141
influxdata/influxql
parser.go
newParseError
func newParseError(found string, expected []string, pos Pos) *ParseError { return &ParseError{Found: found, Expected: expected, Pos: pos} }
go
func newParseError(found string, expected []string, pos Pos) *ParseError { return &ParseError{Found: found, Expected: expected, Pos: pos} }
[ "func", "newParseError", "(", "found", "string", ",", "expected", "[", "]", "string", ",", "pos", "Pos", ")", "*", "ParseError", "{", "return", "&", "ParseError", "{", "Found", ":", "found", ",", "Expected", ":", "expected", ",", "Pos", ":", "pos", "}"...
// newParseError returns a new instance of ParseError.
[ "newParseError", "returns", "a", "new", "instance", "of", "ParseError", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L3117-L3119
133,142
influxdata/influxql
parser.go
Error
func (e *ParseError) Error() string { if e.Message != "" { return fmt.Sprintf("%s at line %d, char %d", e.Message, e.Pos.Line+1, e.Pos.Char+1) } return fmt.Sprintf("found %s, expected %s at line %d, char %d", e.Found, strings.Join(e.Expected, ", "), e.Pos.Line+1, e.Pos.Char+1) }
go
func (e *ParseError) Error() string { if e.Message != "" { return fmt.Sprintf("%s at line %d, char %d", e.Message, e.Pos.Line+1, e.Pos.Char+1) } return fmt.Sprintf("found %s, expected %s at line %d, char %d", e.Found, strings.Join(e.Expected, ", "), e.Pos.Line+1, e.Pos.Char+1) }
[ "func", "(", "e", "*", "ParseError", ")", "Error", "(", ")", "string", "{", "if", "e", ".", "Message", "!=", "\"", "\"", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "Message", ",", "e", ".", "Pos", ".", "Line", "+", ...
// Error returns the string representation of the error.
[ "Error", "returns", "the", "string", "representation", "of", "the", "error", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/parser.go#L3122-L3127
133,143
influxdata/influxql
token.go
tokstr
func tokstr(tok Token, lit string) string { if lit != "" { return lit } return tok.String() }
go
func tokstr(tok Token, lit string) string { if lit != "" { return lit } return tok.String() }
[ "func", "tokstr", "(", "tok", "Token", ",", "lit", "string", ")", "string", "{", "if", "lit", "!=", "\"", "\"", "{", "return", "lit", "\n", "}", "\n", "return", "tok", ".", "String", "(", ")", "\n", "}" ]
// tokstr returns a literal if provided, otherwise returns the token string.
[ "tokstr", "returns", "a", "literal", "if", "provided", "otherwise", "returns", "the", "token", "string", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/token.go#L312-L317
133,144
influxdata/influxql
token.go
Lookup
func Lookup(ident string) Token { if tok, ok := keywords[strings.ToLower(ident)]; ok { return tok } return IDENT }
go
func Lookup(ident string) Token { if tok, ok := keywords[strings.ToLower(ident)]; ok { return tok } return IDENT }
[ "func", "Lookup", "(", "ident", "string", ")", "Token", "{", "if", "tok", ",", "ok", ":=", "keywords", "[", "strings", ".", "ToLower", "(", "ident", ")", "]", ";", "ok", "{", "return", "tok", "\n", "}", "\n", "return", "IDENT", "\n", "}" ]
// Lookup returns the token associated with a given string.
[ "Lookup", "returns", "the", "token", "associated", "with", "a", "given", "string", "." ]
1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513
https://github.com/influxdata/influxql/blob/1cbfca8e56b6eaa120f5b5161e4f0d5edcc9e513/token.go#L320-L325
133,145
GuiaBolso/darwin
driver.go
NewGenericDriver
func NewGenericDriver(db *sql.DB, dialect Dialect) *GenericDriver { if db == nil { panic("darwin: sql.DB is nil") } if dialect == nil { panic("darwin: dialect is nil") } return &GenericDriver{DB: db, Dialect: dialect} }
go
func NewGenericDriver(db *sql.DB, dialect Dialect) *GenericDriver { if db == nil { panic("darwin: sql.DB is nil") } if dialect == nil { panic("darwin: dialect is nil") } return &GenericDriver{DB: db, Dialect: dialect} }
[ "func", "NewGenericDriver", "(", "db", "*", "sql", ".", "DB", ",", "dialect", "Dialect", ")", "*", "GenericDriver", "{", "if", "db", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "dialect", "==", "nil", "{", "panic", "("...
// NewGenericDriver creates a new GenericDriver configured with db and dialect. // Panic if db or dialect is nil
[ "NewGenericDriver", "creates", "a", "new", "GenericDriver", "configured", "with", "db", "and", "dialect", ".", "Panic", "if", "db", "or", "dialect", "is", "nil" ]
86919dfcf80873d58ea2e527c15b1e02a5636ead
https://github.com/GuiaBolso/darwin/blob/86919dfcf80873d58ea2e527c15b1e02a5636ead/driver.go#L34-L44
133,146
GuiaBolso/darwin
driver.go
Create
func (m *GenericDriver) Create() error { err := transaction(m.DB, func(tx *sql.Tx) error { _, err := tx.Exec(m.Dialect.CreateTableSQL()) return err }) return err }
go
func (m *GenericDriver) Create() error { err := transaction(m.DB, func(tx *sql.Tx) error { _, err := tx.Exec(m.Dialect.CreateTableSQL()) return err }) return err }
[ "func", "(", "m", "*", "GenericDriver", ")", "Create", "(", ")", "error", "{", "err", ":=", "transaction", "(", "m", ".", "DB", ",", "func", "(", "tx", "*", "sql", ".", "Tx", ")", "error", "{", "_", ",", "err", ":=", "tx", ".", "Exec", "(", "...
// Create create the table darwin_migrations if necessary
[ "Create", "create", "the", "table", "darwin_migrations", "if", "necessary" ]
86919dfcf80873d58ea2e527c15b1e02a5636ead
https://github.com/GuiaBolso/darwin/blob/86919dfcf80873d58ea2e527c15b1e02a5636ead/driver.go#L47-L54
133,147
GuiaBolso/darwin
driver.go
Insert
func (m *GenericDriver) Insert(e MigrationRecord) error { err := transaction(m.DB, func(tx *sql.Tx) error { _, err := tx.Exec(m.Dialect.InsertSQL(), e.Version, e.Description, e.Checksum, e.AppliedAt.Unix(), e.ExecutionTime, ) return err }) return err }
go
func (m *GenericDriver) Insert(e MigrationRecord) error { err := transaction(m.DB, func(tx *sql.Tx) error { _, err := tx.Exec(m.Dialect.InsertSQL(), e.Version, e.Description, e.Checksum, e.AppliedAt.Unix(), e.ExecutionTime, ) return err }) return err }
[ "func", "(", "m", "*", "GenericDriver", ")", "Insert", "(", "e", "MigrationRecord", ")", "error", "{", "err", ":=", "transaction", "(", "m", ".", "DB", ",", "func", "(", "tx", "*", "sql", ".", "Tx", ")", "error", "{", "_", ",", "err", ":=", "tx",...
// Insert insert a migration entry into database
[ "Insert", "insert", "a", "migration", "entry", "into", "database" ]
86919dfcf80873d58ea2e527c15b1e02a5636ead
https://github.com/GuiaBolso/darwin/blob/86919dfcf80873d58ea2e527c15b1e02a5636ead/driver.go#L57-L71
133,148
GuiaBolso/darwin
driver.go
All
func (m *GenericDriver) All() ([]MigrationRecord, error) { entries := []MigrationRecord{} rows, err := m.DB.Query(m.Dialect.AllSQL()) if err != nil { return []MigrationRecord{}, err } for rows.Next() { var ( version float64 description string checksum string appliedAt int64 e...
go
func (m *GenericDriver) All() ([]MigrationRecord, error) { entries := []MigrationRecord{} rows, err := m.DB.Query(m.Dialect.AllSQL()) if err != nil { return []MigrationRecord{}, err } for rows.Next() { var ( version float64 description string checksum string appliedAt int64 e...
[ "func", "(", "m", "*", "GenericDriver", ")", "All", "(", ")", "(", "[", "]", "MigrationRecord", ",", "error", ")", "{", "entries", ":=", "[", "]", "MigrationRecord", "{", "}", "\n\n", "rows", ",", "err", ":=", "m", ".", "DB", ".", "Query", "(", "...
// All returns all migrations applied
[ "All", "returns", "all", "migrations", "applied" ]
86919dfcf80873d58ea2e527c15b1e02a5636ead
https://github.com/GuiaBolso/darwin/blob/86919dfcf80873d58ea2e527c15b1e02a5636ead/driver.go#L74-L114
133,149
GuiaBolso/darwin
driver.go
Exec
func (m *GenericDriver) Exec(script string) (time.Duration, error) { start := time.Now() err := transaction(m.DB, func(tx *sql.Tx) error { _, err := tx.Exec(script) return err }) return time.Since(start), err }
go
func (m *GenericDriver) Exec(script string) (time.Duration, error) { start := time.Now() err := transaction(m.DB, func(tx *sql.Tx) error { _, err := tx.Exec(script) return err }) return time.Since(start), err }
[ "func", "(", "m", "*", "GenericDriver", ")", "Exec", "(", "script", "string", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "start", ":=", "time", ".", "Now", "(", ")", "\n\n", "err", ":=", "transaction", "(", "m", ".", "DB", ",", "f...
// Exec execute sql scripts into database
[ "Exec", "execute", "sql", "scripts", "into", "database" ]
86919dfcf80873d58ea2e527c15b1e02a5636ead
https://github.com/GuiaBolso/darwin/blob/86919dfcf80873d58ea2e527c15b1e02a5636ead/driver.go#L117-L126
133,150
GuiaBolso/darwin
darwin.go
Checksum
func (m Migration) Checksum() string { return fmt.Sprintf("%x", md5.Sum([]byte(m.Script))) }
go
func (m Migration) Checksum() string { return fmt.Sprintf("%x", md5.Sum([]byte(m.Script))) }
[ "func", "(", "m", "Migration", ")", "Checksum", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "md5", ".", "Sum", "(", "[", "]", "byte", "(", "m", ".", "Script", ")", ")", ")", "\n", "}" ]
// Checksum calculate the Script md5
[ "Checksum", "calculate", "the", "Script", "md5" ]
86919dfcf80873d58ea2e527c15b1e02a5636ead
https://github.com/GuiaBolso/darwin/blob/86919dfcf80873d58ea2e527c15b1e02a5636ead/darwin.go#L51-L53
133,151
GuiaBolso/darwin
darwin.go
Migrate
func (d Darwin) Migrate() error { return Migrate(d.driver, d.migrations, d.infoChan) }
go
func (d Darwin) Migrate() error { return Migrate(d.driver, d.migrations, d.infoChan) }
[ "func", "(", "d", "Darwin", ")", "Migrate", "(", ")", "error", "{", "return", "Migrate", "(", "d", ".", "driver", ",", "d", ".", "migrations", ",", "d", ".", "infoChan", ")", "\n", "}" ]
// Migrate executes the missing migrations in database
[ "Migrate", "executes", "the", "missing", "migrations", "in", "database" ]
86919dfcf80873d58ea2e527c15b1e02a5636ead
https://github.com/GuiaBolso/darwin/blob/86919dfcf80873d58ea2e527c15b1e02a5636ead/darwin.go#L76-L78
133,152
GuiaBolso/darwin
darwin.go
New
func New(driver Driver, migrations []Migration, infoChan chan MigrationInfo) Darwin { return Darwin{ driver: driver, migrations: migrations, infoChan: infoChan, } }
go
func New(driver Driver, migrations []Migration, infoChan chan MigrationInfo) Darwin { return Darwin{ driver: driver, migrations: migrations, infoChan: infoChan, } }
[ "func", "New", "(", "driver", "Driver", ",", "migrations", "[", "]", "Migration", ",", "infoChan", "chan", "MigrationInfo", ")", "Darwin", "{", "return", "Darwin", "{", "driver", ":", "driver", ",", "migrations", ":", "migrations", ",", "infoChan", ":", "i...
// New returns a new Darwin struct
[ "New", "returns", "a", "new", "Darwin", "struct" ]
86919dfcf80873d58ea2e527c15b1e02a5636ead
https://github.com/GuiaBolso/darwin/blob/86919dfcf80873d58ea2e527c15b1e02a5636ead/darwin.go#L86-L92
133,153
GuiaBolso/darwin
darwin.go
Validate
func Validate(d Driver, migrations []Migration) error { sort.Sort(byMigrationVersion(migrations)) if version, invalid := isInvalidVersion(migrations); invalid { return IllegalMigrationVersionError{Version: version} } if version, dup := isDuplicated(migrations); dup { return DuplicateMigrationVersionError{Vers...
go
func Validate(d Driver, migrations []Migration) error { sort.Sort(byMigrationVersion(migrations)) if version, invalid := isInvalidVersion(migrations); invalid { return IllegalMigrationVersionError{Version: version} } if version, dup := isDuplicated(migrations); dup { return DuplicateMigrationVersionError{Vers...
[ "func", "Validate", "(", "d", "Driver", ",", "migrations", "[", "]", "Migration", ")", "error", "{", "sort", ".", "Sort", "(", "byMigrationVersion", "(", "migrations", ")", ")", "\n\n", "if", "version", ",", "invalid", ":=", "isInvalidVersion", "(", "migra...
// Validate if the database migrations are applied and consistent
[ "Validate", "if", "the", "database", "migrations", "are", "applied", "and", "consistent" ]
86919dfcf80873d58ea2e527c15b1e02a5636ead
https://github.com/GuiaBolso/darwin/blob/86919dfcf80873d58ea2e527c15b1e02a5636ead/darwin.go#L131-L157
133,154
GuiaBolso/darwin
darwin.go
Migrate
func Migrate(d Driver, migrations []Migration, infoChan chan MigrationInfo) error { mutex.Lock() defer mutex.Unlock() err := d.Create() if err != nil { return err } err = Validate(d, migrations) if err != nil { return err } planned, err := planMigration(d, migrations) if err != nil { return err }...
go
func Migrate(d Driver, migrations []Migration, infoChan chan MigrationInfo) error { mutex.Lock() defer mutex.Unlock() err := d.Create() if err != nil { return err } err = Validate(d, migrations) if err != nil { return err } planned, err := planMigration(d, migrations) if err != nil { return err }...
[ "func", "Migrate", "(", "d", "Driver", ",", "migrations", "[", "]", "Migration", ",", "infoChan", "chan", "MigrationInfo", ")", "error", "{", "mutex", ".", "Lock", "(", ")", "\n", "defer", "mutex", ".", "Unlock", "(", ")", "\n\n", "err", ":=", "d", "...
// Migrate executes the missing migrations in database.
[ "Migrate", "executes", "the", "missing", "migrations", "in", "database", "." ]
86919dfcf80873d58ea2e527c15b1e02a5636ead
https://github.com/GuiaBolso/darwin/blob/86919dfcf80873d58ea2e527c15b1e02a5636ead/darwin.go#L206-L253
133,155
paulmach/go.geo
path.go
NewPathPreallocate
func NewPathPreallocate(length, capacity int) *Path { return &Path{PointSet(*NewPointSetPreallocate(length, capacity))} }
go
func NewPathPreallocate(length, capacity int) *Path { return &Path{PointSet(*NewPointSetPreallocate(length, capacity))} }
[ "func", "NewPathPreallocate", "(", "length", ",", "capacity", "int", ")", "*", "Path", "{", "return", "&", "Path", "{", "PointSet", "(", "*", "NewPointSetPreallocate", "(", "length", ",", "capacity", ")", ")", "}", "\n", "}" ]
// NewPathPreallocate creates a new path with points array of the given size.
[ "NewPathPreallocate", "creates", "a", "new", "path", "with", "points", "array", "of", "the", "given", "size", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L23-L25
133,156
paulmach/go.geo
path.go
NewPathFromFlatXYData
func NewPathFromFlatXYData(data []float64) *Path { if len(data)%2 != 0 { panic("Flat path requires an even number of coordinates") } p := NewPathPreallocate(0, len(data)/2) for i := 0; i < len(data)/2; i++ { p.PointSet = append(p.PointSet, Point{data[2*i], data[2*i+1]}) } return p }
go
func NewPathFromFlatXYData(data []float64) *Path { if len(data)%2 != 0 { panic("Flat path requires an even number of coordinates") } p := NewPathPreallocate(0, len(data)/2) for i := 0; i < len(data)/2; i++ { p.PointSet = append(p.PointSet, Point{data[2*i], data[2*i+1]}) } return p }
[ "func", "NewPathFromFlatXYData", "(", "data", "[", "]", "float64", ")", "*", "Path", "{", "if", "len", "(", "data", ")", "%", "2", "!=", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "p", ":=", "NewPathPreallocate", "(", "0", ",", "le...
// NewPathFromFlatXYData creates a path from a slice of float64 values // representing horizontal, vertical type data. // Coordinates in even positions correspond to X values. Coordinates in odd positions correspond to Y values
[ "NewPathFromFlatXYData", "creates", "a", "path", "from", "a", "slice", "of", "float64", "values", "representing", "horizontal", "vertical", "type", "data", ".", "Coordinates", "in", "even", "positions", "correspond", "to", "X", "values", ".", "Coordinates", "in", ...
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L92-L103
133,157
paulmach/go.geo
path.go
Transform
func (p *Path) Transform(projector Projector) *Path { for i := range p.PointSet { projector(&p.PointSet[i]) } return p }
go
func (p *Path) Transform(projector Projector) *Path { for i := range p.PointSet { projector(&p.PointSet[i]) } return p }
[ "func", "(", "p", "*", "Path", ")", "Transform", "(", "projector", "Projector", ")", "*", "Path", "{", "for", "i", ":=", "range", "p", ".", "PointSet", "{", "projector", "(", "&", "p", ".", "PointSet", "[", "i", "]", ")", "\n", "}", "\n\n", "retu...
// Transform applies a given projection or inverse projection to all // the points in the path.
[ "Transform", "applies", "a", "given", "projection", "or", "inverse", "projection", "to", "all", "the", "points", "in", "the", "path", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L162-L168
133,158
paulmach/go.geo
path.go
Encode
func (p *Path) Encode(factor ...int) string { f := 1.0e5 if len(factor) != 0 { f = float64(factor[0]) } var pLat int var pLng int var result bytes.Buffer scratch1 := make([]byte, 0, 50) scratch2 := make([]byte, 0, 50) for _, p := range p.PointSet { lat5 := int(math.Floor(p.Lat()*f + 0.5)) lng5 := int(...
go
func (p *Path) Encode(factor ...int) string { f := 1.0e5 if len(factor) != 0 { f = float64(factor[0]) } var pLat int var pLng int var result bytes.Buffer scratch1 := make([]byte, 0, 50) scratch2 := make([]byte, 0, 50) for _, p := range p.PointSet { lat5 := int(math.Floor(p.Lat()*f + 0.5)) lng5 := int(...
[ "func", "(", "p", "*", "Path", ")", "Encode", "(", "factor", "...", "int", ")", "string", "{", "f", ":=", "1.0e5", "\n", "if", "len", "(", "factor", ")", "!=", "0", "{", "f", "=", "float64", "(", "factor", "[", "0", "]", ")", "\n", "}", "\n\n...
// Encode converts the path to a string using the Google Maps Polyline Encoding method. // Factor defaults to 1.0e5, the same used by Google for polyline encoding.
[ "Encode", "converts", "the", "path", "to", "a", "string", "using", "the", "Google", "Maps", "Polyline", "Encoding", "method", ".", "Factor", "defaults", "to", "1", ".", "0e5", "the", "same", "used", "by", "Google", "for", "polyline", "encoding", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L177-L207
133,159
paulmach/go.geo
path.go
Distance
func (p *Path) Distance() float64 { sum := 0.0 loopTo := len(p.PointSet) - 1 for i := 0; i < loopTo; i++ { sum += p.PointSet[i].DistanceFrom(&p.PointSet[i+1]) } return sum }
go
func (p *Path) Distance() float64 { sum := 0.0 loopTo := len(p.PointSet) - 1 for i := 0; i < loopTo; i++ { sum += p.PointSet[i].DistanceFrom(&p.PointSet[i+1]) } return sum }
[ "func", "(", "p", "*", "Path", ")", "Distance", "(", ")", "float64", "{", "sum", ":=", "0.0", "\n\n", "loopTo", ":=", "len", "(", "p", ".", "PointSet", ")", "-", "1", "\n", "for", "i", ":=", "0", ";", "i", "<", "loopTo", ";", "i", "++", "{", ...
// Distance computes the total distance in the units of the points.
[ "Distance", "computes", "the", "total", "distance", "in", "the", "units", "of", "the", "points", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L225-L234
133,160
paulmach/go.geo
path.go
GeoDistance
func (p *Path) GeoDistance(haversine ...bool) float64 { yesgeo := yesHaversine(haversine) sum := 0.0 loopTo := len(p.PointSet) - 1 for i := 0; i < loopTo; i++ { sum += p.PointSet[i].GeoDistanceFrom(&p.PointSet[i+1], yesgeo) } return sum }
go
func (p *Path) GeoDistance(haversine ...bool) float64 { yesgeo := yesHaversine(haversine) sum := 0.0 loopTo := len(p.PointSet) - 1 for i := 0; i < loopTo; i++ { sum += p.PointSet[i].GeoDistanceFrom(&p.PointSet[i+1], yesgeo) } return sum }
[ "func", "(", "p", "*", "Path", ")", "GeoDistance", "(", "haversine", "...", "bool", ")", "float64", "{", "yesgeo", ":=", "yesHaversine", "(", "haversine", ")", "\n", "sum", ":=", "0.0", "\n\n", "loopTo", ":=", "len", "(", "p", ".", "PointSet", ")", "...
// GeoDistance computes the total distance using spherical geometry.
[ "GeoDistance", "computes", "the", "total", "distance", "using", "spherical", "geometry", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L237-L247
133,161
paulmach/go.geo
path.go
Measure
func (p *Path) Measure(point *Point) float64 { minDistance := math.Inf(1) measure := math.Inf(-1) sum := 0.0 seg := &Line{} for i := 0; i < len(p.PointSet)-1; i++ { seg.a = p.PointSet[i] seg.b = p.PointSet[i+1] distanceToLine := seg.SquaredDistanceFrom(point) if distanceToLine < minDistance { minDistan...
go
func (p *Path) Measure(point *Point) float64 { minDistance := math.Inf(1) measure := math.Inf(-1) sum := 0.0 seg := &Line{} for i := 0; i < len(p.PointSet)-1; i++ { seg.a = p.PointSet[i] seg.b = p.PointSet[i+1] distanceToLine := seg.SquaredDistanceFrom(point) if distanceToLine < minDistance { minDistan...
[ "func", "(", "p", "*", "Path", ")", "Measure", "(", "point", "*", "Point", ")", "float64", "{", "minDistance", ":=", "math", ".", "Inf", "(", "1", ")", "\n", "measure", ":=", "math", ".", "Inf", "(", "-", "1", ")", "\n", "sum", ":=", "0.0", "\n...
// Measure computes the distance along this path to the point nearest the given point.
[ "Measure", "computes", "the", "distance", "along", "this", "path", "to", "the", "point", "nearest", "the", "given", "point", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L300-L317
133,162
paulmach/go.geo
path.go
Interpolate
func (p *Path) Interpolate(percent float64) *Point { if percent <= 0 { return p.First() } else if percent >= 1 { return p.Last() } destination := p.Distance() * percent travelled := 0.0 for i := 0; i < len(p.PointSet)-1; i++ { seg := NewLine(&p.PointSet[i], &p.PointSet[i+1]) segDistance := seg.Distance...
go
func (p *Path) Interpolate(percent float64) *Point { if percent <= 0 { return p.First() } else if percent >= 1 { return p.Last() } destination := p.Distance() * percent travelled := 0.0 for i := 0; i < len(p.PointSet)-1; i++ { seg := NewLine(&p.PointSet[i], &p.PointSet[i+1]) segDistance := seg.Distance...
[ "func", "(", "p", "*", "Path", ")", "Interpolate", "(", "percent", "float64", ")", "*", "Point", "{", "if", "percent", "<=", "0", "{", "return", "p", ".", "First", "(", ")", "\n", "}", "else", "if", "percent", ">=", "1", "{", "return", "p", ".", ...
// Interpolate performs a linear interpolation along the path
[ "Interpolate", "performs", "a", "linear", "interpolation", "along", "the", "path" ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L320-L342
133,163
paulmach/go.geo
path.go
Project
func (p *Path) Project(point *Point) float64 { return p.Measure(point) / p.Distance() }
go
func (p *Path) Project(point *Point) float64 { return p.Measure(point) / p.Distance() }
[ "func", "(", "p", "*", "Path", ")", "Project", "(", "point", "*", "Point", ")", "float64", "{", "return", "p", ".", "Measure", "(", "point", ")", "/", "p", ".", "Distance", "(", ")", "\n", "}" ]
// Project computes the measure along this path closest to the given point, // normalized to the length of the path.
[ "Project", "computes", "the", "measure", "along", "this", "path", "closest", "to", "the", "given", "point", "normalized", "to", "the", "length", "of", "the", "path", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L346-L348
133,164
paulmach/go.geo
path.go
IntersectsPath
func (p *Path) IntersectsPath(path *Path) bool { // TODO: done some sort of line sweep here if p.Length() is big enough for i := 0; i < len(p.PointSet)-1; i++ { pLine := NewLine(&p.PointSet[i], &p.PointSet[i+1]) for j := 0; j < len(path.PointSet)-1; j++ { pathLine := NewLine(&path.PointSet[j], &path.PointSet[...
go
func (p *Path) IntersectsPath(path *Path) bool { // TODO: done some sort of line sweep here if p.Length() is big enough for i := 0; i < len(p.PointSet)-1; i++ { pLine := NewLine(&p.PointSet[i], &p.PointSet[i+1]) for j := 0; j < len(path.PointSet)-1; j++ { pathLine := NewLine(&path.PointSet[j], &path.PointSet[...
[ "func", "(", "p", "*", "Path", ")", "IntersectsPath", "(", "path", "*", "Path", ")", "bool", "{", "// TODO: done some sort of line sweep here if p.Length() is big enough", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "p", ".", "PointSet", ")", "-", "1",...
// IntersectsPath takes a Path and checks if it intersects with the path.
[ "IntersectsPath", "takes", "a", "Path", "and", "checks", "if", "it", "intersects", "with", "the", "path", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L437-L452
133,165
paulmach/go.geo
path.go
IntersectsLine
func (p *Path) IntersectsLine(line *Line) bool { for i := 0; i < len(p.PointSet)-1; i++ { pTest := NewLine(&p.PointSet[i], &p.PointSet[i+1]) if pTest.Intersects(line) { return true } } return false }
go
func (p *Path) IntersectsLine(line *Line) bool { for i := 0; i < len(p.PointSet)-1; i++ { pTest := NewLine(&p.PointSet[i], &p.PointSet[i+1]) if pTest.Intersects(line) { return true } } return false }
[ "func", "(", "p", "*", "Path", ")", "IntersectsLine", "(", "line", "*", "Line", ")", "bool", "{", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "p", ".", "PointSet", ")", "-", "1", ";", "i", "++", "{", "pTest", ":=", "NewLine", "(", "&", ...
// IntersectsLine takes a Line and checks if it intersects with the path.
[ "IntersectsLine", "takes", "a", "Line", "and", "checks", "if", "it", "intersects", "with", "the", "path", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L455-L464
133,166
paulmach/go.geo
path.go
SetAt
func (p *Path) SetAt(index int, point *Point) *Path { (&p.PointSet).SetAt(index, point) return p }
go
func (p *Path) SetAt(index int, point *Point) *Path { (&p.PointSet).SetAt(index, point) return p }
[ "func", "(", "p", "*", "Path", ")", "SetAt", "(", "index", "int", ",", "point", "*", "Point", ")", "*", "Path", "{", "(", "&", "p", ".", "PointSet", ")", ".", "SetAt", "(", "index", ",", "point", ")", "\n", "return", "p", "\n", "}" ]
// SetAt updates a position at i along the path. // Panics if index is out of range.
[ "SetAt", "updates", "a", "position", "at", "i", "along", "the", "path", ".", "Panics", "if", "index", "is", "out", "of", "range", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L491-L494
133,167
paulmach/go.geo
path.go
GetAt
func (p *Path) GetAt(i int) *Point { return p.PointSet.GetAt(i) }
go
func (p *Path) GetAt(i int) *Point { return p.PointSet.GetAt(i) }
[ "func", "(", "p", "*", "Path", ")", "GetAt", "(", "i", "int", ")", "*", "Point", "{", "return", "p", ".", "PointSet", ".", "GetAt", "(", "i", ")", "\n", "}" ]
// GetAt returns the pointer to the Point in the path. // This function is good for modifying values in place. // Returns nil if index is out of range.
[ "GetAt", "returns", "the", "pointer", "to", "the", "Point", "in", "the", "path", ".", "This", "function", "is", "good", "for", "modifying", "values", "in", "place", ".", "Returns", "nil", "if", "index", "is", "out", "of", "range", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L499-L501
133,168
paulmach/go.geo
path.go
InsertAt
func (p *Path) InsertAt(index int, point *Point) *Path { (&p.PointSet).InsertAt(index, point) return p }
go
func (p *Path) InsertAt(index int, point *Point) *Path { (&p.PointSet).InsertAt(index, point) return p }
[ "func", "(", "p", "*", "Path", ")", "InsertAt", "(", "index", "int", ",", "point", "*", "Point", ")", "*", "Path", "{", "(", "&", "p", ".", "PointSet", ")", ".", "InsertAt", "(", "index", ",", "point", ")", "\n", "return", "p", "\n", "}" ]
// InsertAt inserts a Point at i along the path. // Panics if index is out of range.
[ "InsertAt", "inserts", "a", "Point", "at", "i", "along", "the", "path", ".", "Panics", "if", "index", "is", "out", "of", "range", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L505-L508
133,169
paulmach/go.geo
path.go
RemoveAt
func (p *Path) RemoveAt(index int) *Path { (&p.PointSet).RemoveAt(index) return p }
go
func (p *Path) RemoveAt(index int) *Path { (&p.PointSet).RemoveAt(index) return p }
[ "func", "(", "p", "*", "Path", ")", "RemoveAt", "(", "index", "int", ")", "*", "Path", "{", "(", "&", "p", ".", "PointSet", ")", ".", "RemoveAt", "(", "index", ")", "\n", "return", "p", "\n", "}" ]
// RemoveAt removes a Point at i along the path. // Panics if index is out of range.
[ "RemoveAt", "removes", "a", "Point", "at", "i", "along", "the", "path", ".", "Panics", "if", "index", "is", "out", "of", "range", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L512-L515
133,170
paulmach/go.geo
path.go
Push
func (p *Path) Push(point *Point) *Path { (&p.PointSet).Push(point) return p }
go
func (p *Path) Push(point *Point) *Path { (&p.PointSet).Push(point) return p }
[ "func", "(", "p", "*", "Path", ")", "Push", "(", "point", "*", "Point", ")", "*", "Path", "{", "(", "&", "p", ".", "PointSet", ")", ".", "Push", "(", "point", ")", "\n", "return", "p", "\n", "}" ]
// Push appends a point to the end of the path.
[ "Push", "appends", "a", "point", "to", "the", "end", "of", "the", "path", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L518-L521
133,171
paulmach/go.geo
path.go
Equals
func (p *Path) Equals(path *Path) bool { return (&p.PointSet).Equals(&path.PointSet) }
go
func (p *Path) Equals(path *Path) bool { return (&p.PointSet).Equals(&path.PointSet) }
[ "func", "(", "p", "*", "Path", ")", "Equals", "(", "path", "*", "Path", ")", "bool", "{", "return", "(", "&", "p", ".", "PointSet", ")", ".", "Equals", "(", "&", "path", ".", "PointSet", ")", "\n", "}" ]
// Equals compares two paths. Returns true if lengths are the same // and all points are Equal.
[ "Equals", "compares", "two", "paths", ".", "Returns", "true", "if", "lengths", "are", "the", "same", "and", "all", "points", "are", "Equal", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L535-L537
133,172
paulmach/go.geo
path.go
ToGeoJSON
func (p *Path) ToGeoJSON() *geojson.Feature { coords := make([][]float64, 0, len(p.PointSet)) for _, p := range p.PointSet { coords = append(coords, []float64{p[0], p[1]}) } return geojson.NewLineStringFeature(coords) }
go
func (p *Path) ToGeoJSON() *geojson.Feature { coords := make([][]float64, 0, len(p.PointSet)) for _, p := range p.PointSet { coords = append(coords, []float64{p[0], p[1]}) } return geojson.NewLineStringFeature(coords) }
[ "func", "(", "p", "*", "Path", ")", "ToGeoJSON", "(", ")", "*", "geojson", ".", "Feature", "{", "coords", ":=", "make", "(", "[", "]", "[", "]", "float64", ",", "0", ",", "len", "(", "p", ".", "PointSet", ")", ")", "\n\n", "for", "_", ",", "p...
// ToGeoJSON creates a new geojson feature with a linestring geometry // containing all the points.
[ "ToGeoJSON", "creates", "a", "new", "geojson", "feature", "with", "a", "linestring", "geometry", "containing", "all", "the", "points", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/path.go#L546-L554
133,173
paulmach/go.geo
point_set.go
NewPointSetPreallocate
func NewPointSetPreallocate(length, capacity int) *PointSet { if length > capacity { capacity = length } ps := make([]Point, length, capacity) p := PointSet(ps) return &p }
go
func NewPointSetPreallocate(length, capacity int) *PointSet { if length > capacity { capacity = length } ps := make([]Point, length, capacity) p := PointSet(ps) return &p }
[ "func", "NewPointSetPreallocate", "(", "length", ",", "capacity", "int", ")", "*", "PointSet", "{", "if", "length", ">", "capacity", "{", "capacity", "=", "length", "\n", "}", "\n\n", "ps", ":=", "make", "(", "[", "]", "Point", ",", "length", ",", "cap...
// NewPointSetPreallocate simply creates a new point set with points array of the given size.
[ "NewPointSetPreallocate", "simply", "creates", "a", "new", "point", "set", "with", "points", "array", "of", "the", "given", "size", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/point_set.go#L20-L28
133,174
paulmach/go.geo
point_set.go
Clone
func (ps PointSet) Clone() *PointSet { points := make([]Point, len(ps)) copy(points, ps) nps := PointSet(points) return &nps }
go
func (ps PointSet) Clone() *PointSet { points := make([]Point, len(ps)) copy(points, ps) nps := PointSet(points) return &nps }
[ "func", "(", "ps", "PointSet", ")", "Clone", "(", ")", "*", "PointSet", "{", "points", ":=", "make", "(", "[", "]", "Point", ",", "len", "(", "ps", ")", ")", "\n", "copy", "(", "points", ",", "ps", ")", "\n\n", "nps", ":=", "PointSet", "(", "po...
// Clone returns a new copy of the point set.
[ "Clone", "returns", "a", "new", "copy", "of", "the", "point", "set", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/point_set.go#L31-L37
133,175
paulmach/go.geo
point_set.go
DistanceFrom
func (ps PointSet) DistanceFrom(point *Point) (float64, int) { dist := math.Inf(1) index := 0 for i := range ps { if d := ps[i].SquaredDistanceFrom(point); d < dist { dist = d index = i } } return math.Sqrt(dist), index }
go
func (ps PointSet) DistanceFrom(point *Point) (float64, int) { dist := math.Inf(1) index := 0 for i := range ps { if d := ps[i].SquaredDistanceFrom(point); d < dist { dist = d index = i } } return math.Sqrt(dist), index }
[ "func", "(", "ps", "PointSet", ")", "DistanceFrom", "(", "point", "*", "Point", ")", "(", "float64", ",", "int", ")", "{", "dist", ":=", "math", ".", "Inf", "(", "1", ")", "\n", "index", ":=", "0", "\n\n", "for", "i", ":=", "range", "ps", "{", ...
// DistanceFrom returns the minimum euclidean distance from the point set.
[ "DistanceFrom", "returns", "the", "minimum", "euclidean", "distance", "from", "the", "point", "set", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/point_set.go#L82-L94
133,176
paulmach/go.geo
point_set.go
GeoDistanceFrom
func (ps PointSet) GeoDistanceFrom(point *Point) (float64, int) { dist := math.Inf(1) index := 0 for i := range ps { if d := ps[i].GeoDistanceFrom(point); d < dist { dist = d index = i } } return dist, index }
go
func (ps PointSet) GeoDistanceFrom(point *Point) (float64, int) { dist := math.Inf(1) index := 0 for i := range ps { if d := ps[i].GeoDistanceFrom(point); d < dist { dist = d index = i } } return dist, index }
[ "func", "(", "ps", "PointSet", ")", "GeoDistanceFrom", "(", "point", "*", "Point", ")", "(", "float64", ",", "int", ")", "{", "dist", ":=", "math", ".", "Inf", "(", "1", ")", "\n", "index", ":=", "0", "\n\n", "for", "i", ":=", "range", "ps", "{",...
// GeoDistanceFrom returns the minimum geo distance from the point set, // along with the index of the point with minimum index.
[ "GeoDistanceFrom", "returns", "the", "minimum", "geo", "distance", "from", "the", "point", "set", "along", "with", "the", "index", "of", "the", "point", "with", "minimum", "index", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/point_set.go#L98-L110
133,177
paulmach/go.geo
point_set.go
Bound
func (ps PointSet) Bound() *Bound { if len(ps) == 0 { return NewBound(0, 0, 0, 0) } minX := math.Inf(1) minY := math.Inf(1) maxX := math.Inf(-1) maxY := math.Inf(-1) for _, v := range ps { minX = math.Min(minX, v.X()) minY = math.Min(minY, v.Y()) maxX = math.Max(maxX, v.X()) maxY = math.Max(maxY, v...
go
func (ps PointSet) Bound() *Bound { if len(ps) == 0 { return NewBound(0, 0, 0, 0) } minX := math.Inf(1) minY := math.Inf(1) maxX := math.Inf(-1) maxY := math.Inf(-1) for _, v := range ps { minX = math.Min(minX, v.X()) minY = math.Min(minY, v.Y()) maxX = math.Max(maxX, v.X()) maxY = math.Max(maxY, v...
[ "func", "(", "ps", "PointSet", ")", "Bound", "(", ")", "*", "Bound", "{", "if", "len", "(", "ps", ")", "==", "0", "{", "return", "NewBound", "(", "0", ",", "0", ",", "0", ",", "0", ")", "\n", "}", "\n\n", "minX", ":=", "math", ".", "Inf", "...
// Bound returns a bound around the point set. Simply uses rectangular coordinates.
[ "Bound", "returns", "a", "bound", "around", "the", "point", "set", ".", "Simply", "uses", "rectangular", "coordinates", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/point_set.go#L113-L133
133,178
paulmach/go.geo
point_set.go
SetAt
func (ps *PointSet) SetAt(index int, point *Point) *PointSet { deref := *ps if index >= len(deref) || index < 0 { panic(fmt.Sprintf("geo: set index out of range, requested: %d, length: %d", index, len(deref))) } deref[index] = *point *ps = deref return ps }
go
func (ps *PointSet) SetAt(index int, point *Point) *PointSet { deref := *ps if index >= len(deref) || index < 0 { panic(fmt.Sprintf("geo: set index out of range, requested: %d, length: %d", index, len(deref))) } deref[index] = *point *ps = deref return ps }
[ "func", "(", "ps", "*", "PointSet", ")", "SetAt", "(", "index", "int", ",", "point", "*", "Point", ")", "*", "PointSet", "{", "deref", ":=", "*", "ps", "\n", "if", "index", ">=", "len", "(", "deref", ")", "||", "index", "<", "0", "{", "panic", ...
// SetAt updates a position at i in the point set
[ "SetAt", "updates", "a", "position", "at", "i", "in", "the", "point", "set" ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/point_set.go#L136-L144
133,179
paulmach/go.geo
point_set.go
GetAt
func (ps *PointSet) GetAt(i int) *Point { deref := *ps if i >= len(deref) || i < 0 { return nil } return &deref[i] }
go
func (ps *PointSet) GetAt(i int) *Point { deref := *ps if i >= len(deref) || i < 0 { return nil } return &deref[i] }
[ "func", "(", "ps", "*", "PointSet", ")", "GetAt", "(", "i", "int", ")", "*", "Point", "{", "deref", ":=", "*", "ps", "\n", "if", "i", ">=", "len", "(", "deref", ")", "||", "i", "<", "0", "{", "return", "nil", "\n", "}", "\n\n", "return", "&",...
// GetAt returns the pointer to the Point in the page. // This function is good for modifying values in place. // Returns nil if index is out of range.
[ "GetAt", "returns", "the", "pointer", "to", "the", "Point", "in", "the", "page", ".", "This", "function", "is", "good", "for", "modifying", "values", "in", "place", ".", "Returns", "nil", "if", "index", "is", "out", "of", "range", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/point_set.go#L149-L156
133,180
paulmach/go.geo
point_set.go
Last
func (ps PointSet) Last() *Point { if len(ps) == 0 { return nil } return &ps[len(ps)-1] }
go
func (ps PointSet) Last() *Point { if len(ps) == 0 { return nil } return &ps[len(ps)-1] }
[ "func", "(", "ps", "PointSet", ")", "Last", "(", ")", "*", "Point", "{", "if", "len", "(", "ps", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "ps", "[", "len", "(", "ps", ")", "-", "1", "]", "\n", "}" ]
// Last returns the last point in the point set. // Will return nil if there are no points in the set.
[ "Last", "returns", "the", "last", "point", "in", "the", "point", "set", ".", "Will", "return", "nil", "if", "there", "are", "no", "points", "in", "the", "set", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/point_set.go#L170-L176
133,181
paulmach/go.geo
point_set.go
InsertAt
func (ps *PointSet) InsertAt(index int, point *Point) *PointSet { deref := *ps if index > len(deref) || index < 0 { panic(fmt.Sprintf("geo: insert index out of range, requested: %d, length: %d", index, len(deref))) } if index == len(deref) { deref = append(deref, *point) *ps = deref return ps } deref = ...
go
func (ps *PointSet) InsertAt(index int, point *Point) *PointSet { deref := *ps if index > len(deref) || index < 0 { panic(fmt.Sprintf("geo: insert index out of range, requested: %d, length: %d", index, len(deref))) } if index == len(deref) { deref = append(deref, *point) *ps = deref return ps } deref = ...
[ "func", "(", "ps", "*", "PointSet", ")", "InsertAt", "(", "index", "int", ",", "point", "*", "Point", ")", "*", "PointSet", "{", "deref", ":=", "*", "ps", "\n", "if", "index", ">", "len", "(", "deref", ")", "||", "index", "<", "0", "{", "panic", ...
// InsertAt inserts a Point at i in the point set. // Panics if index is out of range.
[ "InsertAt", "inserts", "a", "Point", "at", "i", "in", "the", "point", "set", ".", "Panics", "if", "index", "is", "out", "of", "range", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/point_set.go#L180-L197
133,182
paulmach/go.geo
point_set.go
RemoveAt
func (ps *PointSet) RemoveAt(index int) *PointSet { deref := *ps if index >= len(deref) || index < 0 { panic(fmt.Sprintf("geo: remove index out of range, requested: %d, length: %d", index, len(deref))) } deref = append(deref[:index], deref[index+1:]...) *ps = deref return ps }
go
func (ps *PointSet) RemoveAt(index int) *PointSet { deref := *ps if index >= len(deref) || index < 0 { panic(fmt.Sprintf("geo: remove index out of range, requested: %d, length: %d", index, len(deref))) } deref = append(deref[:index], deref[index+1:]...) *ps = deref return ps }
[ "func", "(", "ps", "*", "PointSet", ")", "RemoveAt", "(", "index", "int", ")", "*", "PointSet", "{", "deref", ":=", "*", "ps", "\n", "if", "index", ">=", "len", "(", "deref", ")", "||", "index", "<", "0", "{", "panic", "(", "fmt", ".", "Sprintf",...
// RemoveAt removes a Point at i in the point set. // Panics if index is out of range.
[ "RemoveAt", "removes", "a", "Point", "at", "i", "in", "the", "point", "set", ".", "Panics", "if", "index", "is", "out", "of", "range", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/point_set.go#L201-L210
133,183
paulmach/go.geo
point_set.go
Push
func (ps *PointSet) Push(point *Point) *PointSet { *ps = append(*ps, *point) return ps }
go
func (ps *PointSet) Push(point *Point) *PointSet { *ps = append(*ps, *point) return ps }
[ "func", "(", "ps", "*", "PointSet", ")", "Push", "(", "point", "*", "Point", ")", "*", "PointSet", "{", "*", "ps", "=", "append", "(", "*", "ps", ",", "*", "point", ")", "\n", "return", "ps", "\n", "}" ]
// Push appends a point to the end of the point set.
[ "Push", "appends", "a", "point", "to", "the", "end", "of", "the", "point", "set", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/point_set.go#L213-L216
133,184
paulmach/go.geo
point_set.go
Pop
func (ps *PointSet) Pop() *Point { deref := *ps if len(deref) == 0 { return nil } x := deref[len(deref)-1] *ps = deref[:len(deref)-1] return &x }
go
func (ps *PointSet) Pop() *Point { deref := *ps if len(deref) == 0 { return nil } x := deref[len(deref)-1] *ps = deref[:len(deref)-1] return &x }
[ "func", "(", "ps", "*", "PointSet", ")", "Pop", "(", ")", "*", "Point", "{", "deref", ":=", "*", "ps", "\n", "if", "len", "(", "deref", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "x", ":=", "deref", "[", "len", "(", "deref", ")"...
// Pop removes and returns the last point in the point set
[ "Pop", "removes", "and", "returns", "the", "last", "point", "in", "the", "point", "set" ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/point_set.go#L219-L229
133,185
paulmach/go.geo
point_set.go
Equals
func (ps PointSet) Equals(pointSet *PointSet) bool { if (ps).Length() != (*pointSet).Length() { return false } for i, v := range ps { if !v.Equals((*pointSet).GetAt(i)) { return false } } return true }
go
func (ps PointSet) Equals(pointSet *PointSet) bool { if (ps).Length() != (*pointSet).Length() { return false } for i, v := range ps { if !v.Equals((*pointSet).GetAt(i)) { return false } } return true }
[ "func", "(", "ps", "PointSet", ")", "Equals", "(", "pointSet", "*", "PointSet", ")", "bool", "{", "if", "(", "ps", ")", ".", "Length", "(", ")", "!=", "(", "*", "pointSet", ")", ".", "Length", "(", ")", "{", "return", "false", "\n", "}", "\n\n", ...
// Equals compares two point sets. Returns true if lengths are the same // and all points are Equal
[ "Equals", "compares", "two", "point", "sets", ".", "Returns", "true", "if", "lengths", "are", "the", "same", "and", "all", "points", "are", "Equal" ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/point_set.go#L244-L256
133,186
paulmach/go.geo
point_set.go
ToGeoJSON
func (ps PointSet) ToGeoJSON() *geojson.Feature { f := geojson.NewMultiPointFeature() for _, v := range ps { f.Geometry.MultiPoint = append(f.Geometry.MultiPoint, []float64{v[0], v[1]}) } return f }
go
func (ps PointSet) ToGeoJSON() *geojson.Feature { f := geojson.NewMultiPointFeature() for _, v := range ps { f.Geometry.MultiPoint = append(f.Geometry.MultiPoint, []float64{v[0], v[1]}) } return f }
[ "func", "(", "ps", "PointSet", ")", "ToGeoJSON", "(", ")", "*", "geojson", ".", "Feature", "{", "f", ":=", "geojson", ".", "NewMultiPointFeature", "(", ")", "\n", "for", "_", ",", "v", ":=", "range", "ps", "{", "f", ".", "Geometry", ".", "MultiPoint"...
// ToGeoJSON creates a new geojson feature with a multipoint geometry // containing all the points.
[ "ToGeoJSON", "creates", "a", "new", "geojson", "feature", "with", "a", "multipoint", "geometry", "containing", "all", "the", "points", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/point_set.go#L260-L267
133,187
paulmach/go.geo
clustering/cluster.go
NewCluster
func NewCluster(pointers ...geo.Pointer) *Cluster { var ( sumX, sumY float64 count int ) c := &Cluster{ Pointers: pointers, } if len(pointers) == 0 { c.Centroid = geo.NewPoint(0, 0) return c } if len(pointers) == 1 { c.Centroid = pointers[0].Point().Clone() return c } // find the center/...
go
func NewCluster(pointers ...geo.Pointer) *Cluster { var ( sumX, sumY float64 count int ) c := &Cluster{ Pointers: pointers, } if len(pointers) == 0 { c.Centroid = geo.NewPoint(0, 0) return c } if len(pointers) == 1 { c.Centroid = pointers[0].Point().Clone() return c } // find the center/...
[ "func", "NewCluster", "(", "pointers", "...", "geo", ".", "Pointer", ")", "*", "Cluster", "{", "var", "(", "sumX", ",", "sumY", "float64", "\n", "count", "int", "\n", ")", "\n\n", "c", ":=", "&", "Cluster", "{", "Pointers", ":", "pointers", ",", "}",...
// NewCluster creates the point cluster and finds the center of the given pointers.
[ "NewCluster", "creates", "the", "point", "cluster", "and", "finds", "the", "center", "of", "the", "given", "pointers", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/clustering/cluster.go#L13-L44
133,188
paulmach/go.geo
clustering/cluster.go
NewClusterWithCentroid
func NewClusterWithCentroid(centroid *geo.Point, pointers ...geo.Pointer) *Cluster { return &Cluster{ Centroid: centroid.Clone(), Pointers: pointers, } }
go
func NewClusterWithCentroid(centroid *geo.Point, pointers ...geo.Pointer) *Cluster { return &Cluster{ Centroid: centroid.Clone(), Pointers: pointers, } }
[ "func", "NewClusterWithCentroid", "(", "centroid", "*", "geo", ".", "Point", ",", "pointers", "...", "geo", ".", "Pointer", ")", "*", "Cluster", "{", "return", "&", "Cluster", "{", "Centroid", ":", "centroid", ".", "Clone", "(", ")", ",", "Pointers", ":"...
// NewClusterWithCentroid creates a point cluster stub from the given centroid // and optional pointers.
[ "NewClusterWithCentroid", "creates", "a", "point", "cluster", "stub", "from", "the", "given", "centroid", "and", "optional", "pointers", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/clustering/cluster.go#L48-L53
133,189
paulmach/go.geo
clustering/distance.go
ClusterDistance
func (cd CentroidDistance) ClusterDistance(c1, c2 *Cluster) float64 { return c1.Centroid.DistanceFrom(c2.Centroid) }
go
func (cd CentroidDistance) ClusterDistance(c1, c2 *Cluster) float64 { return c1.Centroid.DistanceFrom(c2.Centroid) }
[ "func", "(", "cd", "CentroidDistance", ")", "ClusterDistance", "(", "c1", ",", "c2", "*", "Cluster", ")", "float64", "{", "return", "c1", ".", "Centroid", ".", "DistanceFrom", "(", "c2", ".", "Centroid", ")", "\n", "}" ]
// ClusterDistance computes the distance between the cluster centroids.
[ "ClusterDistance", "computes", "the", "distance", "between", "the", "cluster", "centroids", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/clustering/distance.go#L13-L15
133,190
paulmach/go.geo
clustering/distance.go
ClusterDistance
func (csd CentroidSquaredDistance) ClusterDistance(c1, c2 *Cluster) float64 { // save the function call, is this faster? d0 := (c1.Centroid[0] - c2.Centroid[0]) d1 := (c1.Centroid[1] - c2.Centroid[1]) return d0*d0 + d1*d1 }
go
func (csd CentroidSquaredDistance) ClusterDistance(c1, c2 *Cluster) float64 { // save the function call, is this faster? d0 := (c1.Centroid[0] - c2.Centroid[0]) d1 := (c1.Centroid[1] - c2.Centroid[1]) return d0*d0 + d1*d1 }
[ "func", "(", "csd", "CentroidSquaredDistance", ")", "ClusterDistance", "(", "c1", ",", "c2", "*", "Cluster", ")", "float64", "{", "// save the function call, is this faster?", "d0", ":=", "(", "c1", ".", "Centroid", "[", "0", "]", "-", "c2", ".", "Centroid", ...
// ClusterDistance computes the squared euclidean distance between the cluster centroids.
[ "ClusterDistance", "computes", "the", "squared", "euclidean", "distance", "between", "the", "cluster", "centroids", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/clustering/distance.go#L23-L28
133,191
paulmach/go.geo
clustering/distance.go
ClusterDistance
func (cgd CentroidGeoDistance) ClusterDistance(c1, c2 *Cluster) float64 { return c1.Centroid.GeoDistanceFrom(c2.Centroid) }
go
func (cgd CentroidGeoDistance) ClusterDistance(c1, c2 *Cluster) float64 { return c1.Centroid.GeoDistanceFrom(c2.Centroid) }
[ "func", "(", "cgd", "CentroidGeoDistance", ")", "ClusterDistance", "(", "c1", ",", "c2", "*", "Cluster", ")", "float64", "{", "return", "c1", ".", "Centroid", ".", "GeoDistanceFrom", "(", "c2", ".", "Centroid", ")", "\n", "}" ]
// ClusterDistance computes the geo distance between the cluster centroids.
[ "ClusterDistance", "computes", "the", "geo", "distance", "between", "the", "cluster", "centroids", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/clustering/distance.go#L37-L39
133,192
paulmach/go.geo
reducers/visvalingam.go
NewVisvalingamReducer
func NewVisvalingamReducer(threshold float64, minPointsToKeep int) *VisvalingamReducer { return &VisvalingamReducer{ Threshold: threshold, ToKeep: minPointsToKeep, } }
go
func NewVisvalingamReducer(threshold float64, minPointsToKeep int) *VisvalingamReducer { return &VisvalingamReducer{ Threshold: threshold, ToKeep: minPointsToKeep, } }
[ "func", "NewVisvalingamReducer", "(", "threshold", "float64", ",", "minPointsToKeep", "int", ")", "*", "VisvalingamReducer", "{", "return", "&", "VisvalingamReducer", "{", "Threshold", ":", "threshold", ",", "ToKeep", ":", "minPointsToKeep", ",", "}", "\n", "}" ]
// NewVisvalingamReducer creates a new VisvalingamReducer.
[ "NewVisvalingamReducer", "creates", "a", "new", "VisvalingamReducer", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/reducers/visvalingam.go#L17-L22
133,193
paulmach/go.geo
reducers/visvalingam.go
Reduce
func (r VisvalingamReducer) Reduce(path *geo.Path) *geo.Path { return Visvalingam(path, r.Threshold, r.ToKeep) }
go
func (r VisvalingamReducer) Reduce(path *geo.Path) *geo.Path { return Visvalingam(path, r.Threshold, r.ToKeep) }
[ "func", "(", "r", "VisvalingamReducer", ")", "Reduce", "(", "path", "*", "geo", ".", "Path", ")", "*", "geo", ".", "Path", "{", "return", "Visvalingam", "(", "path", ",", "r", ".", "Threshold", ",", "r", ".", "ToKeep", ")", "\n", "}" ]
// Reduce runs the Visvalingam reduction using the values of the Visvalingam.
[ "Reduce", "runs", "the", "Visvalingam", "reduction", "using", "the", "values", "of", "the", "Visvalingam", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/reducers/visvalingam.go#L25-L27
133,194
paulmach/go.geo
reducers/visvalingam.go
VisvalingamThreshold
func VisvalingamThreshold(path *geo.Path, threshold float64) *geo.Path { return Visvalingam(path, threshold, 0) }
go
func VisvalingamThreshold(path *geo.Path, threshold float64) *geo.Path { return Visvalingam(path, threshold, 0) }
[ "func", "VisvalingamThreshold", "(", "path", "*", "geo", ".", "Path", ",", "threshold", "float64", ")", "*", "geo", ".", "Path", "{", "return", "Visvalingam", "(", "path", ",", "threshold", ",", "0", ")", "\n", "}" ]
// VisvalingamThreshold runs the Visvalingam-Whyatt algorithm removing // triangles whose area is below the threshold. This function is here to simplify the interface. // Returns a new path and DOES NOT modify the original.
[ "VisvalingamThreshold", "runs", "the", "Visvalingam", "-", "Whyatt", "algorithm", "removing", "triangles", "whose", "area", "is", "below", "the", "threshold", ".", "This", "function", "is", "here", "to", "simplify", "the", "interface", ".", "Returns", "a", "new"...
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/reducers/visvalingam.go#L42-L44
133,195
paulmach/go.geo
reducers/visvalingam.go
VisvalingamKeep
func VisvalingamKeep(path *geo.Path, toKeep int) *geo.Path { return Visvalingam(path, math.MaxFloat64, toKeep) }
go
func VisvalingamKeep(path *geo.Path, toKeep int) *geo.Path { return Visvalingam(path, math.MaxFloat64, toKeep) }
[ "func", "VisvalingamKeep", "(", "path", "*", "geo", ".", "Path", ",", "toKeep", "int", ")", "*", "geo", ".", "Path", "{", "return", "Visvalingam", "(", "path", ",", "math", ".", "MaxFloat64", ",", "toKeep", ")", "\n", "}" ]
// VisvalingamKeep runs the Visvalingam-Whyatt algorithm removing // triangles of minimum area until we're down to `toKeep` number of points. // Returns a new path and DOES NOT modify the original.
[ "VisvalingamKeep", "runs", "the", "Visvalingam", "-", "Whyatt", "algorithm", "removing", "triangles", "of", "minimum", "area", "until", "we", "re", "down", "to", "toKeep", "number", "of", "points", ".", "Returns", "a", "new", "path", "and", "DOES", "NOT", "m...
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/reducers/visvalingam.go#L49-L51
133,196
paulmach/go.geo
clustering/helpers/rematch.go
RematchPointersToClusters
func RematchPointersToClusters( clusters []*clustering.Cluster, pointers []geo.Pointer, distancer clustering.ClusterDistancer, threshold float64, ) []*clustering.Cluster { if len(clusters) == 0 { return []*clustering.Cluster{} } newClusters := make([]*clustering.Cluster, 0, len(clusters)) // clear the curre...
go
func RematchPointersToClusters( clusters []*clustering.Cluster, pointers []geo.Pointer, distancer clustering.ClusterDistancer, threshold float64, ) []*clustering.Cluster { if len(clusters) == 0 { return []*clustering.Cluster{} } newClusters := make([]*clustering.Cluster, 0, len(clusters)) // clear the curre...
[ "func", "RematchPointersToClusters", "(", "clusters", "[", "]", "*", "clustering", ".", "Cluster", ",", "pointers", "[", "]", "geo", ".", "Pointer", ",", "distancer", "clustering", ".", "ClusterDistancer", ",", "threshold", "float64", ",", ")", "[", "]", "*"...
// RematchPointersToClusters will take a set of pointers and map them to the closest cluster. // Basically creates a new cluster from that one point and does the ClusterDistance between them. // Will return a new list.
[ "RematchPointersToClusters", "will", "take", "a", "set", "of", "pointers", "and", "map", "them", "to", "the", "closest", "cluster", ".", "Basically", "creates", "a", "new", "cluster", "from", "that", "one", "point", "and", "does", "the", "ClusterDistance", "be...
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/clustering/helpers/rematch.go#L13-L52
133,197
paulmach/go.geo
clustering/helpers/filter.go
FilterSmallClusters
func FilterSmallClusters(clusters []*clustering.Cluster, minPoints int) []*clustering.Cluster { filtered := make([]*clustering.Cluster, 0, len(clusters)) for _, c := range clusters { if len(c.Pointers) >= minPoints { filtered = append(filtered, c) } } return filtered }
go
func FilterSmallClusters(clusters []*clustering.Cluster, minPoints int) []*clustering.Cluster { filtered := make([]*clustering.Cluster, 0, len(clusters)) for _, c := range clusters { if len(c.Pointers) >= minPoints { filtered = append(filtered, c) } } return filtered }
[ "func", "FilterSmallClusters", "(", "clusters", "[", "]", "*", "clustering", ".", "Cluster", ",", "minPoints", "int", ")", "[", "]", "*", "clustering", ".", "Cluster", "{", "filtered", ":=", "make", "(", "[", "]", "*", "clustering", ".", "Cluster", ",", ...
// FilterSmallClusters will remove points clusters with less than or equal to the minPoints.
[ "FilterSmallClusters", "will", "remove", "points", "clusters", "with", "less", "than", "or", "equal", "to", "the", "minPoints", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/clustering/helpers/filter.go#L6-L15
133,198
paulmach/go.geo
quadtree/quadtree.go
New
func New(bound *geo.Bound, preallocateSize ...int) *Quadtree { qt := &Quadtree{ Threshold: math.Max(bound.Width(), bound.Height()) / float64(1<<12), bound: bound, } if len(preallocateSize) == 1 { qt.freeNodes = make([]node, preallocateSize[0], preallocateSize[0]) } return qt }
go
func New(bound *geo.Bound, preallocateSize ...int) *Quadtree { qt := &Quadtree{ Threshold: math.Max(bound.Width(), bound.Height()) / float64(1<<12), bound: bound, } if len(preallocateSize) == 1 { qt.freeNodes = make([]node, preallocateSize[0], preallocateSize[0]) } return qt }
[ "func", "New", "(", "bound", "*", "geo", ".", "Bound", ",", "preallocateSize", "...", "int", ")", "*", "Quadtree", "{", "qt", ":=", "&", "Quadtree", "{", "Threshold", ":", "math", ".", "Max", "(", "bound", ".", "Width", "(", ")", ",", "bound", ".",...
// New creates a new quadtree for the given bound. Added points // must be within this bound.
[ "New", "creates", "a", "new", "quadtree", "for", "the", "given", "bound", ".", "Added", "points", "must", "be", "within", "this", "bound", "." ]
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/quadtree/quadtree.go#L53-L63
133,199
paulmach/go.geo
quadtree/quadtree.go
NewFromPointSet
func NewFromPointSet(set *geo.PointSet) *Quadtree { q := New(set.Bound(), set.Length()) ps := []geo.Point(*set) for i := range ps { q.Insert(&ps[i]) } return q }
go
func NewFromPointSet(set *geo.PointSet) *Quadtree { q := New(set.Bound(), set.Length()) ps := []geo.Point(*set) for i := range ps { q.Insert(&ps[i]) } return q }
[ "func", "NewFromPointSet", "(", "set", "*", "geo", ".", "PointSet", ")", "*", "Quadtree", "{", "q", ":=", "New", "(", "set", ".", "Bound", "(", ")", ",", "set", ".", "Length", "(", ")", ")", "\n\n", "ps", ":=", "[", "]", "geo", ".", "Point", "(...
// NewFromPointSet creates a quadtree from a pointset. // Copies the points into the quad tree. Modifying the points later // will invalidate the quad tree and lead to unexpected result.
[ "NewFromPointSet", "creates", "a", "quadtree", "from", "a", "pointset", ".", "Copies", "the", "points", "into", "the", "quad", "tree", ".", "Modifying", "the", "points", "later", "will", "invalidate", "the", "quad", "tree", "and", "lead", "to", "unexpected", ...
22b514266d334aa8d88c792452195cbb2f670319
https://github.com/paulmach/go.geo/blob/22b514266d334aa8d88c792452195cbb2f670319/quadtree/quadtree.go#L68-L77