FeatureBaseDB / go-pilosa

Go client library for Pilosa
https://www.pilosa.com/
BSD 3-Clause "New" or "Revised" License
58 stars 23 forks source link

Error: can't skip unknown wire type 7 for internal.QueryResponse #30

Closed tclass closed 7 years ago

tclass commented 7 years ago

Hi, I got the following error: proto: can't skip unknown wire type 7 for internal.QueryResponse

func BenchmarkIntersectSegments(b *testing.B) {
    q := index.Intersect(frame.Bitmap(2), frame.Bitmap(3))
    if q.Error() != nil {
        b.Error(q.Error())
        return
    }
    response, err := client.Query(q, nil)
    if err != nil {
        b.Error(err) // this is where the error happens
        return
    }
    if response.ErrorMessage != "" {
        b.Error(response.ErrorMessage)
        return
    }

    for _, result := range response.Results() {
        if len(result.Bitmap.Bits) == 0 {
            b.Error("bitmap is 0")
            return
        }
    }
    return
}

The query works in the webUI: Intersect(Bitmap(segment_id=2,frame='segments'), Bitmap(segment_id=3,frame='segments'))

yuce commented 7 years ago

Hello!

WebUI uses JSON, but our client libraries use protobuf content when they communicate with the Pilosa server, so there may be some differences. It looks like the response from the server cannot be decoded. We will look into that.

What version of Pilosa are you using? Do you use one of the release binaries, docker or did you compile it from the source?

tclass commented 7 years ago

I use the release binary and the SDK with the 0.4.0 version

yuce commented 7 years ago

I am trying to reproduce the error you've encountered but not wasn't successful so far. Here are a few more questions:

func TestIntersectReturns(t *testing.T) {
    client := getClient()
    options := &FrameOptions{
        RowLabel: "segment_id",
    }
    frame, err := index.Frame("segments", options)
    if err != nil {
        t.Fatal(err)
    }
    qry := index.Intersect(frame.Bitmap(2), frame.Bitmap(3))
    response, err := client.Query(qry, nil)
    if err != nil {
        t.Fatal(err)
    }
        fmt.Println(response.Result().Bitmap.Bits)
}

I'm testing using the following code:

func TestIntersectReturns(t *testing.T) {
    client := getClient()
    options := &FrameOptions{
        RowLabel: "segment_id",
    }
    frame, err := index.Frame("segments", options)
    if err != nil {
        t.Fatal(err)
    }
    err = client.EnsureFrame(frame)
    if err != nil {
        t.Fatal(err)
    }
    qry1 := index.BatchQuery(
        frame.SetBit(2, 10),
        frame.SetBit(2, 15),
        frame.SetBit(3, 10),
        frame.SetBit(3, 20),
    )
    client.Query(qry1, nil)
    qry2 := index.Intersect(frame.Bitmap(2), frame.Bitmap(3))
    response, err := client.Query(qry2, nil)
    if err != nil {
        t.Fatal(err)
    }
    if len(response.Results()) != 1 {
        t.Fatal("There must be 1 result")
    }
    if !reflect.DeepEqual(response.Result().Bitmap.Bits, []uint64{10}) {
        t.Fatal("Returned bits must be: [10]")
    }
}
yuce commented 7 years ago

@tclass I've updated my comment with a non-destructive version of the test code which is OK to run on your Pilosa installation.

tclass commented 7 years ago

Thanks for responding that fast @yuce I found the problem this morning, I reused the index and frame variables and made them globals basically, that's why the error happend. Now it works

yuce commented 7 years ago

@tclass I'm glad the issue was resolved.

For the record, it's perfectly fine (even desired) to have the schema (index, frames) defined only once. The only constraint is the schema and its options (row label, time quantums, etc.) should represent what's on the server. Unfortunately this is currently not automatic but hopefully we won't need to define indexes and frames manually in the near-future.