Bin Guo created AVRO-1350:
-----------------------------

             Summary: Error in decoding enums using ResolvingDecoder
                 Key: AVRO-1350
                 URL: https://issues.apache.org/jira/browse/AVRO-1350
             Project: Avro
          Issue Type: Bug
          Components: c++
    Affects Versions: 1.7.4
            Reporter: Bin Guo


We can't get a correct result when decoding enums using resolving decoder. 
e.g.
{code:title=An enum example}
{"type":"enum","name":"Mode","symbols":["MEMORY","DISK"]}
{code}
We encoded "DISK"(1), then decoded with resolving decoder, got "MEMORY"(0).
I examined the code and found that there is a sort after reading names of 
reader.
I could't quite understand the author's intention, but it really can not work 
well.

{code:title=Symbol.cc}
Symbol Symbol::enumAdjustSymbol(const NodePtr& writer, const NodePtr& reader)
{
    vector<string> rs;
    size_t rc = reader->names();
    for (size_t i = 0; i < rc; ++i) {
        rs.push_back(reader->nameAt(i));
    }
    sort(rs.begin(), rs.end()); // the strange sort
{code}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to