IGetResult.ContentAs issues: Serialization, Expiry


In the 3.0.1 there is multiple issue with the ContentAs function:

  • If we ask for the expiry, this is breaking the serialization paradigm:
    You create a JObject (So it’s limiting to NewtonSoft), instead you may ask the ITypeSerializer to create a raw object.
    You add property by using JProperty, idem, the ITypeSerializer must have a function to do so
    You finaly do two times a ToObject() => So you are using the default serializer instead of the ITypeSerializer.
    So the result is : asking for expiry, is making the ITypeSerialized not used anymore…

  • I do not look at all the sdk, but if you ask to Expiry, you still push a specs Get. So i expect the ContentAs to return the object fully instead of the composite of expiry and the document… I did patch the sdk for our usage with that change:

if (_specs.Count == 1 && _projectList?.Count == 0)
var spec = _specs[0];
return _transcoder.Decode(spec.Bytes, Flags, OpCode.Get);
// normal GET
// If requesting the full doc, return the full doc…
var getSpecs = _specs.FirstOrDefault(s => s.OpCode == OpCode.Get);
if (getSpecs != null && _projectList?.Count == 0)
return _transcoder.Decode(getSpecs.Bytes, Flags, OpCode.Get);

This is increasing the performance of requesting the Expiry by 50% and this is respecting the ITypeSerializer.



1 Like

Hi again,

For the expiry, i think the best way will be to mark with a flag in the SubDocPathFlag if the request is from the client or from the sdk. In the case of the GetOptions().Expiry(), set the PathFlags = SubdocPathFlags.Xattr | SubdocPathFlags.SdkRequested

In the GetResults: filters the specs by removing all the one with the flags SdkRequested.

This is for my point of view, making more sense. If i put Expiry() in the options, i still expect to retreive my doc, and only my doc with the ContentAs.



1 Like

@David_Allaigre -

Thanks for reporting. I created two (NCBC-2570/NCBC-2571) tickets for tracking and linked them back to this post for reference.

These will be resolved likely in 3.0.3 or 3.0.4.