File tree Expand file tree Collapse file tree 3 files changed +15
-11
lines changed
packages/cubejs-schema-compiler/src/compiler Expand file tree Collapse file tree 3 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -8,24 +8,28 @@ export interface Cube {
88}
99
1010export class CubeDictionary implements TranspilerCubeResolver , CompilerInterface {
11- public byId : Record < string , Cube > ;
11+ private byId : Map < string , Cube > ;
1212
1313 public constructor ( ) {
14- this . byId = { } ;
14+ this . byId = new Map < string , Cube > ( ) ;
1515 }
1616
1717 public compile ( cubes : Cube [ ] , _errorReporter ?: ErrorReporter ) : void {
18- this . byId = { } ;
18+ this . byId = new Map < string , Cube > ( ) ;
1919 for ( const cube of cubes ) {
20- this . byId [ cube . name ] = cube ;
20+ this . byId . set ( cube . name , cube ) ;
2121 }
2222 }
2323
24- public resolveCube ( name : string ) : boolean {
25- return ! ! this . byId [ name ] ;
24+ public resolveCube ( name : string ) : Cube | undefined {
25+ return this . byId . get ( name ) ;
2626 }
2727
2828 public free ( ) : void {
29- this . byId = { } ;
29+ this . byId = new Map < string , Cube > ( ) ;
30+ }
31+
32+ public cubeNames ( ) : string [ ] {
33+ return Array . from ( this . byId . keys ( ) ) ;
3034 }
3135}
Original file line number Diff line number Diff line change @@ -560,7 +560,7 @@ export class DataSchemaCompiler {
560560 }
561561
562562 private prepareTranspileSymbols ( ) {
563- const cubeNames : string [ ] = Object . keys ( this . cubeDictionary . byId ) ;
563+ const cubeNames : string [ ] = this . cubeDictionary . cubeNames ( ) ;
564564 // We need only cubes and all its member names for transpiling.
565565 // Cubes doesn't change during transpiling, but are changed during compilation phase,
566566 // so we can prepare them once for every phase.
Original file line number Diff line number Diff line change @@ -8,12 +8,12 @@ export interface TranspilerInterface {
88}
99
1010export interface TranspilerSymbolResolver {
11- resolveSymbol ( cubeName , name ) : any ;
12- isCurrentCube ( name ) : boolean ;
11+ resolveSymbol ( cubeName : string | null | undefined , name : string ) : any ;
12+ isCurrentCube ( name : string ) : boolean ;
1313}
1414
1515export interface TranspilerCubeResolver {
16- resolveCube ( name ) : boolean ;
16+ resolveCube ( name : string ) : any ;
1717}
1818
1919export type SymbolResolver = ( name : string ) => any ;
You can’t perform that action at this time.
0 commit comments