@@ -75,8 +75,6 @@ public static <T> T make(Class<T> baseClass, ColumnSource<?>[] tableKeySources,
75
75
targetLoadFactor );
76
76
}
77
77
78
-
79
-
80
78
/**
81
79
* Produce a hasher for a NaturalJoin base class and column sources while specifying the {@link NaturalJoinType join
82
80
* type} and whether the right hand side is add-only.
@@ -130,29 +128,8 @@ public static <T> T makeNaturalJoin(Class<T> baseClass, ColumnSource<?>[] tableK
130
128
}
131
129
}
132
130
133
- final ChunkType [] chunkTypes =
134
- Arrays .stream (tableKeySources ).map (ColumnSource ::getChunkType ).toArray (ChunkType []::new );
135
- final String className = hasherName (hasherConfig , chunkTypes );
136
-
137
- JavaFile javaFile = generateHasher (hasherConfig , chunkTypes , className , Optional .of (Modifier .PUBLIC ));
138
-
139
- String [] javaStrings = javaFile .toString ().split ("\n " );
140
- final String javaString =
141
- Arrays .stream (javaStrings ).filter (s -> !s .startsWith ("package " )).collect (Collectors .joining ("\n " ));
142
-
143
- final Class <?> clazz = ExecutionContext .getContext ().getQueryCompiler ().compile (QueryCompilerRequest .builder ()
144
- .description ("TypedHasherFactory: " + className )
145
- .className (className )
146
- .classBody (javaString )
147
- .packageNameRoot ("io.deephaven.engine.table.impl.by.typed." + hasherConfig .packageMiddle + ".gen" )
148
- .build ());
149
-
150
- if (!hasherConfig .baseClass .isAssignableFrom (clazz )) {
151
- throw new IllegalStateException ("Generated class is not a " + hasherConfig .baseClass .getCanonicalName ());
152
- }
153
-
154
131
// noinspection unchecked
155
- final Class <? extends T > castedClass = (Class <? extends T >) clazz ;
132
+ final Class <? extends T > castedClass = (Class <? extends T >) generateClass ( tableKeySources , hasherConfig ) ;
156
133
157
134
T retVal ;
158
135
try {
@@ -599,6 +576,25 @@ public static <T> T make(HasherConfig<T> hasherConfig, ColumnSource<?>[] tableKe
599
576
}
600
577
}
601
578
579
+ // noinspection unchecked
580
+ final Class <? extends T > castedClass = (Class <? extends T >) generateClass (tableKeySources , hasherConfig );
581
+
582
+ T retVal ;
583
+ try {
584
+ final Constructor <? extends T > constructor1 =
585
+ castedClass .getDeclaredConstructor (ColumnSource [].class , ColumnSource [].class , int .class ,
586
+ double .class , double .class );
587
+ retVal = constructor1 .newInstance (tableKeySources , originalKeySources , tableSize , maximumLoadFactor ,
588
+ targetLoadFactor );
589
+ } catch (InstantiationException | IllegalAccessException | InvocationTargetException
590
+ | NoSuchMethodException e ) {
591
+ throw new UncheckedDeephavenException ("Could not instantiate " + castedClass .getCanonicalName (), e );
592
+ }
593
+ return retVal ;
594
+ }
595
+
596
+ @ NotNull
597
+ private static <T > Class <?> generateClass (ColumnSource <?>[] tableKeySources , HasherConfig <T > hasherConfig ) {
602
598
final ChunkType [] chunkTypes =
603
599
Arrays .stream (tableKeySources ).map (ColumnSource ::getChunkType ).toArray (ChunkType []::new );
604
600
final String className = hasherName (hasherConfig , chunkTypes );
@@ -619,22 +615,7 @@ public static <T> T make(HasherConfig<T> hasherConfig, ColumnSource<?>[] tableKe
619
615
if (!hasherConfig .baseClass .isAssignableFrom (clazz )) {
620
616
throw new IllegalStateException ("Generated class is not a " + hasherConfig .baseClass .getCanonicalName ());
621
617
}
622
-
623
- // noinspection unchecked
624
- final Class <? extends T > castedClass = (Class <? extends T >) clazz ;
625
-
626
- T retVal ;
627
- try {
628
- final Constructor <? extends T > constructor1 =
629
- castedClass .getDeclaredConstructor (ColumnSource [].class , ColumnSource [].class , int .class ,
630
- double .class , double .class );
631
- retVal = constructor1 .newInstance (tableKeySources , originalKeySources , tableSize , maximumLoadFactor ,
632
- targetLoadFactor );
633
- } catch (InstantiationException | IllegalAccessException | InvocationTargetException
634
- | NoSuchMethodException e ) {
635
- throw new UncheckedDeephavenException ("Could not instantiate " + castedClass .getCanonicalName (), e );
636
- }
637
- return retVal ;
618
+ return clazz ;
638
619
}
639
620
640
621
@ NotNull
0 commit comments