66 Manager ,
77 ExaSchema ,
88} from "./primitives/classes.ts" ;
9- import { getComputedUsage } from "./primitives/functions.ts" ;
109
1110export class Exabase {
1211 private dbDir : string ;
@@ -27,29 +26,23 @@ export class Exabase {
2726 }
2827
2928 //? this is a function that creates/updates schemas also adjusting RCT memory
30- public async _induce ( schema : ExaSchema < any > ) {
29+ public async induce ( schema : ExaSchema < any > ) {
3130 if ( ! ( schema instanceof ExaSchema ) ) {
3231 throw new Error ( "invalid object passed as exabase schema" ) ;
3332 }
3433 this . schemas . push ( schema ) ;
3534 // ? setup rct level
36- const BEST_RCT_LEVEL_PER_MANAGER = getComputedUsage (
37- GLOBAL_OBJECT . MEMORY_PERCENT ,
38- this . schemas . length || 10
39- ) ;
4035 //? setup managers
4136 GLOBAL_OBJECT . EXABASE_MANAGERS [ schema ?. table ! ] = new Manager ( schema ) ;
4237 // ? setup relationships
43- await GLOBAL_OBJECT . EXABASE_MANAGERS [ schema ?. table ! ] . _setup ( {
44- _exabaseDirectory : this . dbDir ,
38+ await GLOBAL_OBJECT . EXABASE_MANAGERS [ schema ?. table ! ] . setup ( {
39+ exabaseDirectory : this . dbDir ,
4540 schemas : this . schemas ,
4641 } ) ;
4742 await GLOBAL_OBJECT . EXABASE_MANAGERS [ schema ?. table ! ] . _synchronize ( ) ;
4843 //? update query makers and RCT level per manager
49- this . schemas . forEach ( ( schema ) => {
50- GLOBAL_OBJECT . EXABASE_MANAGERS [ schema ?. table ! ] . rct_level =
51- BEST_RCT_LEVEL_PER_MANAGER > 5 ? BEST_RCT_LEVEL_PER_MANAGER : 5 ;
52- } ) ;
44+ const rct_level = Math . round ( 150 / this . schemas . length ) ;
45+ GLOBAL_OBJECT . rct_level = rct_level > 5 ? rct_level : 5 ;
5346 GLOBAL_OBJECT . EXABASE_MANAGERS [ schema ?. table ! ] . isActive = true ;
5447 }
5548 async query < T = any > ( query : string ) : Promise < T > {
@@ -72,7 +65,7 @@ export class Exabase {
7265 i -= 1 ;
7366 if ( table . isActive === true ) {
7467 clearInterval ( id ) ;
75- r ( table . _trx_runner ( parsedQuery ) as T ) ;
68+ r ( table . runner ( parsedQuery ) as T ) ;
7669 }
7770 if ( i === 0 ) {
7871 clearInterval ( id ) ;
@@ -85,6 +78,6 @@ export class Exabase {
8578 }
8679 throw new ExaError ( "unknown table '" + parsedQuery . table + "'" ) ;
8780 }
88- return table . _trx_runner ( parsedQuery ) as T ;
81+ return table . runner ( parsedQuery ) as T ;
8982 }
9083}
0 commit comments