Exemple #1
0
        public static ExecutionPlan Deserialize(BinaryReader input, FastAccessList <object> referenceTracking)
        {
            var ep = new ExecutionPlan();

            var nbVars = input.ReadInt32();

            for (var i = 0; i < nbVars; i++)
            {
                var id = input.ReadInt32();
                ep.Variables.Add((SqlVariable)referenceTracking[id]);
            }

            var nbInsertSteps = input.ReadInt32();

            for (var i = 0; i < nbInsertSteps; i++)
            {
                var step = InsertStep.Deserialize(input, referenceTracking);
                ep.InsertSteps.Add(step);
            }

            var nbUpdateSteps = input.ReadInt32();

            for (var i = 0; i < nbUpdateSteps; i++)
            {
                var step = UpdateStep.Deserialize(input);
                ep.UpdateSteps.Add(step);
            }

            return(ep);
        }
Exemple #2
0
        public static InsertStep Deserialize(BinaryReader input, FastAccessList <object> referenceTracking)
        {
            var bf   = SerializationHelper.DefaultFormatter;
            var step = new InsertStep();

            step.StepId           = input.ReadInt32();
            step.Depth            = input.ReadInt32();
            step.SourceTable      = TableIdentifier.Deserialize(input);
            step.DestinationTable = TableIdentifier.Deserialize(input);

            //Variable
            var nbVars = input.ReadInt32();

            for (int i = 0; i < nbVars; i++)
            {
                var id = input.ReadInt32();
                step.Variables.Add((SqlVariable)referenceTracking[id]);
            }

            //TableSchema
            var tsId = input.ReadInt32();

            step.TableSchema = (TableMetadata)referenceTracking[tsId];

            //Datarow
            var nbRows = input.ReadInt32();

            step.Datarow = new object[nbRows];
            for (var i = 0; i < nbRows; i++)
            {
                var tag  = input.ReadInt32();
                var type = SerializationHelper.TagToType[tag];

                if (type == typeof(SqlVariable))
                {
                    var id = input.ReadInt32();
                    step.Datarow[i] = referenceTracking[id];
                }
                else
                {
                    step.Datarow[i] = bf.Deserialize(input.BaseStream);
                }
            }

            return(step);
        }