diff --git a/docs/api-reference.md b/docs/api-reference.md index e8a2ac1a3..c414d9bb5 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -376,6 +376,27 @@ curl -XGET localhost:10101/status } ``` +### Get active queries + +`GET /queries` + +Returns the set of active queries. Supports pretty printing in `text/plain` format or JSON output in `application/json` format. +Also includes the amount of time that the query has been running (in nanoseconds when using JSON). + +```request +curl -XGET localhost:10101/queries +``` +```response +182.412µs All() +``` + +```request +curl -XGET -H "Accept: application/json" localhost:10101/queries +``` +```response +[{"query":"All()","age":135123}] +``` + ### Recalculate Caches `POST /recalculate-caches` diff --git a/holder_internal_test.go b/holder_internal_test.go index 1a229858a..28a18fbe8 100644 --- a/holder_internal_test.go +++ b/holder_internal_test.go @@ -78,8 +78,9 @@ func makeHolder() (*Holder, string, error) { return nil, "", err } h := NewHolder(DefaultPartitionN) + h.Path = path - return h, path, nil + return h, h.Path, nil } func testSetBit(t *testing.T, h *Holder, index, field string, rowID, columnID uint64) { diff --git a/pilosa b/pilosa deleted file mode 100755 index 1aca8c909..000000000 Binary files a/pilosa and /dev/null differ diff --git a/translator_test.go b/translator_test.go index 32a3da00d..caebc4e0a 100644 --- a/translator_test.go +++ b/translator_test.go @@ -336,34 +336,39 @@ func TestTranslation_Coordinator(t *testing.T) { } // Create a field with keys. - if _, err := node0.API.CreateField(ctx, idx, fld, + if _, err := node1.API.CreateField(ctx, idx, fld, pilosa.OptFieldKeys(), ); err != nil { t.Fatal(err) } - key := "abc" - pql := fmt.Sprintf(`Set(1, %s="%s")`, fld, key) + keys := []string{"one", "two", "three"} + for i := range keys { + pql := fmt.Sprintf(`Set(%d, %s="%s")`, i+1, fld, keys[i]) - // Send a translation request to node1 (non-coordinator). - _, err := node1.API.Query(ctx, - &pilosa.QueryRequest{Index: idx, Query: pql}, - ) - if err != nil { - t.Fatal(err) + // Send a translation request to node1 (non-coordinator). + _, err := node1.API.Query(ctx, + &pilosa.QueryRequest{Index: idx, Query: pql}, + ) + if err != nil { + t.Fatal(err) + } } - // Read the row and ensure the key was set. - qry := fmt.Sprintf(`Row(%s="%s")`, fld, key) - resp, err := node0.API.Query(ctx, - &pilosa.QueryRequest{Index: idx, Query: qry}, - ) - if err != nil { - t.Fatal(err) - } - row := resp.Results[0].(*pilosa.Row) - if cols := row.Columns(); !reflect.DeepEqual(cols, []uint64{1}) { - t.Fatalf("unexpected columns: %+v", cols) + for i := len(keys) - 1; i >= 0; i-- { + // Read the row and ensure the key was set. + qry := fmt.Sprintf(`Row(%s="%s")`, fld, keys[i]) + resp, err := node0.API.Query(ctx, + &pilosa.QueryRequest{Index: idx, Query: qry}, + ) + if err != nil { + t.Fatal(err) + } + row := resp.Results[0].(*pilosa.Row) + val := uint64(i + 1) + if cols := row.Columns(); !reflect.DeepEqual(cols, []uint64{val}) { + t.Fatalf("unexpected columns: %+v", cols) + } } }) }