MCPcopy Create free account
hub / github.com/apache/fory / StoreTypeMetaRef

Method StoreTypeMetaRef

csharp/src/Fory/ReadContext.cs:94–129  ·  view source on GitHub ↗
(TypeMeta typeMeta, int index)

Source from the content-addressed store, hash-verified

92 }
93
94 internal void StoreTypeMetaRef(TypeMeta typeMeta, int index)
95 {
96 if (index < 0)
97 {
98 throw new InvalidDataException("negative type meta index");
99 }
100
101 if (index == 0)
102 {
103 _firstTypeMetaRef = typeMeta;
104 _hasFirstTypeMetaRef = true;
105 return;
106 }
107
108 if (!_hasFirstTypeMetaRef)
109 {
110 throw new InvalidDataException(
111 $"type meta index gap: index={index}, missing index 0");
112 }
113
114 int listIndex = index - 1;
115 if (listIndex == _typeMetaRefs.Count)
116 {
117 _typeMetaRefs.Add(typeMeta);
118 return;
119 }
120
121 if (listIndex < _typeMetaRefs.Count)
122 {
123 _typeMetaRefs.Set(listIndex, typeMeta);
124 return;
125 }
126
127 throw new InvalidDataException(
128 $"type meta index gap: index={index}, count={_typeMetaRefs.Count + 1}");
129 }
130
131 internal bool TryGetTypeMetaByHeader(ulong header, out TypeMeta typeMeta)
132 {

Callers 4

ReadTypeInfoCoreMethod · 0.80
ReadNamedTypeInfoMethod · 0.80
ReadRemoteTypeMetaMethod · 0.80
ReadAnyTypeInfoMethod · 0.80

Calls 2

AddMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected