in cs/src/core/Index/FASTER/FASTER.cs [760:827]
private static void UpdateVarLen(ref VariableLengthStructSettings<Key, Value> variableLengthStructSettings)
{
if (typeof(Key) == typeof(SpanByte))
{
if (variableLengthStructSettings == null)
variableLengthStructSettings = new VariableLengthStructSettings<SpanByte, Value>() as VariableLengthStructSettings<Key, Value>;
if (variableLengthStructSettings.keyLength == null)
(variableLengthStructSettings as VariableLengthStructSettings<SpanByte, Value>).keyLength = new SpanByteVarLenStruct();
}
else if (typeof(Key).IsGenericType && (typeof(Key).GetGenericTypeDefinition() == typeof(Memory<>)) && Utility.IsBlittableType(typeof(Key).GetGenericArguments()[0]))
{
if (variableLengthStructSettings == null)
variableLengthStructSettings = new VariableLengthStructSettings<Key, Value>();
if (variableLengthStructSettings.keyLength == null)
{
var m = typeof(MemoryVarLenStruct<>).MakeGenericType(typeof(Key).GetGenericArguments());
object o = Activator.CreateInstance(m);
variableLengthStructSettings.keyLength = o as IVariableLengthStruct<Key>;
}
}
else if (typeof(Key).IsGenericType && (typeof(Key).GetGenericTypeDefinition() == typeof(ReadOnlyMemory<>)) && Utility.IsBlittableType(typeof(Key).GetGenericArguments()[0]))
{
if (variableLengthStructSettings == null)
variableLengthStructSettings = new VariableLengthStructSettings<Key, Value>();
if (variableLengthStructSettings.keyLength == null)
{
var m = typeof(ReadOnlyMemoryVarLenStruct<>).MakeGenericType(typeof(Key).GetGenericArguments());
object o = Activator.CreateInstance(m);
variableLengthStructSettings.keyLength = o as IVariableLengthStruct<Key>;
}
}
if (typeof(Value) == typeof(SpanByte))
{
if (variableLengthStructSettings == null)
variableLengthStructSettings = new VariableLengthStructSettings<Key, SpanByte>() as VariableLengthStructSettings<Key, Value>;
if (variableLengthStructSettings.valueLength == null)
(variableLengthStructSettings as VariableLengthStructSettings<Key, SpanByte>).valueLength = new SpanByteVarLenStruct();
}
else if (typeof(Value).IsGenericType && (typeof(Value).GetGenericTypeDefinition() == typeof(Memory<>)) && Utility.IsBlittableType(typeof(Value).GetGenericArguments()[0]))
{
if (variableLengthStructSettings == null)
variableLengthStructSettings = new VariableLengthStructSettings<Key, Value>();
if (variableLengthStructSettings.valueLength == null)
{
var m = typeof(MemoryVarLenStruct<>).MakeGenericType(typeof(Value).GetGenericArguments());
object o = Activator.CreateInstance(m);
variableLengthStructSettings.valueLength = o as IVariableLengthStruct<Value>;
}
}
else if (typeof(Value).IsGenericType && (typeof(Value).GetGenericTypeDefinition() == typeof(ReadOnlyMemory<>)) && Utility.IsBlittableType(typeof(Value).GetGenericArguments()[0]))
{
if (variableLengthStructSettings == null)
variableLengthStructSettings = new VariableLengthStructSettings<Key, Value>();
if (variableLengthStructSettings.valueLength == null)
{
var m = typeof(ReadOnlyMemoryVarLenStruct<>).MakeGenericType(typeof(Value).GetGenericArguments());
object o = Activator.CreateInstance(m);
variableLengthStructSettings.valueLength = o as IVariableLengthStruct<Value>;
}
}
}