Skip to content

Commit a6e8a7a

Browse files
ankaneroji
andcommitted
Simplified ResolverFactory code - #48
Co-authored-by: Shay Rojansky <[email protected]>
1 parent 10341b8 commit a6e8a7a

File tree

4 files changed

+6
-86
lines changed

4 files changed

+6
-86
lines changed

src/Pgvector/Npgsql/HalfvecTypeInfoResolverFactory.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/Pgvector/Npgsql/SparsevecTypeInfoResolverFactory.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/Pgvector/Npgsql/VectorExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ public static class VectorExtensions
88
public static INpgsqlTypeMapper UseVector(this INpgsqlTypeMapper mapper)
99
{
1010
mapper.AddTypeInfoResolverFactory(new VectorTypeInfoResolverFactory());
11-
mapper.AddTypeInfoResolverFactory(new HalfvecTypeInfoResolverFactory());
12-
mapper.AddTypeInfoResolverFactory(new SparsevecTypeInfoResolverFactory());
1311
return mapper;
1412
}
1513
}

src/Pgvector/Npgsql/VectorTypeInfoResolverFactory.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ static TypeInfoMappingCollection AddMappings(TypeInfoMappingCollection mappings)
2121
{
2222
mappings.AddType<Vector>("vector",
2323
static (options, mapping, _) => mapping.CreateInfo(options, new VectorConverter()), isDefault: true);
24+
mappings.AddType<HalfVector>("halfvec",
25+
static (options, mapping, _) => mapping.CreateInfo(options, new HalfvecConverter()), isDefault: true);
26+
mappings.AddType<SparseVector>("sparsevec",
27+
static (options, mapping, _) => mapping.CreateInfo(options, new SparsevecConverter()), isDefault: true);
2428
return mappings;
2529
}
2630
}
@@ -36,6 +40,8 @@ sealed class ArrayResolver : Resolver, IPgTypeInfoResolver
3640
static TypeInfoMappingCollection AddMappings(TypeInfoMappingCollection mappings)
3741
{
3842
mappings.AddArrayType<Vector>("vector");
43+
mappings.AddArrayType<HalfVector>("halfvec");
44+
mappings.AddArrayType<SparseVector>("sparsevec");
3945
return mappings;
4046
}
4147
}

0 commit comments

Comments
 (0)