Skip to content

Commit

Permalink
Added vector type
Browse files Browse the repository at this point in the history
  • Loading branch information
Harshil Goel committed Mar 13, 2024
1 parent 3754e87 commit b90e0d4
Show file tree
Hide file tree
Showing 14 changed files with 707 additions and 39 deletions.
5 changes: 5 additions & 0 deletions chunker/json_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ func handleBasicType(k string, v interface{}, op int, nq *api.NQuad) error {
return nil
}

if vf, err := types.ParseVFloat(v); err == nil {
nq.ObjectValue = &api.Value{Val: &api.Value_VdoubleVal{VdoubleVal: types.FloatArrayAsBytes(vf)}}
return nil
}

// Handle the uid function in upsert block
s := stripSpaces(v)
if strings.HasPrefix(s, "uid(") || strings.HasPrefix(s, "val(") {
Expand Down
5 changes: 5 additions & 0 deletions dql/mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ func TypeValFrom(val *api.Value) types.Val {
return types.Val{Tid: types.DateTimeID, Value: val.GetDatetimeVal()}
case *api.Value_PasswordVal:
return types.Val{Tid: types.PasswordID, Value: val.GetPasswordVal()}
case *api.Value_VdoubleVal:
return types.Val{
Tid: types.VFloatID,
Value: types.BytesAsFloatArray(val.GetVdoubleVal()),
}
case *api.Value_DefaultVal:
return types.Val{Tid: types.DefaultID, Value: val.GetDefaultVal()}
}
Expand Down
19 changes: 19 additions & 0 deletions protos/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ message Result {
repeated FacetsList facet_matrix = 5;
repeated LangList lang_matrix = 6;
bool list = 7;
map<string, uint64> extra_metrics = 8;
}

message Order {
Expand Down Expand Up @@ -377,6 +378,10 @@ message Posting {
PASSWORD = 8;
STRING = 9;
OBJECT = 10;
// RESERVE 11 for BIGFLOAT, should we desire to pull
// that in at a later date. (There is a pending PR
// that uses this).
VFLOAT = 12; // Float64 Vector
}
ValType val_type = 3;
enum PostingType {
Expand Down Expand Up @@ -514,6 +519,20 @@ message SchemaUpdate {
// Deleted field:
reserved 7;
reserved "explicit";

repeated VectorSpec vector_specs = 15;
}

message VectorSpec {
// This names the kind of Vector Index, e.g.,
// hnsw, lsh, hypertree, ...
string name = 1;
repeated OptionPair options = 2;
}

message OptionPair {
string key = 1;
string value = 2;
}

message TypeUpdate {
Expand Down
Loading

0 comments on commit b90e0d4

Please sign in to comment.