korlov42 commented on code in PR #7333:
URL: https://github.com/apache/ignite-3/pull/7333#discussion_r2654905947


##########
modules/system-view/src/main/java/org/apache/ignite/internal/systemview/SystemViewManagerImpl.java:
##########
@@ -256,30 +267,223 @@ private static Map<String, ScannableView<?>> 
toScannableViews(String localNodeNa
     private static class ScannableView<T> {
         private final Publisher<InternalTuple> publisher;
 
-        private ScannableView(String localNodeName, SystemView<T> view) {
-            BinaryTupleSchema schema = tupleSchemaForView(view);
+        private ScannableView(ViewRowFactory rowFactory, SystemView<T> view) {
+            this.publisher = new TransformingPublisher<>(view.dataProvider(), 
object -> rowFactory.create(view, object));
+        }
 
-            this.publisher = new TransformingPublisher<>(view.dataProvider(), 
object -> {
-                BinaryTupleBuilder builder = new 
BinaryTupleBuilder(schema.elementCount());
+        Publisher<InternalTuple> scan() {
+            return publisher;
+        }
+    }
 
-                int offset = 0;
-                if (view instanceof NodeSystemView) {
-                    builder.appendString(localNodeName);
-                    offset++;
-                }
+    private abstract static class ViewRowFactory {
+        abstract <ViewSourceT> InternalTuple create(SystemView<ViewSourceT> 
view, ViewSourceT source);
+    }
 
-                for (int i = 0; i < view.columns().size(); i++) {
-                    SystemViewColumn<T, ?> column = view.columns().get(i);
+    private static class NodeViewRowFactory extends ViewRowFactory {
+        private final String nodeName;
 
-                    schema.appendValue(builder, i + offset, 
column.value().apply(object));
-                }
+        private NodeViewRowFactory(String nodeName) {
+            this.nodeName = nodeName;
+        }
 
-                return new BinaryTuple(schema.elementCount(), builder.build());
-            });
+        @Override
+        <ViewSourceT> InternalTuple create(SystemView<ViewSourceT> view, 
ViewSourceT source) {
+            return new NodeViewRow<>(nodeName, view, source);
         }
+    }
 
-        Publisher<InternalTuple> scan() {
-            return publisher;
+    private static class ClusterViewRowFactory extends ViewRowFactory {
+        private static final ViewRowFactory INSTANCE = new 
ClusterViewRowFactory();
+
+        @Override
+        <ViewSourceT> InternalTuple create(SystemView<ViewSourceT> view, 
ViewSourceT source) {
+            return new ClusterViewRow<>(view, source);
         }
     }

Review Comment:
   it's nice to have indeed, but not required. I believe the purpose is clear, 
so I ignore this comment



-- 
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