MCPcopy
hub / github.com/dgraph-io/dgraph / TestBulkLoadVectorDimensions

Function TestBulkLoadVectorDimensions

systest/vector/load_test.go:517–629  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

515}
516
517func TestBulkLoadVectorDimensions(t *testing.T) {
518 // Test different dimension sizes: small (3D), medium (128D), large (512D)
519 testCases := []struct {
520 name string
521 dimension int
522 numVecs int
523 }{
524 {"small_3d", 3, 100},
525 {"medium_128d", 128, 100},
526 {"large_512d", 512, 50}, // Fewer vectors for large dimensions
527 }
528
529 for _, tc := range testCases {
530 t.Run(tc.name, func(t *testing.T) {
531 predName := "project_description_v"
532 schema := fmt.Sprintf(`%s: float32vector @index(hnsw(exponent: "5", metric: "euclidean")) .`, predName)
533
534 // Step 1: Create source cluster
535 sourceConf := dgraphtest.NewClusterConfig().
536 WithNumAlphas(1).
537 WithNumZeros(1).
538 WithReplicas(1).
539 WithACL(time.Hour)
540 sourceCluster, err := dgraphtest.NewLocalCluster(sourceConf)
541 require.NoError(t, err)
542 defer func() { sourceCluster.Cleanup(t.Failed()) }()
543 require.NoError(t, sourceCluster.Start())
544
545 gc, cleanup, err := sourceCluster.Client()
546 require.NoError(t, err)
547 defer cleanup()
548 require.NoError(t, gc.LoginIntoNamespace(context.Background(),
549 dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace))
550
551 hc, err := sourceCluster.HTTPClient()
552 require.NoError(t, err)
553 require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser,
554 dgraphapi.DefaultPassword, x.RootNamespace))
555
556 require.NoError(t, gc.SetupSchema(schema))
557
558 // Generate vectors with specific dimension
559 rdfs, vectors := dgraphapi.GenerateRandomVectors(0, tc.numVecs, tc.dimension, predName)
560 mu := &api.Mutation{SetNquads: []byte(rdfs), CommitNow: true}
561 _, err = gc.Mutate(mu)
562 require.NoError(t, err)
563
564 // Step 2: Export
565 require.NoError(t, hc.Export(dgraphtest.DefaultExportDir, "rdf", -1))
566
567 // Step 3: Bulk load
568 bulkOutDir := t.TempDir()
569 bulkConf := dgraphtest.NewClusterConfig().
570 WithNumAlphas(1).
571 WithNumZeros(1).
572 WithReplicas(1).
573 WithACL(time.Hour).
574 WithBulkLoadOutDir(bulkOutDir)

Callers

nothing calls this directly

Calls 15

CleanupMethod · 0.95
StartMethod · 0.95
ClientMethod · 0.95
HTTPClientMethod · 0.95
StartZeroMethod · 0.95
HealthCheckMethod · 0.95
CopyExportToHostMethod · 0.95
BulkLoadMethod · 0.95
NewClusterConfigFunction · 0.92
NewLocalClusterFunction · 0.92
GenerateRandomVectorsFunction · 0.92
cleanupFunction · 0.85

Tested by

no test coverage detected