Exemplo n.º 1
0
        private void Compile()
        {
            if (DataContext == null)
            {
                throw ExceptionBuilder.PropertyNotInitialized("DataContext");
            }

            if (Text == null || Text.Length == 0)
            {
                throw ExceptionBuilder.PropertyNotInitialized("Text");
            }

            // Compile query

            ClearCompiledState();
            Compiler compiler = new Compiler(_errorCollector);

            _resultAlgebraNode = compiler.CompileQuery(Text, Scope);

            if (_errorCollector.ErrorsSeen)
            {
                IList <CompilationError> errors = _errorCollector.GetErrors();
                OnCompilationFailed(new CompilationFailedEventArgs(errors));
                throw ExceptionBuilder.QueryCompilationFailed(errors);
            }

            OnCompilationSucceeded(EventArgs.Empty);
            _resultIterator = IteratorCreator.Convert(DataContext.MetadataContext, true, _resultAlgebraNode);
        }
Exemplo n.º 2
0
        public override AlgebraNode VisitResultAlgebraNode(ResultAlgebraNode node)
        {
            ResultIterator resultIterator = new ResultIterator();

            resultIterator.RowBuffer   = new object[node.OutputList.Length];
            resultIterator.Input       = ConvertAlgebraNode(node.Input);
            resultIterator.InputOutput = new IteratorOutput[node.OutputList.Length];
            resultIterator.ColumnNames = new string[node.OutputList.Length];
            resultIterator.ColumnTypes = new Type[node.OutputList.Length];
            for (int i = 0; i < node.OutputList.Length; i++)
            {
                IteratorOutput iteratorOutput = new IteratorOutput();
                iteratorOutput.SourceIndex    = Array.IndexOf(node.Input.OutputList, node.OutputList[i]);
                iteratorOutput.TargetIndex    = i;
                resultIterator.InputOutput[i] = iteratorOutput;
                resultIterator.ColumnNames[i] = node.ColumnNames[i];
                resultIterator.ColumnTypes[i] = node.OutputList[i].DataType;
            }
            SetLastIterator(node, resultIterator);

            return(node);
        }
Exemplo n.º 3
0
        public static ResultIterator Convert(MetadataContext metadataContext, bool includeStatistics, ResultAlgebraNode resultAlgebraNode)
        {
            IteratorCreator iteratorCreator = new IteratorCreator(metadataContext, includeStatistics);
            Iterator        iterator        = iteratorCreator.ConvertAlgebraNode(resultAlgebraNode);

            ILEmitContext.CompleteILCompilation();

            if (includeStatistics)
            {
                return((ResultIterator)((StatisticsIterator)iterator).Input);
            }

            return((ResultIterator)iterator);
        }
Exemplo n.º 4
0
 protected override void ClearCompiledState()
 {
     _resultAlgebraNode = null;
     _resultIterator    = null;
     _errorCollector.Reset();
 }