tensorflow_io/core/kernels/avro/utils/avro_parser_tree.cc
// TODO: Need to enhance the ordering constraint, the below algorithm won't do
// e.g.
// "friends[@name.first=name.first].name.initial" will result in
// 1. friends[*].name.first                         \  These are grouped by the
// pre-fix tree
// 2. friends[@name.first=name.first].name.initial  /
// 3. name.first
// but the proper order would be
// 1. name.first
// 2. friends[*].name.first
// 3. friends[@name.first=name.first].name.initial
Need to enhance the ordering constraint, the below algorithm won't do
e.g.
Need to enhance the ordering constraint the below algorithm won ' t do e . g .
std::vector<KeyWithType> AvroParserTree::OrderAndResolveKeyTypes(
    const std::vector<KeyWithType>& keys_and_types) {
  std::unordered_set<KeyWithType, KeyWithTypeHash> key_types(
      keys_and_types.begin(), keys_and_types.end());
  VectorOfUniqueElements<KeyWithType> ordered;
  string lhs_name;
  string rhs_name;
  for (const KeyWithType& key_type : key_types) {
    const string& user_name = key_type.first;
    if (ContainsFilter(&lhs_name, &rhs_name, user_name)) {
      const string& filter_name = lhs_name + "=" + rhs_name;
      VLOG(5) << "Found filter with lhs '" << lhs_name << "' and rhs '"
              << rhs_name << "'";
      if (!IsStringConstant(nullptr, lhs_name)) {
        const string& lhs_resolved_name =
            ResolveFilterName(user_name, lhs_name, filter_name);
        VLOG(5) << "  Resolved lhs " << lhs_resolved_name;
        const KeyWithType& lhs_resolved =
            std::make_pair(lhs_resolved_name, DT_STRING);
        ordered.Prepend(lhs_resolved);
        key_types.erase(lhs_resolved);
      }
      if (!IsStringConstant(nullptr, rhs_name)) {
        const string& rhs_resolved_name =
            ResolveFilterName(user_name, rhs_name, filter_name);
        VLOG(5) << "  Resolved rhs " << rhs_resolved_name;
        const KeyWithType& rhs_resolved =
            std::make_pair(rhs_resolved_name, DT_STRING);
        ordered.Prepend(rhs_resolved);
        key_types.erase(rhs_resolved);
      }
    }
    ordered.Append(key_type);
  }
  return ordered.GetOrdered();
}
std :: vector < KeyWithType > AvroParserTree :: OrderAndResolveKeyTypes ( const std :: vector < KeyWithType > & keys_and_types ) { std :: unordered_set < KeyWithType , KeyWithTypeHash > key_types ( keys_and_types . begin ( ) , keys_and_types . end ( ) ) ; VectorOfUniqueElements < KeyWithType > ordered ; string lhs_name ; string rhs_name ; for ( const KeyWithType & key_type : key_types ) { const string & user_name = key_type . first ; if ( ContainsFilter ( & lhs_name , & rhs_name , user_name ) ) { const string & filter_name = lhs_name + " " + rhs_name ; VLOG ( 5 ) << " " << lhs_name << " " << rhs_name << " " ; if ( ! IsStringConstant ( nullptr , lhs_name ) ) { const string & lhs_resolved_name = ResolveFilterName ( user_name , lhs_name , filter_name ) ; VLOG ( 5 ) << " " << lhs_resolved_name ; const KeyWithType & lhs_resolved = std :: make_pair ( lhs_resolved_name , DT_STRING ) ; ordered . Prepend ( lhs_resolved ) ; key_types . erase ( lhs_resolved ) ; } if ( ! IsStringConstant ( nullptr , rhs_name ) ) { const string & rhs_resolved_name = ResolveFilterName ( user_name , rhs_name , filter_name ) ; VLOG ( 5 ) << " " << rhs_resolved_name ; const KeyWithType & rhs_resolved = std :: make_pair ( rhs_resolved_name , DT_STRING ) ; ordered . Prepend ( rhs_resolved ) ; key_types . erase ( rhs_resolved ) ; } } ordered . Append ( key_type ) ; } return ordered . GetOrdered ( ) ; }
TODO: Need to enhance the ordering constraint, the below algorithm won't do
e.g.
TODO : Need to enhance the ordering constraint the below algorithm won ' t do e . g .