sergey-chugunov-1985 commented on code in PR #12362:
URL: https://github.com/apache/ignite/pull/12362#discussion_r2372011693


##########
modules/binary/api/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java:
##########
@@ -38,6 +38,9 @@ public class GridBinaryMarshaller {
     private static final ThreadLocal<BinaryContextHolder> BINARY_CTX =
         ThreadLocal.withInitial(BinaryContextHolder::new);
 
+    /** Binary context supplier. */
+    private static Supplier<BinaryContext> BINARY_CTX_SUPPLIER;

Review Comment:
   I have an idea for the future of how to get rid of this supplier.
   
   I scanned the code and found that 
`IgnitionEx.localIgnite().context().cacheObjects().binaryContext()` call 
returns the same instance of `BinaryContext` as arrives to 
`GridBinaryMarshaller` constructor.
   
   So we could replace this vague trick with supplier initialized from 
KernalContext implementations with a static atomic reference which we set from 
the constructor.
   
   But ultimately one would want to see this static `BINARY_CTX` stuff 
refactored to BinaryUtils or to some separate component.



##########
modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java:
##########
@@ -2758,18 +2756,19 @@ public static void clearCache() {
     /**
      * Gets the schema.
      *
-     * @param cacheObjProc Cache object processor.
+     * @param ctx Binary context.
+     * @param metadataProvider Function to provide binary type metadata.
      * @param typeId Type id.
      * @param schemaId Schema id.
      */
-    public static int[] getSchema(IgniteCacheObjectProcessor cacheObjProc, int 
typeId, int schemaId) {
-        assert cacheObjProc != null;
+    public static int[] getSchema(BinaryContext ctx, IntFunction<BinaryType> 
metadataProvider, int typeId, int schemaId) {
+        assert ctx != null;
 
-        BinarySchemaRegistry schemaReg = 
cacheObjProc.binaryContext().schemaRegistry(typeId);
+        BinarySchemaRegistry schemaReg = ctx.schemaRegistry(typeId);
         BinarySchema schema = schemaReg.schema(schemaId);
 
         if (schema == null) {
-            BinaryTypeImpl meta = 
(BinaryTypeImpl)cacheObjProc.metadata(typeId);
+            BinaryTypeImpl meta = 
(BinaryTypeImpl)metadataProvider.apply(typeId);

Review Comment:
   I think you could use `BinaryContext#metadata` method to obtain 
`BinaryTypeImpl` here. From what I see call to `BinaryContext#metadata` goes 
exactly to `cacheObjProc#metadata(int)` in the end. If this is true then we 
don't need `metadataProvider` parameter at all.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to