Пример #1
0
        private static IFormatter ProcessCommand(Stream inputStream, Stream outputStream, int splitIndex, DateTime bootTime)
        {
            int isSqlUdf = SerDe.ReadInt(inputStream);

            logger.LogDebug("Is func Sql UDF = {0}", isSqlUdf);

            IFormatter formatter = new BinaryFormatter();
            UDFCommand command   = null;

            if (isSqlUdf == 0)
            {
                command = ProcessNonUdfCommand(inputStream, outputStream, splitIndex, bootTime, formatter, isSqlUdf);
            }
            else
            {
                command = ProcessUdfCommand(inputStream, outputStream, splitIndex, bootTime, formatter, isSqlUdf);
            }

            if (command != null)
            {
                command.Execute();
            }

            return(formatter);
        }
Пример #2
0
        private static UDFCommand ProcessNonUdfCommand(Stream inputStream, Stream outputStream, int splitIndex,
                                                       DateTime bootTime, IFormatter formatter, int isSqlUdf)
        {
            logger.LogDebug("Processing non-UDF command");
            int lengthOfCommandByteArray = SerDe.ReadInt(inputStream);

            logger.LogDebug("Command length: " + lengthOfCommandByteArray);

            UDFCommand command = null;

            if (lengthOfCommandByteArray > 0)
            {
                var commandProcessWatch = new Stopwatch();
                commandProcessWatch.Start();

                int              stageId;
                string           deserializerMode;
                string           serializerMode;
                CSharpWorkerFunc cSharpWorkerFunc;
                ReadCommand(inputStream, formatter, out stageId, out deserializerMode, out serializerMode,
                            out cSharpWorkerFunc);

                command = new UDFCommand(inputStream, outputStream, splitIndex, bootTime, deserializerMode,
                                         serializerMode, formatter, commandProcessWatch, isSqlUdf,
                                         new List <WorkerFunc>()
                {
                    new WorkerFunc(cSharpWorkerFunc, 0, null)
                }, stageId);
            }
            else
            {
                logger.LogWarn("lengthOfCommandByteArray = 0. Nothing to execute :-(");
            }

            return(command);
        }