MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / TestVectorTwoTxnWithoutCommit

Function TestVectorTwoTxnWithoutCommit

query/vector/vector_test.go:794–822  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

792}
793
794func TestVectorTwoTxnWithoutCommit(t *testing.T) {
795 pred := "vtest"
796 dropPredicate(pred)
797
798 setSchema(fmt.Sprintf(vectorSchemaWithIndex, pred, "4", "euclidean"))
799
800 rdf, vectors := generateRandomVectors(5, 5, "vtest")
801 txn1 := client.NewTxn()
802 _, err := txn1.Mutate(context.Background(), &api.Mutation{
803 SetNquads: []byte(rdf),
804 })
805 require.NoError(t, err)
806
807 rdf, _ = generateRandomVectors(5, 5, "vtest")
808 txn2 := client.NewTxn()
809 _, err = txn2.Mutate(context.Background(), &api.Mutation{
810 SetNquads: []byte(rdf),
811 })
812 require.NoError(t, err)
813
814 require.NoError(t, txn1.Commit(context.Background()))
815 require.Error(t, txn2.Commit(context.Background()))
816 resp, err := queryMultipleVectorsUsingSimilarTo(t, vectors[0], "vtest", 5)
817 require.NoError(t, err)
818
819 for i := 0; i < len(vectors); i++ {
820 require.Contains(t, resp, vectors[i])
821 }
822}
823
824func TestGetVector(t *testing.T) {
825 setSchema("vectorNonIndex : float32vector .")

Callers

nothing calls this directly

Calls 6

generateRandomVectorsFunction · 0.85
dropPredicateFunction · 0.70
setSchemaFunction · 0.70
MutateMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected