@@ -39,32 +39,32 @@ func Import(ctx context.Context, endpoint string, opts grpc.DialOption, bulkOutD
3939 if err != nil {
4040 return err
4141 }
42- resp , err := startSnapshotStream (ctx , dg )
42+ resp , err := startPDirStream (ctx , dg )
4343 if err != nil {
4444 return err
4545 }
4646
47- return sendSnapshot (ctx , dg , bulkOutDir , resp .Groups )
47+ return sendPDir (ctx , dg , bulkOutDir , resp .Groups )
4848}
4949
50- // startSnapshotStream initiates a snapshot stream session with the Dgraph server.
51- func startSnapshotStream (ctx context.Context , dc apiv25.DgraphClient ) (* apiv25.InitiateSnapshotStreamResponse , error ) {
52- glog .Info ("Initiating snapshot stream" )
53- req := & apiv25.InitiateSnapshotStreamRequest {}
54- resp , err := dc .InitiateSnapshotStream (ctx , req )
50+ // startPDirStream initiates a snapshot stream session with the Dgraph server.
51+ func startPDirStream (ctx context.Context , dc apiv25.DgraphClient ) (* apiv25.InitiatePDirStreamResponse , error ) {
52+ glog .Info ("Initiating pdir stream" )
53+ req := & apiv25.InitiatePDirStreamRequest {}
54+ resp , err := dc .InitiatePDirStream (ctx , req )
5555 if err != nil {
56- glog .Errorf ("failed to initiate snapshot stream: %v" , err )
57- return nil , fmt .Errorf ("failed to initiate snapshot stream: %v" , err )
56+ glog .Errorf ("failed to initiate pdir stream: %v" , err )
57+ return nil , fmt .Errorf ("failed to initiate pdir stream: %v" , err )
5858 }
59- glog .Info ("Snapshot stream initiated successfully" )
59+ glog .Info ("Pdir stream initiated successfully" )
6060 return resp , nil
6161}
6262
63- // sendSnapshot takes a p directory and a set of group IDs and streams the data from the
63+ // sendPDir takes a p directory and a set of group IDs and streams the data from the
6464// p directory to the corresponding group IDs. It first scans the provided directory for
6565// subdirectories named with numeric group IDs.
66- func sendSnapshot (ctx context.Context , dg apiv25.DgraphClient , baseDir string , groups []uint32 ) error {
67- glog .Infof ("Starting to stream snapshots from directory: %s" , baseDir )
66+ func sendPDir (ctx context.Context , dg apiv25.DgraphClient , baseDir string , groups []uint32 ) error {
67+ glog .Infof ("Starting to stream pdir from directory: %s" , baseDir )
6868
6969 errG , ctx := errgroup .WithContext (ctx )
7070 for _ , group := range groups {
@@ -88,7 +88,7 @@ func sendSnapshot(ctx context.Context, dg apiv25.DgraphClient, baseDir string, g
8888 return err
8989 }
9090
91- glog .Infof ("Completed streaming all snapshots " )
91+ glog .Infof ("Completed streaming all pdirs " )
9292 return nil
9393}
9494
@@ -98,9 +98,9 @@ func streamData(ctx context.Context, dg apiv25.DgraphClient, pdir string, groupI
9898 glog .Infof ("Opening stream for group %d from directory %s" , groupId , pdir )
9999
100100 // Initialize stream with the server
101- out , err := dg .StreamSnapshot (ctx )
101+ out , err := dg .StreamPDir (ctx )
102102 if err != nil {
103- return fmt .Errorf ("failed to start snapshot stream for group %d: %w" , groupId , err )
103+ return fmt .Errorf ("failed to start pdir stream for group %d: %w" , groupId , err )
104104 }
105105
106106 // Open the BadgerDB instance at the specified directory
@@ -118,7 +118,7 @@ func streamData(ctx context.Context, dg apiv25.DgraphClient, pdir string, groupI
118118
119119 // Send group ID as the first message in the stream
120120 glog .Infof ("Sending group ID [%d] to server" , groupId )
121- groupReq := & apiv25.StreamSnapshotRequest {GroupId : groupId }
121+ groupReq := & apiv25.StreamPDirRequest {GroupId : groupId }
122122 if err := out .Send (groupReq ); err != nil {
123123 return fmt .Errorf ("failed to send group ID [%d]: %w" , groupId , err )
124124 }
@@ -129,8 +129,8 @@ func streamData(ctx context.Context, dg apiv25.DgraphClient, pdir string, groupI
129129 stream .LogPrefix = fmt .Sprintf ("Sending P dir for group [%d]" , groupId )
130130 stream .KeyToList = nil
131131 stream .Send = func (buf * z.Buffer ) error {
132- kvs := & apiv25.KVS {Data : buf .Bytes ()}
133- if err := out .Send (& apiv25.StreamSnapshotRequest { Pairs : kvs }); err != nil && ! errors .Is (err , io .EOF ) {
132+ p := & apiv25.StreamPacket {Data : buf .Bytes ()}
133+ if err := out .Send (& apiv25.StreamPDirRequest { StreamPacket : p }); err != nil && ! errors .Is (err , io .EOF ) {
134134 return fmt .Errorf ("failed to send data chunk: %w" , err )
135135 }
136136 return nil
@@ -143,9 +143,9 @@ func streamData(ctx context.Context, dg apiv25.DgraphClient, pdir string, groupI
143143
144144 // Send the final 'done' signal to mark completion
145145 glog .Infof ("Sending completion signal for group [%d]" , groupId )
146- done := & apiv25.KVS {Done : true }
146+ done := & apiv25.StreamPacket {Done : true }
147147
148- if err := out .Send (& apiv25.StreamSnapshotRequest { Pairs : done }); err != nil && ! errors .Is (err , io .EOF ) {
148+ if err := out .Send (& apiv25.StreamPDirRequest { StreamPacket : done }); err != nil && ! errors .Is (err , io .EOF ) {
149149 return fmt .Errorf ("failed to send 'done' signal for group [%d]: %w" , groupId , err )
150150 }
151151 // Wait for acknowledgment from the server
0 commit comments