zhaopuming / quickfast

Automatically exported from code.google.com/p/quickfast
Other
1 stars 0 forks source link

presenceMapBitsRequired function should be redefined in FieldInstructionDecimal #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

<group name="AuctionPrice" presence="optional">
  <decimal name="MDEntryPx" id="270">
    <exponent><copy/></exponent>
    <mantissa><delta/></mantissa>
  </decimal>
  <uInt32 name="MDEntrySize" id="271"><delta/></uInt32>
</group>

This example could fail, because MDEntryPx and MDEntrySize return 0 when
they call presenceMapBitsRequired, so group AuctionPrice won't have PMAP,
what is oviusly wrong. 

presenceMapBitsRequired for Decimal numbers should check exponent and
mantissa operators, in order to obtain their real length of PMAP.

Patch attached.

Carlos

Original issue reported on code.google.com by carlo...@gmail.com on 3 Dec 2009 at 2:42

Attachments:

GoogleCodeExporter commented 9 years ago
The actual problem was not related to decimal fields.  The presence map bit 
count for
decimal fields is correct.  When an optional group had been merged into the
containing application message because there were no typerefs or the typeref of 
the
group matched the typeref of the containing segment, the encoder did not write 
the
pmap bit for the group in the containing segment's pmap.

Unit test based on the XML in this issue: test_unit_31 in 
testFieldInstructions.cpp.

Problem fixed in R270

Original comment by dale.wil...@gmail.com on 3 Dec 2009 at 9:02

GoogleCodeExporter commented 9 years ago
I think we are not talking about the same problem. I'll try to explain the 
problem on
detail. When you try to encode a group encodeNop function is called and it call
encodeGroup. Once you are inside encodeGroup, the program will call
presenceMapBitsRequired(FieldInstructionGroup.cpp).

presenceMapBitsRequired iterates for all instructions that compose the group, 
asking
them the length of PMAP. As FieldInstructionDecimal returns 0, the instruction
pmap.encode(Encoder.cpp) will not be executed.

This is the trace:

FieldInstructionGroup::encodeNop(...) : Line 104 
  --> encoder.encodeGroup(destination, segmentBody_ *group);

Encoder::encodeGroup(...) : Line 82 
  --> size_t presenceMapBits = group->presenceMapBitCount(); * It returns 0

Encoder::encodeGroup(...) : Line 99
  --> if (presenceMapBits > 0) 
  --> {
  -->   destination.selectBuffer(pmapBuffer);
  -->   pmap.encode(destination);
  --> }

*As presenceMapBits is 0 pmap don't call encode funtion.

Your test file works but is not 100% accurate. You are creating SegmentBodyPtr 
with
SegmentBody(1) but parsing XML file you use SegmentBody()(0 by default), so in 
some
way your are cheating since you are assuming the group will have 1 bit.

Original comment by carlo...@gmail.com on 4 Dec 2009 at 12:25

GoogleCodeExporter commented 9 years ago
Take two on fixing this one.   I changed the test to create a truly empty 
segment
body, and the problem showed up.   

The fix involved changing how presence map bit requirements are calculated.  
The new
technique gives the real number rather than a "best guess."

Original comment by dale.wil...@gmail.com on 7 Dec 2009 at 4:42