Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

36
LINES

< > BotCompany Repo | #1030881 // quickImportMainConcepts

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (15613L/101K).

1  
// assumes main concepts are empty before
2  
// only works when you call db() afterwards
3  
svoid quickImportMainConcepts(virtual Concepts oldConcepts, IF0<Bool> enabled default null) {
4  
  if (!shortNameIs(oldConcepts, "Concepts")) ret;
5  
  Concepts concepts = db_mainConcepts();
6  
  concepts.miscMapPut("dbGrabber", func -> Bool {
7  
    concepts.miscMapRemove("dbGrabber");
8  
    pcall {
9  
      if (isFalse(callF(enabled))) false;
10  
      concepts.idCounter = getLong idCounter(oldConcepts);
11  
      printVars_str(idCounter := concepts.idCounter);
12  
      Map<Long, virtual Concept> oldMap = cast _get concepts(oldConcepts);
13  
      printVars_str(+oldMap);
14  
      
15  
      new RealmCopy rc;
16  
      rc.nonTransientOnly = true;
17  
      rc.fullCopy = true;
18  
      rc.overrideCollectionOrMapCopy = o -> {
19  
        rc.classMap.put(_getClass(o), _getClass(o));
20  
        false;
21  
      };
22  
      
23  
      {
24  
        temp tempSetTL(dynamicObjectIsLoading_threadLocal(), true);
25  
        concepts.concepts.putAll((Map<Long, Concept>) rc.copy(oldMap));
26  
      }
27  
      pnl("quickImportDB", mapSortedByFunctionOnKey str(rc.classMap));
28  
      
29  
      // Note: this calls _doneLoading2() on all concepts
30  
      concepts.assignConceptsToUs();
31  
      print(nConcepts(countConcepts()) + " quick-imported");
32  
      true;
33  
    }
34  
    false;
35  
  });
36  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030881
Snippet name: quickImportMainConcepts
Eternal ID of this version: #1030881/15
Text MD5: 2d32c6bf174a92a9ec2734f73dbebc86
Transpilation MD5: 13cb40f25fa1e8633d3b2820e00f8c30
Author: stefan
Category: javax / concepts
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-24 06:14:43
Source code size: 1316 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 132 / 234
Version history: 14 change(s)
Referenced in: [show references]