Source/NFX/Serialization/BSON/RowConverter.cs
/// <summary>
/// Maps bsonFieldName to targeted fieldDef from specified schema using cache for TypedRows
/// </summary>
Maps bsonFieldName to targeted fieldDef from specified schema using cache for TypedRows
Maps bsonFieldName to targeted fieldDef from specified schema using cache for TypedRows
protected static Schema.FieldDef MapBSONFieldNameToSchemaFieldDef(Schema schema, string targetName, string bsonFieldName)
        {
          if (schema.TypedRowType==null)
            return mapBSONFieldNameToSchemaFieldDef(schema, targetName, bsonFieldName);
          if (targetName==null) targetName = FieldAttribute.ANY_TARGET;
          Dictionary<string, Schema.FieldDef> byName;
          if (!s_TypedRowSchemaCache.TryGetValue(schema, out byName)) byName = null;
          Schema.FieldDef result;
          var key = targetName+"::"+bsonFieldName;
          if (byName==null || !byName.TryGetValue(key, out result))
          {
            result = mapBSONFieldNameToSchemaFieldDef(schema, targetName, bsonFieldName);
            var dict1 = new Dictionary<Schema,Dictionary<string,Schema.FieldDef>>(s_TypedRowSchemaCache);
            var dict2 = byName==null ? new Dictionary<string, Schema.FieldDef>() : new Dictionary<string, Schema.FieldDef>(byName);
            dict2[key] = result;
            dict1[schema] = dict2;
            s_TypedRowSchemaCache = dict1;
          }
          return result;
        }
protected static Schema . FieldDef MapBSONFieldNameToSchemaFieldDef ( Schema schema , string targetName , string bsonFieldName ) { if ( schema . TypedRowType == null ) return mapBSONFieldNameToSchemaFieldDef ( schema , targetName , bsonFieldName ) ; if ( targetName == null ) targetName = FieldAttribute . ANY_TARGET ; Dictionary < string , Schema . FieldDef > byName ; if ( ! s_TypedRowSchemaCache . TryGetValue ( schema , out byName ) ) byName = null ; Schema . FieldDef result ; var key = targetName + " " + bsonFieldName ; if ( byName == null || ! byName . TryGetValue ( key , out result ) ) { result = mapBSONFieldNameToSchemaFieldDef ( schema , targetName , bsonFieldName ) ; var dict1 = new Dictionary < Schema , Dictionary < string , Schema . FieldDef > > ( s_TypedRowSchemaCache ) ; var dict2 = byName == null ? new Dictionary < string , Schema . FieldDef > ( ) : new Dictionary < string , Schema . FieldDef > ( byName ) ; dict2 [ key ] = result ; dict1 [ schema ] = dict2 ; s_TypedRowSchemaCache = dict1 ; } return result ; }
Maps bsonFieldName to targeted fieldDef from specified schema using cache for TypedRows
Maps bsonFieldName to targeted fieldDef from specified schema using cache for TypedRows
//safeguard //atomic
schema
Schema
targetName
string
bsonFieldName
string