Skip to content

Commit

Permalink
Improved code
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Feb 17, 2025
1 parent f1d8f8d commit 0d09492
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
10 changes: 7 additions & 3 deletions Sources/PgvectorNIO/HalfVector.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import Pgvector
import PostgresNIO

extension HalfVector: @retroactive PostgresEncodable {
public static var psqlType: PostgresDataType = PostgresDataType(1)
extension HalfVector: @retroactive PostgresDynamicTypeEncodable {
public static var psqlType: PostgresDataType?

public static var psqlFormat: PostgresFormat {
public var psqlType: PostgresDataType {
HalfVector.psqlType!
}

public var psqlFormat: PostgresFormat {
.binary
}

Expand Down
10 changes: 7 additions & 3 deletions Sources/PgvectorNIO/SparseVector.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import Pgvector
import PostgresNIO

extension SparseVector: @retroactive PostgresEncodable {
public static var psqlType: PostgresDataType = PostgresDataType(1)
extension SparseVector: @retroactive PostgresDynamicTypeEncodable {
public static var psqlType: PostgresDataType?

public static var psqlFormat: PostgresFormat {
public var psqlType: PostgresDataType {
SparseVector.psqlType!
}

public var psqlFormat: PostgresFormat {
.binary
}

Expand Down
10 changes: 7 additions & 3 deletions Sources/PgvectorNIO/Vector.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import Pgvector
import PostgresNIO

extension Vector: @retroactive PostgresEncodable {
public static var psqlType: PostgresDataType = PostgresDataType(1)
extension Vector: @retroactive PostgresDynamicTypeEncodable {
public static var psqlType: PostgresDataType?

public static var psqlFormat: PostgresFormat {
public var psqlType: PostgresDataType {
Vector.psqlType!
}

public var psqlFormat: PostgresFormat {
.binary
}

Expand Down

0 comments on commit 0d09492

Please sign in to comment.