[ 
https://issues.apache.org/jira/browse/GEODE-3019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16082870#comment-16082870
 ] 

ASF GitHub Bot commented on GEODE-3019:
---------------------------------------

Github user pivotal-jbarrett commented on a diff in the pull request:

    https://github.com/apache/geode-native/pull/107#discussion_r126792435
  
    --- Diff: src/cppcache/src/Struct.cpp ---
    @@ -96,16 +99,16 @@ Serializable* Struct::fromData(DataInput& input) {
       return this;
     }
     
    -const char* Struct::getFieldName(const int32_t index) const {
    +const std::string& Struct::getFieldName(const int32_t index) const {
       if (m_parent != nullptr) {
         return m_parent->getFieldName(index);
       } else {
         for (const auto& iter : m_fieldNames) {
    -      if ((iter.second)->value() == index) return iter.first->asChar();
    +      if (iter.second == index) return (iter.first);
         }
       }
     
    -  return nullptr;
    +  return std::string("");
    --- End diff --
    
    What about throwing 
[`std::out_of_range`](http://en.cppreference.com/w/cpp/error/out_of_range). I 
don't like the idea of checking for empty string.


> Refactor Struct
> ---------------
>
>                 Key: GEODE-3019
>                 URL: https://issues.apache.org/jira/browse/GEODE-3019
>             Project: Geode
>          Issue Type: Task
>          Components: native client
>            Reporter: Jacob S. Barrett
>
> Refactor Struct (geode/Struct.hpp):
> * Replace {{char *}} with {{std::string}}
> * Replace {{m_fieldname}} type with {{std::unordered_map<std::string, 
> int32_t>}}
> * Add vector for index to field name lookup.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to