What does this flag mean?

We are reading items written by the Perl driver that should be just binary, and we get this flag: 50331672 for item type while the same items written in Go have 50331648.

End result is that Perl cannot read what Go writes.

What does the 50331672 flag mean? Maybe by understanding that we can write our records in a way that he Perl can understand what we write.

Could you point to Perl driver implementation? Because there is no official Couchbase SDK for Perl.

Supported SDKs use this RFC for encoding information in the flags: https://github.com/couchbaselabs/sdk-rfcs/blob/master/rfc/0020-common-flags.md

We are using:

http://search.cpan.org/~mnunberg/Couchbase-2.0.3/lib/Couchbase/Bucket.pm

mnunberg is sometimes reading here, but afaik he don’t have time to do active development on the perl library. but while it’s more or less a wrapper around the official C library maybe the support has a idea?

do you have sample code? just writing binary in perl and then try to read in perl? I know it works with JSON and simple text, we use that in a mixed go/perl environment every day.

0x03 << 24 is 50331648, so should be the same as Go.

the common flags is mostly about JSON. You can see that both flags have (0x01 << 24), which means they are using “private” encoding, which allowed to be non-portable.

So we fixed it but it’s super dirty.

When writing a binary to CB, Perl uses this bizarre 50331672 flag. Go can read it, but when writing back to CB, the flag is (correctly) set to 50331648.
Then Perl cannot read it anymore.

So we had to write a transcoder that sets the flag to 50331672. We don’t know why the perl driver is not capable of handling the good flag.

thanks piero, very interesting topic. I tried it today and get the same issue. Also sometimes the other way: items written in perl can’t read in go. I’ve never seen it before, because we use only JSON. Maybe best is, if possible, to avoid binary data completly and store them base64 encoded inside a JSON.