-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
47 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'dart:convert'; | ||
import 'package:postgres/postgres.dart'; | ||
import 'bit.dart'; | ||
import 'halfvec.dart'; | ||
import 'sparsevec.dart'; | ||
import 'vector.dart'; | ||
|
||
EncodedValue? PgvectorEncoder(TypedValue input, CodecContext context) { | ||
final value = input.value; | ||
|
||
if (value is Vector) { | ||
final v = value as Vector; | ||
return EncodedValue.binary(v.toBinary()); | ||
} | ||
|
||
if (value is HalfVector) { | ||
final v = value as HalfVector; | ||
return EncodedValue.text(utf8.encode(v.toString())); | ||
} | ||
|
||
if (value is Bit) { | ||
final v = value as Bit; | ||
return EncodedValue.binary(v.toBinary()); | ||
} | ||
|
||
if (value is SparseVector) { | ||
final v = value as SparseVector; | ||
return EncodedValue.binary(v.toBinary()); | ||
} | ||
|
||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters