Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change "Rows" to "Series" in API output #1687

Merged
merged 1 commit into from
Feb 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions client/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,20 @@ func (c *Client) Ping() (time.Duration, string, error) {

// Result represents a resultset returned from a single statement.
type Result struct {
Rows []influxql.Row
Err error
Series []influxql.Row
Err error
}

// MarshalJSON encodes the result into JSON.
func (r *Result) MarshalJSON() ([]byte, error) {
// Define a struct that outputs "error" as a string.
var o struct {
Rows []influxql.Row `json:"rows,omitempty"`
Err string `json:"error,omitempty"`
Series []influxql.Row `json:"series,omitempty"`
Err string `json:"error,omitempty"`
}

// Copy fields to output struct.
o.Rows = r.Rows
o.Series = r.Series
if r.Err != nil {
o.Err = r.Err.Error()
}
Expand All @@ -170,8 +170,8 @@ func (r *Result) MarshalJSON() ([]byte, error) {
// UnmarshalJSON decodes the data into the Result struct
func (r *Result) UnmarshalJSON(b []byte) error {
var o struct {
Rows []influxql.Row `json:"rows,omitempty"`
Err string `json:"error,omitempty"`
Series []influxql.Row `json:"series,omitempty"`
Err string `json:"error,omitempty"`
}

dec := json.NewDecoder(bytes.NewBuffer(b))
Expand All @@ -180,7 +180,7 @@ func (r *Result) UnmarshalJSON(b []byte) error {
if err != nil {
return err
}
r.Rows = o.Rows
r.Series = o.Series
if o.Err != "" {
r.Err = errors.New(o.Err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/influx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func resultToCSV(result client.Result, seperator string, headerLines bool) []str
// Create a tabbed writer for each result a they won't always line up
columnNames := []string{"name", "tags"}

for i, row := range result.Rows {
for i, row := range result.Series {
// Output the column headings
if i == 0 {
for _, column := range row.Columns {
Expand Down
12 changes: 6 additions & 6 deletions cmd/influxd/server_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func createDatabase(t *testing.T, testName string, nodes cluster, database strin

expectedResults := client.Results{
Results: []client.Result{
{Rows: []influxql.Row{
{Series: []influxql.Row{
{
Columns: []string{"name"},
Values: [][]interface{}{{"foo"}},
Expand Down Expand Up @@ -346,10 +346,10 @@ func simpleCountQuery(t *testing.T, testname string, nodes cluster, query, field
t.Fatalf("query databases failed. Unexpected status code. expected: %d, actual %d", http.StatusOK, resp.StatusCode)
}

if len(results.Results) != 1 || len(results.Results[0].Rows) != 1 {
if len(results.Results) != 1 || len(results.Results[0].Series) != 1 {
t.Fatal("results object returned has insufficient entries")
}
j, ok := results.Results[0].Rows[0].Values[0][1].(json.Number)
j, ok := results.Results[0].Series[0].Values[0][1].(json.Number)
if !ok {
t.Fatalf("count is not a JSON number")
}
Expand Down Expand Up @@ -392,7 +392,7 @@ func Test_ServerSingleIntegration(t *testing.T) {
`, now.UnixNano()))
expectedResults := client.Results{
Results: []client.Result{
{Rows: []influxql.Row{
{Series: []influxql.Row{
{
Name: "cpu",
Columns: []string{"time", "value"},
Expand Down Expand Up @@ -438,7 +438,7 @@ func Test_Server3NodeIntegration(t *testing.T) {
`, now.UnixNano()))
expectedResults := client.Results{
Results: []client.Result{
{Rows: []influxql.Row{
{Series: []influxql.Row{
{
Name: "cpu",
Columns: []string{"time", "value"},
Expand Down Expand Up @@ -485,7 +485,7 @@ func Test_Server5NodeIntegration(t *testing.T) {

expectedResults := client.Results{
Results: []client.Result{
{Rows: []influxql.Row{
{Series: []influxql.Row{
{
Name: "cpu",
Columns: []string{"time", "value"},
Expand Down
Loading