@@ -19,7 +19,8 @@ import Nat64 "mo:base/Nat64";
1919import Nat "mo:base/Nat" ;
2020import Result "mo:base/Result" ;
2121import PipelinifyTypes "types" ;
22- import Candy "mo:candy" ;
22+ import Candy "mo:candy/types" ;
23+ import Workspace "mo:candy/workspace" ;
2324import Debug "mo:base/Debug" ;
2425import Buffer "mo:base/Buffer" ;
2526import Hash "mo:base/Hash" ;
@@ -200,7 +201,7 @@ module {
200201 case (null ){
201202 func _getLocalWorkspace(_hash : PipeInstanceID , _id : Nat , _request: ?PipelinifyTypes . ProcessRequest ) : Candy . Workspace {
202203 // just returns what it was given
203- return Candy . emptyWorkspace();
204+ return Workspace . emptyWorkspace();
204205
205206 }
206207 };
@@ -213,7 +214,7 @@ module {
213214 case (null ){
214215 func _putLocalWorkspacee(_hash : PipeInstanceID , _id : Nat , _workspace: Candy . Workspace , _request: ?PipelinifyTypes . ProcessRequest ) : Candy . Workspace {
215216 // just returns what it was given
216- return Candy . emptyWorkspace();
217+ return Workspace . emptyWorkspace();
217218
218219 }
219220 };
@@ -317,7 +318,7 @@ module {
317318 let dataWillBeReturnedResponse = onDataWillBeReturned(pipeInstanceID, finalData, ?_request);
318319 let processResponse =
319320 #dataIncluded{
320- payload = Candy . workspaceToAddressedChunkArray(finalData);
321+ payload = Workspace . workspaceToAddressedChunkArray(finalData);
321322 };
322323 let dataReturnedResponse : PipelinifyTypes . PipelineEventResponse = onDataReturned(pipeInstanceID, ?_request, ?processResponse);
323324
@@ -365,7 +366,7 @@ module {
365366 let pipeInstanceID = getPipeInstanceID(_request);
366367
367368 Debug . print("the process is on" );
368- var thisWorkspace = Candy . emptyWorkspace();
369+ var thisWorkspace = Workspace . emptyWorkspace();
369370
370371
371372
@@ -389,7 +390,7 @@ module {
389390 let dataWillLoadResponse = onDataWillBeLoaded(pipeInstanceID, ?_request);
390391 // todo: chunk data into workspace
391392
392- thisWorkspace := Candy . fromAddressedChunks(dataIncludedRequest. data);
393+ thisWorkspace := Workspace . fromAddressedChunks(dataIncludedRequest. data);
393394 Debug . print("workspace included" # debug_show (thisWorkspace. size()));
394395 let dataResponse : PipelinifyTypes . PipelineEventResponse = onDataReady(pipeInstanceID, thisWorkspace, ?_request);
395396 };
@@ -405,15 +406,15 @@ module {
405406 Debug . print("initilizing cache with no data" );
406407 workspaceCache. put(pipeInstanceID, {
407408 var status = #initialized;
408- data = Candy . emptyWorkspace();
409+ data = Workspace . emptyWorkspace();
409410 });
410411 bInitilized := true ;
411412 };
412413 case (?data){
413414 Debug . print("initilizing cache with data" );
414415 bInitilized := true ;
415416 bLoading := true ;
416- Candy . fileAddressedChunks(thisWorkspace, data);
417+ Workspace . fileAddressedChunks(thisWorkspace, data);
417418 chunkCount := 1 ;
418419 };
419420 };
@@ -472,18 +473,18 @@ module {
472473 case (#chunk(chunkData)){
473474 Debug . print("found some Data" );
474475 // dataChunks := Array.append<PipelinifyTypes.AddressedChunk>(dataChunks, Array.make<PipelinifyTypes.AddressedChunk>(chunkData));
475- Candy . fileAddressedChunks(thisWorkspace, chunkData);
476+ Workspace . fileAddressedChunks(thisWorkspace, chunkData);
476477 chunkCount := chunkCount + 1 ;
477478 };
478479 case (#eof(chunkData)){
479480 Debug . print("found some eof data" );
480- Candy . fileAddressedChunks(thisWorkspace, chunkData);
481+ Workspace . fileAddressedChunks(thisWorkspace, chunkData);
481482 chunkCount := chunkCount + 1 ;
482483 break dataRetrieve;
483484 };
484485 case (#parallel(chunkData)){
485486 Debug . print("found some parallel data" );
486- Candy . fileAddressedChunks(thisWorkspace, chunkData. 2 );
487+ Workspace . fileAddressedChunks(thisWorkspace, chunkData. 2 );
487488 chunkCount := chunkCount + 1 ;
488489 break dataRetrieve;
489490 };
@@ -516,7 +517,7 @@ module {
516517 // todo: maybe we require initialization
517518 workspaceCache. put(pipeInstanceID, {
518519 var status = #initialized;
519- data = Candy . emptyWorkspace();
520+ data = Workspace . emptyWorkspace();
520521 });
521522 return #ok(#intakeNeeded{
522523 pipeInstanceID = pipeInstanceID;
@@ -754,7 +755,7 @@ module {
754755 };
755756
756757 // Debug.print("chunk data " # debug_show(chunkData[1]) # debug_show(chunkData[2]) # debug_show(chunkData[3]) # debug_show(chunkData[4]) # debug_show(chunkData[5]));
757- Candy . fileAddressedChunks(thisCache. data, chunkData);
758+ Workspace . fileAddressedChunks(thisCache. data, chunkData);
758759 };
759760
760761
@@ -766,7 +767,7 @@ module {
766767 Debug . print("hit EOF Chunk" );
767768 thisCache. status := #doneLoading;
768769 // Debug.print("eof data " # debug_show(chunkData[1]) # debug_show(chunkData[2]) # debug_show(chunkData[3]) # debug_show(chunkData[4]) # debug_show(chunkData[5]) );
769- Candy . fileAddressedChunks(thisCache. data, chunkData);
770+ Workspace . fileAddressedChunks(thisCache. data, chunkData);
770771
771772 };
772773 case (#parallel(chunkData)){
@@ -776,7 +777,7 @@ module {
776777 let thisMap = Array . init< Bool > (chunkData. 1 ,false );
777778 thisMap[chunkData. 0 ] := true ;
778779 thisCache. status := #loading(chunkData. 0 , chunkData. 1 , Array . freeze< Bool > (thisMap));
779- Candy . fileAddressedChunks(thisCache. data, chunkData. 2 );
780+ Workspace . fileAddressedChunks(thisCache. data, chunkData. 2 );
780781 return #ok(#intakeNeeded{
781782 pipeInstanceID = _request. pipeInstanceID;
782783 currentChunks = chunkData. 0 ;
@@ -790,7 +791,7 @@ module {
790791 let thisMap = Array . thaw< Bool > (loadingVal. 2 );
791792 thisMap[chunkData. 0 ] := true ;
792793 thisCache. status := #loading(chunkData. 0 ,chunkData. 1 , Array . freeze< Bool > (thisMap));
793- Candy . fileAddressedChunks(thisCache. data, chunkData. 2 );
794+ Workspace . fileAddressedChunks(thisCache. data, chunkData. 2 );
794795 Debug . print("map is " # debug_show (thisMap));
795796 return #ok(#intakeNeeded{
796797 pipeInstanceID = _request. pipeInstanceID;
@@ -998,7 +999,7 @@ module {
998999 return #err({text= "Cannot find response Cache for ID" # Nat32 . toText(_request. pipeInstanceID); code= 13 ;});
9991000 };
10001001 case (?thisCache){
1001- let result = Candy . getWorkspaceChunk(thisCache. data, _request. chunkID, _request. chunkSize);
1002+ let result = Workspace . getWorkspaceChunk(thisCache. data, _request. chunkID, _request. chunkSize);
10021003 switch (result. 0 ){
10031004 case (#eof){
10041005 return #ok(#eof(result. 1 . toArray()));
0 commit comments