From a61ed011fc1c4fd0ee3553e0350d7abb08ad9c53 Mon Sep 17 00:00:00 2001 From: tgruben Date: Wed, 10 Feb 2021 14:51:11 -0600 Subject: [PATCH] Revert "Update existence field on import-roaring requests" --- api.go | 13 +------------ executor.go | 2 ++ http/client_test.go | 46 --------------------------------------------- http/handler.go | 1 + index.go | 1 + 5 files changed, 5 insertions(+), 58 deletions(-) diff --git a/api.go b/api.go index 79246c271..d2c09fe85 100644 --- a/api.go +++ b/api.go @@ -416,12 +416,6 @@ func importWorker(importWork chan importJob) { case RequestActionSet: fileMagic := uint32(binary.LittleEndian.Uint16(viewData[0:2])) if fileMagic == roaring.MagicNumber { // if pilosa roaring format - if ef := j.field.idx.existenceField(); ef != nil { - err = ef.importRoaring(j.ctx, tx, viewData, j.shard, "standard", false) - if err != nil { - return errors.Wrap(err, "importing pilosa roaring existence") - } - } err := j.field.importRoaring(j.ctx, tx, viewData, j.shard, viewName, doClear) if err != nil { return errors.Wrap(err, "importing pilosa roaring") @@ -431,12 +425,6 @@ func importWorker(importWork chan importJob) { // field.importRoaring changes the standard roaring run format to pilosa roaring data := make([]byte, len(viewData)) copy(data, viewData) - if ef := j.field.idx.existenceField(); ef != nil { - err = ef.importRoaring(j.ctx, tx, data, j.shard, "standard", false) - if err != nil { - return errors.Wrap(err, "importing pilosa roaring existence") - } - } err := j.field.importRoaring(j.ctx, tx, data, j.shard, viewName, doClear) if err != nil { @@ -480,6 +468,7 @@ func (api *API) ImportRoaring(ctx context.Context, indexName, fieldName string, span, ctx := tracing.StartSpanFromContext(ctx, "API.ImportRoaring") span.LogKV("index", indexName, "field", fieldName) defer span.Finish() + if err := api.validate(apiField); err != nil { return errors.Wrap(err, "validating api method") } diff --git a/executor.go b/executor.go index 4b88d4270..6a50d4c2c 100644 --- a/executor.go +++ b/executor.go @@ -4569,6 +4569,7 @@ func (e *executor) executeUnionRows(ctx context.Context, qcx *Qcx, index string, // executeAllCallShard executes an All() call for a local shard. func (e *executor) executeAllCallShard(ctx context.Context, qcx *Qcx, index string, c *pql.Call, shard uint64) (res *Row, err0 error) { + span, _ := tracing.StartSpanFromContext(ctx, "Executor.executeAllCallShard") defer span.Finish() @@ -4595,6 +4596,7 @@ func (e *executor) executeAllCallShard(ctx context.Context, qcx *Qcx, index stri } defer finisher(&err0) + if existenceRow, err = existenceFrag.row(tx, 0); err != nil { return nil, err } diff --git a/http/client_test.go b/http/client_test.go index 4d2c7f315..b1b154647 100644 --- a/http/client_test.go +++ b/http/client_test.go @@ -1435,49 +1435,3 @@ func TestClient_ServerInfoHasTxSrc(t *testing.T) { } pilosa.MustTxsrcToTxtype(si.TxSrc) // panics if invalid } -func TestClient_ImportRoaringExists(t *testing.T) { - cluster := test.MustNewCluster(t, 1) - err := cluster.Start() - if err != nil { - t.Fatalf("starting cluster: %v", err) - } - defer cluster.Close() - - node := cluster.GetNode(0) - _, err = node.API.CreateIndex(context.Background(), "i", pilosa.IndexOptions{TrackExistence: true}) - if err != nil { - t.Fatalf("creating index: %v", err) - } - _, err = node.API.CreateField(context.Background(), "i", "f", pilosa.OptFieldTypeSet(pilosa.CacheTypeRanked, 100)) - if err != nil { - t.Fatalf("creating field: %v", err) - } - // Send import request. - host := node.URL() - c := MustNewClient(host, http.GetHTTPClient(nil)) - // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 65537] - roaringReq := makeImportRoaringRequest(false, "3B3001000100000900010000000100010009000100") - - if err := c.ImportRoaring(context.Background(), &cluster.GetNode(0).API.Node().URI, "i", "f", 0, false, roaringReq); err != nil { - t.Fatal(err) - } - expected := []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 65537} - var qr pilosa.QueryResponse - qr, err = node.API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: "Row(f=0)"}) - if err != nil { - t.Fatalf("%v", err) - } - got := qr.Results[0].(*pilosa.Row).Columns() - if !reflect.DeepEqual(got, expected) { - t.Fatalf(" Row unexpected columns: got %+v expected: %+v", got, expected) - } - qr, err = node.API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: "All()"}) - if err != nil { - t.Fatalf("%v", err) - } - got = qr.Results[0].(*pilosa.Row).Columns() - if !reflect.DeepEqual(got, expected) { - t.Fatalf("All unexpected columns: got %+v expected: %+v", got, expected) - } - -} diff --git a/http/handler.go b/http/handler.go index b7e44f67e..a6dfd5828 100644 --- a/http/handler.go +++ b/http/handler.go @@ -2486,6 +2486,7 @@ func (h *Handler) handlePostImportRoaring(w http.ResponseWriter, r *http.Request http.Error(w, error, code) return } + // Get index and field type to determine how to handle the // import data. indexName := mux.Vars(r)["index"] diff --git a/index.go b/index.go index 94f47c6c7..6129289f5 100644 --- a/index.go +++ b/index.go @@ -482,6 +482,7 @@ func (i *Index) Fields() []*Field { func (i *Index) existenceField() *Field { i.mu.RLock() defer i.mu.RUnlock() + return i.existenceFld }