Class ModelCheckpoints


  • public class ModelCheckpoints
    extends Object
    All checkpoint models known for (associated with) the given original model.
    Since:
    3.3
    • Method Detail

      • find

        @Nullable
        public CheckpointState find​(@NotNull
                                    ModelGenerationPlan.Checkpoint targetPoint)
        Retrieve state that corresponds to transition between specified checkpoints. Starting checkpoint is optional, original input model is assumed to be 'checkpoint' in this case. FIXME perhaps, shall have a distinct Checkpoint to indicate initial model (don't want to keep the model in transients, though and OTOH don't want to tell whether there's a model for Checkpoint based on special Checkpoint instance.
        Returns:
        null if no saved state for the point found
      • findCopiedNode

        @Nullable
        public SNode findCopiedNode​(@NotNull
                                    CheckpointIdentity tp,
                                    @NotNull
                                    SNode inputNode)
        Two models are transformed independently and their generation plans not necessarily identical. The moment we'd like to get output for a certain target node, the node may belong to any earlier checkpoint of a target model, not necessarily immediately preceding one. Most common scenario is that target node (here, inputNode) points to original model, M2, which has gone through few transformation steps, CP1->CP2->CP3, and we'd like to get CP3 output given original M2 node. CP3 records its inputs as known at CP2, and we need to traverse back to CP1 and original model to find out matching node, and then traverse back, assuming node was merely copied between CP1 and CP2. FIXME In fact, need both CheckpointState for tp and SNode as return values, perhaps worth extracting into a separate class which keeps both values as internal state, rather than obtaining it twice. Besides, separate class may hide assumption inputNode comes from same model this object has been constructed for.
        Parameters:
        tp - checkpoint we'd like to get copied output for
        inputNode - a node from one of previous checkpoints (including original model). This {@code {@link ModelCheckpoints} has to be obtained for the node's model.
        Returns:
        outputNode a node in CP identified by tp representing a copy of supplied inputNode
      • findTransformedNode

        @Nullable
        public SNode findTransformedNode​(@NotNull
                                         CheckpointIdentity tp,
                                         @NotNull
                                         SNode inputNode,
                                         String mappingLabel)
        With inputNode coming from one of CP previous to the supplied one, try to find a copy of an input node in a preceding CP, use it as a 'proper' input to retrieve transformed value, and trace this value, if any, up to the target CP.
        Parameters:
        tp - target checkpoint
        inputNode -
        mappingLabel -
        Returns:
        output node from checkpoint model tp of a labeled transformation, or its copy in there, if any.